• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the WebKit project.
3  *
4  * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
5  *           (C) 2006 Apple Computer Inc.
6  *           (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 
25 #ifndef SVGRootInlineBox_h
26 #define SVGRootInlineBox_h
27 
28 #if ENABLE(SVG)
29 #include "RootInlineBox.h"
30 #include "SVGCharacterLayoutInfo.h"
31 
32 namespace WebCore {
33 
34 class InlineTextBox;
35 class RenderSVGRoot;
36 class SVGInlineTextBox;
37 
38 struct LastGlyphInfo {
LastGlyphInfoLastGlyphInfo39     LastGlyphInfo() : isValid(false) { }
40 
41     String unicode;
42     String glyphName;
43     bool isValid;
44 };
45 
46 class SVGRootInlineBox : public RootInlineBox {
47 public:
SVGRootInlineBox(RenderObject * obj)48     SVGRootInlineBox(RenderObject* obj)
49         : RootInlineBox(obj)
50         , m_height(0)
51     {
52     }
53 
isSVGRootInlineBox()54     virtual bool isSVGRootInlineBox() { return true; }
55 
virtualHeight()56     virtual int virtualHeight() const { return m_height; }
setHeight(int h)57     void setHeight(int h) { m_height = h; }
58 
59     virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
60 
61     virtual int placeBoxesHorizontally(int x, int& leftPosition, int& rightPosition, bool& needsWordSpacing);
62     virtual int verticallyAlignBoxes(int heightOfBlock);
63 
64     virtual void computePerCharacterLayoutInformation();
65 
66     // Used by SVGInlineTextBox
67     const Vector<SVGTextChunk>& svgTextChunks() const;
68 
69     void walkTextChunks(SVGTextChunkWalkerBase*, const SVGInlineTextBox* textBox = 0);
70 
71 private:
72     friend struct SVGRootInlineBoxPaintWalker;
73 
74     void layoutInlineBoxes();
75     void layoutInlineBoxes(InlineFlowBox* start, Vector<SVGChar>::iterator& it, int& minX, int& maxX, int& minY, int& maxY);
76 
77     void buildLayoutInformation(InlineFlowBox* start, SVGCharacterLayoutInfo&);
78     void buildLayoutInformationForTextBox(SVGCharacterLayoutInfo&, InlineTextBox*, LastGlyphInfo&);
79 
80     void buildTextChunks(Vector<SVGChar>&, Vector<SVGTextChunk>&, InlineFlowBox* start);
81     void buildTextChunks(Vector<SVGChar>&, InlineFlowBox* start, SVGTextChunkLayoutInfo&);
82     void layoutTextChunks();
83 
84     SVGTextDecorationInfo retrievePaintServersForTextDecoration(RenderObject* start);
85 
86 private:
87     int m_height;
88     Vector<SVGChar> m_svgChars;
89     Vector<SVGTextChunk> m_svgTextChunks;
90 };
91 
92 // Shared with SVGRenderTreeAsText / SVGInlineTextBox
93 TextRun svgTextRunForInlineTextBox(const UChar*, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos);
94 FloatPoint topLeftPositionOfCharacterRange(Vector<SVGChar>::iterator start, Vector<SVGChar>::iterator end);
95 float cummulatedWidthOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);
96 float cummulatedHeightOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);
97 
98 RenderSVGRoot* findSVGRootObject(RenderObject* start);
99 
100 } // namespace WebCore
101 
102 #endif // ENABLE(SVG)
103 
104 #endif // SVGRootInlineBox_h
105