File indexing completed on 2024-04-28 15:24:21
0001 /* 0002 * This file is part of the WebKit project. 0003 * 0004 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 0005 * (C) 2006 Apple Computer Inc. 0006 * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 0007 * 0008 * This library is free software; you can redistribute it and/or 0009 * modify it under the terms of the GNU Library General Public 0010 * License as published by the Free Software Foundation; either 0011 * version 2 of the License, or (at your option) any later version. 0012 * 0013 * This library is distributed in the hope that it will be useful, 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 * Library General Public License for more details. 0017 * 0018 * You should have received a copy of the GNU Library General Public License 0019 * along with this library; see the file COPYING.LIB. If not, write to 0020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 * Boston, MA 02110-1301, USA. 0022 * 0023 */ 0024 0025 #ifndef SVGRootInlineBox_h 0026 #define SVGRootInlineBox_h 0027 0028 #if ENABLE(SVG) 0029 #include "rendering/render_line.h" // RootInlineBox 0030 #include "SVGCharacterLayoutInfo.h" 0031 #include "rendering/render_text.h" 0032 0033 namespace WebCore 0034 { 0035 0036 using namespace khtml; 0037 0038 //class InlineTextBox; 0039 class RenderSVGRoot; 0040 class SVGInlineTextBox; 0041 0042 struct LastGlyphInfo { 0043 LastGlyphInfo() : isValid(false) { } 0044 0045 String unicode; 0046 String glyphName; 0047 bool isValid; 0048 }; 0049 0050 class SVGRootInlineBox : public RootInlineBox 0051 { 0052 public: 0053 SVGRootInlineBox(RenderObject *obj) 0054 : RootInlineBox(obj) 0055 { 0056 } 0057 0058 bool isSVGRootInlineBox() const override 0059 { 0060 return true; 0061 } 0062 0063 void paint(RenderObject::PaintInfo &, int tx, int ty) override; 0064 0065 virtual int placeBoxesHorizontally(int x, int &leftPosition, int &rightPosition, bool &needsWordSpacing); 0066 virtual void verticallyAlignBoxes(int &heightOfBlock); 0067 0068 virtual void computePerCharacterLayoutInformation(); 0069 0070 // Used by SVGInlineTextBox 0071 const Vector<SVGTextChunk> &svgTextChunks() const; 0072 0073 void walkTextChunks(SVGTextChunkWalkerBase *, const SVGInlineTextBox *textBox = nullptr); 0074 0075 private: 0076 friend struct SVGRootInlineBoxPaintWalker; 0077 0078 void layoutInlineBoxes(); 0079 void layoutInlineBoxes(InlineFlowBox *start, Vector<SVGChar>::iterator &it, int &minX, int &maxX, int &minY, int &maxY); 0080 0081 void buildLayoutInformation(InlineFlowBox *start, SVGCharacterLayoutInfo &); 0082 void buildLayoutInformationForTextBox(SVGCharacterLayoutInfo &, InlineTextBox *, LastGlyphInfo &); 0083 0084 void buildTextChunks(Vector<SVGChar> &, Vector<SVGTextChunk> &, InlineFlowBox *start); 0085 void buildTextChunks(Vector<SVGChar> &, InlineFlowBox *start, SVGTextChunkLayoutInfo &); 0086 void layoutTextChunks(); 0087 0088 SVGTextDecorationInfo retrievePaintServersForTextDecoration(RenderObject *start); 0089 0090 private: 0091 Vector<SVGChar> m_svgChars; 0092 Vector<SVGTextChunk> m_svgTextChunks; 0093 }; 0094 0095 // Shared with SVGRenderTreeAsText / SVGInlineTextBox 0096 /*khtml TextRun svgTextRunForInlineTextBox(const UChar*, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos);*/ 0097 FloatPoint topLeftPositionOfCharacterRange(Vector<SVGChar>::iterator start, Vector<SVGChar>::iterator end); 0098 float cummulatedWidthOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange &range); 0099 float cummulatedHeightOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange &range); 0100 0101 RenderSVGRoot *findSVGRootObject(RenderObject *start); 0102 0103 } // namespace WebCore 0104 0105 #endif // ENABLE(SVG) 0106 0107 #endif // SVGRootInlineBox_h