Title: [102918] trunk
- Revision
- 102918
- Author
- [email protected]
- Date
- 2011-12-15 04:02:55 -0800 (Thu, 15 Dec 2011)
Log Message
"user-select none" causes selection to incorrectly escape from clicked container
https://bugs.webkit.org/show_bug.cgi?id=57289
Patch by Rakesh KN <[email protected]> on 2011-12-15
Reviewed by Ryosuke Niwa.
Source/WebCore:
Not selecting the nearest word from the target node if target node has -webkit-user-select:none
Test: fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html
* page/EventHandler.cpp:
(WebCore::EventHandler::updateSelectionForMouseDownDispatchingSelectStart):
If target node has webkit-user-select:none style then do not update the selection.
LayoutTests:
* fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none-expected.txt: Added.
* fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html: Added.
* fast/js/resources/js-test-pre.js:
(shouldNotBe):
Added new helper function to check for inequality.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (102917 => 102918)
--- trunk/LayoutTests/ChangeLog 2011-12-15 12:01:30 UTC (rev 102917)
+++ trunk/LayoutTests/ChangeLog 2011-12-15 12:02:55 UTC (rev 102918)
@@ -1,3 +1,16 @@
+2011-12-15 Rakesh KN <[email protected]>
+
+ "user-select none" causes selection to incorrectly escape from clicked container
+ https://bugs.webkit.org/show_bug.cgi?id=57289
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none-expected.txt: Added.
+ * fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html: Added.
+ * fast/js/resources/js-test-pre.js:
+ (shouldNotBe):
+ Added new helper function to check for inequality.
+
2011-12-13 Andrey Kosyakov <[email protected]>
Web Inspector: Generated HAR is missing pages.startedDateTime
Added: trunk/LayoutTests/fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none-expected.txt (0 => 102918)
--- trunk/LayoutTests/fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none-expected.txt 2011-12-15 12:02:55 UTC (rev 102918)
@@ -0,0 +1,10 @@
+Mouse double/triple click on an element with "webkit-user-select none" should not select the next node
+
+Foo
+PASS doubleClick(); document.getSelection() is not "Foo"
+PASS document.getSelection().removeAllRanges(); document.getSelection().toString().indexOf("Foo") is -1
+PASS tripleClick(); document.getSelection().toString().indexOf("Foo") is -1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html (0 => 102918)
--- trunk/LayoutTests/fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html (rev 0)
+++ trunk/LayoutTests/fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html 2011-12-15 12:02:55 UTC (rev 102918)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<style type="text/css">
+.parent, .child {
+ -moz-user-select: none;
+ -webkit-user-select: none;
+}
+.child {
+ visibility: hidden;
+}
+</style>
+<script src=""
+</head>
+<body>
+<p> Mouse double/triple click on an element with "webkit-user-select none" should not select the next node</p>
+<div>
+<div class='parent'>
+ <div id="second" class='child'>1</div>
+ <div class='child'>2</div>
+ <div class='child'>3</div>
+ <div class='child'>4</div>
+</div>
+Foo
+</div>
+<div id="console"></div>
+<script>
+function doubleClick() {
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+function tripleClick() {
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+
+if (window.eventSender) {
+ var div = document.getElementById("second");
+ var x = div.offsetLeft + 5;
+ var y = div.offsetTop + 5;
+ eventSender.mouseMoveTo(x, y);
+
+ shouldNotBe("doubleClick(); document.getSelection()",'"Foo"');
+
+ shouldBe('document.getSelection().removeAllRanges(); document.getSelection().toString().indexOf("Foo")','-1');
+
+ shouldBe('tripleClick(); document.getSelection().toString().indexOf("Foo")', '-1');
+} else {
+ debug("To test manually, double/triple click on 1/2/3/4 and it should not select Foo");
+}
+successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/js/resources/js-test-pre.js (102917 => 102918)
--- trunk/LayoutTests/fast/js/resources/js-test-pre.js 2011-12-15 12:01:30 UTC (rev 102917)
+++ trunk/LayoutTests/fast/js/resources/js-test-pre.js 2011-12-15 12:02:55 UTC (rev 102918)
@@ -184,6 +184,29 @@
testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
}
+function shouldNotBe(_a, _b, quiet)
+{
+ if (typeof _a != "string" || typeof _b != "string")
+ debug("WARN: shouldNotBe() expects string arguments");
+ var exception;
+ var _av;
+ try {
+ _av = eval(_a);
+ } catch (e) {
+ exception = e;
+ }
+ var _bv = eval(_b);
+
+ if (exception)
+ testFailed(_a + " should not be " + _bv + ". Threw exception " + exception);
+ else if (!isResultCorrect(_av, _bv)) {
+ if (!quiet) {
+ testPassed(_a + " is not " + _b);
+ }
+ } else
+ testFailed(_a + " should not be " + _bv + ".");
+}
+
function shouldBeTrue(_a) { shouldBe(_a, "true"); }
function shouldBeTrueQuiet(_a) { shouldBe(_a, "true", true); }
function shouldBeFalse(_a) { shouldBe(_a, "false"); }
Modified: trunk/Source/WebCore/ChangeLog (102917 => 102918)
--- trunk/Source/WebCore/ChangeLog 2011-12-15 12:01:30 UTC (rev 102917)
+++ trunk/Source/WebCore/ChangeLog 2011-12-15 12:02:55 UTC (rev 102918)
@@ -1,3 +1,18 @@
+2011-12-15 Rakesh KN <[email protected]>
+
+ "user-select none" causes selection to incorrectly escape from clicked container
+ https://bugs.webkit.org/show_bug.cgi?id=57289
+
+ Reviewed by Ryosuke Niwa.
+
+ Not selecting the nearest word from the target node if target node has -webkit-user-select:none
+
+ Test: fast/events/mouse-double-triple-click-should-not-select-next-node-for-user-select-none.html
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::updateSelectionForMouseDownDispatchingSelectStart):
+ If target node has webkit-user-select:none style then do not update the selection.
+
2011-12-13 Andrey Kosyakov <[email protected]>
Web Inspector: Generated HAR is missing pages.startedDateTime
Modified: trunk/Source/WebCore/page/EventHandler.cpp (102917 => 102918)
--- trunk/Source/WebCore/page/EventHandler.cpp 2011-12-15 12:01:30 UTC (rev 102917)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2011-12-15 12:02:55 UTC (rev 102918)
@@ -292,6 +292,9 @@
bool EventHandler::updateSelectionForMouseDownDispatchingSelectStart(Node* targetNode, const VisibleSelection& newSelection, TextGranularity granularity)
{
+ if (Position::nodeIsUserSelectNone(targetNode))
+ return false;
+
if (!dispatchSelectStart(targetNode))
return false;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes