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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 // might impl animate). 2200 // might impl animate).
2201 // 2201 //
2202 // mutable properties: 2202 // mutable properties:
2203 // Only if you have a compositor proxy. 2203 // Only if you have a compositor proxy.
2204 // 2204 //
2205 // The element id for the scroll layers is assigned when they're constructed, 2205 // The element id for the scroll layers is assigned when they're constructed,
2206 // since this is unconditional. However, the element id for the primary layer as 2206 // since this is unconditional. However, the element id for the primary layer as
2207 // well as the mutable properties for all layers may change according to the 2207 // well as the mutable properties for all layers may change according to the
2208 // rules above so we update those values here. 2208 // rules above so we update those values here.
2209 void CompositedLayerMapping::UpdateElementIdAndCompositorMutableProperties() { 2209 void CompositedLayerMapping::UpdateElementIdAndCompositorMutableProperties() {
2210 int element_id = 0;
2211 uint32_t primary_mutable_properties = CompositorMutableProperty::kNone; 2210 uint32_t primary_mutable_properties = CompositorMutableProperty::kNone;
2212 uint32_t scroll_mutable_properties = CompositorMutableProperty::kNone; 2211 uint32_t scroll_mutable_properties = CompositorMutableProperty::kNone;
2213 2212
2214 Node* owning_node = owning_layer_.GetLayoutObject().GetNode(); 2213 Node* owning_node = owning_layer_.GetLayoutObject().GetNode();
2215 Element* animating_element = nullptr; 2214 Element* animating_element = nullptr;
2216 const ComputedStyle* animating_style = nullptr; 2215 const ComputedStyle* animating_style = nullptr;
2217 if (owning_node) { 2216 if (owning_node) {
2218 Document& document = owning_node->GetDocument(); 2217 Document& document = owning_node->GetDocument();
2219 Element* scrolling_element = document.ScrollingElementNoLayout(); 2218 Element* scrolling_element = document.ScrollingElementNoLayout();
2220 if (owning_node->IsElementNode() && 2219 if (owning_node->IsElementNode() &&
2221 (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() || 2220 (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() ||
2222 owning_node != scrolling_element)) { 2221 owning_node != scrolling_element)) {
2223 animating_element = ToElement(owning_node); 2222 animating_element = ToElement(owning_node);
2224 animating_style = owning_layer_.GetLayoutObject().Style(); 2223 animating_style = owning_layer_.GetLayoutObject().Style();
2225 } else if (owning_node->IsDocumentNode() && 2224 } else if (owning_node->IsDocumentNode() &&
2226 RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 2225 RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
2227 owning_node = animating_element = scrolling_element; 2226 owning_node = animating_element = scrolling_element;
2228 if (scrolling_element && scrolling_element->GetLayoutObject()) 2227 if (scrolling_element && scrolling_element->GetLayoutObject())
2229 animating_style = scrolling_element->GetLayoutObject()->Style(); 2228 animating_style = scrolling_element->GetLayoutObject()->Style();
2230 } 2229 }
2231 } 2230 }
2232 2231
2233 if (RuntimeEnabledFeatures::compositorWorkerEnabled() && animating_style && 2232 if (RuntimeEnabledFeatures::compositorWorkerEnabled() && animating_style &&
2234 animating_style->HasCompositorProxy()) { 2233 animating_style->HasCompositorProxy()) {
2235 uint32_t compositor_mutable_properties = 2234 uint32_t compositor_mutable_properties =
2236 animating_element->CompositorMutableProperties(); 2235 animating_element->CompositorMutableProperties();
2237 element_id = DOMNodeIds::IdForNode(owning_node);
2238 primary_mutable_properties = (CompositorMutableProperty::kOpacity | 2236 primary_mutable_properties = (CompositorMutableProperty::kOpacity |
2239 CompositorMutableProperty::kTransform) & 2237 CompositorMutableProperty::kTransform) &
2240 compositor_mutable_properties; 2238 compositor_mutable_properties;
2241 scroll_mutable_properties = (CompositorMutableProperty::kScrollLeft | 2239 scroll_mutable_properties = (CompositorMutableProperty::kScrollLeft |
2242 CompositorMutableProperty::kScrollTop) & 2240 CompositorMutableProperty::kScrollTop) &
2243 compositor_mutable_properties; 2241 compositor_mutable_properties;
2244 } 2242 }
2245 2243
2246 if (animating_style && animating_style->ShouldCompositeForCurrentAnimations()) 2244 CompositorElementId compositor_element_id =
2247 element_id = DOMNodeIds::IdForNode(owning_node); 2245 CompositorElementIdFromPaintLayerId(
2248 2246 owning_layer_.UniqueId(), CompositorElementIdNamespace::kPrimary);
2249 CompositorElementId compositor_element_id;
2250 if (element_id) {
2251 compositor_element_id = CompositorElementIdFromDOMNodeId(
2252 element_id, CompositorElementIdNamespace::kPrimary);
2253 }
2254 2247
2255 graphics_layer_->SetElementId(compositor_element_id); 2248 graphics_layer_->SetElementId(compositor_element_id);
2256 graphics_layer_->SetCompositorMutableProperties(primary_mutable_properties); 2249 graphics_layer_->SetCompositorMutableProperties(primary_mutable_properties);
2257 2250
2258 // We always set the elementId for m_scrollingContentsLayer since it can be 2251 // We always set the elementId for m_scrollingContentsLayer since it can be
2259 // animated for smooth scrolling, so we don't need to set it conditionally 2252 // animated for smooth scrolling, so we don't need to set it conditionally
2260 // here. 2253 // here.
2261 if (scrolling_contents_layer_.get()) 2254 if (scrolling_contents_layer_.get())
2262 scrolling_contents_layer_->SetCompositorMutableProperties( 2255 scrolling_contents_layer_->SetCompositorMutableProperties(
2263 scroll_mutable_properties); 2256 scroll_mutable_properties);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 // Outer layer which corresponds with the scroll view. 2360 // Outer layer which corresponds with the scroll view.
2368 scrolling_layer_ = 2361 scrolling_layer_ =
2369 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContainer); 2362 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContainer);
2370 scrolling_layer_->SetDrawsContent(false); 2363 scrolling_layer_->SetDrawsContent(false);
2371 scrolling_layer_->SetMasksToBounds(true); 2364 scrolling_layer_->SetMasksToBounds(true);
2372 2365
2373 // Inner layer which renders the content that scrolls. 2366 // Inner layer which renders the content that scrolls.
2374 scrolling_contents_layer_ = 2367 scrolling_contents_layer_ =
2375 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContents); 2368 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContents);
2376 2369
2377 if (Node* owning_node = owning_layer_.GetLayoutObject().GetNode()) { 2370 scrolling_contents_layer_->SetElementId(
2378 scrolling_contents_layer_->SetElementId( 2371 CompositorElementIdFromPaintLayerId(
2379 CompositorElementIdFromDOMNodeId( 2372 owning_layer_.UniqueId(), CompositorElementIdNamespace::kScroll));
2380 DOMNodeIds::IdForNode(owning_node),
2381 CompositorElementIdNamespace::kScroll));
2382 }
2383 2373
2384 scrolling_layer_->AddChild(scrolling_contents_layer_.get()); 2374 scrolling_layer_->AddChild(scrolling_contents_layer_.get());
2385 2375
2386 layer_changed = true; 2376 layer_changed = true;
2387 if (scrolling_coordinator) { 2377 if (scrolling_coordinator) {
2388 scrolling_coordinator->ScrollableAreaScrollLayerDidChange( 2378 scrolling_coordinator->ScrollableAreaScrollLayerDidChange(
2389 owning_layer_.GetScrollableArea()); 2379 owning_layer_.GetScrollableArea());
2390 scrolling_coordinator->ScrollableAreasDidChange(); 2380 scrolling_coordinator->ScrollableAreasDidChange();
2391 } 2381 }
2392 } 2382 }
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 } else if (graphics_layer == decoration_outline_layer_.get()) { 3618 } else if (graphics_layer == decoration_outline_layer_.get()) {
3629 name = "Decoration Layer"; 3619 name = "Decoration Layer";
3630 } else { 3620 } else {
3631 NOTREACHED(); 3621 NOTREACHED();
3632 } 3622 }
3633 3623
3634 return name; 3624 return name;
3635 } 3625 }
3636 3626
3637 } // namespace blink 3627 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698