OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2009 Google, Inc. All rights reserved. | 4 * Copyright (C) 2009 Google, Inc. All rights reserved. |
5 * Copyright (C) 2009 Apple Inc. All rights reserved. | 5 * Copyright (C) 2009 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "core/layout/LayoutReplaced.h" | 26 #include "core/layout/LayoutReplaced.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 class SVGElement; | 30 class SVGElement; |
31 | 31 |
32 class LayoutSVGRoot final : public LayoutReplaced { | 32 class LayoutSVGRoot final : public LayoutReplaced { |
33 public: | 33 public: |
34 explicit LayoutSVGRoot(SVGElement*); | 34 explicit LayoutSVGRoot(SVGElement*); |
35 virtual ~LayoutSVGRoot(); | 35 ~LayoutSVGRoot() override; |
36 | 36 |
37 bool isEmbeddedThroughSVGImage() const; | 37 bool isEmbeddedThroughSVGImage() const; |
38 bool isEmbeddedThroughFrameContainingSVGDocument() const; | 38 bool isEmbeddedThroughFrameContainingSVGDocument() const; |
39 | 39 |
40 virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, doub
le& intrinsicRatio) const override; | 40 void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intr
insicRatio) const override; |
41 virtual void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* p
aintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const ove
rride; | 41 void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* paintInva
lidationContainer, LayoutRect&, const PaintInvalidationState*) const override; |
42 | 42 |
43 // If you have a LayoutSVGRoot, use firstChild or lastChild instead. | 43 // If you have a LayoutSVGRoot, use firstChild or lastChild instead. |
44 void slowFirstChild() const = delete; | 44 void slowFirstChild() const = delete; |
45 void slowLastChild() const = delete; | 45 void slowLastChild() const = delete; |
46 | 46 |
47 LayoutObject* firstChild() const { ASSERT(children() == virtualChildren());
return children()->firstChild(); } | 47 LayoutObject* firstChild() const { ASSERT(children() == virtualChildren());
return children()->firstChild(); } |
48 LayoutObject* lastChild() const { ASSERT(children() == virtualChildren()); r
eturn children()->lastChild(); } | 48 LayoutObject* lastChild() const { ASSERT(children() == virtualChildren()); r
eturn children()->lastChild(); } |
49 | 49 |
50 bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; } | 50 bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; } |
51 virtual void setNeedsBoundariesUpdate() override { m_needsBoundariesOrTransf
ormUpdate = true; } | 51 void setNeedsBoundariesUpdate() override { m_needsBoundariesOrTransformUpdat
e = true; } |
52 virtual void setNeedsTransformUpdate() override { m_needsBoundariesOrTransfo
rmUpdate = true; } | 52 void setNeedsTransformUpdate() override { m_needsBoundariesOrTransformUpdate
= true; } |
53 | 53 |
54 IntSize containerSize() const { return m_containerSize; } | 54 IntSize containerSize() const { return m_containerSize; } |
55 void setContainerSize(const IntSize& containerSize) | 55 void setContainerSize(const IntSize& containerSize) |
56 { | 56 { |
57 // SVGImage::draw() does a view layout prior to painting, | 57 // SVGImage::draw() does a view layout prior to painting, |
58 // and we need that layout to know of the new size otherwise | 58 // and we need that layout to know of the new size otherwise |
59 // the layout may be incorrectly using the old size. | 59 // the layout may be incorrectly using the old size. |
60 if (m_containerSize != containerSize) | 60 if (m_containerSize != containerSize) |
61 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Siz
eChanged); | 61 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Siz
eChanged); |
62 m_containerSize = containerSize; | 62 m_containerSize = containerSize; |
63 } | 63 } |
64 | 64 |
65 // localToBorderBoxTransform maps local SVG viewport coordinates to local CS
S box coordinates. | 65 // localToBorderBoxTransform maps local SVG viewport coordinates to local CS
S box coordinates. |
66 const AffineTransform& localToBorderBoxTransform() const { return m_localToB
orderBoxTransform; } | 66 const AffineTransform& localToBorderBoxTransform() const { return m_localToB
orderBoxTransform; } |
67 bool shouldApplyViewportClip() const; | 67 bool shouldApplyViewportClip() const; |
68 | 68 |
69 virtual bool hasNonIsolatedBlendingDescendants() const override final; | 69 bool hasNonIsolatedBlendingDescendants() const final; |
70 | 70 |
71 virtual const char* name() const override { return "LayoutSVGRoot"; } | 71 const char* name() const override { return "LayoutSVGRoot"; } |
72 | 72 |
73 private: | 73 private: |
74 const LayoutObjectChildList* children() const { return &m_children; } | 74 const LayoutObjectChildList* children() const { return &m_children; } |
75 LayoutObjectChildList* children() { return &m_children; } | 75 LayoutObjectChildList* children() { return &m_children; } |
76 | 76 |
77 virtual LayoutObjectChildList* virtualChildren() override { return children(
); } | 77 LayoutObjectChildList* virtualChildren() override { return children(); } |
78 virtual const LayoutObjectChildList* virtualChildren() const override { retu
rn children(); } | 78 const LayoutObjectChildList* virtualChildren() const override { return child
ren(); } |
79 | 79 |
80 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectSVG || type == LayoutObjectSVGRoot || LayoutReplaced::isOfType(type
); } | 80 bool isOfType(LayoutObjectType type) const override { return type == LayoutO
bjectSVG || type == LayoutObjectSVGRoot || LayoutReplaced::isOfType(type); } |
81 | 81 |
82 virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = Com
puteActual) const override; | 82 LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = ComputeActu
al) const override; |
83 virtual LayoutUnit computeReplacedLogicalHeight() const override; | 83 LayoutUnit computeReplacedLogicalHeight() const override; |
84 virtual void layout() override; | 84 void layout() override; |
85 virtual void paintReplaced(const PaintInfo&, const LayoutPoint&) override; | 85 void paintReplaced(const PaintInfo&, const LayoutPoint&) override; |
86 | 86 |
87 virtual void willBeDestroyed() override; | 87 void willBeDestroyed() override; |
88 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle)
override; | 88 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
89 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const overr
ide; | 89 bool isChildAllowed(LayoutObject*, const ComputedStyle&) const override; |
90 virtual void addChild(LayoutObject* child, LayoutObject* beforeChild = nullp
tr) override; | 90 void addChild(LayoutObject* child, LayoutObject* beforeChild = nullptr) over
ride; |
91 virtual void removeChild(LayoutObject*) override; | 91 void removeChild(LayoutObject*) override; |
92 | 92 |
93 virtual void insertedIntoTree() override; | 93 void insertedIntoTree() override; |
94 virtual void willBeRemovedFromTree() override; | 94 void willBeRemovedFromTree() override; |
95 | 95 |
96 virtual const AffineTransform& localToParentTransform() const override; | 96 const AffineTransform& localToParentTransform() const override; |
97 | 97 |
98 virtual FloatRect objectBoundingBox() const override { return m_objectBoundi
ngBox; } | 98 FloatRect objectBoundingBox() const override { return m_objectBoundingBox; } |
99 virtual FloatRect strokeBoundingBox() const override { return m_strokeBoundi
ngBox; } | 99 FloatRect strokeBoundingBox() const override { return m_strokeBoundingBox; } |
100 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override {
return m_paintInvalidationBoundingBox; } | 100 FloatRect paintInvalidationRectInLocalCoordinates() const override { return
m_paintInvalidationBoundingBox; } |
101 | 101 |
102 virtual bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInCo
ntainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; | 102 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer,
const LayoutPoint& accumulatedOffset, HitTestAction) override; |
103 | 103 |
104 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo
delObject* paintInvalidationContainer, const PaintInvalidationState* = nullptr)
const override; | 104 LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxModelObjec
t* paintInvalidationContainer, const PaintInvalidationState* = nullptr) const ov
erride; |
105 | 105 |
106 virtual void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidati
onContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wa
sFixed = nullptr, const PaintInvalidationState* = nullptr) const override; | 106 void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidationContai
ner, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed =
nullptr, const PaintInvalidationState* = nullptr) const override; |
107 virtual const LayoutObject* pushMappingToContainer(const LayoutBoxModelObjec
t* ancestorToStopAt, LayoutGeometryMap&) const override; | 107 const LayoutObject* pushMappingToContainer(const LayoutBoxModelObject* ances
torToStopAt, LayoutGeometryMap&) const override; |
108 | 108 |
109 virtual bool canBeSelectionLeaf() const override { return false; } | 109 bool canBeSelectionLeaf() const override { return false; } |
110 virtual bool canHaveChildren() const override { return true; } | 110 bool canHaveChildren() const override { return true; } |
111 | 111 |
112 virtual void descendantIsolationRequirementsChanged(DescendantIsolationState
) override final; | 112 void descendantIsolationRequirementsChanged(DescendantIsolationState) final; |
113 | 113 |
114 void updateCachedBoundaries(); | 114 void updateCachedBoundaries(); |
115 void buildLocalToBorderBoxTransform(); | 115 void buildLocalToBorderBoxTransform(); |
116 | 116 |
117 LayoutObjectChildList m_children; | 117 LayoutObjectChildList m_children; |
118 IntSize m_containerSize; | 118 IntSize m_containerSize; |
119 FloatRect m_objectBoundingBox; | 119 FloatRect m_objectBoundingBox; |
120 bool m_objectBoundingBoxValid; | 120 bool m_objectBoundingBoxValid; |
121 FloatRect m_strokeBoundingBox; | 121 FloatRect m_strokeBoundingBox; |
122 FloatRect m_paintInvalidationBoundingBox; | 122 FloatRect m_paintInvalidationBoundingBox; |
123 mutable AffineTransform m_localToParentTransform; | 123 mutable AffineTransform m_localToParentTransform; |
124 AffineTransform m_localToBorderBoxTransform; | 124 AffineTransform m_localToBorderBoxTransform; |
125 bool m_isLayoutSizeChanged : 1; | 125 bool m_isLayoutSizeChanged : 1; |
126 bool m_needsBoundariesOrTransformUpdate : 1; | 126 bool m_needsBoundariesOrTransformUpdate : 1; |
127 bool m_hasBoxDecorationBackground : 1; | 127 bool m_hasBoxDecorationBackground : 1; |
128 mutable bool m_hasNonIsolatedBlendingDescendants : 1; | 128 mutable bool m_hasNonIsolatedBlendingDescendants : 1; |
129 mutable bool m_hasNonIsolatedBlendingDescendantsDirty : 1; | 129 mutable bool m_hasNonIsolatedBlendingDescendantsDirty : 1; |
130 }; | 130 }; |
131 | 131 |
132 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGRoot, isSVGRoot()); | 132 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGRoot, isSVGRoot()); |
133 | 133 |
134 } // namespace blink | 134 } // namespace blink |
135 | 135 |
136 #endif // LayoutSVGRoot_h | 136 #endif // LayoutSVGRoot_h |
OLD | NEW |