Skip to content
Permalink
Browse files
REGRESSION (r278561): Right clicking a link selects the full line wit…
…h 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.



Canonical link: https://commits.webkit.org/246010@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287981 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Jan 13, 2022
1 parent f15bd5c commit 06a0eb09e04a59cd7015a0c97b3feb6177c56789
@@ -1,3 +1,14 @@
2022-01-13 Alan Bujtas <zalan@apple.com>

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 <svillar@igalia.com>

[css-flexbox] Incorrect height of flex items with aspect-ratio whenever the cross axis intrinsic size is larger than the viewport
@@ -0,0 +1,6 @@
select this text but not this
(repaint rects
(rect 8 8 220 40)
(rect 228 8 564 20)
)

@@ -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="">select 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>
@@ -421,6 +421,7 @@ editing/selection/select-out-of-floated-non-editable-13.html [ Skip ]
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 ]
@@ -1,3 +1,30 @@
2022-01-13 Alan Bujtas <zalan@apple.com>

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 <peng.liu6@apple.com>

Clean up MediaPlaybackTargetPicker::Client
@@ -190,7 +190,9 @@ RenderObject::HighlightState Line::selectionState() const
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;
}

0 comments on commit 06a0eb0

Please sign in to comment.