| 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/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 if (properties && properties->svgLocalToBorderBoxTransform()) { | 633 if (properties && properties->svgLocalToBorderBoxTransform()) { |
| 634 context.current.transform = properties->svgLocalToBorderBoxTransform(); | 634 context.current.transform = properties->svgLocalToBorderBoxTransform(); |
| 635 context.current.shouldFlattenInheritedTransform = false; | 635 context.current.shouldFlattenInheritedTransform = false; |
| 636 context.current.renderingContextID = 0; | 636 context.current.renderingContextID = 0; |
| 637 } | 637 } |
| 638 // The paint offset is included in |transformToBorderBox| so SVG does not need | 638 // The paint offset is included in |transformToBorderBox| so SVG does not need |
| 639 // to handle paint offset internally. | 639 // to handle paint offset internally. |
| 640 context.current.paintOffset = LayoutPoint(); | 640 context.current.paintOffset = LayoutPoint(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 MainThreadScrollingReasons mainScrollingReasons(const LayoutObject& object) { |
| 644 MainThreadScrollingReasons reasons = 0; |
| 645 if (!object.document().settings()->threadedScrollingEnabled()) |
| 646 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; |
| 647 // Checking for descendants in the layout tree has two downsides: |
| 648 // 1) There can be more descendants in layout order than in paint order (e.g., |
| 649 // fixed position objects). |
| 650 // 2) Iterating overall all background attachment fixed objects for every |
| 651 // scroll node can be slow, though there will be none in the common case. |
| 652 const FrameView& frameView = *object.frameView(); |
| 653 if (frameView.hasBackgroundAttachmentFixedDescendants(object)) |
| 654 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; |
| 655 return reasons; |
| 656 } |
| 657 |
| 643 void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation( | 658 void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation( |
| 644 const LayoutObject& object, | 659 const LayoutObject& object, |
| 645 PaintPropertyTreeBuilderContext& context) { | 660 PaintPropertyTreeBuilderContext& context) { |
| 646 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 661 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 662 bool needsScrollProperties = false; |
| 647 if (object.hasOverflowClip()) { | 663 if (object.hasOverflowClip()) { |
| 664 auto mainThreadScrollingReasons = mainScrollingReasons(object); |
| 648 const LayoutBox& box = toLayoutBox(object); | 665 const LayoutBox& box = toLayoutBox(object); |
| 649 const PaintLayerScrollableArea* scrollableArea = box.getScrollableArea(); | 666 const auto* scrollableArea = box.getScrollableArea(); |
| 650 IntSize scrollOffset = box.scrolledContentOffset(); | 667 IntSize scrollOffset = box.scrolledContentOffset(); |
| 651 if (!scrollOffset.isZero() || scrollableArea->scrollsOverflow()) { | 668 if (mainThreadScrollingReasons || !scrollOffset.isZero() || |
| 669 scrollableArea->scrollsOverflow()) { |
| 670 needsScrollProperties = true; |
| 652 auto& properties = | 671 auto& properties = |
| 653 object.getMutableForPainting().ensurePaintProperties(); | 672 object.getMutableForPainting().ensurePaintProperties(); |
| 654 TransformationMatrix matrix = TransformationMatrix().translate( | 673 TransformationMatrix matrix = TransformationMatrix().translate( |
| 655 -scrollOffset.width(), -scrollOffset.height()); | 674 -scrollOffset.width(), -scrollOffset.height()); |
| 656 context.forceSubtreeUpdate |= properties.updateScrollTranslation( | 675 context.forceSubtreeUpdate |= properties.updateScrollTranslation( |
| 657 context.current.transform, matrix, FloatPoint3D(), | 676 context.current.transform, matrix, FloatPoint3D(), |
| 658 context.current.shouldFlattenInheritedTransform, | 677 context.current.shouldFlattenInheritedTransform, |
| 659 context.current.renderingContextID); | 678 context.current.renderingContextID); |
| 660 | 679 |
| 661 IntSize scrollClip = scrollableArea->visibleContentRect().size(); | 680 IntSize scrollClip = scrollableArea->visibleContentRect().size(); |
| 662 IntSize scrollBounds = scrollableArea->contentsSize(); | 681 IntSize scrollBounds = scrollableArea->contentsSize(); |
| 663 bool userScrollableHorizontal = | 682 bool userScrollableHorizontal = |
| 664 scrollableArea->userInputScrollable(HorizontalScrollbar); | 683 scrollableArea->userInputScrollable(HorizontalScrollbar); |
| 665 bool userScrollableVertical = | 684 bool userScrollableVertical = |
| 666 scrollableArea->userInputScrollable(VerticalScrollbar); | 685 scrollableArea->userInputScrollable(VerticalScrollbar); |
| 667 MainThreadScrollingReasons reasons = 0; | |
| 668 if (!object.document().settings()->threadedScrollingEnabled()) | |
| 669 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled; | |
| 670 // Checking for descendants in the layout tree has two downsides: | |
| 671 // 1) There can be more descendants in layout order than in paint | |
| 672 // order (e.g., fixed position objects). | |
| 673 // 2) Iterating overall all background attachment fixed objects for | |
| 674 // every scroll node can be slow, though there will be no objects | |
| 675 // in the common case. | |
| 676 const FrameView& frameView = *object.frameView(); | |
| 677 if (frameView.hasBackgroundAttachmentFixedDescendants(object)) { | |
| 678 reasons |= | |
| 679 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; | |
| 680 } | |
| 681 context.forceSubtreeUpdate |= properties.updateScroll( | 686 context.forceSubtreeUpdate |= properties.updateScroll( |
| 682 context.current.scroll, properties.scrollTranslation(), scrollClip, | 687 context.current.scroll, properties.scrollTranslation(), scrollClip, |
| 683 scrollBounds, userScrollableHorizontal, userScrollableVertical, | 688 scrollBounds, userScrollableHorizontal, userScrollableVertical, |
| 684 reasons); | 689 mainThreadScrollingReasons); |
| 685 } else { | 690 } |
| 686 // Ensure pre-existing properties are cleared when there is no | 691 } |
| 687 // scrolling. | 692 |
| 688 auto* properties = object.getMutableForPainting().paintProperties(); | 693 if (!needsScrollProperties) { |
| 689 if (properties) { | 694 // Ensure pre-existing properties are cleared. |
| 690 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); | 695 if (auto* properties = object.getMutableForPainting().paintProperties()) { |
| 691 context.forceSubtreeUpdate |= properties->clearScroll(); | 696 context.forceSubtreeUpdate |= properties->clearScrollTranslation(); |
| 692 } | 697 context.forceSubtreeUpdate |= properties->clearScroll(); |
| 693 } | 698 } |
| 694 } | 699 } |
| 695 } | 700 } |
| 696 | 701 |
| 697 if (object.paintProperties() && object.paintProperties()->scroll()) { | 702 if (object.paintProperties() && object.paintProperties()->scroll()) { |
| 698 context.current.transform = object.paintProperties()->scrollTranslation(); | 703 context.current.transform = object.paintProperties()->scrollTranslation(); |
| 699 context.current.scroll = object.paintProperties()->scroll(); | 704 context.current.scroll = object.paintProperties()->scroll(); |
| 700 context.current.shouldFlattenInheritedTransform = false; | 705 context.current.shouldFlattenInheritedTransform = false; |
| 701 } | 706 } |
| 702 } | 707 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 #endif | 910 #endif |
| 906 | 911 |
| 907 updateOverflowClip(object, context); | 912 updateOverflowClip(object, context); |
| 908 updatePerspective(object, context); | 913 updatePerspective(object, context); |
| 909 updateSvgLocalToBorderBoxTransform(object, context); | 914 updateSvgLocalToBorderBoxTransform(object, context); |
| 910 updateScrollAndScrollTranslation(object, context); | 915 updateScrollAndScrollTranslation(object, context); |
| 911 updateOutOfFlowContext(object, context); | 916 updateOutOfFlowContext(object, context); |
| 912 } | 917 } |
| 913 | 918 |
| 914 } // namespace blink | 919 } // namespace blink |
| OLD | NEW |