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, 2009 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 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. | 5 * Copyright (C) 2009 Google, Inc. |
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
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 | 25 |
26 #include "core/rendering/svg/RenderSVGRoot.h" | 26 #include "core/rendering/svg/RenderSVGRoot.h" |
27 | 27 |
28 #include "core/frame/LocalFrame.h" | 28 #include "core/frame/LocalFrame.h" |
| 29 #include "core/paint/SVGRootPainter.h" |
29 #include "core/rendering/HitTestResult.h" | 30 #include "core/rendering/HitTestResult.h" |
30 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
31 #include "core/rendering/RenderPart.h" | 32 #include "core/rendering/RenderPart.h" |
32 #include "core/rendering/RenderView.h" | 33 #include "core/rendering/RenderView.h" |
33 #include "core/rendering/svg/RenderSVGResourceContainer.h" | |
34 #include "core/rendering/svg/SVGRenderSupport.h" | 34 #include "core/rendering/svg/SVGRenderSupport.h" |
35 #include "core/rendering/svg/SVGRenderingContext.h" | |
36 #include "core/rendering/svg/SVGResources.h" | |
37 #include "core/rendering/svg/SVGResourcesCache.h" | 35 #include "core/rendering/svg/SVGResourcesCache.h" |
38 #include "core/svg/SVGElement.h" | 36 #include "core/svg/SVGElement.h" |
39 #include "core/svg/SVGSVGElement.h" | 37 #include "core/svg/SVGSVGElement.h" |
40 #include "core/svg/graphics/SVGImage.h" | 38 #include "core/svg/graphics/SVGImage.h" |
41 #include "platform/LengthFunctions.h" | 39 #include "platform/LengthFunctions.h" |
42 #include "platform/graphics/GraphicsContext.h" | |
43 | 40 |
44 namespace blink { | 41 namespace blink { |
45 | 42 |
46 RenderSVGRoot::RenderSVGRoot(SVGElement* node) | 43 RenderSVGRoot::RenderSVGRoot(SVGElement* node) |
47 : RenderReplaced(node) | 44 : RenderReplaced(node) |
48 , m_objectBoundingBoxValid(false) | 45 , m_objectBoundingBoxValid(false) |
49 , m_isLayoutSizeChanged(false) | 46 , m_isLayoutSizeChanged(false) |
50 , m_needsBoundariesOrTransformUpdate(true) | 47 , m_needsBoundariesOrTransformUpdate(true) |
51 , m_hasBoxDecorationBackground(false) | 48 , m_hasBoxDecorationBackground(false) |
52 { | 49 { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // When the svg is stand-alone (isDocumentElement() == true) the viewport cl
ipping should always | 207 // When the svg is stand-alone (isDocumentElement() == true) the viewport cl
ipping should always |
211 // be applied, noting that the window scrollbars should be hidden if overflo
w=hidden. | 208 // be applied, noting that the window scrollbars should be hidden if overflo
w=hidden. |
212 return style()->overflowX() == OHIDDEN | 209 return style()->overflowX() == OHIDDEN |
213 || style()->overflowX() == OAUTO | 210 || style()->overflowX() == OAUTO |
214 || style()->overflowX() == OSCROLL | 211 || style()->overflowX() == OSCROLL |
215 || this->isDocumentElement(); | 212 || this->isDocumentElement(); |
216 } | 213 } |
217 | 214 |
218 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint
Offset) | 215 void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint
Offset) |
219 { | 216 { |
220 // An empty viewport disables rendering. | 217 SVGRootPainter(*this).paint(paintInfo, paintOffset); |
221 if (pixelSnappedBorderBoxRect().isEmpty()) | |
222 return; | |
223 | |
224 // SVG outlines are painted during PaintPhaseForeground. | |
225 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSel
fOutline) | |
226 return; | |
227 | |
228 // An empty viewBox also disables rendering. | |
229 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) | |
230 SVGSVGElement* svg = toSVGSVGElement(node()); | |
231 ASSERT(svg); | |
232 if (svg->hasEmptyViewBox()) | |
233 return; | |
234 | |
235 // Don't paint if we don't have kids, except if we have filters we should pa
int those. | |
236 if (!firstChild()) { | |
237 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj
ect(this); | |
238 if (!resources || !resources->filter()) | |
239 return; | |
240 } | |
241 | |
242 // Make a copy of the PaintInfo because applyTransform will modify the damag
e rect. | |
243 PaintInfo childPaintInfo(paintInfo); | |
244 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); | |
245 | |
246 // Apply initial viewport clip | |
247 if (shouldApplyViewportClip()) | |
248 childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintO
ffset))); | |
249 | |
250 // Convert from container offsets (html renderers) to a relative transform (
svg renderers). | |
251 // Transform from our paint container's coordinate system to our local coord
s. | |
252 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); | |
253 childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffs
et.x(), adjustedPaintOffset.y()) * localToBorderBoxTransform()); | |
254 | |
255 SVGRenderingContext renderingContext; | |
256 if (childPaintInfo.phase == PaintPhaseForeground) { | |
257 renderingContext.prepareToRenderSVGContent(this, childPaintInfo); | |
258 if (!renderingContext.isRenderingPrepared()) | |
259 return; | |
260 } | |
261 | |
262 RenderBox::paint(childPaintInfo, LayoutPoint()); | |
263 } | 218 } |
264 | 219 |
265 void RenderSVGRoot::willBeDestroyed() | 220 void RenderSVGRoot::willBeDestroyed() |
266 { | 221 { |
267 RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this))
; | 222 RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this))
; |
268 | 223 |
269 SVGResourcesCache::clientDestroyed(this); | 224 SVGResourcesCache::clientDestroyed(this); |
270 RenderReplaced::willBeDestroyed(); | 225 RenderReplaced::willBeDestroyed(); |
271 } | 226 } |
272 | 227 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 updateHitTestResult(result, pointInBorderBox); | 402 updateHitTestResult(result, pointInBorderBox); |
448 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn
Container, boundsRect)) | 403 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn
Container, boundsRect)) |
449 return true; | 404 return true; |
450 } | 405 } |
451 } | 406 } |
452 | 407 |
453 return false; | 408 return false; |
454 } | 409 } |
455 | 410 |
456 } | 411 } |
OLD | NEW |