| OLD | NEW |
| 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 Loading... |
| 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( |
| 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 CompositorElementId compositorElementId = |
| 109 createDomNodeBasedCompositorElementId(*frameView.layoutView()); |
| 101 if (auto* existingScroll = frameView.scroll()) { | 110 if (auto* existingScroll = frameView.scroll()) { |
| 102 auto existingReasons = existingScroll->mainThreadScrollingReasons(); | 111 auto existingReasons = existingScroll->mainThreadScrollingReasons(); |
| 103 existingScroll->update(std::move(parent), std::move(scrollOffset), clip, | 112 existingScroll->update(std::move(parent), std::move(scrollOffset), clip, |
| 104 bounds, userScrollableHorizontal, | 113 bounds, userScrollableHorizontal, |
| 105 userScrollableVertical, mainThreadScrollingReasons); | 114 userScrollableVertical, mainThreadScrollingReasons, |
| 115 compositorElementId); |
| 106 return existingReasons != mainThreadScrollingReasons; | 116 return existingReasons != mainThreadScrollingReasons; |
| 107 } | 117 } |
| 108 frameView.setScroll(ScrollPaintPropertyNode::create( | 118 frameView.setScroll(ScrollPaintPropertyNode::create( |
| 109 std::move(parent), std::move(scrollOffset), clip, bounds, | 119 std::move(parent), std::move(scrollOffset), clip, bounds, |
| 110 userScrollableHorizontal, userScrollableVertical, | 120 userScrollableHorizontal, userScrollableVertical, |
| 111 mainThreadScrollingReasons)); | 121 mainThreadScrollingReasons, compositorElementId)); |
| 112 return true; | 122 return true; |
| 113 } | 123 } |
| 114 | 124 |
| 115 static MainThreadScrollingReasons mainThreadScrollingReasons( | 125 static MainThreadScrollingReasons mainThreadScrollingReasons( |
| 116 const FrameView& frameView, | 126 const FrameView& frameView, |
| 117 MainThreadScrollingReasons ancestorReasons) { | 127 MainThreadScrollingReasons ancestorReasons) { |
| 118 auto reasons = ancestorReasons; | 128 auto reasons = ancestorReasons; |
| 119 if (!frameView.frame().settings()->getThreadedScrollingEnabled()) | 129 if (!frameView.frame().settings()->getThreadedScrollingEnabled()) |
| 120 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; | 130 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; |
| 121 if (frameView.hasBackgroundAttachmentFixedObjects()) | 131 if (frameView.hasBackgroundAttachmentFixedObjects()) |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Transform origin has no effect without a transform or motion path. | 352 // Transform origin has no effect without a transform or motion path. |
| 343 if (!style.hasTransform()) | 353 if (!style.hasTransform()) |
| 344 return FloatPoint3D(); | 354 return FloatPoint3D(); |
| 345 FloatSize borderBoxSize(box.size()); | 355 FloatSize borderBoxSize(box.size()); |
| 346 return FloatPoint3D( | 356 return FloatPoint3D( |
| 347 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), | 357 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), |
| 348 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), | 358 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), |
| 349 style.transformOriginZ()); | 359 style.transformOriginZ()); |
| 350 } | 360 } |
| 351 | 361 |
| 352 static CompositorElementId createDomNodeBasedCompositorElementId( | |
| 353 const LayoutObject& object) { | |
| 354 return createCompositorElementId(DOMNodeIds::idForNode(object.node()), | |
| 355 CompositorSubElementId::Primary); | |
| 356 } | |
| 357 | |
| 358 void PaintPropertyTreeBuilder::updateTransform( | 362 void PaintPropertyTreeBuilder::updateTransform( |
| 359 const LayoutObject& object, | 363 const LayoutObject& object, |
| 360 PaintPropertyTreeBuilderContext& context) { | 364 PaintPropertyTreeBuilderContext& context) { |
| 361 if (object.isSVGChild()) { | 365 if (object.isSVGChild()) { |
| 362 updateTransformForNonRootSVG(object, context); | 366 updateTransformForNonRootSVG(object, context); |
| 363 return; | 367 return; |
| 364 } | 368 } |
| 365 | 369 |
| 366 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 370 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 367 const ComputedStyle& style = object.styleRef(); | 371 const ComputedStyle& style = object.styleRef(); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 bool userScrollableVertical = | 791 bool userScrollableVertical = |
| 788 scrollableArea->userInputScrollable(VerticalScrollbar); | 792 scrollableArea->userInputScrollable(VerticalScrollbar); |
| 789 | 793 |
| 790 // Main thread scrolling reasons depend on their ancestor's reasons | 794 // Main thread scrolling reasons depend on their ancestor's reasons |
| 791 // so ensure the entire subtree is updated when reasons change. | 795 // so ensure the entire subtree is updated when reasons change. |
| 792 if (auto* existingScrollNode = properties.scroll()) { | 796 if (auto* existingScrollNode = properties.scroll()) { |
| 793 if (existingScrollNode->mainThreadScrollingReasons() != reasons) | 797 if (existingScrollNode->mainThreadScrollingReasons() != reasons) |
| 794 context.forceSubtreeUpdate = true; | 798 context.forceSubtreeUpdate = true; |
| 795 } | 799 } |
| 796 | 800 |
| 801 CompositorElementId compositorElementId = |
| 802 createDomNodeBasedCompositorElementId(object); |
| 803 |
| 797 context.forceSubtreeUpdate |= properties.updateScroll( | 804 context.forceSubtreeUpdate |= properties.updateScroll( |
| 798 context.current.scroll, properties.scrollTranslation(), scrollClip, | 805 context.current.scroll, properties.scrollTranslation(), scrollClip, |
| 799 scrollBounds, userScrollableHorizontal, userScrollableVertical, | 806 scrollBounds, userScrollableHorizontal, userScrollableVertical, |
| 800 reasons); | 807 reasons, compositorElementId); |
| 801 } | 808 } |
| 802 } | 809 } |
| 803 | 810 |
| 804 if (!needsScrollProperties) { | 811 if (!needsScrollProperties) { |
| 805 // Ensure pre-existing properties are cleared. | 812 // Ensure pre-existing properties are cleared. |
| 806 if (auto* properties = object.getMutableForPainting().paintProperties()) { | 813 if (auto* properties = object.getMutableForPainting().paintProperties()) { |
| 807 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); | 814 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); |
| 808 context.forceSubtreeUpdate |= properties->clearScroll(); | 815 context.forceSubtreeUpdate |= properties->clearScroll(); |
| 809 } | 816 } |
| 810 } | 817 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 updateOverflowClip(object, context); | 998 updateOverflowClip(object, context); |
| 992 updatePerspective(object, context); | 999 updatePerspective(object, context); |
| 993 updateSvgLocalToBorderBoxTransform(object, context); | 1000 updateSvgLocalToBorderBoxTransform(object, context); |
| 994 updateScrollAndScrollTranslation(object, context); | 1001 updateScrollAndScrollTranslation(object, context); |
| 995 updateOutOfFlowContext(object, context); | 1002 updateOutOfFlowContext(object, context); |
| 996 | 1003 |
| 997 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1004 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 998 } | 1005 } |
| 999 | 1006 |
| 1000 } // namespace blink | 1007 } // namespace blink |
| OLD | NEW |