| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/DOMNodeIds.h" | 8 #include "core/dom/DOMNodeIds.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 (object.IsLayoutView() || | 258 (object.IsLayoutView() || |
| 259 context.current.paint_offset != LayoutPoint())) { | 259 context.current.paint_offset != LayoutPoint())) { |
| 260 auto& properties = *object.GetMutableForPainting().PaintProperties(); | 260 auto& properties = *object.GetMutableForPainting().PaintProperties(); |
| 261 // We should use the same subpixel paint offset values for snapping | 261 // We should use the same subpixel paint offset values for snapping |
| 262 // regardless of whether a transform is present. If there is a transform | 262 // regardless of whether a transform is present. If there is a transform |
| 263 // we round the paint offset but keep around the residual fractional | 263 // we round the paint offset but keep around the residual fractional |
| 264 // component for the transformed content to paint with. In spv1 this was | 264 // component for the transformed content to paint with. In spv1 this was |
| 265 // called "subpixel accumulation". For more information, see | 265 // called "subpixel accumulation". For more information, see |
| 266 // PaintLayer::subpixelAccumulation() and | 266 // PaintLayer::subpixelAccumulation() and |
| 267 // PaintLayerPainter::paintFragmentByApplyingTransform. | 267 // PaintLayerPainter::paintFragmentByApplyingTransform. |
| 268 IntPoint rounded_paint_offset = | 268 LayoutPoint used_paint_offset(context.current.paint_offset.X().Round(), |
| 269 RoundedIntPoint(context.current.paint_offset); | 269 context.current.paint_offset.Y().Round()); |
| 270 LayoutPoint fractional_paint_offset = | 270 LayoutPoint remainder_paint_offset = |
| 271 LayoutPoint(context.current.paint_offset - rounded_paint_offset); | 271 LayoutPoint(context.current.paint_offset - used_paint_offset); |
| 272 |
| 273 if (remainder_paint_offset != LayoutPoint()) { |
| 274 // However, if the object has a non-translation transform, we can't pass |
| 275 // subpixel offsets through the transform to descendants. |
| 276 TransformationMatrix matrix; |
| 277 object.StyleRef().ApplyTransform( |
| 278 matrix, LayoutSize(), ComputedStyle::kExcludeTransformOrigin, |
| 279 ComputedStyle::kIncludeMotionPath, |
| 280 ComputedStyle::kIncludeIndependentTransformProperties); |
| 281 if (!matrix.IsIdentityOrTranslation()) { |
| 282 remainder_paint_offset = LayoutPoint(); |
| 283 used_paint_offset = context.current.paint_offset; |
| 284 } |
| 285 } |
| 272 | 286 |
| 273 force_subtree_update |= properties.UpdatePaintOffsetTranslation( | 287 force_subtree_update |= properties.UpdatePaintOffsetTranslation( |
| 274 context.current.transform, | 288 context.current.transform, |
| 275 TransformationMatrix().Translate(rounded_paint_offset.X(), | 289 TransformationMatrix().Translate(used_paint_offset.X().ToDouble(), |
| 276 rounded_paint_offset.Y()), | 290 used_paint_offset.Y().ToDouble()), |
| 277 FloatPoint3D(), context.current.should_flatten_inherited_transform, | 291 FloatPoint3D(), context.current.should_flatten_inherited_transform, |
| 278 context.current.rendering_context_id); | 292 context.current.rendering_context_id); |
| 279 | 293 |
| 280 context.current.transform = properties.PaintOffsetTranslation(); | 294 context.current.transform = properties.PaintOffsetTranslation(); |
| 281 context.current.paint_offset = fractional_paint_offset; | 295 context.current.paint_offset = remainder_paint_offset; |
| 282 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 296 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 283 object.IsLayoutView()) { | 297 object.IsLayoutView()) { |
| 284 context.absolute_position.transform = properties.PaintOffsetTranslation(); | 298 context.absolute_position.transform = properties.PaintOffsetTranslation(); |
| 285 context.fixed_position.transform = properties.PaintOffsetTranslation(); | 299 context.fixed_position.transform = properties.PaintOffsetTranslation(); |
| 286 context.absolute_position.paint_offset = LayoutPoint(); | 300 context.absolute_position.paint_offset = remainder_paint_offset; |
| 287 context.fixed_position.paint_offset = LayoutPoint(); | 301 context.fixed_position.paint_offset = remainder_paint_offset; |
| 288 } | 302 } |
| 289 } else { | 303 } else { |
| 290 if (auto* properties = object.GetMutableForPainting().PaintProperties()) | 304 if (auto* properties = object.GetMutableForPainting().PaintProperties()) |
| 291 force_subtree_update |= properties->ClearPaintOffsetTranslation(); | 305 force_subtree_update |= properties->ClearPaintOffsetTranslation(); |
| 292 } | 306 } |
| 293 } | 307 } |
| 294 | 308 |
| 295 static bool NeedsTransformForNonRootSVG(const LayoutObject& object) { | 309 static bool NeedsTransformForNonRootSVG(const LayoutObject& object) { |
| 296 // TODO(pdr): Check for the presence of a transform instead of the value. | 310 // TODO(pdr): Check for the presence of a transform instead of the value. |
| 297 // Checking for an identity matrix will cause the property tree structure | 311 // Checking for an identity matrix will cause the property tree structure |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 context.force_subtree_update); | 1284 context.force_subtree_update); |
| 1271 | 1285 |
| 1272 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); | 1286 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); |
| 1273 } | 1287 } |
| 1274 | 1288 |
| 1275 if (object.CanContainAbsolutePositionObjects()) | 1289 if (object.CanContainAbsolutePositionObjects()) |
| 1276 context.container_for_absolute_position = &object; | 1290 context.container_for_absolute_position = &object; |
| 1277 } | 1291 } |
| 1278 | 1292 |
| 1279 } // namespace blink | 1293 } // namespace blink |
| OLD | NEW |