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 "RenderBoxModelObject.h"
     27 #include "RenderLineBoxList.h"
     28 
     29 namespace WebCore {
     30 
     31 class Position;
     32 
     33 class RenderInline : public RenderBoxModelObject {
     34 public:
     35     RenderInline(Node*);
     36 
     37     virtual void destroy();
     38 
     39     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
     40 
     41     virtual int marginLeft() const;
     42     virtual int marginRight() const;
     43 
     44     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
     45     virtual void absoluteQuads(Vector<FloatQuad>&);
     46 
     47     virtual IntSize offsetFromContainer(RenderObject*) const;
     48 
     49     IntRect linesBoundingBox() const;
     50     IntRect linesVisibleOverflowBoundingBox() const;
     51 
     52     InlineFlowBox* createAndAppendInlineFlowBox();
     53 
     54     void dirtyLineBoxes(bool fullLayout);
     55 
     56     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
     57     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
     58 
     59     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
     60     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
     61 
     62     RenderBoxModelObject* continuation() const { return m_continuation; }
     63 
     64     virtual void updateDragState(bool dragOn);
     65 
     66     IntSize relativePositionedInlineOffset(const RenderBox* child) const;
     67 
     68     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
     69     void paintOutline(GraphicsContext*, int tx, int ty);
     70 
     71     int verticalPositionFromCache(bool firstLine) const;
     72     void invalidateVerticalPosition() { m_verticalPosition = PositionUndefined; }
     73 
     74 private:
     75     virtual RenderObjectChildList* virtualChildren() { return children(); }
     76     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
     77     const RenderObjectChildList* children() const { return &m_children; }
     78     RenderObjectChildList* children() { return &m_children; }
     79 
     80     virtual const char* renderName() const;
     81 
     82     virtual bool isRenderInline() const { return true; }
     83 
     84     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
     85     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
     86 
     87     void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
     88                       RenderObject* beforeChild, RenderBoxModelObject* oldCont);
     89     void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
     90                    RenderObject* newChild, RenderBoxModelObject* oldCont);
     91 
     92     virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
     93 
     94     virtual void paint(PaintInfo&, int tx, int ty);
     95 
     96     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
     97 
     98     virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
     99 
    100     virtual int offsetLeft() const;
    101     virtual int offsetTop() const;
    102     virtual int offsetWidth() const { return linesBoundingBox().width(); }
    103     virtual int offsetHeight() const { return linesBoundingBox().height(); }
    104 
    105     // Just ignore top/bottom margins on RenderInlines.
    106     virtual int marginTop() const { return 0; }
    107     virtual int marginBottom() const { return 0; }
    108     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
    109     virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
    110     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed);
    111 
    112     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&) const;
    113     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
    114 
    115     virtual VisiblePosition positionForPoint(const IntPoint&);
    116 
    117     virtual IntRect borderBoundingBox() const
    118     {
    119         IntRect boundingBox = linesBoundingBox();
    120         return IntRect(0, 0, boundingBox.width(), boundingBox.height());
    121     }
    122 
    123     virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
    124 
    125     virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
    126 
    127     virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
    128 
    129     RenderInline* inlineContinuation() const;
    130     void setContinuation(RenderBoxModelObject* c) { m_continuation = c; }
    131 
    132     virtual void childBecameNonInline(RenderObject* child);
    133 
    134     virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
    135 
    136     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
    137 
    138 #if ENABLE(DASHBOARD_SUPPORT)
    139     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
    140 #endif
    141 
    142     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
    143     virtual void updateBoxModelInfoFromStyle();
    144 
    145     static RenderInline* cloneInline(RenderInline* src);
    146 
    147     void paintOutlineForLine(GraphicsContext*, int tx, int ty, const IntRect& prevLine, const IntRect& thisLine, const IntRect& nextLine);
    148     RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
    149 
    150     RenderObjectChildList m_children;
    151     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.
    152 
    153     RenderBoxModelObject* m_continuation; // Can be either a block or an inline. <b><i><p>Hello</p></i></b>. In this example the <i> will have a block as its continuation but the
    154                                           // <b> will just have an inline as its continuation.
    155     mutable int m_lineHeight;
    156     mutable int m_verticalPosition;
    157 };
    158 
    159 inline RenderInline* toRenderInline(RenderObject* object)
    160 {
    161     ASSERT(!object || object->isRenderInline());
    162     return static_cast<RenderInline*>(object);
    163 }
    164 
    165 inline const RenderInline* toRenderInline(const RenderObject* object)
    166 {
    167     ASSERT(!object || object->isRenderInline());
    168     return static_cast<const RenderInline*>(object);
    169 }
    170 
    171 // This will catch anyone doing an unnecessary cast.
    172 void toRenderInline(const RenderInline*);
    173 
    174 } // namespace WebCore
    175 
    176 #endif // RenderInline_h
    177