1 /*
2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2008 Rob Buis <buis@kde.org>
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 RenderSVGInlineText_h
23 #define RenderSVGInlineText_h
24
25 #if ENABLE(SVG)
26 #include "RenderText.h"
27 #include "SVGTextLayoutAttributes.h"
28
29 namespace WebCore {
30
31 class SVGInlineTextBox;
32
33 class RenderSVGInlineText : public RenderText {
34 public:
35 RenderSVGInlineText(Node*, PassRefPtr<StringImpl>);
36
37 bool characterStartsNewTextChunk(int position) const;
38
layoutAttributes()39 SVGTextLayoutAttributes& layoutAttributes() { return m_attributes; }
layoutAttributes()40 const SVGTextLayoutAttributes& layoutAttributes() const { return m_attributes; }
storeLayoutAttributes(const SVGTextLayoutAttributes & attributes)41 void storeLayoutAttributes(const SVGTextLayoutAttributes& attributes) { m_attributes = attributes; }
42
scalingFactor()43 float scalingFactor() const { return m_scalingFactor; }
scaledFont()44 const Font& scaledFont() const { return m_scaledFont; }
45 void updateScaledFont();
46 static void computeNewScaledFontForStyle(RenderObject*, const RenderStyle*, float& scalingFactor, Font& scaledFont);
47
48 private:
renderName()49 virtual const char* renderName() const { return "RenderSVGInlineText"; }
50
51 virtual void destroy();
52 virtual void styleDidChange(StyleDifference, const RenderStyle*);
53
54 // FIXME: We need objectBoundingBox for DRT results and filters at the moment.
55 // This should be fixed to give back the objectBoundingBox of the text root.
objectBoundingBox()56 virtual FloatRect objectBoundingBox() const { return FloatRect(); }
57
requiresLayer()58 virtual bool requiresLayer() const { return false; }
isSVGInlineText()59 virtual bool isSVGInlineText() const { return true; }
60
61 virtual VisiblePosition positionForPoint(const IntPoint&);
62 virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
63 virtual IntRect linesBoundingBox() const;
64 virtual InlineTextBox* createTextBox();
65
66 float m_scalingFactor;
67 Font m_scaledFont;
68 SVGTextLayoutAttributes m_attributes;
69 };
70
toRenderSVGInlineText(RenderObject * object)71 inline RenderSVGInlineText* toRenderSVGInlineText(RenderObject* object)
72 {
73 ASSERT(!object || object->isSVGInlineText());
74 return static_cast<RenderSVGInlineText*>(object);
75 }
76
toRenderSVGInlineText(const RenderObject * object)77 inline const RenderSVGInlineText* toRenderSVGInlineText(const RenderObject* object)
78 {
79 ASSERT(!object || object->isSVGInlineText());
80 return static_cast<const RenderSVGInlineText*>(object);
81 }
82
83 // This will catch anyone doing an unnecessary cast.
84 void toRenderSVGInlineText(const RenderSVGInlineText*);
85
86 }
87
88 #endif // ENABLE(SVG)
89 #endif // RenderSVGInlineText_h
90