Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: Source/core/html/HTMLSelectElement.cpp

Issue 211093004: Tapping <select multiple> option toggles selection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698