Chromium Code Reviews| 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; | |
|
chrishtr
2017/01/26 21:22:58
Move this down below 173 if it's not needed?
pdr.
2017/01/27 20:09:33
My goal in moving this is to initialize each of th
| |
| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 return; | 565 return; |
| 582 | 566 |
| 583 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since | 567 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since |
| 584 // we don't need them at the moment. | 568 // we don't need them at the moment. |
| 585 if (!object.isBox() && !object.hasLayer()) { | 569 if (!object.isBox() && !object.hasLayer()) { |
| 586 if (auto* properties = object.getMutableForPainting().paintProperties()) | 570 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 587 properties->clearLocalBorderBoxProperties(); | 571 properties->clearLocalBorderBoxProperties(); |
| 588 } else { | 572 } else { |
| 589 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 573 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 590 properties.updateLocalBorderBoxProperties( | 574 properties.updateLocalBorderBoxProperties( |
| 591 context.current.transform, context.current.clip, context.currentEffect, | 575 context.current.transform, context.current.clip, context.currentEffect); |
| 592 context.current.scroll); | |
| 593 } | 576 } |
| 594 } | 577 } |
| 595 | 578 |
| 596 // TODO(trchen): Remove this once we bake the paint offset into frameRect. | 579 // TODO(trchen): Remove this once we bake the paint offset into frameRect. |
| 597 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset( | 580 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset( |
| 598 const LayoutObject& object, | 581 const LayoutObject& object, |
| 599 PaintPropertyTreeBuilderContext& context) { | 582 PaintPropertyTreeBuilderContext& context) { |
| 600 if (!object.needsPaintPropertyUpdate() && !context.forceSubtreeUpdate) | 583 if (!object.needsPaintPropertyUpdate() && !context.forceSubtreeUpdate) |
| 601 return; | 584 return; |
| 602 | 585 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 if (object.isBox() && style.hasPerspective()) { | 669 if (object.isBox() && style.hasPerspective()) { |
| 687 // The perspective node must not flatten (else nothing will get | 670 // The perspective node must not flatten (else nothing will get |
| 688 // perspective), but it should still extend the rendering context as | 671 // perspective), but it should still extend the rendering context as |
| 689 // most transform nodes do. | 672 // most transform nodes do. |
| 690 TransformationMatrix matrix = | 673 TransformationMatrix matrix = |
| 691 TransformationMatrix().applyPerspective(style.perspective()); | 674 TransformationMatrix().applyPerspective(style.perspective()); |
| 692 FloatPoint3D origin = perspectiveOrigin(toLayoutBox(object)) + | 675 FloatPoint3D origin = perspectiveOrigin(toLayoutBox(object)) + |
| 693 toLayoutSize(context.current.paintOffset); | 676 toLayoutSize(context.current.paintOffset); |
| 694 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 677 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 695 context.forceSubtreeUpdate |= properties.updatePerspective( | 678 context.forceSubtreeUpdate |= properties.updatePerspective( |
| 696 context.current.transform, matrix, origin, nullptr, | 679 context.current.transform, matrix, origin, |
| 697 context.current.shouldFlattenInheritedTransform, | 680 context.current.shouldFlattenInheritedTransform, |
| 698 context.current.renderingContextId); | 681 context.current.renderingContextId); |
| 699 } else { | 682 } else { |
| 700 if (auto* properties = object.getMutableForPainting().paintProperties()) | 683 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 701 context.forceSubtreeUpdate |= properties->clearPerspective(); | 684 context.forceSubtreeUpdate |= properties->clearPerspective(); |
| 702 } | 685 } |
| 703 } | 686 } |
| 704 | 687 |
| 705 const auto* properties = object.paintProperties(); | 688 const auto* properties = object.paintProperties(); |
| 706 if (properties && properties->perspective()) { | 689 if (properties && properties->perspective()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 context.current.scroll->mainThreadScrollingReasons(); | 748 context.current.scroll->mainThreadScrollingReasons(); |
| 766 auto reasons = mainThreadScrollingReasons(object, ancestorReasons); | 749 auto reasons = mainThreadScrollingReasons(object, ancestorReasons); |
| 767 bool scrollNodeNeededForMainThreadReasons = ancestorReasons != reasons; | 750 bool scrollNodeNeededForMainThreadReasons = ancestorReasons != reasons; |
| 768 | 751 |
| 769 const LayoutBox& box = toLayoutBox(object); | 752 const LayoutBox& box = toLayoutBox(object); |
| 770 const auto* scrollableArea = box.getScrollableArea(); | 753 const auto* scrollableArea = box.getScrollableArea(); |
| 771 IntSize scrollOffset = box.scrolledContentOffset(); | 754 IntSize scrollOffset = box.scrolledContentOffset(); |
| 772 if (scrollNodeNeededForMainThreadReasons || !scrollOffset.isZero() || | 755 if (scrollNodeNeededForMainThreadReasons || !scrollOffset.isZero() || |
| 773 scrollableArea->scrollsOverflow()) { | 756 scrollableArea->scrollsOverflow()) { |
| 774 needsScrollProperties = true; | 757 needsScrollProperties = true; |
| 758 auto& properties = | |
| 759 object.getMutableForPainting().ensurePaintProperties(); | |
| 775 | 760 |
| 776 IntSize scrollClip = scrollableArea->visibleContentRect().size(); | 761 IntSize scrollClip = scrollableArea->visibleContentRect().size(); |
| 777 IntSize scrollBounds = scrollableArea->contentsSize(); | 762 IntSize scrollBounds = scrollableArea->contentsSize(); |
| 778 bool userScrollableHorizontal = | 763 bool userScrollableHorizontal = |
| 779 scrollableArea->userInputScrollable(HorizontalScrollbar); | 764 scrollableArea->userInputScrollable(HorizontalScrollbar); |
| 780 bool userScrollableVertical = | 765 bool userScrollableVertical = |
| 781 scrollableArea->userInputScrollable(VerticalScrollbar); | 766 scrollableArea->userInputScrollable(VerticalScrollbar); |
| 782 | 767 |
| 783 // Main thread scrolling reasons depend on their ancestor's reasons | 768 // Main thread scrolling reasons depend on their ancestor's reasons |
| 784 // so ensure the entire subtree is updated when reasons change. | 769 // so ensure the entire subtree is updated when reasons change. |
| 785 auto& properties = | 770 if (auto* existingScrollTranslation = properties.scrollTranslation()) { |
| 786 object.getMutableForPainting().ensurePaintProperties(); | 771 auto* existingScrollNode = existingScrollTranslation->scrollNode(); |
| 787 if (auto* existingScrollNode = properties.scroll()) { | |
| 788 if (existingScrollNode->mainThreadScrollingReasons() != reasons) | 772 if (existingScrollNode->mainThreadScrollingReasons() != reasons) |
| 789 context.forceSubtreeUpdate = true; | 773 context.forceSubtreeUpdate = true; |
| 790 } | 774 } |
| 791 | 775 |
| 792 context.forceSubtreeUpdate |= properties.updateScroll( | |
| 793 context.current.scroll, scrollClip, scrollBounds, | |
| 794 userScrollableHorizontal, userScrollableVertical, reasons); | |
| 795 | |
| 796 CompositorElementId compositorElementId = | 776 CompositorElementId compositorElementId = |
| 797 createDomNodeBasedCompositorElementId(object); | 777 createDomNodeBasedCompositorElementId(object); |
| 798 TransformationMatrix matrix = TransformationMatrix().translate( | 778 TransformationMatrix matrix = TransformationMatrix().translate( |
| 799 -scrollOffset.width(), -scrollOffset.height()); | 779 -scrollOffset.width(), -scrollOffset.height()); |
| 800 context.forceSubtreeUpdate |= properties.updateScrollTranslation( | 780 context.forceSubtreeUpdate |= properties.updateScrollTranslation( |
| 801 context.current.transform, matrix, FloatPoint3D(), | 781 context.current.transform, matrix, FloatPoint3D(), |
| 802 properties.scroll(), | |
| 803 context.current.shouldFlattenInheritedTransform, | 782 context.current.shouldFlattenInheritedTransform, |
| 804 context.current.renderingContextId, CompositingReasonNone, | 783 context.current.renderingContextId, CompositingReasonNone, |
| 805 compositorElementId); | 784 compositorElementId, context.current.scroll, scrollClip, |
| 785 scrollBounds, userScrollableHorizontal, userScrollableVertical, | |
| 786 reasons); | |
| 806 } | 787 } |
| 807 } | 788 } |
| 808 | 789 |
| 809 if (!needsScrollProperties) { | 790 if (!needsScrollProperties) { |
| 810 // Ensure pre-existing properties are cleared. | 791 // Ensure pre-existing properties are cleared. |
| 811 if (auto* properties = object.getMutableForPainting().paintProperties()) { | 792 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 812 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); | 793 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); |
| 813 context.forceSubtreeUpdate |= properties->clearScroll(); | |
| 814 } | |
| 815 } | 794 } |
| 816 } | 795 } |
| 817 | 796 |
| 818 if (object.paintProperties() && object.paintProperties()->scroll()) { | 797 if (object.paintProperties() && |
| 798 object.paintProperties()->scrollTranslation()) { | |
| 819 context.current.transform = object.paintProperties()->scrollTranslation(); | 799 context.current.transform = object.paintProperties()->scrollTranslation(); |
| 820 context.current.scroll = object.paintProperties()->scroll(); | 800 context.current.scroll = context.current.transform->scrollNode(); |
| 821 context.current.shouldFlattenInheritedTransform = false; | 801 context.current.shouldFlattenInheritedTransform = false; |
| 822 } | 802 } |
| 823 } | 803 } |
| 824 | 804 |
| 825 void PaintPropertyTreeBuilder::updateOutOfFlowContext( | 805 void PaintPropertyTreeBuilder::updateOutOfFlowContext( |
| 826 const LayoutObject& object, | 806 const LayoutObject& object, |
| 827 PaintPropertyTreeBuilderContext& context) { | 807 PaintPropertyTreeBuilderContext& context) { |
| 828 if (object.isLayoutBlock()) | 808 if (object.isLayoutBlock()) |
| 829 context.paintOffsetForFloat = context.current.paintOffset; | 809 context.paintOffsetForFloat = context.current.paintOffset; |
| 830 | 810 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 updateOverflowClip(object, context); | 976 updateOverflowClip(object, context); |
| 997 updatePerspective(object, context); | 977 updatePerspective(object, context); |
| 998 updateSvgLocalToBorderBoxTransform(object, context); | 978 updateSvgLocalToBorderBoxTransform(object, context); |
| 999 updateScrollAndScrollTranslation(object, context); | 979 updateScrollAndScrollTranslation(object, context); |
| 1000 updateOutOfFlowContext(object, context); | 980 updateOutOfFlowContext(object, context); |
| 1001 | 981 |
| 1002 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 982 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 1003 } | 983 } |
| 1004 | 984 |
| 1005 } // namespace blink | 985 } // namespace blink |
| OLD | NEW |