Commit 72d260d0 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Reland "Fix TransformNode::IsAffectedByOuterViewportBoundsDelta()"

This reverts commit c7cb1a8e.

Use a more reliable way to check if a fixed-pos element's container
is LayoutView.

The previous method of checking parent transform was not reliable
because the fixed-pos container may not create transform nodes.

Original change's description:
> Revert "Fix TransformNode::IsAffectedByOuterViewportBoundsDelta()"
>
> This reverts commit ea5c2a2c.
>
> Reason for revert: Checking the parent transform to check if a fix-pos
> element is contained by LayoutView is not reliable.
>
> Original change's description:
> > Fix TransformNode::IsAffectedByOuterViewportBoundsDelta()
> >
> > Don't set the flag in the following cases:
> > 1. The fixed element is contained by an ancestor below the LayoutView;
> > 2. The fixed element is not in the main frame.
> >
> > Bug: 978774
> > Change-Id: I430dc968c0d016ac9bee4f4934508703a3b90645
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1680938
> > Reviewed-by: David Bokan <bokan@chromium.org>
> > Reviewed-by: Philip Rogers <pdr@chromium.org>
> > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#673239}
>
> TBR=wangxianzhu@chromium.org,bokan@chromium.org,pdr@chromium.org
>
> Change-Id: I120ced5c25468a81e0d9ec227073597dce7bb2c8
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 978774
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1680734
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#673370}

Change-Id: I5fc8f9c354f616068899b967160425d481dc2c26
Bug: 978774
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1681931Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#673439}
parent ce031a07
...@@ -169,6 +169,7 @@ class FragmentPaintPropertyTreeBuilder { ...@@ -169,6 +169,7 @@ class FragmentPaintPropertyTreeBuilder {
private: private:
ALWAYS_INLINE void UpdatePaintOffset(); ALWAYS_INLINE void UpdatePaintOffset();
ALWAYS_INLINE void UpdateForPaintOffsetTranslation(base::Optional<IntPoint>&); ALWAYS_INLINE void UpdateForPaintOffsetTranslation(base::Optional<IntPoint>&);
ALWAYS_INLINE bool IsAffectedByOuterViewportBoundsDelta() const;
ALWAYS_INLINE void UpdatePaintOffsetTranslation( ALWAYS_INLINE void UpdatePaintOffsetTranslation(
const base::Optional<IntPoint>&); const base::Optional<IntPoint>&);
ALWAYS_INLINE void SetNeedsPaintPropertyUpdateIfNeeded(); ALWAYS_INLINE void SetNeedsPaintPropertyUpdateIfNeeded();
...@@ -456,6 +457,18 @@ void FragmentPaintPropertyTreeBuilder::UpdateForPaintOffsetTranslation( ...@@ -456,6 +457,18 @@ void FragmentPaintPropertyTreeBuilder::UpdateForPaintOffsetTranslation(
context_.current.paint_offset = subpixel_accumulation; context_.current.paint_offset = subpixel_accumulation;
} }
bool FragmentPaintPropertyTreeBuilder::IsAffectedByOuterViewportBoundsDelta()
const {
if (object_.StyleRef().GetPosition() != EPosition::kFixed ||
!object_.StyleRef().IsFixedToBottom() ||
!object_.GetFrame()->IsMainFrame())
return false;
// It's affected by viewport only if the container is the LayoutView.
DCHECK_EQ(full_context_.container_for_fixed_position, object_.Container());
return full_context_.container_for_fixed_position->IsLayoutView();
}
void FragmentPaintPropertyTreeBuilder::UpdatePaintOffsetTranslation( void FragmentPaintPropertyTreeBuilder::UpdatePaintOffsetTranslation(
const base::Optional<IntPoint>& paint_offset_translation) { const base::Optional<IntPoint>& paint_offset_translation) {
DCHECK(properties_); DCHECK(properties_);
...@@ -465,11 +478,8 @@ void FragmentPaintPropertyTreeBuilder::UpdatePaintOffsetTranslation( ...@@ -465,11 +478,8 @@ void FragmentPaintPropertyTreeBuilder::UpdatePaintOffsetTranslation(
FloatSize(ToIntSize(*paint_offset_translation))}; FloatSize(ToIntSize(*paint_offset_translation))};
state.flattens_inherited_transform = state.flattens_inherited_transform =
context_.current.should_flatten_inherited_transform; context_.current.should_flatten_inherited_transform;
state.affected_by_outer_viewport_bounds_delta = state.affected_by_outer_viewport_bounds_delta =
object_.StyleRef().GetPosition() == EPosition::kFixed && IsAffectedByOuterViewportBoundsDelta();
object_.StyleRef().IsFixedToBottom();
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() || if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
state.rendering_context_id = context_.current.rendering_context_id; state.rendering_context_id = context_.current.rendering_context_id;
......
...@@ -6795,4 +6795,45 @@ TEST_P(PaintPropertyTreeBuilderTest, SetViewportScrollingBits) { ...@@ -6795,4 +6795,45 @@ TEST_P(PaintPropertyTreeBuilderTest, SetViewportScrollingBits) {
} }
} }
TEST_P(PaintPropertyTreeBuilderTest, IsAffectedByOuterViewportBoundsDelta) {
SetBodyInnerHTML(R"HTML(
<style>div { will-change: transform; position: fixed; }</style>
<div id="fixed1"></div>
<div id="fixed2" style="right: 0"></div>
<div id="fixed3" style="bottom: 0"></div>
<div id="fixed4" style="bottom: 20px"></div>
<div style="transform: translateX(100px)">
<div id="fixed5" style="bottom: 0"></div>
</div>
<iframe></iframe>
)HTML");
SetChildFrameHTML(R"HTML(
<div id="fixed"
style="will-change: transform; position: fixed; bottom: 0"></div>
)HTML");
UpdateAllLifecyclePhasesForTest();
auto check_result = [&](const ObjectPaintProperties* properties,
bool expected) {
ASSERT_TRUE(properties);
ASSERT_TRUE(properties->PaintOffsetTranslation());
EXPECT_EQ(expected, properties->PaintOffsetTranslation()
->IsAffectedByOuterViewportBoundsDelta());
};
check_result(PaintPropertiesForElement("fixed1"), false);
check_result(PaintPropertiesForElement("fixed2"), false);
check_result(PaintPropertiesForElement("fixed3"), true);
check_result(PaintPropertiesForElement("fixed4"), true);
check_result(PaintPropertiesForElement("fixed5"), false);
// Fixed elements in subframes are not affected by viewport.
check_result(ChildDocument()
.getElementById("fixed")
->GetLayoutObject()
->FirstFragment()
.PaintProperties(),
false);
}
} // 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