1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 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., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #ifndef RenderBox_h
24 #define RenderBox_h
25
26 #include "RenderBoxModelObject.h"
27 #include "RenderOverflow.h"
28 #include "ScrollTypes.h"
29
30 namespace WebCore {
31
32 struct PaintInfo;
33
34 enum LogicalWidthType { LogicalWidth, MinLogicalWidth, MaxLogicalWidth };
35
36 enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayScrollbarSize };
37
38 class RenderBox : public RenderBoxModelObject {
39 public:
40 RenderBox(Node*);
41 virtual ~RenderBox();
42
43 // Use this with caution! No type checking is done!
44 RenderBox* firstChildBox() const;
45 RenderBox* lastChildBox() const;
46
x()47 int x() const { return m_frameRect.x(); }
y()48 int y() const { return m_frameRect.y(); }
width()49 int width() const { return m_frameRect.width(); }
height()50 int height() const { return m_frameRect.height(); }
51
setX(int x)52 void setX(int x) { m_frameRect.setX(x); }
setY(int y)53 void setY(int y) { m_frameRect.setY(y); }
setWidth(int width)54 void setWidth(int width) { m_frameRect.setWidth(width); }
setHeight(int height)55 void setHeight(int height) { m_frameRect.setHeight(height); }
56
logicalLeft()57 int logicalLeft() const { return style()->isHorizontalWritingMode() ? x() : y(); }
logicalRight()58 int logicalRight() const { return logicalLeft() + logicalWidth(); }
logicalTop()59 int logicalTop() const { return style()->isHorizontalWritingMode() ? y() : x(); }
logicalBottom()60 int logicalBottom() const { return logicalTop() + logicalHeight(); }
logicalWidth()61 int logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
logicalHeight()62 int logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
63
setLogicalLeft(int left)64 void setLogicalLeft(int left)
65 {
66 if (style()->isHorizontalWritingMode())
67 setX(left);
68 else
69 setY(left);
70 }
setLogicalTop(int top)71 void setLogicalTop(int top)
72 {
73 if (style()->isHorizontalWritingMode())
74 setY(top);
75 else
76 setX(top);
77 }
setLogicalWidth(int size)78 void setLogicalWidth(int size)
79 {
80 if (style()->isHorizontalWritingMode())
81 setWidth(size);
82 else
83 setHeight(size);
84 }
setLogicalHeight(int size)85 void setLogicalHeight(int size)
86 {
87 if (style()->isHorizontalWritingMode())
88 setHeight(size);
89 else
90 setWidth(size);
91 }
setLogicalLocation(int left,int top)92 void setLogicalLocation(int left, int top)
93 {
94 if (style()->isHorizontalWritingMode())
95 setLocation(left, top);
96 else
97 setLocation(top, left);
98 }
99
location()100 IntPoint location() const { return m_frameRect.location(); }
locationOffset()101 IntSize locationOffset() const { return IntSize(x(), y()); }
size()102 IntSize size() const { return m_frameRect.size(); }
103
setLocation(const IntPoint & location)104 void setLocation(const IntPoint& location) { m_frameRect.setLocation(location); }
setLocation(int x,int y)105 void setLocation(int x, int y) { setLocation(IntPoint(x, y)); }
106
setSize(const IntSize & size)107 void setSize(const IntSize& size) { m_frameRect.setSize(size); }
move(int dx,int dy)108 void move(int dx, int dy) { m_frameRect.move(dx, dy); }
109
frameRect()110 IntRect frameRect() const { return m_frameRect; }
setFrameRect(const IntRect & rect)111 void setFrameRect(const IntRect& rect) { m_frameRect = rect; }
112
borderBoxRect()113 IntRect borderBoxRect() const { return IntRect(0, 0, width(), height()); }
borderBoundingBox()114 virtual IntRect borderBoundingBox() const { return borderBoxRect(); }
115
116 // The content area of the box (excludes padding and border).
contentBoxRect()117 IntRect contentBoxRect() const { return IntRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
118 // The content box in absolute coords. Ignores transforms.
119 IntRect absoluteContentBox() const;
120 // The content box converted to absolute coords (taking transforms into account).
121 FloatQuad absoluteContentQuad() const;
122
123 // Bounds of the outline box in absolute coords. Respects transforms
124 virtual IntRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, IntPoint* cachedOffsetToRepaintContainer) const;
125 virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
126
127 // Use this with caution! No type checking is done!
128 RenderBox* previousSiblingBox() const;
129 RenderBox* nextSiblingBox() const;
130 RenderBox* parentBox() const;
131
132 // Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions.
133 // For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right
134 // respectively are flipped when compared to their physical counterparts. For example minX is on the left in vertical-lr,
135 // but it is on the right in vertical-rl.
layoutOverflowRect()136 IntRect layoutOverflowRect() const { return m_overflow ? m_overflow->layoutOverflowRect() : clientBoxRect(); }
minYLayoutOverflow()137 int minYLayoutOverflow() const { return m_overflow? m_overflow->minYLayoutOverflow() : borderTop(); }
maxYLayoutOverflow()138 int maxYLayoutOverflow() const { return m_overflow ? m_overflow->maxYLayoutOverflow() : borderTop() + clientHeight(); }
minXLayoutOverflow()139 int minXLayoutOverflow() const { return m_overflow ? m_overflow->minXLayoutOverflow() : borderLeft(); }
maxXLayoutOverflow()140 int maxXLayoutOverflow() const { return m_overflow ? m_overflow->maxXLayoutOverflow() : borderLeft() + clientWidth(); }
logicalLeftLayoutOverflow()141 int logicalLeftLayoutOverflow() const { return style()->isHorizontalWritingMode() ? minXLayoutOverflow() : minYLayoutOverflow(); }
logicalRightLayoutOverflow()142 int logicalRightLayoutOverflow() const { return style()->isHorizontalWritingMode() ? maxXLayoutOverflow() : maxYLayoutOverflow(); }
143
visualOverflowRect()144 IntRect visualOverflowRect() const { return m_overflow ? m_overflow->visualOverflowRect() : borderBoxRect(); }
minYVisualOverflow()145 int minYVisualOverflow() const { return m_overflow? m_overflow->minYVisualOverflow() : 0; }
maxYVisualOverflow()146 int maxYVisualOverflow() const { return m_overflow ? m_overflow->maxYVisualOverflow() : height(); }
minXVisualOverflow()147 int minXVisualOverflow() const { return m_overflow ? m_overflow->minXVisualOverflow() : 0; }
maxXVisualOverflow()148 int maxXVisualOverflow() const { return m_overflow ? m_overflow->maxXVisualOverflow() : width(); }
logicalLeftVisualOverflow()149 int logicalLeftVisualOverflow() const { return style()->isHorizontalWritingMode() ? minXVisualOverflow() : minYVisualOverflow(); }
logicalRightVisualOverflow()150 int logicalRightVisualOverflow() const { return style()->isHorizontalWritingMode() ? maxXVisualOverflow() : maxYVisualOverflow(); }
151
152 void addLayoutOverflow(const IntRect&);
153 void addVisualOverflow(const IntRect&);
154
155 void addShadowOverflow();
addOverflowFromChild(RenderBox * child)156 void addOverflowFromChild(RenderBox* child) { addOverflowFromChild(child, IntSize(child->x(), child->y())); }
157 void addOverflowFromChild(RenderBox* child, const IntSize& delta);
158 void clearLayoutOverflow();
159
160 void updateLayerTransform();
161
162 void blockDirectionOverflow(bool isLineHorizontal, int& logicalTopLayoutOverflow, int& logicalBottomLayoutOverflow,
163 int& logicalTopVisualOverflow, int& logicalBottomVisualOverflow);
164
contentWidth()165 int contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
contentHeight()166 int contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
contentLogicalWidth()167 int contentLogicalWidth() const { return style()->isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
contentLogicalHeight()168 int contentLogicalHeight() const { return style()->isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
169
170 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
171 // to return the remaining width on a given line (and the height of a single line).
offsetWidth()172 virtual int offsetWidth() const { return width(); }
offsetHeight()173 virtual int offsetHeight() const { return height(); }
174
175 // More IE extensions. clientWidth and clientHeight represent the interior of an object
176 // excluding border and scrollbar. clientLeft/Top are just the borderLeftWidth and borderTopWidth.
clientLeft()177 int clientLeft() const { return borderLeft(); }
clientTop()178 int clientTop() const { return borderTop(); }
179 int clientWidth() const;
180 int clientHeight() const;
clientLogicalWidth()181 int clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
clientLogicalHeight()182 int clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
clientLogicalBottom()183 int clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
clientBoxRect()184 IntRect clientBoxRect() const { return IntRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
185
186 // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
187 // object has overflow:hidden/scroll/auto specified and also has overflow.
188 // scrollLeft/Top return the current scroll position. These methods are virtual so that objects like
189 // textareas can scroll shadow content (but pretend that they are the objects that are
190 // scrolling).
191 virtual int scrollLeft() const;
192 virtual int scrollTop() const;
193 virtual int scrollWidth() const;
194 virtual int scrollHeight() const;
195 virtual void setScrollLeft(int);
196 virtual void setScrollTop(int);
197
marginTop()198 virtual int marginTop() const { return m_marginTop; }
marginBottom()199 virtual int marginBottom() const { return m_marginBottom; }
marginLeft()200 virtual int marginLeft() const { return m_marginLeft; }
marginRight()201 virtual int marginRight() const { return m_marginRight; }
setMarginTop(int margin)202 void setMarginTop(int margin) { m_marginTop = margin; }
setMarginBottom(int margin)203 void setMarginBottom(int margin) { m_marginBottom = margin; }
setMarginLeft(int margin)204 void setMarginLeft(int margin) { m_marginLeft = margin; }
setMarginRight(int margin)205 void setMarginRight(int margin) { m_marginRight = margin; }
206 virtual int marginBefore() const;
207 virtual int marginAfter() const;
208 virtual int marginStart() const;
209 virtual int marginEnd() const;
210 void setMarginStart(int);
211 void setMarginEnd(int);
212 void setMarginBefore(int);
213 void setMarginAfter(int);
214
215 // The following five functions are used to implement collapsing margins.
216 // All objects know their maximal positive and negative margins. The
217 // formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargin|.
218 // For a non-collapsing box, such as a leaf element, this formula will simply return
219 // the margin of the element. Blocks override the maxMarginBefore and maxMarginAfter
220 // methods.
221 enum MarginSign { PositiveMargin, NegativeMargin };
isSelfCollapsingBlock()222 virtual bool isSelfCollapsingBlock() const { return false; }
collapsedMarginBefore()223 virtual int collapsedMarginBefore() const { return marginBefore(); }
collapsedMarginAfter()224 virtual int collapsedMarginAfter() const { return marginAfter(); }
225
226 virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
227 virtual void absoluteQuads(Vector<FloatQuad>&);
228
229 IntRect reflectionBox() const;
230 int reflectionOffset() const;
231 // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection.
232 IntRect reflectedRect(const IntRect&) const;
233
234 virtual void layout();
235 virtual void paint(PaintInfo&, int tx, int ty);
236 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
237
238 virtual void destroy();
239
240 virtual int minPreferredLogicalWidth() const;
241 virtual int maxPreferredLogicalWidth() const;
242
243 int overrideSize() const;
244 int overrideWidth() const;
245 int overrideHeight() const;
246 virtual void setOverrideSize(int);
247
248 virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
249
250 int computeBorderBoxLogicalWidth(int width) const;
251 int computeBorderBoxLogicalHeight(int height) const;
252 int computeContentBoxLogicalWidth(int width) const;
253 int computeContentBoxLogicalHeight(int height) const;
254
borderFitAdjust(int &,int &)255 virtual void borderFitAdjust(int& /*x*/, int& /*w*/) const { } // Shrink the box in which the border paints if border-fit is set.
256
257 // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
258 // of the containing block.
259 void computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth);
260
261 // Used to resolve margins in the containing block's block-flow direction.
262 void computeBlockDirectionMargins(RenderBlock* containingBlock);
263
264 void positionLineBox(InlineBox*);
265
266 virtual InlineBox* createInlineBox();
267 void dirtyLineBoxes(bool fullLayout);
268
269 // For inline replaced elements, this function returns the inline box that owns us. Enables
270 // the replaced RenderObject to quickly determine what line it is contained on and to easily
271 // iterate over structures on the line.
inlineBoxWrapper()272 InlineBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
setInlineBoxWrapper(InlineBox * boxWrapper)273 void setInlineBoxWrapper(InlineBox* boxWrapper) { m_inlineBoxWrapper = boxWrapper; }
274 void deleteLineBoxWrapper();
275
276 virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
277 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
278
279 virtual void repaintDuringLayoutIfMoved(const IntRect&);
280
281 virtual int containingBlockLogicalWidthForContent() const;
282 int perpendicularContainingBlockLogicalHeight() const;
283
284 virtual void computeLogicalWidth();
285 virtual void computeLogicalHeight();
286
stretchesToViewport()287 bool stretchesToViewport() const
288 {
289 return document()->inQuirksMode() && style()->logicalHeight().isAuto() && !isFloatingOrPositioned() && (isRoot() || isBody());
290 }
291
intrinsicSize()292 virtual IntSize intrinsicSize() const { return IntSize(); }
intrinsicLogicalWidth()293 int intrinsicLogicalWidth() const { return style()->isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); }
intrinsicLogicalHeight()294 int intrinsicLogicalHeight() const { return style()->isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); }
295
296 // Whether or not the element shrinks to its intrinsic width (rather than filling the width
297 // of a containing block). HTML4 buttons, <select>s, <input>s, legends, and floating/compact elements do this.
298 bool sizesToIntrinsicLogicalWidth(LogicalWidthType) const;
stretchesToMinIntrinsicLogicalWidth()299 virtual bool stretchesToMinIntrinsicLogicalWidth() const { return false; }
300
301 int computeLogicalWidthUsing(LogicalWidthType, int availableLogicalWidth);
302 int computeLogicalHeightUsing(const Length& height);
303 int computeReplacedLogicalWidthUsing(Length width) const;
304 int computeReplacedLogicalHeightUsing(Length height) const;
305
306 virtual int computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
307 virtual int computeReplacedLogicalHeight() const;
308
309 int computePercentageLogicalHeight(const Length& height);
310
311 // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
availableLogicalWidth()312 virtual int availableLogicalWidth() const { return contentLogicalWidth(); }
313 int availableLogicalHeight() const;
314 int availableLogicalHeightUsing(const Length&) const;
315
316 // There are a few cases where we need to refer specifically to the available physical width and available physical height.
317 // Relative positioning is one of those cases, since left/top offsets are physical.
availableWidth()318 int availableWidth() const { return style()->isHorizontalWritingMode() ? availableLogicalWidth() : availableLogicalHeight(); }
availableHeight()319 int availableHeight() const { return style()->isHorizontalWritingMode() ? availableLogicalHeight() : availableLogicalWidth(); }
320
321 virtual int verticalScrollbarWidth() const;
322 int horizontalScrollbarHeight() const;
scrollbarLogicalHeight()323 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
324 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
325 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
326 bool canBeScrolledAndHasScrollableArea() const;
327 virtual bool canBeProgramaticallyScrolled(bool) const;
328 virtual void autoscroll();
stopAutoscroll()329 virtual void stopAutoscroll() { }
330 virtual void panScroll(const IntPoint&);
hasAutoVerticalScrollbar()331 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); }
hasAutoHorizontalScrollbar()332 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); }
scrollsOverflow()333 bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
scrollsOverflowX()334 bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
scrollsOverflowY()335 bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
336
337 virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
338
339 virtual IntRect overflowClipRect(int tx, int ty, OverlayScrollbarSizeRelevancy relevancy = IgnoreOverlayScrollbarSize);
340 IntRect clipRect(int tx, int ty);
hasControlClip()341 virtual bool hasControlClip() const { return false; }
controlClipRect(int,int)342 virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const { return IntRect(); }
343 bool pushContentsClip(PaintInfo&, int tx, int ty);
344 void popContentsClip(PaintInfo&, PaintPhase originalPhase, int tx, int ty);
345
paintObject(PaintInfo &,int,int)346 virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); }
347 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
348 virtual void paintMask(PaintInfo&, int tx, int ty);
349 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
350
351 // Called when a positioned object moves but doesn't necessarily change size. A simplified layout is attempted
352 // that just updates the object's position. If the size does change, the object remains dirty.
tryLayoutDoingPositionedMovementOnly()353 bool tryLayoutDoingPositionedMovementOnly()
354 {
355 int oldWidth = width();
356 computeLogicalWidth();
357 // If we shrink to fit our width may have changed, so we still need full layout.
358 if (oldWidth != width())
359 return false;
360 computeLogicalHeight();
361 return true;
362 }
363
364 IntRect maskClipRect();
365
366 virtual VisiblePosition positionForPoint(const IntPoint&);
367
368 void removeFloatingOrPositionedChildFromBlockLists();
369
370 RenderLayer* enclosingFloatPaintingLayer() const;
371
firstLineBoxBaseline()372 virtual int firstLineBoxBaseline() const { return -1; }
lastLineBoxBaseline()373 virtual int lastLineBoxBaseline() const { return -1; }
374
375 bool shrinkToAvoidFloats() const;
376 virtual bool avoidsFloats() const;
377
markForPaginationRelayoutIfNeeded()378 virtual void markForPaginationRelayoutIfNeeded() { }
379
isWritingModeRoot()380 bool isWritingModeRoot() const { return !parent() || parent()->style()->writingMode() != style()->writingMode(); }
381
isDeprecatedFlexItem()382 bool isDeprecatedFlexItem() const { return !isInline() && !isFloatingOrPositioned() && parent() && parent()->isFlexibleBox(); }
383
384 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
385 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
386
387 enum FlippingAdjustment { ChildToParentFlippingAdjustment, ParentToChildFlippingAdjustment };
388 IntPoint flipForWritingMode(const RenderBox* child, const IntPoint&, FlippingAdjustment) const;
389 int flipForWritingMode(int position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
390 IntPoint flipForWritingMode(const IntPoint&) const;
391 IntPoint flipForWritingModeIncludingColumns(const IntPoint&) const;
392 IntSize flipForWritingMode(const IntSize&) const;
393 void flipForWritingMode(IntRect&) const;
394 FloatPoint flipForWritingMode(const FloatPoint&) const;
395 void flipForWritingMode(FloatRect&) const;
396 IntSize locationOffsetIncludingFlipping() const;
397
398 IntRect logicalVisualOverflowRectForPropagation(RenderStyle*) const;
399 IntRect visualOverflowRectForPropagation(RenderStyle*) const;
400 IntRect logicalLayoutOverflowRectForPropagation(RenderStyle*) const;
401 IntRect layoutOverflowRectForPropagation(RenderStyle*) const;
402
hasRenderOverflow()403 RenderOverflow* hasRenderOverflow() const { return m_overflow.get(); }
404
405 #ifdef ANDROID_LAYOUT
getVisibleWidth()406 int getVisibleWidth() const { return m_visibleWidth; }
407 #endif
408
409 protected:
410 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
411 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
412 virtual void updateBoxModelInfoFromStyle();
413
414 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, CompositeOperator op, RenderObject* backgroundObject);
415 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
416
417 void paintBoxDecorationsWithSize(PaintInfo&, int tx, int ty, int width, int height);
418 void paintMaskImages(const PaintInfo&, int tx, int ty, int width, int height);
419
420 #if PLATFORM(MAC)
421 void paintCustomHighlight(int tx, int ty, const AtomicString& type, bool behindText);
422 #endif
423
424 void computePositionedLogicalWidth();
425
shouldComputeSizeAsReplaced()426 virtual bool shouldComputeSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
427
428 virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&) const;
429 virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
430
431 void paintRootBoxFillLayers(const PaintInfo&);
432
433 private:
434 bool includeVerticalScrollbarSize() const;
435 bool includeHorizontalScrollbarSize() const;
436
437 // Returns true if we did a full repaint
438 bool repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground);
439
440 int containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
441 int containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
442
443 void computePositionedLogicalHeight();
444 void computePositionedLogicalWidthUsing(Length logicalWidth, const RenderBoxModelObject* containerBlock, TextDirection containerDirection,
445 int containerLogicalWidth, int bordersPlusPadding,
446 Length logicalLeft, Length logicalRight, Length marginLogicalLeft, Length marginLogicalRight,
447 int& logicalWidthValue, int& marginLogicalLeftValue, int& marginLogicalRightValue, int& logicalLeftPos);
448 void computePositionedLogicalHeightUsing(Length logicalHeight, const RenderBoxModelObject* containerBlock,
449 int containerLogicalHeight, int bordersPlusPadding,
450 Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom,
451 int& logicalHeightValue, int& marginLogicalTopValue, int& marginLogicalBottomValue, int& logicalTopPos);
452
453 void computePositionedLogicalHeightReplaced();
454 void computePositionedLogicalWidthReplaced();
455
456 // This function calculates the minimum and maximum preferred widths for an object.
457 // These values are used in shrink-to-fit layout systems.
458 // These include tables, positioned objects, floats and flexible boxes.
computePreferredLogicalWidths()459 virtual void computePreferredLogicalWidths() { setPreferredLogicalWidthsDirty(false); }
460
461 private:
462 // The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent).
463 IntRect m_frameRect;
464
465 protected:
466
467 #ifdef ANDROID_LAYOUT
468 void setVisibleWidth(int newWidth);
469 bool checkAndSetRelayoutChildren(bool* relayoutChildren);
470 #endif
471
472 int m_marginLeft;
473 int m_marginRight;
474 int m_marginTop;
475 int m_marginBottom;
476
477 // The preferred logical width of the element if it were to break its lines at every possible opportunity.
478 int m_minPreferredLogicalWidth;
479
480 // The preferred logical width of the element if it never breaks any lines at all.
481 int m_maxPreferredLogicalWidth;
482
483 // For inline replaced elements, the inline box that owns us.
484 InlineBox* m_inlineBoxWrapper;
485
486 // Our overflow information.
487 OwnPtr<RenderOverflow> m_overflow;
488
489 private:
490 // Used to store state between styleWillChange and styleDidChange
491 static bool s_hadOverflowClip;
492
493 #ifdef ANDROID_LAYOUT
494 int m_visibleWidth;
495 bool m_isVisibleWidthChangedBeforeLayout;
496 #endif
497 };
498
toRenderBox(RenderObject * object)499 inline RenderBox* toRenderBox(RenderObject* object)
500 {
501 ASSERT(!object || object->isBox());
502 return static_cast<RenderBox*>(object);
503 }
504
toRenderBox(const RenderObject * object)505 inline const RenderBox* toRenderBox(const RenderObject* object)
506 {
507 ASSERT(!object || object->isBox());
508 return static_cast<const RenderBox*>(object);
509 }
510
511 // This will catch anyone doing an unnecessary cast.
512 void toRenderBox(const RenderBox*);
513
previousSiblingBox()514 inline RenderBox* RenderBox::previousSiblingBox() const
515 {
516 return toRenderBox(previousSibling());
517 }
518
nextSiblingBox()519 inline RenderBox* RenderBox::nextSiblingBox() const
520 {
521 return toRenderBox(nextSibling());
522 }
523
parentBox()524 inline RenderBox* RenderBox::parentBox() const
525 {
526 return toRenderBox(parent());
527 }
528
firstChildBox()529 inline RenderBox* RenderBox::firstChildBox() const
530 {
531 return toRenderBox(firstChild());
532 }
533
lastChildBox()534 inline RenderBox* RenderBox::lastChildBox() const
535 {
536 return toRenderBox(lastChild());
537 }
538
539 } // namespace WebCore
540
541 #endif // RenderBox_h
542