Commit 79205a19 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Correct LayoutText::Quads() for vertical-rl.

NG needs to produce a rectangle with the block-axis offset relatively to
block-start of the container, just like legacy does. Using purely
physical coordinates is wrong.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I9989628dcc339c71d850818498538aafa142ed29
Reviewed-on: https://chromium-review.googlesource.com/c/1261698Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596747}
parent a1723da5
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-element-getclientrects">
<div style="position:absolute; top:0; left:0; width:200px; height:100px; writing-mode:horizontal-tb; direction:ltr;">
<br id="child">
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=>{
let r = document.getElementById("child").getClientRects()[0];
assert_equals(r.left, 0);
assert_greater_than_equal(r.top, 0);
assert_less_than(r.top, 50);
}, "Position of the BR element");
</script>
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-element-getclientrects">
<div style="position:absolute; top:0; left:0; width:200px; height:100px; writing-mode:horizontal-tb; direction:rtl;">
<br id="child">
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=>{
let r = document.getElementById("child").getClientRects()[0];
assert_equals(r.left, 200);
assert_greater_than_equal(r.top, 0);
assert_less_than(r.top, 50);
}, "Position of the BR element");
</script>
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-element-getclientrects">
<div style="position:absolute; top:0; left:0; width:200px; height:100px; writing-mode:vertical-lr; direction:ltr;">
<br id="child">
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=>{
let r = document.getElementById("child").getClientRects()[0];
assert_greater_than_equal(r.left, 0);
assert_less_than(r.left, 50);
assert_equals(r.top, 0);
}, "Position of the BR element");
</script>
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-element-getclientrects">
<div style="position:absolute; top:0; left:0; width:200px; height:100px; writing-mode:vertical-lr; direction:rtl;">
<br id="child">
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=>{
let r = document.getElementById("child").getClientRects()[0];
assert_greater_than_equal(r.left, 0);
assert_less_than(r.left, 50);
assert_equals(r.top, 100);
}, "Position of the BR element");
</script>
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-element-getclientrects">
<div style="position:absolute; top:0; left:0; width:200px; height:100px; writing-mode:vertical-rl; direction:ltr;">
<br id="child">
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=>{
let r = document.getElementById("child").getClientRects()[0];
assert_greater_than(r.left, 150);
assert_less_than(r.left, 200);
assert_equals(r.top, 0);
}, "Position of the BR element");
</script>
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://drafts.csswg.org/cssom-view-1/#dom-element-getclientrects">
<div style="position:absolute; top:0; left:0; width:200px; height:100px; writing-mode:vertical-rl; direction:rtl;">
<br id="child">
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=>{
let r = document.getElementById("child").getClientRects()[0];
assert_greater_than(r.left, 150);
assert_less_than(r.left, 200);
assert_equals(r.top, 100);
}, "Position of the BR element");
</script>
......@@ -466,10 +466,15 @@ void LayoutText::Quads(Vector<FloatQuad>& quads,
EnclosingBlockFlowFragment()) {
const auto children =
NGInlineFragmentTraversal::SelfFragmentsOf(*box_fragment, this);
const LayoutBlock* block_for_flipping = nullptr;
if (UNLIKELY(HasFlippedBlocksWritingMode()))
block_for_flipping = ContainingBlock();
for (const auto& child : children) {
// TODO(layout-dev): We should have NG version of |EllipsisRectForBox()|
AccumlateQuads(quads, IntRect(), local_or_absolute, mode,
child.RectInContainerBox().ToLayoutRect());
LayoutRect rect = child.RectInContainerBox().ToLayoutRect();
if (UNLIKELY(block_for_flipping))
block_for_flipping->FlipForWritingMode(rect);
AccumlateQuads(quads, IntRect(), local_or_absolute, mode, rect);
}
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment