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 "RenderSVGResource.h" 28#include "RenderSVGText.h" 29#include "SVGInlineFlowBox.h" 30 31namespace WebCore { 32 33RenderSVGInline::RenderSVGInline(Node* n) 34 : RenderInline(n) 35{ 36 setAlwaysCreateLineBoxes(); 37} 38 39InlineFlowBox* RenderSVGInline::createInlineFlowBox() 40{ 41 InlineFlowBox* box = new (renderArena()) SVGInlineFlowBox(this); 42 box->setHasVirtualLogicalHeight(); 43 return box; 44} 45 46FloatRect RenderSVGInline::objectBoundingBox() const 47{ 48 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this)) 49 return object->objectBoundingBox(); 50 51 return FloatRect(); 52} 53 54FloatRect RenderSVGInline::strokeBoundingBox() const 55{ 56 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this)) 57 return object->strokeBoundingBox(); 58 59 return FloatRect(); 60} 61 62FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const 63{ 64 if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this)) 65 return object->repaintRectInLocalCoordinates(); 66 67 return FloatRect(); 68} 69 70IntRect RenderSVGInline::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) 71{ 72 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer); 73} 74 75void RenderSVGInline::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed) 76{ 77 SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed); 78} 79 80void RenderSVGInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState& transformState) const 81{ 82 SVGRenderSupport::mapLocalToContainer(this, repaintContainer, useTransforms, fixed, transformState); 83} 84 85void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads) 86{ 87 RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this); 88 if (!object) 89 return; 90 91 FloatRect textBoundingBox = object->strokeBoundingBox(); 92 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) 93 quads.append(localToAbsoluteQuad(FloatRect(textBoundingBox.x() + box->x(), textBoundingBox.y() + box->y(), box->logicalWidth(), box->logicalHeight()))); 94} 95 96void RenderSVGInline::destroy() 97{ 98 SVGResourcesCache::clientDestroyed(this); 99 RenderInline::destroy(); 100} 101 102void RenderSVGInline::styleWillChange(StyleDifference diff, const RenderStyle* newStyle) 103{ 104 if (diff == StyleDifferenceLayout) 105 setNeedsBoundariesUpdate(); 106 RenderInline::styleWillChange(diff, newStyle); 107} 108 109void RenderSVGInline::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 110{ 111 RenderInline::styleDidChange(diff, oldStyle); 112 SVGResourcesCache::clientStyleChanged(this, diff, style()); 113} 114 115void RenderSVGInline::updateFromElement() 116{ 117 RenderInline::updateFromElement(); 118 SVGResourcesCache::clientUpdatedFromElement(this, style()); 119} 120 121 122} 123 124#endif // ENABLE(SVG) 125