#pragma once
#include "CachedImageClient.h"
#include "Element.h"
#include "FloatQuad.h"
#include "Frame.h"
#include "LayoutRect.h"
#include "Page.h"
#include "RenderObjectEnums.h"
#include "RenderStyle.h"
#include "ScrollAlignment.h"
#include "StyleImage.h"
#include "TextAffinity.h"
#include <wtf/IsoMalloc.h>
#include <wtf/WeakPtr.h>
namespace WebCore {
class AffineTransform;
class CSSAnimationController;
class Color;
class Cursor;
class Document;
class DocumentTimeline;
class HitTestLocation;
class HitTestRequest;
class HitTestResult;
class InlineBox;
class Path;
class Position;
class PseudoStyleRequest;
class RenderBoxModelObject;
class RenderInline;
class RenderBlock;
class RenderElement;
class RenderFragmentedFlow;
class RenderGeometryMap;
class RenderLayer;
class RenderLayerModelObject;
class RenderFragmentContainer;
class RenderTheme;
class RenderTreeBuilder;
class SelectionRangeData;
class TransformState;
class VisiblePosition;
#if PLATFORM(IOS_FAMILY)
class SelectionRect;
#endif
struct PaintInfo;
#if PLATFORM(IOS_FAMILY)
const int caretWidth = 2; #else
const int caretWidth = 1;
#endif
enum class ShouldAllowCrossOriginScrolling { No, Yes };
struct ScrollRectToVisibleOptions;
#if ENABLE(DASHBOARD_SUPPORT)
struct AnnotatedRegionValue {
bool operator==(const AnnotatedRegionValue& o) const
{
return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
}
bool operator!=(const AnnotatedRegionValue& o) const
{
return !(*this == o);
}
LayoutRect bounds;
String label;
LayoutRect clip;
int type;
};
#endif
class RenderObject : public CachedImageClient, public CanMakeWeakPtr<RenderObject> {
WTF_MAKE_ISO_ALLOCATED(RenderObject);
friend class RenderBlock;
friend class RenderBlockFlow;
friend class RenderElement;
friend class RenderLayer;
public:
explicit RenderObject(Node&);
virtual ~RenderObject();
RenderTheme& theme() const;
virtual const char* renderName() const = 0;
RenderElement* parent() const { return m_parent; }
bool isDescendantOf(const RenderObject*) const;
RenderObject* previousSibling() const { return m_previous; }
RenderObject* nextSibling() const { return m_next; }
virtual RenderObject* firstChildSlow() const { return nullptr; }
virtual RenderObject* lastChildSlow() const { return nullptr; }
RenderObject* nextInPreOrder() const;
RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
RenderObject* nextInPreOrderAfterChildren() const;
RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
RenderObject* previousInPreOrder() const;
RenderObject* previousInPreOrder(const RenderObject* stayWithin) const;
WEBCORE_EXPORT RenderObject* childAt(unsigned) const;
RenderObject* firstLeafChild() const;
RenderObject* lastLeafChild() const;
#if ENABLE(TEXT_AUTOSIZING)
static const int TextAutoSizingFixedHeightDepth = 3;
enum BlockContentHeightType {
FixedHeight,
FlexibleHeight,
OverflowHeight
};
typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&);
RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const;
#endif
WEBCORE_EXPORT RenderLayer* enclosingLayer() const;
WEBCORE_EXPORT bool scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&);
WEBCORE_EXPORT RenderBox& enclosingBox() const;
RenderBoxModelObject& enclosingBoxModelObject() const;
RenderFragmentedFlow* enclosingFragmentedFlow() const
{
if (fragmentedFlowState() == NotInsideFragmentedFlow)
return nullptr;
return locateEnclosingFragmentedFlow();
}
WEBCORE_EXPORT bool useDarkAppearance() const;
OptionSet<StyleColor::Options> styleColorOptions() const;
#ifndef NDEBUG
void setHasAXObject(bool flag) { m_hasAXObject = flag; }
bool hasAXObject() const { return m_hasAXObject; }
class SetLayoutNeededForbiddenScope {
public:
explicit SetLayoutNeededForbiddenScope(RenderObject*, bool isForbidden = true);
~SetLayoutNeededForbiddenScope();
private:
RenderObject* m_renderObject;
bool m_preexistingForbidden;
};
#endif
virtual RenderBlock* firstLineBlock() const;
virtual bool canHaveChildren() const = 0;
virtual bool canHaveGeneratedChildren() const;
virtual bool createsAnonymousWrapper() const { return false; }
#if ENABLE(TREE_DEBUGGING)
void showNodeTreeForThis() const;
void showRenderTreeForThis() const;
void showLineTreeForThis() const;
void outputRenderObject(WTF::TextStream&, bool mark, int depth) const;
void outputRenderSubTreeAndMark(WTF::TextStream&, const RenderObject* markedObject, int depth) const;
void outputRegionsInformation(WTF::TextStream&) const;
#endif
bool isPseudoElement() const { return node() && node()->isPseudoElement(); }
bool isRenderElement() const { return !isText(); }
bool isRenderReplaced() const;
bool isBoxModelObject() const;
bool isRenderBlock() const;
bool isRenderBlockFlow() const;
bool isRenderInline() const;
bool isRenderLayerModelObject() const;
virtual bool isCounter() const { return false; }
virtual bool isQuote() const { return false; }
virtual bool isDetailsMarker() const { return false; }
virtual bool isEmbeddedObject() const { return false; }
bool isFieldset() const;
virtual bool isFileUploadControl() const { return false; }
virtual bool isFrame() const { return false; }
virtual bool isFrameSet() const { return false; }
virtual bool isImage() const { return false; }
virtual bool isInlineBlockOrInlineTable() const { return false; }
virtual bool isListBox() const { return false; }
virtual bool isListItem() const { return false; }
virtual bool isListMarker() const { return false; }
virtual bool isMedia() const { return false; }
virtual bool isMenuList() const { return false; }
#if ENABLE(METER_ELEMENT)
virtual bool isMeter() const { return false; }
#endif
virtual bool isSnapshottedPlugIn() const { return false; }
virtual bool isProgress() const { return false; }
virtual bool isRenderButton() const { return false; }
virtual bool isRenderIFrame() const { return false; }
virtual bool isRenderImage() const { return false; }
virtual bool isRenderFragmentContainer() const { return false; }
virtual bool isReplica() const { return false; }
virtual bool isRubyInline() const { return false; }
virtual bool isRubyBlock() const { return false; }
virtual bool isRubyBase() const { return false; }
virtual bool isRubyRun() const { return false; }
virtual bool isRubyText() const { return false; }
virtual bool isSlider() const { return false; }
virtual bool isSliderThumb() const { return false; }
virtual bool isTable() const { return false; }
virtual bool isTableCell() const { return false; }
virtual bool isRenderTableCol() const { return false; }
virtual bool isTableCaption() const { return false; }
virtual bool isTableRow() const { return false; }
virtual bool isTableSection() const { return false; }
virtual bool isTextControl() const { return false; }
virtual bool isTextArea() const { return false; }
virtual bool isTextField() const { return false; }
virtual bool isSearchField() const { return false; }
virtual bool isTextControlInnerBlock() const { return false; }
virtual bool isVideo() const { return false; }
virtual bool isWidget() const { return false; }
virtual bool isCanvas() const { return false; }
#if ENABLE(ATTACHMENT_ELEMENT)
virtual bool isAttachment() const { return false; }
#endif
#if ENABLE(FULLSCREEN_API)
virtual bool isRenderFullScreen() const { return false; }
virtual bool isRenderFullScreenPlaceholder() const { return false; }
#endif
virtual bool isRenderGrid() const { return false; }
bool isInFlowRenderFragmentedFlow() const { return isRenderFragmentedFlow() && !isOutOfFlowPositioned(); }
bool isOutOfFlowRenderFragmentedFlow() const { return isRenderFragmentedFlow() && isOutOfFlowPositioned(); }
virtual bool isMultiColumnBlockFlow() const { return false; }
virtual bool isRenderMultiColumnSet() const { return false; }
virtual bool isRenderMultiColumnFlow() const { return false; }
virtual bool isRenderMultiColumnSpannerPlaceholder() const { return false; }
virtual bool isRenderScrollbarPart() const { return false; }
bool isDocumentElementRenderer() const { return document().documentElement() == &m_node; }
bool isBody() const { return node() && node()->hasTagName(HTMLNames::bodyTag); }
bool isHR() const { return node() && node()->hasTagName(HTMLNames::hrTag); }
bool isLegend() const;
bool isHTMLMarquee() const;
bool isTablePart() const { return isTableCell() || isRenderTableCol() || isTableCaption() || isTableRow() || isTableSection(); }
inline bool isBeforeContent() const;
inline bool isAfterContent() const;
inline bool isBeforeOrAfterContent() const;
static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
bool beingDestroyed() const { return m_bitfields.beingDestroyed(); }
bool everHadLayout() const { return m_bitfields.everHadLayout(); }
bool childrenInline() const { return m_bitfields.childrenInline(); }
void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
enum FragmentedFlowState {
NotInsideFragmentedFlow = 0,
InsideInFragmentedFlow = 1,
};
void setFragmentedFlowStateIncludingDescendants(FragmentedFlowState);
FragmentedFlowState fragmentedFlowState() const { return m_bitfields.fragmentedFlowState(); }
void setFragmentedFlowState(FragmentedFlowState state) { m_bitfields.setFragmentedFlowState(state); }
#if ENABLE(MATHML)
virtual bool isRenderMathMLBlock() const { return false; }
virtual bool isRenderMathMLTable() const { return false; }
virtual bool isRenderMathMLOperator() const { return false; }
virtual bool isRenderMathMLRow() const { return false; }
virtual bool isRenderMathMLMath() const { return false; }
virtual bool isRenderMathMLMenclose() const { return false; }
virtual bool isRenderMathMLFenced() const { return false; }
virtual bool isRenderMathMLFencedOperator() const { return false; }
virtual bool isRenderMathMLFraction() const { return false; }
virtual bool isRenderMathMLPadded() const { return false; }
virtual bool isRenderMathMLRoot() const { return false; }
virtual bool isRenderMathMLSpace() const { return false; }
virtual bool isRenderMathMLSquareRoot() const { return false; }
virtual bool isRenderMathMLScripts() const { return false; }
virtual bool isRenderMathMLToken() const { return false; }
virtual bool isRenderMathMLUnderOver() const { return false; }
#endif // ENABLE(MATHML)
virtual bool isRenderSVGModelObject() const { return false; }
virtual bool isRenderSVGBlock() const { return false; };
virtual bool isSVGRoot() const { return false; }
virtual bool isSVGContainer() const { return false; }
virtual bool isSVGTransformableContainer() const { return false; }
virtual bool isSVGViewportContainer() const { return false; }
virtual bool isSVGGradientStop() const { return false; }
virtual bool isSVGHiddenContainer() const { return false; }
virtual bool isSVGPath() const { return false; }
virtual bool isSVGShape() const { return false; }
virtual bool isSVGText() const { return false; }
virtual bool isSVGTextPath() const { return false; }
virtual bool isSVGTSpan() const { return false; }
virtual bool isSVGInline() const { return false; }
virtual bool isSVGInlineText() const { return false; }
virtual bool isSVGImage() const { return false; }
virtual bool isSVGForeignObject() const { return false; }
virtual bool isSVGResourceContainer() const { return false; }
virtual bool isSVGResourceFilter() const { return false; }
virtual bool isSVGResourceClipper() const { return false; }
virtual bool isSVGResourceFilterPrimitive() const { return false; }
virtual void setNeedsTransformUpdate() { }
virtual void setNeedsBoundariesUpdate();
virtual bool needsBoundariesUpdate() { return false; }
virtual FloatRect objectBoundingBox() const;
virtual FloatRect strokeBoundingBox() const;
virtual FloatRect repaintRectInLocalCoordinates() const;
virtual AffineTransform localTransform() const;
virtual const AffineTransform& localToParentTransform() const;
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
bool hasAspectRatio() const { return isReplaced() && (isImage() || isVideo() || isCanvas()); }
bool isAnonymous() const { return m_bitfields.isAnonymous(); }
bool isAnonymousBlock() const
{
return isAnonymous() && (style().display() == DisplayType::Block || style().display() == DisplayType::Box) && style().styleType() == PseudoId::None && isRenderBlock() && !isListMarker() && !isRenderFragmentedFlow() && !isRenderMultiColumnSet() && !isRenderView()
#if ENABLE(FULLSCREEN_API)
&& !isRenderFullScreen()
&& !isRenderFullScreenPlaceholder()
#endif
#if ENABLE(MATHML)
&& !isRenderMathMLBlock()
#endif
;
}
bool isFloating() const { return m_bitfields.floating(); }
bool isPositioned() const { return m_bitfields.isPositioned(); }
bool isInFlowPositioned() const { return m_bitfields.isRelativelyPositioned() || m_bitfields.isStickilyPositioned(); }
bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositioned(); } bool isFixedPositioned() const { return isOutOfFlowPositioned() && style().position() == PositionType::Fixed; }
bool isAbsolutelyPositioned() const { return isOutOfFlowPositioned() && style().position() == PositionType::Absolute; }
bool isRelativelyPositioned() const { return m_bitfields.isRelativelyPositioned(); }
bool isStickilyPositioned() const { return m_bitfields.isStickilyPositioned(); }
bool isText() const { return !m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
bool isLineBreak() const { return m_bitfields.isLineBreak(); }
bool isBR() const { return isLineBreak() && !isWBR(); }
bool isLineBreakOpportunity() const { return isLineBreak() && isWBR(); }
bool isTextOrLineBreak() const { return isText() || isLineBreak(); }
bool isBox() const { return m_bitfields.isBox(); }
bool isRenderView() const { return m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
bool isInline() const { return m_bitfields.isInline(); } bool isReplaced() const { return m_bitfields.isReplaced(); } bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
bool isDragging() const { return m_bitfields.hasRareData() && rareData().isDragging(); }
bool hasReflection() const { return m_bitfields.hasRareData() && rareData().hasReflection(); }
bool isRenderFragmentedFlow() const { return m_bitfields.hasRareData() && rareData().isRenderFragmentedFlow(); }
bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
bool isExcludedFromNormalLayout() const { return m_bitfields.isExcludedFromNormalLayout(); }
void setIsExcludedFromNormalLayout(bool excluded) { m_bitfields.setIsExcludedFromNormalLayout(excluded); }
bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() && isLegend(); }
bool hasLayer() const { return m_bitfields.hasLayer(); }
enum BoxDecorationState {
NoBoxDecorations,
HasBoxDecorationsAndBackgroundObscurationStatusInvalid,
HasBoxDecorationsAndBackgroundIsKnownToBeObscured,
HasBoxDecorationsAndBackgroundMayBeVisible,
};
bool hasVisibleBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
bool backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset);
bool needsLayout() const
{
return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
|| m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.needsPositionedMovementLayout();
}
bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
bool needsPositionedMovementLayoutOnly() const
{
return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
&& !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifiedNormalFlowLayout();
}
bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
bool needsSimplifiedNormalFlowLayoutOnly() const;
bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
bool isSelectionBorder() const;
bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } bool hasTransform() const { return hasTransformRelatedProperty() && style().hasTransform(); }
inline bool preservesNewline() const;
virtual void updateDragState(bool dragOn);
RenderView& view() const { return *document().renderView(); };
bool isRooted() const;
Node* node() const { return isAnonymous() ? nullptr : &m_node; }
Node* nonPseudoNode() const { return isPseudoElement() ? nullptr : node(); }
Node* generatingNode() const { return isPseudoElement() ? generatingPseudoHostElement() : node(); }
Document& document() const { return m_node.document(); }
Frame& frame() const;
Page& page() const;
Settings& settings() const { return page().settings(); }
RenderElement* container() const;
RenderElement* container(const RenderLayerModelObject* repaintContainer, bool& repaintContainerSkipped) const;
RenderBoxModelObject* offsetParent() const;
void markContainingBlocksForLayout(ScheduleRelayout = ScheduleRelayout::Yes, RenderElement* newRoot = nullptr);
void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain);
void clearNeedsLayout();
void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
void invalidateContainerPreferredLogicalWidths();
void setNeedsLayoutAndPrefWidthsRecalc()
{
setNeedsLayout();
setPreferredLogicalWidthsDirty(true);
}
void setPositionState(PositionType position)
{
ASSERT((position != PositionType::Absolute && position != PositionType::Fixed) || isBox());
m_bitfields.setPositionedState(static_cast<int>(position));
}
void clearPositionedState() { m_bitfields.clearPositionedState(); }
void setFloating(bool b = true) { m_bitfields.setFloating(b); }
void setInline(bool b = true) { m_bitfields.setIsInline(b); }
void setHasVisibleBoxDecorations(bool = true);
void invalidateBackgroundObscurationStatus();
virtual bool computeBackgroundIsKnownToBeObscured(const LayoutPoint&) { return false; }
void setIsText() { ASSERT(!isBox()); m_bitfields.setIsTextOrRenderView(true); }
void setIsLineBreak() { m_bitfields.setIsLineBreak(true); }
void setIsBox() { m_bitfields.setIsBox(true); }
void setIsRenderView() { ASSERT(isBox()); m_bitfields.setIsTextOrRenderView(true); }
void setReplaced(bool b = true) { m_bitfields.setIsReplaced(b); }
void setHorizontalWritingMode(bool b = true) { m_bitfields.setHorizontalWritingMode(b); }
void setHasOverflowClip(bool b = true) { m_bitfields.setHasOverflowClip(b); }
void setHasLayer(bool b = true) { m_bitfields.setHasLayer(b); }
void setHasTransformRelatedProperty(bool b = true) { m_bitfields.setHasTransformRelatedProperty(b); }
void setIsDragging(bool);
void setHasReflection(bool = true);
void setIsRenderFragmentedFlow(bool = true);
void setHasOutlineAutoAncestor(bool = true);
virtual int innerLineHeight() const;
virtual void updateFromElement() { }
#if ENABLE(DASHBOARD_SUPPORT)
virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&);
void collectAnnotatedRegions(Vector<AnnotatedRegionValue>&);
#endif
bool isComposited() const;
bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual Position positionForPoint(const LayoutPoint&);
virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderFragmentContainer*);
VisiblePosition createVisiblePosition(int offset, EAffinity) const;
VisiblePosition createVisiblePosition(const Position&) const;
WEBCORE_EXPORT RenderBlock* containingBlock() const;
RenderBlock* containingBlockForObjectInFlow() const;
WEBCORE_EXPORT FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const;
FloatPoint absoluteToLocal(const FloatPoint&, MapCoordinatesFlags = 0) const;
FloatQuad localToAbsoluteQuad(const FloatQuad& quad, MapCoordinatesFlags mode = UseTransforms, bool* wasFixed = nullptr) const
{
return localToContainerQuad(quad, nullptr, mode, wasFixed);
}
FloatQuad absoluteToLocalQuad(const FloatQuad&, MapCoordinatesFlags mode = UseTransforms) const;
WEBCORE_EXPORT FloatQuad localToContainerQuad(const FloatQuad&, const RenderLayerModelObject* repaintContainer, MapCoordinatesFlags = UseTransforms, bool* wasFixed = nullptr) const;
WEBCORE_EXPORT FloatPoint localToContainerPoint(const FloatPoint&, const RenderLayerModelObject* repaintContainer, MapCoordinatesFlags = UseTransforms, bool* wasFixed = nullptr) const;
virtual LayoutSize offsetFromContainer(RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = nullptr) const;
LayoutSize offsetFromAncestorContainer(RenderElement&) const;
#if PLATFORM(IOS_FAMILY)
virtual void collectSelectionRects(Vector<SelectionRect>&, unsigned startOffset = 0, unsigned endOffset = std::numeric_limits<unsigned>::max());
virtual void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const { absoluteQuads(quads); }
#endif
virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
WEBCORE_EXPORT IntRect absoluteBoundingBoxRect(bool useTransform = true, bool* wasFixed = nullptr) const;
IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
virtual void absoluteQuads(Vector<FloatQuad>&, bool* = nullptr) const { }
virtual void absoluteFocusRingQuads(Vector<FloatQuad>&);
static FloatRect absoluteBoundingBoxRectForRange(const Range*);
WEBCORE_EXPORT LayoutRect paintingRootRect(LayoutRect& topLevelRect);
virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
const RenderStyle& style() const;
const RenderStyle& firstLineStyle() const;
virtual const RenderStyle& outlineStyleForRepaint() const { return style(); }
virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
RenderLayerModelObject* containerForRepaint() const;
void repaintUsingContainer(const RenderLayerModelObject* repaintContainer, const LayoutRect&, bool shouldClipToLayer = true) const;
void repaint() const;
WEBCORE_EXPORT void repaintRectangle(const LayoutRect&, bool shouldClipToLayer = true) const;
void repaintSlowRepaintObject() const;
LayoutRect absoluteClippedOverflowRect() const
{
return clippedOverflowRectForRepaint(nullptr);
}
WEBCORE_EXPORT IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const;
virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const;
virtual LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* , const RenderGeometryMap* = nullptr) const { return LayoutRect(); }
LayoutRect computeAbsoluteRepaintRect(const LayoutRect& r) const
{
return computeRectForRepaint(r, nullptr);
}
LayoutRect computeRectForRepaint(const LayoutRect&, const RenderLayerModelObject* repaintContainer) const;
FloatRect computeFloatRectForRepaint(const FloatRect&, const RenderLayerModelObject* repaintContainer) const;
enum class VisibleRectContextOption {
UseEdgeInclusiveIntersection = 1 << 0,
ApplyCompositedClips = 1 << 1,
ApplyCompositedContainerScrolls = 1 << 2,
};
struct VisibleRectContext {
VisibleRectContext(bool hasPositionFixedDescendant = false, bool dirtyRectIsFlipped = false, OptionSet<VisibleRectContextOption> options = { })
: m_hasPositionFixedDescendant(hasPositionFixedDescendant)
, m_dirtyRectIsFlipped(dirtyRectIsFlipped)
, m_options(options)
{
}
bool m_hasPositionFixedDescendant;
bool m_dirtyRectIsFlipped;
OptionSet<VisibleRectContextOption> m_options;
};
virtual Optional<LayoutRect> computeVisibleRectInContainer(const LayoutRect&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
virtual Optional<FloatRect> computeFloatVisibleRectInContainer(const FloatRect&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
virtual unsigned int length() const { return 1; }
bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
enum SelectionState {
SelectionNone, SelectionStart, SelectionInside, SelectionEnd, SelectionBoth };
SelectionState selectionState() const { return m_bitfields.selectionState(); }
virtual void setSelectionState(SelectionState state) { m_bitfields.setSelectionState(state); }
inline void setSelectionStateIfNeeded(SelectionState);
bool canUpdateSelectionOnRootLineBoxes();
LayoutRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(nullptr, clipToVisibleContent); }
virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* , bool = true) { return LayoutRect(); }
virtual bool canBeSelectionLeaf() const { return false; }
virtual bool shouldPaintSelectionGaps() const { return false; }
virtual LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr);
bool renderTreeBeingDestroyed() const;
void destroy();
virtual bool isDeprecatedFlexibleBox() const { return false; }
virtual bool isFlexibleBox() const { return false; }
bool isFlexibleBoxIncludingDeprecated() const
{
return isFlexibleBox() || isDeprecatedFlexibleBox();
}
virtual bool isCombineText() const { return false; }
virtual int caretMinOffset() const;
virtual int caretMaxOffset() const;
virtual int previousOffset(int current) const;
virtual int previousOffsetForBackwardDeletion(int current) const;
virtual int nextOffset(int current) const;
void imageChanged(CachedImage*, const IntRect* = nullptr) override;
virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { }
CSSAnimationController& animation() const;
DocumentTimeline* documentTimeline() const;
virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed = nullptr) const;
virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const;
virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const;
bool shouldUseTransformFromContainer(const RenderObject* container) const;
void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& , const RenderLayerModelObject* = nullptr) { };
LayoutRect absoluteOutlineBounds() const
{
return outlineBoundsForRepaint(nullptr);
}
virtual void willBeRemovedFromTree();
void resetFragmentedFlowStateOnRemoval();
void initializeFragmentedFlowStateOnInsertion();
virtual void insertedIntoTree();
WEBCORE_EXPORT bool isTransparentRespectingParentFrames() const;
protected:
void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
void setNextSibling(RenderObject* next) { m_next = next; }
void setParent(RenderElement*);
void addPDFURLRect(PaintInfo&, const LayoutPoint&);
Node& nodeForNonAnonymous() const { ASSERT(!isAnonymous()); return m_node; }
void adjustRectForOutlineAndShadow(LayoutRect&) const;
virtual void willBeDestroyed();
void setNeedsPositionedMovementLayoutBit(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
void setNormalChildNeedsLayoutBit(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
void setPosChildNeedsLayoutBit(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
void setNeedsSimplifiedNormalFlowLayoutBit(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
virtual RenderFragmentedFlow* locateEnclosingFragmentedFlow() const;
static void calculateBorderStyleColor(const BorderStyle&, const BoxSide&, Color&);
static FragmentedFlowState computedFragmentedFlowState(const RenderObject&);
static bool shouldApplyCompositedContainerScrollsForRepaint();
static VisibleRectContext visibleRectContextForRepaint();
private:
#ifndef NDEBUG
bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
#endif
void addAbsoluteRectForLayer(LayoutRect& result);
void setLayerNeedsFullRepaint();
void setLayerNeedsFullRepaintForPositionedMovementLayout();
Node* generatingPseudoHostElement() const;
void propagateRepaintToParentWithOutlineAutoIfNeeded(const RenderLayerModelObject& repaintContainer, const LayoutRect& repaintRect) const;
virtual bool isWBR() const { ASSERT_NOT_REACHED(); return false; }
void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
bool hasRareData() const { return m_bitfields.hasRareData(); }
void setHasRareData(bool b) { m_bitfields.setHasRareData(b); }
#ifndef NDEBUG
void checkBlockPositionedObjectsNeedLayout();
#endif
Node& m_node;
RenderElement* m_parent;
RenderObject* m_previous;
RenderObject* m_next;
#ifndef NDEBUG
bool m_hasAXObject : 1;
bool m_setNeedsLayoutForbidden : 1;
#endif
#define ADD_BOOLEAN_BITFIELD(name, Name) \
private:\
unsigned m_##name : 1;\
public:\
bool name() const { return m_##name; }\
void set##Name(bool name) { m_##name = name; }\
#define ADD_ENUM_BITFIELD(name, Name, Type, width) \
private:\
unsigned m_##name : width;\
public:\
Type name() const { return static_cast<Type>(m_##name); }\
void set##Name(Type name) { m_##name = static_cast<unsigned>(name); }\
class RenderObjectBitfields {
enum PositionedState {
IsStaticallyPositioned = 0,
IsRelativelyPositioned = 1,
IsOutOfFlowPositioned = 2,
IsStickilyPositioned = 3
};
public:
RenderObjectBitfields(const Node& node)
: m_hasRareData(false)
, m_beingDestroyed(false)
, m_needsLayout(false)
, m_needsPositionedMovementLayout(false)
, m_normalChildNeedsLayout(false)
, m_posChildNeedsLayout(false)
, m_needsSimplifiedNormalFlowLayout(false)
, m_preferredLogicalWidthsDirty(false)
, m_floating(false)
, m_isAnonymous(node.isDocumentNode())
, m_isTextOrRenderView(false)
, m_isBox(false)
, m_isInline(true)
, m_isReplaced(false)
, m_isLineBreak(false)
, m_horizontalWritingMode(true)
, m_hasLayer(false)
, m_hasOverflowClip(false)
, m_hasTransformRelatedProperty(false)
, m_everHadLayout(false)
, m_childrenInline(false)
, m_isExcludedFromNormalLayout(false)
, m_positionedState(IsStaticallyPositioned)
, m_selectionState(SelectionNone)
, m_fragmentedFlowState(NotInsideFragmentedFlow)
, m_boxDecorationState(NoBoxDecorations)
{
}
ADD_BOOLEAN_BITFIELD(hasRareData, HasRareData);
ADD_BOOLEAN_BITFIELD(beingDestroyed, BeingDestroyed);
ADD_BOOLEAN_BITFIELD(needsLayout, NeedsLayout);
ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovementLayout);
ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNormalFlowLayout);
ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidthsDirty);
ADD_BOOLEAN_BITFIELD(floating, Floating);
ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
ADD_BOOLEAN_BITFIELD(isTextOrRenderView, IsTextOrRenderView);
ADD_BOOLEAN_BITFIELD(isBox, IsBox);
ADD_BOOLEAN_BITFIELD(isInline, IsInline);
ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
ADD_BOOLEAN_BITFIELD(isLineBreak, IsLineBreak);
ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedProperty);
ADD_BOOLEAN_BITFIELD(unused, Unused);
ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
ADD_BOOLEAN_BITFIELD(isExcludedFromNormalLayout, IsExcludedFromNormalLayout);
private:
unsigned m_positionedState : 2; unsigned m_selectionState : 3; unsigned m_fragmentedFlowState : 2; unsigned m_boxDecorationState : 2;
public:
bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOfFlowPositioned; }
bool isRelativelyPositioned() const { return m_positionedState == IsRelativelyPositioned; }
bool isStickilyPositioned() const { return m_positionedState == IsStickilyPositioned; }
bool isPositioned() const { return m_positionedState != IsStaticallyPositioned; }
void setPositionedState(int positionState)
{
m_positionedState = static_cast<PositionedState>(positionState & 0x3);
}
void clearPositionedState() { m_positionedState = static_cast<unsigned>(PositionType::Static); }
ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
ALWAYS_INLINE FragmentedFlowState fragmentedFlowState() const { return static_cast<FragmentedFlowState>(m_fragmentedFlowState); }
ALWAYS_INLINE void setFragmentedFlowState(FragmentedFlowState fragmentedFlowState) { m_fragmentedFlowState = fragmentedFlowState; }
ALWAYS_INLINE BoxDecorationState boxDecorationState() const { return static_cast<BoxDecorationState>(m_boxDecorationState); }
ALWAYS_INLINE void setBoxDecorationState(BoxDecorationState boxDecorationState) { m_boxDecorationState = boxDecorationState; }
};
RenderObjectBitfields m_bitfields;
class RenderObjectRareData {
public:
RenderObjectRareData()
: m_isDragging(false)
, m_hasReflection(false)
, m_isRenderFragmentedFlow(false)
, m_hasOutlineAutoAncestor(false)
{
}
ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
ADD_BOOLEAN_BITFIELD(isRenderFragmentedFlow, IsRenderFragmentedFlow);
ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
std::unique_ptr<RenderStyle> cachedFirstLineStyle;
};
const RenderObject::RenderObjectRareData& rareData() const;
RenderObjectRareData& ensureRareData();
void removeRareData();
typedef HashMap<const RenderObject*, std::unique_ptr<RenderObjectRareData>> RareDataMap;
static RareDataMap& rareDataMap();
#undef ADD_BOOLEAN_BITFIELD
};
inline Frame& RenderObject::frame() const
{
return *document().frame();
}
inline Page& RenderObject::page() const
{
ASSERT(frame().page());
return *frame().page();
}
inline CSSAnimationController& RenderObject::animation() const
{
return frame().animation();
}
inline DocumentTimeline* RenderObject::documentTimeline() const
{
return document().existingTimeline();
}
inline bool RenderObject::renderTreeBeingDestroyed() const
{
return document().renderTreeBeingDestroyed();
}
inline bool RenderObject::isBeforeContent() const
{
if (isText())
return false;
if (style().styleType() != PseudoId::Before)
return false;
return true;
}
inline bool RenderObject::isAfterContent() const
{
if (isText())
return false;
if (style().styleType() != PseudoId::After)
return false;
return true;
}
inline bool RenderObject::isBeforeOrAfterContent() const
{
return isBeforeContent() || isAfterContent();
}
inline void RenderObject::setNeedsLayout(MarkingBehavior markParents)
{
ASSERT(!isSetNeedsLayoutForbidden());
if (m_bitfields.needsLayout())
return;
m_bitfields.setNeedsLayout(true);
if (markParents == MarkContainingBlockChain)
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaint();
}
inline bool RenderObject::preservesNewline() const
{
if (isSVGInlineText())
return false;
return style().preserveNewline();
}
inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
{
if (selectionState() == state)
return;
setSelectionState(state);
}
inline void RenderObject::setHasVisibleBoxDecorations(bool b)
{
if (!b) {
m_bitfields.setBoxDecorationState(NoBoxDecorations);
return;
}
if (hasVisibleBoxDecorations())
return;
m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
}
inline void RenderObject::invalidateBackgroundObscurationStatus()
{
if (!hasVisibleBoxDecorations())
return;
m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
}
inline bool RenderObject::backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset)
{
if (m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundObscurationStatusInvalid) {
BoxDecorationState boxDecorationState = computeBackgroundIsKnownToBeObscured(paintOffset) ? HasBoxDecorationsAndBackgroundIsKnownToBeObscured : HasBoxDecorationsAndBackgroundMayBeVisible;
m_bitfields.setBoxDecorationState(boxDecorationState);
}
return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
}
inline bool RenderObject::needsSimplifiedNormalFlowLayoutOnly() const
{
return m_bitfields.needsSimplifiedNormalFlowLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
&& !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsPositionedMovementLayout();
}
#if ENABLE(TREE_DEBUGGING)
void printRenderTreeForLiveDocuments();
void printLayerTreeForLiveDocuments();
void printGraphicsLayerTreeForLiveDocuments();
#endif
}
#define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
static bool isType(const WebCore::RenderObject& renderer) { return renderer.predicate; } \
SPECIALIZE_TYPE_TRAITS_END()
#if ENABLE(TREE_DEBUGGING)
void showNodeTree(const WebCore::RenderObject*);
void showLineTree(const WebCore::RenderObject*);
void showRenderTree(const WebCore::RenderObject*);
#endif