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.
24 #include "core/rendering/svg/RenderSVGInline.h"
27 #include "core/rendering/svg/RenderSVGText.h"
28 #include "core/rendering/svg/SVGInlineFlowBox.h"
29 #include "core/rendering/svg/SVGRenderSupport.h"
30 #include "core/rendering/svg/SVGResourcesCache.h"
31 #include "core/svg/SVGAElement.h"
35 bool RenderSVGInline::isChildAllowed(RenderObject* child, RenderStyle* style) const
38 return SVGRenderSupport::isRenderableTextNode(child);
40 if (isSVGAElement(*node())) {
41 // Disallow direct descendant 'a'.
42 if (isSVGAElement(*child->node()))
46 if (!child->isSVGInline() && !child->isSVGInlineText())
49 return RenderInline::isChildAllowed(child, style);
52 RenderSVGInline::RenderSVGInline(Element* element)
53 : RenderInline(element)
55 setAlwaysCreateLineBoxes();
58 InlineFlowBox* RenderSVGInline::createInlineFlowBox()
60 InlineFlowBox* box = new SVGInlineFlowBox(*this);
61 box->setHasVirtualLogicalHeight();
65 FloatRect RenderSVGInline::objectBoundingBox() const
67 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
68 return object->objectBoundingBox();
73 FloatRect RenderSVGInline::strokeBoundingBox() const
75 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
76 return object->strokeBoundingBox();
81 FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const
83 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
84 return object->repaintRectInLocalCoordinates();
89 LayoutRect RenderSVGInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
91 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
94 void RenderSVGInline::computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const
96 SVGRenderSupport::computeFloatRectForRepaint(this, repaintContainer, repaintRect, fixed);
99 void RenderSVGInline::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed) const
101 SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
104 const RenderObject* RenderSVGInline::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
106 return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap);
109 void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
111 const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this);
115 FloatRect textBoundingBox = object->strokeBoundingBox();
116 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
117 quads.append(localToAbsoluteQuad(FloatRect(textBoundingBox.x() + box->x(), textBoundingBox.y() + box->y(), box->logicalWidth(), box->logicalHeight()), false, wasFixed));
120 void RenderSVGInline::willBeDestroyed()
122 SVGResourcesCache::clientDestroyed(this);
123 RenderInline::willBeDestroyed();
126 void RenderSVGInline::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
128 if (diff.needsFullLayout())
129 setNeedsBoundariesUpdate();
131 RenderInline::styleDidChange(diff, oldStyle);
132 SVGResourcesCache::clientStyleChanged(this, diff, style());
135 void RenderSVGInline::addChild(RenderObject* child, RenderObject* beforeChild)
137 RenderInline::addChild(child, beforeChild);
138 SVGResourcesCache::clientWasAddedToTree(child, child->style());
140 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
141 textRenderer->subtreeChildWasAdded(child);
144 void RenderSVGInline::removeChild(RenderObject* child)
146 SVGResourcesCache::clientWillBeRemovedFromTree(child);
148 RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this);
150 RenderInline::removeChild(child);
153 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
154 textRenderer->subtreeChildWillBeRemoved(child, affectedAttributes);
155 RenderInline::removeChild(child);
156 textRenderer->subtreeChildWasRemoved(affectedAttributes);