Commit 4e5257d2 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Correct scroll compensation when printing in vertical writing-modes.

We have code that compensates for the scroll offset on screen when
printing, but this didn't work correctly in vertical writing modes.

When printing, we set a rectangle for each page in logical coordinates,
and then transpose it to physical coordinates if writing mode is
vertical. The scroll offset, however, is already in physical
coordinates, so we have to apply this after transposing.

Pagination in vertical writing modes is very broken (crbug.com/881727),
but before we can even get to that problem, we need to make sure that
scrolling doesn't cause problems.

Bug: 1123706, 881727
Change-Id: Ie0370bcd5c0856afe2e1ca8f85ecaa1ce752f92d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386735Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803387}
parent 233a5213
......@@ -131,13 +131,12 @@ void PrintContext::ComputePageRectsWithPageSizeInternal(
: inline_direction_start - page_logical_width;
auto* scrollable_area = GetFrame()->View()->LayoutViewport();
IntSize frame_scroll = scrollable_area->ScrollOffsetInt();
page_logical_left -= frame_scroll.Width();
page_logical_top -= frame_scroll.Height();
IntRect page_rect(page_logical_left, page_logical_top, page_logical_width,
page_logical_height);
if (!is_horizontal)
page_rect = page_rect.TransposedRect();
IntSize frame_scroll = scrollable_area->ScrollOffsetInt();
page_rect.Move(-frame_scroll.Width(), -frame_scroll.Height());
page_rects_.push_back(page_rect);
}
}
......
<!DOCTYPE html>
<div style="font-size:3em;">PASS</div>
<div style="width:5000px; height:5000px;"></div>
<script>
if (window.testRunner)
testRunner.setPrinting();
</script>
<!DOCTYPE html>
<div style="font-size:3em;">PASS</div>
<div style="width:5000px; height:5000px;"></div>
<script>
window.scroll(1000, 100);
if (window.testRunner)
testRunner.setPrinting();
</script>
<!DOCTYPE html>
<style>
html { writing-mode:vertical-lr; }
</style>
<div style="writing-mode:horizontal-tb; font-size:3em;">PASS</div>
<div style="width:5000px; height:5000px;"></div>
<script>
if (window.testRunner)
testRunner.setPrinting();
</script>
<!DOCTYPE html>
<style>
html { writing-mode:vertical-lr; }
</style>
<div style="writing-mode:horizontal-tb; font-size:3em;">PASS</div>
<div style="width:5000px; height:5000px;"></div>
<script>
window.scroll(100, 1000);
if (window.testRunner)
testRunner.setPrinting();
</script>
<!DOCTYPE html>
<style>
html { writing-mode:vertical-rl; }
</style>
<div style="writing-mode:horizontal-tb; font-size:3em;">PASS</div>
<div style="width:5000px; height:5000px;"></div>
<script>
if (window.testRunner)
testRunner.setPrinting();
</script>
<!DOCTYPE html>
<style>
html { writing-mode:vertical-rl; }
</style>
<div style="writing-mode:horizontal-tb; font-size:3em;">PASS</div>
<div style="width:5000px; height:5000px;"></div>
<script>
window.scroll(100, 1000);
if (window.testRunner)
testRunner.setPrinting();
</script>
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