Commit 8a857490 authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Remove special handling for attaching iframe root graphics layer

The iframe's root graphics layer should not be treated specially; it
should be incorporated into the regular GraphicsLayerTreeBuilder
flow. This has the added benefit that it's not necessary for the
iframe element in the parent document to be composited. A future CL
will stop compositing iframe elements by default.

Change-Id: I9bcfdc2384b072601c87786b269a32d86d7973e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2220868Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773820}
parent b7d8b731
......@@ -447,10 +447,12 @@ bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration(
graphics_layer_->SetContentsToCcLayer(
remote->GetCcLayer(), remote->WebLayerHasFixedContentsOpaque());
}
PaintLayerCompositor* inner_compositor =
PaintLayerCompositor::FrameContentsCompositor(
ToLayoutEmbeddedContent(layout_object));
if (inner_compositor && inner_compositor->RootLayerAttachmentDirty())
layer_config_changed = true;
}
if (PaintLayerCompositor::AttachFrameContentLayersToIframeLayer(
ToLayoutEmbeddedContent(layout_object)))
layer_config_changed = true;
} else if (IsA<LayoutVideo>(layout_object)) {
auto* media_element = To<HTMLMediaElement>(layout_object.GetNode());
graphics_layer_->SetContentsToCcLayer(
......
......@@ -116,13 +116,26 @@ void GraphicsLayerTreeBuilder::RebuildRecursive(
}
}
if (has_composited_layer_mapping) {
bool parented = false;
if (layer.GetLayoutObject().IsLayoutEmbeddedContent()) {
parented = PaintLayerCompositor::AttachFrameContentLayersToIframeLayer(
ToLayoutEmbeddedContent(layer.GetLayoutObject()));
if (layer.GetLayoutObject().IsLayoutEmbeddedContent()) {
DCHECK(this_layer_children.IsEmpty());
PaintLayerCompositor* inner_compositor =
PaintLayerCompositor::FrameContentsCompositor(
ToLayoutEmbeddedContent(layer.GetLayoutObject()));
// If the embedded frame is render-throttled, it might not be compositing
// clean at this point. In that case, we still need to connect its existing
// root graphics layer, so we need to query the stale compositing state.
DisableCompositingQueryAsserts disabler;
if (inner_compositor) {
if (inner_compositor->InCompositingMode()) {
GraphicsLayer* inner_root_layer = inner_compositor->RootGraphicsLayer();
DCHECK(inner_root_layer);
layer_vector_for_children->push_back(inner_root_layer);
}
inner_compositor->ClearRootLayerAttachmentDirty();
}
}
if (has_composited_layer_mapping) {
// Apply all pending reparents by inserting the overflow controls
// root layers into |this_layer_children|. To do this, first sort
// them by index. Then insert them one-by-one into the array,
......@@ -146,7 +159,7 @@ void GraphicsLayerTreeBuilder::RebuildRecursive(
}
}
if (!parented && !this_layer_children.IsEmpty())
if (!this_layer_children.IsEmpty())
current_composited_layer_mapping->SetSublayers(this_layer_children);
if (ShouldAppendLayer(layer)) {
......
......@@ -70,13 +70,11 @@ PaintLayerCompositor::PaintLayerCompositor(LayoutView& layout_view)
DCHECK(!RuntimeEnabledFeatures::CompositeAfterPaintEnabled());
}
PaintLayerCompositor::~PaintLayerCompositor() {
DCHECK_EQ(root_layer_attachment_, kRootLayerUnattached);
}
PaintLayerCompositor::~PaintLayerCompositor() = default;
void PaintLayerCompositor::CleanUp() {
if (InCompositingMode())
DetachRootLayer();
SetOwnerNeedsCompositingUpdate();
}
bool PaintLayerCompositor::InCompositingMode() const {
......@@ -93,24 +91,16 @@ bool PaintLayerCompositor::StaleInCompositingMode() const {
void PaintLayerCompositor::SetCompositingModeEnabled(bool enable) {
if (enable == compositing_)
return;
compositing_ = enable;
if (compositing_)
AttachRootLayer();
else
DetachRootLayer();
root_layer_attachment_dirty_ = true;
// Schedule an update in the parent frame so the <iframe>'s layer in the owner
// document matches the compositing state here.
if (HTMLFrameOwnerElement* owner_element =
layout_view_.GetDocument().LocalOwner())
owner_element->SetNeedsCompositingUpdate();
SetOwnerNeedsCompositingUpdate();
}
void PaintLayerCompositor::UpdateAcceleratedCompositingSettings() {
if (root_layer_attachment_ != kRootLayerUnattached)
RootLayer()->SetNeedsCompositingInputsUpdate();
if (auto* root_layer = RootLayer())
root_layer->SetNeedsCompositingInputsUpdate();
}
static LayoutVideo* FindFullscreenVideoLayoutObject(Document& document) {
......@@ -495,13 +485,6 @@ bool PaintLayerCompositor::AllocateOrClearCompositedLayerMapping(
if (!composited_layer_mapping_changed)
return false;
if (layer->GetLayoutObject().IsLayoutEmbeddedContent()) {
PaintLayerCompositor* inner_compositor = FrameContentsCompositor(
ToLayoutEmbeddedContent(layer->GetLayoutObject()));
if (inner_compositor && inner_compositor->StaleInCompositingMode())
inner_compositor->AttachRootLayer();
}
layer->ClearClipRects(kPaintingClipRects);
// Compositing state affects whether to create paint offset translation of
......@@ -541,26 +524,6 @@ PaintLayerCompositor* PaintLayerCompositor::FrameContentsCompositor(
return nullptr;
}
bool PaintLayerCompositor::AttachFrameContentLayersToIframeLayer(
LayoutEmbeddedContent& layout_object) {
PaintLayerCompositor* inner_compositor =
FrameContentsCompositor(layout_object);
if (!inner_compositor || !inner_compositor->StaleInCompositingMode() ||
inner_compositor->root_layer_attachment_ !=
kRootLayerAttachedViaEnclosingFrame)
return false;
PaintLayer* layer = layout_object.Layer();
if (!layer->HasCompositedLayerMapping())
return false;
DisableCompositingQueryAsserts disabler;
inner_compositor->RootLayer()->EnsureCompositedLayerMapping();
layer->GetCompositedLayerMapping()->SetSublayers(
GraphicsLayerVector(1, inner_compositor->RootGraphicsLayer()));
return true;
}
static void FullyInvalidatePaintRecursive(PaintLayer* layer) {
if (layer->GetCompositingState() == kPaintsIntoOwnBacking)
layer->GetCompositedLayerMapping()->SetAllLayersNeedDisplay();
......@@ -693,47 +656,11 @@ void PaintLayerCompositor::UpdateTrackingRasterInvalidations() {
UpdateTrackingRasterInvalidationsRecursive(root_layer);
}
void PaintLayerCompositor::AttachRootLayer() {
if (root_layer_attachment_ != kRootLayerUnattached)
return;
// With CompositeAfterPaint, PaintArtifactCompositor is responsible for the
// root layer.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
// The root layer of local frame root doesn't need to attach to anything.
if (layout_view_.GetFrame()->IsLocalRoot()) {
root_layer_attachment_ = kRootLayerOfLocalFrameRoot;
return;
}
HTMLFrameOwnerElement* owner_element =
layout_view_.GetDocument().LocalOwner();
DCHECK(owner_element);
// The layer will get hooked up via
// CompositedLayerMapping::updateGraphicsLayerConfiguration() for the
// frame's layoutObject in the parent document.
owner_element->SetNeedsCompositingUpdate();
if (owner_element->GetLayoutObject()) {
ToLayoutBoxModelObject(owner_element->GetLayoutObject())
->Layer()
->SetNeedsCompositingInputsUpdate();
}
root_layer_attachment_ = kRootLayerAttachedViaEnclosingFrame;
}
void PaintLayerCompositor::DetachRootLayer() {
if (root_layer_attachment_ == kRootLayerAttachedViaEnclosingFrame) {
// The layer will get unhooked up via
// CompositedLayerMapping::updateGraphicsLayerConfiguration() for the
// frame's layoutObject in the parent document.
if (HTMLFrameOwnerElement* owner_element =
layout_view_.GetDocument().LocalOwner())
owner_element->SetNeedsCompositingUpdate();
void PaintLayerCompositor::SetOwnerNeedsCompositingUpdate() {
if (HTMLFrameOwnerElement* owner_element =
layout_view_.GetDocument().LocalOwner()) {
owner_element->SetNeedsCompositingUpdate();
}
root_layer_attachment_ = kRootLayerUnattached;
}
ScrollingCoordinator* PaintLayerCompositor::GetScrollingCoordinator() const {
......
......@@ -120,8 +120,6 @@ class CORE_EXPORT PaintLayerCompositor {
GraphicsLayer* PaintRootGraphicsLayer() const;
static PaintLayerCompositor* FrameContentsCompositor(LayoutEmbeddedContent&);
// Return true if the layers changed.
static bool AttachFrameContentLayersToIframeLayer(LayoutEmbeddedContent&);
void UpdateTrackingRasterInvalidations();
......@@ -132,6 +130,9 @@ class CORE_EXPORT PaintLayerCompositor {
// Whether the layer could ever be composited.
bool CanBeComposited(const PaintLayer*) const;
bool RootLayerAttachmentDirty() const { return root_layer_attachment_dirty_; }
void ClearRootLayerAttachmentDirty() { root_layer_attachment_dirty_ = false; }
// FIXME: Move allocateOrClearCompositedLayerMapping to
// CompositingLayerAssigner once we've fixed the compositing chicken/egg
// issues.
......@@ -165,8 +166,7 @@ class CORE_EXPORT PaintLayerCompositor {
void UpdateIfNeeded(DocumentLifecycle::LifecycleState target_state,
CompositingReasonsStats&);
void AttachRootLayer();
void DetachRootLayer();
void SetOwnerNeedsCompositingUpdate();
Page* GetPage() const;
......@@ -186,18 +186,12 @@ class CORE_EXPORT PaintLayerCompositor {
LayoutView& layout_view_;
bool compositing_ = false;
bool root_layer_attachment_dirty_ = false;
// After initialization, compositing updates must be done, so start dirty.
CompositingUpdateType pending_update_type_ =
kCompositingUpdateAfterCompositingInputChange;
enum RootLayerAttachment {
kRootLayerUnattached,
kRootLayerAttachedViaEnclosingFrame,
kRootLayerOfLocalFrameRoot // which doesn't need to attach to anything.
};
RootLayerAttachment root_layer_attachment_ = kRootLayerUnattached;
CompositingInputsRoot compositing_inputs_root_;
FRIEND_TEST_ALL_PREFIXES(FrameThrottlingTest,
......
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