Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2890953002: [SPv1] Always set a CompositorElementId on main graphics layers; use PaintLayer id. (Closed)
Patch Set: none Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 50a63a3e6fb39273db67ebc6f3932bc0193f7759..a6b3dcc52da8f3f2cfa375cab0cd8bb3bbb19025 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -2199,6 +2199,37 @@ void CompositedLayerMapping::UpdateShouldFlattenTransform() {
}
}
+struct AnimatingData {
+ STACK_ALLOCATED()
+ Persistent<Node> owning_node = nullptr;
+ Persistent<Element> animating_element = nullptr;
+ const ComputedStyle* animating_style = nullptr;
+};
+
+void GetAnimatingData(PaintLayer& paint_layer, AnimatingData& data) {
+ if (!RuntimeEnabledFeatures::compositorWorkerEnabled())
+ return;
+
+ data.owning_node = paint_layer.GetLayoutObject().GetNode();
+
+ if (!data.owning_node)
+ return;
+
+ Document& document = data.owning_node->GetDocument();
+ Element* scrolling_element = document.ScrollingElementNoLayout();
+ if (data.owning_node->IsElementNode() &&
+ (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() ||
+ data.owning_node != scrolling_element)) {
+ data.animating_element = ToElement(data.owning_node);
+ data.animating_style = paint_layer.GetLayoutObject().Style();
+ } else if (data.owning_node->IsDocumentNode() &&
+ RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
+ data.owning_node = data.animating_element = scrolling_element;
+ if (scrolling_element && scrolling_element->GetLayoutObject())
+ data.animating_style = scrolling_element->GetLayoutObject()->Style();
+ }
+}
+
// Some background on when you receive an element id or mutable properties.
//
// element id:
@@ -2213,52 +2244,34 @@ void CompositedLayerMapping::UpdateShouldFlattenTransform() {
// well as the mutable properties for all layers may change according to the
// rules above so we update those values here.
void CompositedLayerMapping::UpdateElementIdAndCompositorMutableProperties() {
- int element_id = 0;
uint32_t primary_mutable_properties = CompositorMutableProperty::kNone;
uint32_t scroll_mutable_properties = CompositorMutableProperty::kNone;
- Node* owning_node = owning_layer_.GetLayoutObject().GetNode();
- Element* animating_element = nullptr;
- const ComputedStyle* animating_style = nullptr;
- if (owning_node) {
- Document& document = owning_node->GetDocument();
- Element* scrolling_element = document.ScrollingElementNoLayout();
- if (owning_node->IsElementNode() &&
- (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() ||
- owning_node != scrolling_element)) {
- animating_element = ToElement(owning_node);
- animating_style = owning_layer_.GetLayoutObject().Style();
- } else if (owning_node->IsDocumentNode() &&
- RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
- owning_node = animating_element = scrolling_element;
- if (scrolling_element && scrolling_element->GetLayoutObject())
- animating_style = scrolling_element->GetLayoutObject()->Style();
- }
- }
+ AnimatingData data;
+ GetAnimatingData(owning_layer_, data);
+
+ CompositorElementId element_id;
+ if (data.animating_style && data.animating_style->HasCompositorProxy()) {
+ // Compositor proxy element ids cannot be based on PaintLayers, since
+ // those are not kept alive by script across frames.
+ element_id = CompositorElementIdFromDOMNodeId(
+ DOMNodeIds::IdForNode(data.owning_node),
+ CompositorElementIdNamespace::kPrimaryCompositorProxy);
- if (RuntimeEnabledFeatures::compositorWorkerEnabled() && animating_style &&
- animating_style->HasCompositorProxy()) {
uint32_t compositor_mutable_properties =
- animating_element->CompositorMutableProperties();
- element_id = DOMNodeIds::IdForNode(owning_node);
+ data.animating_element->CompositorMutableProperties();
primary_mutable_properties = (CompositorMutableProperty::kOpacity |
CompositorMutableProperty::kTransform) &
compositor_mutable_properties;
scroll_mutable_properties = (CompositorMutableProperty::kScrollLeft |
CompositorMutableProperty::kScrollTop) &
compositor_mutable_properties;
+ } else {
+ element_id = CompositorElementIdFromPaintLayerId(
+ owning_layer_.UniqueId(), CompositorElementIdNamespace::kPrimary);
}
- if (animating_style && animating_style->ShouldCompositeForCurrentAnimations())
- element_id = DOMNodeIds::IdForNode(owning_node);
-
- CompositorElementId compositor_element_id;
- if (element_id) {
- compositor_element_id = CompositorElementIdFromDOMNodeId(
- element_id, CompositorElementIdNamespace::kPrimary);
- }
-
- graphics_layer_->SetElementId(compositor_element_id);
+ graphics_layer_->SetElementId(element_id);
graphics_layer_->SetCompositorMutableProperties(primary_mutable_properties);
// We always set the elementId for m_scrollingContentsLayer since it can be
@@ -2380,13 +2393,21 @@ bool CompositedLayerMapping::UpdateScrollingLayers(
scrolling_contents_layer_ =
CreateGraphicsLayer(kCompositingReasonLayerForScrollingContents);
- if (Node* owning_node = owning_layer_.GetLayoutObject().GetNode()) {
- scrolling_contents_layer_->SetElementId(
- CompositorElementIdFromDOMNodeId(
- DOMNodeIds::IdForNode(owning_node),
- CompositorElementIdNamespace::kScroll));
+ AnimatingData data;
+ GetAnimatingData(owning_layer_, data);
+
+ CompositorElementId element_id;
+ if (data.animating_style && data.animating_style->HasCompositorProxy()) {
+ element_id = CompositorElementIdFromDOMNodeId(
+ DOMNodeIds::IdForNode(data.owning_node),
+ CompositorElementIdNamespace::kScrollCompositorProxy);
+ } else {
+ element_id = CompositorElementIdFromPaintLayerId(
+ owning_layer_.UniqueId(), CompositorElementIdNamespace::kScroll);
}
+ scrolling_contents_layer_->SetElementId(element_id);
+
scrolling_layer_->AddChild(scrolling_contents_layer_.get());
layer_changed = true;

Powered by Google App Engine
This is Rietveld 408576698