Title: [152198] trunk
Revision
152198
Author
[email protected]
Date
2013-06-28 17:09:09 -0700 (Fri, 28 Jun 2013)

Log Message

An element with -webkit-user-select: all should be selected on single click
https://bugs.webkit.org/show_bug.cgi?id=117864

Reviewed by Darin Adler.

Source/WebCore: 

Set m_mouseDownMayStartSelect true even when the node cannot start selection
if the node was inside an element with -webkit-user-select: all.

Test: editing/selection/user-select-all-with-single-click.html

* page/EventHandler.cpp:
(WebCore::canMouseDownStartSelect):

LayoutTests: 

Add tests for single clicking on an element with user-select: all.
We select the entire element regardless of whether the user had clicked on text or an image
to be consistent even though Firefox requires a double click on the latter case.

* editing/selection/user-select-all-with-image-single-click-expected.txt: Added.
* editing/selection/user-select-all-with-image-single-click.html: Added.
* editing/selection/user-select-all-with-single-click-expected.txt: Added.
* editing/selection/user-select-all-with-single-click.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152197 => 152198)


--- trunk/LayoutTests/ChangeLog	2013-06-29 00:01:37 UTC (rev 152197)
+++ trunk/LayoutTests/ChangeLog	2013-06-29 00:09:09 UTC (rev 152198)
@@ -1,5 +1,21 @@
 2013-06-28  Ryosuke Niwa  <[email protected]>
 
+        An element with -webkit-user-select: all should be selected on single click
+        https://bugs.webkit.org/show_bug.cgi?id=117864
+
+        Reviewed by Darin Adler.
+
+        Add tests for single clicking on an element with user-select: all.
+        We select the entire element regardless of whether the user had clicked on text or an image
+        to be consistent even though Firefox requires a double click on the latter case.
+
+        * editing/selection/user-select-all-with-image-single-click-expected.txt: Added.
+        * editing/selection/user-select-all-with-image-single-click.html: Added.
+        * editing/selection/user-select-all-with-single-click-expected.txt: Added.
+        * editing/selection/user-select-all-with-single-click.html: Added.
+
+2013-06-28  Ryosuke Niwa  <[email protected]>
+
         -webkit-line-break: after-white-space sometimes truncates DOM on copy & paste
         https://bugs.webkit.org/show_bug.cgi?id=118164
 

Added: trunk/LayoutTests/editing/selection/user-select-all-image-with-single-click-expected.txt (0 => 152198)


--- trunk/LayoutTests/editing/selection/user-select-all-image-with-single-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/user-select-all-image-with-single-click-expected.txt	2013-06-29 00:09:09 UTC (rev 152198)
@@ -0,0 +1,9 @@
+This tests single-clicking on an image inside user-select: all. WebKit should select the entire element.
+Firefox doesn't do this but I'm not sure it makes sense for us to be inconsistent since Firefox DOES allow text with user-select: all to be selected by a single click.
+To manually test, single click on the image below. WebKit should select the entire bordered region.
+| <div>
+|   class="select-all"
+|   <#selection-anchor>
+|   <img>
+|     src=""
+|   <#selection-focus>

Added: trunk/LayoutTests/editing/selection/user-select-all-image-with-single-click.html (0 => 152198)


--- trunk/LayoutTests/editing/selection/user-select-all-image-with-single-click.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/user-select-all-image-with-single-click.html	2013-06-29 00:09:09 UTC (rev 152198)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<body _onload_="runTest()">
+<p id="description">This tests single-clicking on an image inside user-select: all. WebKit should select the entire element.
+Firefox doesn't do this but I'm not sure it makes sense for us to be inconsistent since Firefox DOES allow text with user-select: all to be selected by a single click.<br>
+To manually test, single click on the image below. WebKit should select the entire bordered region.</p>
+<div id="container"><div class="select-all"><img src=""
+<script src=""
+<style>
+.select-all {
+    border: 1px solid black;
+    height: 200px;
+    width: 200px;
+    -webkit-user-select: all;
+    -moz-user-select: all;
+}
+</style>
+<script>
+
+Markup.description(document.getElementById('description').textContent);
+Markup.waitUntilDone();
+
+function runTest() {
+    function clickOnElement(element) {
+        eventSender.mouseMoveTo(element.offsetLeft + 10, element.offsetTop + 10);
+        eventSender.mouseDown(0);
+        eventSender.mouseUp(0);
+    }
+
+    if (window.eventSender) {
+        clickOnElement(document.querySelector('.select-all'));
+        Markup.dump('container');
+        Markup.notifyDone();
+    }
+}
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/user-select-all-with-single-click-expected.txt (0 => 152198)


