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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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);
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.
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 event->setDefaultHandled();
tkent 2014/03/26 03:21:32 You call setDefaultHandled twice.
keishi 2014/03/26 09:16:27 Done.
1340 } else if (event->type() == EventTypeNames::mousedown && event->isMouseEvent () && toMouseEvent(event)->button() == LeftButton) {
1324 focus(); 1341 focus();
1325 // Calling focus() may cause us to lose our renderer, in which case do n ot want to handle the event. 1342 // Calling focus() may cause us to lose our renderer, in which case do n ot want to handle the event.
1326 if (!renderer()) 1343 if (!renderer())
1327 return; 1344 return;
1328 1345
1329 // Convert to coords relative to the list box if needed. 1346 // Convert to coords relative to the list box if needed.
1330 MouseEvent* mouseEvent = toMouseEvent(event); 1347 MouseEvent* mouseEvent = toMouseEvent(event);
1331 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouse Event->absoluteLocation(), UseTransforms)); 1348 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouse Event->absoluteLocation(), UseTransforms));
1332 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize (localOffset)); 1349 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize (localOffset));
1333 if (listIndex >= 0) { 1350 if (listIndex >= 0) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 { 1635 {
1619 return true; 1636 return true;
1620 } 1637 }
1621 1638
1622 bool HTMLSelectElement::supportsAutofocus() const 1639 bool HTMLSelectElement::supportsAutofocus() const
1623 { 1640 {
1624 return true; 1641 return true;
1625 } 1642 }
1626 1643
1627 } // namespace 1644 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698