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

[Blink] Add fixed-pos counterscroll in PaintLayerClipper for RLS mode

The caller of PaintLayerClipper expects the returned clip rect to be in
the scrolled space of LayoutView, while the computed clip rect for a
fixed-pos layer is in the unscrolled space prior to compensation. The
fixed-pos compensation has been done for non-RLS mode, this CL adds the
RLS counterpart.

BUG=821279

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I48a92d0614d97c745fe66b1265dce0613514ffc4
Reviewed-on: https://chromium-review.googlesource.com/961643Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543584}
parent 5ddd8560
...@@ -635,7 +635,7 @@ void PaintLayerClipper::CalculateBackgroundClipRect( ...@@ -635,7 +635,7 @@ void PaintLayerClipper::CalculateBackgroundClipRect(
if (parent_clip_rects->Fixed() && if (parent_clip_rects->Fixed() &&
&context.root_layer->GetLayoutObject() == layout_view && &context.root_layer->GetLayoutObject() == layout_view &&
output != LayoutRect(LayoutRect::InfiniteIntRect())) output != LayoutRect(LayoutRect::InfiniteIntRect()))
output.Move(LayoutSize(layout_view->GetFrameView()->GetScrollOffset())); output.Move(LayoutSize(layout_view->OffsetForFixedPosition()));
} }
void PaintLayerClipper::GetOrCalculateClipRects(const ClipRectsContext& context, void PaintLayerClipper::GetOrCalculateClipRects(const ClipRectsContext& context,
......
...@@ -864,4 +864,56 @@ TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) { ...@@ -864,4 +864,56 @@ TEST_F(PaintLayerClipperTest, ScrollbarClipBehaviorParent) {
EXPECT_EQ(LayoutRect(0, 0, 200, 300), layer_bounds); EXPECT_EQ(LayoutRect(0, 0, 200, 300), layer_bounds);
} }
class PaintLayerClipperTestParameterized
: public ::testing::WithParamInterface<bool>,
private ScopedRootLayerScrollingForTest,
public PaintLayerClipperTest {
public:
PaintLayerClipperTestParameterized()
: ScopedRootLayerScrollingForTest(GetParam()) {}
};
INSTANTIATE_TEST_CASE_P(All,
PaintLayerClipperTestParameterized,
::testing::Bool());
TEST_P(PaintLayerClipperTestParameterized, FixedLayerClipRectInDocumentSpace) {
SetBodyInnerHTML(R"HTML(
<div style="position:fixed; left:100px; top:200px; width:300px; height:400px; overflow:hidden;">
<div id="target" style="position:relative;"></div>
</div>
<div style="height:3000px;"></div>
)HTML");
Element* target = GetDocument().getElementById("target");
PaintLayer* target_layer =
ToLayoutBoxModelObject(target->GetLayoutObject())->Layer();
{
ClipRect clip_rect;
target_layer->Clipper(PaintLayer::kDoNotUseGeometryMapper)
.CalculateBackgroundClipRect(
ClipRectsContext(GetDocument().GetLayoutView()->Layer(),
kAbsoluteClipRectsIgnoringViewportClip,
kIgnorePlatformOverlayScrollbarSize,
kIgnoreOverflowClipAndScroll),
clip_rect);
EXPECT_EQ(LayoutRect(100, 200, 300, 400), clip_rect.Rect());
}
GetDocument().domWindow()->scrollTo(0, 50);
{
ClipRect clip_rect;
target_layer->Clipper(PaintLayer::kDoNotUseGeometryMapper)
.CalculateBackgroundClipRect(
ClipRectsContext(GetDocument().GetLayoutView()->Layer(),
kAbsoluteClipRectsIgnoringViewportClip,
kIgnorePlatformOverlayScrollbarSize,
kIgnoreOverflowClipAndScroll),
clip_rect);
EXPECT_EQ(LayoutRect(100, 250, 300, 400), clip_rect.Rect());
}
}
} // namespace blink } // namespace blink
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