2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
7 * Copyright (C) 2009 Google Inc. All rights reserved.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
26 #ifndef RenderObject_h
27 #define RenderObject_h
29 #include "CachedImageClient.h"
31 #include "FloatQuad.h"
33 #include "LayoutRect.h"
34 #include "PaintPhase.h"
35 #include "RenderStyle.h"
36 #include "ScrollBehavior.h"
37 #include "StyleImage.h"
38 #include "TextAffinity.h"
42 class AffineTransform;
43 class AnimationController;
47 class HitTestLocation;
53 class PseudoStyleRequest;
54 class RenderBoxModelObject;
58 class RenderFlowThread;
59 class RenderGeometryMap;
61 class RenderLayerModelObject;
62 class RenderNamedFlowFragment;
63 class RenderNamedFlowThread;
66 class SelectionSubtreeRoot;
68 class VisiblePosition;
76 enum CursorDirective {
77 SetCursorBasedOnStyle,
89 HitTestBlockBackground,
90 HitTestChildBlockBackground,
91 HitTestChildBlockBackgrounds,
96 // Sides used when drawing borders and outlines. The values should run clockwise from top.
104 enum MarkingBehavior {
106 MarkContainingBlockChain,
109 enum class ScheduleRelayout { No, Yes };
111 enum MapCoordinatesMode {
113 UseTransforms = 1 << 1,
114 ApplyContainerFlip = 1 << 2
116 typedef unsigned MapCoordinatesFlags;
119 const int caretWidth = 2; // This value should be kept in sync with UIKit. See <rdar://problem/15580601>.
121 const int caretWidth = 1;
124 #if ENABLE(DASHBOARD_SUPPORT)
125 struct AnnotatedRegionValue {
126 bool operator==(const AnnotatedRegionValue& o) const
128 return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
130 bool operator!=(const AnnotatedRegionValue& o) const
132 return !(*this == o);
142 // Base class for all rendering tree objects.
143 class RenderObject : public CachedImageClient {
144 WTF_MAKE_FAST_ALLOCATED;
145 friend class RenderBlock;
146 friend class RenderBlockFlow;
147 friend class RenderElement;
148 friend class RenderLayer;
150 // Anonymous objects should pass the document as their node, and they will then automatically be
151 // marked as anonymous in the constructor.
152 explicit RenderObject(Node&);
153 virtual ~RenderObject();
155 RenderTheme& theme() const;
157 virtual const char* renderName() const = 0;
159 RenderElement* parent() const { return m_parent; }
160 bool isDescendantOf(const RenderObject*) const;
162 RenderObject* previousSibling() const { return m_previous; }
163 RenderObject* nextSibling() const { return m_next; }
165 // Use RenderElement versions instead.
166 virtual RenderObject* firstChildSlow() const { return nullptr; }
167 virtual RenderObject* lastChildSlow() const { return nullptr; }
169 RenderObject* nextInPreOrder() const;
170 RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
171 RenderObject* nextInPreOrderAfterChildren() const;
172 RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
173 RenderObject* previousInPreOrder() const;
174 RenderObject* previousInPreOrder(const RenderObject* stayWithin) const;
175 WEBCORE_EXPORT RenderObject* childAt(unsigned) const;
177 RenderObject* firstLeafChild() const;
178 RenderObject* lastLeafChild() const;
180 #if ENABLE(IOS_TEXT_AUTOSIZING)
181 // Minimal distance between the block with fixed height and overflowing content and the text block to apply text autosizing.
182 // The greater this constant is the more potential places we have where autosizing is turned off.
183 // So it should be as low as possible. There are sites that break at 2.
184 static const int TextAutoSizingFixedHeightDepth = 3;
186 enum BlockContentHeightType {
192 typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&);
193 RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const;
196 WEBCORE_EXPORT RenderLayer* enclosingLayer() const;
198 // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
199 WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
201 // Convenience function for getting to the nearest enclosing box of a RenderObject.
202 RenderBox& enclosingBox() const;
203 RenderBoxModelObject& enclosingBoxModelObject() const;
205 bool fixedPositionedWithNamedFlowContainingBlock() const;
207 // Function to return our enclosing flow thread if we are contained inside one. This
208 // function follows the containing block chain.
209 RenderFlowThread* flowThreadContainingBlock() const
211 if (flowThreadState() == NotInsideFlowThread)
214 return locateFlowThreadContainingBlock();
217 RenderNamedFlowFragment* currentRenderNamedFlowFragment() const;
219 // FIXME: The meaning of this function is unclear.
220 virtual bool isEmpty() const { return !firstChildSlow(); }
223 void setHasAXObject(bool flag) { m_hasAXObject = flag; }
224 bool hasAXObject() const { return m_hasAXObject; }
226 // Helper class forbidding calls to setNeedsLayout() during its lifetime.
227 class SetLayoutNeededForbiddenScope {
229 explicit SetLayoutNeededForbiddenScope(RenderObject*, bool isForbidden = true);
230 ~SetLayoutNeededForbiddenScope();
232 RenderObject* m_renderObject;
233 bool m_preexistingForbidden;
237 // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
239 virtual RenderBlock* firstLineBlock() const;
241 // RenderObject tree manipulation
242 //////////////////////////////////////////
243 virtual bool canHaveChildren() const = 0;
244 virtual bool canHaveGeneratedChildren() const;
245 virtual bool createsAnonymousWrapper() const { return false; }
246 //////////////////////////////////////////
248 #if ENABLE(TREE_DEBUGGING)
249 void showNodeTreeForThis() const;
250 void showRenderTreeForThis() const;
251 void showLineTreeForThis() const;
253 void showRenderObject(bool mark, int depth) const;
254 void showRenderSubTreeAndMark(const RenderObject* markedObject, int depth) const;
255 void showRegionsInformation() const;
258 bool isPseudoElement() const { return node() && node()->isPseudoElement(); }
260 bool isRenderElement() const { return !isText(); }
261 bool isRenderReplaced() const;
262 bool isBoxModelObject() const;
263 bool isRenderBlock() const;
264 bool isRenderBlockFlow() const;
265 bool isRenderInline() const;
266 bool isRenderLayerModelObject() const;
268 virtual bool isCounter() const { return false; }
269 virtual bool isQuote() const { return false; }
271 #if ENABLE(DETAILS_ELEMENT)
272 virtual bool isDetailsMarker() const { return false; }
274 virtual bool isEmbeddedObject() const { return false; }
275 virtual bool isFieldset() const { return false; }
276 virtual bool isFileUploadControl() const { return false; }
277 virtual bool isFrame() const { return false; }
278 virtual bool isFrameSet() const { return false; }
279 virtual bool isImage() const { return false; }
280 virtual bool isInlineBlockOrInlineTable() const { return false; }
281 virtual bool isListBox() const { return false; }
282 virtual bool isListItem() const { return false; }
283 virtual bool isListMarker() const { return false; }
284 virtual bool isMedia() const { return false; }
285 virtual bool isMenuList() const { return false; }
286 #if ENABLE(METER_ELEMENT)
287 virtual bool isMeter() const { return false; }
289 virtual bool isSnapshottedPlugIn() const { return false; }
290 virtual bool isProgress() const { return false; }
291 virtual bool isRenderSVGBlock() const { return false; };
292 virtual bool isRenderButton() const { return false; }
293 virtual bool isRenderIFrame() const { return false; }
294 virtual bool isRenderImage() const { return false; }
295 virtual bool isRenderRegion() const { return false; }
296 virtual bool isRenderNamedFlowFragment() const { return false; }
297 virtual bool isReplica() const { return false; }
299 virtual bool isRubyInline() const { return false; }
300 virtual bool isRubyBlock() const { return false; }
301 virtual bool isRubyBase() const { return false; }
302 virtual bool isRubyRun() const { return false; }
303 virtual bool isRubyText() const { return false; }
305 virtual bool isSlider() const { return false; }
306 virtual bool isSliderThumb() const { return false; }
307 virtual bool isTable() const { return false; }
308 virtual bool isTableCell() const { return false; }
309 virtual bool isRenderTableCol() const { return false; }
310 virtual bool isTableCaption() const { return false; }
311 virtual bool isTableRow() const { return false; }
312 virtual bool isTableSection() const { return false; }
313 virtual bool isTextControl() const { return false; }
314 virtual bool isTextArea() const { return false; }
315 virtual bool isTextField() const { return false; }
316 virtual bool isTextControlInnerBlock() const { return false; }
317 virtual bool isVideo() const { return false; }
318 virtual bool isWidget() const { return false; }
319 virtual bool isCanvas() const { return false; }
320 #if ENABLE(ATTACHMENT_ELEMENT)
321 virtual bool isAttachment() const { return false; }
323 #if ENABLE(FULLSCREEN_API)
324 virtual bool isRenderFullScreen() const { return false; }
325 virtual bool isRenderFullScreenPlaceholder() const { return false; }
327 #if ENABLE(CSS_GRID_LAYOUT)
328 virtual bool isRenderGrid() const { return false; }
330 virtual bool isRenderNamedFlowThread() const { return false; }
331 bool isInFlowRenderFlowThread() const { return isRenderFlowThread() && !isOutOfFlowPositioned(); }
332 bool isOutOfFlowRenderFlowThread() const { return isRenderFlowThread() && isOutOfFlowPositioned(); }
334 virtual bool isMultiColumnBlockFlow() const { return false; }
335 virtual bool isRenderMultiColumnSet() const { return false; }
336 virtual bool isRenderMultiColumnFlowThread() const { return false; }
337 virtual bool isRenderMultiColumnSpannerPlaceholder() const { return false; }
339 virtual bool isRenderScrollbarPart() const { return false; }
341 bool isDocumentElementRenderer() const { return document().documentElement() == &m_node; }
342 bool isBody() const { return node() && node()->hasTagName(HTMLNames::bodyTag); }
343 bool isHR() const { return node() && node()->hasTagName(HTMLNames::hrTag); }
344 bool isLegend() const;
346 bool isHTMLMarquee() const;
348 bool isTablePart() const { return isTableCell() || isRenderTableCol() || isTableCaption() || isTableRow() || isTableSection(); }
350 inline bool isBeforeContent() const;
351 inline bool isAfterContent() const;
352 inline bool isBeforeOrAfterContent() const;
353 static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
354 static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
355 static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
357 bool beingDestroyed() const { return m_bitfields.beingDestroyed(); }
359 bool everHadLayout() const { return m_bitfields.everHadLayout(); }
361 bool childrenInline() const { return m_bitfields.childrenInline(); }
362 void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
364 enum FlowThreadState {
365 NotInsideFlowThread = 0,
366 InsideOutOfFlowThread = 1,
367 InsideInFlowThread = 2,
370 void setFlowThreadStateIncludingDescendants(FlowThreadState);
372 FlowThreadState flowThreadState() const { return m_bitfields.flowThreadState(); }
373 void setFlowThreadState(FlowThreadState state) { m_bitfields.setFlowThreadState(state); }
375 virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
378 virtual bool isRenderMathMLBlock() const { return false; }
379 virtual bool isRenderMathMLTable() const { return false; }
380 virtual bool isRenderMathMLOperator() const { return false; }
381 virtual bool isRenderMathMLRadicalOperator() const { return false; }
382 virtual bool isRenderMathMLRow() const { return false; }
383 virtual bool isRenderMathMLMath() const { return false; }
384 virtual bool isRenderMathMLMenclose() const { return false; }
385 virtual bool isRenderMathMLFenced() const { return false; }
386 virtual bool isRenderMathMLFraction() const { return false; }
387 virtual bool isRenderMathMLRoot() const { return false; }
388 virtual bool isRenderMathMLRootWrapper() const { return false; }
389 virtual bool isRenderMathMLSpace() const { return false; }
390 virtual bool isRenderMathMLSquareRoot() const { return false; }
391 virtual bool isRenderMathMLScripts() const { return false; }
392 virtual bool isRenderMathMLScriptsWrapper() const { return false; }
393 virtual bool isRenderMathMLToken() const { return false; }
394 virtual bool isRenderMathMLUnderOver() const { return false; }
395 #endif // ENABLE(MATHML)
397 // FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
398 // to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
399 virtual bool isRenderSVGModelObject() const { return false; }
400 virtual bool isSVGRoot() const { return false; }
401 virtual bool isSVGContainer() const { return false; }
402 virtual bool isSVGTransformableContainer() const { return false; }
403 virtual bool isSVGViewportContainer() const { return false; }
404 virtual bool isSVGGradientStop() const { return false; }
405 virtual bool isSVGHiddenContainer() const { return false; }
406 virtual bool isSVGPath() const { return false; }
407 virtual bool isSVGShape() const { return false; }
408 virtual bool isSVGText() const { return false; }
409 virtual bool isSVGTextPath() const { return false; }
410 virtual bool isSVGTSpan() const { return false; }
411 virtual bool isSVGInline() const { return false; }
412 virtual bool isSVGInlineText() const { return false; }
413 virtual bool isSVGImage() const { return false; }
414 virtual bool isSVGForeignObject() const { return false; }
415 virtual bool isSVGResourceContainer() const { return false; }
416 virtual bool isSVGResourceFilter() const { return false; }
417 virtual bool isSVGResourceClipper() const { return false; }
418 virtual bool isSVGResourceFilterPrimitive() const { return false; }
420 // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
421 // Unfortunately we don't have such a class yet, because it's not possible for all renderers
422 // to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
423 virtual void setNeedsTransformUpdate() { }
424 virtual void setNeedsBoundariesUpdate();
425 virtual bool needsBoundariesUpdate() { return false; }
427 // Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
428 // This is used for all computation of objectBoundingBox relative units and by SVGLocatable::getBBox().
429 // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we ignore them
430 // since stroke-width is ignored (and marker size can depend on stroke-width).
431 // objectBoundingBox is returned local coordinates.
432 // The name objectBoundingBox is taken from the SVG 1.1 spec.
433 virtual FloatRect objectBoundingBox() const;
434 virtual FloatRect strokeBoundingBox() const;
436 // Returns the smallest rectangle enclosing all of the painted content
437 // respecting clipping, masking, filters, opacity, stroke-width and markers
438 virtual FloatRect repaintRectInLocalCoordinates() const;
440 // This only returns the transform="" value from the element
441 // most callsites want localToParentTransform() instead.
442 virtual AffineTransform localTransform() const;
444 // Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
445 // This includes any viewport transforms and x/y offsets as well as the transform="" value off the element.
446 virtual const AffineTransform& localToParentTransform() const;
448 // SVG uses FloatPoint precise hit testing, and passes the point in parent
449 // coordinates instead of in repaint container coordinates. Eventually the
450 // rest of the rendering tree will move to a similar model.
451 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
453 bool hasAspectRatio() const { return isReplaced() && (isImage() || isVideo() || isCanvas()); }
454 bool isAnonymous() const { return m_bitfields.isAnonymous(); }
455 bool isAnonymousBlock() const
457 // This function is kept in sync with anonymous block creation conditions in
458 // RenderBlock::createAnonymousBlock(). This includes creating an anonymous
459 // RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
460 // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709.
461 return isAnonymous() && (style().display() == BLOCK || style().display() == BOX) && style().styleType() == NOPSEUDO && isRenderBlock() && !isListMarker() && !isRenderFlowThread() && !isRenderMultiColumnSet() && !isRenderView()
462 #if ENABLE(FULLSCREEN_API)
463 && !isRenderFullScreen()
464 && !isRenderFullScreenPlaceholder()
467 && !isRenderMathMLBlock()
471 bool isAnonymousInlineBlock() const;
472 bool isElementContinuation() const { return node() && node()->renderer() != this; }
473 bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
474 bool isBlockElementContinuation() const { return isElementContinuation() && !isInline(); }
475 virtual RenderBoxModelObject* virtualContinuation() const { return nullptr; }
477 bool isFloating() const { return m_bitfields.floating(); }
479 bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositioned(); } // absolute or fixed positioning
480 bool isInFlowPositioned() const { return m_bitfields.isRelPositioned() || m_bitfields.isStickyPositioned(); } // relative or sticky positioning
481 bool isRelPositioned() const { return m_bitfields.isRelPositioned(); } // relative positioning
482 bool isStickyPositioned() const { return m_bitfields.isStickyPositioned(); }
483 bool isPositioned() const { return m_bitfields.isPositioned(); }
485 bool isText() const { return !m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
486 bool isLineBreak() const { return m_bitfields.isLineBreak(); }
487 bool isBR() const { return isLineBreak() && !isWBR(); }
488 bool isLineBreakOpportunity() const { return isLineBreak() && isWBR(); }
489 bool isTextOrLineBreak() const { return isText() || isLineBreak(); }
490 bool isBox() const { return m_bitfields.isBox(); }
491 bool isRenderView() const { return m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
492 bool isInline() const { return m_bitfields.isInline(); } // inline object
493 bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced" element (see CSS)
494 bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
496 bool isDragging() const { return m_bitfields.hasRareData() && rareData().isDragging(); }
497 bool hasReflection() const { return m_bitfields.hasRareData() && rareData().hasReflection(); }
498 bool isRenderFlowThread() const { return m_bitfields.hasRareData() && rareData().isRenderFlowThread(); }
499 bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
500 bool isRegisteredForVisibleInViewportCallback() { return m_bitfields.hasRareData() && rareData().isRegisteredForVisibleInViewportCallback(); }
502 enum VisibleInViewportState {
505 NotVisibleInViewport,
507 VisibleInViewportState visibleInViewportState() { return m_bitfields.hasRareData() ? rareData().visibleInViewportState() : VisibilityUnknown; }
509 bool hasLayer() const { return m_bitfields.hasLayer(); }
510 bool hasSelfPaintingLayer() const;
512 enum BoxDecorationState {
514 HasBoxDecorationsAndBackgroundObscurationStatusInvalid,
515 HasBoxDecorationsAndBackgroundIsKnownToBeObscured,
516 HasBoxDecorationsAndBackgroundMayBeVisible,
518 bool hasVisibleBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
519 bool backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset);
520 bool hasEntirelyFixedBackground() const;
522 bool needsLayout() const
524 return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
525 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.needsPositionedMovementLayout();
528 bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
529 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
530 bool needsPositionedMovementLayoutOnly() const
532 return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
533 && !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifiedNormalFlowLayout();
536 bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
537 bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
538 bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
540 bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
542 bool isSelectionBorder() const;
544 bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
546 bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } // Transform, perspective or transform-style: preserve-3d.
547 bool hasTransform() const { return hasTransformRelatedProperty() && style().hasTransform(); }
549 inline bool preservesNewline() const;
551 virtual void updateDragState(bool dragOn);
553 RenderView& view() const { return *document().renderView(); };
555 // Returns true if this renderer is rooted.
556 bool isRooted() const;
558 Node* node() const { return isAnonymous() ? nullptr : &m_node; }
559 Node* nonPseudoNode() const { return isPseudoElement() ? nullptr : node(); }
561 // Returns the styled node that caused the generation of this renderer.
562 // This is the same as node() except for renderers of :before and :after
563 // pseudo elements for which their parent node is returned.
564 Node* generatingNode() const { return isPseudoElement() ? generatingPseudoHostElement() : node(); }
566 Document& document() const { return m_node.document(); }
567 Frame& frame() const;
569 bool hasOutlineAnnotation() const;
570 bool hasOutline() const { return style().hasOutline() || hasOutlineAnnotation(); }
572 // Returns the object containing this one. Can be different from parent for positioned elements.
573 // If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
574 // is true if the renderer returned is an ancestor of repaintContainer.
575 RenderElement* container() const;
576 RenderElement* container(const RenderLayerModelObject* repaintContainer, bool& repaintContainerSkipped) const;
578 RenderBoxModelObject* offsetParent() const;
580 void markContainingBlocksForLayout(ScheduleRelayout = ScheduleRelayout::Yes, RenderElement* newRoot = nullptr);
581 void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain);
582 void clearNeedsLayout();
583 void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
584 void invalidateContainerPreferredLogicalWidths();
586 void setNeedsLayoutAndPrefWidthsRecalc()
589 setPreferredLogicalWidthsDirty(true);
592 void setPositionState(EPosition position)
594 ASSERT((position != AbsolutePosition && position != FixedPosition) || isBox());
595 m_bitfields.setPositionedState(position);
597 void clearPositionedState() { m_bitfields.clearPositionedState(); }
599 void setFloating(bool b = true) { m_bitfields.setFloating(b); }
600 void setInline(bool b = true) { m_bitfields.setIsInline(b); }
602 void setHasVisibleBoxDecorations(bool = true);
603 void invalidateBackgroundObscurationStatus();
604 virtual bool computeBackgroundIsKnownToBeObscured(const LayoutPoint&) { return false; }
606 void setIsText() { ASSERT(!isBox()); m_bitfields.setIsTextOrRenderView(true); }
607 void setIsLineBreak() { m_bitfields.setIsLineBreak(true); }
608 void setIsBox() { m_bitfields.setIsBox(true); }
609 void setIsRenderView() { ASSERT(isBox()); m_bitfields.setIsTextOrRenderView(true); }
610 void setReplaced(bool b = true) { m_bitfields.setIsReplaced(b); }
611 void setHorizontalWritingMode(bool b = true) { m_bitfields.setHorizontalWritingMode(b); }
612 void setHasOverflowClip(bool b = true) { m_bitfields.setHasOverflowClip(b); }
613 void setHasLayer(bool b = true) { m_bitfields.setHasLayer(b); }
614 void setHasTransformRelatedProperty(bool b = true) { m_bitfields.setHasTransformRelatedProperty(b); }
616 void setIsDragging(bool);
617 void setHasReflection(bool = true);
618 void setIsRenderFlowThread(bool = true);
619 void setHasOutlineAutoAncestor(bool = true);
620 void setIsRegisteredForVisibleInViewportCallback(bool);
621 void setVisibleInViewportState(VisibleInViewportState);
623 // Hook so that RenderTextControl can return the line height of its inner renderer.
624 // For other renderers, the value is the same as lineHeight(false).
625 virtual int innerLineHeight() const;
627 // used for element state updates that cannot be fixed with a
628 // repaint and do not need a relayout
629 virtual void updateFromElement() { }
631 #if ENABLE(DASHBOARD_SUPPORT)
632 virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&);
633 void collectAnnotatedRegions(Vector<AnnotatedRegionValue>&);
636 bool isComposited() const;
638 bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
639 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
640 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
642 virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*);
643 VisiblePosition createVisiblePosition(int offset, EAffinity) const;
644 VisiblePosition createVisiblePosition(const Position&) const;
646 // returns the containing block level element for this element.
647 RenderBlock* containingBlock() const;
648 RenderBlock* containingBlockForFixedPosition() const;
649 RenderBlock* containingBlockForAbsolutePosition() const;
650 RenderBlock* containingBlockForObjectInFlow() const;
652 // Convert the given local point to absolute coordinates. If MapCoordinatesFlags includes UseTransforms, take transforms into account.
653 WEBCORE_EXPORT FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const;
654 FloatPoint absoluteToLocal(const FloatPoint&, MapCoordinatesFlags = 0) const;
656 // Convert a local quad to absolute coordinates, taking transforms into account.
657 FloatQuad localToAbsoluteQuad(const FloatQuad& quad, MapCoordinatesFlags mode = UseTransforms, bool* wasFixed = nullptr) const
659 return localToContainerQuad(quad, nullptr, mode, wasFixed);
661 // Convert an absolute quad to local coordinates.
662 FloatQuad absoluteToLocalQuad(const FloatQuad&, MapCoordinatesFlags mode = UseTransforms) const;
664 // Convert a local quad into the coordinate system of container, taking transforms into account.
665 WEBCORE_EXPORT FloatQuad localToContainerQuad(const FloatQuad&, const RenderLayerModelObject* repaintContainer, MapCoordinatesFlags = UseTransforms, bool* wasFixed = nullptr) const;
666 WEBCORE_EXPORT FloatPoint localToContainerPoint(const FloatPoint&, const RenderLayerModelObject* repaintContainer, MapCoordinatesFlags = UseTransforms, bool* wasFixed = nullptr) const;
668 // Return the offset from the container() renderer (excluding transforms). In multi-column layout,
669 // different offsets apply at different points, so return the offset that applies to the given point.
670 virtual LayoutSize offsetFromContainer(RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = nullptr) const;
671 // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
672 LayoutSize offsetFromAncestorContainer(RenderElement&) const;
675 virtual void collectSelectionRects(Vector<SelectionRect>&, unsigned startOffset = 0, unsigned endOffset = std::numeric_limits<unsigned>::max());
676 virtual void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const { absoluteQuads(quads); }
679 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
681 // FIXME: useTransforms should go away eventually
682 WEBCORE_EXPORT IntRect absoluteBoundingBoxRect(bool useTransform = true, bool* wasFixed = nullptr) const;
683 IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
685 // Build an array of quads in absolute coords for line boxes
686 virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = nullptr) const { }
688 virtual void absoluteFocusRingQuads(Vector<FloatQuad>&);
690 static FloatRect absoluteBoundingBoxRectForRange(const Range*);
692 // the rect that will be painted if this object is passed as the paintingRoot
693 WEBCORE_EXPORT LayoutRect paintingRootRect(LayoutRect& topLevelRect);
695 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
696 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
698 const RenderStyle& style() const;
699 const RenderStyle& firstLineStyle() const;
701 // Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
702 // This is typically only relevant when repainting.
703 virtual const RenderStyle& outlineStyleForRepaint() const { return style(); }
705 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
707 void getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
708 TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false) const;
710 // Return the RenderLayerModelObject in the container chain which is responsible for painting this object, or nullptr
711 // if painting is root-relative. This is the container that should be passed to the 'forRepaint'
713 RenderLayerModelObject* containerForRepaint() const;
714 // Actually do the repaint of rect r for this object which has been computed in the coordinate space
715 // of repaintContainer. If repaintContainer is nullptr, repaint via the view.
716 void repaintUsingContainer(const RenderLayerModelObject* repaintContainer, const LayoutRect&, bool shouldClipToLayer = true) const;
718 // Repaint the entire object. Called when, e.g., the color of a border changes, or when a border
720 void repaint() const;
722 // Repaint a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
723 WEBCORE_EXPORT void repaintRectangle(const LayoutRect&, bool shouldClipToLayer = true) const;
725 // Repaint a slow repaint object, which, at this time, means we are repainting an object with background-attachment:fixed.
726 void repaintSlowRepaintObject() const;
728 bool checkForRepaintDuringLayout() const;
730 // Returns the rect that should be repainted whenever this object changes. The rect is in the view's
731 // coordinate space. This method deals with outlines and overflow.
732 LayoutRect absoluteClippedOverflowRect() const
734 return clippedOverflowRectForRepaint(nullptr);
736 WEBCORE_EXPORT IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
737 virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const;
738 virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const;
739 virtual LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* /*repaintContainer*/, const RenderGeometryMap* = nullptr) const { return LayoutRect(); }
741 // Given a rect in the object's coordinate space, compute a rect suitable for repainting
742 // that rect in view coordinates.
743 LayoutRect computeAbsoluteRepaintRect(const LayoutRect& r, bool fixed = false) const
745 return computeRectForRepaint(r, nullptr, { fixed, false });
747 // Given a rect in the object's coordinate space, compute a rect suitable for repainting
748 // that rect in the coordinate space of repaintContainer.
749 struct RepaintContext {
750 RepaintContext(bool hasPositionFixedDescendant, bool dirtyRectIsFlipped)
751 : m_hasPositionFixedDescendant(hasPositionFixedDescendant)
752 , m_dirtyRectIsFlipped(dirtyRectIsFlipped)
755 bool m_hasPositionFixedDescendant { false };
756 bool m_dirtyRectIsFlipped { false };
758 virtual LayoutRect computeRectForRepaint(const LayoutRect&, const RenderLayerModelObject* repaintContainer, RepaintContext = { false, false }) const;
759 virtual FloatRect computeFloatRectForRepaint(const FloatRect&, const RenderLayerModelObject* repaintContainer, bool fixed = false) const;
761 virtual unsigned int length() const { return 1; }
763 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
765 enum SelectionState {
766 SelectionNone, // The object is not selected.
767 SelectionStart, // The object either contains the start of a selection run or is the start of a run
768 SelectionInside, // The object is fully encompassed by a selection run
769 SelectionEnd, // The object either contains the end of a selection run or is the end of a run
770 SelectionBoth // The object contains an entire run or is the sole selected object in that run
773 // The current selection state for an object. For blocks, the state refers to the state of the leaf
774 // descendants (as described above in the SelectionState enum declaration).
775 SelectionState selectionState() const { return m_bitfields.selectionState(); }
776 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelectionState(state); }
777 inline void setSelectionStateIfNeeded(SelectionState);
778 bool canUpdateSelectionOnRootLineBoxes();
780 // A single rectangle that encompasses all of the selected objects within this object. Used to determine the tightest
781 // possible bounding box for the selection.
782 LayoutRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(nullptr, clipToVisibleContent); }
783 virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return LayoutRect(); }
785 virtual bool canBeSelectionLeaf() const { return false; }
786 bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
788 // Whether or not a given block needs to paint selection gaps.
789 virtual bool shouldPaintSelectionGaps() const { return false; }
792 * Returns the local coordinates of the caret within this render object.
793 * @param caretOffset zero-based offset determining position within the render object.
794 * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
795 * useful for character range rect computations
797 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr);
799 // When performing a global document tear-down, the renderer of the document is cleared. We use this
800 // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
801 bool documentBeingDestroyed() const;
803 void destroyAndCleanupAnonymousWrappers();
806 // Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
807 virtual bool isDeprecatedFlexibleBox() const { return false; }
809 // Virtual function helper for the new FlexibleBox Layout (display: -webkit-flex).
810 virtual bool isFlexibleBox() const { return false; }
812 bool isFlexibleBoxIncludingDeprecated() const
814 return isFlexibleBox() || isDeprecatedFlexibleBox();
817 virtual bool isCombineText() const { return false; }
819 virtual int caretMinOffset() const;
820 virtual int caretMaxOffset() const;
822 virtual int previousOffset(int current) const;
823 virtual int previousOffsetForBackwardDeletion(int current) const;
824 virtual int nextOffset(int current) const;
826 void imageChanged(CachedImage*, const IntRect* = nullptr) override;
827 virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { }
829 SelectionSubtreeRoot& selectionRoot() const;
830 void selectionStartEnd(int& spos, int& epos) const;
832 void removeFromParent();
834 AnimationController& animation() const;
836 // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
837 // localToAbsolute/absoluteToLocal methods instead.
838 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed = nullptr) const;
839 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const;
841 // Pushes state onto RenderGeometryMap about how to map coordinates from this renderer to its container, or ancestorToStopAt (whichever is encountered first).
842 // Returns the renderer which was mapped to (container or ancestorToStopAt).
843 virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const;
845 bool shouldUseTransformFromContainer(const RenderObject* container) const;
846 void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
848 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& /* additionalOffset */, const RenderLayerModelObject* /* paintContainer */ = nullptr) { };
850 LayoutRect absoluteOutlineBounds() const
852 return outlineBoundsForRepaint(nullptr);
855 RespectImageOrientationEnum shouldRespectImageOrientation() const;
858 //////////////////////////////////////////
859 // Helper functions. Dangerous to use!
860 void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
861 void setNextSibling(RenderObject* next) { m_next = next; }
862 void setParent(RenderElement*);
863 //////////////////////////////////////////
864 void addPDFURLRect(PaintInfo&, const LayoutPoint&);
865 Node& nodeForNonAnonymous() const { ASSERT(!isAnonymous()); return m_node; }
867 void adjustRectForOutlineAndShadow(LayoutRect&) const;
869 virtual void willBeDestroyed();
871 virtual void insertedIntoTree();
872 virtual void willBeRemovedFromTree();
874 void setNeedsPositionedMovementLayoutBit(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
875 void setNormalChildNeedsLayoutBit(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
876 void setPosChildNeedsLayoutBit(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
877 void setNeedsSimplifiedNormalFlowLayoutBit(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
879 virtual RenderFlowThread* locateFlowThreadContainingBlock() const;
880 void invalidateFlowThreadContainingBlockIncludingDescendants(RenderFlowThread* = nullptr);
881 static void calculateBorderStyleColor(const EBorderStyle&, const BoxSide&, Color&);
885 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
886 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
889 void addAbsoluteRectForLayer(LayoutRect& result);
890 void setLayerNeedsFullRepaint();
891 void setLayerNeedsFullRepaintForPositionedMovementLayout();
893 void removeFromRenderFlowThread();
894 void removeFromRenderFlowThreadIncludingDescendants(bool);
895 Node* generatingPseudoHostElement() const;
897 void propagateRepaintToParentWithOutlineAutoIfNeeded(const RenderLayerModelObject& repaintContainer, const LayoutRect& repaintRect) const;
899 virtual bool isWBR() const { ASSERT_NOT_REACHED(); return false; }
901 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
903 bool hasRareData() const { return m_bitfields.hasRareData(); }
904 void setHasRareData(bool b) { m_bitfields.setHasRareData(b); }
907 void checkBlockPositionedObjectsNeedLayout();
912 RenderElement* m_parent;
913 RenderObject* m_previous;
914 RenderObject* m_next;
917 bool m_hasAXObject : 1;
918 bool m_setNeedsLayoutForbidden : 1;
921 #define ADD_BOOLEAN_BITFIELD(name, Name) \
923 unsigned m_##name : 1;\
925 bool name() const { return m_##name; }\
926 void set##Name(bool name) { m_##name = name; }\
928 #define ADD_ENUM_BITFIELD(name, Name, Type, width) \
930 unsigned m_##name : width;\
932 Type name() const { return static_cast<Type>(m_##name); }\
933 void set##Name(Type name) { m_##name = static_cast<unsigned>(name); }\
935 class RenderObjectBitfields {
936 enum PositionedState {
937 IsStaticallyPositioned = 0,
938 IsRelativelyPositioned = 1,
939 IsOutOfFlowPositioned = 2,
940 IsStickyPositioned = 3
944 RenderObjectBitfields(const Node& node)
945 : m_hasRareData(false)
946 , m_beingDestroyed(false)
947 , m_needsLayout(false)
948 , m_needsPositionedMovementLayout(false)
949 , m_normalChildNeedsLayout(false)
950 , m_posChildNeedsLayout(false)
951 , m_needsSimplifiedNormalFlowLayout(false)
952 , m_preferredLogicalWidthsDirty(false)
954 , m_isAnonymous(node.isDocumentNode())
955 , m_isTextOrRenderView(false)
958 , m_isReplaced(false)
959 , m_isLineBreak(false)
960 , m_horizontalWritingMode(true)
962 , m_hasOverflowClip(false)
963 , m_hasTransformRelatedProperty(false)
964 , m_everHadLayout(false)
965 , m_childrenInline(false)
966 , m_positionedState(IsStaticallyPositioned)
967 , m_selectionState(SelectionNone)
968 , m_flowThreadState(NotInsideFlowThread)
969 , m_boxDecorationState(NoBoxDecorations)
973 ADD_BOOLEAN_BITFIELD(hasRareData, HasRareData);
975 ADD_BOOLEAN_BITFIELD(beingDestroyed, BeingDestroyed);
976 ADD_BOOLEAN_BITFIELD(needsLayout, NeedsLayout);
977 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovementLayout);
978 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
979 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
980 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNormalFlowLayout);
981 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidthsDirty);
982 ADD_BOOLEAN_BITFIELD(floating, Floating);
984 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
985 ADD_BOOLEAN_BITFIELD(isTextOrRenderView, IsTextOrRenderView);
986 ADD_BOOLEAN_BITFIELD(isBox, IsBox);
987 ADD_BOOLEAN_BITFIELD(isInline, IsInline);
988 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
989 ADD_BOOLEAN_BITFIELD(isLineBreak, IsLineBreak);
990 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
992 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
993 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the case of overflow:auto/scroll/hidden
994 ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedProperty);
995 ADD_BOOLEAN_BITFIELD(unused, Unused);
997 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
1000 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1003 unsigned m_positionedState : 2; // PositionedState
1004 unsigned m_selectionState : 3; // SelectionState
1005 unsigned m_flowThreadState : 2; // FlowThreadState
1006 unsigned m_boxDecorationState : 2; // BoxDecorationState
1009 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOfFlowPositioned; }
1010 bool isRelPositioned() const { return m_positionedState == IsRelativelyPositioned; }
1011 bool isStickyPositioned() const { return m_positionedState == IsStickyPositioned; }
1012 bool isPositioned() const { return m_positionedState != IsStaticallyPositioned; }
1014 void setPositionedState(int positionState)
1016 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowPositioned, saving one bit.
1017 m_positionedState = static_cast<PositionedState>(positionState & 0x3);
1019 void clearPositionedState() { m_positionedState = StaticPosition; }
1021 ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
1022 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
1024 ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_cast<FlowThreadState>(m_flowThreadState); }
1025 ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
1027 ALWAYS_INLINE BoxDecorationState boxDecorationState() const { return static_cast<BoxDecorationState>(m_boxDecorationState); }
1028 ALWAYS_INLINE void setBoxDecorationState(BoxDecorationState boxDecorationState) { m_boxDecorationState = boxDecorationState; }
1031 RenderObjectBitfields m_bitfields;
1033 class RenderObjectRareData {
1035 RenderObjectRareData()
1036 : m_isDragging(false)
1037 , m_hasReflection(false)
1038 , m_isRenderFlowThread(false)
1039 , m_hasOutlineAutoAncestor(false)
1040 , m_isRegisteredForVisibleInViewportCallback(false)
1041 , m_visibleInViewportState(VisibilityUnknown)
1044 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
1045 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
1046 ADD_BOOLEAN_BITFIELD(isRenderFlowThread, IsRenderFlowThread);
1047 ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
1049 // From RenderElement
1050 ADD_BOOLEAN_BITFIELD(isRegisteredForVisibleInViewportCallback, IsRegisteredForVisibleInViewportCallback);
1051 ADD_ENUM_BITFIELD(visibleInViewportState, VisibleInViewportState, VisibleInViewportState, 2);
1055 RenderObjectRareData rareData() const;
1056 RenderObjectRareData& ensureRareData();
1057 void removeRareData();
1059 // Note: RenderObjectRareData is stored by value.
1060 typedef HashMap<const RenderObject*, RenderObjectRareData> RareDataHash;
1062 static RareDataHash& rareDataMap();
1064 #undef ADD_BOOLEAN_BITFIELD
1067 inline Frame& RenderObject::frame() const
1069 return *document().frame();
1072 inline AnimationController& RenderObject::animation() const
1074 return frame().animation();
1077 inline bool RenderObject::documentBeingDestroyed() const
1079 return document().renderTreeBeingDestroyed();
1082 inline bool RenderObject::isBeforeContent() const
1084 // Text nodes don't have their own styles, so ignore the style on a text node.
1087 if (style().styleType() != BEFORE)
1092 inline bool RenderObject::isAfterContent() const
1094 // Text nodes don't have their own styles, so ignore the style on a text node.
1097 if (style().styleType() != AFTER)
1102 inline bool RenderObject::isBeforeOrAfterContent() const
1104 return isBeforeContent() || isAfterContent();
1107 inline void RenderObject::setNeedsLayout(MarkingBehavior markParents)
1109 ASSERT(!isSetNeedsLayoutForbidden());
1110 if (m_bitfields.needsLayout())
1112 m_bitfields.setNeedsLayout(true);
1113 if (markParents == MarkContainingBlockChain)
1114 markContainingBlocksForLayout();
1116 setLayerNeedsFullRepaint();
1119 inline bool RenderObject::preservesNewline() const
1121 if (isSVGInlineText())
1124 return style().preserveNewline();
1127 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
1129 if (selectionState() == state)
1132 setSelectionState(state);
1135 inline void RenderObject::setHasVisibleBoxDecorations(bool b)
1138 m_bitfields.setBoxDecorationState(NoBoxDecorations);
1141 if (hasVisibleBoxDecorations())
1143 m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
1146 inline void RenderObject::invalidateBackgroundObscurationStatus()
1148 if (!hasVisibleBoxDecorations())
1150 m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
1153 inline bool RenderObject::backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset)
1155 if (m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundObscurationStatusInvalid) {
1156 BoxDecorationState boxDecorationState = computeBackgroundIsKnownToBeObscured(paintOffset) ? HasBoxDecorationsAndBackgroundIsKnownToBeObscured : HasBoxDecorationsAndBackgroundMayBeVisible;
1157 m_bitfields.setBoxDecorationState(boxDecorationState);
1159 return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
1162 #if ENABLE(TREE_DEBUGGING)
1163 void printRenderTreeForLiveDocuments();
1164 void printLayerTreeForLiveDocuments();
1167 } // namespace WebCore
1169 #define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \
1170 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
1171 static bool isType(const WebCore::RenderObject& renderer) { return renderer.predicate; } \
1172 SPECIALIZE_TYPE_TRAITS_END()
1174 #if ENABLE(TREE_DEBUGGING)
1175 // Outside the WebCore namespace for ease of invocation from gdb.
1176 void showNodeTree(const WebCore::RenderObject*);
1177 void showLineTree(const WebCore::RenderObject*);
1178 void showRenderTree(const WebCore::RenderObject*);
1181 #endif // RenderObject_h