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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 (object.IsLayoutView() || | 252 (object.IsLayoutView() || |
253 context.current.paint_offset != LayoutPoint())) { | 253 context.current.paint_offset != LayoutPoint())) { |
254 auto& properties = *object.GetMutableForPainting().PaintProperties(); | 254 auto& properties = *object.GetMutableForPainting().PaintProperties(); |
255 // We should use the same subpixel paint offset values for snapping | 255 // We should use the same subpixel paint offset values for snapping |
256 // regardless of whether a transform is present. If there is a transform | 256 // regardless of whether a transform is present. If there is a transform |
257 // we round the paint offset but keep around the residual fractional | 257 // we round the paint offset but keep around the residual fractional |
258 // component for the transformed content to paint with. In spv1 this was | 258 // component for the transformed content to paint with. In spv1 this was |
259 // called "subpixel accumulation". For more information, see | 259 // called "subpixel accumulation". For more information, see |
260 // PaintLayer::subpixelAccumulation() and | 260 // PaintLayer::subpixelAccumulation() and |
261 // PaintLayerPainter::paintFragmentByApplyingTransform. | 261 // PaintLayerPainter::paintFragmentByApplyingTransform. |
262 IntPoint rounded_paint_offset = | 262 LayoutPoint used_paint_offset(context.current.paint_offset.X().Round(), |
263 RoundedIntPoint(context.current.paint_offset); | 263 context.current.paint_offset.Y().Round()); |
264 LayoutPoint fractional_paint_offset = | 264 LayoutPoint remainder_paint_offset = |
265 LayoutPoint(context.current.paint_offset - rounded_paint_offset); | 265 LayoutPoint(context.current.paint_offset - used_paint_offset); |
| 266 |
| 267 if (remainder_paint_offset != LayoutPoint()) { |
| 268 // However, if the object has a non-translation transform, we can't pass |
| 269 // subpixel offsets through the transform to descendants. |
| 270 TransformationMatrix matrix; |
| 271 object.StyleRef().ApplyTransform( |
| 272 matrix, LayoutSize(), ComputedStyle::kExcludeTransformOrigin, |
| 273 ComputedStyle::kIncludeMotionPath, |
| 274 ComputedStyle::kIncludeIndependentTransformProperties); |
| 275 if (!matrix.IsIdentityOrTranslation()) { |
| 276 remainder_paint_offset = LayoutPoint(); |
| 277 used_paint_offset = context.current.paint_offset; |
| 278 } |
| 279 } |
266 | 280 |
267 context.force_subtree_update |= properties.UpdatePaintOffsetTranslation( | 281 context.force_subtree_update |= properties.UpdatePaintOffsetTranslation( |
268 context.current.transform, | 282 context.current.transform, |
269 TransformationMatrix().Translate(rounded_paint_offset.X(), | 283 TransformationMatrix().Translate(used_paint_offset.X().ToDouble(), |
270 rounded_paint_offset.Y()), | 284 used_paint_offset.Y().ToDouble()), |
271 FloatPoint3D(), context.current.should_flatten_inherited_transform, | 285 FloatPoint3D(), context.current.should_flatten_inherited_transform, |
272 context.current.rendering_context_id); | 286 context.current.rendering_context_id); |
273 | 287 |
274 context.current.transform = properties.PaintOffsetTranslation(); | 288 context.current.transform = properties.PaintOffsetTranslation(); |
275 context.current.paint_offset = fractional_paint_offset; | 289 context.current.paint_offset = remainder_paint_offset; |
276 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 290 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
277 object.IsLayoutView()) { | 291 object.IsLayoutView()) { |
278 context.absolute_position.transform = properties.PaintOffsetTranslation(); | 292 context.absolute_position.transform = properties.PaintOffsetTranslation(); |
279 context.fixed_position.transform = properties.PaintOffsetTranslation(); | 293 context.fixed_position.transform = properties.PaintOffsetTranslation(); |
280 context.absolute_position.paint_offset = LayoutPoint(); | 294 context.absolute_position.paint_offset = remainder_paint_offset; |
281 context.fixed_position.paint_offset = LayoutPoint(); | 295 context.fixed_position.paint_offset = remainder_paint_offset; |
282 } | 296 } |
283 } else { | 297 } else { |
284 if (auto* properties = object.GetMutableForPainting().PaintProperties()) | 298 if (auto* properties = object.GetMutableForPainting().PaintProperties()) |
285 context.force_subtree_update |= properties->ClearPaintOffsetTranslation(); | 299 context.force_subtree_update |= properties->ClearPaintOffsetTranslation(); |
286 } | 300 } |
287 } | 301 } |
288 | 302 |
289 static bool NeedsTransformForNonRootSVG(const LayoutObject& object) { | 303 static bool NeedsTransformForNonRootSVG(const LayoutObject& object) { |
290 // TODO(pdr): Check for the presence of a transform instead of the value. | 304 // TODO(pdr): Check for the presence of a transform instead of the value. |
291 // Checking for an identity matrix will cause the property tree structure | 305 // Checking for an identity matrix will cause the property tree structure |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 UpdateOverflowClip(object, context); | 1248 UpdateOverflowClip(object, context); |
1235 UpdatePerspective(object, context); | 1249 UpdatePerspective(object, context); |
1236 UpdateSvgLocalToBorderBoxTransform(object, context); | 1250 UpdateSvgLocalToBorderBoxTransform(object, context); |
1237 UpdateScrollAndScrollTranslation(object, context); | 1251 UpdateScrollAndScrollTranslation(object, context); |
1238 UpdateOutOfFlowContext(object, context); | 1252 UpdateOutOfFlowContext(object, context); |
1239 | 1253 |
1240 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); | 1254 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); |
1241 } | 1255 } |
1242 | 1256 |
1243 } // namespace blink | 1257 } // namespace blink |
OLD | NEW |