diff options
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 |