Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      4  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. 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 
     23 #ifndef RenderInline_h
     24 #define RenderInline_h
     25 
     26 #include "InlineFlowBox.h"
     27 #include "RenderBoxModelObject.h"
     28 #include "RenderLineBoxList.h"
     29 
     30 namespace WebCore {
     31 
     32 class Position;
     33 
     34 class RenderInline : public RenderBoxModelObject {
     35 public:
     36     explicit RenderInline(Node*);
     37 
     38     virtual void destroy();
     39 
     40     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
     41 
     42     virtual int marginLeft() const;
     43     virtual int marginRight() const;
     44     virtual int marginTop() const;
     45     virtual int marginBottom() const;
     46     virtual int marginBefore() const;
     47     virtual int marginAfter() const;
     48     virtual int marginStart() const;
     49     virtual int marginEnd() const;
     50 
     51     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
     52     virtual void absoluteQuads(Vector<FloatQuad>&);
     53 
     54     virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
     55 
     56     IntRect linesBoundingBox() const;
     57     IntRect linesVisualOverflowBoundingBox() const;
     58 
     59     InlineFlowBox* createAndAppendInlineFlowBox();
     60 
     61     void dirtyLineBoxes(bool fullLayout);
     62 
     63     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
     64     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
     65 
     66     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
     67     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
     68     InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
     69     InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
     70 
     71     virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
     72     RenderInline* inlineElementContinuation() const;
     73 
     74     virtual void updateDragState(bool dragOn);
     75 
     76     IntSize relativePositionedInlineOffset(const RenderBox* child) const;
     77 
     78     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
     79     void paintOutline(GraphicsContext*, int tx, int ty);
     80 
     81     using RenderBoxModelObject::continuation;
     82     using RenderBoxModelObject::setContinuation;
     83 
     84     bool alwaysCreateLineBoxes() const { return m_alwaysCreateLineBoxes; }
     85     void setAlwaysCreateLineBoxes() { m_alwaysCreateLineBoxes = true; }
     86     void updateAlwaysCreateLineBoxes();
     87 
     88 protected:
     89     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     90 
     91 private:
     92     virtual RenderObjectChildList* virtualChildren() { return children(); }
     93     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
     94     const RenderObjectChildList* children() const { return &m_children; }
     95     RenderObjectChildList* children() { return &m_children; }
     96 
     97     virtual const char* renderName() const;
     98 
     99     virtual bool isRenderInline() const { return true; }
    100 
    101     FloatRect culledInlineBoundingBox(const RenderInline* container) const;
    102     IntRect culledInlineVisualOverflowBoundingBox() const;
    103     InlineBox* culledInlineFirstLineBox() const;
    104     InlineBox* culledInlineLastLineBox() const;
    105     void culledInlineAbsoluteRects(const RenderInline* container, Vector<IntRect>&, const IntSize&);
    106     void culledInlineAbsoluteQuads(const RenderInline* container, Vector<FloatQuad>&);
    107 
    108     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
    109     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
    110 
    111     void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
    112                       RenderObject* beforeChild, RenderBoxModelObject* oldCont);
    113     void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
    114                    RenderObject* newChild, RenderBoxModelObject* oldCont);
    115 
    116     virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
    117 
    118     virtual void paint(PaintInfo&, int tx, int ty);
    119 
    120     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    121 
    122     virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
    123 
    124     virtual int offsetLeft() const;
    125     virtual int offsetTop() const;
    126     virtual int offsetWidth() const { return linesBoundingBox().width(); }
    127     virtual int offsetHeight() const { return linesBoundingBox().height(); }
    128 
    129     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
    130     virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
    131     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed);
    132 
    133     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&) const;
    134     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
    135 
    136     virtual VisiblePosition positionForPoint(const IntPoint&);
    137 
    138     virtual IntRect borderBoundingBox() const
    139     {
    140         IntRect boundingBox = linesBoundingBox();
    141         return IntRect(0, 0, boundingBox.width(), boundingBox.height());
    142     }
    143 
    144     virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
    145 
    146     virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
    147 
    148     virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    149     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    150 
    151     virtual void childBecameNonInline(RenderObject* child);
    152 
    153     virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
    154 
    155     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
    156 
    157 #if ENABLE(DASHBOARD_SUPPORT)
    158     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
    159 #endif
    160 
    161     virtual void updateBoxModelInfoFromStyle();
    162 
    163     static RenderInline* cloneInline(RenderInline* src);
    164 
    165     void paintOutlineForLine(GraphicsContext*, int tx, int ty, const IntRect& prevLine, const IntRect& thisLine, const IntRect& nextLine);
    166     RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
    167 
    168     RenderObjectChildList m_children;
    169     RenderLineBoxList m_lineBoxes;   // All of the line boxes created for this inline flow.  For example, <i>Hello<br>world.</i> will have two <i> line boxes.
    170 
    171     mutable int m_lineHeight : 31;
    172     bool m_alwaysCreateLineBoxes : 1;
    173 };
    174 
    175 inline RenderInline* toRenderInline(RenderObject* object)
    176 {
    177     ASSERT(!object || object->isRenderInline());
    178     return static_cast<RenderInline*>(object);
    179 }
    180 
    181 inline const RenderInline* toRenderInline(const RenderObject* object)
    182 {
    183     ASSERT(!object || object->isRenderInline());
    184     return static_cast<const RenderInline*>(object);
    185 }
    186 
    187 // This will catch anyone doing an unnecessary cast.
    188 void toRenderInline(const RenderInline*);
    189 
    190 } // namespace WebCore
    191 
    192 #endif // RenderInline_h
    193