KHtml

render_box.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 1999-2003 Lars Knoll ([email protected])
5  * (C) 1999 Antti Koivisto ([email protected])
6  * (C) 2002-2003 Apple Computer, Inc.
7  *
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.
12  *
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.
17  *
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., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 #ifndef RENDER_BOX_H
25 #define RENDER_BOX_H
26 
27 #include "render_container.h"
28 
29 namespace khtml
30 {
31 
32 enum WidthType { Width, MinWidth, MaxWidth };
33 enum HeightType { Height, MinHeight, MaxHeight };
34 
35 class RenderBlock;
36 class RenderTableCell;
37 
38 class RenderBox : public RenderContainer
39 {
40  friend class RenderTableCell;
41 
42 // combines ElemImpl & PosElImpl (all rendering objects are positioned)
43 // should contain all border and padding handling
44 
45 public:
46  RenderBox(DOM::NodeImpl *node);
47  virtual ~RenderBox();
48 
49  const char *renderName() const override
50  {
51  return "RenderBox";
52  }
53  bool isBox() const override
54  {
55  return true;
56  }
57 
58  void setStyle(RenderStyle *style) override;
59  void paint(PaintInfo &i, int _tx, int _ty) override;
60 
61  void close() override;
62 
63  InlineBox *createInlineBox(bool makePlaceHolderBox, bool isRootLineBox) override;
64  void deleteInlineBoxes(RenderArena *arena = nullptr) override;
65  void dirtyInlineBoxes(bool fullLayout, bool isRootLineBox = false) override;
66  void removeInlineBox(InlineBox *_box) override
67  {
68  if (m_placeHolderBox == _box) {
69  m_placeHolderBox = nullptr;
70  }
71  }
72 
73  void removeChild(RenderObject *) override;
74 
75  void detach() override;
76 
77  short minWidth() const override
78  {
79  return m_minWidth;
80  }
81  int maxWidth() const override
82  {
83  return m_maxWidth;
84  }
85 
86  short contentWidth() const override;
87  int contentHeight() const override;
88 
89  bool absolutePosition(int &xPos, int &yPos, bool f = false) const override;
90 
91  void setPos(int xPos, int yPos) override;
92 
93  int xPos() const override
94  {
95  return m_x;
96  }
97  int yPos() const override
98  {
99  return m_y;
100  }
101  short width() const override;
102  int height() const override;
103 
104  short marginTop() const override
105  {
106  return m_marginTop;
107  }
108  short marginBottom() const override
109  {
110  return m_marginBottom;
111  }
112  short marginLeft() const override
113  {
114  return m_marginLeft;
115  }
116  short marginRight() const override
117  {
118  return m_marginRight;
119  }
120 
121  void setWidth(int width) override;
122  void setHeight(int height) override;
123 
124  void position(InlineBox *box, int from, int len, bool reverse) override;
125 
126  int highestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
127  int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
128  int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
129  int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const override;
130 
131  void repaint(Priority p = NormalPriority) override;
132 
133  void repaintRectangle(int x, int y, int w, int h, Priority p = NormalPriority, bool f = false) override;
134 
135  short containingBlockWidth(RenderObject *providedCB = nullptr) const override;
136  void relativePositionOffset(int &tx, int &ty) const;
137 
138  void calcWidth() override;
139  void calcHeight() override;
140 
141  virtual short calcReplacedWidth() const;
142  virtual int calcReplacedHeight() const;
143 
144  int availableHeight() const override;
145  virtual int availableWidth() const;
146 
147  void calcVerticalMargins() override;
148 
149  RenderLayer *layer() const override
150  {
151  return m_layer;
152  }
153 
154  void setStaticX(short staticX);
155  void setStaticY(int staticY);
156  int staticX() const
157  {
158  return m_staticX;
159  }
160  int staticY() const
161  {
162  return m_staticY;
163  }
164 
165  void caretPos(int offset, int flags, int &_x, int &_y, int &width, int &height) const override;
166 
167  void calcHorizontalMargins(const Length &ml, const Length &mr, int cw);
168  RenderBlock *createAnonymousBlock();
169 
170  int pageTopAfter(int y) const override;
171  int crossesPageBreak(int t, int b) const override;
172 
173  bool handleEvent(const DOM::EventImpl &ev) override;
174 
175  int calcBoxWidth(int w) const;
176  int calcBoxHeight(int h) const;
177  virtual int calcContentWidth(int w) const;
178  virtual int calcContentHeight(int h) const;
179 
180  InlineBox *placeHolderBox()
181  {
182  return m_placeHolderBox;
183  }
184  void setPlaceHolderBox(InlineBox *placeHolder)
185  {
186  m_placeHolderBox = placeHolder; /* assert !m_placeHolderBox */
187  }
188  QRect getFixedBackgroundImageRect(const BackgroundLayer *bglayer, int &sx, int &sy, int &scaledImageWidth, int &scaledImageHeight);
189 
190 protected:
191  int calcWidthUsing(WidthType widthType, int cw, LengthType &lengthType);
192  int calcHeightUsing(const Length &height);
193  int calcReplacedWidthUsing(WidthType widthType) const;
194  int calcReplacedHeightUsing(HeightType heightType) const;
195  int calcPercentageHeight(const Length &height) const;
196  int availableHeightUsing(const Length &h) const;
197  int availableWidthUsing(const Length &w) const;
198  int calcImplicitContentHeight() const;
199  bool hasImplicitHeight() const
200  {
201  return isPositioned() && !style()->top().isAuto() && !style()->bottom().isAuto();
202  }
203 
204 protected:
205  void paintBoxDecorations(PaintInfo &paintInfo, int _tx, int _ty) override;
206  void paintRootBoxDecorations(PaintInfo &paintInfo, int _tx, int _ty);
207 
208  void paintAllBackgrounds(QPainter *p, const QColor &c, const BackgroundLayer *bgLayer, QRect clipr, int _tx, int _ty, int w, int h);
209  virtual void paintOneBackground(QPainter *p, const QColor &c, const BackgroundLayer *bgLayer, QRect clipr, int _tx, int _ty, int w, int h);
210  virtual void paintBackgroundExtended(QPainter * /*p*/, const QColor & /*c*/, const BackgroundLayer * /*bgLayer*/,
211  QRect clipr, int /*_tx*/, int /*_ty*/,
212  int /*w*/, int /*height*/, int /*bleft*/, int /*bright*/, int /*pleft*/, int /*pright*/,
213  int /*btop*/, int /*bbottom*/, int /*ptop*/, int /*pbottom*/) override;
214  void outlineBox(QPainter *p, int _tx, int _ty, const char *color = "red");
215 
216  void calcAbsoluteHorizontal();
217  void calcAbsoluteVertical();
218  void calcAbsoluteHorizontalValues(Length width, const RenderObject *cb, EDirection containerDirection,
219  const int containerWidth, const int bordersPlusPadding,
220  const Length left, const Length right, const Length marginLeft, const Length marginRight,
221  short &widthValue, short &marginLeftValue, short &marginRightValue, short &xPos);
222  void calcAbsoluteVerticalValues(Length height, const RenderObject *cb,
223  const int containerHeight, const int bordersPlusPadding,
224  const Length top, const Length bottom, const Length marginTop, const Length marginBottom,
225  int &heightValue, short &marginTopValue, short &marginBottomValue, int &yPos);
226 
227  void calcAbsoluteVerticalReplaced();
228  void calcAbsoluteHorizontalReplaced();
229 
230  QPainterPath borderRadiusClipPath(const BackgroundLayer *bgLayer, int _tx, int _ty, int w, int h,
231  int borderLeft, int borderRight, int borderTop, int borderBottom,
232  int paddingLeft, int paddingRight, int paddingTop, int paddingBottom) const;
233  QRect overflowClipRect(int tx, int ty) override;
234  QRect clipRect(int tx, int ty) override;
235 
236  void restructureParentFlow();
237  void detachRemainingChildren();
238 
239  // the actual height of the contents + borders + padding (border-box)
240  int m_height;
241  int m_y;
242 
243  short m_width;
244  short m_x;
245 
246  short m_marginTop;
247  short m_marginBottom;
248 
249  short m_marginLeft;
250  short m_marginRight;
251 
252  /*
253  * the minimum width the element needs, to be able to render
254  * its content without clipping
255  */
256  short m_minWidth;
257  /* The maximum width the element can fill horizontally
258  * ( = the width of the element with line breaking disabled)
259  */
260  int m_maxWidth;
261 
262  // Cached normal flow values for absolute positioned elements with static left/top values.
263  short m_staticX;
264  int m_staticY;
265 
266  RenderLayer *m_layer;
267 
268  /* A box used to represent this object on a line
269  * when its inner content isn't contextually relevant
270  * (e.g replaced or positioned elements)
271  */
272  InlineBox *m_placeHolderBox;
273 };
274 
275 } //namespace
276 
277 #endif
This file is part of the HTML rendering engine for KDE.
const QList< QKeySequence > & close()
Width
Height
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.