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

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
« no previous file with comments | « LayoutTests/fast/forms/select/listbox-tap-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLSelectElement.cpp
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index ed9942c1b431faf10bf5242adf2dab270549dd4b..8c9a708a0f5b101082a535ee5c0fbdaec895fab8 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,22 @@ 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);
+ 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();
+ }
+ } 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())
« no previous file with comments | « LayoutTests/fast/forms/select/listbox-tap-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698