#ifndef RenderObject_h
#define RenderObject_h
#include "CachedImage.h"
#include "Document.h"
#include "Element.h"
#include "FractionalLayoutUnit.h"
#include "FloatQuad.h"
#include "LayoutTypes.h"
#include "PaintPhase.h"
#include "RenderObjectChildList.h"
#include "RenderStyle.h"
#include "ScrollBehavior.h"
#include "TextAffinity.h"
#include "TransformationMatrix.h"
#include <wtf/HashSet.h>
#include <wtf/UnusedParam.h>
#if USE(CG) || USE(CAIRO) || USE(SKIA) || PLATFORM(QT)
#define HAVE_PATH_BASED_BORDER_RADIUS_DRAWING 1
#endif
namespace WebCore {
class AffineTransform;
class AnimationController;
class Cursor;
class HitTestResult;
class InlineBox;
class InlineFlowBox;
class OverlapTestRequestClient;
class Path;
class Position;
class RenderBoxModelObject;
class RenderInline;
class RenderBlock;
class RenderFlowThread;
class RenderGeometryMap;
class RenderLayer;
class RenderNamedFlowThread;
class RenderTable;
class RenderTheme;
class TransformState;
class VisiblePosition;
#if ENABLE(SVG)
class RenderSVGResourceContainer;
#endif
struct PaintInfo;
enum CursorDirective {
SetCursorBasedOnStyle,
SetCursor,
DoNotSetCursor
};
enum HitTestFilter {
HitTestAll,
HitTestSelf,
HitTestDescendants
};
enum HitTestAction {
HitTestBlockBackground,
HitTestChildBlockBackground,
HitTestChildBlockBackgrounds,
HitTestFloat,
HitTestForeground
};
enum BoxSide {
BSTop,
BSRight,
BSBottom,
BSLeft
};
enum MarkingBehavior {
MarkOnlyThis,
MarkContainingBlockChain,
};
enum PlaceGeneratedRunInFlag {
PlaceGeneratedRunIn,
DoNotPlaceGeneratedRunIn
};
const int caretWidth = 1;
#if ENABLE(DASHBOARD_SUPPORT)
struct DashboardRegionValue {
bool operator==(const DashboardRegionValue& o) const
{
return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
}
bool operator!=(const DashboardRegionValue& o) const
{
return !(*this == o);
}
String label;
LayoutRect bounds;
LayoutRect clip;
int type;
};
#endif
typedef WTF::HashSet<const RenderObject*> RenderObjectAncestorLineboxDirtySet;
#ifndef NDEBUG
const int showTreeCharacterOffset = 39;
#endif
class RenderObject : public CachedImageClient {
friend class LayoutRepainter;
friend class RenderBlock;
friend class RenderBox;
friend class RenderLayer;
friend class RenderObjectChildList;
friend class RenderSVGContainer;
public:
RenderObject(Node*);
virtual ~RenderObject();
RenderTheme* theme() const;
virtual const char* renderName() const = 0;
RenderObject* parent() const { return m_parent; }
bool isDescendantOf(const RenderObject*) const;
RenderObject* previousSibling() const { return m_previous; }
RenderObject* nextSibling() const { return m_next; }
RenderObject* firstChild() const
{
if (const RenderObjectChildList* children = virtualChildren())
return children->firstChild();
return 0;
}
RenderObject* lastChild() const
{
if (const RenderObjectChildList* children = virtualChildren())
return children->lastChild();
return 0;
}
RenderObject* beforePseudoElementRenderer() const
{
if (const RenderObjectChildList* children = virtualChildren())
return children->beforePseudoElementRenderer(this);
return 0;
}
RenderObject* afterPseudoElementRenderer() const
{
if (const RenderObjectChildList* children = virtualChildren())
return children->afterPseudoElementRenderer(this);
return 0;
}
virtual RenderObjectChildList* virtualChildren() { return 0; }
virtual const RenderObjectChildList* virtualChildren() const { return 0; }
RenderObject* nextInPreOrder() const;
RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
RenderObject* nextInPreOrderAfterChildren() const;
RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
RenderObject* previousInPreOrder() const;
RenderObject* childAt(unsigned) const;
RenderObject* firstLeafChild() const;
RenderObject* lastLeafChild() const;
RenderLayer* enclosingLayer() const;
void addLayers(RenderLayer* parentLayer);
void removeLayers(RenderLayer* parentLayer);
void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
RenderBox* enclosingBox() const;
RenderBoxModelObject* enclosingBoxModelObject() const;
RenderFlowThread* enclosingRenderFlowThread() const;
RenderNamedFlowThread* enclosingRenderNamedFlowThread() const;
virtual bool isEmpty() const { return firstChild() == 0; }
#ifndef NDEBUG
void setHasAXObject(bool flag) { m_hasAXObject = flag; }
bool hasAXObject() const { return m_hasAXObject; }
bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
#endif
virtual RenderBlock* firstLineBlock() const;
void handleDynamicFloatPositionChange();
virtual bool canHaveChildren() const { return virtualChildren(); }
virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true; }
virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }
virtual void removeChild(RenderObject*);
virtual bool createsAnonymousWrapper() const { return false; }
protected:
void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
void setNextSibling(RenderObject* next) { m_next = next; }
void setParent(RenderObject* parent)
{
m_parent = parent;
if (parent && parent->inRenderFlowThread())
setInRenderFlowThread(true);
else if (!parent && inRenderFlowThread())
setInRenderFlowThread(false);
}
private:
void addAbsoluteRectForLayer(LayoutRect& result);
void setLayerNeedsFullRepaint();
void setLayerNeedsFullRepaintForPositionedMovementLayout();
public:
#ifndef NDEBUG
void showTreeForThis() const;
void showRenderTreeForThis() const;
void showLineTreeForThis() const;
void showRenderObject() const;
void showRenderObject(int printedCharacters) const;
void showRenderTreeAndMark(const RenderObject* markedObject1 = 0, const char* markedLabel1 = 0, const RenderObject* markedObject2 = 0, const char* markedLabel2 = 0, int depth = 0) const;
#endif
static RenderObject* createObject(Node*, RenderStyle*);
void* operator new(size_t, RenderArena*);
void operator delete(void*, size_t);
private:
void* operator new(size_t) throw();
public:
RenderArena* renderArena() const { return document()->renderArena(); }
virtual bool isBR() const { return false; }
virtual bool isBlockFlow() const { return false; }
virtual bool isBoxModelObject() const { return false; }
virtual bool isCounter() const { return false; }
virtual bool isQuote() const { return false; }
#if ENABLE(DETAILS)
virtual bool isDetailsMarker() const { return false; }
#endif
virtual bool isEmbeddedObject() const { return false; }
virtual bool isFieldset() const { return false; }
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_TAG)
virtual bool isMeter() const { return false; }
#endif
#if ENABLE(PROGRESS_TAG)
virtual bool isProgress() const { return false; }
#endif
virtual bool isRenderBlock() const { return false; }
virtual bool isRenderButton() const { return false; }
virtual bool isRenderIFrame() const { return false; }
virtual bool isRenderImage() const { return false; }
virtual bool isRenderInline() const { return false; }
virtual bool isRenderPart() const { return false; }
virtual bool isRenderRegion() const { return false; }
virtual bool isRenderView() const { return false; }
virtual bool isReplica() const { return false; }
virtual bool isRuby() 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 isTableCol() 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 isVideo() const { return false; }
virtual bool isWidget() const { return false; }
virtual bool isCanvas() const { return false; }
#if ENABLE(FULLSCREEN_API)
virtual bool isRenderFullScreen() const { return false; }
virtual bool isRenderFullScreenPlaceholder() const { return false; }
#endif
virtual bool isRenderFlowThread() const { return false; }
virtual bool isRenderNamedFlowThread() const { return false; }
virtual bool isRenderScrollbarPart() const { return false; }
bool canHaveRegionStyle() const { return isRenderBlock() && !isAnonymous() && !isRenderFlowThread(); }
bool isRoot() const { return document()->documentElement() == m_node; }
bool isBody() const;
bool isHR() const;
bool isLegend() const;
bool isHTMLMarquee() const;
bool isTablePart() const { return isTableCell() || isTableCol() || 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 hasCounterNodeMap() const { return m_bitfields.hasCounterNodeMap(); }
void setHasCounterNodeMap(bool hasCounterNodeMap) { m_bitfields.setHasCounterNodeMap(hasCounterNodeMap); }
bool everHadLayout() const { return m_bitfields.everHadLayout(); }
bool childrenInline() const { return m_bitfields.childrenInline(); }
void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
bool hasColumns() const { return m_bitfields.hasColumns(); }
void setHasColumns(bool b = true) { m_bitfields.setHasColumns(b); }
bool ancestorLineBoxDirty() const { return s_ancestorLineboxDirtySet && s_ancestorLineboxDirtySet->contains(this); }
void setAncestorLineBoxDirty(bool b = true)
{
if (b) {
if (!s_ancestorLineboxDirtySet)
s_ancestorLineboxDirtySet = new RenderObjectAncestorLineboxDirtySet;
s_ancestorLineboxDirtySet->add(this);
setNeedsLayout(true);
} else if (s_ancestorLineboxDirtySet) {
s_ancestorLineboxDirtySet->remove(this);
if (s_ancestorLineboxDirtySet->isEmpty()) {
delete s_ancestorLineboxDirtySet;
s_ancestorLineboxDirtySet = 0;
}
}
}
bool inRenderFlowThread() const { return m_bitfields.inRenderFlowThread(); }
void setInRenderFlowThread(bool b = true) { m_bitfields.setInRenderFlowThread(b); }
virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
#if ENABLE(MATHML)
virtual bool isRenderMathMLBlock() const { return false; }
#endif // ENABLE(MATHML)
#if ENABLE(SVG)
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 isSVGRect() const { return false; }
virtual bool isSVGShape() const { return false; }
virtual bool isSVGText() const { return false; }
virtual bool isSVGTextPath() 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 isSVGResourceFilterPrimitive() const { return false; }
virtual RenderSVGResourceContainer* toRenderSVGResourceContainer();
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);
#endif
bool isAnonymous() const { return m_bitfields.isAnonymous(); }
void setIsAnonymous(bool b) { m_bitfields.setIsAnonymous(b); }
bool isAnonymousBlock() const
{
return isAnonymous() && (style()->display() == BLOCK || style()->display() == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMarker()
#if ENABLE(FULLSCREEN_API)
&& !isRenderFullScreen()
&& !isRenderFullScreenPlaceholder()
#endif
;
}
bool isAnonymousColumnsBlock() const { return style()->specifiesColumns() && isAnonymousBlock(); }
bool isAnonymousColumnSpanBlock() const { return style()->columnSpan() && isAnonymousBlock(); }
bool isElementContinuation() const { return node() && node()->renderer() != this; }
bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
bool isBlockElementContinuation() const { return isElementContinuation() && !isInline(); }
virtual RenderBoxModelObject* virtualContinuation() const { return 0; }
bool isFloating() const { return m_bitfields.floating(); }
bool isPositioned() const { return m_bitfields.positioned(); } bool isRelPositioned() const { return m_bitfields.relPositioned(); } bool isText() const { return m_bitfields.isText(); }
bool isBox() const { return m_bitfields.isBox(); }
bool isInline() const { return m_bitfields.isInline(); } bool isRunIn() const { return style()->display() == RUN_IN; } bool isDragging() const { return m_bitfields.isDragging(); }
bool isReplaced() const { return m_bitfields.isReplaced(); } bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
bool hasLayer() const { return m_bitfields.hasLayer(); }
bool hasBoxDecorations() const { return m_bitfields.paintBackground(); }
bool borderImageIsLoadedAndCanBeRendered() const;
bool mustRepaintBackgroundOrBorder() const;
bool hasBackground() const { return style()->hasBackground(); }
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 normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
bool isSelectionBorder() const;
bool hasClip() const { return isPositioned() && style()->hasClip(); }
bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
bool hasTransform() const { return m_bitfields.hasTransform(); }
bool hasMask() const { return style() && style()->hasMask(); }
bool hasHiddenBackface() const { return style() && style()->backfaceVisibility() == BackfaceVisibilityHidden; }
#if ENABLE(CSS_FILTERS)
bool hasFilter() const { return style() && style()->hasFilter(); }
#else
bool hasFilter() const { return false; }
#endif
inline bool preservesNewline() const;
#if !HAVE(PATH_BASED_BORDER_RADIUS_DRAWING)
void drawArcForBoxSide(GraphicsContext*, int x, int y, float thickness, const IntSize& radius, int angleStart,
int angleSpan, BoxSide, Color, EBorderStyle, bool firstCorner);
#endif
RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
PassRefPtr<RenderStyle> getUncachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
virtual void updateDragState(bool dragOn);
RenderView* view() const;
bool isRooted(RenderView** = 0);
Node* node() const { return isAnonymous() ? 0 : m_node; }
Node* generatingNode() const { return m_node == document() ? 0 : m_node; }
void setNode(Node* node) { m_node = node; }
Document* document() const { return m_node->document(); }
Frame* frame() const { return document()->frame(); }
bool hasOutlineAnnotation() const;
bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
RenderObject* container(const RenderBoxModelObject* repaintContainer = 0, bool* repaintContainerSkipped = 0) const;
virtual RenderObject* hoverAncestor() const { return parent(); }
RenderBoxModelObject* offsetParent() const;
void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObject* newRoot = 0);
void setNeedsLayout(bool needsLayout, MarkingBehavior = MarkContainingBlockChain);
void setChildNeedsLayout(bool childNeedsLayout, MarkingBehavior = MarkContainingBlockChain);
void setNeedsPositionedMovementLayout();
void setNeedsSimplifiedNormalFlowLayout();
void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
void invalidateContainerPreferredLogicalWidths();
void setNeedsLayoutAndPrefWidthsRecalc()
{
setNeedsLayout(true);
setPreferredLogicalWidthsDirty(true);
}
void setPositioned(bool b = true) { m_bitfields.setPositioned(b); }
void setRelPositioned(bool b = true) { m_bitfields.setRelPositioned(b); }
void setFloating(bool b = true) { m_bitfields.setFloating(b); }
void setInline(bool b = true) { m_bitfields.setIsInline(b); }
void setHasBoxDecorations(bool b = true) { m_bitfields.setPaintBackground(b); }
void setIsText() { m_bitfields.setIsText(true); }
void setIsBox() { m_bitfields.setIsBox(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 setHasTransform(bool b = true) { m_bitfields.setHasTransform(b); }
void setHasReflection(bool b = true) { m_bitfields.setHasReflection(b); }
void scheduleRelayout();
void updateFillImages(const FillLayer*, const FillLayer*);
void updateImage(StyleImage*, StyleImage*);
virtual void paint(PaintInfo&, const LayoutPoint&);
virtual void layout();
void layoutIfNeeded() { if (needsLayout()) layout(); }
virtual void updateFromElement() { }
#if ENABLE(DASHBOARD_SUPPORT)
virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
void collectDashboardRegions(Vector<DashboardRegionValue>&);
#endif
bool isComposited() const;
bool hitTest(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
virtual VisiblePosition positionForPoint(const LayoutPoint&);
VisiblePosition createVisiblePosition(int offset, EAffinity);
VisiblePosition createVisiblePosition(const Position&);
virtual void dirtyLinesFromChangedChild(RenderObject*);
void setAnimatableStyle(PassRefPtr<RenderStyle>);
virtual void setStyle(PassRefPtr<RenderStyle>);
void setStyleInternal(PassRefPtr<RenderStyle>);
RenderBlock* containingBlock() const;
FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
FloatPoint absoluteToLocal(const FloatPoint&, bool fixed = false, bool useTransforms = false) const;
FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false, bool* wasFixed = 0) const
{
return localToContainerQuad(quad, 0, fixed, wasFixed);
}
FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0) const;
FloatPoint localToContainerPoint(const FloatPoint&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0) const;
virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const;
LayoutSize offsetFromAncestorContainer(RenderObject*) const;
virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
IntRect absoluteBoundingBoxRect(bool useTransform = true) const;
IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
virtual void absoluteQuads(Vector<FloatQuad>&, bool* = 0) const { }
void absoluteFocusRingQuads(Vector<FloatQuad>&);
LayoutRect paintingRootRect(LayoutRect& topLevelRect);
virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
RenderStyle* style() const { return m_style.get(); }
RenderStyle* firstLineStyle() const { return document()->usesFirstLineRules() ? firstLineStyleSlowCase() : style(); }
RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
void getTextDecorationColors(int decorations, Color& underline, Color& overline, Color& linethrough, bool quirksMode = false);
RenderBoxModelObject* containerForRepaint() const;
void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const LayoutRect&, bool immediate = false);
void repaint(bool immediate = false);
void repaintRectangle(const LayoutRect&, bool immediate = false);
bool repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, const LayoutRect* newBoundsPtr = 0, const LayoutRect* newOutlineBoxPtr = 0);
virtual void repaintDuringLayoutIfMoved(const LayoutRect&);
virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
bool checkForRepaintDuringLayout() const;
LayoutRect absoluteClippedOverflowRect() const
{
return clippedOverflowRectForRepaint(0);
}
IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const;
void computeAbsoluteRepaintRect(LayoutRect& r, bool fixed = false) const
{
computeRectForRepaint(0, r, fixed);
}
virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed = false) const;
virtual void computeFloatRectForRepaint(RenderBoxModelObject* repaintContainer, FloatRect& repaintRect, bool fixed = false) const;
virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const { }
virtual unsigned int length() const { return 1; }
bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); }
bool isTransparent() const { return style()->opacity() < 1.0f; }
float opacity() const { return style()->opacity(); }
bool hasReflection() const { return m_bitfields.hasReflection(); }
int maximalOutlineSize(PaintPhase) const;
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(0, clipToVisibleContent); }
virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* , bool = true) { return LayoutRect(); }
virtual bool canBeSelectionLeaf() const { return false; }
bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
Color selectionBackgroundColor() const;
Color selectionForegroundColor() const;
Color selectionEmphasisMarkColor() const;
virtual bool shouldPaintSelectionGaps() const { return false; }
virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
bool isMarginBeforeQuirk() const { return m_bitfields.marginBeforeQuirk(); }
bool isMarginAfterQuirk() const { return m_bitfields.marginAfterQuirk(); }
void setMarginBeforeQuirk(bool b = true) { m_bitfields.setMarginBeforeQuirk(b); }
void setMarginAfterQuirk(bool b = true) { m_bitfields.setMarginAfterQuirk(b); }
bool documentBeingDestroyed() const;
void destroyAndCleanupAnonymousWrappers();
virtual void destroy();
virtual bool isDeprecatedFlexibleBox() const { return false; }
virtual bool isFlexingChildren() const { return false; }
virtual bool isStretchingChildren() 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;
virtual void imageChanged(CachedImage*, const IntRect* = 0);
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
virtual bool willRenderImage(CachedImage*);
void selectionStartEnd(int& spos, int& epos) const;
void remove() { if (parent()) parent()->removeChild(this); }
AnimationController* animation() const;
bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
enum ApplyContainerFlipOrNot { DoNotApplyContainerFlip, ApplyContainerFlip };
virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, ApplyContainerFlipOrNot = ApplyContainerFlip, bool* wasFixed = 0) const;
virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
virtual const RenderObject* pushMappingToContainer(const RenderBoxModelObject* ancestorToStopAt, RenderGeometryMap&) const;
bool shouldUseTransformFromContainer(const RenderObject* container) const;
void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&) { };
LayoutRect absoluteOutlineBounds() const
{
return outlineBoundsForRepaint(0);
}
RenderObject* rendererForRootBackground();
RespectImageOrientationEnum shouldRespectImageOrientation() const;
protected:
inline bool layerCreationAllowedForSubtree() const;
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
void paintFocusRing(GraphicsContext*, const LayoutPoint&, RenderStyle*);
void paintOutline(GraphicsContext*, const LayoutRect&);
void addPDFURLRect(GraphicsContext*, const LayoutRect&);
virtual LayoutRect viewRect() const;
void adjustRectForOutlineAndShadow(LayoutRect&) const;
void clearLayoutRootIfNeeded() const;
virtual void willBeDestroyed();
void arenaDelete(RenderArena*, void* objectBase);
virtual LayoutRect outlineBoundsForRepaint(RenderBoxModelObject* , const RenderGeometryMap* = 0) const { return LayoutRect(); }
virtual bool canBeReplacedWithInlineRunIn() const;
virtual void insertedIntoTree();
virtual void willBeRemovedFromTree();
private:
RenderStyle* firstLineStyleSlowCase() const;
StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensitiveProperties) const;
Color selectionColor(int colorProperty) const;
RefPtr<RenderStyle> m_style;
Node* m_node;
RenderObject* m_parent;
RenderObject* m_previous;
RenderObject* m_next;
static RenderObjectAncestorLineboxDirtySet* s_ancestorLineboxDirtySet;
#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; }\
class RenderObjectBitfields {
public:
RenderObjectBitfields(Node* node)
: m_needsLayout(false)
, m_needsPositionedMovementLayout(false)
, m_normalChildNeedsLayout(false)
, m_posChildNeedsLayout(false)
, m_needsSimplifiedNormalFlowLayout(false)
, m_preferredLogicalWidthsDirty(false)
, m_floating(false)
, m_positioned(false)
, m_relPositioned(false)
, m_paintBackground(false)
, m_isAnonymous(node == node->document())
, m_isText(false)
, m_isBox(false)
, m_isInline(true)
, m_isReplaced(false)
, m_horizontalWritingMode(true)
, m_isDragging(false)
, m_hasLayer(false)
, m_hasOverflowClip(false)
, m_hasTransform(false)
, m_hasReflection(false)
, m_hasCounterNodeMap(false)
, m_everHadLayout(false)
, m_inRenderFlowThread(false)
, m_childrenInline(false)
, m_marginBeforeQuirk(false)
, m_marginAfterQuirk(false)
, m_hasColumns(false)
, m_selectionState(SelectionNone)
{
}
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(positioned, Positioned);
ADD_BOOLEAN_BITFIELD(relPositioned, RelPositioned);
ADD_BOOLEAN_BITFIELD(paintBackground, PaintBackground);
ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
ADD_BOOLEAN_BITFIELD(isText, IsText);
ADD_BOOLEAN_BITFIELD(isBox, IsBox);
ADD_BOOLEAN_BITFIELD(isInline, IsInline);
ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); ADD_BOOLEAN_BITFIELD(hasTransform, HasTransform);
ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
ADD_BOOLEAN_BITFIELD(inRenderFlowThread, InRenderFlowThread);
ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
ADD_BOOLEAN_BITFIELD(marginBeforeQuirk, MarginBeforeQuirk);
ADD_BOOLEAN_BITFIELD(marginAfterQuirk, MarginAfterQuirk);
ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
private:
unsigned m_selectionState : 3;
public:
ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
};
#undef ADD_BOOLEAN_BITFIELD
RenderObjectBitfields m_bitfields;
void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
void setPaintBackground(bool b) { m_bitfields.setPaintBackground(b); }
void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
private:
static bool s_affectsParentBlock;
};
inline bool RenderObject::documentBeingDestroyed() const
{
return !document()->renderer();
}
inline bool RenderObject::isBeforeContent() const
{
if (style()->styleType() != BEFORE)
return false;
if (isText() && !isBR())
return false;
return true;
}
inline bool RenderObject::isAfterContent() const
{
if (style()->styleType() != AFTER)
return false;
if (isText() && !isBR())
return false;
return true;
}
inline bool RenderObject::isBeforeOrAfterContent() const
{
return isBeforeContent() || isAfterContent();
}
inline void RenderObject::setNeedsLayout(bool needsLayout, MarkingBehavior markParents)
{
bool alreadyNeededLayout = m_bitfields.needsLayout();
m_bitfields.setNeedsLayout(needsLayout);
if (needsLayout) {
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout) {
if (markParents == MarkContainingBlockChain)
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaint();
}
} else {
setEverHadLayout(true);
setPosChildNeedsLayout(false);
setNeedsSimplifiedNormalFlowLayout(false);
setNormalChildNeedsLayout(false);
setNeedsPositionedMovementLayout(false);
setAncestorLineBoxDirty(false);
}
}
inline void RenderObject::setChildNeedsLayout(bool childNeedsLayout, MarkingBehavior markParents)
{
bool alreadyNeededLayout = normalChildNeedsLayout();
setNormalChildNeedsLayout(childNeedsLayout);
if (childNeedsLayout) {
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout && markParents == MarkContainingBlockChain)
markContainingBlocksForLayout();
} else {
setPosChildNeedsLayout(false);
setNeedsSimplifiedNormalFlowLayout(false);
setNormalChildNeedsLayout(false);
setNeedsPositionedMovementLayout(false);
}
}
inline void RenderObject::setNeedsPositionedMovementLayout()
{
bool alreadyNeededLayout = needsPositionedMovementLayout();
setNeedsPositionedMovementLayout(true);
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout) {
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaintForPositionedMovementLayout();
}
}
inline void RenderObject::setNeedsSimplifiedNormalFlowLayout()
{
bool alreadyNeededLayout = needsSimplifiedNormalFlowLayout();
setNeedsSimplifiedNormalFlowLayout(true);
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout) {
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaint();
}
}
inline bool RenderObject::preservesNewline() const
{
#if ENABLE(SVG)
if (isSVGInlineText())
return false;
#endif
return style()->preserveNewline();
}
inline bool RenderObject::layerCreationAllowedForSubtree() const
{
#if ENABLE(SVG)
RenderObject* parentRenderer = parent();
while (parentRenderer) {
if (parentRenderer->isSVGHiddenContainer())
return false;
parentRenderer = parentRenderer->parent();
}
#endif
return true;
}
inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
{
if (selectionState() == state)
return;
setSelectionState(state);
}
inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
{
#if !ENABLE(3D_RENDERING)
UNUSED_PARAM(has3DRendering);
matrix.makeAffine();
#else
if (!has3DRendering)
matrix.makeAffine();
#endif
}
inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
{
return adjustForAbsoluteZoom(value, renderer->style());
}
inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
{
float zoom = renderer->style()->effectiveZoom();
if (zoom != 1)
quad.scale(1 / zoom, 1 / zoom);
}
inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject* renderer)
{
float zoom = renderer->style()->effectiveZoom();
if (zoom != 1)
rect.scale(1 / zoom, 1 / zoom);
}
inline void adjustFloatQuadForPageScale(FloatQuad& quad, float pageScale)
{
if (pageScale != 1)
quad.scale(1 / pageScale, 1 / pageScale);
}
inline void adjustFloatRectForPageScale(FloatRect& rect, float pageScale)
{
if (pageScale != 1)
rect.scale(1 / pageScale, 1 / pageScale);
}
}
#ifndef NDEBUG
void showTree(const WebCore::RenderObject*);
void showLineTree(const WebCore::RenderObject*);
void showRenderTree(const WebCore::RenderObject* object1);
void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderObject* object2);
#endif
#endif // RenderObject_h