Chromium Code Reviews| Index: Source/core/html/HTMLSelectElement.cpp |
| diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp |
| index ed9942c1b431faf10bf5242adf2dab270549dd4b..b88fe8656b1d7d850d195da8e0e822c1412cc1ff 100644 |
| --- a/Source/core/html/HTMLSelectElement.cpp |
| +++ b/Source/core/html/HTMLSelectElement.cpp |
| @@ -36,6 +36,7 @@ |
| #include "core/dom/Attribute.h" |
| #include "core/dom/ElementTraversal.h" |
| #include "core/dom/NodeTraversal.h" |
| +#include "core/events/GestureEvent.h" |
| #include "core/events/KeyboardEvent.h" |
| #include "core/events/MouseEvent.h" |
| #include "core/events/ThreadLocalEventNames.h" |
| @@ -1320,7 +1321,23 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event) |
| { |
| const Vector<HTMLElement*>& listItems = this->listItems(); |
| bool dragSelection = false; |
| - if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) { |
| + if (event->type() == EventTypeNames::gesturetap && event->isGestureEvent()) { |
| + focus(); |
| + // Calling focus() may cause us to lose our renderer or change the render type, in which case do not want to handle the event. |
| + if (!renderer() || !renderer()->isListBox()) |
| + return; |
| + |
| + // Convert to coords relative to the list box if needed. |
| + GestureEvent* gestureEvent = toGestureEvent(event); |
|
tkent
2014/03/26 03:21:32
Because we can assume event is not null, we can us
keishi
2014/03/26 09:16:27
Done.
|
| + IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(gestureEvent->absoluteLocation(), UseTransforms)); |
| + int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize(localOffset)); |
| + if (listIndex >= 0) { |
| + if (!isDisabledFormControl()) |
| + updateSelectedState(listIndex, true, gestureEvent->shiftKey()); |
| + event->setDefaultHandled(); |
| + } |
| + event->setDefaultHandled(); |
|
tkent
2014/03/26 03:21:32
You call setDefaultHandled twice.
keishi
2014/03/26 09:16:27
Done.
|
| + } else if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && toMouseEvent(event)->button() == LeftButton) { |
| focus(); |
| // Calling focus() may cause us to lose our renderer, in which case do not want to handle the event. |
| if (!renderer()) |