OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
10 * | 10 * |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "core/html/HTMLSelectElement.h" | 29 #include "core/html/HTMLSelectElement.h" |
30 | 30 |
31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
32 #include "bindings/v8/ExceptionMessages.h" | 32 #include "bindings/v8/ExceptionMessages.h" |
33 #include "bindings/v8/ExceptionState.h" | 33 #include "bindings/v8/ExceptionState.h" |
34 #include "bindings/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/v8/ExceptionStatePlaceholder.h" |
35 #include "core/accessibility/AXObjectCache.h" | 35 #include "core/accessibility/AXObjectCache.h" |
36 #include "core/dom/Attribute.h" | 36 #include "core/dom/Attribute.h" |
37 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
38 #include "core/dom/NodeTraversal.h" | 38 #include "core/dom/NodeTraversal.h" |
| 39 #include "core/events/GestureEvent.h" |
39 #include "core/events/KeyboardEvent.h" | 40 #include "core/events/KeyboardEvent.h" |
40 #include "core/events/MouseEvent.h" | 41 #include "core/events/MouseEvent.h" |
41 #include "core/events/ThreadLocalEventNames.h" | 42 #include "core/events/ThreadLocalEventNames.h" |
42 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
43 #include "core/html/FormDataList.h" | 44 #include "core/html/FormDataList.h" |
44 #include "core/html/HTMLFormElement.h" | 45 #include "core/html/HTMLFormElement.h" |
45 #include "core/html/HTMLOptionElement.h" | 46 #include "core/html/HTMLOptionElement.h" |
46 #include "core/html/forms/FormController.h" | 47 #include "core/html/forms/FormController.h" |
47 #include "core/page/EventHandler.h" | 48 #include "core/page/EventHandler.h" |
48 #include "core/page/SpatialNavigation.h" | 49 #include "core/page/SpatialNavigation.h" |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 setActiveSelectionAnchorIndex(listIndex); | 1314 setActiveSelectionAnchorIndex(listIndex); |
1314 | 1315 |
1315 setActiveSelectionEndIndex(listIndex); | 1316 setActiveSelectionEndIndex(listIndex); |
1316 updateListBoxSelection(!multiSelect); | 1317 updateListBoxSelection(!multiSelect); |
1317 } | 1318 } |
1318 | 1319 |
1319 void HTMLSelectElement::listBoxDefaultEventHandler(Event* event) | 1320 void HTMLSelectElement::listBoxDefaultEventHandler(Event* event) |
1320 { | 1321 { |
1321 const Vector<HTMLElement*>& listItems = this->listItems(); | 1322 const Vector<HTMLElement*>& listItems = this->listItems(); |
1322 bool dragSelection = false; | 1323 bool dragSelection = false; |
1323 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t
oMouseEvent(event)->button() == LeftButton) { | 1324 if (event->type() == EventTypeNames::gesturetap && event->isGestureEvent())
{ |
| 1325 focus(); |
| 1326 // Calling focus() may cause us to lose our renderer or change the rende
r type, in which case do not want to handle the event. |
| 1327 if (!renderer() || !renderer()->isListBox()) |
| 1328 return; |
| 1329 |
| 1330 // Convert to coords relative to the list box if needed. |
| 1331 GestureEvent& gestureEvent = toGestureEvent(*event); |
| 1332 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(gestu
reEvent.absoluteLocation(), UseTransforms)); |
| 1333 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize
(localOffset)); |
| 1334 if (listIndex >= 0) { |
| 1335 if (!isDisabledFormControl()) |
| 1336 updateSelectedState(listIndex, true, gestureEvent.shiftKey()); |
| 1337 event->setDefaultHandled(); |
| 1338 } |
| 1339 } else if (event->type() == EventTypeNames::mousedown && event->isMouseEvent
() && toMouseEvent(event)->button() == LeftButton) { |
1324 focus(); | 1340 focus(); |
1325 // Calling focus() may cause us to lose our renderer, in which case do n
ot want to handle the event. | 1341 // Calling focus() may cause us to lose our renderer, in which case do n
ot want to handle the event. |
1326 if (!renderer()) | 1342 if (!renderer()) |
1327 return; | 1343 return; |
1328 | 1344 |
1329 // Convert to coords relative to the list box if needed. | 1345 // Convert to coords relative to the list box if needed. |
1330 MouseEvent* mouseEvent = toMouseEvent(event); | 1346 MouseEvent* mouseEvent = toMouseEvent(event); |
1331 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouse
Event->absoluteLocation(), UseTransforms)); | 1347 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouse
Event->absoluteLocation(), UseTransforms)); |
1332 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize
(localOffset)); | 1348 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize
(localOffset)); |
1333 if (listIndex >= 0) { | 1349 if (listIndex >= 0) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 { | 1634 { |
1619 return true; | 1635 return true; |
1620 } | 1636 } |
1621 | 1637 |
1622 bool HTMLSelectElement::supportsAutofocus() const | 1638 bool HTMLSelectElement::supportsAutofocus() const |
1623 { | 1639 { |
1624 return true; | 1640 return true; |
1625 } | 1641 } |
1626 | 1642 |
1627 } // namespace | 1643 } // namespace |
OLD | NEW |