--- trunk/LayoutTests/editing/selection/user-select-all-with-single-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/user-select-all-with-single-click-expected.txt	2013-06-29 00:09:09 UTC (rev 152198)
@@ -0,0 +1,5 @@
+This tests single-clicking on text inside user-select: all. WebKit should select the entire element.
+To manually test, single click on "click here" below. WebKit should select the entire bordered region.
+| <div>
+|   class="select-all"
+|   "<#selection-anchor>Click here<#selection-focus>"

Added: trunk/LayoutTests/editing/selection/user-select-all-with-single-click.html (0 => 152198)


--- trunk/LayoutTests/editing/selection/user-select-all-with-single-click.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/user-select-all-with-single-click.html	2013-06-29 00:09:09 UTC (rev 152198)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests single-clicking on text inside user-select: all. WebKit should select the entire element.
+To manually test, single click on "click here" below. WebKit should select the entire bordered region.</p>
+<div id="container"><div class="select-all">Click here</div></div>
+<script src=""
+<style>
+.select-all {
+    border: 1px solid black;
+    height: 100px;
+    width: 100px;
+    -webkit-user-select: all;
+    -moz-user-select: all;
+}
+</style>
+<script>
+
+Markup.description(document.getElementById('description').textContent);
+
+function clickOnElement(element) {
+    eventSender.mouseMoveTo(element.offsetLeft + 10, element.offsetTop + 10);
+    eventSender.mouseDown(0);
+    eventSender.mouseUp(0);
+}
+
+if (window.eventSender) {
+    clickOnElement(document.querySelector('.select-all'));
+    Markup.dump('container');
+} else
+    Markup.noAutoDump();
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (152197 => 152198)


--- trunk/Source/WebCore/ChangeLog	2013-06-29 00:01:37 UTC (rev 152197)
+++ trunk/Source/WebCore/ChangeLog	2013-06-29 00:09:09 UTC (rev 152198)
@@ -1,5 +1,20 @@
 2013-06-28  Ryosuke Niwa  <[email protected]>
 
+        An element with -webkit-user-select: all should be selected on single click
+        https://bugs.webkit.org/show_bug.cgi?id=117864
+
+        Reviewed by Darin Adler.
+
+        Set m_mouseDownMayStartSelect true even when the node cannot start selection
+        if the node was inside an element with -webkit-user-select: all.
+
+        Test: editing/selection/user-select-all-with-single-click.html
+
+        * page/EventHandler.cpp:
+        (WebCore::canMouseDownStartSelect):
+
+2013-06-28  Ryosuke Niwa  <[email protected]>
+
         Remove unused attachChildrenLazily method and make attach/detachChildren private
         https://bugs.webkit.org/show_bug.cgi?id=118016
 

Modified: trunk/Source/WebCore/dom/Position.h (152197 => 152198)


--- trunk/Source/WebCore/dom/Position.h	2013-06-29 00:01:37 UTC (rev 152197)
+++ trunk/Source/WebCore/dom/Position.h	2013-06-29 00:09:09 UTC (rev 152198)
@@ -191,6 +191,9 @@
 #if ENABLE(USERSELECT_ALL)
     static bool nodeIsUserSelectAll(const Node*);
     static Node* rootUserSelectAllForNode(Node*);
+#else
+    static bool nodeIsUserSelectAll(const Node*) { return false; }
+    static Node* rootUserSelectAllForNode(Node*) { return 0; }
 #endif
     static ContainerNode* findParent(const Node*);
     

Modified: trunk/Source/WebCore/page/EventHandler.cpp (152197 => 152198)


--- trunk/Source/WebCore/page/EventHandler.cpp	2013-06-29 00:01:37 UTC (rev 152197)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2013-06-29 00:09:09 UTC (rev 152198)
@@ -640,10 +640,7 @@
     if (!node || !node->renderer())
         return true;
 
-    if (!node->canStartSelection())
-        return false;
-
-    return true;
+    return node->canStartSelection() || Position::nodeIsUserSelectAll(node);
 }
 
 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& event)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to