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

Side by Side Diff: Source/core/html/HTMLLabelElement.cpp

Issue 291243002: Never ignore HTMLLabelElement's click() calls (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Click may be not a mouse event Created 6 years, 7 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
« no previous file with comments | « LayoutTests/fast/forms/label/label-click-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 10 matching lines...) Expand all
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "core/html/HTMLLabelElement.h" 26 #include "core/html/HTMLLabelElement.h"
27 27
28 #include "HTMLNames.h" 28 #include "HTMLNames.h"
29 #include "core/dom/ElementTraversal.h" 29 #include "core/dom/ElementTraversal.h"
30 #include "core/editing/FrameSelection.h" 30 #include "core/editing/FrameSelection.h"
31 #include "core/events/Event.h" 31 #include "core/events/MouseEvent.h"
32 #include "core/frame/LocalFrame.h" 32 #include "core/frame/LocalFrame.h"
33 #include "core/html/FormAssociatedElement.h" 33 #include "core/html/FormAssociatedElement.h"
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 using namespace HTMLNames; 37 using namespace HTMLNames;
38 38
39 static bool supportsLabels(const Element& element) 39 static bool supportsLabels(const Element& element)
40 { 40 {
41 if (!element.isHTMLElement()) 41 if (!element.isHTMLElement())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 node = node->parentOrShadowHostNode(); 131 node = node->parentOrShadowHostNode();
132 } 132 }
133 return false; 133 return false;
134 } 134 }
135 135
136 void HTMLLabelElement::defaultEventHandler(Event* evt) 136 void HTMLLabelElement::defaultEventHandler(Event* evt)
137 { 137 {
138 static bool processingClick = false; 138 static bool processingClick = false;
139 139
140 if (evt->type() == EventTypeNames::click && !processingClick) { 140 if (evt->type() == EventTypeNames::click && !processingClick) {
141 // If text of label element is selected, do not pass 141 // If the click is not simulated and the text of label element is
142 // the event to control element. 142 // selected, do not pass the event to control element.
143 if (document().frame()->selection().selection().isRange()) 143 // Note: a click event may be not a mouse event if created by
144 // document.createEvent().
145 if (evt->isMouseEvent() && !toMouseEvent(evt)->isSimulated() && document ().frame()->selection().selection().isRange())
144 return; 146 return;
145 147
146 RefPtrWillBeRawPtr<HTMLElement> element = control(); 148 RefPtrWillBeRawPtr<HTMLElement> element = control();
147 149
148 // If we can't find a control or if the control received the click 150 // If we can't find a control or if the control received the click
149 // event, then there's no need for us to do anything. 151 // event, then there's no need for us to do anything.
150 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev t->target()->toNode()))) 152 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev t->target()->toNode())))
151 return; 153 return;
152 154
153 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) 155 if (evt->target() && isInInteractiveContent(evt->target()->toNode()))
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 191
190 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) 192 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents)
191 { 193 {
192 if (HTMLElement* element = control()) 194 if (HTMLElement* element = control())
193 element->accessKeyAction(sendMouseEvents); 195 element->accessKeyAction(sendMouseEvents);
194 else 196 else
195 HTMLElement::accessKeyAction(sendMouseEvents); 197 HTMLElement::accessKeyAction(sendMouseEvents);
196 } 198 }
197 199
198 } // namespace 200 } // namespace
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/label/label-click-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698