1/* 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18#include "config.h" 19#include "SuggestionBoxElement.h" 20 21#include "Frame.h" 22#include "HTMLNames.h" 23#include "MouseEvent.h" 24#include "SuggestionBoxHandler.h" 25#include "TouchEvent.h" 26 27namespace WebCore { 28 29SuggestionBoxElement::SuggestionBoxElement(SuggestionBoxHandler* element, String& value, const QualifiedName& name, Document* document) 30 : HTMLDivElement(name, document) 31 , m_suggestionBox(element) 32 , m_value(value) 33{ 34} 35 36SuggestionBoxElement::~SuggestionBoxElement() 37{ 38} 39 40PassRefPtr<SuggestionBoxElement> SuggestionBoxElement::create(SuggestionBoxHandler* element, String& value, Document* document) 41{ 42 return adoptRef(new SuggestionBoxElement(element, value, HTMLNames::divTag, document)); 43} 44 45void SuggestionBoxElement::defaultEventHandler(Event* event) 46{ 47 if (event->isMouseEvent()) { 48 // Capture a mouse down event with left click and set the parent input element to the node's text 49 if (event->type() == eventNames().mousedownEvent && static_cast<MouseEvent*>(event)->button() != RightButton && document()->frame()) { 50 m_suggestionBox->changeInputElementInnerTextValue(m_value); 51 m_suggestionBox->hideDropdownBox(); 52 } 53 } 54} 55 56} /* namespace WebCore */ 57