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 "RenderObjectEnums.h"
36 #include "RenderStyle.h"
37 #include "ScrollBehavior.h"
38 #include "StyleImage.h"
39 #include "TextAffinity.h"
43 class AffineTransform;
44 class AnimationController;
48 class HitTestLocation;
54 class PseudoStyleRequest;
55 class RenderBoxModelObject;
59 class RenderFlowThread;
60 class RenderGeometryMap;
62 class RenderLayerModelObject;
63 class RenderNamedFlowFragment;
64 class RenderNamedFlowThread;
67 class SelectionSubtreeRoot;
69 class VisiblePosition;
78 const int caretWidth = 2; // This value should be kept in sync with UIKit. See <rdar://problem/15580601>.
80 const int caretWidth = 1;
83 #if ENABLE(DASHBOARD_SUPPORT)
84 struct AnnotatedRegionValue {
85 bool operator==(const AnnotatedRegionValue& o) const
87 return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
89 bool operator!=(const AnnotatedRegionValue& o) const
101 // Base class for all rendering tree objects.
102 class RenderObject : public CachedImageClient {
103 WTF_MAKE_FAST_ALLOCATED;
104 friend class RenderBlock;
105 friend class RenderBlockFlow;
106 friend class RenderElement;
107 friend class RenderLayer;
109 // Anonymous objects should pass the document as their node, and they will then automatically be
110 // marked as anonymous in the constructor.
111 explicit RenderObject(Node&);
112 virtual ~RenderObject();
114 RenderTheme& theme() const;
116 virtual const char* renderName() const = 0;
118 RenderElement* parent() const { return m_parent; }
119 bool isDescendantOf(const RenderObject*) const;
121 RenderObject* previousSibling() const { return m_previous; }
122 RenderObject* nextSibling() const { return m_next; }
124 // Use RenderElement versions instead.
125 virtual RenderObject* firstChildSlow() const { return nullptr; }
126 virtual RenderObject* lastChildSlow() const { return nullptr; }
128 RenderObject* nextInPreOrder() const;
129 RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
130 RenderObject* nextInPreOrderAfterChildren() const;
131 RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
132 RenderObject* previousInPreOrder() const;
133 RenderObject* previousInPreOrder(const RenderObject* stayWithin) const;
134 WEBCORE_EXPORT RenderObject* childAt(unsigned) const;
136 RenderObject* firstLeafChild() const;
137 RenderObject* lastLeafChild() const;
139 #if ENABLE(IOS_TEXT_AUTOSIZING)
140 // Minimal distance between the block with fixed height and overflowing content and the text block to apply text autosizing.
141 // The greater this constant is the more potential places we have where autosizing is turned off.
142 // So it should be as low as possible. There are sites that break at 2.
143 static const int TextAutoSizingFixedHeightDepth = 3;
145 enum BlockContentHeightType {
151 typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&);
152 RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const;
155 WEBCORE_EXPORT RenderLayer* enclosingLayer() const;
157 // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
158 WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
160 // Convenience function for getting to the nearest enclosing box of a RenderObject.
161 RenderBox& enclosingBox() const;
162 RenderBoxModelObject& enclosingBoxModelObject() const;
164 bool fixedPositionedWithNamedFlowContainingBlock() const;
166 // Function to return our enclosing flow thread if we are contained inside one. This
167 // function follows the containing block chain.
168 RenderFlowThread* flowThreadContainingBlock() const
170 if (flowThreadState() == NotInsideFlowThread)
173 return locateFlowThreadContainingBlock();
176 RenderNamedFlowFragment* currentRenderNamedFlowFragment() const;
178 // FIXME: The meaning of this function is unclear.
179 virtual bool isEmpty() const { return !firstChildSlow(); }
182 void setHasAXObject(bool flag) { m_hasAXObject = flag; }
183 bool hasAXObject() const { return m_hasAXObject; }
185 // Helper class forbidding calls to setNeedsLayout() during its lifetime.
186 class SetLayoutNeededForbiddenScope {
188 explicit SetLayoutNeededForbiddenScope(RenderObject*, bool isForbidden = true);
189 ~SetLayoutNeededForbiddenScope();
191 RenderObject* m_renderObject;
192 bool m_preexistingForbidden;
196 // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
198 virtual RenderBlock* firstLineBlock() const;
200 // RenderObject tree manipulation
201 //////////////////////////////////////////
202 virtual bool canHaveChildren() const = 0;
203 virtual bool canHaveGeneratedChildren() const;
204 virtual bool createsAnonymousWrapper() const { return false; }
205 //////////////////////////////////////////
207 #if ENABLE(TREE_DEBUGGING)
208 void showNodeTreeForThis() const;
209 void showRenderTreeForThis() const;
210 void showLineTreeForThis() const;
212 void showRenderObject(bool mark, int depth) const;
213 void showRenderSubTreeAndMark(const RenderObject* markedObject, int depth) const;
214 void showRegionsInformation() const;
217 bool isPseudoElement() const { return node() && node()->isPseudoElement(); }
219 bool isRenderElement() const { return !isText(); }
220 bool isRenderReplaced() const;
221 bool isBoxModelObject() const;
222 bool isRenderBlock() const;
223 bool isRenderBlockFlow() const;
224 bool isRenderInline() const;
225 bool isRenderLayerModelObject() const;
227 virtual bool isCounter() const { return false; }
228 virtual bool isQuote() const { return false; }
230 #if ENABLE(DETAILS_ELEMENT)
231 virtual bool isDetailsMarker() const { return false; }
233 virtual bool isEmbeddedObject() const { return false; }
234 virtual bool isFieldset() const { return false; }
235 virtual bool isFileUploadControl() const { return false; }
236 virtual bool isFrame() const { return false; }
237 virtual bool isFrameSet() const { return false; }
238 virtual bool isImage() const { return false; }
239 virtual bool isInlineBlockOrInlineTable() const { return false; }
240 virtual bool isListBox() const { return false; }
241 virtual bool isListItem() const { return false; }
242 virtual bool isListMarker() const { return false; }
243 virtual bool isMedia() const { return false; }
244 virtual bool isMenuList() const { return false; }
245 #if ENABLE(METER_ELEMENT)
246 virtual bool isMeter() const { return false; }
248 virtual bool isSnapshottedPlugIn() const { return false; }
249 virtual bool isProgress() const { return false; }
250 virtual bool isRenderSVGBlock() const { return false; };
251 virtual bool isRenderButton() const { return false; }
252 virtual bool isRenderIFrame() const { return false; }
253 virtual bool isRenderImage() const { return false; }
254 virtual bool isRenderRegion() const { return false; }
255 virtual bool isRenderNamedFlowFragment() const { return false; }
256 virtual bool isReplica() const { return false; }
258 virtual bool isRubyInline() const { return false; }
259 virtual bool isRubyBlock() const { return false; }
260 virtual bool isRubyBase() const { return false; }
261 virtual bool isRubyRun() const { return false; }
262 virtual bool isRubyText() const { return false; }
264 virtual bool isSlider() const { return false; }
265 virtual bool isSliderThumb() const { return false; }
266 virtual bool isTable() const { return false; }
267 virtual bool isTableCell() const { return false; }
268 virtual bool isRenderTableCol() const { return false; }
269 virtual bool isTableCaption() const { return false; }
270 virtual bool isTableRow() const { return false; }
271 virtual bool isTableSection() const { return false; }
272 virtual bool isTextControl() const { return false; }
273 virtual bool isTextArea() const { return false; }
274 virtual bool isTextField() const { return false; }
275 virtual bool isTextControlInnerBlock() const { return false; }
276 virtual bool isVideo() const { return false; }
277 virtual bool isWidget() const { return false; }
278 virtual bool isCanvas() const { return false; }
279 #if ENABLE(ATTACHMENT_ELEMENT)
280 virtual bool isAttachment() const { return false; }
282 #if ENABLE(FULLSCREEN_API)
283 virtual bool isRenderFullScreen() const { return false; }
284 virtual bool isRenderFullScreenPlaceholder() const { return false; }
286 #if ENABLE(CSS_GRID_LAYOUT)
287 virtual bool isRenderGrid() const { return false; }
289 virtual bool isRenderNamedFlowThread() const { return false; }
290 bool isInFlowRenderFlowThread() const { return isRenderFlowThread() && !isOutOfFlowPositioned(); }
291 bool isOutOfFlowRenderFlowThread() const { return isRenderFlowThread() && isOutOfFlowPositioned(); }
293 virtual bool isMultiColumnBlockFlow() const { return false; }
294 virtual bool isRenderMultiColumnSet() const { return false; }
295 virtual bool isRenderMultiColumnFlowThread() const { return false; }
296 virtual bool isRenderMultiColumnSpannerPlaceholder() const { return false; }
298 virtual bool isRenderScrollbarPart() const { return false; }
300 bool isDocumentElementRenderer() const { return document().documentElement() == &m_node; }
301 bool isBody() const { return node() && node()->hasTagName(HTMLNames::bodyTag); }
302 bool isHR() const { return node() && node()->hasTagName(HTMLNames::hrTag); }
303 bool isLegend() const;
305 bool isHTMLMarquee() const;
307 bool isTablePart() const { return isTableCell() || isRenderTableCol() || isTableCaption() || isTableRow() || isTableSection(); }
309 inline bool isBeforeContent() const;
310 inline bool isAfterContent() const;
311 inline bool isBeforeOrAfterContent() const;
312 static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
313 static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
314 static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
316 bool beingDestroyed() const { return m_bitfields.beingDestroyed(); }
318 bool everHadLayout() const { return m_bitfields.everHadLayout(); }
320 bool childrenInline() const { return m_bitfields.childrenInline(); }
321 void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
323 enum FlowThreadState {
324 NotInsideFlowThread = 0,
325 InsideOutOfFlowThread = 1,
326 InsideInFlowThread = 2,
329 void setFlowThreadStateIncludingDescendants(FlowThreadState);
331 FlowThreadState flowThreadState() const { return m_bitfields.flowThreadState(); }
332 void setFlowThreadState(FlowThreadState state) { m_bitfields.setFlowThreadState(state); }
334 virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
337 virtual bool isRenderMathMLBlock() const { return false; }
338 virtual bool isRenderMathMLTable() const { return false; }
339 virtual bool isRenderMathMLOperator() const { return false; }
340 virtual bool isRenderMathMLRow() const { return false; }
341 virtual bool isRenderMathMLMath() const { return false; }
342 virtual bool isRenderMathMLMenclose() const { return false; }
343 virtual bool isRenderMathMLFenced() const { return false; }
344 virtual bool isRenderMathMLFraction() const { return false; }
345 virtual bool isRenderMathMLRoot() const { return false; }
346 virtual bool isRenderMathMLRootWrapper() const { return false; }
347 virtual bool isRenderMathMLSpace() const { return false; }
348 virtual bool isRenderMathMLSquareRoot() const { return false; }
349 virtual bool isRenderMathMLScripts() const { return false; }
350 virtual bool isRenderMathMLScriptsWrapper() const { return false; }
351 virtual bool isRenderMathMLToken() const { return false; }
352 virtual bool isRenderMathMLUnderOver() const { return false; }
353 #endif // ENABLE(MATHML)
355 // FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
356 // to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
357 virtual bool isRenderSVGModelObject() const { return false; }
358 virtual bool isSVGRoot() const { return false; }
359 virtual bool isSVGContainer() const { return false; }
360 virtual bool isSVGTransformableContainer() const { return false; }
361 virtual bool isSVGViewportContainer() const { return false; }
362 virtual bool isSVGGradientStop() const { return false; }
363 virtual bool isSVGHiddenContainer() const { return false; }
364 virtual bool isSVGPath() const { return false; }
365 virtual bool isSVGShape() const { return false; }
366 virtual bool isSVGText() const { return false; }
367 virtual bool isSVGTextPath() const { return false; }
368 virtual bool isSVGTSpan() const { return false; }
369 virtual bool isSVGInline() const { return false; }
370 virtual bool isSVGInlineText() const { return false; }
371 virtual bool isSVGImage() const { return false; }
372 virtual bool isSVGForeignObject() const { return false; }
373 virtual bool isSVGResourceContainer() const { return false; }
374 virtual bool isSVGResourceFilter() const { return false; }
375 virtual bool isSVGResourceClipper() const { return false; }
376 virtual bool isSVGResourceFilterPrimitive() const { return false; }
378 // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
379 // Unfortunately we don't have such a class yet, because it's not possible for all renderers
380 // to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
381 virtual void setNeedsTransformUpdate() { }
382 virtual void setNeedsBoundariesUpdate();
383 virtual bool needsBoundariesUpdate() { return false; }
385 // Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
386 // This is used for all computation of objectBoundingBox relative units and by SVGLocatable::getBBox().
387 // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we ignore them
388 // since stroke-width is ignored (and marker size can depend on stroke-width).
389 // objectBoundingBox is returned local coordinates.
390 // The name objectBoundingBox is taken from the SVG 1.1 spec.
391 virtual FloatRect objectBoundingBox() const;
392 virtual FloatRect strokeBoundingBox() const;
394 // Returns the smallest rectangle enclosing all of the painted content
395 // respecting clipping, masking, filters, opacity, stroke-width and markers
396 virtual FloatRect repaintRectInLocalCoordinates() const;
398 // This only returns the transform="" value from the element
399 // most callsites want localToParentTransform() instead.
400 virtual AffineTransform localTransform() const;
402 // Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
403 // This includes any viewport transforms and x/y offsets as well as the transform="" value off the element.
404 virtual const AffineTransform& localToParentTransform() const;
406 // SVG uses FloatPoint precise hit testing, and passes the point in parent
407 // coordinates instead of in repaint container coordinates. Eventually the
408 // rest of the rendering tree will move to a similar model.
409 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
411 bool hasAspectRatio() const { return isReplaced() && (isImage() || isVideo() || isCanvas()); }
412 bool isAnonymous() const { return m_bitfields.isAnonymous(); }
413 bool isAnonymousBlock() const
415 // This function is kept in sync with anonymous block creation conditions in
416 // RenderBlock::createAnonymousBlock(). This includes creating an anonymous
417 // RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
418 // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709.
419 return isAnonymous() && (style().display() == BLOCK || style().display() == BOX) && style().styleType() == NOPSEUDO && isRenderBlock() && !isListMarker() && !isRenderFlowThread() && !isRenderMultiColumnSet() && !isRenderView()
420 #if ENABLE(FULLSCREEN_API)
421 && !isRenderFullScreen()
422 && !isRenderFullScreenPlaceholder()
425 && !isRenderMathMLBlock()
429 bool isAnonymousInlineBlock() const;
430 bool isElementContinuation() const { return node() && node()->renderer() != this; }
431 bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
432 bool isBlockElementContinuation() const { return isElementContinuation() && !isInline(); }
433 virtual RenderBoxModelObject* virtualContinuation() const { return nullptr; }
435 bool isFloating() const { return m_bitfields.floating(); }
437 bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositioned(); } // absolute or fixed positioning
438 bool isInFlowPositioned() const { return m_bitfields.isRelPositioned() || m_bitfields.isStickyPositioned(); } // relative or sticky positioning
439 bool isRelPositioned() const { return m_bitfields.isRelPositioned(); } // relative positioning
440 bool isStickyPositioned() const { return m_bitfields.isStickyPositioned(); }
441 bool isPositioned() const { return m_bitfields.isPositioned(); }
443 bool isText() const { return !m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
444 bool isLineBreak() const { return m_bitfields.isLineBreak(); }
445 bool isBR() const { return isLineBreak() && !isWBR(); }
446 bool isLineBreakOpportunity() const { return isLineBreak() && isWBR(); }
447 bool isTextOrLineBreak() const { return isText() || isLineBreak(); }
448 bool isBox() const { return m_bitfields.isBox(); }
449 bool isRenderView() const { return m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
450 bool isInline() const { return m_bitfields.isInline(); } // inline object
451 bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced" element (see CSS)
452 bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
454 bool isDragging() const { return m_bitfields.hasRareData() && rareData().isDragging(); }
455 bool hasReflection() const { return m_bitfields.hasRareData() && rareData().hasReflection(); }
456 bool isRenderFlowThread() const { return m_bitfields.hasRareData() && rareData().isRenderFlowThread(); }
457 bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
458 bool isRegisteredForVisibleInViewportCallback() { return m_bitfields.hasRareData() && rareData().isRegisteredForVisibleInViewportCallback(); }
460 enum VisibleInViewportState {
463 NotVisibleInViewport,
465 VisibleInViewportState visibleInViewportState() { return m_bitfields.hasRareData() ? rareData().visibleInViewportState() : VisibilityUnknown; }
467 bool hasLayer() const { return m_bitfields.hasLayer(); }
468 bool hasSelfPaintingLayer() const;
470 enum BoxDecorationState {
472 HasBoxDecorationsAndBackgroundObscurationStatusInvalid,
473 HasBoxDecorationsAndBackgroundIsKnownToBeObscured,
474 HasBoxDecorationsAndBackgroundMayBeVisible,
476 bool hasVisibleBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
477 bool backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset);
478 bool hasEntirelyFixedBackground() const;
480 bool needsLayout() const
482 return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
483 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.needsPositionedMovementLayout();
486 bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
487 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
488 bool needsPositionedMovementLayoutOnly() const
490 return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
491 && !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifiedNormalFlowLayout();
494 bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
495 bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
496 bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
498 bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
500 bool isSelectionBorder() const;
502 bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
504 bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } // Transform, perspective or transform-style: preserve-3d.
505 bool hasTransform() const { return hasTransformRelatedProperty() && style().hasTransform(); }
507 inline bool preservesNewline() const;
509 virtual void updateDragState(bool dragOn);
511 RenderView& view() const { return *document().renderView(); };
513 // Returns true if this renderer is rooted.
514 bool isRooted() const;
516 Node* node() const { return isAnonymous() ? nullptr : &m_node; }
517 Node* nonPseudoNode() const { return isPseudoElement() ? nullptr : node(); }
519 // Returns the styled node that caused the generation of this renderer.
520 // This is the same as node() except for renderers of :before and :after
521 // pseudo elements for which their parent node is returned.
522 Node* generatingNode() const { return isPseudoElement() ? generatingPseudoHostElement() : node(); }
524 Document& document() const { return m_node.document(); }
525 Frame& frame() const;
527 bool hasOutlineAnnotation() const;
528 bool hasOutline() const { return style().hasOutline() || hasOutlineAnnotation(); }
530 // Returns the object containing this one. Can be different from parent for positioned elements.
531 // If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
532 // is true if the renderer returned is an ancestor of repaintContainer.
533 RenderElement* container() const;
534 RenderElement* container(const RenderLayerModelObject* repaintContainer, bool& repaintContainerSkipped) const;
536 RenderBoxModelObject* offsetParent() const;
538 void markContainingBlocksForLayout(ScheduleRelayout = ScheduleRelayout::Yes, RenderElement* newRoot = nullptr);
539 void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain);
540 void clearNeedsLayout();
541 void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
542 void invalidateContainerPreferredLogicalWidths();
544 void setNeedsLayoutAndPrefWidthsRecalc()
547 setPreferredLogicalWidthsDirty(true);
550 void setPositionState(EPosition position)
552 ASSERT((position != AbsolutePosition && position != FixedPosition) || isBox());
553 m_bitfields.setPositionedState(position);
555 void clearPositionedState() { m_bitfields.clearPositionedState(); }
557 void setFloating(bool b = true) { m_bitfields.setFloating(b); }
558 void setInline(bool b = true) { m_bitfields.setIsInline(b); }
560 void setHasVisibleBoxDecorations(bool = true);
561 void invalidateBackgroundObscurationStatus();
562 virtual bool computeBackgroundIsKnownToBeObscured(const LayoutPoint&) { return false; }
564 void setIsText() { ASSERT(!isBox()); m_bitfields.setIsTextOrRenderView(true); }
565 void setIsLineBreak() { m_bitfields.setIsLineBreak(true); }
566 void setIsBox() { m_bitfields.setIsBox(true); }
567 void setIsRenderView() { ASSERT(isBox()); m_bitfields.setIsTextOrRenderView(true); }
568 void setReplaced(bool b = true) { m_bitfields.setIsReplaced(b); }
569 void setHorizontalWritingMode(bool b = true) { m_bitfields.setHorizontalWritingMode(b); }
570 void setHasOverflowClip(bool b = true) { m_bitfields.setHasOverflowClip(b); }
571 void setHasLayer(bool b = true) { m_bitfields.setHasLayer(b); }
572 void setHasTransformRelatedProperty(bool b = true) { m_bitfields.setHasTransformRelatedProperty(b); }
574 void setIsDragging(bool);
575 void setHasReflection(bool = true);
576 void setIsRenderFlowThread(bool = true);
577 void setHasOutlineAutoAncestor(bool = true);
578 void setIsRegisteredForVisibleInViewportCallback(bool);
579 void setVisibleInViewportState(VisibleInViewportState);
581 // Hook so that RenderTextControl can return the line height of its inner renderer.
582 // For other renderers, the value is the same as lineHeight(false).
583 virtual int innerLineHeight() const;
585 // used for element state updates that cannot be fixed with a
586 // repaint and do not need a relayout
587 virtual void updateFromElement() { }
589 #if ENABLE(DASHBOARD_SUPPORT)
590 virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&);
591 void collectAnnotatedRegions(Vector<AnnotatedRegionValue>&);
594 bool isComposited() const;
596 bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
597 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
598 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
600 virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*);
601 VisiblePosition createVisiblePosition(int offset, EAffinity) const;
602 VisiblePosition createVisiblePosition(const Position&) const;
604 // returns the containing block level element for this element.
605 RenderBlock* containingBlock() const;
606 RenderBlock* containingBlockForFixedPosition() const;
607 RenderBlock* containingBlockForAbsolutePosition() const;
608 RenderBlock* containingBlockForObjectInFlow() const;
610 // Convert the given local point to absolute coordinates. If MapCoordinatesFlags includes UseTransforms, take transforms into account.
611 WEBCORE_EXPORT FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const;
612 FloatPoint absoluteToLocal(const FloatPoint&, MapCoordinatesFlags = 0) const;
614 // Convert a local quad to absolute coordinates, taking transforms into account.
615 FloatQuad localToAbsoluteQuad(const FloatQuad& quad, MapCoordinatesFlags mode = UseTransforms, bool* wasFixed = nullptr) const
617 return localToContainerQuad(quad, nullptr, mode, wasFixed);
619 // Convert an absolute quad to local coordinates.
620 FloatQuad absoluteToLocalQuad(const FloatQuad&, MapCoordinatesFlags mode = UseTransforms) const;
622 // Convert a local quad into the coordinate system of container, taking transforms into account.
623 WEBCORE_EXPORT FloatQuad localToContainerQuad(const FloatQuad&, const RenderLayerModelObject* repaintContainer, MapCoordinatesFlags = UseTransforms, bool* wasFixed = nullptr) const;
624 WEBCORE_EXPORT FloatPoint localToContainerPoint(const FloatPoint&, const RenderLayerModelObject* repaintContainer, MapCoordinatesFlags = UseTransforms, bool* wasFixed = nullptr) const;
626 // Return the offset from the container() renderer (excluding transforms). In multi-column layout,
627 // different offsets apply at different points, so return the offset that applies to the given point.
628 virtual LayoutSize offsetFromContainer(RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = nullptr) const;
629 // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
630 LayoutSize offsetFromAncestorContainer(RenderElement&) const;
633 virtual void collectSelectionRects(Vector<SelectionRect>&, unsigned startOffset = 0, unsigned endOffset = std::numeric_limits<unsigned>::max());
634 virtual void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const { absoluteQuads(quads); }
637 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
639 // FIXME: useTransforms should go away eventually
640 WEBCORE_EXPORT IntRect absoluteBoundingBoxRect(bool useTransform = true, bool* wasFixed = nullptr) const;
641 IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
643 // Build an array of quads in absolute coords for line boxes
644 virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = nullptr) const { }
646 virtual void absoluteFocusRingQuads(Vector<FloatQuad>&);
648 static FloatRect absoluteBoundingBoxRectForRange(const Range*);
650 // the rect that will be painted if this object is passed as the paintingRoot
651 WEBCORE_EXPORT LayoutRect paintingRootRect(LayoutRect& topLevelRect);
653 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
654 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
656 const RenderStyle& style() const;
657 const RenderStyle& firstLineStyle() const;
659 // Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
660 // This is typically only relevant when repainting.
661 virtual const RenderStyle& outlineStyleForRepaint() const { return style(); }
663 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
665 void getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
666 TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false) const;
668 // Return the RenderLayerModelObject in the container chain which is responsible for painting this object, or nullptr
669 // if painting is root-relative. This is the container that should be passed to the 'forRepaint'
671 RenderLayerModelObject* containerForRepaint() const;
672 // Actually do the repaint of rect r for this object which has been computed in the coordinate space
673 // of repaintContainer. If repaintContainer is nullptr, repaint via the view.
674 void repaintUsingContainer(const RenderLayerModelObject* repaintContainer, const LayoutRect&, bool shouldClipToLayer = true) const;
676 // Repaint the entire object. Called when, e.g., the color of a border changes, or when a border
678 void repaint() const;
680 // Repaint a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
681 WEBCORE_EXPORT void repaintRectangle(const LayoutRect&, bool shouldClipToLayer = true) const;
683 // Repaint a slow repaint object, which, at this time, means we are repainting an object with background-attachment:fixed.
684 void repaintSlowRepaintObject() const;
686 bool checkForRepaintDuringLayout() const;
688 // Returns the rect that should be repainted whenever this object changes. The rect is in the view's
689 // coordinate space. This method deals with outlines and overflow.
690 LayoutRect absoluteClippedOverflowRect() const
692 return clippedOverflowRectForRepaint(nullptr);
694 WEBCORE_EXPORT IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
695 virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const;
696 virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const;
697 virtual LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* /*repaintContainer*/, const RenderGeometryMap* = nullptr) const { return LayoutRect(); }
699 // Given a rect in the object's coordinate space, compute a rect suitable for repainting
700 // that rect in view coordinates.
701 LayoutRect computeAbsoluteRepaintRect(const LayoutRect& r, bool fixed = false) const
703 return computeRectForRepaint(r, nullptr, { fixed, false });
705 // Given a rect in the object's coordinate space, compute a rect suitable for repainting
706 // that rect in the coordinate space of repaintContainer.
707 struct RepaintContext {
708 RepaintContext(bool hasPositionFixedDescendant = false, bool dirtyRectIsFlipped = false)
709 : m_hasPositionFixedDescendant(hasPositionFixedDescendant)
710 , m_dirtyRectIsFlipped(dirtyRectIsFlipped)
713 bool m_hasPositionFixedDescendant;
714 bool m_dirtyRectIsFlipped;
716 virtual LayoutRect computeRectForRepaint(const LayoutRect&, const RenderLayerModelObject* repaintContainer, RepaintContext = { }) const;
717 virtual FloatRect computeFloatRectForRepaint(const FloatRect&, const RenderLayerModelObject* repaintContainer, bool fixed = false) const;
719 virtual unsigned int length() const { return 1; }
721 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
723 enum SelectionState {
724 SelectionNone, // The object is not selected.
725 SelectionStart, // The object either contains the start of a selection run or is the start of a run
726 SelectionInside, // The object is fully encompassed by a selection run
727 SelectionEnd, // The object either contains the end of a selection run or is the end of a run
728 SelectionBoth // The object contains an entire run or is the sole selected object in that run
731 // The current selection state for an object. For blocks, the state refers to the state of the leaf
732 // descendants (as described above in the SelectionState enum declaration).
733 SelectionState selectionState() const { return m_bitfields.selectionState(); }
734 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelectionState(state); }
735 inline void setSelectionStateIfNeeded(SelectionState);
736 bool canUpdateSelectionOnRootLineBoxes();
738 // A single rectangle that encompasses all of the selected objects within this object. Used to determine the tightest
739 // possible bounding box for the selection.
740 LayoutRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(nullptr, clipToVisibleContent); }
741 virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return LayoutRect(); }
743 virtual bool canBeSelectionLeaf() const { return false; }
744 bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
746 // Whether or not a given block needs to paint selection gaps.
747 virtual bool shouldPaintSelectionGaps() const { return false; }
750 * Returns the local coordinates of the caret within this render object.
751 * @param caretOffset zero-based offset determining position within the render object.
752 * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
753 * useful for character range rect computations
755 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr);
757 // When performing a global document tear-down, the renderer of the document is cleared. We use this
758 // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
759 bool documentBeingDestroyed() const;
761 void destroyAndCleanupAnonymousWrappers();
764 // Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
765 virtual bool isDeprecatedFlexibleBox() const { return false; }
767 // Virtual function helper for the new FlexibleBox Layout (display: -webkit-flex).
768 virtual bool isFlexibleBox() const { return false; }
770 bool isFlexibleBoxIncludingDeprecated() const
772 return isFlexibleBox() || isDeprecatedFlexibleBox();
775 virtual bool isCombineText() const { return false; }
777 virtual int caretMinOffset() const;
778 virtual int caretMaxOffset() const;
780 virtual int previousOffset(int current) const;
781 virtual int previousOffsetForBackwardDeletion(int current) const;
782 virtual int nextOffset(int current) const;
784 void imageChanged(CachedImage*, const IntRect* = nullptr) override;
785 virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { }
787 SelectionSubtreeRoot& selectionRoot() const;
788 void selectionStartEnd(int& spos, int& epos) const;
790 void removeFromParent();
792 AnimationController& animation() const;
794 // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
795 // localToAbsolute/absoluteToLocal methods instead.
796 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed = nullptr) const;
797 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const;
799 // Pushes state onto RenderGeometryMap about how to map coordinates from this renderer to its container, or ancestorToStopAt (whichever is encountered first).
800 // Returns the renderer which was mapped to (container or ancestorToStopAt).
801 virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const;
803 bool shouldUseTransformFromContainer(const RenderObject* container) const;
804 void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
806 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& /* additionalOffset */, const RenderLayerModelObject* /* paintContainer */ = nullptr) { };
808 LayoutRect absoluteOutlineBounds() const
810 return outlineBoundsForRepaint(nullptr);
813 RespectImageOrientationEnum shouldRespectImageOrientation() const;
816 //////////////////////////////////////////
817 // Helper functions. Dangerous to use!
818 void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
819 void setNextSibling(RenderObject* next) { m_next = next; }
820 void setParent(RenderElement*);
821 //////////////////////////////////////////
822 void addPDFURLRect(PaintInfo&, const LayoutPoint&);
823 Node& nodeForNonAnonymous() const { ASSERT(!isAnonymous()); return m_node; }
825 void adjustRectForOutlineAndShadow(LayoutRect&) const;
827 virtual void willBeDestroyed();
829 virtual void insertedIntoTree();
830 virtual void willBeRemovedFromTree();
832 void setNeedsPositionedMovementLayoutBit(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
833 void setNormalChildNeedsLayoutBit(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
834 void setPosChildNeedsLayoutBit(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
835 void setNeedsSimplifiedNormalFlowLayoutBit(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
837 virtual RenderFlowThread* locateFlowThreadContainingBlock() const;
838 void invalidateFlowThreadContainingBlockIncludingDescendants(RenderFlowThread* = nullptr);
839 static void calculateBorderStyleColor(const EBorderStyle&, const BoxSide&, Color&);
843 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
844 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
847 bool inPageCache() const final { return document().inPageCache(); }
849 void addAbsoluteRectForLayer(LayoutRect& result);
850 void setLayerNeedsFullRepaint();
851 void setLayerNeedsFullRepaintForPositionedMovementLayout();
853 void removeFromRenderFlowThread();
854 void removeFromRenderFlowThreadIncludingDescendants(bool);
855 Node* generatingPseudoHostElement() const;
857 void propagateRepaintToParentWithOutlineAutoIfNeeded(const RenderLayerModelObject& repaintContainer, const LayoutRect& repaintRect) const;
859 virtual bool isWBR() const { ASSERT_NOT_REACHED(); return false; }
861 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
863 bool hasRareData() const { return m_bitfields.hasRareData(); }
864 void setHasRareData(bool b) { m_bitfields.setHasRareData(b); }
867 void checkBlockPositionedObjectsNeedLayout();
872 RenderElement* m_parent;
873 RenderObject* m_previous;
874 RenderObject* m_next;
877 bool m_hasAXObject : 1;
878 bool m_setNeedsLayoutForbidden : 1;
881 #define ADD_BOOLEAN_BITFIELD(name, Name) \
883 unsigned m_##name : 1;\
885 bool name() const { return m_##name; }\
886 void set##Name(bool name) { m_##name = name; }\
888 #define ADD_ENUM_BITFIELD(name, Name, Type, width) \
890 unsigned m_##name : width;\
892 Type name() const { return static_cast<Type>(m_##name); }\
893 void set##Name(Type name) { m_##name = static_cast<unsigned>(name); }\
895 class RenderObjectBitfields {
896 enum PositionedState {
897 IsStaticallyPositioned = 0,
898 IsRelativelyPositioned = 1,
899 IsOutOfFlowPositioned = 2,
900 IsStickyPositioned = 3
904 RenderObjectBitfields(const Node& node)
905 : m_hasRareData(false)
906 , m_beingDestroyed(false)
907 , m_needsLayout(false)
908 , m_needsPositionedMovementLayout(false)
909 , m_normalChildNeedsLayout(false)
910 , m_posChildNeedsLayout(false)
911 , m_needsSimplifiedNormalFlowLayout(false)
912 , m_preferredLogicalWidthsDirty(false)
914 , m_isAnonymous(node.isDocumentNode())
915 , m_isTextOrRenderView(false)
918 , m_isReplaced(false)
919 , m_isLineBreak(false)
920 , m_horizontalWritingMode(true)
922 , m_hasOverflowClip(false)
923 , m_hasTransformRelatedProperty(false)
924 , m_everHadLayout(false)
925 , m_childrenInline(false)
926 , m_positionedState(IsStaticallyPositioned)
927 , m_selectionState(SelectionNone)
928 , m_flowThreadState(NotInsideFlowThread)
929 , m_boxDecorationState(NoBoxDecorations)
933 ADD_BOOLEAN_BITFIELD(hasRareData, HasRareData);
935 ADD_BOOLEAN_BITFIELD(beingDestroyed, BeingDestroyed);
936 ADD_BOOLEAN_BITFIELD(needsLayout, NeedsLayout);
937 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovementLayout);
938 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
939 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
940 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNormalFlowLayout);
941 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidthsDirty);
942 ADD_BOOLEAN_BITFIELD(floating, Floating);
944 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
945 ADD_BOOLEAN_BITFIELD(isTextOrRenderView, IsTextOrRenderView);
946 ADD_BOOLEAN_BITFIELD(isBox, IsBox);
947 ADD_BOOLEAN_BITFIELD(isInline, IsInline);
948 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
949 ADD_BOOLEAN_BITFIELD(isLineBreak, IsLineBreak);
950 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
952 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
953 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the case of overflow:auto/scroll/hidden
954 ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedProperty);
955 ADD_BOOLEAN_BITFIELD(unused, Unused);
957 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
960 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
963 unsigned m_positionedState : 2; // PositionedState
964 unsigned m_selectionState : 3; // SelectionState
965 unsigned m_flowThreadState : 2; // FlowThreadState
966 unsigned m_boxDecorationState : 2; // BoxDecorationState
969 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOfFlowPositioned; }
970 bool isRelPositioned() const { return m_positionedState == IsRelativelyPositioned; }
971 bool isStickyPositioned() const { return m_positionedState == IsStickyPositioned; }
972 bool isPositioned() const { return m_positionedState != IsStaticallyPositioned; }
974 void setPositionedState(int positionState)
976 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowPositioned, saving one bit.
977 m_positionedState = static_cast<PositionedState>(positionState & 0x3);
979 void clearPositionedState() { m_positionedState = StaticPosition; }
981 ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
982 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
984 ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_cast<FlowThreadState>(m_flowThreadState); }
985 ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
987 ALWAYS_INLINE BoxDecorationState boxDecorationState() const { return static_cast<BoxDecorationState>(m_boxDecorationState); }
988 ALWAYS_INLINE void setBoxDecorationState(BoxDecorationState boxDecorationState) { m_boxDecorationState = boxDecorationState; }
991 RenderObjectBitfields m_bitfields;
993 class RenderObjectRareData {
995 RenderObjectRareData()
996 : m_isDragging(false)
997 , m_hasReflection(false)
998 , m_isRenderFlowThread(false)
999 , m_hasOutlineAutoAncestor(false)
1000 , m_isRegisteredForVisibleInViewportCallback(false)
1001 , m_visibleInViewportState(VisibilityUnknown)
1004 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
1005 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
1006 ADD_BOOLEAN_BITFIELD(isRenderFlowThread, IsRenderFlowThread);
1007 ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
1009 // From RenderElement
1010 ADD_BOOLEAN_BITFIELD(isRegisteredForVisibleInViewportCallback, IsRegisteredForVisibleInViewportCallback);
1011 ADD_ENUM_BITFIELD(visibleInViewportState, VisibleInViewportState, VisibleInViewportState, 2);
1015 RenderObjectRareData rareData() const;
1016 RenderObjectRareData& ensureRareData();
1017 void removeRareData();
1019 // Note: RenderObjectRareData is stored by value.
1020 typedef HashMap<const RenderObject*, RenderObjectRareData> RareDataHash;
1022 static RareDataHash& rareDataMap();
1024 #undef ADD_BOOLEAN_BITFIELD
1027 inline Frame& RenderObject::frame() const
1029 return *document().frame();
1032 inline AnimationController& RenderObject::animation() const
1034 return frame().animation();
1037 inline bool RenderObject::documentBeingDestroyed() const
1039 return document().renderTreeBeingDestroyed();
1042 inline bool RenderObject::isBeforeContent() const
1044 // Text nodes don't have their own styles, so ignore the style on a text node.
1047 if (style().styleType() != BEFORE)
1052 inline bool RenderObject::isAfterContent() const
1054 // Text nodes don't have their own styles, so ignore the style on a text node.
1057 if (style().styleType() != AFTER)
1062 inline bool RenderObject::isBeforeOrAfterContent() const
1064 return isBeforeContent() || isAfterContent();
1067 inline void RenderObject::setNeedsLayout(MarkingBehavior markParents)
1069 ASSERT(!isSetNeedsLayoutForbidden());
1070 if (m_bitfields.needsLayout())
1072 m_bitfields.setNeedsLayout(true);
1073 if (markParents == MarkContainingBlockChain)
1074 markContainingBlocksForLayout();
1076 setLayerNeedsFullRepaint();
1079 inline bool RenderObject::preservesNewline() const
1081 if (isSVGInlineText())
1084 return style().preserveNewline();
1087 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
1089 if (selectionState() == state)
1092 setSelectionState(state);
1095 inline void RenderObject::setHasVisibleBoxDecorations(bool b)
1098 m_bitfields.setBoxDecorationState(NoBoxDecorations);
1101 if (hasVisibleBoxDecorations())
1103 m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
1106 inline void RenderObject::invalidateBackgroundObscurationStatus()
1108 if (!hasVisibleBoxDecorations())
1110 m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
1113 inline bool RenderObject::backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset)
1115 if (m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundObscurationStatusInvalid) {
1116 BoxDecorationState boxDecorationState = computeBackgroundIsKnownToBeObscured(paintOffset) ? HasBoxDecorationsAndBackgroundIsKnownToBeObscured : HasBoxDecorationsAndBackgroundMayBeVisible;
1117 m_bitfields.setBoxDecorationState(boxDecorationState);
1119 return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
1122 #if ENABLE(TREE_DEBUGGING)
1123 void printRenderTreeForLiveDocuments();
1124 void printLayerTreeForLiveDocuments();
1127 } // namespace WebCore
1129 #define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \
1130 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
1131 static bool isType(const WebCore::RenderObject& renderer) { return renderer.predicate; } \
1132 SPECIALIZE_TYPE_TRAITS_END()
1134 #if ENABLE(TREE_DEBUGGING)
1135 // Outside the WebCore namespace for ease of invocation from gdb.
1136 void showNodeTree(const WebCore::RenderObject*);
1137 void showLineTree(const WebCore::RenderObject*);
1138 void showRenderTree(const WebCore::RenderObject*);
1141 #endif // RenderObject_h