Unpredictable selection when dragging out of float elements children of in-flow block...
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2017 13:43:28 +0000 (13:43 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2017 13:43:28 +0000 (13:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176096

Reviewed by David Hyatt.

Source/WebCore:

In order to improve Selection across float elements we need to
consider them as HitTest candidates.  Additionally, since
out-of-flow elements must not affect how in-flow elements are
rendered we have to deal with some special cases when implementing
the positionForPoint logic.

This patch addresses the issues caused by the fact that an in-flow
box's logicalBottom does not consider the out-of-flow children, as
they don't affect its height. Hence, we should add the lowest float
logical bottom to figure out the box the point is actually hitting.

Tests: editing/selection/select-out-of-floated-non-editable-01.html
       editing/selection/select-out-of-floated-non-editable-02.html
       editing/selection/select-out-of-floated-non-editable-03.html
       editing/selection/select-out-of-floated-non-editable-04.html
       editing/selection/select-out-of-floated-non-editable-05.html
       editing/selection/select-out-of-floated-non-editable-06.html
       editing/selection/select-out-of-floated-non-editable-07.html
       editing/selection/select-out-of-floated-non-editable-08.html
       editing/selection/select-out-of-floated-non-editable-09.html
       editing/selection/select-out-of-floated-non-editable-10.html
       editing/selection/select-out-of-floated-non-editable-11.html
       editing/selection/select-out-of-floated-non-editable-12.html

* rendering/RenderBlock.cpp:
(WebCore::isChildHitTestCandidate):
(WebCore::RenderBlock::positionForPoint):

LayoutTests:

Tests defining several cases of selection with floats, children of
a block-level box, so they behave as regular HitTest candidates
and don't mess the selection boundaries.

* editing/selection/resources/select-out-of-floated-non-editable.js: Added.
(clearLog):
(log):
(else.window.onmouseup):
(runTest):
(checkSelection):
* editing/selection/select-out-of-floated-non-editable-01-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-01.html: Added.
* editing/selection/select-out-of-floated-non-editable-02-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-02.html: Added.
* editing/selection/select-out-of-floated-non-editable-03-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-03.html: Added.
* editing/selection/select-out-of-floated-non-editable-04-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-04.html: Added.
* editing/selection/select-out-of-floated-non-editable-05-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-05.html: Added.
* editing/selection/select-out-of-floated-non-editable-06-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-06.html: Added.
* editing/selection/select-out-of-floated-non-editable-07-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-07.html: Added.
* editing/selection/select-out-of-floated-non-editable-08-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-08.html: Added.
* editing/selection/select-out-of-floated-non-editable-09-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-09.html: Added.
* editing/selection/select-out-of-floated-non-editable-10-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-10.html: Added.
* editing/selection/select-out-of-floated-non-editable-11-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-11.html: Added.
* editing/selection/select-out-of-floated-non-editable-12-expected.txt: Added.
* editing/selection/select-out-of-floated-non-editable-12.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/resources/select-out-of-floated-non-editable.js [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-01-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-01.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-02-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-02.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-03-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-03.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-04-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-04.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-05-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-05.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-06-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-06.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-07-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-07.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-08-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-08.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-09-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-09.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-10-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-10.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-11-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-11.html [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-12-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/select-out-of-floated-non-editable-12.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlockFlow.h

index a10963d..4d11e39 100644 (file)
@@ -1,3 +1,45 @@
+2017-09-21  Javier Fernandez  <jfernandez@igalia.com>
+
+        Unpredictable selection when dragging out of float elements children of in-flow block-level box
+        https://bugs.webkit.org/show_bug.cgi?id=176096
+
+        Reviewed by David Hyatt.
+
+        Tests defining several cases of selection with floats, children of
+        a block-level box, so they behave as regular HitTest candidates
+        and don't mess the selection boundaries.
+
+        * editing/selection/resources/select-out-of-floated-non-editable.js: Added.
+        (clearLog):
+        (log):
+        (else.window.onmouseup):
+        (runTest):
+        (checkSelection):
+        * editing/selection/select-out-of-floated-non-editable-01-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-01.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-02-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-02.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-03-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-03.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-04-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-04.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-05-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-05.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-06-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-06.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-07-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-07.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-08-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-08.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-09-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-09.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-10-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-10.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-11-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-11.html: Added.
+        * editing/selection/select-out-of-floated-non-editable-12-expected.txt: Added.
+        * editing/selection/select-out-of-floated-non-editable-12.html: Added.
+
 2017-09-21  Miguel Gomez  <magomez@igalia.com>
 
         Unreviewed GTK+ gardening. Update expectations and rebaseline several tests failing at r222312.
diff --git a/LayoutTests/editing/selection/resources/select-out-of-floated-non-editable.js b/LayoutTests/editing/selection/resources/select-out-of-floated-non-editable.js
new file mode 100644 (file)
index 0000000..dcdf3cb
--- /dev/null
@@ -0,0 +1,43 @@
+function clearLog() {
+    const logText = document.getElementById('console').firstChild;
+    if (logText)
+        document.getElementById('console').removeChild(logText);
+}
+function log(msg) {
+    document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
+}
+function runTest(expectedSelection, dragOffset) {
+    Markup.noAutoDump();
+    container.style.fontFamily = 'monospace';
+    container.style.fontSize = '10px';
+    if (window.testRunner && window.eventSender) {
+        testRunner.dumpAsText();
+
+        var x = target.offsetLeft + (target.offsetWidth / 2);
+        var y = target.offsetTop + (target.offsetHeight / 2);
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseDown();
+        x = target.offsetLeft + target.offsetWidth + dragOffset;
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseUp();
+
+        checkSelection(expectedSelection);
+    } else {
+        window.onmouseup = function() {
+            window.setTimeout(function() {
+                clearLog();
+                log("Selected test is: '" + getSelection().toString() + "'\n" + Markup.get(container));
+            }, 0);  // Without a timeout the selection is inaccurately printed
+        }
+    }
+}
+
+function checkSelection(expectedSelection) {
+    const selectedText = getSelection().toString();
+    if (expectedSelection === selectedText) {
+        log("SUCCESS: Selected test is '" + selectedText + "' as expected");
+    } else {
+        log("FAIL: Selection should be '" + expectedSelection + "' but was '" + selectedText + "'");
+    }
+    log(Markup.get(container));
+}
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-01-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-01-expected.txt
new file mode 100644 (file)
index 0000000..36f04f0
--- /dev/null
@@ -0,0 +1,16 @@
+block-level text before floats
+first float*second float*inline-level text after the floats
+To test manually, drag from the middle of the 'first float' div to the right, into the space between floats. The selection should go to the end of the 'second float' div with a portion of the inline-level box's background and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*second float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   "second float*"
+| "<#selection-focus>inline-level text after the floats"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-01.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-01.html
new file mode 100644 (file)
index 0000000..c11d0b2
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float*</div>inline-level text after the floats</div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first float' div to the
+right, into the space between floats. The selection should go to the end
+of the 'second float' div with a portion of the inline-level box's
+background and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*second float*", 10);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-02-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-02-expected.txt
new file mode 100644 (file)
index 0000000..3a11664
--- /dev/null
@@ -0,0 +1,17 @@
+block-level text before floats
+first float*second float*inline-level text after the floats
+To test manually, drag from the middle of the 'first float' div to the right, just before the 'second float' div. The selection should go to the end of the 'first float' div and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   <#selection-focus>
+|   "second float*"
+| "inline-level text after the floats"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-02.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-02.html
new file mode 100644 (file)
index 0000000..cebc0df
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float*</div>inline-level text after the floats</div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first float' div to the
+right, just before the 'second float' div. The selection should go to the end
+of the 'first float' div and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*", 20);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-03-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-03-expected.txt
new file mode 100644 (file)
index 0000000..7601527
--- /dev/null
@@ -0,0 +1,16 @@
+block-level text before floats
+first float*second float*inline-level text after the floats
+To test manually, drag from the middle of the 'first float' div to the right, until the space between the 'second float' and the inline-text. The selection should include both floats enterely with a portion of the inline-level box's background and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*second float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   "second float*"
+| "<#selection-focus>inline-level text after the floats"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-03.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-03.html
new file mode 100644 (file)
index 0000000..72bbfbe
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float*</div>inline-level text after the floats</div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first float' div to the
+right, until the space between the 'second float' and the inline-text.
+The selection should include both floats enterely with a portion of the
+inline-level box's background and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*second float*", 100);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-04-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-04-expected.txt
new file mode 100644 (file)
index 0000000..83618c1
--- /dev/null
@@ -0,0 +1,16 @@
+block-level text before floats
+first float*second float*inline-level text after the floats
+To test manually, drag from the middle of the 'first float' div to the right, into the inline-level text. The selection should include both floats with part of the inline-level box's background and text and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*second float*inlin' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   "second float*"
+| "inlin<#selection-focus>e-level text after the floats"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-04.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-04.html
new file mode 100644 (file)
index 0000000..f7aaa81
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float*</div>inline-level text after the floats</div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first float' div to the
+right, into the inline-level text. The selection should include both floats
+with part of the inline-level box's background and text and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*second float*inlin", 150);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-05-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-05-expected.txt
new file mode 100644 (file)
index 0000000..d23b1b9
--- /dev/null
@@ -0,0 +1,13 @@
+block-level text before floats
+first float*inline-level text after the floats
+To test manually, drag from the middle of the 'first float' div to the right, into the space before the inline-level box. The selection should go to the end of the first float element with a portion of the inline-level box's background and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| "<#selection-focus>inline-level text after the floats"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-05.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-05.html
new file mode 100644 (file)
index 0000000..b48dac3
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div>inline-level text after the floats</div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first float' div to the
+right, into the space before the inline-level box. The selection should
+go to the end of the first float element with a portion of the inline-level
+box's background and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*", 10);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-06-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-06-expected.txt
new file mode 100644 (file)
index 0000000..d25962a
--- /dev/null
@@ -0,0 +1,13 @@
+block-level text before floats
+first float*inline-level text after the floats
+To test manually, drag from the middle of the 'first float' div to the right, into inline-level box. The selection should go to the end of the first float element with part of the inline-level box's background and text and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*in' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| "in<#selection-focus>line-level text after the floats"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-06.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-06.html
new file mode 100644 (file)
index 0000000..adb6001
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div>inline-level text after the floats</div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first float' div to the
+right, into inline-level box. The selection should go to the end
+of the first float element with part of the inline-level box's background
+and text and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*in", 30);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-07-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-07-expected.txt
new file mode 100644 (file)
index 0000000..7049fc5
--- /dev/null
@@ -0,0 +1,16 @@
+block-level text before floats
+first float*second float
+To test manually, drag from the middle of the 'first-float' div to the right, into the space between floats. The selection should go to the end of the first float element and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   <#selection-focus>
+|   "second float"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-07.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-07.html
new file mode 100644 (file)
index 0000000..6d6483f
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float</div></div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first-float' div to the
+right, into the space between floats. The selection should go to the end
+of the first float element and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*", 10);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-08-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-08-expected.txt
new file mode 100644 (file)
index 0000000..434341d
--- /dev/null
@@ -0,0 +1,15 @@
+block-level text before floats
+first float*second float
+To test manually, drag from the middle of the 'first-float' div to the right, into the 'second float' element. The selection should end inside the 'second float' element and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*s' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   "s<#selection-focus>econd float"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-08.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-08.html
new file mode 100644 (file)
index 0000000..64ec858
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float</div></div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first-float' div to the
+right, into the 'second float' element. The selection should end
+inside the 'second float' element and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*s", 25);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-09-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-09-expected.txt
new file mode 100644 (file)
index 0000000..9942c85
--- /dev/null
@@ -0,0 +1,15 @@
+block-level text before floats
+first float*second float
+To test manually, drag from the middle of the 'first-float' div to the right, into the space after the 'second float' element. The selection should go to the end of the 'second float' element and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*second float' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left; margin-right: 20px"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left; margin-right: 20px"
+|   "second float<#selection-focus>"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-09.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-09.html
new file mode 100644 (file)
index 0000000..b4c0bdf
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left; margin-right: 20px">first float*</div><div style="float: left; margin-right: 20px">second float</div></div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first-float' div to the
+right, into the space after the 'second float' element. The selection should go to the end
+of the 'second float' element and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*second float", 100);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-10-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-10-expected.txt
new file mode 100644 (file)
index 0000000..8885976
--- /dev/null
@@ -0,0 +1,16 @@
+block-level text before floats
+first float*second float
+To test manually, drag from the middle of the 'first-float' div to the right, just before the 'second float' element. The selection should go to the end of the first float element and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left"
+|   <#selection-focus>
+|   "second float"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-10.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-10.html
new file mode 100644 (file)
index 0000000..7d7ca36
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left">first float*</div><div style="float: left">second float</div></div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first-float' div to the
+right, just before the 'second float' element. The selection should go to the end
+of the first float element and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*", 0);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-11-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-11-expected.txt
new file mode 100644 (file)
index 0000000..bc2119c
--- /dev/null
@@ -0,0 +1,15 @@
+block-level text before floats
+first float*second float
+To test manually, drag from the middle of the 'first-float' div to the right, into the the 'second float' element. The selection should go into the 'second float' element, including text of both floats, and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*s' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left"
+|   "first <#selection-anchor>float*"
+| <div>
+|   style="float: left"
+|   "s<#selection-focus>econd float"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-11.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-11.html
new file mode 100644 (file)
index 0000000..d46ac66
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left">first float*</div><div style="float: left">second float</div></div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first-float' div to the
+right, into the the 'second float' element. The selection should go into
+the 'second float' element, including text of both floats, and not jump
+to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*s", 5);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-12-expected.txt b/LayoutTests/editing/selection/select-out-of-floated-non-editable-12-expected.txt
new file mode 100644 (file)
index 0000000..9356123
--- /dev/null
@@ -0,0 +1,12 @@
+block-level text before floats
+first float*
+To test manually, drag from the middle of the 'first-float' div to the right, into the space after the float. The selection should go to the end of the 'first float' element and not jump to the beginning.
+
+SUCCESS: Selected test is 'float*' as expected
+| <div>
+|   "block-level text before floats"
+| <div>
+|   id="target"
+|   style="float: left"
+|   "first <#selection-anchor>float*<#selection-focus>"
+
diff --git a/LayoutTests/editing/selection/select-out-of-floated-non-editable-12.html b/LayoutTests/editing/selection/select-out-of-floated-non-editable-12.html
new file mode 100644 (file)
index 0000000..f7cd2f7
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container"><div>block-level text before floats</div><div id="target" style="float: left">first float*</div></div>
+<p style="padding-top: 1em;">
+To test manually, drag from the middle of the 'first-float' div to the
+right, into the space after the float. The selection should go to the end
+of the 'first float' element and not jump to the beginning.
+</p>
+<pre id="console"></pre>
+<script src="../../resources/dump-as-markup.js"></script>
+<script src="resources/select-out-of-floated-non-editable.js"></script>
+<script>
+runTest("float*", 10);
+</script>
+</body>
+</html>
index 2fca168..fd33896 100644 (file)
@@ -44,3 +44,16 @@ webkit.org/b/172384 fast/hidpi/hidpi-long-page-with-inset-element.html [ Pass Im
 
 webkit.org/b/175865 quicklook/multi-sheet-numbers-09.html [ Pass Failure ]
 
+# iOS simulator doesn’t support mouse events simulation using the eventSender.
+editing/selection/select-out-of-floated-non-editable-01.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-02.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-03.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-04.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-05.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-06.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-07.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-08.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-09.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-10.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-11.html [ Skip ]
+editing/selection/select-out-of-floated-non-editable-12.html [ Skip ]
index b42c08b..c49f924 100644 (file)
@@ -1,3 +1,38 @@
+2017-09-21  Javier Fernandez  <jfernandez@igalia.com>
+
+        Unpredictable selection when dragging out of float elements children of in-flow block-level box
+        https://bugs.webkit.org/show_bug.cgi?id=176096
+
+        Reviewed by David Hyatt.
+
+        In order to improve Selection across float elements we need to
+        consider them as HitTest candidates.  Additionally, since
+        out-of-flow elements must not affect how in-flow elements are
+        rendered we have to deal with some special cases when implementing
+        the positionForPoint logic.
+
+        This patch addresses the issues caused by the fact that an in-flow
+        box's logicalBottom does not consider the out-of-flow children, as
+        they don't affect its height. Hence, we should add the lowest float
+        logical bottom to figure out the box the point is actually hitting.
+
+        Tests: editing/selection/select-out-of-floated-non-editable-01.html
+               editing/selection/select-out-of-floated-non-editable-02.html
+               editing/selection/select-out-of-floated-non-editable-03.html
+               editing/selection/select-out-of-floated-non-editable-04.html
+               editing/selection/select-out-of-floated-non-editable-05.html
+               editing/selection/select-out-of-floated-non-editable-06.html
+               editing/selection/select-out-of-floated-non-editable-07.html
+               editing/selection/select-out-of-floated-non-editable-08.html
+               editing/selection/select-out-of-floated-non-editable-09.html
+               editing/selection/select-out-of-floated-non-editable-10.html
+               editing/selection/select-out-of-floated-non-editable-11.html
+               editing/selection/select-out-of-floated-non-editable-12.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::isChildHitTestCandidate):
+        (WebCore::RenderBlock::positionForPoint):
+
 2017-09-21  Zan Dobersek  <zdobersek@igalia.com>
 
         [WebCrypto] Support Elliptic Curve P-521
index fe8da13..496d678 100644 (file)
@@ -2628,7 +2628,7 @@ VisiblePosition RenderBlock::positionForPointWithInlineChildren(const LayoutPoin
 
 static inline bool isChildHitTestCandidate(const RenderBox& box)
 {
-    return box.height() && box.style().visibility() == VISIBLE && !box.isFloatingOrOutOfFlowPositioned() && !box.isInFlowRenderFlowThread();
+    return box.height() && box.style().visibility() == VISIBLE && !box.isOutOfFlowPositioned() && !box.isInFlowRenderFlowThread();
 }
 
 // Valid candidates in a FlowThread must be rendered by the region.
@@ -2685,6 +2685,8 @@ VisiblePosition RenderBlock::positionForPoint(const LayoutPoint& point, const Re
             if (!isChildHitTestCandidate(*childBox, region, pointInLogicalContents))
                 continue;
             LayoutUnit childLogicalBottom = logicalTopForChild(*childBox) + logicalHeightForChild(*childBox);
+            if (is<RenderBlockFlow>(childBox))
+                childLogicalBottom += downcast<RenderBlockFlow>(childBox)->lowestFloatLogicalBottom();
             // We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3).
             if (isChildHitTestCandidate(*childBox, region, pointInLogicalContents) && (pointInLogicalContents.y() < childLogicalBottom
                 || (blocksAreFlipped && pointInLogicalContents.y() == childLogicalBottom)))
index 686005a..7f9a165 100644 (file)
@@ -293,6 +293,8 @@ public:
     Position positionForPoint(const LayoutPoint&) override;
     VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) override;
 
+    LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const;
+
     void removeFloatingObjects();
     void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = nullptr, bool inLayout = true);
     void markSiblingsWithFloatsForLayout(RenderBox* floatToRemove = nullptr);
@@ -509,7 +511,6 @@ private:
 
     LayoutUnit lowestInitialLetterLogicalBottom() const;
     
-    LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const; 
     LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const;
     LayoutUnit nextFloatLogicalBottomBelowForBlock(LayoutUnit) const;