Commit 0c3cbcc1 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Revert "[CI] Combine GetBackgroundPaintLocation of PaintLayer and LayoutBoxModelObject"

This reverts commit af460e9a.

Reason for revert:
Seems to have broken paint/invalidation/table/cached-69296.html from webkit_layout_tests on Mac 10.11 - currently failed 7/7 times after this landed:
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Mac10.11%20Tests
First failing build:
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Mac10.11%20Tests/30030

Original change's description:
> [CI] Combine GetBackgroundPaintLocation of PaintLayer and LayoutBoxModelObject
> 
> For fixing SlimmingPaintV2 scrolling background painting and
> invalidation, we need a single place to get the accurate value
> of the background paint location.
> 
> Bug: 732611
> 
> Change-Id: I0ad696395d73c9c19078e13e9a32cf9dbd0c628f
> Reviewed-on: https://chromium-review.googlesource.com/c/1297586
> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> Reviewed-by: Robert Flack <flackr@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#602250}

TBR=flackr@chromium.org,wangxianzhu@chromium.org

Change-Id: I279520fc9deafd9891dd3a5457e42d6fa0b201aa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 732611
Reviewed-on: https://chromium-review.googlesource.com/c/1297362Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602289}
parent ac476a6e
...@@ -98,30 +98,18 @@ bool LayoutBoxModelObject::UsesCompositedScrolling() const { ...@@ -98,30 +98,18 @@ bool LayoutBoxModelObject::UsesCompositedScrolling() const {
} }
BackgroundPaintLocation LayoutBoxModelObject::GetBackgroundPaintLocation( BackgroundPaintLocation LayoutBoxModelObject::GetBackgroundPaintLocation(
uint32_t* main_thread_scrolling_reasons) const { uint32_t* reasons) const {
bool may_have_scrolling_layers_without_scrolling = IsLayoutView(); bool has_custom_scrollbars = false;
const auto* scrollable_area = GetScrollableArea();
bool scrolls_overflow = scrollable_area && scrollable_area->ScrollsOverflow();
if (!scrolls_overflow && !may_have_scrolling_layers_without_scrolling)
return kBackgroundPaintInGraphicsLayer;
// If we care about LCD text, paint root backgrounds into scrolling contents
// layer even if style suggests otherwise. (For non-root scrollers, we just
// avoid compositing - see PLSA::ComputeNeedsCompositedScrolling.)
if (IsLayoutView()) {
DCHECK(Layer()->Compositor());
if (!Layer()->Compositor()->PreferCompositingToLCDTextEnabled())
return kBackgroundPaintInScrollingContents;
}
// TODO(flackr): Detect opaque custom scrollbars which would cover up a // TODO(flackr): Detect opaque custom scrollbars which would cover up a
// border-box background. // border-box background.
bool has_custom_scrollbars = if (PaintLayerScrollableArea* scrollable_area = GetScrollableArea()) {
scrollable_area && if ((scrollable_area->HorizontalScrollbar() &&
((scrollable_area->HorizontalScrollbar() && scrollable_area->HorizontalScrollbar()->IsCustomScrollbar()) ||
scrollable_area->HorizontalScrollbar()->IsCustomScrollbar()) || (scrollable_area->VerticalScrollbar() &&
(scrollable_area->VerticalScrollbar() && scrollable_area->VerticalScrollbar()->IsCustomScrollbar())) {
scrollable_area->VerticalScrollbar()->IsCustomScrollbar())); has_custom_scrollbars = true;
}
}
// TODO(flackr): When we correctly clip the scrolling contents layer we can // TODO(flackr): When we correctly clip the scrolling contents layer we can
// paint locally equivalent backgrounds into it. https://crbug.com/645957 // paint locally equivalent backgrounds into it. https://crbug.com/645957
...@@ -132,10 +120,8 @@ BackgroundPaintLocation LayoutBoxModelObject::GetBackgroundPaintLocation( ...@@ -132,10 +120,8 @@ BackgroundPaintLocation LayoutBoxModelObject::GetBackgroundPaintLocation(
// painting into the composited scrolling contents layer. // painting into the composited scrolling contents layer.
// https://crbug.com/646464 // https://crbug.com/646464
if (StyleRef().BoxShadow()) { if (StyleRef().BoxShadow()) {
if (main_thread_scrolling_reasons) { if (reasons)
*main_thread_scrolling_reasons |= *reasons |= MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer;
MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer;
}
return kBackgroundPaintInGraphicsLayer; return kBackgroundPaintInGraphicsLayer;
} }
......
...@@ -188,12 +188,7 @@ class CORE_EXPORT LayoutBoxModelObject : public LayoutObject { ...@@ -188,12 +188,7 @@ class CORE_EXPORT LayoutBoxModelObject : public LayoutObject {
// Returns which layers backgrounds should be painted into for overflow // Returns which layers backgrounds should be painted into for overflow
// scrolling boxes. // scrolling boxes.
// TODO(yigu): PaintLayerScrollableArea::ComputeNeedsCompositedScrolling BackgroundPaintLocation GetBackgroundPaintLocation(uint32_t* reasons) const;
// calls this method to obtain main thread scrolling reasons due to
// background paint location. Once the cases get handled on compositor the
// parameter "reasons" could be removed.
BackgroundPaintLocation GetBackgroundPaintLocation(
uint32_t* main_thread_scrolling_reasons = nullptr) const;
// These return the CSS computed padding values. // These return the CSS computed padding values.
LayoutUnit ComputedCSSPaddingTop() const { LayoutUnit ComputedCSSPaddingTop() const {
......
...@@ -409,7 +409,7 @@ void CompositedLayerMapping::UpdateBackgroundPaintsOntoScrollingContentsLayer( ...@@ -409,7 +409,7 @@ void CompositedLayerMapping::UpdateBackgroundPaintsOntoScrollingContentsLayer(
// it would be visually correct and we are using composited scrolling meaning // it would be visually correct and we are using composited scrolling meaning
// we have a scrolling contents layer to paint it into. // we have a scrolling contents layer to paint it into.
BackgroundPaintLocation paint_location = BackgroundPaintLocation paint_location =
GetLayoutObject().GetBackgroundPaintLocation(); owning_layer_.GetBackgroundPaintLocation();
bool should_paint_onto_scrolling_contents_layer = bool should_paint_onto_scrolling_contents_layer =
paint_location & kBackgroundPaintInScrollingContents && paint_location & kBackgroundPaintInScrollingContents &&
owning_layer_.GetScrollableArea()->UsesCompositedScrolling(); owning_layer_.GetScrollableArea()->UsesCompositedScrolling();
...@@ -473,7 +473,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() { ...@@ -473,7 +473,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
owning_layer_.BackgroundIsKnownToBeOpaqueInRect( owning_layer_.BackgroundIsKnownToBeOpaqueInRect(
ToLayoutBox(GetLayoutObject()).PhysicalPaddingBoxRect())); ToLayoutBox(GetLayoutObject()).PhysicalPaddingBoxRect()));
if (GetLayoutObject().GetBackgroundPaintLocation() & if (owning_layer_.GetBackgroundPaintLocation() &
kBackgroundPaintInGraphicsLayer) { kBackgroundPaintInGraphicsLayer) {
graphics_layer_->SetContentsOpaque( graphics_layer_->SetContentsOpaque(
owning_layer_.BackgroundIsKnownToBeOpaqueInRect( owning_layer_.BackgroundIsKnownToBeOpaqueInRect(
......
...@@ -1157,21 +1157,23 @@ TEST_F(CompositedLayerMappingTest, ...@@ -1157,21 +1157,23 @@ TEST_F(CompositedLayerMappingTest,
true); true);
SetBodyInnerHTML(R"HTML( SetBodyInnerHTML(R"HTML(
<div id='container' style='overflow: scroll; width: 300px; height: <div id='container' style='overflow: scroll; width: 300px; height:
300px; background: white; will-change: transform;'> 300px; background: white; will-change: transform;'>
<div style='background-color: blue; width: 2000px; height: 2000px; <div style='background-color: blue; clip-path: circle(600px at 1000px 1000px);
clip-path: circle(600px at 1000px 1000px);'></div> width: 2000px; height:
2000px;'></div>
</div> </div>
)HTML"); )HTML");
const auto* container = ToLayoutBox(GetLayoutObjectByElementId("container")); PaintLayer* layer =
ToLayoutBlock(GetLayoutObjectByElementId("container"))->Layer();
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(kBackgroundPaintInScrollingContents,
container->GetBackgroundPaintLocation()); layer->GetBackgroundPaintLocation());
// We currently don't use composited scrolling when the container has a // We currently don't use composited scrolling when the container has a
// border-radius so even though we can paint the background onto the scrolling // border-radius so even though we can paint the background onto the scrolling
// contents layer we don't have a scrolling contents layer to paint into in // contents layer we don't have a scrolling contents layer to paint into in
// this case. // this case.
const auto* mapping = container->Layer()->GetCompositedLayerMapping(); CompositedLayerMapping* mapping = layer->GetCompositedLayerMapping();
EXPECT_FALSE(mapping->HasScrollingLayer()); EXPECT_FALSE(mapping->HasScrollingLayer());
EXPECT_FALSE(mapping->BackgroundPaintsOntoScrollingContentsLayer()); EXPECT_FALSE(mapping->BackgroundPaintsOntoScrollingContentsLayer());
} }
......
...@@ -300,7 +300,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedLayoutViewResize) { ...@@ -300,7 +300,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedLayoutViewResize) {
target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); target->setAttribute(HTMLNames::styleAttr, "height: 2000px");
GetDocument().View()->UpdateAllLifecyclePhases(); GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(kBackgroundPaintInScrollingContents,
GetLayoutView().GetBackgroundPaintLocation()); GetLayoutView().Layer()->GetBackgroundPaintLocation());
const auto* mapping = GetLayoutView().Layer()->GetCompositedLayerMapping(); const auto* mapping = GetLayoutView().Layer()->GetCompositedLayerMapping();
EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer()); EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer());
EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer()); EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer());
...@@ -337,7 +337,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedLayoutViewGradientResize) { ...@@ -337,7 +337,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedLayoutViewGradientResize) {
target->setAttribute(HTMLNames::styleAttr, "height: 2000px"); target->setAttribute(HTMLNames::styleAttr, "height: 2000px");
GetDocument().View()->UpdateAllLifecyclePhases(); GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(kBackgroundPaintInScrollingContents,
GetLayoutView().GetBackgroundPaintLocation()); GetLayoutView().Layer()->GetBackgroundPaintLocation());
const auto* mapping = GetLayoutView().Layer()->GetCompositedLayerMapping(); const auto* mapping = GetLayoutView().Layer()->GetCompositedLayerMapping();
EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer()); EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer());
EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer()); EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer());
...@@ -386,6 +386,7 @@ TEST_P(PaintAndRasterInvalidationTest, NonCompositedLayoutViewResize) { ...@@ -386,6 +386,7 @@ TEST_P(PaintAndRasterInvalidationTest, NonCompositedLayoutViewResize) {
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(kBackgroundPaintInScrollingContents,
content->GetLayoutObject() content->GetLayoutObject()
->View() ->View()
->Layer()
->GetBackgroundPaintLocation()); ->GetBackgroundPaintLocation());
// Resize the content. // Resize the content.
...@@ -480,7 +481,7 @@ TEST_P(PaintAndRasterInvalidationTest, ...@@ -480,7 +481,7 @@ TEST_P(PaintAndRasterInvalidationTest,
auto* target_obj = ToLayoutBoxModelObject(target->GetLayoutObject()); auto* target_obj = ToLayoutBoxModelObject(target->GetLayoutObject());
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(kBackgroundPaintInScrollingContents,
target_obj->GetBackgroundPaintLocation()); target_obj->Layer()->GetBackgroundPaintLocation());
const auto* mapping = target_obj->Layer()->GetCompositedLayerMapping(); const auto* mapping = target_obj->Layer()->GetCompositedLayerMapping();
EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer()); EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer());
EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer()); EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer());
...@@ -550,7 +551,7 @@ TEST_P(PaintAndRasterInvalidationTest, ...@@ -550,7 +551,7 @@ TEST_P(PaintAndRasterInvalidationTest,
LayoutBoxModelObject* target_obj = LayoutBoxModelObject* target_obj =
ToLayoutBoxModelObject(target->GetLayoutObject()); ToLayoutBoxModelObject(target->GetLayoutObject());
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(kBackgroundPaintInScrollingContents,
target_obj->GetBackgroundPaintLocation()); target_obj->Layer()->GetBackgroundPaintLocation());
const auto* mapping = target_obj->Layer()->GetCompositedLayerMapping(); const auto* mapping = target_obj->Layer()->GetCompositedLayerMapping();
EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer()); EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer());
EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer()); EXPECT_FALSE(mapping->BackgroundPaintsOntoGraphicsLayer());
...@@ -595,8 +596,9 @@ TEST_P(PaintAndRasterInvalidationTest, ...@@ -595,8 +596,9 @@ TEST_P(PaintAndRasterInvalidationTest,
Element* child = GetDocument().getElementById("child"); Element* child = GetDocument().getElementById("child");
GetDocument().View()->UpdateAllLifecyclePhases(); GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(&GetLayoutView(), object->ContainerForPaintInvalidation()); EXPECT_EQ(&GetLayoutView(), object->ContainerForPaintInvalidation());
EXPECT_EQ(kBackgroundPaintInScrollingContents, EXPECT_EQ(
ToLayoutBoxModelObject(object)->GetBackgroundPaintLocation()); kBackgroundPaintInScrollingContents,
ToLayoutBoxModelObject(object)->Layer()->GetBackgroundPaintLocation());
// Resize the content. // Resize the content.
GetDocument().View()->SetTracksPaintInvalidations(true); GetDocument().View()->SetTracksPaintInvalidations(true);
...@@ -642,7 +644,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedSolidBackgroundResize) { ...@@ -642,7 +644,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedSolidBackgroundResize) {
ToLayoutBoxModelObject(target->GetLayoutObject()); ToLayoutBoxModelObject(target->GetLayoutObject());
EXPECT_EQ( EXPECT_EQ(
kBackgroundPaintInScrollingContents | kBackgroundPaintInGraphicsLayer, kBackgroundPaintInScrollingContents | kBackgroundPaintInGraphicsLayer,
target_object->GetBackgroundPaintLocation()); target_object->Layer()->GetBackgroundPaintLocation());
const auto* mapping = target_object->Layer()->GetCompositedLayerMapping(); const auto* mapping = target_object->Layer()->GetCompositedLayerMapping();
EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer()); EXPECT_TRUE(mapping->BackgroundPaintsOntoScrollingContentsLayer());
EXPECT_TRUE(mapping->BackgroundPaintsOntoGraphicsLayer()); EXPECT_TRUE(mapping->BackgroundPaintsOntoGraphicsLayer());
......
...@@ -2748,6 +2748,25 @@ GraphicsLayer* PaintLayer::GraphicsLayerBacking(const LayoutObject* obj) const { ...@@ -2748,6 +2748,25 @@ GraphicsLayer* PaintLayer::GraphicsLayerBacking(const LayoutObject* obj) const {
} }
} }
BackgroundPaintLocation PaintLayer::GetBackgroundPaintLocation(
uint32_t* reasons) const {
BackgroundPaintLocation location;
bool may_have_scrolling_layers_without_scrolling = IsRootLayer();
if (!ScrollsOverflow() && !may_have_scrolling_layers_without_scrolling) {
location = kBackgroundPaintInGraphicsLayer;
} else {
// If we care about LCD text, paint root backgrounds into scrolling contents
// layer even if style suggests otherwise. (For non-root scrollers, we just
// avoid compositing - see PLSA::ComputeNeedsCompositedScrolling.)
DCHECK(Compositor());
if (IsRootLayer() && !Compositor()->PreferCompositingToLCDTextEnabled())
location = kBackgroundPaintInScrollingContents;
else
location = GetLayoutObject().GetBackgroundPaintLocation(reasons);
}
return location;
}
void PaintLayer::EnsureCompositedLayerMapping() { void PaintLayer::EnsureCompositedLayerMapping() {
if (rare_data_ && rare_data_->composited_layer_mapping) if (rare_data_ && rare_data_->composited_layer_mapping)
return; return;
......
...@@ -531,6 +531,12 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient { ...@@ -531,6 +531,12 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
// Returns nullptr if this PaintLayer is not composited. // Returns nullptr if this PaintLayer is not composited.
GraphicsLayer* GraphicsLayerBacking(const LayoutObject* = nullptr) const; GraphicsLayer* GraphicsLayerBacking(const LayoutObject* = nullptr) const;
// TODO(yigu): PaintLayerScrollableArea::computeNeedsCompositedScrolling
// calls this method to obtain main thread scrolling reasons due to
// background paint location. Once the cases get handled on compositor the
// parameter "reasons" could be removed.
BackgroundPaintLocation GetBackgroundPaintLocation(
uint32_t* reasons = nullptr) const;
// NOTE: If you are using hasCompositedLayerMapping to determine the state of // NOTE: If you are using hasCompositedLayerMapping to determine the state of
// compositing for this layer, (and not just to do bookkeeping related to the // compositing for this layer, (and not just to do bookkeeping related to the
// mapping like, say, allocating or deallocating a mapping), then you may have // mapping like, say, allocating or deallocating a mapping), then you may have
......
...@@ -2253,8 +2253,8 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling( ...@@ -2253,8 +2253,8 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling(
// TODO(flackr): Allow integer transforms as long as all of the ancestor // TODO(flackr): Allow integer transforms as long as all of the ancestor
// transforms are also integer. // transforms are also integer.
bool background_supports_lcd_text = bool background_supports_lcd_text =
GetLayoutBox()->StyleRef().IsStackingContext() && layer->GetLayoutObject().StyleRef().IsStackingContext() &&
GetLayoutBox()->GetBackgroundPaintLocation( layer->GetBackgroundPaintLocation(
&non_composited_main_thread_scrolling_reasons_) & &non_composited_main_thread_scrolling_reasons_) &
kBackgroundPaintInScrollingContents && kBackgroundPaintInScrollingContents &&
layer->BackgroundIsKnownToBeOpaqueInRect( layer->BackgroundIsKnownToBeOpaqueInRect(
......
...@@ -45,8 +45,9 @@ class PaintLayerScrollableAreaTest : public RenderingTest { ...@@ -45,8 +45,9 @@ class PaintLayerScrollableAreaTest : public RenderingTest {
} }
BackgroundPaintLocation GetBackgroundPaintLocation(const char* element_id) { BackgroundPaintLocation GetBackgroundPaintLocation(const char* element_id) {
return ToLayoutBoxModelObject(GetLayoutObjectByElementId(element_id)) PaintLayer* paint_layer =
->GetBackgroundPaintLocation(); ToLayoutBoxModelObject(GetLayoutObjectByElementId(element_id))->Layer();
return paint_layer->GetBackgroundPaintLocation();
} }
private: private:
......
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