Title: [222317] trunk
Revision
222317
Author
[email protected]
Date
2017-09-21 06:43:28 -0700 (Thu, 21 Sep 2017)

Log Message

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.

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222316 => 222317)


--- trunk/LayoutTests/ChangeLog	2017-09-21 09:51:47 UTC (rev 222316)
+++ trunk/LayoutTests/ChangeLog	2017-09-21 13:43:28 UTC (rev 222317)
@@ -1,3 +1,45 @@
+2017-09-21  Javier Fernandez  <[email protected]>
+
+        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  <[email protected]>
 
         Unreviewed GTK+ gardening. Update expectations and rebaseline several tests failing at r222312.

Added: trunk/LayoutTests/editing/selection/resources/select-out-of-floated-non-editable.js (0 => 222317)


--- trunk/LayoutTests/editing/selection/resources/select-out-of-floated-non-editable.js	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/resources/select-out-of-floated-non-editable.js	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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));
+}

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-01-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-01-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-01-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-01.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-01.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-01.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*second float*", 10);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-02-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-02-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-02-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-02.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-02.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-02.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*", 20);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-03-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-03-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-03-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-03.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-03.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-03.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*second float*", 100);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-04-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-04-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-04-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-04.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-04.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-04.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*second float*inlin", 150);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-05-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-05-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-05-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-05.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-05.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-05.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*", 10);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-06-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-06-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-06-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-06.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-06.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-06.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*in", 30);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-07-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-07-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-07-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-07.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-07.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-07.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*", 10);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-08-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-08-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-08-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-08.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-08.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-08.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*s", 25);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-09-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-09-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-09-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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>"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-09.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-09.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-09.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*second float", 100);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-10-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-10-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-10-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-10.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-10.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-10.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*", 0);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-11-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-11-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-11-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-11.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-11.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-11.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*s", 5);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-12-expected.txt (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-12-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-12-expected.txt	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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>"
+

Added: trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-12.html (0 => 222317)


--- trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-12.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/select-out-of-floated-non-editable-12.html	2017-09-21 13:43:28 UTC (rev 222317)
@@ -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=""
+<script src=""
+<script>
+runTest("float*", 10);
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (222316 => 222317)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2017-09-21 09:51:47 UTC (rev 222316)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2017-09-21 13:43:28 UTC (rev 222317)
@@ -44,3 +44,16 @@
 
 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 ]

Modified: trunk/Source/WebCore/ChangeLog (222316 => 222317)


--- trunk/Source/WebCore/ChangeLog	2017-09-21 09:51:47 UTC (rev 222316)
+++ trunk/Source/WebCore/ChangeLog	2017-09-21 13:43:28 UTC (rev 222317)
@@ -1,3 +1,38 @@
+2017-09-21  Javier Fernandez  <[email protected]>
+
+        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  <[email protected]>
 
         [WebCrypto] Support Elliptic Curve P-521

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (222316 => 222317)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2017-09-21 09:51:47 UTC (rev 222316)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2017-09-21 13:43:28 UTC (rev 222317)
@@ -2628,7 +2628,7 @@
 
 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 @@
             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)))

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (222316 => 222317)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2017-09-21 09:51:47 UTC (rev 222316)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2017-09-21 13:43:28 UTC (rev 222317)
@@ -293,6 +293,8 @@
     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 @@
 
     LayoutUnit lowestInitialLetterLogicalBottom() const;
     
-    LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const; 
     LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const;
     LayoutUnit nextFloatLogicalBottomBelowForBlock(LayoutUnit) const;
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to