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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/forms/label/label-click-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/HTMLLabelElement.cpp
diff --git a/Source/core/html/HTMLLabelElement.cpp b/Source/core/html/HTMLLabelElement.cpp
index b625e78f6d1c03e85537220ce833a8da5c2d4f3e..f6dc7fc6d24226728ca4fbad415e0a585b3523df 100644
--- a/Source/core/html/HTMLLabelElement.cpp
+++ b/Source/core/html/HTMLLabelElement.cpp
@@ -28,7 +28,7 @@
#include "HTMLNames.h"
#include "core/dom/ElementTraversal.h"
#include "core/editing/FrameSelection.h"
-#include "core/events/Event.h"
+#include "core/events/MouseEvent.h"
#include "core/frame/LocalFrame.h"
#include "core/html/FormAssociatedElement.h"
@@ -138,9 +138,11 @@ void HTMLLabelElement::defaultEventHandler(Event* evt)
static bool processingClick = false;
if (evt->type() == EventTypeNames::click && !processingClick) {
- // If text of label element is selected, do not pass
- // the event to control element.
- if (document().frame()->selection().selection().isRange())
+ // If the click is not simulated and the text of label element is
+ // selected, do not pass the event to control element.
+ // Note: a click event may be not a mouse event if created by
+ // document.createEvent().
+ if (evt->isMouseEvent() && !toMouseEvent(evt)->isSimulated() && document().frame()->selection().selection().isRange())
return;
RefPtrWillBeRawPtr<HTMLElement> element = control();
« 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