Title: [287981] trunk
Revision
287981
Author
[email protected]
Date
2022-01-13 10:21:34 -0800 (Thu, 13 Jan 2022)

Log Message

REGRESSION (r278561): Right clicking a link selects the full line with unrelated text
https://bugs.webkit.org/show_bug.cgi?id=235172
<rdar://84069534>

Reviewed by Dean Jackson.

Source/WebCore:

r278561 slightly change highlightStateForTextBox's behavior which now (correctly) returns HighlightState::None when the
RenderText content is not part of the current selection. Prior to r278561, it returned the RenderText's original selection state
which in this case was HighlightState::End.

<div><span>A<br>B<span style="position: absolute"></span></span>C</div>

In this specific case when we select the outer <span>, we end up with the following selection states for the generated line boxes:
  (B) -> "Inside"
  (C) -> "None"
while previously (C) came back as "End" (note that the absolute positioned element does not generate line boxes).

Now as Line::selectionState traverses through the line boxes, it comes across an unexpected "Inside -> None" transition at the selection end boundary (B -> C)
which incorrectly leaves the line state in "Inside" and we paint the selection all the way to the end of the block.

Test: fast/editing/selection-with-absolute-positioned-empty-content.html

* layout/integration/InlineIteratorLine.cpp:
(WebCore::InlineIterator::Line::selectionState const):

LayoutTests:

* fast/editing/selection-with-absolute-positioned-empty-content-expected.txt: Added.
* fast/editing/selection-with-absolute-positioned-empty-content.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287980 => 287981)


--- trunk/LayoutTests/ChangeLog	2022-01-13 17:16:07 UTC (rev 287980)
+++ trunk/LayoutTests/ChangeLog	2022-01-13 18:21:34 UTC (rev 287981)
@@ -1,3 +1,14 @@
+2022-01-13  Alan Bujtas  <[email protected]>
+
+        REGRESSION (r278561): Right clicking a link selects the full line with unrelated text
+        https://bugs.webkit.org/show_bug.cgi?id=235172
+        <rdar://84069534>
+
+        Reviewed by Dean Jackson.
+
+        * fast/editing/selection-with-absolute-positioned-empty-content-expected.txt: Added.
+        * fast/editing/selection-with-absolute-positioned-empty-content.html: Added.
+
 2022-01-10  Sergio Villar Senin  <[email protected]>
 
         [css-flexbox] Incorrect height of flex items with aspect-ratio whenever the cross axis intrinsic size is larger than the viewport

Added: trunk/LayoutTests/editing/selection-with-absolute-positioned-empty-content-expected.txt (0 => 287981)


--- trunk/LayoutTests/editing/selection-with-absolute-positioned-empty-content-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection-with-absolute-positioned-empty-content-expected.txt	2022-01-13 18:21:34 UTC (rev 287981)
@@ -0,0 +1,6 @@
+select this text but not this
+(repaint rects
+  (rect 8 8 220 40)
+  (rect 228 8 564 20)
+)
+

Added: trunk/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html (0 => 287981)


--- trunk/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html	2022-01-13 18:21:34 UTC (rev 287981)
@@ -0,0 +1,26 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 20px;
+  width: 220px;
+}
+
+span {
+  position: absolute;
+}
+</style>
+<div><a id=foobar style="color: black" href="" this text<span></span></a> but not this</div>
+<pre id=result></pre>
+<script>
+if (window.internals)
+  internals.startTrackingRepaints();
+if (window.testRunner)
+  testRunner.dumpAsText();
+
+window.getSelection().selectAllChildren(foobar);
+
+if (window.internals) {
+  result.innerText = internals.repaintRectsAsText();
+  internals.stopTrackingRepaints();
+}
+</script>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/ios/TestExpectations (287980 => 287981)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-01-13 17:16:07 UTC (rev 287980)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-01-13 18:21:34 UTC (rev 287981)
@@ -421,6 +421,7 @@
 editing/selection/selecting-content-by-overshooting-the-flex-container.html [ Skip ]
 editing/selection/selecting-content-by-overshooting-the-deprecated-flex-container.html [ Skip ]
 editing/selection/selecting-content-by-overshooting-the-grid-container.html [ Skip ]
+editing/selection-with-absolute-positioned-empty-content.html [ Skip ]
 editing/spelling/context-menu-suggestions-multiword-selection.html [ Skip ]
 editing/spelling/context-menu-suggestions-subword-selection.html [ Skip ]
 editing/spelling/context-menu-suggestions.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (287980 => 287981)


--- trunk/Source/WebCore/ChangeLog	2022-01-13 17:16:07 UTC (rev 287980)
+++ trunk/Source/WebCore/ChangeLog	2022-01-13 18:21:34 UTC (rev 287981)
@@ -1,3 +1,30 @@
+2022-01-13  Alan Bujtas  <[email protected]>
+
+        REGRESSION (r278561): Right clicking a link selects the full line with unrelated text
+        https://bugs.webkit.org/show_bug.cgi?id=235172
+        <rdar://84069534>
+
+        Reviewed by Dean Jackson.
+
+        r278561 slightly change highlightStateForTextBox's behavior which now (correctly) returns HighlightState::None when the
+        RenderText content is not part of the current selection. Prior to r278561, it returned the RenderText's original selection state
+        which in this case was HighlightState::End.
+
+        <div><span>A<br>B<span style="position: absolute"></span></span>C</div>
+
+        In this specific case when we select the outer <span>, we end up with the following selection states for the generated line boxes:
+          (B) -> "Inside"
+          (C) -> "None"
+        while previously (C) came back as "End" (note that the absolute positioned element does not generate line boxes).
+
+        Now as Line::selectionState traverses through the line boxes, it comes across an unexpected "Inside -> None" transition at the selection end boundary (B -> C)
+        which incorrectly leaves the line state in "Inside" and we paint the selection all the way to the end of the block.
+
+        Test: fast/editing/selection-with-absolute-positioned-empty-content.html
+
+        * layout/integration/InlineIteratorLine.cpp:
+        (WebCore::InlineIterator::Line::selectionState const):
+
 2022-01-13  Peng Liu  <[email protected]>
 
         Clean up MediaPlaybackTargetPicker::Client

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp (287980 => 287981)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-01-13 17:16:07 UTC (rev 287980)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-01-13 18:21:34 UTC (rev 287981)
@@ -190,7 +190,9 @@
         else if (boxState == RenderObject::HighlightState::None && state == RenderObject::HighlightState::Start) {
             // We are past the end of the selection.
             state = RenderObject::HighlightState::Both;
-        }
+        } else if (boxState == RenderObject::HighlightState::None && state == RenderObject::HighlightState::Inside)
+            state = RenderObject::HighlightState::End;
+
         if (state == RenderObject::HighlightState::Both)
             break;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to