Commit 63694859 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Fix printing in vertical writing modes.

Using page logical height as physical height isn't right, if writing
mode is vertical. Use it as physical *width* then.

Also update LayoutView::GetLayoutSize() documentation.

Bug: 881727
Change-Id: I67ca50df01315ea8dc7af9c57781ee1809ba68f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362749
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810148}
parent 9c50a80f
......@@ -753,8 +753,14 @@ PhysicalRect LayoutView::DocumentRect() const {
IntSize LayoutView::GetLayoutSize(
IncludeScrollbarsInRect scrollbar_inclusion) const {
if (ShouldUsePrintingLayout())
return IntSize(Size().Width().ToInt(), PageLogicalHeight().ToInt());
if (ShouldUsePrintingLayout()) {
LayoutSize size = Size();
if (StyleRef().IsHorizontalWritingMode())
size.SetHeight(PageLogicalHeight());
else
size.SetWidth(PageLogicalHeight());
return FlooredIntSize(size);
}
if (!frame_view_)
return IntSize();
......
......@@ -101,7 +101,7 @@ class CORE_EXPORT LayoutView final : public LayoutBlockFlow {
// Based on LocalFrameView::LayoutSize, but:
// - checks for null LocalFrameView
// - returns 0x0 if using printing layout
// - Replaces logical height with PageLogicalHeight() if using printing layout
// - scrollbar exclusion is compatible with root layer scrolling
IntSize GetLayoutSize(IncludeScrollbarsInRect = kExcludeScrollbars) const;
......
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
if (window.internals)
internals.settings.setShouldPrintBackgrounds(true);
</script>
<style>
body { margin:20px; }
</style>
<p style="position:absolute; right:0; top:0; width:200px;">
There should be a right-aligned blue box on the first page, and a
right-aligned hotpink box on the second page.
</p>
<div style="width:600px; height:100px; background:blue;"></div>
<!-- Retain the inline-start margin in the test by setting the top margin to
20px. Cancel out the block-start body margin (shouldn't be repeated on
every page) in the test, by setting the left margin to -20px. -->
<div style="break-before:page; width:600px; height:100px; margin:20px 0 0 -20px; background:hotpink;"></div>
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
if (window.internals)
internals.settings.setShouldPrintBackgrounds(true);
</script>
<style>
html { writing-mode: vertical-lr; }
body { margin:20px; }
</style>
<!-- Note: This test assumes that the page width is more than 600px and less
than 1200px. There's currently no way of specifying the page size for
tests. -->
<p style="writing-mode:horizontal-tb; position:absolute; right:0; top:0; width:200px;">
There should be a right-aligned blue box on the first page, and a
right-aligned hotpink box on the second page.
</p>
<div style="width:600px; height:100px; break-inside:avoid; background:blue;"></div>
<div style="width:600px; height:100px; break-inside:avoid; background:hotpink;"></div>
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
if (window.internals)
internals.settings.setShouldPrintBackgrounds(true);
</script>
<style>
body { margin:20px; }
</style>
<p style="position:absolute; left:0; top:0; width:200px;">
There should be a right-aligned blue box on the first page, and a
right-aligned hotpink box on the second page.
</p>
<!-- Right-align with auto left margin. -->
<div style="margin-left:auto; width:600px; height:100px; background:blue;"></div>
<!-- Retain the inline-start margin in the test by setting the top margin to
20px. Cancel out the block-start body margin (shouldn't be repeated on
every page) in the test, by setting the right margin to -20px. -->
<div style="break-before:page; width:600px; height:100px; margin:20px -20px 0 auto; background:hotpink;"></div>
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
if (window.internals)
internals.settings.setShouldPrintBackgrounds(true);
</script>
<style>
html { writing-mode: vertical-rl; }
body { margin:20px; }
</style>
<!-- Note: This test assumes that the page width is more than 600px and less
than 1200px. There's currently no way of specifying the page size for
tests. -->
<p style="writing-mode:horizontal-tb; position:absolute; left:0; top:0; width:200px;">
There should be a right-aligned blue box on the first page, and a
right-aligned hotpink box on the second page.
</p>
<div style="width:600px; height:100px; break-inside:avoid; background:blue;"></div>
<div style="width:600px; height:100px; break-inside:avoid; background:hotpink;"></div>
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