Title: [210687] trunk
Revision
210687
Author
[email protected]
Date
2017-01-12 16:36:58 -0800 (Thu, 12 Jan 2017)

Log Message

Do not allow selection of editable content when not editing.
https://bugs.webkit.org/show_bug.cgi?id=166897
<rdar://problem/29388806>

Reviewed by Tim Horton.

Source/WebKit2:

Test: fast/events/touch/ios/long-press-on-editable.html

When retrieving the position information, we should not consider
as candidates for selection editable elements, since this is only
used for non editable selections.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::isAssistableElement): Moved within the file.
(WebKit::WebPage::getPositionInformation):

LayoutTests:

* fast/events/touch/ios/long-press-on-editable-expected.txt: Added.
* fast/events/touch/ios/long-press-on-editable.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210686 => 210687)


--- trunk/LayoutTests/ChangeLog	2017-01-13 00:15:51 UTC (rev 210686)
+++ trunk/LayoutTests/ChangeLog	2017-01-13 00:36:58 UTC (rev 210687)
@@ -1,3 +1,14 @@
+2017-01-12  Enrica Casucci  <[email protected]>
+
+        Do not allow selection of editable content when not editing.
+        https://bugs.webkit.org/show_bug.cgi?id=166897
+        <rdar://problem/29388806>
+
+        Reviewed by Tim Horton.
+
+        * fast/events/touch/ios/long-press-on-editable-expected.txt: Added.
+        * fast/events/touch/ios/long-press-on-editable.html: Added.
+
 2017-01-12  Ryan Haddad  <[email protected]>
 
         Marking fast/mediastream/MediaStream-video-element-video-tracks-disabled-then-enabled.html as a timeout on mac-wk2.

Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-expected.txt (0 => 210687)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-expected.txt	2017-01-13 00:36:58 UTC (rev 210687)
@@ -0,0 +1,2 @@
+PASS: no selection made
+

Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable.html (0 => 210687)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable.html	2017-01-13 00:36:58 UTC (rev 210687)
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function getPressScript()
+        {
+            return `
+            (function() {
+                uiController.longPressAtPoint(30, 20, function() {
+                    uiController.uiScriptComplete();
+                });
+            })();`
+        }
+    
+        function runTest()
+        {
+            if (!testRunner.runUIScript)
+                return;
+
+            var output = '';
+            var target = document.getElementById('target');
+            if (testRunner.runUIScript) {
+                testRunner.runUIScript(getPressScript(), function(result) {
+                    var selectionText = document.getSelection().toString();
+                    if (selectionText == "PressMe")
+                        output += 'FAILED: Selected: ' + selectionText;
+                    else
+                        output += 'PASS: no selection made';
+                    output += '<br>';
+                    document.getElementById('target').innerHTML = output;
+                    testRunner.notifyDone();
+                });
+            }
+        }
+
+        window.addEventListener('load', runTest, false);
+    </script>
+    <style>
+        #target {
+            height: 100px;
+            width: 200px;
+            background-color: silver;
+        }
+    </style>
+    <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+<div id="target">
+	<textarea>PressMe</textarea>
+    This test requires UIScriptController to run.
+</div>
+</body>
+</html>

Modified: trunk/Source/WebKit2/ChangeLog (210686 => 210687)


--- trunk/Source/WebKit2/ChangeLog	2017-01-13 00:15:51 UTC (rev 210686)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-13 00:36:58 UTC (rev 210687)
@@ -1,3 +1,21 @@
+2017-01-12  Enrica Casucci  <[email protected]>
+
+        Do not allow selection of editable content when not editing.
+        https://bugs.webkit.org/show_bug.cgi?id=166897
+        <rdar://problem/29388806>
+
+        Reviewed by Tim Horton.
+
+        Test: fast/events/touch/ios/long-press-on-editable.html
+
+        When retrieving the position information, we should not consider
+        as candidates for selection editable elements, since this is only
+        used for non editable selections.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::isAssistableElement): Moved within the file.
+        (WebKit::WebPage::getPositionInformation):
+
 2017-01-12  Megan Gardner  <[email protected]>
 
         Double Check URLs on UI side before putting in pasteboard

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (210686 => 210687)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2017-01-13 00:15:51 UTC (rev 210686)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2017-01-13 00:36:58 UTC (rev 210687)
@@ -2282,6 +2282,20 @@
     return nullptr;
 }
 
+static inline bool isAssistableElement(Element& node)
+{
+    if (is<HTMLSelectElement>(node))
+        return true;
+    if (is<HTMLTextAreaElement>(node))
+        return true;
+    if (is<HTMLInputElement>(node)) {
+        HTMLInputElement& inputElement = downcast<HTMLInputElement>(node);
+        // FIXME: This laundry list of types is not a good way to factor this. Need a suitable function on HTMLInputElement itself.
+        return inputElement.isTextField() || inputElement.isDateField() || inputElement.isDateTimeLocalField() || inputElement.isMonthField() || inputElement.isTimeField();
+    }
+    return node.isContentEditable();
+}
+
 void WebPage::getPositionInformation(const InteractionInformationRequest& request, InteractionInformationAtPosition& info)
 {
     info.request = request;
@@ -2435,7 +2449,7 @@
             } else {
                 info.isSelectable = renderer->style().userSelect() != SELECT_NONE;
                 if (info.isSelectable && !hitNode->isTextNode())
-                    info.isSelectable = !rectIsTooBigForSelection(info.bounds, *result.innerNodeFrame());
+                    info.isSelectable = !isAssistableElement(*downcast<Element>(hitNode)) && !rectIsTooBigForSelection(info.bounds, *result.innerNodeFrame());
             }
         }
     }
@@ -2497,20 +2511,6 @@
     }
 }
 
-static inline bool isAssistableElement(Element& node)
-{
-    if (is<HTMLSelectElement>(node))
-        return true;
-    if (is<HTMLTextAreaElement>(node))
-        return true;
-    if (is<HTMLInputElement>(node)) {
-        HTMLInputElement& inputElement = downcast<HTMLInputElement>(node);
-        // FIXME: This laundry list of types is not a good way to factor this. Need a suitable function on HTMLInputElement itself.
-        return inputElement.isTextField() || inputElement.isDateField() || inputElement.isDateTimeLocalField() || inputElement.isMonthField() || inputElement.isTimeField();
-    }
-    return node.isContentEditable();
-}
-
 static inline Element* nextAssistableElement(Node* startNode, Page& page, bool isForward)
 {
     if (!is<Element>(startNode))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to