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.
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.
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.
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.
26 #include "RenderBoxModelObject.h"
27 #include "RenderOverflow.h"
28 #include "ScrollTypes.h"
32 class RenderBoxRegionInfo;
36 enum LogicalWidthType { LogicalWidth, MinLogicalWidth, MaxLogicalWidth };
38 enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayScrollbarSize };
40 class RenderBox : public RenderBoxModelObject {
45 // Use this with caution! No type checking is done!
46 RenderBox* firstChildBox() const;
47 RenderBox* lastChildBox() const;
49 LayoutUnit x() const { return m_frameRect.x(); }
50 LayoutUnit y() const { return m_frameRect.y(); }
51 LayoutUnit width() const { return m_frameRect.width(); }
52 LayoutUnit height() const { return m_frameRect.height(); }
54 // These represent your location relative to your container as a physical offset.
55 // In layout related methods you almost always want the logical location (e.g. x() and y()).
56 LayoutUnit top() const { return topLeftLocation().y(); }
57 LayoutUnit left() const { return topLeftLocation().x(); }
59 void setX(LayoutUnit x) { m_frameRect.setX(x); }
60 void setY(LayoutUnit y) { m_frameRect.setY(y); }
61 void setWidth(LayoutUnit width) { m_frameRect.setWidth(width); }
62 void setHeight(LayoutUnit height) { m_frameRect.setHeight(height); }
64 LayoutUnit logicalLeft() const { return style()->isHorizontalWritingMode() ? x() : y(); }
65 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); }
66 LayoutUnit logicalTop() const { return style()->isHorizontalWritingMode() ? y() : x(); }
67 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); }
68 LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
69 LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
71 void setLogicalLeft(LayoutUnit left)
73 if (style()->isHorizontalWritingMode())
78 void setLogicalTop(LayoutUnit top)
80 if (style()->isHorizontalWritingMode())
85 void setLogicalLocation(const LayoutPoint& location)
87 if (style()->isHorizontalWritingMode())
88 setLocation(location);
90 setLocation(location.transposedPoint());
92 void setLogicalWidth(LayoutUnit size)
94 if (style()->isHorizontalWritingMode())
99 void setLogicalHeight(LayoutUnit size)
101 if (style()->isHorizontalWritingMode())
106 void setLogicalSize(const LayoutSize& size)
108 if (style()->isHorizontalWritingMode())
111 setSize(size.transposedSize());
114 LayoutPoint location() const { return m_frameRect.location(); }
115 LayoutSize locationOffset() const { return LayoutSize(x(), y()); }
116 LayoutSize size() const { return m_frameRect.size(); }
118 void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(location); }
120 void setSize(const LayoutSize& size) { m_frameRect.setSize(size); }
121 void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); }
123 LayoutRect frameRect() const { return m_frameRect; }
124 void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; }
126 LayoutRect borderBoxRect() const { return LayoutRect(0, 0, width(), height()); }
127 virtual LayoutRect borderBoundingBox() const { return borderBoxRect(); }
129 // The content area of the box (excludes padding and border).
130 LayoutRect contentBoxRect() const { return LayoutRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
131 // The content box in absolute coords. Ignores transforms.
132 LayoutRect absoluteContentBox() const;
133 // The content box converted to absolute coords (taking transforms into account).
134 FloatQuad absoluteContentQuad() const;
136 // Bounds of the outline box in absolute coords. Respects transforms
137 virtual LayoutRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, LayoutPoint* cachedOffsetToRepaintContainer) const;
138 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
140 // Use this with caution! No type checking is done!
141 RenderBox* previousSiblingBox() const;
142 RenderBox* nextSiblingBox() const;
143 RenderBox* parentBox() const;
145 // Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions.
146 // For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right
147 // respectively are flipped when compared to their physical counterparts. For example minX is on the left in vertical-lr,
148 // but it is on the right in vertical-rl.
149 LayoutRect layoutOverflowRect() const { return m_overflow ? m_overflow->layoutOverflowRect() : clientBoxRect(); }
150 LayoutUnit minYLayoutOverflow() const { return m_overflow? m_overflow->minYLayoutOverflow() : borderTop(); }
151 LayoutUnit maxYLayoutOverflow() const { return m_overflow ? m_overflow->maxYLayoutOverflow() : borderTop() + clientHeight(); }
152 LayoutUnit minXLayoutOverflow() const { return m_overflow ? m_overflow->minXLayoutOverflow() : borderLeft(); }
153 LayoutUnit maxXLayoutOverflow() const { return m_overflow ? m_overflow->maxXLayoutOverflow() : borderLeft() + clientWidth(); }
154 LayoutSize maxLayoutOverflow() const { return LayoutSize(maxXLayoutOverflow(), maxYLayoutOverflow()); }
155 LayoutUnit logicalLeftLayoutOverflow() const { return style()->isHorizontalWritingMode() ? minXLayoutOverflow() : minYLayoutOverflow(); }
156 LayoutUnit logicalRightLayoutOverflow() const { return style()->isHorizontalWritingMode() ? maxXLayoutOverflow() : maxYLayoutOverflow(); }
158 virtual LayoutRect visualOverflowRect() const { return m_overflow ? m_overflow->visualOverflowRect() : borderBoxRect(); }
159 LayoutUnit minYVisualOverflow() const { return m_overflow? m_overflow->minYVisualOverflow() : 0; }
160 LayoutUnit maxYVisualOverflow() const { return m_overflow ? m_overflow->maxYVisualOverflow() : height(); }
161 LayoutUnit minXVisualOverflow() const { return m_overflow ? m_overflow->minXVisualOverflow() : 0; }
162 LayoutUnit maxXVisualOverflow() const { return m_overflow ? m_overflow->maxXVisualOverflow() : width(); }
163 LayoutUnit logicalLeftVisualOverflow() const { return style()->isHorizontalWritingMode() ? minXVisualOverflow() : minYVisualOverflow(); }
164 LayoutUnit logicalRightVisualOverflow() const { return style()->isHorizontalWritingMode() ? maxXVisualOverflow() : maxYVisualOverflow(); }
166 void addLayoutOverflow(const LayoutRect&);
167 void addVisualOverflow(const LayoutRect&);
169 void addBoxShadowAndBorderOverflow();
170 void addOverflowFromChild(RenderBox* child) { addOverflowFromChild(child, child->locationOffset()); }
171 void addOverflowFromChild(RenderBox* child, const LayoutSize& delta);
172 void clearLayoutOverflow();
174 void updateLayerTransform();
176 LayoutUnit contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
177 LayoutUnit contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
178 LayoutUnit contentLogicalWidth() const { return style()->isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
179 LayoutUnit contentLogicalHeight() const { return style()->isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
181 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
182 // to return the remaining width on a given line (and the height of a single line).
183 virtual LayoutUnit offsetWidth() const { return width(); }
184 virtual LayoutUnit offsetHeight() const { return height(); }
186 // More IE extensions. clientWidth and clientHeight represent the interior of an object
187 // excluding border and scrollbar. clientLeft/Top are just the borderLeftWidth and borderTopWidth.
188 LayoutUnit clientLeft() const { return borderLeft(); }
189 LayoutUnit clientTop() const { return borderTop(); }
190 LayoutUnit clientWidth() const;
191 LayoutUnit clientHeight() const;
192 LayoutUnit clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
193 LayoutUnit clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
194 LayoutUnit clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
195 LayoutRect clientBoxRect() const { return LayoutRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
197 // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
198 // object has overflow:hidden/scroll/auto specified and also has overflow.
199 // scrollLeft/Top return the current scroll position. These methods are virtual so that objects like
200 // textareas can scroll shadow content (but pretend that they are the objects that are
202 virtual int scrollLeft() const;
203 virtual int scrollTop() const;
204 virtual int scrollWidth() const;
205 virtual int scrollHeight() const;
206 virtual void setScrollLeft(int);
207 virtual void setScrollTop(int);
209 virtual LayoutUnit marginTop() const { return m_marginTop; }
210 virtual LayoutUnit marginBottom() const { return m_marginBottom; }
211 virtual LayoutUnit marginLeft() const { return m_marginLeft; }
212 virtual LayoutUnit marginRight() const { return m_marginRight; }
213 void setMarginTop(LayoutUnit margin) { m_marginTop = margin; }
214 void setMarginBottom(LayoutUnit margin) { m_marginBottom = margin; }
215 void setMarginLeft(LayoutUnit margin) { m_marginLeft = margin; }
216 void setMarginRight(LayoutUnit margin) { m_marginRight = margin; }
217 virtual LayoutUnit marginBefore() const;
218 virtual LayoutUnit marginAfter() const;
219 virtual LayoutUnit marginStart() const;
220 virtual LayoutUnit marginEnd() const;
221 void setMarginStart(LayoutUnit);
222 void setMarginEnd(LayoutUnit);
223 void setMarginBefore(LayoutUnit);
224 void setMarginAfter(LayoutUnit);
226 // The following five functions are used to implement collapsing margins.
227 // All objects know their maximal positive and negative margins. The
228 // formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargin|.
229 // For a non-collapsing box, such as a leaf element, this formula will simply return
230 // the margin of the element. Blocks override the maxMarginBefore and maxMarginAfter
232 enum MarginSign { PositiveMargin, NegativeMargin };
233 virtual bool isSelfCollapsingBlock() const { return false; }
234 virtual LayoutUnit collapsedMarginBefore() const { return marginBefore(); }
235 virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); }
237 virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset) const;
238 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const;
240 LayoutRect reflectionBox() const;
241 int reflectionOffset() const;
242 // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection.
243 LayoutRect reflectedRect(const LayoutRect&) const;
245 virtual void layout();
246 virtual void paint(PaintInfo&, const LayoutPoint&);
247 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
249 virtual LayoutUnit minPreferredLogicalWidth() const;
250 virtual LayoutUnit maxPreferredLogicalWidth() const;
252 LayoutUnit overrideWidth() const;
253 LayoutUnit overrideHeight() const;
254 bool hasOverrideHeight() const;
255 bool hasOverrideWidth() const;
256 void setOverrideHeight(LayoutUnit);
257 void setOverrideWidth(LayoutUnit);
258 void clearOverrideSize();
260 virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&) const;
262 LayoutUnit computeBorderBoxLogicalWidth(LayoutUnit width) const;
263 LayoutUnit computeBorderBoxLogicalHeight(LayoutUnit height) const;
264 LayoutUnit computeContentBoxLogicalWidth(LayoutUnit width) const;
265 LayoutUnit computeContentBoxLogicalHeight(LayoutUnit height) const;
267 virtual void borderFitAdjust(LayoutRect&) const { } // Shrink the box in which the border paints if border-fit is set.
269 // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
270 // of the containing block.
271 void computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth);
273 // Used to resolve margins in the containing block's block-flow direction.
274 void computeBlockDirectionMargins(RenderBlock* containingBlock);
276 enum RenderBoxRegionInfoFlags { CacheRenderBoxRegionInfo, DoNotCacheRenderBoxRegionInfo };
277 LayoutRect borderBoxRectInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage = 0, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
278 void clearRenderBoxRegionInfo();
280 void positionLineBox(InlineBox*);
282 virtual InlineBox* createInlineBox();
283 void dirtyLineBoxes(bool fullLayout);
285 // For inline replaced elements, this function returns the inline box that owns us. Enables
286 // the replaced RenderObject to quickly determine what line it is contained on and to easily
287 // iterate over structures on the line.
288 InlineBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
289 void setInlineBoxWrapper(InlineBox* boxWrapper) { m_inlineBoxWrapper = boxWrapper; }
290 void deleteLineBoxWrapper();
292 virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
293 virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed = false) const;
295 virtual void repaintDuringLayoutIfMoved(const LayoutRect&);
297 virtual LayoutUnit containingBlockLogicalWidthForContent() const;
298 LayoutUnit containingBlockLogicalWidthForContentInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
299 LayoutUnit perpendicularContainingBlockLogicalHeight() const;
301 virtual void computeLogicalWidth();
302 virtual void computeLogicalHeight();
304 RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
305 void computeLogicalWidthInRegion(RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0);
307 bool stretchesToViewport() const
309 return document()->inQuirksMode() && style()->logicalHeight().isAuto() && !isFloatingOrPositioned() && (isRoot() || isBody());
312 virtual LayoutSize intrinsicSize() const { return LayoutSize(); }
313 LayoutUnit intrinsicLogicalWidth() const { return style()->isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); }
314 LayoutUnit intrinsicLogicalHeight() const { return style()->isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); }
316 // Whether or not the element shrinks to its intrinsic width (rather than filling the width
317 // of a containing block). HTML4 buttons, <select>s, <input>s, legends, and floating/compact elements do this.
318 bool sizesToIntrinsicLogicalWidth(LogicalWidthType) const;
319 virtual bool stretchesToMinIntrinsicLogicalWidth() const { return false; }
321 LayoutUnit computeLogicalWidthUsing(LogicalWidthType, LayoutUnit availableLogicalWidth);
322 LayoutUnit computeLogicalHeightUsing(const Length& height);
323 LayoutUnit computeReplacedLogicalWidthUsing(Length width) const;
324 LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, bool includeMaxWidth = true) const;
325 LayoutUnit computeReplacedLogicalHeightUsing(Length height) const;
326 LayoutUnit computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight) const;
328 virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
329 virtual LayoutUnit computeReplacedLogicalHeight() const;
331 LayoutUnit computePercentageLogicalHeight(const Length& height);
333 // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
334 virtual LayoutUnit availableLogicalWidth() const { return contentLogicalWidth(); }
335 LayoutUnit availableLogicalHeight() const;
336 LayoutUnit availableLogicalHeightUsing(const Length&) const;
338 // There are a few cases where we need to refer specifically to the available physical width and available physical height.
339 // Relative positioning is one of those cases, since left/top offsets are physical.
340 LayoutUnit availableWidth() const { return style()->isHorizontalWritingMode() ? availableLogicalWidth() : availableLogicalHeight(); }
341 LayoutUnit availableHeight() const { return style()->isHorizontalWritingMode() ? availableLogicalHeight() : availableLogicalWidth(); }
343 virtual int verticalScrollbarWidth() const;
344 int horizontalScrollbarHeight() const;
345 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
346 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
347 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
348 bool canBeScrolledAndHasScrollableArea() const;
349 virtual bool canBeProgramaticallyScrolled() const;
350 virtual void autoscroll();
351 virtual void stopAutoscroll() { }
352 virtual void panScroll(const IntPoint&);
353 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); }
354 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); }
355 bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
356 bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
357 bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
359 bool hasUnsplittableScrollingOverflow() const;
360 bool isUnsplittableForPagination() const;
362 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
364 virtual LayoutRect overflowClipRect(const LayoutPoint& location, RenderRegion*, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize);
365 LayoutRect clipRect(const LayoutPoint& location, RenderRegion*);
366 virtual bool hasControlClip() const { return false; }
367 virtual LayoutRect controlClipRect(const LayoutPoint&) const { return LayoutRect(); }
368 bool pushContentsClip(PaintInfo&, const LayoutPoint& accumulatedOffset);
369 void popContentsClip(PaintInfo&, PaintPhase originalPhase, const LayoutPoint& accumulatedOffset);
371 virtual void paintObject(PaintInfo&, const LayoutPoint&) { ASSERT_NOT_REACHED(); }
372 virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
373 virtual void paintMask(PaintInfo&, const LayoutPoint&);
374 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
376 // Called when a positioned object moves but doesn't necessarily change size. A simplified layout is attempted
377 // that just updates the object's position. If the size does change, the object remains dirty.
378 bool tryLayoutDoingPositionedMovementOnly()
380 LayoutUnit oldWidth = width();
381 computeLogicalWidth();
382 // If we shrink to fit our width may have changed, so we still need full layout.
383 if (oldWidth != width())
385 computeLogicalHeight();
389 LayoutRect maskClipRect();
391 virtual VisiblePosition positionForPoint(const LayoutPoint&);
393 void removeFloatingOrPositionedChildFromBlockLists();
395 RenderLayer* enclosingFloatPaintingLayer() const;
397 virtual LayoutUnit firstLineBoxBaseline() const { return -1; }
398 virtual LayoutUnit lastLineBoxBaseline() const { return -1; }
400 bool shrinkToAvoidFloats() const;
401 virtual bool avoidsFloats() const;
403 virtual void markForPaginationRelayoutIfNeeded() { }
405 bool isWritingModeRoot() const { return !parent() || parent()->style()->writingMode() != style()->writingMode(); }
407 bool isDeprecatedFlexItem() const { return !isInline() && !isFloatingOrPositioned() && parent() && parent()->isDeprecatedFlexibleBox(); }
409 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
410 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
412 LayoutPoint flipForWritingModeForChild(const RenderBox* child, const LayoutPoint&) const;
413 int flipForWritingMode(int position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
414 IntPoint flipForWritingMode(const IntPoint&) const;
415 LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
416 IntSize flipForWritingMode(const IntSize&) const;
417 void flipForWritingMode(IntRect&) const;
418 FloatPoint flipForWritingMode(const FloatPoint&) const;
419 void flipForWritingMode(FloatRect&) const;
420 // These represent your location relative to your container as a physical offset.
421 // In layout related methods you almost always want the logical location (e.g. x() and y()).
422 LayoutPoint topLeftLocation() const;
423 LayoutSize topLeftLocationOffset() const;
425 LayoutRect logicalVisualOverflowRectForPropagation(RenderStyle*) const;
426 LayoutRect visualOverflowRectForPropagation(RenderStyle*) const;
427 LayoutRect logicalLayoutOverflowRectForPropagation(RenderStyle*) const;
428 LayoutRect layoutOverflowRectForPropagation(RenderStyle*) const;
430 RenderOverflow* hasRenderOverflow() const { return m_overflow.get(); }
431 bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); }
433 virtual bool needsPreferredWidthsRecalculation() const;
434 virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
437 virtual void willBeDestroyed();
439 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
440 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
441 virtual void updateBoxModelInfoFromStyle();
443 virtual bool backgroundIsObscured() const { return false; }
444 void paintBackground(const PaintInfo&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone);
446 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, CompositeOperator, RenderObject* backgroundObject);
447 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
449 void paintMaskImages(const PaintInfo&, const LayoutRect&);
452 void paintCustomHighlight(const LayoutPoint&, const AtomicString& type, bool behindText);
455 void computePositionedLogicalWidth(RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0);
457 virtual bool shouldComputeSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
459 virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&, bool* wasFixed = 0) const;
460 virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
462 void paintRootBoxFillLayers(const PaintInfo&);
465 bool includeVerticalScrollbarSize() const;
466 bool includeHorizontalScrollbarSize() const;
468 // Returns true if we did a full repaint
469 bool repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground);
471 LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0,
472 LayoutUnit offsetFromLogicalTopOfFirstPage = 0, bool checkForPerpendicularWritingMode = true) const;
473 LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
475 void computePositionedLogicalHeight();
476 void computePositionedLogicalWidthUsing(Length logicalWidth, const RenderBoxModelObject* containerBlock, TextDirection containerDirection,
477 LayoutUnit containerLogicalWidth, LayoutUnit bordersPlusPadding,
478 Length logicalLeft, Length logicalRight, Length marginLogicalLeft, Length marginLogicalRight,
479 LayoutUnit& logicalWidthValue, LayoutUnit& marginLogicalLeftValue, LayoutUnit& marginLogicalRightValue, LayoutUnit& logicalLeftPos);
480 void computePositionedLogicalHeightUsing(Length logicalHeight, const RenderBoxModelObject* containerBlock,
481 LayoutUnit containerLogicalHeight, LayoutUnit bordersPlusPadding,
482 Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom,
483 LayoutUnit& logicalHeightValue, LayoutUnit& marginLogicalTopValue, LayoutUnit& marginLogicalBottomValue, LayoutUnit& logicalTopPos);
485 void computePositionedLogicalHeightReplaced();
486 void computePositionedLogicalWidthReplaced();
488 // This function calculates the minimum and maximum preferred widths for an object.
489 // These values are used in shrink-to-fit layout systems.
490 // These include tables, positioned objects, floats and flexible boxes.
491 virtual void computePreferredLogicalWidths() { setPreferredLogicalWidthsDirty(false); }
493 BackgroundBleedAvoidance determineBackgroundBleedAvoidance(GraphicsContext*) const;
496 // The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent).
497 LayoutRect m_frameRect;
500 LayoutUnit m_marginLeft;
501 LayoutUnit m_marginRight;
502 LayoutUnit m_marginTop;
503 LayoutUnit m_marginBottom;
505 // The preferred logical width of the element if it were to break its lines at every possible opportunity.
506 LayoutUnit m_minPreferredLogicalWidth;
508 // The preferred logical width of the element if it never breaks any lines at all.
509 LayoutUnit m_maxPreferredLogicalWidth;
511 // For inline replaced elements, the inline box that owns us.
512 InlineBox* m_inlineBoxWrapper;
514 // Our overflow information.
515 OwnPtr<RenderOverflow> m_overflow;
518 // Used to store state between styleWillChange and styleDidChange
519 static bool s_hadOverflowClip;
522 inline RenderBox* toRenderBox(RenderObject* object)
524 ASSERT(!object || object->isBox());
525 return static_cast<RenderBox*>(object);
528 inline const RenderBox* toRenderBox(const RenderObject* object)
530 ASSERT(!object || object->isBox());
531 return static_cast<const RenderBox*>(object);
534 // This will catch anyone doing an unnecessary cast.
535 void toRenderBox(const RenderBox*);
537 inline RenderBox* RenderBox::previousSiblingBox() const
539 return toRenderBox(previousSibling());
542 inline RenderBox* RenderBox::nextSiblingBox() const
544 return toRenderBox(nextSibling());
547 inline RenderBox* RenderBox::parentBox() const
549 return toRenderBox(parent());
552 inline RenderBox* RenderBox::firstChildBox() const
554 return toRenderBox(firstChild());
557 inline RenderBox* RenderBox::lastChildBox() const
559 return toRenderBox(lastChild());
562 } // namespace WebCore
564 #endif // RenderBox_h