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 25 matching lines...) Expand all Loading... |
36 #include "core/rendering/svg/RenderSVGRoot.h" | 36 #include "core/rendering/svg/RenderSVGRoot.h" |
37 #include "core/rendering/svg/RenderSVGText.h" | 37 #include "core/rendering/svg/RenderSVGText.h" |
38 #include "core/rendering/svg/RenderSVGViewportContainer.h" | 38 #include "core/rendering/svg/RenderSVGViewportContainer.h" |
39 #include "core/rendering/svg/SVGResources.h" | 39 #include "core/rendering/svg/SVGResources.h" |
40 #include "core/rendering/svg/SVGResourcesCache.h" | 40 #include "core/rendering/svg/SVGResourcesCache.h" |
41 #include "core/svg/SVGElement.h" | 41 #include "core/svg/SVGElement.h" |
42 #include "platform/geometry/TransformState.h" | 42 #include "platform/geometry/TransformState.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 LayoutRect SVGRenderSupport::clippedOverflowRectForRepaint(const RenderObject* o
bject, const RenderLayerModelObject* repaintContainer, const PaintInvalidationSt
ate* paintInvalidationState) | 46 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende
rObject* object, const RenderLayerModelObject* paintInvalidationContainer, const
PaintInvalidationState* paintInvalidationState) |
47 { | 47 { |
48 // Return early for any cases where we don't actually paint | 48 // Return early for any cases where we don't actually paint |
49 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h
asVisibleContent()) | 49 if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->h
asVisibleContent()) |
50 return LayoutRect(); | 50 return LayoutRect(); |
51 | 51 |
52 // Pass our local paint rect to computeRectForRepaint() which will | 52 // Pass our local paint rect to computeRectForPaintInvalidation() which will |
53 // map to parent coords and recurse up the parent chain. | 53 // map to parent coords and recurse up the parent chain. |
54 FloatRect repaintRect = object->paintInvalidationRectInLocalCoordinates(); | 54 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); |
55 object->computeFloatRectForPaintInvalidation(repaintContainer, repaintRect,
paintInvalidationState); | 55 object->computeFloatRectForPaintInvalidation(paintInvalidationContainer, pai
ntInvalidationRect, paintInvalidationState); |
56 return enclosingLayoutRect(repaintRect); | 56 return enclosingLayoutRect(paintInvalidationRect); |
57 } | 57 } |
58 | 58 |
59 void SVGRenderSupport::computeFloatRectForRepaint(const RenderObject* object, co
nst RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed
, const PaintInvalidationState* paintInvalidationState) | 59 void SVGRenderSupport::computeFloatRectForPaintInvalidation(const RenderObject*
object, const RenderLayerModelObject* paintInvalidationContainer, FloatRect& pai
ntInvalidationRect, bool fixed, const PaintInvalidationState* paintInvalidationS
tate) |
60 { | 60 { |
61 repaintRect.inflate(object->style()->outlineWidth()); | 61 paintInvalidationRect.inflate(object->style()->outlineWidth()); |
62 | 62 |
63 // Translate to coords in our parent renderer, and then call computeFloatRec
tForPaintInvalidation() on our parent. | 63 // Translate to coords in our parent renderer, and then call computeFloatRec
tForPaintInvalidation() on our parent. |
64 repaintRect = object->localToParentTransform().mapRect(repaintRect); | 64 paintInvalidationRect = object->localToParentTransform().mapRect(paintInvali
dationRect); |
65 object->parent()->computeFloatRectForPaintInvalidation(repaintContainer, rep
aintRect, fixed, paintInvalidationState); | 65 object->parent()->computeFloatRectForPaintInvalidation(paintInvalidationCont
ainer, paintInvalidationRect, fixed, paintInvalidationState); |
66 } | 66 } |
67 | 67 |
68 void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const Ren
derLayerModelObject* repaintContainer, TransformState& transformState, bool* was
Fixed, const PaintInvalidationState* paintInvalidationState) | 68 void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const Ren
derLayerModelObject* paintInvalidationContainer, TransformState& transformState,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) |
69 { | 69 { |
70 transformState.applyTransform(object->localToParentTransform()); | 70 transformState.applyTransform(object->localToParentTransform()); |
71 | 71 |
72 RenderObject* parent = object->parent(); | 72 RenderObject* parent = object->parent(); |
73 | 73 |
74 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform | 74 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform |
75 // to map an element from SVG viewport coordinates to CSS box coordinates. | 75 // to map an element from SVG viewport coordinates to CSS box coordinates. |
76 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. | 76 // RenderSVGRoot's mapLocalToContainer method expects CSS box coordinates. |
77 if (parent->isSVGRoot()) | 77 if (parent->isSVGRoot()) |
78 transformState.applyTransform(toRenderSVGRoot(parent)->localToBorderBoxT
ransform()); | 78 transformState.applyTransform(toRenderSVGRoot(parent)->localToBorderBoxT
ransform()); |
79 | 79 |
80 MapCoordinatesFlags mode = UseTransforms; | 80 MapCoordinatesFlags mode = UseTransforms; |
81 parent->mapLocalToContainer(repaintContainer, transformState, mode, wasFixed
, paintInvalidationState); | 81 parent->mapLocalToContainer(paintInvalidationContainer, transformState, mode
, wasFixed, paintInvalidationState); |
82 } | 82 } |
83 | 83 |
84 const RenderObject* SVGRenderSupport::pushMappingToContainer(const RenderObject*
object, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geom
etryMap) | 84 const RenderObject* SVGRenderSupport::pushMappingToContainer(const RenderObject*
object, const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geom
etryMap) |
85 { | 85 { |
86 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); | 86 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); |
87 | 87 |
88 RenderObject* parent = object->parent(); | 88 RenderObject* parent = object->parent(); |
89 | 89 |
90 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform | 90 // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderB
oxTransform |
91 // to map an element from SVG viewport coordinates to CSS box coordinates. | 91 // to map an element from SVG viewport coordinates to CSS box coordinates. |
(...skipping 17 matching lines...) Expand all Loading... |
109 | 109 |
110 if (!objectBoundingBoxValid) { | 110 if (!objectBoundingBoxValid) { |
111 objectBoundingBox = otherBoundingBox; | 111 objectBoundingBox = otherBoundingBox; |
112 objectBoundingBoxValid = true; | 112 objectBoundingBoxValid = true; |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 objectBoundingBox.uniteEvenIfEmpty(otherBoundingBox); | 116 objectBoundingBox.uniteEvenIfEmpty(otherBoundingBox); |
117 } | 117 } |
118 | 118 |
119 void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* contain
er, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strok
eBoundingBox, FloatRect& repaintBoundingBox) | 119 void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* contain
er, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strok
eBoundingBox, FloatRect& paintInvalidationBoundingBox) |
120 { | 120 { |
121 objectBoundingBox = FloatRect(); | 121 objectBoundingBox = FloatRect(); |
122 objectBoundingBoxValid = false; | 122 objectBoundingBoxValid = false; |
123 strokeBoundingBox = FloatRect(); | 123 strokeBoundingBox = FloatRect(); |
124 | 124 |
125 // When computing the strokeBoundingBox, we use the repaintRects of the cont
ainer's children so that the container's stroke includes | 125 // When computing the strokeBoundingBox, we use the paintInvalidationRects o
f the container's children so that the container's stroke includes |
126 // the resources applied to the children (such as clips and filters). This a
llows filters applied to containers to correctly bound | 126 // the resources applied to the children (such as clips and filters). This a
llows filters applied to containers to correctly bound |
127 // the children, and also improves inlining of SVG content, as the stroke bo
und is used in that situation also. | 127 // the children, and also improves inlining of SVG content, as the stroke bo
und is used in that situation also. |
128 for (RenderObject* current = container->slowFirstChild(); current; current =
current->nextSibling()) { | 128 for (RenderObject* current = container->slowFirstChild(); current; current =
current->nextSibling()) { |
129 if (current->isSVGHiddenContainer()) | 129 if (current->isSVGHiddenContainer()) |
130 continue; | 130 continue; |
131 | 131 |
132 // Don't include elements in the union that do not render. | 132 // Don't include elements in the union that do not render. |
133 if (current->isSVGShape() && toRenderSVGShape(current)->isShapeEmpty()) | 133 if (current->isSVGShape() && toRenderSVGShape(current)->isShapeEmpty()) |
134 continue; | 134 continue; |
135 | 135 |
136 const AffineTransform& transform = current->localToParentTransform(); | 136 const AffineTransform& transform = current->localToParentTransform(); |
137 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, curre
nt, | 137 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, curre
nt, |
138 transform.mapRect(current->objectBoundingBox())); | 138 transform.mapRect(current->objectBoundingBox())); |
139 strokeBoundingBox.unite(transform.mapRect(current->paintInvalidationRect
InLocalCoordinates())); | 139 strokeBoundingBox.unite(transform.mapRect(current->paintInvalidationRect
InLocalCoordinates())); |
140 } | 140 } |
141 | 141 |
142 repaintBoundingBox = strokeBoundingBox; | 142 paintInvalidationBoundingBox = strokeBoundingBox; |
143 } | 143 } |
144 | 144 |
145 bool SVGRenderSupport::paintInfoIntersectsRepaintRect(const FloatRect& localRepa
intRect, const AffineTransform& localTransform, const PaintInfo& paintInfo) | 145 bool SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(const FloatRect&
localPaintInvalidationRect, const AffineTransform& localTransform, const PaintI
nfo& paintInfo) |
146 { | 146 { |
147 return localTransform.mapRect(localRepaintRect).intersects(paintInfo.rect); | 147 return localTransform.mapRect(localPaintInvalidationRect).intersects(paintIn
fo.rect); |
148 } | 148 } |
149 | 149 |
150 const RenderSVGRoot* SVGRenderSupport::findTreeRootObject(const RenderObject* st
art) | 150 const RenderSVGRoot* SVGRenderSupport::findTreeRootObject(const RenderObject* st
art) |
151 { | 151 { |
152 while (start && !start->isSVGRoot()) | 152 while (start && !start->isSVGRoot()) |
153 start = start->parent(); | 153 start = start->parent(); |
154 | 154 |
155 ASSERT(start); | 155 ASSERT(start); |
156 ASSERT(start->isSVGRoot()); | 156 ASSERT(start->isSVGRoot()); |
157 return toRenderSVGRoot(start); | 157 return toRenderSVGRoot(start); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 bool SVGRenderSupport::isOverflowHidden(const RenderObject* object) | 245 bool SVGRenderSupport::isOverflowHidden(const RenderObject* object) |
246 { | 246 { |
247 // RenderSVGRoot should never query for overflow state - it should always cl
ip itself to the initial viewport size. | 247 // RenderSVGRoot should never query for overflow state - it should always cl
ip itself to the initial viewport size. |
248 ASSERT(!object->isDocumentElement()); | 248 ASSERT(!object->isDocumentElement()); |
249 | 249 |
250 return object->style()->overflowX() == OHIDDEN || object->style()->overflowX
() == OSCROLL; | 250 return object->style()->overflowX() == OHIDDEN || object->style()->overflowX
() == OSCROLL; |
251 } | 251 } |
252 | 252 |
253 void SVGRenderSupport::intersectRepaintRectWithResources(const RenderObject* ren
derer, FloatRect& repaintRect) | 253 void SVGRenderSupport::intersectPaintInvalidationRectWithResources(const RenderO
bject* renderer, FloatRect& paintInvalidationRect) |
254 { | 254 { |
255 ASSERT(renderer); | 255 ASSERT(renderer); |
256 | 256 |
257 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
renderer); | 257 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
renderer); |
258 if (!resources) | 258 if (!resources) |
259 return; | 259 return; |
260 | 260 |
261 if (RenderSVGResourceFilter* filter = resources->filter()) | 261 if (RenderSVGResourceFilter* filter = resources->filter()) |
262 repaintRect = filter->resourceBoundingBox(renderer); | 262 paintInvalidationRect = filter->resourceBoundingBox(renderer); |
263 | 263 |
264 if (RenderSVGResourceClipper* clipper = resources->clipper()) | 264 if (RenderSVGResourceClipper* clipper = resources->clipper()) |
265 repaintRect.intersect(clipper->resourceBoundingBox(renderer)); | 265 paintInvalidationRect.intersect(clipper->resourceBoundingBox(renderer)); |
266 | 266 |
267 if (RenderSVGResourceMasker* masker = resources->masker()) | 267 if (RenderSVGResourceMasker* masker = resources->masker()) |
268 repaintRect.intersect(masker->resourceBoundingBox(renderer)); | 268 paintInvalidationRect.intersect(masker->resourceBoundingBox(renderer)); |
269 } | 269 } |
270 | 270 |
271 bool SVGRenderSupport::filtersForceContainerLayout(RenderObject* object) | 271 bool SVGRenderSupport::filtersForceContainerLayout(RenderObject* object) |
272 { | 272 { |
273 // If any of this container's children need to be laid out, and a filter is
applied | 273 // If any of this container's children need to be laid out, and a filter is
applied |
274 // to the container, we need to repaint the entire container. | 274 // to the container, we need to issue paint invalidations the entire contain
er. |
275 if (!object->normalChildNeedsLayout()) | 275 if (!object->normalChildNeedsLayout()) |
276 return false; | 276 return false; |
277 | 277 |
278 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
object); | 278 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
object); |
279 if (!resources || !resources->filter()) | 279 if (!resources || !resources->filter()) |
280 return false; | 280 return false; |
281 | 281 |
282 return true; | 282 return true; |
283 } | 283 } |
284 | 284 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 | 365 |
366 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) | 366 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) |
367 { | 367 { |
368 ASSERT(object->isText()); | 368 ASSERT(object->isText()); |
369 // <br> is marked as text, but is not handled by the SVG rendering code-path
. | 369 // <br> is marked as text, but is not handled by the SVG rendering code-path
. |
370 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty
Text(); | 370 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty
Text(); |
371 } | 371 } |
372 | 372 |
373 } | 373 } |
OLD | NEW |