OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@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 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) | 47 static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) |
48 { | 48 { |
49 if (rect.isEmpty()) | 49 if (rect.isEmpty()) |
50 return LayoutRect(); | 50 return LayoutRect(); |
51 return enclosingIntRect(rect); | 51 return enclosingIntRect(rect); |
52 } | 52 } |
53 | 53 |
54 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende
rObject* object, const LayoutLayerModelObject* paintInvalidationContainer, const
PaintInvalidationState* paintInvalidationState) | 54 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Layou
tObject* object, const LayoutLayerModelObject* paintInvalidationContainer, const
PaintInvalidationState* paintInvalidationState) |
55 { | 55 { |
56 // Return early for any cases where we don't actually paint | 56 // Return early for any cases where we don't actually paint |
57 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h
asVisibleContent()) | 57 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h
asVisibleContent()) |
58 return LayoutRect(); | 58 return LayoutRect(); |
59 | 59 |
60 // Pass our local paint rect to computeRectForPaintInvalidation() which will | 60 // Pass our local paint rect to computeRectForPaintInvalidation() which will |
61 // map to parent coords and recurse up the parent chain. | 61 // map to parent coords and recurse up the parent chain. |
62 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); | 62 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); |
63 paintInvalidationRect.inflate(object->style()->outlineWidth()); | 63 paintInvalidationRect.inflate(object->style()->outlineWidth()); |
64 | 64 |
65 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 65 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
66 // Compute accumulated SVG transform and apply to local paint rect. | 66 // Compute accumulated SVG transform and apply to local paint rect. |
67 AffineTransform transform = paintInvalidationState->svgTransform() * obj
ect->localToParentTransform(); | 67 AffineTransform transform = paintInvalidationState->svgTransform() * obj
ect->localToParentTransform(); |
68 paintInvalidationRect = transform.mapRect(paintInvalidationRect); | 68 paintInvalidationRect = transform.mapRect(paintInvalidationRect); |
69 // FIXME: These are quirks carried forward from the old paint invalidati
on infrastructure. | 69 // FIXME: These are quirks carried forward from the old paint invalidati
on infrastructure. |
70 LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | 70 LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
71 // Offset by SVG root paint offset and apply clipping as needed. | 71 // Offset by SVG root paint offset and apply clipping as needed. |
72 rect.move(paintInvalidationState->paintOffset()); | 72 rect.move(paintInvalidationState->paintOffset()); |
73 if (paintInvalidationState->isClipped()) | 73 if (paintInvalidationState->isClipped()) |
74 rect.intersect(paintInvalidationState->clipRect()); | 74 rect.intersect(paintInvalidationState->clipRect()); |
75 return rect; | 75 return rect; |
76 } | 76 } |
77 | 77 |
78 LayoutRect rect; | 78 LayoutRect rect; |
79 const RenderSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object,
paintInvalidationRect, rect); | 79 const RenderSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object,
paintInvalidationRect, rect); |
80 svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect,
paintInvalidationState); | 80 svgRoot.mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect,
paintInvalidationState); |
81 return rect; | 81 return rect; |
82 } | 82 } |
83 | 83 |
84 const RenderSVGRoot& SVGRenderSupport::mapRectToSVGRootForPaintInvalidation(cons
t RenderObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect&
rect) | 84 const RenderSVGRoot& SVGRenderSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect&
rect) |
85 { | 85 { |
86 ASSERT(object && object->isSVG() && !object->isSVGRoot()); | 86 ASSERT(object && object->isSVG() && !object->isSVGRoot()); |
87 | 87 |
88 FloatRect paintInvalidationRect = localPaintInvalidationRect; | 88 FloatRect paintInvalidationRect = localPaintInvalidationRect; |
89 // FIXME: Building the transform to the SVG root border box and then doing | 89 // FIXME: Building the transform to the SVG root border box and then doing |
90 // mapRect() with that would be slightly more efficient, but requires some | 90 // mapRect() with that would be slightly more efficient, but requires some |
91 // additions to AffineTransform (preMultiply, preTranslate) to avoid | 91 // additions to AffineTransform (preMultiply, preTranslate) to avoid |
92 // excessive copying and to get a similar fast-path for translations. | 92 // excessive copying and to get a similar fast-path for translations. |
93 const RenderObject* parent = object; | 93 const LayoutObject* parent = object; |
94 do { | 94 do { |
95 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn
validationRect); | 95 paintInvalidationRect = parent->localToParentTransform().mapRect(paintIn
validationRect); |
96 parent = parent->parent(); | 96 parent = parent->parent(); |
97 } while (!parent->isSVGRoot()); | 97 } while (!parent->isSVGRoot()); |
98 | 98 |
99 const RenderSVGRoot& svgRoot = toRenderSVGRoot(*parent); | 99 const RenderSVGRoot& svgRoot = toRenderSVGRoot(*parent); |
100 | 100 |
101 paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInv
alidationRect); | 101 paintInvalidationRect = svgRoot.localToBorderBoxTransform().mapRect(paintInv
alidationRect); |
102 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); | 102 rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
103 return svgRoot; | 103 return svgRoot; |
104 } | 104 } |
105 | 105 |
106 void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const Lay
outLayerModelObject* paintInvalidationContainer, TransformState& transformState,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) | 106 void SVGRenderSupport::mapLocalToContainer(const LayoutObject* object, const Lay
outLayerModelObject* paintInvalidationContainer, TransformState& transformState,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) |
107 { | 107 { |
108 transformState.applyTransform(object->localToParentTransform()); | 108 transformState.applyTransform(object->localToParentTransform()); |
109 | 109 |
110 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 110 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
111 // |svgTransform| contains localToBorderBoxTransform mentioned below. | 111 // |svgTransform| contains localToBorderBoxTransform mentioned below. |
112 transformState.applyTransform(paintInvalidationState->svgTransform()); | 112 transformState.applyTransform(paintInvalidationState->svgTransform()); |
113 transformState.move(paintInvalidationState->paintOffset()); | 113 transformState.move(paintInvalidationState->paintOffset()); |
114 return; | 114 return; |
115 } | 115 } |
116 | 116 |
117 RenderObject* parent = object->parent(); | 117 LayoutObject* parent = object->parent(); |
118 | 118 |
119 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform | 119 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform |
120 // to map an element from SVG viewport coordinates to CSS box coordinates. | 120 // to map an element from SVG viewport coordinates to CSS box coordinates. |
121 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. | 121 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. |
122 if (parent->isSVGRoot()) | 122 if (parent->isSVGRoot()) |
123 transformState.applyTransform(toRenderSVGRoot(parent)->localToBorderBoxT
ransform()); | 123 transformState.applyTransform(toRenderSVGRoot(parent)->localToBorderBoxT
ransform()); |
124 | 124 |
125 MapCoordinatesFlags mode = UseTransforms; | 125 MapCoordinatesFlags mode = UseTransforms; |
126 parent->mapLocalToContainer(paintInvalidationContainer, transformState, mode
, wasFixed, paintInvalidationState); | 126 parent->mapLocalToContainer(paintInvalidationContainer, transformState, mode
, wasFixed, paintInvalidationState); |
127 } | 127 } |
128 | 128 |
129 const RenderObject* SVGRenderSupport::pushMappingToContainer(const RenderObject*
object, const LayoutLayerModelObject* ancestorToStopAt, RenderGeometryMap& geom
etryMap) | 129 const LayoutObject* SVGRenderSupport::pushMappingToContainer(const LayoutObject*
object, const LayoutLayerModelObject* ancestorToStopAt, RenderGeometryMap& geom
etryMap) |
130 { | 130 { |
131 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); | 131 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); |
132 | 132 |
133 RenderObject* parent = object->parent(); | 133 LayoutObject* parent = object->parent(); |
134 | 134 |
135 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform | 135 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform |
136 // to map an element from SVG viewport coordinates to CSS box coordinates. | 136 // to map an element from SVG viewport coordinates to CSS box coordinates. |
137 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. | 137 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. |
138 if (parent->isSVGRoot()) { | 138 if (parent->isSVGRoot()) { |
139 TransformationMatrix matrix(object->localToParentTransform()); | 139 TransformationMatrix matrix(object->localToParentTransform()); |
140 matrix.multiply(toRenderSVGRoot(parent)->localToBorderBoxTransform()); | 140 matrix.multiply(toRenderSVGRoot(parent)->localToBorderBoxTransform()); |
141 geometryMap.push(object, matrix); | 141 geometryMap.push(object, matrix); |
142 } else | 142 } else |
143 geometryMap.push(object, object->localToParentTransform()); | 143 geometryMap.push(object, object->localToParentTransform()); |
144 | 144 |
145 return parent; | 145 return parent; |
146 } | 146 } |
147 | 147 |
148 // Update a bounding box taking into account the validity of the other bounding
box. | 148 // Update a bounding box taking into account the validity of the other bounding
box. |
149 inline void SVGRenderSupport::updateObjectBoundingBox(FloatRect& objectBoundingB
ox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBo
x) | 149 inline void SVGRenderSupport::updateObjectBoundingBox(FloatRect& objectBoundingB
ox, bool& objectBoundingBoxValid, LayoutObject* other, FloatRect otherBoundingBo
x) |
150 { | 150 { |
151 bool otherValid = other->isSVGContainer() ? toRenderSVGContainer(other)->isO
bjectBoundingBoxValid() : true; | 151 bool otherValid = other->isSVGContainer() ? toRenderSVGContainer(other)->isO
bjectBoundingBoxValid() : true; |
152 if (!otherValid) | 152 if (!otherValid) |
153 return; | 153 return; |
154 | 154 |
155 if (!objectBoundingBoxValid) { | 155 if (!objectBoundingBoxValid) { |
156 objectBoundingBox = otherBoundingBox; | 156 objectBoundingBox = otherBoundingBox; |
157 objectBoundingBoxValid = true; | 157 objectBoundingBoxValid = true; |
158 return; | 158 return; |
159 } | 159 } |
160 | 160 |
161 objectBoundingBox.uniteEvenIfEmpty(otherBoundingBox); | 161 objectBoundingBox.uniteEvenIfEmpty(otherBoundingBox); |
162 } | 162 } |
163 | 163 |
164 void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* contain
er, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strok
eBoundingBox, FloatRect& paintInvalidationBoundingBox) | 164 void SVGRenderSupport::computeContainerBoundingBoxes(const LayoutObject* contain
er, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strok
eBoundingBox, FloatRect& paintInvalidationBoundingBox) |
165 { | 165 { |
166 objectBoundingBox = FloatRect(); | 166 objectBoundingBox = FloatRect(); |
167 objectBoundingBoxValid = false; | 167 objectBoundingBoxValid = false; |
168 strokeBoundingBox = FloatRect(); | 168 strokeBoundingBox = FloatRect(); |
169 | 169 |
170 // When computing the strokeBoundingBox, we use the paintInvalidationRects o
f the container's children so that the container's stroke includes | 170 // When computing the strokeBoundingBox, we use the paintInvalidationRects o
f the container's children so that the container's stroke includes |
171 // the resources applied to the children (such as clips and filters). This a
llows filters applied to containers to correctly bound | 171 // the resources applied to the children (such as clips and filters). This a
llows filters applied to containers to correctly bound |
172 // the children, and also improves inlining of SVG content, as the stroke bo
und is used in that situation also. | 172 // the children, and also improves inlining of SVG content, as the stroke bo
und is used in that situation also. |
173 for (RenderObject* current = container->slowFirstChild(); current; current =
current->nextSibling()) { | 173 for (LayoutObject* current = container->slowFirstChild(); current; current =
current->nextSibling()) { |
174 if (current->isSVGHiddenContainer()) | 174 if (current->isSVGHiddenContainer()) |
175 continue; | 175 continue; |
176 | 176 |
177 // Don't include elements in the union that do not render. | 177 // Don't include elements in the union that do not render. |
178 if (current->isSVGShape() && toRenderSVGShape(current)->isShapeEmpty()) | 178 if (current->isSVGShape() && toRenderSVGShape(current)->isShapeEmpty()) |
179 continue; | 179 continue; |
180 | 180 |
181 const AffineTransform& transform = current->localToParentTransform(); | 181 const AffineTransform& transform = current->localToParentTransform(); |
182 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, curre
nt, | 182 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, curre
nt, |
183 transform.mapRect(current->objectBoundingBox())); | 183 transform.mapRect(current->objectBoundingBox())); |
184 strokeBoundingBox.unite(transform.mapRect(current->paintInvalidationRect
InLocalCoordinates())); | 184 strokeBoundingBox.unite(transform.mapRect(current->paintInvalidationRect
InLocalCoordinates())); |
185 } | 185 } |
186 | 186 |
187 paintInvalidationBoundingBox = strokeBoundingBox; | 187 paintInvalidationBoundingBox = strokeBoundingBox; |
188 } | 188 } |
189 | 189 |
190 const RenderSVGRoot* SVGRenderSupport::findTreeRootObject(const RenderObject* st
art) | 190 const RenderSVGRoot* SVGRenderSupport::findTreeRootObject(const LayoutObject* st
art) |
191 { | 191 { |
192 while (start && !start->isSVGRoot()) | 192 while (start && !start->isSVGRoot()) |
193 start = start->parent(); | 193 start = start->parent(); |
194 | 194 |
195 ASSERT(start); | 195 ASSERT(start); |
196 ASSERT(start->isSVGRoot()); | 196 ASSERT(start->isSVGRoot()); |
197 return toRenderSVGRoot(start); | 197 return toRenderSVGRoot(start); |
198 } | 198 } |
199 | 199 |
200 inline bool SVGRenderSupport::layoutSizeOfNearestViewportChanged(const RenderObj
ect* start) | 200 inline bool SVGRenderSupport::layoutSizeOfNearestViewportChanged(const LayoutObj
ect* start) |
201 { | 201 { |
202 while (start && !start->isSVGRoot() && !start->isSVGViewportContainer()) | 202 while (start && !start->isSVGRoot() && !start->isSVGViewportContainer()) |
203 start = start->parent(); | 203 start = start->parent(); |
204 | 204 |
205 ASSERT(start); | 205 ASSERT(start); |
206 ASSERT(start->isSVGRoot() || start->isSVGViewportContainer()); | 206 ASSERT(start->isSVGRoot() || start->isSVGViewportContainer()); |
207 if (start->isSVGViewportContainer()) | 207 if (start->isSVGViewportContainer()) |
208 return toRenderSVGViewportContainer(start)->isLayoutSizeChanged(); | 208 return toRenderSVGViewportContainer(start)->isLayoutSizeChanged(); |
209 | 209 |
210 return toRenderSVGRoot(start)->isLayoutSizeChanged(); | 210 return toRenderSVGRoot(start)->isLayoutSizeChanged(); |
211 } | 211 } |
212 | 212 |
213 bool SVGRenderSupport::transformToRootChanged(RenderObject* ancestor) | 213 bool SVGRenderSupport::transformToRootChanged(LayoutObject* ancestor) |
214 { | 214 { |
215 while (ancestor && !ancestor->isSVGRoot()) { | 215 while (ancestor && !ancestor->isSVGRoot()) { |
216 if (ancestor->isSVGTransformableContainer()) | 216 if (ancestor->isSVGTransformableContainer()) |
217 return toRenderSVGContainer(ancestor)->didTransformToRootUpdate(); | 217 return toRenderSVGContainer(ancestor)->didTransformToRootUpdate(); |
218 if (ancestor->isSVGViewportContainer()) | 218 if (ancestor->isSVGViewportContainer()) |
219 return toRenderSVGViewportContainer(ancestor)->didTransformToRootUpd
ate(); | 219 return toRenderSVGViewportContainer(ancestor)->didTransformToRootUpd
ate(); |
220 ancestor = ancestor->parent(); | 220 ancestor = ancestor->parent(); |
221 } | 221 } |
222 | 222 |
223 return false; | 223 return false; |
224 } | 224 } |
225 | 225 |
226 void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout) | 226 void SVGRenderSupport::layoutChildren(LayoutObject* start, bool selfNeedsLayout) |
227 { | 227 { |
228 // When hasRelativeLengths() is false, no descendants have relative lengths | 228 // When hasRelativeLengths() is false, no descendants have relative lengths |
229 // (hence no one is interested in viewport size changes). | 229 // (hence no one is interested in viewport size changes). |
230 bool layoutSizeChanged = toSVGElement(start->node())->hasRelativeLengths() | 230 bool layoutSizeChanged = toSVGElement(start->node())->hasRelativeLengths() |
231 && layoutSizeOfNearestViewportChanged(start); | 231 && layoutSizeOfNearestViewportChanged(start); |
232 bool transformChanged = transformToRootChanged(start); | 232 bool transformChanged = transformToRootChanged(start); |
233 | 233 |
234 for (RenderObject* child = start->slowFirstChild(); child; child = child->ne
xtSibling()) { | 234 for (LayoutObject* child = start->slowFirstChild(); child; child = child->ne
xtSibling()) { |
235 bool forceLayout = selfNeedsLayout; | 235 bool forceLayout = selfNeedsLayout; |
236 | 236 |
237 if (transformChanged) { | 237 if (transformChanged) { |
238 // If the transform changed we need to update the text metrics (note
: this also happens for layoutSizeChanged=true). | 238 // If the transform changed we need to update the text metrics (note
: this also happens for layoutSizeChanged=true). |
239 if (child->isSVGText()) | 239 if (child->isSVGText()) |
240 toRenderSVGText(child)->setNeedsTextMetricsUpdate(); | 240 toRenderSVGText(child)->setNeedsTextMetricsUpdate(); |
241 forceLayout = true; | 241 forceLayout = true; |
242 } | 242 } |
243 | 243 |
244 if (layoutSizeChanged) { | 244 if (layoutSizeChanged) { |
(...skipping 21 matching lines...) Expand all Loading... |
266 // SubtreeLayoutScope (in RenderView::layout()). | 266 // SubtreeLayoutScope (in RenderView::layout()). |
267 if (forceLayout && !child->isSVGResourceContainer()) | 267 if (forceLayout && !child->isSVGResourceContainer()) |
268 layoutScope.setNeedsLayout(child); | 268 layoutScope.setNeedsLayout(child); |
269 | 269 |
270 // Lay out any referenced resources before the child. | 270 // Lay out any referenced resources before the child. |
271 layoutResourcesIfNeeded(child); | 271 layoutResourcesIfNeeded(child); |
272 child->layoutIfNeeded(); | 272 child->layoutIfNeeded(); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 void SVGRenderSupport::layoutResourcesIfNeeded(const RenderObject* object) | 276 void SVGRenderSupport::layoutResourcesIfNeeded(const LayoutObject* object) |
277 { | 277 { |
278 ASSERT(object); | 278 ASSERT(object); |
279 | 279 |
280 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
object); | 280 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
object); |
281 if (resources) | 281 if (resources) |
282 resources->layoutIfNeeded(); | 282 resources->layoutIfNeeded(); |
283 } | 283 } |
284 | 284 |
285 bool SVGRenderSupport::isOverflowHidden(const RenderObject* object) | 285 bool SVGRenderSupport::isOverflowHidden(const LayoutObject* object) |
286 { | 286 { |
287 // RenderSVGRoot should never query for overflow state - it should always cl
ip itself to the initial viewport size. | 287 // RenderSVGRoot should never query for overflow state - it should always cl
ip itself to the initial viewport size. |
288 ASSERT(!object->isDocumentElement()); | 288 ASSERT(!object->isDocumentElement()); |
289 | 289 |
290 return object->style()->overflowX() == OHIDDEN || object->style()->overflowX
() == OSCROLL; | 290 return object->style()->overflowX() == OHIDDEN || object->style()->overflowX
() == OSCROLL; |
291 } | 291 } |
292 | 292 |
293 void SVGRenderSupport::intersectPaintInvalidationRectWithResources(const RenderO
bject* renderer, FloatRect& paintInvalidationRect) | 293 void SVGRenderSupport::intersectPaintInvalidationRectWithResources(const LayoutO
bject* renderer, FloatRect& paintInvalidationRect) |
294 { | 294 { |
295 ASSERT(renderer); | 295 ASSERT(renderer); |
296 | 296 |
297 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
renderer); | 297 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
renderer); |
298 if (!resources) | 298 if (!resources) |
299 return; | 299 return; |
300 | 300 |
301 if (RenderSVGResourceFilter* filter = resources->filter()) | 301 if (RenderSVGResourceFilter* filter = resources->filter()) |
302 paintInvalidationRect = filter->resourceBoundingBox(renderer); | 302 paintInvalidationRect = filter->resourceBoundingBox(renderer); |
303 | 303 |
304 if (RenderSVGResourceClipper* clipper = resources->clipper()) | 304 if (RenderSVGResourceClipper* clipper = resources->clipper()) |
305 paintInvalidationRect.intersect(clipper->resourceBoundingBox(renderer)); | 305 paintInvalidationRect.intersect(clipper->resourceBoundingBox(renderer)); |
306 | 306 |
307 if (RenderSVGResourceMasker* masker = resources->masker()) | 307 if (RenderSVGResourceMasker* masker = resources->masker()) |
308 paintInvalidationRect.intersect(masker->resourceBoundingBox(renderer)); | 308 paintInvalidationRect.intersect(masker->resourceBoundingBox(renderer)); |
309 } | 309 } |
310 | 310 |
311 bool SVGRenderSupport::filtersForceContainerLayout(RenderObject* object) | 311 bool SVGRenderSupport::filtersForceContainerLayout(LayoutObject* object) |
312 { | 312 { |
313 // If any of this container's children need to be laid out, and a filter is
applied | 313 // If any of this container's children need to be laid out, and a filter is
applied |
314 // to the container, we need to issue paint invalidations the entire contain
er. | 314 // to the container, we need to issue paint invalidations the entire contain
er. |
315 if (!object->normalChildNeedsLayout()) | 315 if (!object->normalChildNeedsLayout()) |
316 return false; | 316 return false; |
317 | 317 |
318 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
object); | 318 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
object); |
319 if (!resources || !resources->filter()) | 319 if (!resources || !resources->filter()) |
320 return false; | 320 return false; |
321 | 321 |
322 return true; | 322 return true; |
323 } | 323 } |
324 | 324 |
325 bool SVGRenderSupport::pointInClippingArea(RenderObject* object, const FloatPoin
t& point) | 325 bool SVGRenderSupport::pointInClippingArea(LayoutObject* object, const FloatPoin
t& point) |
326 { | 326 { |
327 ASSERT(object); | 327 ASSERT(object); |
328 | 328 |
329 // We just take clippers into account to determine if a point is on the node
. The Specification may | 329 // We just take clippers into account to determine if a point is on the node
. The Specification may |
330 // change later and we also need to check maskers. | 330 // change later and we also need to check maskers. |
331 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
object); | 331 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
object); |
332 if (!resources) | 332 if (!resources) |
333 return true; | 333 return true; |
334 | 334 |
335 if (RenderSVGResourceClipper* clipper = resources->clipper()) | 335 if (RenderSVGResourceClipper* clipper = resources->clipper()) |
336 return clipper->hitTestClipContent(object->objectBoundingBox(), point); | 336 return clipper->hitTestClipContent(object->objectBoundingBox(), point); |
337 | 337 |
338 return true; | 338 return true; |
339 } | 339 } |
340 | 340 |
341 bool SVGRenderSupport::transformToUserSpaceAndCheckClipping(RenderObject* object
, const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatP
oint& localPoint) | 341 bool SVGRenderSupport::transformToUserSpaceAndCheckClipping(LayoutObject* object
, const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatP
oint& localPoint) |
342 { | 342 { |
343 if (!localTransform.isInvertible()) | 343 if (!localTransform.isInvertible()) |
344 return false; | 344 return false; |
345 localPoint = localTransform.inverse().mapPoint(pointInParent); | 345 localPoint = localTransform.inverse().mapPoint(pointInParent); |
346 return pointInClippingArea(object, localPoint); | 346 return pointInClippingArea(object, localPoint); |
347 } | 347 } |
348 | 348 |
349 void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const
RenderStyle& style, const RenderObject* object) | 349 void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const
RenderStyle& style, const LayoutObject* object) |
350 { | 350 { |
351 ASSERT(context); | 351 ASSERT(context); |
352 ASSERT(object); | 352 ASSERT(object); |
353 ASSERT(object->node()); | 353 ASSERT(object->node()); |
354 ASSERT(object->node()->isSVGElement()); | 354 ASSERT(object->node()->isSVGElement()); |
355 | 355 |
356 const SVGRenderStyle& svgStyle = style.svgStyle(); | 356 const SVGRenderStyle& svgStyle = style.svgStyle(); |
357 | 357 |
358 SVGLengthContext lengthContext(toSVGElement(object->node())); | 358 SVGLengthContext lengthContext(toSVGElement(object->node())); |
359 context->setStrokeThickness(svgStyle.strokeWidth()->value(lengthContext)); | 359 context->setStrokeThickness(svgStyle.strokeWidth()->value(lengthContext)); |
360 context->setLineCap(svgStyle.capStyle()); | 360 context->setLineCap(svgStyle.capStyle()); |
361 context->setLineJoin(svgStyle.joinStyle()); | 361 context->setLineJoin(svgStyle.joinStyle()); |
362 context->setMiterLimit(svgStyle.strokeMiterLimit()); | 362 context->setMiterLimit(svgStyle.strokeMiterLimit()); |
363 | 363 |
364 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); | 364 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); |
365 DashArray dashArray; | 365 DashArray dashArray; |
366 if (!dashes->isEmpty()) { | 366 if (!dashes->isEmpty()) { |
367 SVGLengthList::ConstIterator it = dashes->begin(); | 367 SVGLengthList::ConstIterator it = dashes->begin(); |
368 SVGLengthList::ConstIterator itEnd = dashes->end(); | 368 SVGLengthList::ConstIterator itEnd = dashes->end(); |
369 for (; it != itEnd; ++it) | 369 for (; it != itEnd; ++it) |
370 dashArray.append(it->value(lengthContext)); | 370 dashArray.append(it->value(lengthContext)); |
371 } | 371 } |
372 context->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(lengthCon
text)); | 372 context->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(lengthCon
text)); |
373 } | 373 } |
374 | 374 |
375 void SVGRenderSupport::applyStrokeStyleToStrokeData(StrokeData* strokeData, cons
t RenderStyle* style, const RenderObject* object) | 375 void SVGRenderSupport::applyStrokeStyleToStrokeData(StrokeData* strokeData, cons
t RenderStyle* style, const LayoutObject* object) |
376 { | 376 { |
377 ASSERT(strokeData); | 377 ASSERT(strokeData); |
378 ASSERT(style); | 378 ASSERT(style); |
379 ASSERT(object); | 379 ASSERT(object); |
380 ASSERT(object->node()); | 380 ASSERT(object->node()); |
381 ASSERT(object->node()->isSVGElement()); | 381 ASSERT(object->node()->isSVGElement()); |
382 | 382 |
383 const SVGRenderStyle& svgStyle = style->svgStyle(); | 383 const SVGRenderStyle& svgStyle = style->svgStyle(); |
384 | 384 |
385 SVGLengthContext lengthContext(toSVGElement(object->node())); | 385 SVGLengthContext lengthContext(toSVGElement(object->node())); |
386 strokeData->setThickness(svgStyle.strokeWidth()->value(lengthContext)); | 386 strokeData->setThickness(svgStyle.strokeWidth()->value(lengthContext)); |
387 strokeData->setLineCap(svgStyle.capStyle()); | 387 strokeData->setLineCap(svgStyle.capStyle()); |
388 strokeData->setLineJoin(svgStyle.joinStyle()); | 388 strokeData->setLineJoin(svgStyle.joinStyle()); |
389 strokeData->setMiterLimit(svgStyle.strokeMiterLimit()); | 389 strokeData->setMiterLimit(svgStyle.strokeMiterLimit()); |
390 | 390 |
391 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); | 391 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); |
392 DashArray dashArray; | 392 DashArray dashArray; |
393 if (!dashes->isEmpty()) { | 393 if (!dashes->isEmpty()) { |
394 SVGLengthList::ConstIterator it = dashes->begin(); | 394 SVGLengthList::ConstIterator it = dashes->begin(); |
395 SVGLengthList::ConstIterator itEnd = dashes->end(); | 395 SVGLengthList::ConstIterator itEnd = dashes->end(); |
396 for (; it != itEnd; ++it) | 396 for (; it != itEnd; ++it) |
397 dashArray.append(it->value(lengthContext)); | 397 dashArray.append(it->value(lengthContext)); |
398 } | 398 } |
399 strokeData->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(length
Context)); | 399 strokeData->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(length
Context)); |
400 } | 400 } |
401 | 401 |
402 bool SVGRenderSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic
sContextStateSaver& stateSaver, const RenderStyle& style, RenderObject& renderer
, RenderSVGResourceMode resourceMode, const AffineTransform* additionalPaintServ
erTransform) | 402 bool SVGRenderSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic
sContextStateSaver& stateSaver, const RenderStyle& style, LayoutObject& renderer
, RenderSVGResourceMode resourceMode, const AffineTransform* additionalPaintServ
erTransform) |
403 { | 403 { |
404 ASSERT(paintInfo.context == stateSaver.context()); | 404 ASSERT(paintInfo.context == stateSaver.context()); |
405 | 405 |
406 GraphicsContext* context = paintInfo.context; | 406 GraphicsContext* context = paintInfo.context; |
407 if (paintInfo.isRenderingClipPathAsMaskImage()) { | 407 if (paintInfo.isRenderingClipPathAsMaskImage()) { |
408 if (resourceMode == ApplyToStrokeMode) | 408 if (resourceMode == ApplyToStrokeMode) |
409 return false; | 409 return false; |
410 context->setFillColor(SVGRenderStyle::initialFillPaintColor()); | 410 context->setFillColor(SVGRenderStyle::initialFillPaintColor()); |
411 return true; | 411 return true; |
412 } | 412 } |
(...skipping 10 matching lines...) Expand all Loading... |
423 paintServer.apply(*context, resourceMode, paintAlpha, stateSaver); | 423 paintServer.apply(*context, resourceMode, paintAlpha, stateSaver); |
424 | 424 |
425 if (resourceMode == ApplyToFillMode) | 425 if (resourceMode == ApplyToFillMode) |
426 context->setFillRule(svgStyle.fillRule()); | 426 context->setFillRule(svgStyle.fillRule()); |
427 else | 427 else |
428 applyStrokeStyleToContext(context, style, &renderer); | 428 applyStrokeStyleToContext(context, style, &renderer); |
429 | 429 |
430 return true; | 430 return true; |
431 } | 431 } |
432 | 432 |
433 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) | 433 bool SVGRenderSupport::isRenderableTextNode(const LayoutObject* object) |
434 { | 434 { |
435 ASSERT(object->isText()); | 435 ASSERT(object->isText()); |
436 // <br> is marked as text, but is not handled by the SVG rendering code-path
. | 436 // <br> is marked as text, but is not handled by the SVG rendering code-path
. |
437 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty
Text(); | 437 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty
Text(); |
438 } | 438 } |
439 | 439 |
440 bool SVGRenderSupport::willIsolateBlendingDescendantsForStyle(const RenderStyle*
style) | 440 bool SVGRenderSupport::willIsolateBlendingDescendantsForStyle(const RenderStyle*
style) |
441 { | 441 { |
442 ASSERT(style); | 442 ASSERT(style); |
443 const SVGRenderStyle& svgStyle = style->svgStyle(); | 443 const SVGRenderStyle& svgStyle = style->svgStyle(); |
444 | 444 |
445 return style->hasIsolation() || style->opacity() < 1 || style->hasBlendMode(
) | 445 return style->hasIsolation() || style->opacity() < 1 || style->hasBlendMode(
) |
446 || svgStyle.hasFilter() || svgStyle.hasMasker() || svgStyle.hasClipper()
; | 446 || svgStyle.hasFilter() || svgStyle.hasMasker() || svgStyle.hasClipper()
; |
447 } | 447 } |
448 | 448 |
449 bool SVGRenderSupport::willIsolateBlendingDescendantsForObject(const RenderObjec
t* object) | 449 bool SVGRenderSupport::willIsolateBlendingDescendantsForObject(const LayoutObjec
t* object) |
450 { | 450 { |
451 if (object->isSVGHiddenContainer()) | 451 if (object->isSVGHiddenContainer()) |
452 return false; | 452 return false; |
453 if (!object->isSVGRoot() && !object->isSVGContainer()) | 453 if (!object->isSVGRoot() && !object->isSVGContainer()) |
454 return false; | 454 return false; |
455 return willIsolateBlendingDescendantsForStyle(object->style()); | 455 return willIsolateBlendingDescendantsForStyle(object->style()); |
456 } | 456 } |
457 | 457 |
458 bool SVGRenderSupport::isIsolationRequired(const RenderObject* object) | 458 bool SVGRenderSupport::isIsolationRequired(const LayoutObject* object) |
459 { | 459 { |
460 return willIsolateBlendingDescendantsForObject(object) && object->hasNonIsol
atedBlendingDescendants(); | 460 return willIsolateBlendingDescendantsForObject(object) && object->hasNonIsol
atedBlendingDescendants(); |
461 } | 461 } |
462 | 462 |
463 } | 463 } |
OLD | NEW |