8000 Unexpected overlapping selection with tab in RTL context. · WebKit/WebKit@6361a69 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6361a69

Browse files
committed
Unexpected overlapping selection with tab in RTL context.
https://bugs.webkit.org/show_bug.cgi?id=251169 Reviewed by Antti Koivisto. In order to get the correct advanced width at selection paint time we need to pass in the "logical horizontal position" (the value we used at layout). * LayoutTests/fast/repaint/rtl-with-position-dependent-content-width-selection-expected.txt: Added. * LayoutTests/fast/repaint/rtl-with-position-dependent-content-width-selection.html: Added. * Source/WebCore/layout/integration/inline/InlineIteratorBoxModernPath.h: (WebCore::InlineIterator::BoxModernPath::textRun const): Canonical link: https://commits.webkit.org/259460@main
1 parent 1aae682 commit 6361a69

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
X
2+
(repaint rects
3+
(rect 8 8 109 46)
4+
)
5+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<style>
2+
div {
3+
direction: rtl;
4+
white-space: pre;
5+
font-size: 40px;
6+
float: left;
7+
}
8+
</style>
9+
<div id=select_this> X</div>
10+
<script src="../../resources/ui-helper.js"></script>
11+
<script>
12+
if (window.testRunner) {
13+
testRunner.dumpAsText();
14+
testRunner.waitUntilDone();
15+
}
16+
17+
async function repaintTest() {
18+
if (window.internals)
19+
internals.startTrackingRepaints();
20+
21+
let range = document.createRange();
22+
range.selectNodeContents(select_this);
23+
window.getSelection().addRange(range);
24+
25+
await UIHelper.renderingUpdate();
26+
27+
if (window.internals) {
28+
var repaintRects = internals.repaintRectsAsText();
29+
internals.stopTrackingRepaints();
30+
var pre = document.createElement('pre');
31+
document.body.appendChild(pre);
32+
pre.innerHTML = repaintRects;
33+
}
34+
35+
if (window.testRunner)
36+
testRunner.notifyDone();
37+
}
38+
setTimeout(repaintTest, 0);
39+
40+
</script>

Source/WebCore/layout/integration/inline/InlineIteratorBoxModernPath.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ class BoxModernPath {
9292
{
9393
auto& style = box().style();
9494
auto expansion = box().expansion();
95-
auto rect = this->visualRectIgnoringBlockDirection();
96-
auto xPos = rect.x() - (line().lineBoxLeft() + line().contentLogicalLeftIgnoringInlineDirection());
95+
auto logicalLeft = [&] {
96+
if (style.isLeftToRightDirection())
97+
return visualRectIgnoringBlockDirection().x() - (line().lineBoxLeft() + line().contentLogicalLeft());
98+
return line().lineBoxRight() - (visualRectIgnoringBlockDirection().maxX() + line().contentLogicalLeft());
99+
};
97100
auto characterScanForCodePath = isText() && !renderText().canUseSimpleFontCodePath();
98-
auto textRun = TextRun { mode == TextRunMode::Editing ? originalText() : box().text()->renderedContent(), xPos, expansion.horizontalExpansion, expansion.behavior, direction(), style.rtlOrdering() == Order::Visual, characterScanForCodePath };
101+
auto textRun = TextRun { mode == TextRunMode::Editing ? originalText() : box().text()->renderedContent(), logicalLeft(), expansion.horizontalExpansion, expansion.behavior, direction(), style.rtlOrdering() == Order::Visual, characterScanForCodePath };
99102
textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
100103
return textRun;
101104
};

0 commit comments

Comments
 (0)
0