OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 select ed, do not pass |
tkent
2014/05/21 00:35:49
nit: Please wrap a comment line in 80-columns.
Xianzhu
2014/05/21 15:58:53
Done.
| |
142 // the event to control element. | 142 // the event to control element. |
143 if (document().frame()->selection().selection().isRange()) | 143 if (!static_cast<MouseEvent*>(evt)->isSimulated() && document().frame()- >selection().selection().isRange()) |
tkent
2014/05/21 00:35:49
Pease use toMouseEvent(evt) instead of static_cast
Xianzhu
2014/05/21 15:58:53
Done.
| |
144 return; | 144 return; |
145 | 145 |
146 RefPtrWillBeRawPtr<HTMLElement> element = control(); | 146 RefPtrWillBeRawPtr<HTMLElement> element = control(); |
147 | 147 |
148 // If we can't find a control or if the control received the click | 148 // 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. | 149 // event, then there's no need for us to do anything. |
150 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev t->target()->toNode()))) | 150 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev t->target()->toNode()))) |
151 return; | 151 return; |
152 | 152 |
153 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) | 153 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 | 189 |
190 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) | 190 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) |
191 { | 191 { |
192 if (HTMLElement* element = control()) | 192 if (HTMLElement* element = control()) |
193 element->accessKeyAction(sendMouseEvents); | 193 element->accessKeyAction(sendMouseEvents); |
194 else | 194 else |
195 HTMLElement::accessKeyAction(sendMouseEvents); | 195 HTMLElement::accessKeyAction(sendMouseEvents); |
196 } | 196 } |
197 | 197 |
198 } // namespace | 198 } // namespace |
OLD | NEW |