summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-05-19 17:06:51 +0000
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-05-19 17:06:51 +0000
commit0500cce78d3075dfaa36a3f5a19223f1302e156f (patch)
treecd01294c2b5813b693bbd9f4fbb85688f6ab5b92
parent556f42e96712047a88a9e0317db41f69e2a9748f (diff)
downloadchromium_src-0500cce78d3075dfaa36a3f5a19223f1302e156f.zip
chromium_src-0500cce78d3075dfaa36a3f5a19223f1302e156f.tar.gz
chromium_src-0500cce78d3075dfaa36a3f5a19223f1302e156f.tar.bz2
Revert of Revert of Fix selection of label having control element. (https://codereview.chromium.org/290153002/)
Reason for revert: The previously reverted behavior is actually correct and what we wanted. BUG=148912,370859 Original issue's description: > Revert of Fix selection of label having control element. (https://codereview.chromium.org/258933006/) > > Reason for revert: > Causes bug 370859 > > BUG=148912,370859 > TBR=keishi > > Original issue's description: > > Fix selection of label having control element. > > > > Any click event on label goes to its control element. So, if > > we tried to select the text inside label by dragging the mouse > > or by double clicking on the text, it went to its control > > element. This patch checks whether there is selection or not, > > after the click is happened. If there is selection then do > > nothing else continue. > > > > New Layout test added: > > fast/forms/label/label-selection.html > > > > BUG=148912 > > > > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=173310 > > Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=174193 TBR=tkent@chromium.org,keishi@chromium.org,deepak.sa@samsung.com NOTREECHECKS=true NOTRY=true BUG=148912,370859 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=174202 Review URL: https://codereview.chromium.org/282343005 git-svn-id: svn://svn.chromium.org/blink/trunk@174296 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/label/label-selection-expected.txt10
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/label/label-selection.html29
-rw-r--r--third_party/WebKit/Source/core/html/HTMLLabelElement.cpp7
3 files changed, 46 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-expected.txt
new file mode 100644
index 0000000..b17395b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection-expected.txt
@@ -0,0 +1,10 @@
+Test the selection of label associated with input.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getSelection().toString() is "Some"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/third_party/WebKit/LayoutTests/fast/forms/label/label-selection.html b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection.html
new file mode 100644
index 0000000..92b70a6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/forms/label/label-selection.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<script src="../../../resources/js-test.js"></script>
+
+<body>
+<label id="labelWithInput" for="inputText">Some, Text associated with input</label>
+<input id="inputText" type="text">
+</body>
+
+<script>
+description('Test the selection of label associated with input.');
+
+var labelElement = document.getElementById('labelWithInput');
+testWithDoubleClick(labelElement);
+
+shouldBeEqualToString('window.getSelection().toString()', 'Some');
+
+labelElement.style.display = 'none';
+
+function testWithDoubleClick(element)
+{
+ eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+</script>
+</html> \ No newline at end of file
diff --git a/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp b/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
index 801692b..b625e78 100644
--- a/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLabelElement.cpp
@@ -27,7 +27,9 @@
#include "HTMLNames.h"
#include "core/dom/ElementTraversal.h"
+#include "core/editing/FrameSelection.h"
#include "core/events/Event.h"
+#include "core/frame/LocalFrame.h"
#include "core/html/FormAssociatedElement.h"
namespace WebCore {
@@ -136,6 +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())
+ return;
+
RefPtrWillBeRawPtr<HTMLElement> element = control();
// If we can't find a control or if the control received the click