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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), | 259 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), |
260 style.transformOriginZ()); | 260 style.transformOriginZ()); |
261 } | 261 } |
262 | 262 |
263 // SVG does not use the general transform update of |updateTransform|, instead | 263 // SVG does not use the general transform update of |updateTransform|, instead |
264 // creating a transform node for SVG-specific transforms without 3D. | 264 // creating a transform node for SVG-specific transforms without 3D. |
265 void PaintPropertyTreeBuilder::updateTransformForNonRootSVG( | 265 void PaintPropertyTreeBuilder::updateTransformForNonRootSVG( |
266 const LayoutObject& object, | 266 const LayoutObject& object, |
267 PaintPropertyTreeBuilderContext& context) { | 267 PaintPropertyTreeBuilderContext& context) { |
268 DCHECK(object.isSVG() && !object.isSVGRoot()); | 268 DCHECK(object.isSVG() && !object.isSVGRoot()); |
269 // SVG does not use paint offset internally. | 269 // SVG (other than SVGForeignObject) does not use paint offset internally. |
270 DCHECK(context.current.paintOffset == LayoutPoint()); | 270 DCHECK(object.isSVGForeignObject() || |
| 271 context.current.paintOffset == LayoutPoint()); |
271 | 272 |
272 if (object.needsPaintPropertyUpdate()) { | 273 if (object.needsPaintPropertyUpdate()) { |
273 const AffineTransform& transform = object.localToSVGParentTransform(); | 274 // TODO(pdr): Refactor this so all non-root SVG objects use the same |
| 275 // transform function. |
| 276 const AffineTransform& transform = object.isSVGForeignObject() |
| 277 ? object.localSVGTransform() |
| 278 : object.localToSVGParentTransform(); |
274 // TODO(pdr): Check for the presence of a transform instead of the value. | 279 // TODO(pdr): Check for the presence of a transform instead of the value. |
275 // Checking for an identity matrix will cause the property tree structure | 280 // Checking for an identity matrix will cause the property tree structure |
276 // to change during animations if the animation passes through the | 281 // to change during animations if the animation passes through the |
277 // identity matrix. | 282 // identity matrix. |
278 if (!transform.isIdentity()) { | 283 if (!transform.isIdentity()) { |
279 // The origin is included in the local transform, so leave origin empty. | 284 // The origin is included in the local transform, so leave origin empty. |
280 object.getMutableForPainting().ensurePaintProperties().updateTransform( | 285 object.getMutableForPainting().ensurePaintProperties().updateTransform( |
281 context.current.transform, TransformationMatrix(transform), | 286 context.current.transform, TransformationMatrix(transform), |
282 FloatPoint3D()); | 287 FloatPoint3D()); |
283 } else { | 288 } else { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 overrideContaineringBlockContextFromRealContainingBlock( | 838 overrideContaineringBlockContextFromRealContainingBlock( |
834 toLayoutBlock(*boxModelObject.container()), context.current); | 839 toLayoutBlock(*boxModelObject.container()), context.current); |
835 } else { | 840 } else { |
836 context.current = context.fixedPosition; | 841 context.current = context.fixedPosition; |
837 } | 842 } |
838 break; | 843 break; |
839 default: | 844 default: |
840 ASSERT_NOT_REACHED(); | 845 ASSERT_NOT_REACHED(); |
841 } | 846 } |
842 | 847 |
| 848 // SVGForeignObject needs paint offset because its viewport offset is baked |
| 849 // into its location(), while its localSVGTransform() doesn't contain the |
| 850 // offset. |
843 if (boxModelObject.isBox() && | 851 if (boxModelObject.isBox() && |
844 (!boxModelObject.isSVG() || boxModelObject.isSVGRoot())) { | 852 (!boxModelObject.isSVG() || boxModelObject.isSVGRoot() || |
| 853 boxModelObject.isSVGForeignObject())) { |
845 // TODO(pdr): Several calls in this function walk back up the tree to | 854 // TODO(pdr): Several calls in this function walk back up the tree to |
846 // calculate containers (e.g., topLeftLocation, offsetForInFlowPosition*). | 855 // calculate containers (e.g., topLeftLocation, offsetForInFlowPosition*). |
847 // The containing block and other containers can be stored on | 856 // The containing block and other containers can be stored on |
848 // PaintPropertyTreeBuilderContext instead of recomputing them. | 857 // PaintPropertyTreeBuilderContext instead of recomputing them. |
849 context.current.paintOffset.moveBy( | 858 context.current.paintOffset.moveBy( |
850 toLayoutBox(boxModelObject).topLeftLocation()); | 859 toLayoutBox(boxModelObject).topLeftLocation()); |
851 // This is a weird quirk that table cells paint as children of table rows, | 860 // This is a weird quirk that table cells paint as children of table rows, |
852 // but their location have the row's location baked-in. | 861 // but their location have the row's location baked-in. |
853 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). | 862 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). |
854 if (boxModelObject.isTableCell()) { | 863 if (boxModelObject.isTableCell()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 #endif | 900 #endif |
892 | 901 |
893 updateOverflowClip(object, context); | 902 updateOverflowClip(object, context); |
894 updatePerspective(object, context); | 903 updatePerspective(object, context); |
895 updateSvgLocalToBorderBoxTransform(object, context); | 904 updateSvgLocalToBorderBoxTransform(object, context); |
896 updateScrollAndScrollTranslation(object, context); | 905 updateScrollAndScrollTranslation(object, context); |
897 updateOutOfFlowContext(object, context); | 906 updateOutOfFlowContext(object, context); |
898 } | 907 } |
899 | 908 |
900 } // namespace blink | 909 } // namespace blink |
OLD | NEW |