2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * Copyright (C) 2003 Apple Computer, Inc.
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.
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.
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., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
27 #include "render_container.h"
29 #include "render_line.h"
34 * all geometry managing stuff is only in the block elements.
36 * Inline elements don't layout themselves, but the whole paragraph
37 * gets flowed by the surrounding block element. This is, because
38 * one needs to know the whole paragraph to calculate bidirectional
39 * behaviour of text, so putting the layouting routines in the inline
40 * elements is impossible.
42 class RenderFlow : public RenderContainer
45 RenderFlow(DOM::NodeImpl* node)
46 : RenderContainer(node), m_lineHeight(-1)
47 { m_continuation = 0; m_firstLineBox = 0; m_lastLineBox = 0;}
49 virtual RenderFlow* continuation() const { return m_continuation; }
50 void setContinuation(RenderFlow* c) { m_continuation = c; }
51 RenderFlow* continuationBefore(RenderObject* beforeChild);
53 void addChildWithContinuation(RenderObject* newChild, RenderObject* beforeChild);
54 virtual void addChildToFlow(RenderObject* newChild, RenderObject* beforeChild) = 0;
55 virtual void addChild(RenderObject *newChild, RenderObject *beforeChild = 0);
57 static RenderFlow* createAnonymousFlow(DOM::DocumentImpl* doc, RenderStyle* style);
59 void extractLineBox(InlineFlowBox* lineBox);
60 void attachLineBox(InlineFlowBox* lineBox);
61 void removeLineBox(InlineFlowBox* lineBox);
62 void deleteLineBoxes();
63 virtual void detach();
65 virtual void dirtyLinesFromChangedChild(RenderObject* child, bool adding = true);
67 virtual short lineHeight(bool firstLine, bool isRootLineBox=false) const;
69 InlineFlowBox* firstLineBox() const { return m_firstLineBox; }
70 InlineFlowBox* lastLineBox() const { return m_lastLineBox; }
72 virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun=false);
73 virtual void dirtyLineBoxes(bool fullLayout, bool isRootLineBox = false);
75 void paintLineBoxBackgroundBorder(PaintInfo& i, int _tx, int _ty);
76 void paintLineBoxDecorations(PaintInfo& i, int _tx, int _ty, bool paintedChildren = false);
78 virtual QRect getAbsoluteRepaintRect();
80 virtual int lowestPosition(bool includeOverflowInterior=true, bool includeSelf=true) const;
81 virtual int rightmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const;
82 virtual int leftmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const;
84 virtual QRect caretRect(int offset, EAffinity affinity = UPSTREAM, int *extraWidthToEndOfLine = 0);
87 // An inline can be split with blocks occurring in between the inline content.
88 // When this occurs we need a pointer to our next object. We can basically be
89 // split into a sequence of inlines and blocks. The continuation will either be
90 // an anonymous block (that houses other blocks) or it will be an inline flow.
91 RenderFlow* m_continuation;
93 // For block flows, each box represents the root inline box for a line in the
95 // For inline flows, each box represents a portion of that inline.
96 InlineFlowBox* m_firstLineBox;
97 InlineFlowBox* m_lastLineBox;
99 mutable short m_lineHeight;