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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 context.containerForAbsolutePosition = nullptr; | 208 context.containerForAbsolutePosition = nullptr; |
209 context.fixedPosition = context.current; | 209 context.fixedPosition = context.current; |
210 context.fixedPosition.transform = fixedTransformNode; | 210 context.fixedPosition.transform = fixedTransformNode; |
211 context.fixedPosition.scroll = fixedScrollNode; | 211 context.fixedPosition.scroll = fixedScrollNode; |
212 | 212 |
213 std::unique_ptr<PropertyTreeState> contentsState(new PropertyTreeState( | 213 std::unique_ptr<PropertyTreeState> contentsState(new PropertyTreeState( |
214 context.current.transform, context.current.clip, context.currentEffect)); | 214 context.current.transform, context.current.clip, context.currentEffect)); |
215 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); | 215 frameView.setTotalPropertyTreeStateForContents(std::move(contentsState)); |
216 } | 216 } |
217 | 217 |
218 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( | 218 static bool calculatePaintOffsetTranslation( |
219 const LayoutObject& object, | 219 const LayoutObject& object, |
220 PaintPropertyTreeBuilderContext& context) { | 220 const LayoutPoint& paintOffset, |
| 221 IntPoint& roundedPaintOffset, |
| 222 LayoutPoint& fractionalPaintOffset) { |
221 bool usesPaintOffsetTranslation = false; | 223 bool usesPaintOffsetTranslation = false; |
222 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 224 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
223 object.isLayoutView()) { | 225 object.isLayoutView()) { |
224 // Root layer scrolling always creates a translation node for LayoutView to | 226 // Root layer scrolling always creates a translation node for LayoutView to |
225 // ensure fixed and absolute contexts use the correct transform space. | 227 // ensure fixed and absolute contexts use the correct transform space. |
226 usesPaintOffsetTranslation = true; | 228 usesPaintOffsetTranslation = true; |
227 } else if (object.isBoxModelObject() && | 229 } else if (object.isBoxModelObject() && paintOffset != LayoutPoint()) { |
228 context.current.paintOffset != LayoutPoint()) { | |
229 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | 230 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
230 if (layer && | 231 if (layer && |
231 layer->paintsWithTransform(GlobalPaintFlattenCompositingLayers)) | 232 layer->paintsWithTransform(GlobalPaintFlattenCompositingLayers)) |
232 usesPaintOffsetTranslation = true; | 233 usesPaintOffsetTranslation = true; |
233 } | 234 } |
234 | 235 |
235 // We should use the same subpixel paint offset values for snapping | 236 // We should use the same subpixel paint offset values for snapping |
236 // regardless of whether a transform is present. If there is a transform | 237 // regardless of whether a transform is present. If there is a transform |
237 // we round the paint offset but keep around the residual fractional | 238 // we round the paint offset but keep around the residual fractional |
238 // component for the transformed content to paint with. In spv1 this was | 239 // component for the transformed content to paint with. In spv1 this was |
239 // called "subpixel accumulation". For more information, see | 240 // called "subpixel accumulation". For more information, see |
240 // PaintLayer::subpixelAccumulation() and | 241 // PaintLayer::subpixelAccumulation() and |
241 // PaintLayerPainter::paintFragmentByApplyingTransform. | 242 // PaintLayerPainter::paintFragmentByApplyingTransform. |
242 IntPoint roundedPaintOffset = roundedIntPoint(context.current.paintOffset); | 243 if (usesPaintOffsetTranslation) { |
243 LayoutPoint fractionalPaintOffset = | 244 roundedPaintOffset = roundedIntPoint(paintOffset); |
244 LayoutPoint(context.current.paintOffset - roundedPaintOffset); | 245 fractionalPaintOffset = LayoutPoint(paintOffset - roundedPaintOffset); |
| 246 } |
245 | 247 |
| 248 return usesPaintOffsetTranslation; |
| 249 } |
| 250 |
| 251 void PaintPropertyTreeBuilder::updatePaintOffsetTranslation( |
| 252 const LayoutObject& object, |
| 253 PaintPropertyTreeBuilderContext& context) { |
| 254 IntPoint roundedPaintOffset; |
| 255 LayoutPoint fractionalPaintOffset; |
| 256 bool usesPaintOffsetTranslation = calculatePaintOffsetTranslation( |
| 257 object, context.current.paintOffset, roundedPaintOffset, |
| 258 fractionalPaintOffset); |
246 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 259 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
247 if (usesPaintOffsetTranslation) { | 260 if (usesPaintOffsetTranslation) { |
248 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 261 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
249 context.forceSubtreeUpdate |= properties.updatePaintOffsetTranslation( | 262 context.forceSubtreeUpdate |= properties.updatePaintOffsetTranslation( |
250 context.current.transform, | 263 context.current.transform, |
251 TransformationMatrix().translate(roundedPaintOffset.x(), | 264 TransformationMatrix().translate(roundedPaintOffset.x(), |
252 roundedPaintOffset.y()), | 265 roundedPaintOffset.y()), |
253 FloatPoint3D(), context.current.shouldFlattenInheritedTransform, | 266 FloatPoint3D(), context.current.shouldFlattenInheritedTransform, |
254 context.current.renderingContextId); | 267 context.current.renderingContextId); |
255 } else { | 268 } else { |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 return; | 869 return; |
857 } | 870 } |
858 } | 871 } |
859 | 872 |
860 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 873 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
861 if (auto* properties = object.getMutableForPainting().paintProperties()) | 874 if (auto* properties = object.getMutableForPainting().paintProperties()) |
862 context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition(); | 875 context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition(); |
863 } | 876 } |
864 } | 877 } |
865 | 878 |
866 void PaintPropertyTreeBuilder::updateContextForBoxPosition( | 879 void PaintPropertyTreeBuilder::updateContextForLocation( |
867 const LayoutObject& object, | 880 const LayoutObject& object, |
868 PaintPropertyTreeBuilderContext& context) { | 881 PaintPropertyTreeBuilderContext& context) { |
869 if (!object.isBoxModelObject()) | 882 if (!object.isBoxModelObject()) |
870 return; | 883 return; |
871 | 884 |
872 const LayoutBoxModelObject& boxModelObject = toLayoutBoxModelObject(object); | 885 const LayoutBoxModelObject& boxModelObject = toLayoutBoxModelObject(object); |
873 | 886 |
874 if (boxModelObject.isFloating()) | 887 if (boxModelObject.isFloating()) |
875 context.current.paintOffset = context.paintOffsetForFloat; | 888 context.current.paintOffset = context.paintOffsetForFloat; |
876 | 889 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 // but their location have the row's location baked-in. | 936 // but their location have the row's location baked-in. |
924 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). | 937 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). |
925 if (boxModelObject.isTableCell()) { | 938 if (boxModelObject.isTableCell()) { |
926 LayoutObject* parentRow = boxModelObject.parent(); | 939 LayoutObject* parentRow = boxModelObject.parent(); |
927 DCHECK(parentRow && parentRow->isTableRow()); | 940 DCHECK(parentRow && parentRow->isTableRow()); |
928 context.current.paintOffset.moveBy( | 941 context.current.paintOffset.moveBy( |
929 -toLayoutBox(parentRow)->physicalLocation()); | 942 -toLayoutBox(parentRow)->physicalLocation()); |
930 } | 943 } |
931 } | 944 } |
932 | 945 |
| 946 IntPoint roundedPaintOffset; |
| 947 LayoutPoint paintOffsetAfterTranslation = context.current.paintOffset; |
| 948 if (calculatePaintOffsetTranslation( |
| 949 toLayoutBoxModelObject(object), context.current.paintOffset, |
| 950 roundedPaintOffset, paintOffsetAfterTranslation)) { |
| 951 const auto* properties = object.paintProperties(); |
| 952 if (!properties || !properties->paintOffsetTranslation() || |
| 953 properties->paintOffsetTranslation()->matrix().to2DTranslation() != |
| 954 FloatSize(roundedPaintOffset.x(), roundedPaintOffset.y())) |
| 955 object.getMutableForPainting().setNeedsPaintPropertyUpdate(); |
| 956 } |
| 957 |
933 // Many paint properties depend on paint offset so we force an update of | 958 // Many paint properties depend on paint offset so we force an update of |
934 // the entire subtree on paint offset changes. | 959 // the entire subtree on paint offset changes. |
935 if (object.paintOffset() != context.current.paintOffset) | 960 if (object.paintOffset() != paintOffsetAfterTranslation) |
936 context.forceSubtreeUpdate = true; | 961 context.forceSubtreeUpdate = true; |
937 } | 962 } |
938 | 963 |
939 void PaintPropertyTreeBuilder::updatePropertiesForSelf( | 964 void PaintPropertyTreeBuilder::updatePropertiesForSelf( |
940 const LayoutObject& object, | 965 const LayoutObject& object, |
941 PaintPropertyTreeBuilderContext& context) { | 966 PaintPropertyTreeBuilderContext& context) { |
| 967 updateContextForLocation(object, context); |
| 968 |
942 #if DCHECK_IS_ON() | 969 #if DCHECK_IS_ON() |
943 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); | 970 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); |
944 #endif | 971 #endif |
945 | 972 |
946 if (object.isBoxModelObject() || object.isSVG()) { | 973 if (object.isBoxModelObject() || object.isSVG()) { |
947 updatePaintOffsetTranslation(object, context); | 974 updatePaintOffsetTranslation(object, context); |
948 updateTransform(object, context); | 975 updateTransform(object, context); |
949 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 976 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
950 updateEffect(object, context); | 977 updateEffect(object, context); |
951 updateCssClip(object, context); | 978 updateCssClip(object, context); |
(...skipping 25 matching lines...) Expand all Loading... |
977 updateOverflowClip(object, context); | 1004 updateOverflowClip(object, context); |
978 updatePerspective(object, context); | 1005 updatePerspective(object, context); |
979 updateSvgLocalToBorderBoxTransform(object, context); | 1006 updateSvgLocalToBorderBoxTransform(object, context); |
980 updateScrollAndScrollTranslation(object, context); | 1007 updateScrollAndScrollTranslation(object, context); |
981 updateOutOfFlowContext(object, context); | 1008 updateOutOfFlowContext(object, context); |
982 | 1009 |
983 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1010 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
984 } | 1011 } |
985 | 1012 |
986 } // namespace blink | 1013 } // namespace blink |
OLD | NEW |