1 /* 2 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann (at) kde.org> 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 #ifndef RenderSVGText_h 23 #define RenderSVGText_h 24 25 #if ENABLE(SVG) 26 27 #include "AffineTransform.h" 28 #include "RenderSVGBlock.h" 29 #include "SVGTextLayoutAttributes.h" 30 31 namespace WebCore { 32 33 class SVGTextElement; 34 35 class RenderSVGText : public RenderSVGBlock { 36 public: 37 RenderSVGText(SVGTextElement*); 38 39 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; 40 41 void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; } 42 virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; } 43 virtual FloatRect repaintRectInLocalCoordinates() const; 44 45 static RenderSVGText* locateRenderSVGTextAncestor(RenderObject*); 46 static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject*); 47 48 Vector<SVGTextLayoutAttributes>& layoutAttributes() { return m_layoutAttributes; } 49 bool needsReordering() const { return m_needsReordering; } 50 51 private: 52 virtual const char* renderName() const { return "RenderSVGText"; } 53 virtual bool isSVGText() const { return true; } 54 55 virtual void paint(PaintInfo&, int tx, int ty); 56 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); 57 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction); 58 virtual VisiblePosition positionForPoint(const IntPoint&); 59 60 virtual bool requiresLayer() const { return false; } 61 virtual void layout(); 62 63 virtual void absoluteQuads(Vector<FloatQuad>&); 64 65 virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer); 66 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false); 67 68 virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const; 69 70 virtual FloatRect objectBoundingBox() const { return frameRect(); } 71 virtual FloatRect strokeBoundingBox() const; 72 73 virtual const AffineTransform& localToParentTransform() const { return m_localTransform; } 74 virtual AffineTransform localTransform() const { return m_localTransform; } 75 virtual RootInlineBox* createRootInlineBox(); 76 77 virtual RenderBlock* firstLineBlock() const; 78 virtual void updateFirstLetter(); 79 80 bool m_needsReordering : 1; 81 bool m_needsPositioningValuesUpdate : 1; 82 bool m_needsTransformUpdate : 1; 83 AffineTransform m_localTransform; 84 Vector<SVGTextLayoutAttributes> m_layoutAttributes; 85 }; 86 87 inline RenderSVGText* toRenderSVGText(RenderObject* object) 88 { 89 ASSERT(!object || object->isSVGText()); 90 return static_cast<RenderSVGText*>(object); 91 } 92 93 inline const RenderSVGText* toRenderSVGText(const RenderObject* object) 94 { 95 ASSERT(!object || object->isSVGText()); 96 return static_cast<const RenderSVGText*>(object); 97 } 98 99 // This will catch anyone doing an unnecessary cast. 100 void toRenderSVGText(const RenderSVGText*); 101 102 } 103 104 #endif // ENABLE(SVG) 105 #endif 106