File indexing completed on 2024-04-28 11:38:42

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
0005  *           (C) 1999-2003 Antti Koivisto (koivisto@kde.org)
0006  *           (C) 2002-2003 Dirk Mueller (mueller@kde.org)
0007  *           (C) 2003 Apple Computer, Inc.
0008  *
0009  * This library is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU Library General Public
0011  * License as published by the Free Software Foundation; either
0012  * version 2 of the License, or (at your option) any later version.
0013  *
0014  * This library is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017  * Library General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU Library General Public License
0020  * along with this library; see the file COPYING.LIB.  If not, write to
0021  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0022  * Boston, MA 02110-1301, USA.
0023  *
0024  */
0025 #ifndef RENDER_FLOW_H
0026 #define RENDER_FLOW_H
0027 
0028 #include "render_box.h"
0029 #include "bidi.h"
0030 #include "render_line.h"
0031 
0032 namespace khtml
0033 {
0034 
0035 /**
0036  * all geometry managing stuff is only in the block elements.
0037  *
0038  * Inline elements don't layout themselves, but the whole paragraph
0039  * gets flowed by the surrounding block element. This is, because
0040  * one needs to know the whole paragraph to calculate bidirectional
0041  * behaviour of text, so putting the layouting routines in the inline
0042  * elements is impossible.
0043  */
0044 class RenderFlow : public RenderBox
0045 {
0046 public:
0047     RenderFlow(DOM::NodeImpl *node)
0048         : RenderBox(node)
0049     {
0050         m_continuation = nullptr;
0051         m_firstLineBox = nullptr;
0052         m_lastLineBox = nullptr;
0053     }
0054 
0055     RenderFlow *continuation() const override
0056     {
0057         return m_continuation;
0058     }
0059     void setContinuation(RenderFlow *c)
0060     {
0061         m_continuation = c;
0062     }
0063     RenderFlow *continuationBefore(const RenderObject *beforeChild);
0064 
0065     void addChildWithContinuation(RenderObject *newChild, RenderObject *beforeChild);
0066     virtual void addChildToFlow(RenderObject *newChild, RenderObject *beforeChild) = 0;
0067     void addChild(RenderObject *newChild, RenderObject *beforeChild = nullptr) override;
0068 
0069     static RenderFlow *createFlow(DOM::NodeImpl *node, RenderStyle *style, RenderArena *arena);
0070 
0071     void detach() override;
0072 
0073     void attachLineBox(InlineFlowBox *box);
0074     void extractLineBox(InlineFlowBox *box);
0075 
0076     virtual void deleteLastLineBox(RenderArena *arena = nullptr);
0077     void deleteInlineBoxes(RenderArena *arena = nullptr) override;
0078     void removeInlineBox(InlineBox *box) override;
0079     void dirtyInlineBoxes(bool fullLayout, bool isRootLineBox = false) override;
0080 
0081     void dirtyLinesFromChangedChild(RenderObject *child) override;
0082 
0083     InlineFlowBox *firstLineBox() const
0084     {
0085         return m_firstLineBox;
0086     }
0087     InlineFlowBox *lastLineBox() const
0088     {
0089         return m_lastLineBox;
0090     }
0091 
0092     QList< QRectF > getClientRects() override;
0093 
0094     InlineBox *createInlineBox(bool makePlaceHolderBox, bool isRootLineBox) override;
0095 
0096     void paintLines(PaintInfo &i, int _tx, int _ty);
0097     bool hitTestLines(NodeInfo &i, int x, int y, int tx, int ty, HitTestAction hitTestAction);
0098 
0099     void repaint(Priority p = NormalPriority) override;
0100 
0101     int highestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
0102     int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
0103     int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
0104     int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
0105 
0106 protected:
0107     // An inline can be split with blocks occurring in between the inline content.
0108     // When this occurs we need a pointer to our next object.  We can basically be
0109     // split into a sequence of inlines and blocks.  The continuation will either be
0110     // an anonymous block (that houses other blocks) or it will be an inline flow.
0111     RenderFlow *m_continuation;
0112 
0113     // For block flows, each box represents the root inline box for a line in the
0114     // paragraph.
0115     // For inline flows, each box represents a portion of that inline.
0116     InlineFlowBox *m_firstLineBox;
0117     InlineFlowBox *m_lastLineBox;
0118 };
0119 
0120 } //namespace
0121 
0122 #endif