Commit 6bfdf66c authored by Tien-Ren Chen's avatar Tien-Ren Chen Committed by Commit Bot

[Blink/SPv175] Fix background-attachment:fixed for SPv175

This CL fixes two bugs with background-attachment:fixed computation:

1. Since CL 827671 we switch root layer in PaintInfo whenever the
current transform node changes. This has a side effect that the painting
root layer is no longer guaranteed to be a containing block ancestor of
the current layout object, and AccumulatedScrollOffsetForFixedBackground()
may skip over the painting root all the way to the root. This CL adds
the skipping check to ensure we only collect scroll offsets up to the
painting root.

2. FixedAttachmentPositioningArea() converts the viewport rect to the
space of the current paint context. Prior to SPv175 the border box space
of the painting root is always equivalent to the space of the current
paint context, so FixedAttachmentPositioningArea() did just that. In
SPv175 the painting root may not always create a paint offset
translation in case of a squashed layer, thus can induce an offset from
its transform node. This CL ensures the paint offset taken into account.

BUG=529963,849854

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ib2f84a619235ab4ec6a9bfc695b57aae9d41b808
Reviewed-on: https://chromium-review.googlesource.com/1098313
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567030}
parent 098960b5
<!DOCTYPE html>
<div style="position:absolute; left:0; top:0; width:100px; height:97px; background:url(../../paint/invalidation/resources/grid.png);"></div>
<!DOCTYPE html>
<style>
::-webkit-scrollbar {
display: none;
}
</style>
<div style="position:absolute; left:0; top:0; width:100px; height:100px; background:fixed url(../../paint/invalidation/resources/grid.png);"></div>
<div style="height:1000px;"></div>
<script>
scrollTo(0, 3);
</script>
<!DOCTYPE html>
<div style="position:absolute; left:0; top:0; width:100px; height:100px; background:url(../../paint/invalidation/resources/grid.png);"></div>
<!DOCTYPE html>
<style>
::-webkit-scrollbar {
display: none;
}
</style>
<div style="height:1000px; will-change:transform;"></div>
<div style="position:absolute; left:0; top:3px; width:100px; height:100px; background:fixed url(../../paint/invalidation/resources/grid.png);"></div>
<script>
scrollTo(0, 3);
</script>
...@@ -177,8 +177,11 @@ IntPoint AccumulatedScrollOffsetForFixedBackground( ...@@ -177,8 +177,11 @@ IntPoint AccumulatedScrollOffsetForFixedBackground(
IntPoint result; IntPoint result;
if (&object == container) if (&object == container)
return result; return result;
for (const LayoutBlock* block = object.ContainingBlock(); block;
block = block->ContainingBlock()) { LayoutObject::AncestorSkipInfo skip_info(container);
for (const LayoutBlock* block = object.ContainingBlock(&skip_info);
block && !skip_info.AncestorSkipped();
block = block->ContainingBlock(&skip_info)) {
if (block->HasOverflowClip()) if (block->HasOverflowClip())
result += block->ScrolledContentOffset(); result += block->ScrolledContentOffset();
if (block == container) if (block == container)
...@@ -449,13 +452,27 @@ LayoutRect FixedAttachmentPositioningArea(const LayoutBoxModelObject& obj, ...@@ -449,13 +452,27 @@ LayoutRect FixedAttachmentPositioningArea(const LayoutBoxModelObject& obj,
rect.SetLocation(IntPoint(ToLayoutView(obj).ScrolledContentOffset())); rect.SetLocation(IntPoint(ToLayoutView(obj).ScrolledContentOffset()));
} }
// Compensate the translations created by ScrollRecorders.
// TODO(trchen): Fix this for SP phase 2. crbug.com/529963.
rect.MoveBy(AccumulatedScrollOffsetForFixedBackground(obj, container)); rect.MoveBy(AccumulatedScrollOffsetForFixedBackground(obj, container));
if (container) if (container)
rect.MoveBy(LayoutPoint(-container->LocalToAbsolute(FloatPoint()))); rect.MoveBy(LayoutPoint(-container->LocalToAbsolute(FloatPoint())));
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) {
// By now we have converted the viewport rect to the border box space of
// |container|, however |container| does not necessarily create a paint
// offset translation node, thus its paint offset must be added to convert
// the rect to the space of the transform node.
// TODO(trchen): This function does only one simple thing -- mapping the
// viewport rect from frame space to whatever space the current paint
// context uses. However we can't always invoke geometry mapper because
// there are at least one caller uses this before PrePaint phase.
if (container) {
DCHECK_GE(container->GetDocument().Lifecycle().GetState(),
DocumentLifecycle::kPrePaintClean);
rect.MoveBy(container->FirstFragment().PaintOffset());
}
}
return rect; return rect;
} }
......
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