2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006 Apple Inc. All rights reserved.
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #include "RenderSVGInline.h"
27 #include "RenderSVGInlineText.h"
28 #include "RenderSVGResource.h"
29 #include "RenderSVGText.h"
30 #include "SVGInlineFlowBox.h"
31 #include "SVGResourcesCache.h"
35 RenderSVGInline::RenderSVGInline(SVGGraphicsElement& element)
36 : RenderInline(element)
38 setAlwaysCreateLineBoxes();
41 InlineFlowBox* RenderSVGInline::createInlineFlowBox()
43 InlineFlowBox* box = new (renderArena()) SVGInlineFlowBox(*this);
44 box->setHasVirtualLogicalHeight();
48 FloatRect RenderSVGInline::objectBoundingBox() const
50 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
51 return object->objectBoundingBox();
56 FloatRect RenderSVGInline::strokeBoundingBox() const
58 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
59 return object->strokeBoundingBox();
64 FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const
66 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
67 return object->repaintRectInLocalCoordinates();
72 LayoutRect RenderSVGInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
74 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
77 void RenderSVGInline::computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const
79 SVGRenderSupport::computeFloatRectForRepaint(this, repaintContainer, repaintRect, fixed);
82 void RenderSVGInline::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed) const
84 SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
87 const RenderObject* RenderSVGInline::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
89 return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap);
92 void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
94 const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this);
98 FloatRect textBoundingBox = object->strokeBoundingBox();
99 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
100 quads.append(localToAbsoluteQuad(FloatRect(textBoundingBox.x() + box->x(), textBoundingBox.y() + box->y(), box->logicalWidth(), box->logicalHeight()), false, wasFixed));
103 void RenderSVGInline::willBeDestroyed()
105 SVGResourcesCache::clientDestroyed(this);
106 RenderInline::willBeDestroyed();
109 void RenderSVGInline::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
111 if (diff == StyleDifferenceLayout)
112 setNeedsBoundariesUpdate();
113 RenderInline::styleDidChange(diff, oldStyle);
114 SVGResourcesCache::clientStyleChanged(this, diff, style());
117 void RenderSVGInline::addChild(RenderObject* child, RenderObject* beforeChild)
119 RenderInline::addChild(child, beforeChild);
120 SVGResourcesCache::clientWasAddedToTree(child, child->style());
122 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
123 textRenderer->subtreeChildWasAdded(child);
126 void RenderSVGInline::removeChild(RenderObject& child)
128 SVGResourcesCache::clientWillBeRemovedFromTree(&child);
130 RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this);
132 RenderInline::removeChild(child);
135 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
136 textRenderer->subtreeChildWillBeRemoved(&child, affectedAttributes);
137 RenderInline::removeChild(child);
138 textRenderer->subtreeChildWasRemoved(affectedAttributes);
143 #endif // ENABLE(SVG)