~ubuntu-branches/ubuntu/maverick/webkit/maverick

1 by Mike Hommey
Import upstream version 0~svn25144
1
/*
2
 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4
 * Copyright (C) 2003, 2004, 2005, 2006, 2007 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., 59 Temple Place - Suite 330,
19
 * Boston, MA 02111-1307, USA.
20
 *
21
 */
22
23
#ifndef RenderFlow_h
24
#define RenderFlow_h
25
26
#include "RenderContainer.h"
27
28
namespace WebCore {
29
30
/**
31
 * all geometry managing stuff is only in the block elements.
32
 *
33
 * Inline elements don't layout themselves, but the whole paragraph
34
 * gets flowed by the surrounding block element. This is, because
35
 * one needs to know the whole paragraph to calculate bidirectional
36
 * behaviour of text, so putting the layouting routines in the inline
37
 * elements is impossible.
38
 */
39
class RenderFlow : public RenderContainer {
40
public:
41
    RenderFlow(Node* node)
42
        : RenderContainer(node)
43
        , m_continuation(0)
44
        , m_firstLineBox(0)
45
        , m_lastLineBox(0)
46
        , m_lineHeight(-1)
47
        , m_childrenInline(true)
48
        , m_firstLine(false)
49
        , m_clearStatus(CNONE)
50
        , m_topMarginQuirk(false) 
51
        , m_bottomMarginQuirk(false)
52
        , m_hasMarkupTruncation(false)
53
        , m_selectionState(SelectionNone)
54
        , m_hasColumns(false)
55
        , m_isContinuation(false)
56
    {
57
    }
58
#ifndef NDEBUG
59
    virtual ~RenderFlow();
60
#endif
61
62
    virtual RenderFlow* continuation() const { return m_continuation; }
63
    void setContinuation(RenderFlow* c) { m_continuation = c; }
64
    RenderFlow* continuationBefore(RenderObject* beforeChild);
65
66
    void addChildWithContinuation(RenderObject* newChild, RenderObject* beforeChild);
67
    virtual void addChildToFlow(RenderObject* newChild, RenderObject* beforeChild) = 0;
68
    virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
69
70
    static RenderFlow* createAnonymousFlow(Document*, RenderStyle*);
71
72
    void extractLineBox(InlineFlowBox*);
73
    void attachLineBox(InlineFlowBox*);
74
    void removeLineBox(InlineFlowBox*);
75
    void deleteLineBoxes();
76
    virtual void destroy();
77
78
    virtual void dirtyLinesFromChangedChild(RenderObject* child);
79
80
    virtual short lineHeight(bool firstLine, bool isRootLineBox = false) const;
81
82
    InlineFlowBox* firstLineBox() const { return m_firstLineBox; }
83
    InlineFlowBox* lastLineBox() const { return m_lastLineBox; }
84
85
    virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun=false);
86
    virtual void dirtyLineBoxes(bool fullLayout, bool isRootLineBox = false);
87
88
    void paintLines(PaintInfo&, int tx, int ty);
89
    bool hitTestLines(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
90
91
    virtual IntRect absoluteClippedOverflowRect();
92
93
    virtual int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
94
    virtual int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
95
    virtual int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
96
97
    virtual IntRect caretRect(int offset, EAffinity = UPSTREAM, int* extraWidthToEndOfLine = 0);
98
99
    virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
100
    void paintOutlineForLine(GraphicsContext*, int tx, int ty, const IntRect& prevLine, const IntRect& thisLine, const IntRect& nextLine);
101
    void paintOutline(GraphicsContext*, int tx, int ty);
102
103
    virtual bool hasColumns() const { return m_hasColumns; }
104
105
    virtual bool isWordBreak() const { ASSERT(isInlineFlow()); return false; }
106
107
    void checkConsistency() const;
108
109
private:
110
    // An inline can be split with blocks occurring in between the inline content.
111
    // When this occurs we need a pointer to our next object.  We can basically be
112
    // split into a sequence of inlines and blocks.  The continuation will either be
113
    // an anonymous block (that houses other blocks) or it will be an inline flow.
114
    RenderFlow* m_continuation;
115
116
protected:
117
    // For block flows, each box represents the root inline box for a line in the
118
    // paragraph.
119
    // For inline flows, each box represents a portion of that inline.
120
    InlineFlowBox* m_firstLineBox;
121
    InlineFlowBox* m_lastLineBox;
122
123
    mutable short m_lineHeight;
124
    
125
    // These bitfields are moved here from subclasses to pack them together
126
    // from RenderBlock
127
    bool m_childrenInline : 1;
128
    bool m_firstLine : 1;
129
    unsigned m_clearStatus  : 2; // EClear
130
    bool m_topMarginQuirk : 1;
131
    bool m_bottomMarginQuirk : 1;
132
    bool m_hasMarkupTruncation : 1;
133
    unsigned m_selectionState : 3; // SelectionState
134
    bool m_hasColumns : 1;
135
    
136
    // from RenderInline
137
    bool m_isContinuation : 1; // Whether or not we're a continuation of an inline.
138
};
139
140
#ifdef NDEBUG
141
inline void RenderFlow::checkConsistency() const
142
{
143
}
144
#endif
145
146
} // namespace WebCore
147
148
#endif // RenderFlow_h