Chromium Code Reviews| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), | 255 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), |
| 256 style.transformOriginZ()); | 256 style.transformOriginZ()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 // SVG does not use the general transform update of |updateTransform|, instead | 259 // SVG does not use the general transform update of |updateTransform|, instead |
| 260 // creating a transform node for SVG-specific transforms without 3D. | 260 // creating a transform node for SVG-specific transforms without 3D. |
| 261 void PaintPropertyTreeBuilder::updateTransformForNonRootSVG( | 261 void PaintPropertyTreeBuilder::updateTransformForNonRootSVG( |
| 262 const LayoutObject& object, | 262 const LayoutObject& object, |
| 263 PaintPropertyTreeBuilderContext& context) { | 263 PaintPropertyTreeBuilderContext& context) { |
| 264 DCHECK(object.isSVG() && !object.isSVGRoot()); | 264 DCHECK(object.isSVG() && !object.isSVGRoot()); |
| 265 // SVG (other than SVGForeignObject) does not use paint offset internally. | 265 // SVG does not use paint offset internally, except for those inheriting from |
| 266 DCHECK(object.isSVGForeignObject() || | 266 // LayoutBoxModelObject or LayoutText which will use HTML painters. |
| 267 DCHECK(object.isBoxModelObject() || object.isText() || | |
| 267 context.current.paintOffset == LayoutPoint()); | 268 context.current.paintOffset == LayoutPoint()); |
| 268 | 269 |
| 269 if (object.needsPaintPropertyUpdate()) { | 270 if (object.needsPaintPropertyUpdate()) { |
| 271 // SVGForeignObject issues paint offset using its location() which contains | |
| 272 // its viewport offset, so here we must use localSVGTransform() which does | |
| 273 // not contain the viewport offset, instead of localToSVGParentTransform(). | |
| 270 // TODO(pdr): Refactor this so all non-root SVG objects use the same | 274 // TODO(pdr): Refactor this so all non-root SVG objects use the same |
| 271 // transform function. | 275 // transform function. |
| 272 const AffineTransform& transform = object.isSVGForeignObject() | 276 const AffineTransform& transform = object.isSVGForeignObject() |
| 273 ? object.localSVGTransform() | 277 ? object.localSVGTransform() |
| 274 : object.localToSVGParentTransform(); | 278 : object.localToSVGParentTransform(); |
| 275 // 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. |
| 276 // Checking for an identity matrix will cause the property tree structure | 280 // Checking for an identity matrix will cause the property tree structure |
| 277 // to change during animations if the animation passes through the | 281 // to change during animations if the animation passes through the |
| 278 // identity matrix. | 282 // identity matrix. |
| 279 if (!transform.isIdentity()) { | 283 if (!transform.isIdentity()) { |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 overrideContaineringBlockContextFromRealContainingBlock( | 852 overrideContaineringBlockContextFromRealContainingBlock( |
| 849 toLayoutBlock(*boxModelObject.container()), context.current); | 853 toLayoutBlock(*boxModelObject.container()), context.current); |
| 850 } else { | 854 } else { |
| 851 context.current = context.fixedPosition; | 855 context.current = context.fixedPosition; |
| 852 } | 856 } |
| 853 break; | 857 break; |
| 854 default: | 858 default: |
| 855 ASSERT_NOT_REACHED(); | 859 ASSERT_NOT_REACHED(); |
| 856 } | 860 } |
| 857 | 861 |
| 858 // SVGForeignObject needs paint offset because its viewport offset is baked | 862 // The following condition also includes any SVG objects inheriting LayoutBox |
|
pdr.
2016/11/16 03:53:49
Nit: ...inheriting [from] LayoutBox...
Xianzhu
2016/11/16 04:05:48
Done.
| |
| 859 // into its location(), while its localSVGTransform() doesn't contain the | 863 // and using HTML painters which will offset the paint origin by the object's |
| 860 // offset. | 864 // location(). |
| 861 if (boxModelObject.isBox() && | 865 if (boxModelObject.isBox()) { |
| 862 (!boxModelObject.isSVG() || boxModelObject.isSVGRoot() || | |
| 863 boxModelObject.isSVGForeignObject())) { | |
| 864 // TODO(pdr): Several calls in this function walk back up the tree to | 866 // TODO(pdr): Several calls in this function walk back up the tree to |
| 865 // calculate containers (e.g., topLeftLocation, offsetForInFlowPosition*). | 867 // calculate containers (e.g., topLeftLocation, offsetForInFlowPosition*). |
| 866 // The containing block and other containers can be stored on | 868 // The containing block and other containers can be stored on |
| 867 // PaintPropertyTreeBuilderContext instead of recomputing them. | 869 // PaintPropertyTreeBuilderContext instead of recomputing them. |
| 868 context.current.paintOffset.moveBy( | 870 context.current.paintOffset.moveBy( |
| 869 toLayoutBox(boxModelObject).topLeftLocation()); | 871 toLayoutBox(boxModelObject).topLeftLocation()); |
| 870 // This is a weird quirk that table cells paint as children of table rows, | 872 // This is a weird quirk that table cells paint as children of table rows, |
| 871 // but their location have the row's location baked-in. | 873 // but their location have the row's location baked-in. |
| 872 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). | 874 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). |
| 873 if (boxModelObject.isTableCell()) { | 875 if (boxModelObject.isTableCell()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 #endif | 913 #endif |
| 912 | 914 |
| 913 updateOverflowClip(object, context); | 915 updateOverflowClip(object, context); |
| 914 updatePerspective(object, context); | 916 updatePerspective(object, context); |
| 915 updateSvgLocalToBorderBoxTransform(object, context); | 917 updateSvgLocalToBorderBoxTransform(object, context); |
| 916 updateScrollAndScrollTranslation(object, context); | 918 updateScrollAndScrollTranslation(object, context); |
| 917 updateOutOfFlowContext(object, context); | 919 updateOutOfFlowContext(object, context); |
| 918 } | 920 } |
| 919 | 921 |
| 920 } // namespace blink | 922 } // namespace blink |
| OLD | NEW |