1/* 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. 5 * 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. 10 * 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. 15 * 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. 20 */ 21 22#include "config.h" 23 24#if ENABLE(SVG) 25#include "RenderSVGInline.h" 26 27#include "RenderSVGInlineText.h" 28#include "RenderSVGResource.h" 29#include "RenderSVGText.h" 30#include "SVGInlineFlowBox.h" 31#include "SVGResourcesCache.h" 32 33namespace WebCore { 34 35RenderSVGInline::RenderSVGInline(Element* element) 36 : RenderInline(element) 37{ 38 setAlwaysCreateLineBoxes(); 39} 40 41InlineFlowBox* RenderSVGInline::createInlineFlowBox() 42{ 43 InlineFlowBox* box = new (renderArena()) SVGInlineFlowBox(this); 44 box->setHasVirtualLogicalHeight(); 45 return box; 46} 47 48FloatRect RenderSVGInline::objectBoundingBox() const 49{ 50 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this)) 51 return object->objectBoundingBox(); 52 53 return FloatRect(); 54} 55 56FloatRect RenderSVGInline::strokeBoundingBox() const 57{ 58 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this)) 59 return object->strokeBoundingBox(); 60 61 return FloatRect(); 62} 63 64FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const 65{ 66 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this)) 67 return object->repaintRectInLocalCoordinates(); 68 69 return FloatRect(); 70} 71 72LayoutRect RenderSVGInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const 73{ 74 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); 75} 76 77void RenderSVGInline::computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const 78{ 79 SVGRenderSupport::computeFloatRectForRepaint(this, repaintContainer, repaintRect, fixed); 80} 81 82void RenderSVGInline::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed) const 83{ 84 SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed); 85} 86 87const RenderObject* RenderSVGInline::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const 88{ 89 return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap); 90} 91 92void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const 93{ 94 const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this); 95 if (!object) 96 return; 97 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)); 101} 102 103void RenderSVGInline::willBeDestroyed() 104{ 105 SVGResourcesCache::clientDestroyed(this); 106 RenderInline::willBeDestroyed(); 107} 108 109void RenderSVGInline::styleWillChange(StyleDifference diff, const RenderStyle* newStyle) 110{ 111 if (diff == StyleDifferenceLayout) 112 setNeedsBoundariesUpdate(); 113 RenderInline::styleWillChange(diff, newStyle); 114} 115 116void RenderSVGInline::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 117{ 118 RenderInline::styleDidChange(diff, oldStyle); 119 SVGResourcesCache::clientStyleChanged(this, diff, style()); 120} 121 122void RenderSVGInline::addChild(RenderObject* child, RenderObject* beforeChild) 123{ 124 RenderInline::addChild(child, beforeChild); 125 SVGResourcesCache::clientWasAddedToTree(child, child->style()); 126 127 if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this)) 128 textRenderer->subtreeChildWasAdded(child); 129} 130 131void RenderSVGInline::removeChild(RenderObject* child) 132{ 133 SVGResourcesCache::clientWillBeRemovedFromTree(child); 134 135 RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this); 136 if (!textRenderer) { 137 RenderInline::removeChild(child); 138 return; 139 } 140 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; 141 textRenderer->subtreeChildWillBeRemoved(child, affectedAttributes); 142 RenderInline::removeChild(child); 143 textRenderer->subtreeChildWasRemoved(affectedAttributes); 144} 145 146} 147 148#endif // ENABLE(SVG) 149