| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::move(parent), std::move(localTransformSpace), clipRect)); | 69 std::move(parent), std::move(localTransformSpace), clipRect)); |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 static CompositorElementId createDomNodeBasedCompositorElementId( | 73 static CompositorElementId createDomNodeBasedCompositorElementId( |
| 74 const LayoutObject& object) { | 74 const LayoutObject& object) { |
| 75 return createCompositorElementId(DOMNodeIds::idForNode(object.node()), | 75 return createCompositorElementId(DOMNodeIds::idForNode(object.node()), |
| 76 CompositorSubElementId::Primary); | 76 CompositorSubElementId::Primary); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // True if a new property was created, false if an existing one was updated. | 79 // True if a new property was created or a main thread scrolling reason changed |
| 80 // (which can affect descendants), false if an existing one was updated. |
| 80 static bool updateScrollTranslation( | 81 static bool updateScrollTranslation( |
| 81 FrameView& frameView, | 82 FrameView& frameView, |
| 82 PassRefPtr<const TransformPaintPropertyNode> parent, | 83 PassRefPtr<const TransformPaintPropertyNode> parent, |
| 83 const TransformationMatrix& matrix, | 84 const TransformationMatrix& matrix, |
| 84 const FloatPoint3D& origin, | 85 const FloatPoint3D& origin, |
| 85 PassRefPtr<const ScrollPaintPropertyNode> scroll) { | 86 PassRefPtr<const ScrollPaintPropertyNode> scrollParent, |
| 86 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | |
| 87 CompositorElementId compositorElementId = | |
| 88 createDomNodeBasedCompositorElementId(*frameView.layoutView()); | |
| 89 if (auto* existingScrollTranslation = frameView.scrollTranslation()) { | |
| 90 existingScrollTranslation->update( | |
| 91 std::move(parent), matrix, origin, std::move(scroll), false, 0, | |
| 92 CompositingReasonNone, compositorElementId); | |
| 93 return false; | |
| 94 } | |
| 95 frameView.setScrollTranslation(TransformPaintPropertyNode::create( | |
| 96 std::move(parent), matrix, origin, std::move(scroll), false, 0, | |
| 97 CompositingReasonNone, compositorElementId)); | |
| 98 return true; | |
| 99 } | |
| 100 | |
| 101 // True if a new property was created or a main thread scrolling reason changed | |
| 102 // (which can affect descendants), false if an existing one was updated. | |
| 103 static bool updateScroll( | |
| 104 FrameView& frameView, | |
| 105 PassRefPtr<const ScrollPaintPropertyNode> parent, | |
| 106 const IntSize& clip, | 87 const IntSize& clip, |
| 107 const IntSize& bounds, | 88 const IntSize& bounds, |
| 108 bool userScrollableHorizontal, | 89 bool userScrollableHorizontal, |
| 109 bool userScrollableVertical, | 90 bool userScrollableVertical, |
| 110 MainThreadScrollingReasons mainThreadScrollingReasons) { | 91 MainThreadScrollingReasons mainThreadScrollingReasons) { |
| 111 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 92 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 112 if (auto* existingScroll = frameView.scroll()) { | 93 CompositorElementId compositorElementId = |
| 113 auto existingReasons = existingScroll->mainThreadScrollingReasons(); | 94 createDomNodeBasedCompositorElementId(*frameView.layoutView()); |
| 114 existingScroll->update(std::move(parent), clip, bounds, | 95 if (auto* existingScrollTranslation = frameView.scrollTranslation()) { |
| 115 userScrollableHorizontal, userScrollableVertical, | 96 auto existingReasons = |
| 116 mainThreadScrollingReasons); | 97 existingScrollTranslation->scrollNode()->mainThreadScrollingReasons(); |
| 98 existingScrollTranslation->updateScrollTranslation( |
| 99 std::move(parent), matrix, origin, false, 0, CompositingReasonNone, |
| 100 compositorElementId, std::move(scrollParent), clip, bounds, |
| 101 userScrollableHorizontal, userScrollableVertical, |
| 102 mainThreadScrollingReasons); |
| 117 return existingReasons != mainThreadScrollingReasons; | 103 return existingReasons != mainThreadScrollingReasons; |
| 118 } | 104 } |
| 119 frameView.setScroll(ScrollPaintPropertyNode::create( | 105 frameView.setScrollTranslation( |
| 120 std::move(parent), clip, bounds, userScrollableHorizontal, | 106 TransformPaintPropertyNode::createScrollTranslation( |
| 121 userScrollableVertical, mainThreadScrollingReasons)); | 107 std::move(parent), matrix, origin, false, 0, CompositingReasonNone, |
| 108 compositorElementId, std::move(scrollParent), clip, bounds, |
| 109 userScrollableHorizontal, userScrollableVertical, |
| 110 mainThreadScrollingReasons)); |
| 122 return true; | 111 return true; |
| 123 } | 112 } |
| 124 | 113 |
| 125 static MainThreadScrollingReasons mainThreadScrollingReasons( | 114 static MainThreadScrollingReasons mainThreadScrollingReasons( |
| 126 const FrameView& frameView, | 115 const FrameView& frameView, |
| 127 MainThreadScrollingReasons ancestorReasons) { | 116 MainThreadScrollingReasons ancestorReasons) { |
| 128 auto reasons = ancestorReasons; | 117 auto reasons = ancestorReasons; |
| 129 if (!frameView.frame().settings()->getThreadedScrollingEnabled()) | 118 if (!frameView.frame().settings()->getThreadedScrollingEnabled()) |
| 130 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; | 119 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; |
| 131 if (frameView.hasBackgroundAttachmentFixedObjects()) | 120 if (frameView.hasBackgroundAttachmentFixedObjects()) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 162 frameView, context.current.transform, frameTranslate, FloatPoint3D()); | 151 frameView, context.current.transform, frameTranslate, FloatPoint3D()); |
| 163 | 152 |
| 164 FloatRoundedRect contentClip( | 153 FloatRoundedRect contentClip( |
| 165 IntRect(IntPoint(), frameView.visibleContentSize())); | 154 IntRect(IntPoint(), frameView.visibleContentSize())); |
| 166 context.forceSubtreeUpdate |= | 155 context.forceSubtreeUpdate |= |
| 167 updateContentClip(frameView, context.current.clip, | 156 updateContentClip(frameView, context.current.clip, |
| 168 frameView.preTranslation(), contentClip); | 157 frameView.preTranslation(), contentClip); |
| 169 | 158 |
| 170 ScrollOffset scrollOffset = frameView.getScrollOffset(); | 159 ScrollOffset scrollOffset = frameView.getScrollOffset(); |
| 171 if (frameView.isScrollable() || !scrollOffset.isZero()) { | 160 if (frameView.isScrollable() || !scrollOffset.isZero()) { |
| 161 TransformationMatrix frameScroll; |
| 162 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); |
| 163 |
| 172 IntSize scrollClip = frameView.visibleContentSize(); | 164 IntSize scrollClip = frameView.visibleContentSize(); |
| 173 IntSize scrollBounds = frameView.contentsSize(); | 165 IntSize scrollBounds = frameView.contentsSize(); |
| 174 bool userScrollableHorizontal = | 166 bool userScrollableHorizontal = |
| 175 frameView.userInputScrollable(HorizontalScrollbar); | 167 frameView.userInputScrollable(HorizontalScrollbar); |
| 176 bool userScrollableVertical = | 168 bool userScrollableVertical = |
| 177 frameView.userInputScrollable(VerticalScrollbar); | 169 frameView.userInputScrollable(VerticalScrollbar); |
| 178 | 170 |
| 179 auto ancestorReasons = | 171 auto ancestorReasons = |
| 180 context.current.scroll->mainThreadScrollingReasons(); | 172 context.current.scroll->mainThreadScrollingReasons(); |
| 181 auto reasons = mainThreadScrollingReasons(frameView, ancestorReasons); | 173 auto reasons = mainThreadScrollingReasons(frameView, ancestorReasons); |
| 182 context.forceSubtreeUpdate |= updateScroll( | |
| 183 frameView, context.current.scroll, scrollClip, scrollBounds, | |
| 184 userScrollableHorizontal, userScrollableVertical, reasons); | |
| 185 | 174 |
| 186 TransformationMatrix frameScroll; | |
| 187 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); | |
| 188 context.forceSubtreeUpdate |= updateScrollTranslation( | 175 context.forceSubtreeUpdate |= updateScrollTranslation( |
| 189 frameView, frameView.preTranslation(), frameScroll, FloatPoint3D(), | 176 frameView, frameView.preTranslation(), frameScroll, FloatPoint3D(), |
| 190 frameView.scroll()); | 177 context.current.scroll, scrollClip, scrollBounds, |
| 178 userScrollableHorizontal, userScrollableVertical, reasons); |
| 191 } else { | 179 } else { |
| 192 if (frameView.scrollTranslation() || frameView.scroll()) { | 180 if (frameView.scrollTranslation()) { |
| 193 // Ensure pre-existing properties are cleared if there is no scrolling. | 181 // Ensure pre-existing properties are cleared if there is no scrolling. |
| 194 frameView.setScrollTranslation(nullptr); | 182 frameView.setScrollTranslation(nullptr); |
| 195 frameView.setScroll(nullptr); | |
| 196 | |
| 197 // Rebuild all descendant properties because a property was removed. | 183 // Rebuild all descendant properties because a property was removed. |
| 198 context.forceSubtreeUpdate = true; | 184 context.forceSubtreeUpdate = true; |
| 199 } | 185 } |
| 200 } | 186 } |
| 201 } | 187 } |
| 202 | 188 |
| 203 // Initialize the context for current, absolute and fixed position cases. | 189 // Initialize the context for current, absolute and fixed position cases. |
| 204 // They are the same, except that scroll translation does not apply to | 190 // They are the same, except that scroll translation does not apply to |
| 205 // fixed position descendants. | 191 // fixed position descendants. |
| 206 const auto* fixedTransformNode = frameView.preTranslation() | 192 const auto* fixedTransformNode = frameView.preTranslation() |
| 207 ? frameView.preTranslation() | 193 ? frameView.preTranslation() |
| 208 : context.current.transform; | 194 : context.current.transform; |
| 209 auto* fixedScrollNode = context.current.scroll; | 195 auto* fixedScrollNode = context.current.scroll; |
| 210 DCHECK(frameView.preTranslation()); | 196 DCHECK(frameView.preTranslation()); |
| 211 context.current.transform = frameView.preTranslation(); | 197 context.current.transform = frameView.preTranslation(); |
| 212 DCHECK(frameView.contentClip()); | 198 DCHECK(frameView.contentClip()); |
| 213 context.current.clip = frameView.contentClip(); | 199 context.current.clip = frameView.contentClip(); |
| 214 if (const auto* scrollTranslation = frameView.scrollTranslation()) | 200 if (const auto* scrollTranslation = frameView.scrollTranslation()) { |
| 215 context.current.transform = scrollTranslation; | 201 context.current.transform = scrollTranslation; |
| 216 if (const auto* scroll = frameView.scroll()) | 202 context.current.scroll = scrollTranslation->scrollNode(); |
| 217 context.current.scroll = scroll; | 203 } |
| 218 context.current.paintOffset = LayoutPoint(); | 204 context.current.paintOffset = LayoutPoint(); |
| 219 context.current.renderingContextId = 0; | 205 context.current.renderingContextId = 0; |
| 220 context.current.shouldFlattenInheritedTransform = true; | 206 context.current.shouldFlattenInheritedTransform = true; |
| 221 context.absolutePosition = context.current; | 207 context.absolutePosition = context.current; |
| 222 context.containerForAbsolutePosition = nullptr; | 208 context.containerForAbsolutePosition = nullptr; |
| 223 context.fixedPosition = context.current; | 209 context.fixedPosition = context.current; |
| 224 context.fixedPosition.transform = fixedTransformNode; | 210 context.fixedPosition.transform = fixedTransformNode; |
| 225 context.fixedPosition.scroll = fixedScrollNode; | 211 context.fixedPosition.scroll = fixedScrollNode; |
| 226 | 212 |
| 227 std::unique_ptr<PropertyTreeState> contentsState( | 213 std::unique_ptr<PropertyTreeState> contentsState(new PropertyTreeState( |
| 228 new PropertyTreeState(context.current.transform, context.current.clip, | 214 context.current.transform, context.current.clip, context.currentEffect)); |
| 229 context.currentEffect, context.current.scroll)); | |
| 230 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); | 215 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); |
| 231 } | 216 } |
| 232 | 217 |
| 233 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( | 218 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( |
| 234 const LayoutObject& object, | 219 const LayoutObject& object, |
| 235 PaintPropertyTreeBuilderContext& context) { | 220 PaintPropertyTreeBuilderContext& context) { |
| 236 bool usesPaintOffsetTranslation = false; | 221 bool usesPaintOffsetTranslation = false; |
| 237 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 222 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 238 object.isLayoutView()) { | 223 object.isLayoutView()) { |
| 239 // Root layer scrolling always creates a translation node for LayoutView to | 224 // Root layer scrolling always creates a translation node for LayoutView to |
| (...skipping 18 matching lines...) Expand all Loading... |
| 258 LayoutPoint fractionalPaintOffset = | 243 LayoutPoint fractionalPaintOffset = |
| 259 LayoutPoint(context.current.paintOffset - roundedPaintOffset); | 244 LayoutPoint(context.current.paintOffset - roundedPaintOffset); |
| 260 | 245 |
| 261 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 246 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 262 if (usesPaintOffsetTranslation) { | 247 if (usesPaintOffsetTranslation) { |
| 263 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 248 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 264 context.forceSubtreeUpdate |= properties.updatePaintOffsetTranslation( | 249 context.forceSubtreeUpdate |= properties.updatePaintOffsetTranslation( |
| 265 context.current.transform, | 250 context.current.transform, |
| 266 TransformationMatrix().translate(roundedPaintOffset.x(), | 251 TransformationMatrix().translate(roundedPaintOffset.x(), |
| 267 roundedPaintOffset.y()), | 252 roundedPaintOffset.y()), |
| 268 FloatPoint3D(), nullptr, | 253 FloatPoint3D(), context.current.shouldFlattenInheritedTransform, |
| 269 context.current.shouldFlattenInheritedTransform, | |
| 270 context.current.renderingContextId); | 254 context.current.renderingContextId); |
| 271 } else { | 255 } else { |
| 272 if (auto* properties = object.getMutableForPainting().paintProperties()) | 256 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 273 context.forceSubtreeUpdate |= properties->clearPaintOffsetTranslation(); | 257 context.forceSubtreeUpdate |= properties->clearPaintOffsetTranslation(); |
| 274 } | 258 } |
| 275 } | 259 } |
| 276 | 260 |
| 277 const auto* properties = object.paintProperties(); | 261 const auto* properties = object.paintProperties(); |
| 278 if (properties && properties->paintOffsetTranslation()) { | 262 if (properties && properties->paintOffsetTranslation()) { |
| 279 context.current.transform = properties->paintOffsetTranslation(); | 263 context.current.transform = properties->paintOffsetTranslation(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 renderingContextId = PtrHash<const LayoutObject>::hash(&object); | 382 renderingContextId = PtrHash<const LayoutObject>::hash(&object); |
| 399 | 383 |
| 400 CompositorElementId compositorElementId = | 384 CompositorElementId compositorElementId = |
| 401 style.hasCurrentTransformAnimation() | 385 style.hasCurrentTransformAnimation() |
| 402 ? createDomNodeBasedCompositorElementId(object) | 386 ? createDomNodeBasedCompositorElementId(object) |
| 403 : CompositorElementId(); | 387 : CompositorElementId(); |
| 404 | 388 |
| 405 auto& properties = | 389 auto& properties = |
| 406 object.getMutableForPainting().ensurePaintProperties(); | 390 object.getMutableForPainting().ensurePaintProperties(); |
| 407 context.forceSubtreeUpdate |= properties.updateTransform( | 391 context.forceSubtreeUpdate |= properties.updateTransform( |
| 408 context.current.transform, matrix, transformOrigin(box), nullptr, | 392 context.current.transform, matrix, transformOrigin(box), |
| 409 context.current.shouldFlattenInheritedTransform, renderingContextId, | 393 context.current.shouldFlattenInheritedTransform, renderingContextId, |
| 410 compositingReasons, compositorElementId); | 394 compositingReasons, compositorElementId); |
| 411 hasTransform = true; | 395 hasTransform = true; |
| 412 } | 396 } |
| 413 } | 397 } |
| 414 if (!hasTransform) { | 398 if (!hasTransform) { |
| 415 if (auto* properties = object.getMutableForPainting().paintProperties()) | 399 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 416 context.forceSubtreeUpdate |= properties->clearTransform(); | 400 context.forceSubtreeUpdate |= properties->clearTransform(); |
| 417 } | 401 } |
| 418 } | 402 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 return; | 566 return; |
| 583 | 567 |
| 584 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since | 568 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since |
| 585 // we don't need them at the moment. | 569 // we don't need them at the moment. |
| 586 if (!object.isBox() && !object.hasLayer()) { | 570 if (!object.isBox() && !object.hasLayer()) { |
| 587 if (auto* properties = object.getMutableForPainting().paintProperties()) | 571 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 588 properties->clearLocalBorderBoxProperties(); | 572 properties->clearLocalBorderBoxProperties(); |
| 589 } else { | 573 } else { |
| 590 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 574 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 591 properties.updateLocalBorderBoxProperties( | 575 properties.updateLocalBorderBoxProperties( |
| 592 context.current.transform, context.current.clip, context.currentEffect, | 576 context.current.transform, context.current.clip, context.currentEffect); |
| 593 context.current.scroll); | |
| 594 } | 577 } |
| 595 } | 578 } |
| 596 | 579 |
| 597 // TODO(trchen): Remove this once we bake the paint offset into frameRect. | 580 // TODO(trchen): Remove this once we bake the paint offset into frameRect. |
| 598 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset( | 581 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset( |
| 599 const LayoutObject& object, | 582 const LayoutObject& object, |
| 600 PaintPropertyTreeBuilderContext& context) { | 583 PaintPropertyTreeBuilderContext& context) { |
| 601 if (!object.needsPaintPropertyUpdate() && !context.forceSubtreeUpdate) | 584 if (!object.needsPaintPropertyUpdate() && !context.forceSubtreeUpdate) |
| 602 return; | 585 return; |
| 603 | 586 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (object.isBox() && style.hasPerspective()) { | 670 if (object.isBox() && style.hasPerspective()) { |
| 688 // The perspective node must not flatten (else nothing will get | 671 // The perspective node must not flatten (else nothing will get |
| 689 // perspective), but it should still extend the rendering context as | 672 // perspective), but it should still extend the rendering context as |
| 690 // most transform nodes do. | 673 // most transform nodes do. |
| 691 TransformationMatrix matrix = | 674 TransformationMatrix matrix = |
| 692 TransformationMatrix().applyPerspective(style.perspective()); | 675 TransformationMatrix().applyPerspective(style.perspective()); |
| 693 FloatPoint3D origin = perspectiveOrigin(toLayoutBox(object)) + | 676 FloatPoint3D origin = perspectiveOrigin(toLayoutBox(object)) + |
| 694 toLayoutSize(context.current.paintOffset); | 677 toLayoutSize(context.current.paintOffset); |
| 695 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 678 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 696 context.forceSubtreeUpdate |= properties.updatePerspective( | 679 context.forceSubtreeUpdate |= properties.updatePerspective( |
| 697 context.current.transform, matrix, origin, nullptr, | 680 context.current.transform, matrix, origin, |
| 698 context.current.shouldFlattenInheritedTransform, | 681 context.current.shouldFlattenInheritedTransform, |
| 699 context.current.renderingContextId); | 682 context.current.renderingContextId); |
| 700 } else { | 683 } else { |
| 701 if (auto* properties = object.getMutableForPainting().paintProperties()) | 684 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 702 context.forceSubtreeUpdate |= properties->clearPerspective(); | 685 context.forceSubtreeUpdate |= properties->clearPerspective(); |
| 703 } | 686 } |
| 704 } | 687 } |
| 705 | 688 |
| 706 const auto* properties = object.paintProperties(); | 689 const auto* properties = object.paintProperties(); |
| 707 if (properties && properties->perspective()) { | 690 if (properties && properties->perspective()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 context.current.scroll->mainThreadScrollingReasons(); | 749 context.current.scroll->mainThreadScrollingReasons(); |
| 767 auto reasons = mainThreadScrollingReasons(object, ancestorReasons); | 750 auto reasons = mainThreadScrollingReasons(object, ancestorReasons); |
| 768 bool scrollNodeNeededForMainThreadReasons = ancestorReasons != reasons; | 751 bool scrollNodeNeededForMainThreadReasons = ancestorReasons != reasons; |
| 769 | 752 |
| 770 const LayoutBox& box = toLayoutBox(object); | 753 const LayoutBox& box = toLayoutBox(object); |
| 771 const auto* scrollableArea = box.getScrollableArea(); | 754 const auto* scrollableArea = box.getScrollableArea(); |
| 772 IntSize scrollOffset = box.scrolledContentOffset(); | 755 IntSize scrollOffset = box.scrolledContentOffset(); |
| 773 if (scrollNodeNeededForMainThreadReasons || !scrollOffset.isZero() || | 756 if (scrollNodeNeededForMainThreadReasons || !scrollOffset.isZero() || |
| 774 scrollableArea->scrollsOverflow()) { | 757 scrollableArea->scrollsOverflow()) { |
| 775 needsScrollProperties = true; | 758 needsScrollProperties = true; |
| 759 auto& properties = |
| 760 object.getMutableForPainting().ensurePaintProperties(); |
| 776 | 761 |
| 777 IntSize scrollClip = scrollableArea->visibleContentRect().size(); | 762 IntSize scrollClip = scrollableArea->visibleContentRect().size(); |
| 778 IntSize scrollBounds = scrollableArea->contentsSize(); | 763 IntSize scrollBounds = scrollableArea->contentsSize(); |
| 779 bool userScrollableHorizontal = | 764 bool userScrollableHorizontal = |
| 780 scrollableArea->userInputScrollable(HorizontalScrollbar); | 765 scrollableArea->userInputScrollable(HorizontalScrollbar); |
| 781 bool userScrollableVertical = | 766 bool userScrollableVertical = |
| 782 scrollableArea->userInputScrollable(VerticalScrollbar); | 767 scrollableArea->userInputScrollable(VerticalScrollbar); |
| 783 | 768 |
| 784 // Main thread scrolling reasons depend on their ancestor's reasons | 769 // Main thread scrolling reasons depend on their ancestor's reasons |
| 785 // so ensure the entire subtree is updated when reasons change. | 770 // so ensure the entire subtree is updated when reasons change. |
| 786 auto& properties = | 771 if (auto* existingScrollTranslation = properties.scrollTranslation()) { |
| 787 object.getMutableForPainting().ensurePaintProperties(); | 772 auto* existingScrollNode = existingScrollTranslation->scrollNode(); |
| 788 if (auto* existingScrollNode = properties.scroll()) { | |
| 789 if (existingScrollNode->mainThreadScrollingReasons() != reasons) | 773 if (existingScrollNode->mainThreadScrollingReasons() != reasons) |
| 790 context.forceSubtreeUpdate = true; | 774 context.forceSubtreeUpdate = true; |
| 791 } | 775 } |
| 792 | 776 |
| 793 context.forceSubtreeUpdate |= properties.updateScroll( | |
| 794 context.current.scroll, scrollClip, scrollBounds, | |
| 795 userScrollableHorizontal, userScrollableVertical, reasons); | |
| 796 | |
| 797 CompositorElementId compositorElementId = | 777 CompositorElementId compositorElementId = |
| 798 createDomNodeBasedCompositorElementId(object); | 778 createDomNodeBasedCompositorElementId(object); |
| 799 TransformationMatrix matrix = TransformationMatrix().translate( | 779 TransformationMatrix matrix = TransformationMatrix().translate( |
| 800 -scrollOffset.width(), -scrollOffset.height()); | 780 -scrollOffset.width(), -scrollOffset.height()); |
| 801 context.forceSubtreeUpdate |= properties.updateScrollTranslation( | 781 context.forceSubtreeUpdate |= properties.updateScrollTranslation( |
| 802 context.current.transform, matrix, FloatPoint3D(), | 782 context.current.transform, matrix, FloatPoint3D(), |
| 803 properties.scroll(), | |
| 804 context.current.shouldFlattenInheritedTransform, | 783 context.current.shouldFlattenInheritedTransform, |
| 805 context.current.renderingContextId, CompositingReasonNone, | 784 context.current.renderingContextId, CompositingReasonNone, |
| 806 compositorElementId); | 785 compositorElementId, context.current.scroll, scrollClip, |
| 786 scrollBounds, userScrollableHorizontal, userScrollableVertical, |
| 787 reasons); |
| 807 } | 788 } |
| 808 } | 789 } |
| 809 | 790 |
| 810 if (!needsScrollProperties) { | 791 if (!needsScrollProperties) { |
| 811 // Ensure pre-existing properties are cleared. | 792 // Ensure pre-existing properties are cleared. |
| 812 if (auto* properties = object.getMutableForPainting().paintProperties()) { | 793 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 813 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); | 794 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); |
| 814 context.forceSubtreeUpdate |= properties->clearScroll(); | |
| 815 } | |
| 816 } | 795 } |
| 817 } | 796 } |
| 818 | 797 |
| 819 if (object.paintProperties() && object.paintProperties()->scroll()) { | 798 if (object.paintProperties() && |
| 799 object.paintProperties()->scrollTranslation()) { |
| 820 context.current.transform = object.paintProperties()->scrollTranslation(); | 800 context.current.transform = object.paintProperties()->scrollTranslation(); |
| 821 context.current.scroll = object.paintProperties()->scroll(); | 801 context.current.scroll = context.current.transform->scrollNode(); |
| 822 context.current.shouldFlattenInheritedTransform = false; | 802 context.current.shouldFlattenInheritedTransform = false; |
| 823 } | 803 } |
| 824 } | 804 } |
| 825 | 805 |
| 826 void PaintPropertyTreeBuilder::updateOutOfFlowContext( | 806 void PaintPropertyTreeBuilder::updateOutOfFlowContext( |
| 827 const LayoutObject& object, | 807 const LayoutObject& object, |
| 828 PaintPropertyTreeBuilderContext& context) { | 808 PaintPropertyTreeBuilderContext& context) { |
| 829 if (object.isLayoutBlock()) | 809 if (object.isLayoutBlock()) |
| 830 context.paintOffsetForFloat = context.current.paintOffset; | 810 context.paintOffsetForFloat = context.current.paintOffset; |
| 831 | 811 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 updateOverflowClip(object, context); | 977 updateOverflowClip(object, context); |
| 998 updatePerspective(object, context); | 978 updatePerspective(object, context); |
| 999 updateSvgLocalToBorderBoxTransform(object, context); | 979 updateSvgLocalToBorderBoxTransform(object, context); |
| 1000 updateScrollAndScrollTranslation(object, context); | 980 updateScrollAndScrollTranslation(object, context); |
| 1001 updateOutOfFlowContext(object, context); | 981 updateOutOfFlowContext(object, context); |
| 1002 | 982 |
| 1003 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 983 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 1004 } | 984 } |
| 1005 | 985 |
| 1006 } // namespace blink | 986 } // namespace blink |
| OLD | NEW |