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, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 */ | 22 */ |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 #include "core/rendering/svg/RenderSVGContainer.h" | 25 #include "core/layout/svg/LayoutSVGContainer.h" |
26 | 26 |
27 #include "core/layout/svg/SVGLayoutSupport.h" | 27 #include "core/layout/svg/SVGLayoutSupport.h" |
28 #include "core/layout/svg/SVGResources.h" | 28 #include "core/layout/svg/SVGResources.h" |
29 #include "core/layout/svg/SVGResourcesCache.h" | 29 #include "core/layout/svg/SVGResourcesCache.h" |
30 #include "core/paint/SVGContainerPainter.h" | 30 #include "core/paint/SVGContainerPainter.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 RenderSVGContainer::RenderSVGContainer(SVGElement* node) | 34 LayoutSVGContainer::LayoutSVGContainer(SVGElement* node) |
35 : RenderSVGModelObject(node) | 35 : RenderSVGModelObject(node) |
36 , m_objectBoundingBoxValid(false) | 36 , m_objectBoundingBoxValid(false) |
37 , m_needsBoundariesUpdate(true) | 37 , m_needsBoundariesUpdate(true) |
38 , m_hasNonIsolatedBlendingDescendants(false) | 38 , m_hasNonIsolatedBlendingDescendants(false) |
39 , m_hasNonIsolatedBlendingDescendantsDirty(false) | 39 , m_hasNonIsolatedBlendingDescendantsDirty(false) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 RenderSVGContainer::~RenderSVGContainer() | 43 LayoutSVGContainer::~LayoutSVGContainer() |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 void RenderSVGContainer::layout() | 47 void LayoutSVGContainer::layout() |
48 { | 48 { |
49 ASSERT(needsLayout()); | 49 ASSERT(needsLayout()); |
50 | 50 |
51 // Allow RenderSVGViewportContainer to update its viewport. | 51 // Allow RenderSVGViewportContainer to update its viewport. |
52 calcViewport(); | 52 calcViewport(); |
53 | 53 |
54 // Allow RenderSVGTransformableContainer to update its transform. | 54 // Allow RenderSVGTransformableContainer to update its transform. |
55 bool updatedTransform = calculateLocalTransform(); | 55 bool updatedTransform = calculateLocalTransform(); |
56 | 56 |
57 // RenderSVGViewportContainer needs to set the 'layout size changed' flag. | 57 // RenderSVGViewportContainer needs to set the 'layout size changed' flag. |
58 determineIfLayoutSizeChanged(); | 58 determineIfLayoutSizeChanged(); |
59 | 59 |
60 SVGLayoutSupport::layoutChildren(this, selfNeedsLayout() || SVGLayoutSupport
::filtersForceContainerLayout(this)); | 60 SVGLayoutSupport::layoutChildren(this, selfNeedsLayout() || SVGLayoutSupport
::filtersForceContainerLayout(this)); |
61 | 61 |
62 // Invalidate all resources of this client if our layout changed. | 62 // Invalidate all resources of this client if our layout changed. |
63 if (everHadLayout() && needsLayout()) | 63 if (everHadLayout() && needsLayout()) |
64 SVGResourcesCache::clientLayoutChanged(this); | 64 SVGResourcesCache::clientLayoutChanged(this); |
65 | 65 |
66 if (m_needsBoundariesUpdate || updatedTransform) { | 66 if (m_needsBoundariesUpdate || updatedTransform) { |
67 updateCachedBoundaries(); | 67 updateCachedBoundaries(); |
68 m_needsBoundariesUpdate = false; | 68 m_needsBoundariesUpdate = false; |
69 | 69 |
70 // If our bounds changed, notify the parents. | 70 // If our bounds changed, notify the parents. |
71 RenderSVGModelObject::setNeedsBoundariesUpdate(); | 71 RenderSVGModelObject::setNeedsBoundariesUpdate(); |
72 } | 72 } |
73 | 73 |
74 clearNeedsLayout(); | 74 clearNeedsLayout(); |
75 } | 75 } |
76 | 76 |
77 void RenderSVGContainer::addChild(LayoutObject* child, LayoutObject* beforeChild
) | 77 void LayoutSVGContainer::addChild(LayoutObject* child, LayoutObject* beforeChild
) |
78 { | 78 { |
79 RenderSVGModelObject::addChild(child, beforeChild); | 79 RenderSVGModelObject::addChild(child, beforeChild); |
80 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); | 80 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); |
81 | 81 |
82 bool shouldIsolateDescendants = (child->isBlendingAllowed() && child->style(
)->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants(); | 82 bool shouldIsolateDescendants = (child->isBlendingAllowed() && child->style(
)->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants(); |
83 if (shouldIsolateDescendants) | 83 if (shouldIsolateDescendants) |
84 descendantIsolationRequirementsChanged(DescendantIsolationRequired); | 84 descendantIsolationRequirementsChanged(DescendantIsolationRequired); |
85 } | 85 } |
86 | 86 |
87 void RenderSVGContainer::removeChild(LayoutObject* child) | 87 void LayoutSVGContainer::removeChild(LayoutObject* child) |
88 { | 88 { |
89 SVGResourcesCache::clientWillBeRemovedFromTree(child); | 89 SVGResourcesCache::clientWillBeRemovedFromTree(child); |
90 RenderSVGModelObject::removeChild(child); | 90 RenderSVGModelObject::removeChild(child); |
91 | 91 |
92 bool hadNonIsolatedDescendants = (child->isBlendingAllowed() && child->style
()->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants(); | 92 bool hadNonIsolatedDescendants = (child->isBlendingAllowed() && child->style
()->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants(); |
93 if (hadNonIsolatedDescendants) | 93 if (hadNonIsolatedDescendants) |
94 descendantIsolationRequirementsChanged(DescendantIsolationNeedsUpdate); | 94 descendantIsolationRequirementsChanged(DescendantIsolationNeedsUpdate); |
95 } | 95 } |
96 | 96 |
97 bool RenderSVGContainer::selfWillPaint() | 97 bool LayoutSVGContainer::selfWillPaint() |
98 { | 98 { |
99 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
this); | 99 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
this); |
100 return resources && resources->filter(); | 100 return resources && resources->filter(); |
101 } | 101 } |
102 | 102 |
103 void RenderSVGContainer::styleDidChange(StyleDifference diff, const LayoutStyle*
oldStyle) | 103 void LayoutSVGContainer::styleDidChange(StyleDifference diff, const LayoutStyle*
oldStyle) |
104 { | 104 { |
105 RenderSVGModelObject::styleDidChange(diff, oldStyle); | 105 RenderSVGModelObject::styleDidChange(diff, oldStyle); |
106 | 106 |
107 bool hadIsolation = oldStyle && !isSVGHiddenContainer() && SVGLayoutSupport:
:willIsolateBlendingDescendantsForStyle(*oldStyle); | 107 bool hadIsolation = oldStyle && !isSVGHiddenContainer() && SVGLayoutSupport:
:willIsolateBlendingDescendantsForStyle(*oldStyle); |
108 bool isolationChanged = hadIsolation == !SVGLayoutSupport::willIsolateBlendi
ngDescendantsForObject(this); | 108 bool isolationChanged = hadIsolation == !SVGLayoutSupport::willIsolateBlendi
ngDescendantsForObject(this); |
109 | 109 |
110 if (!parent() || !isolationChanged) | 110 if (!parent() || !isolationChanged) |
111 return; | 111 return; |
112 | 112 |
113 if (hasNonIsolatedBlendingDescendants()) | 113 if (hasNonIsolatedBlendingDescendants()) |
114 parent()->descendantIsolationRequirementsChanged(SVGLayoutSupport::willI
solateBlendingDescendantsForObject(this) ? DescendantIsolationNeedsUpdate : Desc
endantIsolationRequired); | 114 parent()->descendantIsolationRequirementsChanged(SVGLayoutSupport::willI
solateBlendingDescendantsForObject(this) ? DescendantIsolationNeedsUpdate : Desc
endantIsolationRequired); |
115 } | 115 } |
116 | 116 |
117 bool RenderSVGContainer::hasNonIsolatedBlendingDescendants() const | 117 bool LayoutSVGContainer::hasNonIsolatedBlendingDescendants() const |
118 { | 118 { |
119 if (m_hasNonIsolatedBlendingDescendantsDirty) { | 119 if (m_hasNonIsolatedBlendingDescendantsDirty) { |
120 m_hasNonIsolatedBlendingDescendants = SVGLayoutSupport::computeHasNonIso
latedBlendingDescendants(this); | 120 m_hasNonIsolatedBlendingDescendants = SVGLayoutSupport::computeHasNonIso
latedBlendingDescendants(this); |
121 m_hasNonIsolatedBlendingDescendantsDirty = false; | 121 m_hasNonIsolatedBlendingDescendantsDirty = false; |
122 } | 122 } |
123 return m_hasNonIsolatedBlendingDescendants; | 123 return m_hasNonIsolatedBlendingDescendants; |
124 } | 124 } |
125 | 125 |
126 void RenderSVGContainer::descendantIsolationRequirementsChanged(DescendantIsolat
ionState state) | 126 void LayoutSVGContainer::descendantIsolationRequirementsChanged(DescendantIsolat
ionState state) |
127 { | 127 { |
128 switch (state) { | 128 switch (state) { |
129 case DescendantIsolationRequired: | 129 case DescendantIsolationRequired: |
130 m_hasNonIsolatedBlendingDescendants = true; | 130 m_hasNonIsolatedBlendingDescendants = true; |
131 m_hasNonIsolatedBlendingDescendantsDirty = false; | 131 m_hasNonIsolatedBlendingDescendantsDirty = false; |
132 break; | 132 break; |
133 case DescendantIsolationNeedsUpdate: | 133 case DescendantIsolationNeedsUpdate: |
134 if (m_hasNonIsolatedBlendingDescendantsDirty) | 134 if (m_hasNonIsolatedBlendingDescendantsDirty) |
135 return; | 135 return; |
136 m_hasNonIsolatedBlendingDescendantsDirty = true; | 136 m_hasNonIsolatedBlendingDescendantsDirty = true; |
137 break; | 137 break; |
138 } | 138 } |
139 if (SVGLayoutSupport::willIsolateBlendingDescendantsForObject(this)) | 139 if (SVGLayoutSupport::willIsolateBlendingDescendantsForObject(this)) |
140 return; | 140 return; |
141 if (parent()) | 141 if (parent()) |
142 parent()->descendantIsolationRequirementsChanged(state); | 142 parent()->descendantIsolationRequirementsChanged(state); |
143 } | 143 } |
144 | 144 |
145 void RenderSVGContainer::paint(const PaintInfo& paintInfo, const LayoutPoint&) | 145 void LayoutSVGContainer::paint(const PaintInfo& paintInfo, const LayoutPoint&) |
146 { | 146 { |
147 SVGContainerPainter(*this).paint(paintInfo); | 147 SVGContainerPainter(*this).paint(paintInfo); |
148 } | 148 } |
149 | 149 |
150 void RenderSVGContainer::addFocusRingRects(Vector<LayoutRect>& rects, const Layo
utPoint&) const | 150 void LayoutSVGContainer::addFocusRingRects(Vector<LayoutRect>& rects, const Layo
utPoint&) const |
151 { | 151 { |
152 LayoutRect contentRect = LayoutRect(paintInvalidationRectInLocalCoordinates(
)); | 152 LayoutRect contentRect = LayoutRect(paintInvalidationRectInLocalCoordinates(
)); |
153 if (!contentRect.isEmpty()) | 153 if (!contentRect.isEmpty()) |
154 rects.append(contentRect); | 154 rects.append(contentRect); |
155 } | 155 } |
156 | 156 |
157 void RenderSVGContainer::updateCachedBoundaries() | 157 void LayoutSVGContainer::updateCachedBoundaries() |
158 { | 158 { |
159 SVGLayoutSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m
_objectBoundingBoxValid, m_strokeBoundingBox, m_paintInvalidationBoundingBox); | 159 SVGLayoutSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m
_objectBoundingBoxValid, m_strokeBoundingBox, m_paintInvalidationBoundingBox); |
160 SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_paintI
nvalidationBoundingBox); | 160 SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_paintI
nvalidationBoundingBox); |
161 } | 161 } |
162 | 162 |
163 bool RenderSVGContainer::nodeAtFloatPoint(const HitTestRequest& request, HitTest
Result& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) | 163 bool LayoutSVGContainer::nodeAtFloatPoint(const HitTestRequest& request, HitTest
Result& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) |
164 { | 164 { |
165 // Give RenderSVGViewportContainer a chance to apply its viewport clip | 165 // Give RenderSVGViewportContainer a chance to apply its viewport clip |
166 if (!pointIsInsideViewportClip(pointInParent)) | 166 if (!pointIsInsideViewportClip(pointInParent)) |
167 return false; | 167 return false; |
168 | 168 |
169 FloatPoint localPoint; | 169 FloatPoint localPoint; |
170 if (!SVGLayoutSupport::transformToUserSpaceAndCheckClipping(this, localToPar
entTransform(), pointInParent, localPoint)) | 170 if (!SVGLayoutSupport::transformToUserSpaceAndCheckClipping(this, localToPar
entTransform(), pointInParent, localPoint)) |
171 return false; | 171 return false; |
172 | 172 |
173 for (LayoutObject* child = lastChild(); child; child = child->previousSiblin
g()) { | 173 for (LayoutObject* child = lastChild(); child; child = child->previousSiblin
g()) { |
174 if (child->nodeAtFloatPoint(request, result, localPoint, hitTestAction))
{ | 174 if (child->nodeAtFloatPoint(request, result, localPoint, hitTestAction))
{ |
175 updateHitTestResult(result, roundedLayoutPoint(localPoint)); | 175 updateHitTestResult(result, roundedLayoutPoint(localPoint)); |
176 return true; | 176 return true; |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 // pointer-events=boundingBox makes it possible for containers to be direct
targets | 180 // pointer-events=boundingBox makes it possible for containers to be direct
targets |
181 if (style()->pointerEvents() == PE_BOUNDINGBOX) { | 181 if (style()->pointerEvents() == PE_BOUNDINGBOX) { |
182 ASSERT(isObjectBoundingBoxValid()); | 182 ASSERT(isObjectBoundingBoxValid()); |
183 if (objectBoundingBox().contains(localPoint)) { | 183 if (objectBoundingBox().contains(localPoint)) { |
184 updateHitTestResult(result, roundedLayoutPoint(localPoint)); | 184 updateHitTestResult(result, roundedLayoutPoint(localPoint)); |
185 return true; | 185 return true; |
186 } | 186 } |
187 } | 187 } |
188 // 16.4: "If there are no graphics elements whose relevant graphics content
is under the pointer (i.e., there is no target element), the event is not dispat
ched." | 188 // 16.4: "If there are no graphics elements whose relevant graphics content
is under the pointer (i.e., there is no target element), the event is not dispat
ched." |
189 return false; | 189 return false; |
190 } | 190 } |
191 | 191 |
192 } | 192 } |
OLD | NEW |