Home | History | Annotate | Download | only in rendering
      1 /*
      2  * This file is part of the WebKit project.
      3  *
      4  * Copyright (C) 2006 Oliver Hunt <ojh16 (at) student.canterbury.ac.nz>
      5  *           (C) 2006 Apple Computer Inc.
      6  *           (C) 2007 Nikolas Zimmermann <zimmermann (at) 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 #include "SVGRenderSupport.h"
     32 
     33 namespace WebCore {
     34 
     35 class InlineTextBox;
     36 class RenderSVGRoot;
     37 class SVGInlineTextBox;
     38 
     39 struct LastGlyphInfo {
     40     LastGlyphInfo() : isValid(false) { }
     41 
     42     String unicode;
     43     String glyphName;
     44     bool isValid;
     45 };
     46 
     47 class SVGRootInlineBox : public RootInlineBox, protected SVGRenderBase {
     48 public:
     49     SVGRootInlineBox(RenderObject* obj)
     50         : RootInlineBox(obj)
     51         , m_height(0)
     52     {
     53     }
     54     virtual const SVGRenderBase* toSVGRenderBase() const { return this; }
     55 
     56     virtual bool isSVGRootInlineBox() { return true; }
     57 
     58     virtual int virtualHeight() const { return m_height; }
     59     void setHeight(int h) { m_height = h; }
     60 
     61     virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
     62 
     63     virtual int placeBoxesHorizontally(int x, int& leftPosition, int& rightPosition, bool& needsWordSpacing);
     64     virtual int verticallyAlignBoxes(int heightOfBlock);
     65 
     66     virtual void computePerCharacterLayoutInformation();
     67 
     68     virtual FloatRect objectBoundingBox() const { return FloatRect(); }
     69     virtual FloatRect repaintRectInLocalCoordinates() const { return FloatRect(); }
     70 
     71     // Used by SVGInlineTextBox
     72     const Vector<SVGTextChunk>& svgTextChunks() const;
     73 
     74     void walkTextChunks(SVGTextChunkWalkerBase*, const SVGInlineTextBox* textBox = 0);
     75 
     76 private:
     77     friend struct SVGRootInlineBoxPaintWalker;
     78 
     79     void layoutInlineBoxes();
     80     void layoutInlineBoxes(InlineFlowBox* start, Vector<SVGChar>::iterator& it, int& minX, int& maxX, int& minY, int& maxY);
     81 
     82     void buildLayoutInformation(InlineFlowBox* start, SVGCharacterLayoutInfo&);
     83     void buildLayoutInformationForTextBox(SVGCharacterLayoutInfo&, InlineTextBox*, LastGlyphInfo&);
     84 
     85     void buildTextChunks(Vector<SVGChar>&, Vector<SVGTextChunk>&, InlineFlowBox* start);
     86     void buildTextChunks(Vector<SVGChar>&, InlineFlowBox* start, SVGTextChunkLayoutInfo&);
     87     void layoutTextChunks();
     88 
     89     SVGTextDecorationInfo retrievePaintServersForTextDecoration(RenderObject* start);
     90 
     91 private:
     92     int m_height;
     93     Vector<SVGChar> m_svgChars;
     94     Vector<SVGTextChunk> m_svgTextChunks;
     95 };
     96 
     97 // Shared with SVGRenderTreeAsText / SVGInlineTextBox
     98 TextRun svgTextRunForInlineTextBox(const UChar*, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos);
     99 FloatPoint topLeftPositionOfCharacterRange(Vector<SVGChar>::iterator start, Vector<SVGChar>::iterator end);
    100 float cummulatedWidthOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);
    101 float cummulatedHeightOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);
    102 
    103 RenderSVGRoot* findSVGRootObject(RenderObject* start);
    104 
    105 } // namespace WebCore
    106 
    107 #endif // ENABLE(SVG)
    108 
    109 #endif // SVGRootInlineBox_h
    110