| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 context.current.scroll = context.absolutePosition.scroll = | 63 context.current.scroll = context.absolutePosition.scroll = |
| 64 context.fixedPosition.scroll = rootScrollNode(); | 64 context.fixedPosition.scroll = rootScrollNode(); |
| 65 | 65 |
| 66 // Ensure scroll tree properties are reset. They will be rebuilt during the | 66 // Ensure scroll tree properties are reset. They will be rebuilt during the |
| 67 // tree walk. | 67 // tree walk. |
| 68 rootScrollNode()->clearMainThreadScrollingReasons(); | 68 rootScrollNode()->clearMainThreadScrollingReasons(); |
| 69 | 69 |
| 70 return context; | 70 return context; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void createOrUpdateFrameViewPreTranslation( | 73 const TransformPaintPropertyNode* createOrUpdateFrameViewPreTranslation( |
| 74 FrameView& frameView, | 74 FrameView& frameView, |
| 75 PassRefPtr<const TransformPaintPropertyNode> parent, | 75 PassRefPtr<const TransformPaintPropertyNode> parent, |
| 76 const TransformationMatrix& matrix, | 76 const TransformationMatrix& matrix, |
| 77 const FloatPoint3D& origin) { | 77 const FloatPoint3D& origin) { |
| 78 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 78 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 79 if (TransformPaintPropertyNode* existingPreTranslation = | 79 if (TransformPaintPropertyNode* existingPreTranslation = |
| 80 frameView.preTranslation()) | 80 frameView.preTranslation()) |
| 81 existingPreTranslation->update(std::move(parent), matrix, origin); | 81 existingPreTranslation->update(std::move(parent), matrix, origin); |
| 82 else | 82 else |
| 83 frameView.setPreTranslation( | 83 frameView.setPreTranslation( |
| 84 TransformPaintPropertyNode::create(std::move(parent), matrix, origin)); | 84 TransformPaintPropertyNode::create(std::move(parent), matrix, origin)); |
| 85 return frameView.preTranslation(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void createOrUpdateFrameViewContentClip( | 88 const ClipPaintPropertyNode* createOrUpdateFrameViewContentClip( |
| 88 FrameView& frameView, | 89 FrameView& frameView, |
| 89 PassRefPtr<const ClipPaintPropertyNode> parent, | 90 PassRefPtr<const ClipPaintPropertyNode> parent, |
| 90 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 91 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 91 const FloatRoundedRect& clipRect) { | 92 const FloatRoundedRect& clipRect) { |
| 92 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 93 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 93 if (ClipPaintPropertyNode* existingContentClip = frameView.contentClip()) | 94 if (ClipPaintPropertyNode* existingContentClip = frameView.contentClip()) |
| 94 existingContentClip->update(std::move(parent), | 95 existingContentClip->update(std::move(parent), |
| 95 std::move(localTransformSpace), clipRect); | 96 std::move(localTransformSpace), clipRect); |
| 96 else | 97 else |
| 97 frameView.setContentClip(ClipPaintPropertyNode::create( | 98 frameView.setContentClip(ClipPaintPropertyNode::create( |
| 98 std::move(parent), std::move(localTransformSpace), clipRect)); | 99 std::move(parent), std::move(localTransformSpace), clipRect)); |
| 100 return frameView.contentClip(); |
| 99 } | 101 } |
| 100 | 102 |
| 101 void createOrUpdateFrameViewScrollTranslation( | 103 const TransformPaintPropertyNode* createOrUpdateFrameViewScrollTranslation( |
| 102 FrameView& frameView, | 104 FrameView& frameView, |
| 103 PassRefPtr<const TransformPaintPropertyNode> parent, | 105 PassRefPtr<const TransformPaintPropertyNode> parent, |
| 104 const TransformationMatrix& matrix, | 106 const TransformationMatrix& matrix, |
| 105 const FloatPoint3D& origin) { | 107 const FloatPoint3D& origin) { |
| 106 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 108 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 107 if (TransformPaintPropertyNode* existingScrollTranslation = | 109 if (TransformPaintPropertyNode* existingScrollTranslation = |
| 108 frameView.scrollTranslation()) | 110 frameView.scrollTranslation()) |
| 109 existingScrollTranslation->update(std::move(parent), matrix, origin); | 111 existingScrollTranslation->update(std::move(parent), matrix, origin); |
| 110 else | 112 else |
| 111 frameView.setScrollTranslation( | 113 frameView.setScrollTranslation( |
| 112 TransformPaintPropertyNode::create(std::move(parent), matrix, origin)); | 114 TransformPaintPropertyNode::create(std::move(parent), matrix, origin)); |
| 115 return frameView.scrollTranslation(); |
| 113 } | 116 } |
| 114 | 117 |
| 115 void createOrUpdateFrameViewScroll( | 118 ScrollPaintPropertyNode* createOrUpdateFrameViewScroll( |
| 116 FrameView& frameView, | 119 FrameView& frameView, |
| 117 PassRefPtr<ScrollPaintPropertyNode> parent, | 120 PassRefPtr<ScrollPaintPropertyNode> parent, |
| 118 PassRefPtr<const TransformPaintPropertyNode> scrollOffset, | 121 PassRefPtr<const TransformPaintPropertyNode> scrollOffset, |
| 119 const IntSize& clip, | 122 const IntSize& clip, |
| 120 const IntSize& bounds, | 123 const IntSize& bounds, |
| 121 bool userScrollableHorizontal, | 124 bool userScrollableHorizontal, |
| 122 bool userScrollableVertical) { | 125 bool userScrollableVertical) { |
| 123 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 126 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 124 if (ScrollPaintPropertyNode* existingScroll = frameView.scroll()) | 127 if (ScrollPaintPropertyNode* existingScroll = frameView.scroll()) |
| 125 existingScroll->update(std::move(parent), std::move(scrollOffset), clip, | 128 existingScroll->update(std::move(parent), std::move(scrollOffset), clip, |
| 126 bounds, userScrollableHorizontal, | 129 bounds, userScrollableHorizontal, |
| 127 userScrollableVertical); | 130 userScrollableVertical); |
| 128 else | 131 else |
| 129 frameView.setScroll(ScrollPaintPropertyNode::create( | 132 frameView.setScroll(ScrollPaintPropertyNode::create( |
| 130 std::move(parent), std::move(scrollOffset), clip, bounds, | 133 std::move(parent), std::move(scrollOffset), clip, bounds, |
| 131 userScrollableHorizontal, userScrollableVertical)); | 134 userScrollableHorizontal, userScrollableVertical)); |
| 135 return frameView.scroll(); |
| 132 } | 136 } |
| 133 | 137 |
| 134 void PaintPropertyTreeBuilder::buildTreeNodes( | 138 void PaintPropertyTreeBuilder::buildTreeNodes( |
| 135 FrameView& frameView, | 139 FrameView& frameView, |
| 136 PaintPropertyTreeBuilderContext& context) { | 140 PaintPropertyTreeBuilderContext& context) { |
| 137 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 141 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 138 LayoutView* layoutView = frameView.layoutView(); | 142 LayoutView* layoutView = frameView.layoutView(); |
| 139 if (!layoutView) | 143 if (!layoutView) |
| 140 return; | 144 return; |
| 141 | 145 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 155 context.absolutePosition = context.current; | 159 context.absolutePosition = context.current; |
| 156 context.containerForAbsolutePosition = | 160 context.containerForAbsolutePosition = |
| 157 nullptr; // This will get set in updateOutOfFlowContext(). | 161 nullptr; // This will get set in updateOutOfFlowContext(). |
| 158 context.fixedPosition = context.current; | 162 context.fixedPosition = context.current; |
| 159 return; | 163 return; |
| 160 } | 164 } |
| 161 | 165 |
| 162 TransformationMatrix frameTranslate; | 166 TransformationMatrix frameTranslate; |
| 163 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), | 167 frameTranslate.translate(frameView.x() + context.current.paintOffset.x(), |
| 164 frameView.y() + context.current.paintOffset.y()); | 168 frameView.y() + context.current.paintOffset.y()); |
| 165 createOrUpdateFrameViewPreTranslation(frameView, context.current.transform, | 169 context.current.transform = createOrUpdateFrameViewPreTranslation( |
| 166 frameTranslate, FloatPoint3D()); | 170 frameView, context.current.transform, frameTranslate, FloatPoint3D()); |
| 167 | 171 |
| 168 FloatRoundedRect contentClip( | 172 FloatRoundedRect contentClip( |
| 169 IntRect(IntPoint(), frameView.visibleContentSize())); | 173 IntRect(IntPoint(), frameView.visibleContentSize())); |
| 170 createOrUpdateFrameViewContentClip(frameView, context.current.clip, | 174 context.current.clip = createOrUpdateFrameViewContentClip( |
| 171 frameView.preTranslation(), contentClip); | 175 frameView, context.current.clip, frameView.preTranslation(), contentClip); |
| 176 |
| 177 // Record the fixed properties before any scrolling occurs. |
| 178 const auto* fixedTransformNode = context.current.transform; |
| 179 auto* fixedScrollNode = context.current.scroll; |
| 172 | 180 |
| 173 ScrollOffset scrollOffset = frameView.scrollOffset(); | 181 ScrollOffset scrollOffset = frameView.scrollOffset(); |
| 174 if (frameView.isScrollable() || !scrollOffset.isZero()) { | 182 if (frameView.isScrollable() || !scrollOffset.isZero()) { |
| 175 TransformationMatrix frameScroll; | 183 TransformationMatrix frameScroll; |
| 176 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); | 184 frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); |
| 177 createOrUpdateFrameViewScrollTranslation( | 185 context.current.transform = createOrUpdateFrameViewScrollTranslation( |
| 178 frameView, frameView.preTranslation(), frameScroll, FloatPoint3D()); | 186 frameView, frameView.preTranslation(), frameScroll, FloatPoint3D()); |
| 179 | 187 |
| 180 IntSize scrollClip = frameView.visibleContentSize(); | 188 IntSize scrollClip = frameView.visibleContentSize(); |
| 181 IntSize scrollBounds = frameView.contentsSize(); | 189 IntSize scrollBounds = frameView.contentsSize(); |
| 182 bool userScrollableHorizontal = | 190 bool userScrollableHorizontal = |
| 183 frameView.userInputScrollable(HorizontalScrollbar); | 191 frameView.userInputScrollable(HorizontalScrollbar); |
| 184 bool userScrollableVertical = | 192 bool userScrollableVertical = |
| 185 frameView.userInputScrollable(VerticalScrollbar); | 193 frameView.userInputScrollable(VerticalScrollbar); |
| 186 createOrUpdateFrameViewScroll(frameView, context.current.scroll, | 194 context.current.scroll = createOrUpdateFrameViewScroll( |
| 187 frameView.scrollTranslation(), scrollClip, | 195 frameView, context.current.scroll, frameView.scrollTranslation(), |
| 188 scrollBounds, userScrollableHorizontal, | 196 scrollClip, scrollBounds, userScrollableHorizontal, |
| 189 userScrollableVertical); | 197 userScrollableVertical); |
| 190 } else { | 198 } else { |
| 199 // Ensure pre-existing properties are cleared when there is no scrolling. |
| 191 frameView.setScrollTranslation(nullptr); | 200 frameView.setScrollTranslation(nullptr); |
| 192 frameView.setScroll(nullptr); | 201 frameView.setScroll(nullptr); |
| 193 } | 202 } |
| 194 | 203 |
| 195 // Initialize the context for current, absolute and fixed position cases. | 204 // Initialize the context for current, absolute and fixed position cases. |
| 196 // They are the same, except that scroll translation does not apply to | 205 // They are the same, except that scroll translation does not apply to |
| 197 // fixed position descendants. | 206 // fixed position descendants. |
| 198 ScrollPaintPropertyNode* initialScroll = context.current.scroll; | |
| 199 context.current.transform = frameView.scrollTranslation() | |
| 200 ? frameView.scrollTranslation() | |
| 201 : frameView.preTranslation(); | |
| 202 context.current.paintOffset = LayoutPoint(); | 207 context.current.paintOffset = LayoutPoint(); |
| 203 context.current.clip = frameView.contentClip(); | |
| 204 context.current.scroll = | |
| 205 frameView.scroll() ? frameView.scroll() : initialScroll; | |
| 206 context.current.renderingContextID = 0; | 208 context.current.renderingContextID = 0; |
| 207 context.current.shouldFlattenInheritedTransform = true; | 209 context.current.shouldFlattenInheritedTransform = true; |
| 208 context.absolutePosition = context.current; | 210 context.absolutePosition = context.current; |
| 209 context.containerForAbsolutePosition = nullptr; | 211 context.containerForAbsolutePosition = nullptr; |
| 210 context.fixedPosition = context.current; | 212 context.fixedPosition = context.current; |
| 211 context.fixedPosition.transform = frameView.preTranslation(); | 213 context.fixedPosition.transform = fixedTransformNode; |
| 212 context.fixedPosition.scroll = initialScroll; | 214 context.fixedPosition.scroll = fixedScrollNode; |
| 213 | 215 |
| 214 std::unique_ptr<PropertyTreeState> contentsState( | 216 std::unique_ptr<PropertyTreeState> contentsState( |
| 215 new PropertyTreeState(context.current.transform, context.current.clip, | 217 new PropertyTreeState(context.current.transform, context.current.clip, |
| 216 context.currentEffect, context.current.scroll)); | 218 context.currentEffect, context.current.scroll)); |
| 217 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); | 219 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); |
| 218 } | 220 } |
| 219 | 221 |
| 220 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( | 222 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( |
| 221 const LayoutObject& object, | 223 const LayoutObject& object, |
| 222 PaintPropertyTreeBuilderContext& context) { | 224 PaintPropertyTreeBuilderContext& context) { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 return; | 814 return; |
| 813 | 815 |
| 814 updateOverflowClip(object, context); | 816 updateOverflowClip(object, context); |
| 815 updatePerspective(object, context); | 817 updatePerspective(object, context); |
| 816 updateSvgLocalToBorderBoxTransform(object, context); | 818 updateSvgLocalToBorderBoxTransform(object, context); |
| 817 updateScrollAndScrollTranslation(object, context); | 819 updateScrollAndScrollTranslation(object, context); |
| 818 updateOutOfFlowContext(object, context); | 820 updateOutOfFlowContext(object, context); |
| 819 } | 821 } |
| 820 | 822 |
| 821 } // namespace blink | 823 } // namespace blink |
| OLD | NEW |