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

[Blink] Clean-up CompositingInputsUpdater

This CL does some light clean-up to CompositingInputsUpdater.
It is for aesthetic improvement only and should not change behavior.

1. Move AncestorDependentCompositingInputs computation to its own helper
   function.
2. Remove CompositingInputsUpdater::AncestorInfo::has_ancestor_with_clip_path
   which is unused.
3. Add shorthand variable layout_object = layer->GetLayoutObject().

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I745a392b80adedef278fa5ad45436b2c652bf37d
Reviewed-on: https://chromium-review.googlesource.com/950008
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541248}
parent 1ee268df
......@@ -91,10 +91,12 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
update_type != kForceUpdate)
return;
LayoutBoxModelObject& layout_object = layer->GetLayoutObject();
const PaintLayer* previous_overflow_layer = layer->AncestorOverflowLayer();
layer->UpdateAncestorOverflowLayer(info.last_overflow_clip_layer);
if (info.last_overflow_clip_layer && layer->NeedsCompositingInputsUpdate() &&
layer->GetLayoutObject().Style()->HasStickyConstrainedPosition()) {
layout_object.Style()->HasStickyConstrainedPosition()) {
if (!RuntimeEnabledFeatures::RootLayerScrollingEnabled()) {
if (info.last_overflow_clip_layer != previous_overflow_layer) {
// Old ancestor scroller should no longer have these constraints.
......@@ -107,21 +109,17 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
// If our ancestor scroller has changed and the previous one was the
// root layer, we are no longer viewport constrained.
if (previous_overflow_layer && previous_overflow_layer->IsRootLayer()) {
layer->GetLayoutObject()
.View()
->GetFrameView()
->RemoveViewportConstrainedObject(layer->GetLayoutObject());
layout_object.View()->GetFrameView()->RemoveViewportConstrainedObject(
layout_object);
}
}
if (info.last_overflow_clip_layer->IsRootLayer()) {
layer->GetLayoutObject()
.View()
->GetFrameView()
->AddViewportConstrainedObject(layer->GetLayoutObject());
layout_object.View()->GetFrameView()->AddViewportConstrainedObject(
layout_object);
}
}
layer->GetLayoutObject().UpdateStickyPositionConstraints();
layout_object.UpdateStickyPositionConstraints();
// Sticky position constraints and ancestor overflow scroller affect
// the sticky layer position, so we need to update it again here.
......@@ -133,21 +131,66 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
geometry_map_.PushMappingsToAncestor(layer, layer->Parent());
if (layer->HasCompositedLayerMapping())
info.enclosing_composited_layer = layer;
PaintLayer* enclosing_composited_layer =
layer->HasCompositedLayerMapping() ? layer
: info.enclosing_composited_layer;
if (layer->NeedsCompositingInputsUpdate()) {
if (info.enclosing_composited_layer) {
info.enclosing_composited_layer->GetCompositedLayerMapping()
if (enclosing_composited_layer) {
enclosing_composited_layer->GetCompositedLayerMapping()
->SetNeedsGraphicsLayerUpdate(kGraphicsLayerUpdateSubtree);
}
update_type = kForceUpdate;
}
if (update_type == kForceUpdate) {
if (update_type == kForceUpdate)
UpdateAncestorDependentCompositingInputs(layer, info);
info.enclosing_composited_layer = enclosing_composited_layer;
if (layer->StackingNode()->IsStackingContext())
info.ancestor_stacking_context = layer;
if (layer->IsRootLayer() || layout_object.HasOverflowClip())
info.last_overflow_clip_layer = layer;
if (layer->ScrollsOverflow())
info.last_scrolling_ancestor = layer;
if (layout_object.HasClipRelatedProperty())
info.has_ancestor_with_clip_related_property = true;
for (PaintLayer* child = layer->FirstChild(); child;
child = child->NextSibling())
UpdateRecursive(child, update_type, info);
layer->DidUpdateCompositingInputs();
geometry_map_.PopMappingsToAncestor(layer->Parent());
if (layer->SelfPaintingStatusChanged()) {
layer->ClearSelfPaintingStatusChanged();
// If the floating object becomes non-self-painting, so some ancestor should
// paint it; if it becomes self-painting, it should paint itself and no
// ancestor should paint it.
if (layout_object.IsFloating()) {
LayoutBlockFlow::UpdateAncestorShouldPaintFloatingObject(
*layer->GetLayoutBox());
}
}
}
void CompositingInputsUpdater::UpdateAncestorDependentCompositingInputs(
PaintLayer* layer,
const AncestorInfo& info) {
if (layer->IsRootLayer()) {
layer->UpdateAncestorDependentCompositingInputs(
PaintLayer::AncestorDependentCompositingInputs());
return;
}
PaintLayer::AncestorDependentCompositingInputs properties;
LayoutBoxModelObject& layout_object = layer->GetLayoutObject();
if (!layer->IsRootLayer()) {
if (!RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
properties.unclipped_absolute_bounding_box =
EnclosingIntRect(geometry_map_.AbsoluteRect(
......@@ -180,9 +223,8 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
parent->IsTransparent() ? parent : parent->OpacityAncestor();
properties.transform_ancestor =
parent->Transform() ? parent : parent->TransformAncestor();
properties.filter_ancestor = parent->HasFilterInducingProperty()
? parent
: parent->FilterAncestor();
properties.filter_ancestor =
parent->HasFilterInducingProperty() ? parent : parent->FilterAncestor();
properties.clip_path_ancestor = parent->GetLayoutObject().HasClipPath()
? parent
: parent->ClipPathAncestor();
......@@ -190,7 +232,7 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
parent->GetLayoutObject().HasMask() ? parent : parent->MaskAncestor();
bool layer_is_fixed_position =
layer->GetLayoutObject().Style()->GetPosition() == EPosition::kFixed;
layout_object.Style()->GetPosition() == EPosition::kFixed;
properties.nearest_fixed_position_layer =
layer_is_fixed_position ? layer : parent->NearestFixedPositionLayer();
......@@ -209,10 +251,10 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
: parent_layer_on_clipping_container_chain->ClippingContainer();
if (!layer->SubtreeIsInvisible()) {
if (layer->GetLayoutObject().IsOutOfFlowPositioned() &&
if (layout_object.IsOutOfFlowPositioned() &&
NeedsToEscapeClipInheritedFromCompositingContainer(
layer, parent_layer_on_clipping_container_chain
->GetLayoutObject())) {
layer,
parent_layer_on_clipping_container_chain->GetLayoutObject())) {
properties.clip_parent = parent_layer_on_clipping_container_chain;
} else if (parent_layer_on_clipping_container_chain
->CompositingContainer() ==
......@@ -234,8 +276,7 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
}
if (info.last_scrolling_ancestor) {
const LayoutObject* containing_block =
layer->GetLayoutObject().ContainingBlock();
const LayoutObject* containing_block = layout_object.ContainingBlock();
const PaintLayer* parent_layer_on_containing_block_chain =
FindParentLayerOnContainingBlockChain(containing_block);
......@@ -252,41 +293,8 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
&properties.ancestor_scrolling_layer->GetLayoutObject()))
properties.scroll_parent = properties.ancestor_scrolling_layer;
}
}
layer->UpdateAncestorDependentCompositingInputs(properties);
}
if (layer->StackingNode()->IsStackingContext())
info.ancestor_stacking_context = layer;
if (layer->IsRootLayer() || layer->GetLayoutObject().HasOverflowClip())
info.last_overflow_clip_layer = layer;
if (layer->ScrollsOverflow())
info.last_scrolling_ancestor = layer;
if (layer->GetLayoutObject().HasClipRelatedProperty())
info.has_ancestor_with_clip_related_property = true;
for (PaintLayer* child = layer->FirstChild(); child;
child = child->NextSibling())
UpdateRecursive(child, update_type, info);
layer->DidUpdateCompositingInputs();
geometry_map_.PopMappingsToAncestor(layer->Parent());
if (layer->SelfPaintingStatusChanged()) {
layer->ClearSelfPaintingStatusChanged();
// If the floating object becomes non-self-painting, so some ancestor should
// paint it; if it becomes self-painting, it should paint itself and no
// ancestor should paint it.
if (layer->GetLayoutObject().IsFloating()) {
LayoutBlockFlow::UpdateAncestorShouldPaintFloatingObject(
*layer->GetLayoutBox());
}
}
}
#if DCHECK_IS_ON()
......
......@@ -49,10 +49,11 @@ class CompositingInputsUpdater {
// containing block chain.
PaintLayer* last_scrolling_ancestor;
bool has_ancestor_with_clip_related_property;
bool has_ancestor_with_clip_path;
};
void UpdateRecursive(PaintLayer*, UpdateType, AncestorInfo);
void UpdateAncestorDependentCompositingInputs(PaintLayer*,
const AncestorInfo&);
LayoutGeometryMap geometry_map_;
PaintLayer* root_layer_;
......
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