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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2638333007: Add compositor element id for scroll nodes in SPv2. (Closed)
Patch Set: Created 3 years, 11 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PaintPropertyTreeBuilder.h" 5 #include "core/paint/PaintPropertyTreeBuilder.h"
6 6
7 #include "core/dom/DOMNodeIds.h" 7 #include "core/dom/DOMNodeIds.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); 79 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled());
80 if (auto* existingScrollTranslation = frameView.scrollTranslation()) { 80 if (auto* existingScrollTranslation = frameView.scrollTranslation()) {
81 existingScrollTranslation->update(std::move(parent), matrix, origin); 81 existingScrollTranslation->update(std::move(parent), matrix, origin);
82 return false; 82 return false;
83 } 83 }
84 frameView.setScrollTranslation( 84 frameView.setScrollTranslation(
85 TransformPaintPropertyNode::create(std::move(parent), matrix, origin)); 85 TransformPaintPropertyNode::create(std::move(parent), matrix, origin));
86 return true; 86 return true;
87 } 87 }
88 88
89 static CompositorElementId createDomNodeBasedCompositorElementId(
wkorman 2017/01/19 23:43:10 Moved here without changes so that it's in scope f
90 const LayoutObject& object) {
91 return createCompositorElementId(DOMNodeIds::idForNode(object.node()),
92 CompositorSubElementId::Primary);
93 }
94
89 // True if a new property was created or a main thread scrolling reason changed 95 // True if a new property was created or a main thread scrolling reason changed
90 // (which can affect descendants), false if an existing one was updated. 96 // (which can affect descendants), false if an existing one was updated.
91 static bool updateScroll( 97 static bool updateScroll(
92 FrameView& frameView, 98 FrameView& frameView,
93 PassRefPtr<const ScrollPaintPropertyNode> parent, 99 PassRefPtr<const ScrollPaintPropertyNode> parent,
94 PassRefPtr<const TransformPaintPropertyNode> scrollOffset, 100 PassRefPtr<const TransformPaintPropertyNode> scrollOffset,
95 const IntSize& clip, 101 const IntSize& clip,
96 const IntSize& bounds, 102 const IntSize& bounds,
97 bool userScrollableHorizontal, 103 bool userScrollableHorizontal,
98 bool userScrollableVertical, 104 bool userScrollableVertical,
99 MainThreadScrollingReasons mainThreadScrollingReasons) { 105 MainThreadScrollingReasons mainThreadScrollingReasons) {
100 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); 106 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled());
107
108 // TODO(wkorman): Should we generate compositor element id conditionally on
wkorman 2017/01/19 23:43:10 Seeking feedback here. The general things I'm unce
pdr. 2017/01/20 06:26:32 Nope, you got the two.
ajuma 2017/01/20 14:41:57 The only downside I can think of is that each DOMN
109 // something that connotes use of composited scrolling? Or pass it in as a
110 // param similar to scrolling reasons? See also similar comment in
111 // PaintPropertyTreeBuilder::updateScrollAndScrollTranslation.
112 CompositorElementId compositorElementId =
113 createDomNodeBasedCompositorElementId(*frameView.layoutView());
101 if (auto* existingScroll = frameView.scroll()) { 114 if (auto* existingScroll = frameView.scroll()) {
102 auto existingReasons = existingScroll->mainThreadScrollingReasons(); 115 auto existingReasons = existingScroll->mainThreadScrollingReasons();
103 existingScroll->update(std::move(parent), std::move(scrollOffset), clip, 116 existingScroll->update(std::move(parent), std::move(scrollOffset), clip,
104 bounds, userScrollableHorizontal, 117 bounds, userScrollableHorizontal,
105 userScrollableVertical, mainThreadScrollingReasons); 118 userScrollableVertical, mainThreadScrollingReasons,
119 compositorElementId);
106 return existingReasons != mainThreadScrollingReasons; 120 return existingReasons != mainThreadScrollingReasons;
107 } 121 }
108 frameView.setScroll(ScrollPaintPropertyNode::create( 122 frameView.setScroll(ScrollPaintPropertyNode::create(
109 std::move(parent), std::move(scrollOffset), clip, bounds, 123 std::move(parent), std::move(scrollOffset), clip, bounds,
110 userScrollableHorizontal, userScrollableVertical, 124 userScrollableHorizontal, userScrollableVertical,
111 mainThreadScrollingReasons)); 125 mainThreadScrollingReasons, compositorElementId));
112 return true; 126 return true;
113 } 127 }
114 128
115 static MainThreadScrollingReasons mainThreadScrollingReasons( 129 static MainThreadScrollingReasons mainThreadScrollingReasons(
116 const FrameView& frameView, 130 const FrameView& frameView,
117 MainThreadScrollingReasons ancestorReasons) { 131 MainThreadScrollingReasons ancestorReasons) {
118 auto reasons = ancestorReasons; 132 auto reasons = ancestorReasons;
119 if (!frameView.frame().settings()->getThreadedScrollingEnabled()) 133 if (!frameView.frame().settings()->getThreadedScrollingEnabled())
120 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; 134 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled;
121 if (frameView.hasBackgroundAttachmentFixedObjects()) 135 if (frameView.hasBackgroundAttachmentFixedObjects())
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Transform origin has no effect without a transform or motion path. 356 // Transform origin has no effect without a transform or motion path.
343 if (!style.hasTransform()) 357 if (!style.hasTransform())
344 return FloatPoint3D(); 358 return FloatPoint3D();
345 FloatSize borderBoxSize(box.size()); 359 FloatSize borderBoxSize(box.size());
346 return FloatPoint3D( 360 return FloatPoint3D(
347 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), 361 floatValueForLength(style.transformOriginX(), borderBoxSize.width()),
348 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), 362 floatValueForLength(style.transformOriginY(), borderBoxSize.height()),
349 style.transformOriginZ()); 363 style.transformOriginZ());
350 } 364 }
351 365
352 static CompositorElementId createDomNodeBasedCompositorElementId(
353 const LayoutObject& object) {
354 return createCompositorElementId(DOMNodeIds::idForNode(object.node()),
355 CompositorSubElementId::Primary);
356 }
357
358 void PaintPropertyTreeBuilder::updateTransform( 366 void PaintPropertyTreeBuilder::updateTransform(
359 const LayoutObject& object, 367 const LayoutObject& object,
360 PaintPropertyTreeBuilderContext& context) { 368 PaintPropertyTreeBuilderContext& context) {
361 if (object.isSVGChild()) { 369 if (object.isSVGChild()) {
362 updateTransformForNonRootSVG(object, context); 370 updateTransformForNonRootSVG(object, context);
363 return; 371 return;
364 } 372 }
365 373
366 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { 374 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) {
367 const ComputedStyle& style = object.styleRef(); 375 const ComputedStyle& style = object.styleRef();
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 bool userScrollableVertical = 795 bool userScrollableVertical =
788 scrollableArea->userInputScrollable(VerticalScrollbar); 796 scrollableArea->userInputScrollable(VerticalScrollbar);
789 797
790 // Main thread scrolling reasons depend on their ancestor's reasons 798 // Main thread scrolling reasons depend on their ancestor's reasons
791 // so ensure the entire subtree is updated when reasons change. 799 // so ensure the entire subtree is updated when reasons change.
792 if (auto* existingScrollNode = properties.scroll()) { 800 if (auto* existingScrollNode = properties.scroll()) {
793 if (existingScrollNode->mainThreadScrollingReasons() != reasons) 801 if (existingScrollNode->mainThreadScrollingReasons() != reasons)
794 context.forceSubtreeUpdate = true; 802 context.forceSubtreeUpdate = true;
795 } 803 }
796 804
805 // TODO(wkorman): Should we do this conditionally on something that
wkorman 2017/01/19 23:43:10 And seeking feedback here.
ajuma 2017/01/20 14:41:57 See comment above, but I think this is fine for no
806 // connotes use of composited scrolling?
807 // ScrollableArea::usesCompositedScrolling is not currently SPv2
808 // compatible due to dependence on CompositedLayerMapping (see
809 // PaintLayerScrollableArea override).
810 CompositorElementId compositorElementId =
811 createDomNodeBasedCompositorElementId(object);
812
797 context.forceSubtreeUpdate |= properties.updateScroll( 813 context.forceSubtreeUpdate |= properties.updateScroll(
798 context.current.scroll, properties.scrollTranslation(), scrollClip, 814 context.current.scroll, properties.scrollTranslation(), scrollClip,
799 scrollBounds, userScrollableHorizontal, userScrollableVertical, 815 scrollBounds, userScrollableHorizontal, userScrollableVertical,
800 reasons); 816 reasons, compositorElementId);
801 } 817 }
802 } 818 }
803 819
804 if (!needsScrollProperties) { 820 if (!needsScrollProperties) {
805 // Ensure pre-existing properties are cleared. 821 // Ensure pre-existing properties are cleared.
806 if (auto* properties = object.getMutableForPainting().paintProperties()) { 822 if (auto* properties = object.getMutableForPainting().paintProperties()) {
807 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); 823 context.forceSubtreeUpdate |= properties->clearScrollTranslation();
808 context.forceSubtreeUpdate |= properties->clearScroll(); 824 context.forceSubtreeUpdate |= properties->clearScroll();
809 } 825 }
810 } 826 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 updateOverflowClip(object, context); 1005 updateOverflowClip(object, context);
990 updatePerspective(object, context); 1006 updatePerspective(object, context);
991 updateSvgLocalToBorderBoxTransform(object, context); 1007 updateSvgLocalToBorderBoxTransform(object, context);
992 updateScrollAndScrollTranslation(object, context); 1008 updateScrollAndScrollTranslation(object, context);
993 updateOutOfFlowContext(object, context); 1009 updateOutOfFlowContext(object, context);
994 1010
995 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); 1011 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate();
996 } 1012 }
997 1013
998 } // namespace blink 1014 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698