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

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 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 // Regardless, mark the graphics layer, scrolling layer and scrolling block 2192 // Regardless, mark the graphics layer, scrolling layer and scrolling block
2193 // selection layer (if they exist) as not flattening. Having them flatten 2193 // selection layer (if they exist) as not flattening. Having them flatten
2194 // causes unclipped render surfaces which cause bugs. 2194 // causes unclipped render surfaces which cause bugs.
2195 // http://crbug.com/521768 2195 // http://crbug.com/521768
2196 if (HasScrollingLayer()) { 2196 if (HasScrollingLayer()) {
2197 graphics_layer_->SetShouldFlattenTransform(false); 2197 graphics_layer_->SetShouldFlattenTransform(false);
2198 scrolling_layer_->SetShouldFlattenTransform(false); 2198 scrolling_layer_->SetShouldFlattenTransform(false);
2199 } 2199 }
2200 } 2200 }
2201 2201
2202 struct AnimatingData {
2203 STACK_ALLOCATED()
2204 Persistent<Node> owning_node = nullptr;
2205 Persistent<Element> animating_element = nullptr;
2206 const ComputedStyle* animating_style = nullptr;
2207 };
2208
2209 void GetAnimatingData(PaintLayer& paint_layer, AnimatingData& data) {
2210 if (!RuntimeEnabledFeatures::compositorWorkerEnabled())
2211 return;
2212
2213 data.owning_node = paint_layer.GetLayoutObject().GetNode();
2214
2215 if (!data.owning_node)
2216 return;
2217
2218 Document& document = data.owning_node->GetDocument();
2219 Element* scrolling_element = document.ScrollingElementNoLayout();
2220 if (data.owning_node->IsElementNode() &&
2221 (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() ||
2222 data.owning_node != scrolling_element)) {
2223 data.animating_element = ToElement(data.owning_node);
2224 data.animating_style = paint_layer.GetLayoutObject().Style();
2225 } else if (data.owning_node->IsDocumentNode() &&
2226 RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
2227 data.owning_node = data.animating_element = scrolling_element;
2228 if (scrolling_element && scrolling_element->GetLayoutObject())
2229 data.animating_style = scrolling_element->GetLayoutObject()->Style();
2230 }
2231 }
2232
2202 // Some background on when you receive an element id or mutable properties. 2233 // Some background on when you receive an element id or mutable properties.
2203 // 2234 //
2204 // element id: 2235 // element id:
2205 // If you have a compositor proxy, an animation, or you're a scroller (and 2236 // If you have a compositor proxy, an animation, or you're a scroller (and
2206 // might impl animate). 2237 // might impl animate).
2207 // 2238 //
2208 // mutable properties: 2239 // mutable properties:
2209 // Only if you have a compositor proxy. 2240 // Only if you have a compositor proxy.
2210 // 2241 //
2211 // The element id for the scroll layers is assigned when they're constructed, 2242 // The element id for the scroll layers is assigned when they're constructed,
2212 // since this is unconditional. However, the element id for the primary layer as 2243 // since this is unconditional. However, the element id for the primary layer as
2213 // well as the mutable properties for all layers may change according to the 2244 // well as the mutable properties for all layers may change according to the
2214 // rules above so we update those values here. 2245 // rules above so we update those values here.
2215 void CompositedLayerMapping::UpdateElementIdAndCompositorMutableProperties() { 2246 void CompositedLayerMapping::UpdateElementIdAndCompositorMutableProperties() {
2216 int element_id = 0;
2217 uint32_t primary_mutable_properties = CompositorMutableProperty::kNone; 2247 uint32_t primary_mutable_properties = CompositorMutableProperty::kNone;
2218 uint32_t scroll_mutable_properties = CompositorMutableProperty::kNone; 2248 uint32_t scroll_mutable_properties = CompositorMutableProperty::kNone;
2219 2249
2220 Node* owning_node = owning_layer_.GetLayoutObject().GetNode(); 2250 AnimatingData data;
2221 Element* animating_element = nullptr; 2251 GetAnimatingData(owning_layer_, data);
2222 const ComputedStyle* animating_style = nullptr;
2223 if (owning_node) {
2224 Document& document = owning_node->GetDocument();
2225 Element* scrolling_element = document.ScrollingElementNoLayout();
2226 if (owning_node->IsElementNode() &&
2227 (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() ||
2228 owning_node != scrolling_element)) {
2229 animating_element = ToElement(owning_node);
2230 animating_style = owning_layer_.GetLayoutObject().Style();
2231 } else if (owning_node->IsDocumentNode() &&
2232 RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
2233 owning_node = animating_element = scrolling_element;
2234 if (scrolling_element && scrolling_element->GetLayoutObject())
2235 animating_style = scrolling_element->GetLayoutObject()->Style();
2236 }
2237 }
2238 2252
2239 if (RuntimeEnabledFeatures::compositorWorkerEnabled() && animating_style && 2253 CompositorElementId element_id;
2240 animating_style->HasCompositorProxy()) { 2254 if (data.animating_style && data.animating_style->HasCompositorProxy()) {
2255 // Compositor proxy element ids cannot be based on PaintLayers, since
2256 // those are not kept alive by script across frames.
2257 element_id = CompositorElementIdFromDOMNodeId(
2258 DOMNodeIds::IdForNode(data.owning_node),
2259 CompositorElementIdNamespace::kPrimaryCompositorProxy);
2260
2241 uint32_t compositor_mutable_properties = 2261 uint32_t compositor_mutable_properties =
2242 animating_element->CompositorMutableProperties(); 2262 data.animating_element->CompositorMutableProperties();
2243 element_id = DOMNodeIds::IdForNode(owning_node);
2244 primary_mutable_properties = (CompositorMutableProperty::kOpacity | 2263 primary_mutable_properties = (CompositorMutableProperty::kOpacity |
2245 CompositorMutableProperty::kTransform) & 2264 CompositorMutableProperty::kTransform) &
2246 compositor_mutable_properties; 2265 compositor_mutable_properties;
2247 scroll_mutable_properties = (CompositorMutableProperty::kScrollLeft | 2266 scroll_mutable_properties = (CompositorMutableProperty::kScrollLeft |
2248 CompositorMutableProperty::kScrollTop) & 2267 CompositorMutableProperty::kScrollTop) &
2249 compositor_mutable_properties; 2268 compositor_mutable_properties;
2269 } else {
2270 element_id = CompositorElementIdFromPaintLayerId(
2271 owning_layer_.UniqueId(), CompositorElementIdNamespace::kPrimary);
2250 } 2272 }
2251 2273
2252 if (animating_style && animating_style->ShouldCompositeForCurrentAnimations()) 2274 graphics_layer_->SetElementId(element_id);
2253 element_id = DOMNodeIds::IdForNode(owning_node);
2254
2255 CompositorElementId compositor_element_id;
2256 if (element_id) {
2257 compositor_element_id = CompositorElementIdFromDOMNodeId(
2258 element_id, CompositorElementIdNamespace::kPrimary);
2259 }
2260
2261 graphics_layer_->SetElementId(compositor_element_id);
2262 graphics_layer_->SetCompositorMutableProperties(primary_mutable_properties); 2275 graphics_layer_->SetCompositorMutableProperties(primary_mutable_properties);
2263 2276
2264 // We always set the elementId for m_scrollingContentsLayer since it can be 2277 // We always set the elementId for m_scrollingContentsLayer since it can be
2265 // animated for smooth scrolling, so we don't need to set it conditionally 2278 // animated for smooth scrolling, so we don't need to set it conditionally
2266 // here. 2279 // here.
2267 if (scrolling_contents_layer_.get()) 2280 if (scrolling_contents_layer_.get())
2268 scrolling_contents_layer_->SetCompositorMutableProperties( 2281 scrolling_contents_layer_->SetCompositorMutableProperties(
2269 scroll_mutable_properties); 2282 scroll_mutable_properties);
2270 } 2283 }
2271 2284
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 // Outer layer which corresponds with the scroll view. 2386 // Outer layer which corresponds with the scroll view.
2374 scrolling_layer_ = 2387 scrolling_layer_ =
2375 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContainer); 2388 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContainer);
2376 scrolling_layer_->SetDrawsContent(false); 2389 scrolling_layer_->SetDrawsContent(false);
2377 scrolling_layer_->SetMasksToBounds(true); 2390 scrolling_layer_->SetMasksToBounds(true);
2378 2391
2379 // Inner layer which renders the content that scrolls. 2392 // Inner layer which renders the content that scrolls.
2380 scrolling_contents_layer_ = 2393 scrolling_contents_layer_ =
2381 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContents); 2394 CreateGraphicsLayer(kCompositingReasonLayerForScrollingContents);
2382 2395
2383 if (Node* owning_node = owning_layer_.GetLayoutObject().GetNode()) { 2396 AnimatingData data;
2384 scrolling_contents_layer_->SetElementId( 2397 GetAnimatingData(owning_layer_, data);
2385 CompositorElementIdFromDOMNodeId( 2398
2386 DOMNodeIds::IdForNode(owning_node), 2399 CompositorElementId element_id;
2387 CompositorElementIdNamespace::kScroll)); 2400 if (data.animating_style && data.animating_style->HasCompositorProxy()) {
2401 element_id = CompositorElementIdFromDOMNodeId(
2402 DOMNodeIds::IdForNode(data.owning_node),
2403 CompositorElementIdNamespace::kScrollCompositorProxy);
2404 } else {
2405 element_id = CompositorElementIdFromPaintLayerId(
2406 owning_layer_.UniqueId(), CompositorElementIdNamespace::kScroll);
2388 } 2407 }
2389 2408
2409 scrolling_contents_layer_->SetElementId(element_id);
2410
2390 scrolling_layer_->AddChild(scrolling_contents_layer_.get()); 2411 scrolling_layer_->AddChild(scrolling_contents_layer_.get());
2391 2412
2392 layer_changed = true; 2413 layer_changed = true;
2393 if (scrolling_coordinator) { 2414 if (scrolling_coordinator) {
2394 scrolling_coordinator->ScrollableAreaScrollLayerDidChange( 2415 scrolling_coordinator->ScrollableAreaScrollLayerDidChange(
2395 owning_layer_.GetScrollableArea()); 2416 owning_layer_.GetScrollableArea());
2396 scrolling_coordinator->ScrollableAreasDidChange(); 2417 scrolling_coordinator->ScrollableAreasDidChange();
2397 } 2418 }
2398 } 2419 }
2399 } else if (scrolling_layer_) { 2420 } else if (scrolling_layer_) {
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3634 } else if (graphics_layer == decoration_outline_layer_.get()) { 3655 } else if (graphics_layer == decoration_outline_layer_.get()) {
3635 name = "Decoration Layer"; 3656 name = "Decoration Layer";
3636 } else { 3657 } else {
3637 NOTREACHED(); 3658 NOTREACHED();
3638 } 3659 }
3639 3660
3640 return name; 3661 return name;
3641 } 3662 }
3642 3663
3643 } // namespace blink 3664 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698