#ifndef RenderObject_h
#define RenderObject_h
#include "CachedResourceClient.h"
#include "Document.h"
#include "Element.h"
#include "FloatQuad.h"
#include "RenderObjectChildList.h"
#include "RenderStyle.h"
#include "TextAffinity.h"
#include "TransformationMatrix.h"
#include <wtf/UnusedParam.h>
#include "SelectionRect.h"
namespace WebCore {
class AnimationController;
class HitTestResult;
class InlineBox;
class InlineFlowBox;
class OverlapTestRequestClient;
class Position;
class RenderBoxModelObject;
class RenderInline;
class RenderBlock;
class RenderFlow;
class RenderLayer;
class RenderTheme;
class TransformState;
class VisiblePosition;
#if ENABLE(SVG)
class SVGRenderBase;
#endif
enum PaintPhase {
PaintPhaseBlockBackground,
PaintPhaseChildBlockBackground,
PaintPhaseChildBlockBackgrounds,
PaintPhaseFloat,
PaintPhaseForeground,
PaintPhaseOutline,
PaintPhaseChildOutlines,
PaintPhaseSelfOutline,
PaintPhaseSelection,
PaintPhaseCollapsedTableBorders,
PaintPhaseTextClip,
PaintPhaseMask
};
enum PaintBehaviorFlags {
PaintBehaviorNormal = 0,
PaintBehaviorSelectionOnly = 1 << 0,
PaintBehaviorForceBlackText = 1 << 1,
PaintBehaviorFlattenCompositingLayers = 1 << 2
};
typedef unsigned PaintBehavior;
enum HitTestFilter {
HitTestAll,
HitTestSelf,
HitTestDescendants
};
enum HitTestAction {
HitTestBlockBackground,
HitTestChildBlockBackground,
HitTestChildBlockBackgrounds,
HitTestFloat,
HitTestForeground
};
enum BoxSide {
BSTop,
BSBottom,
BSLeft,
BSRight
};
const int caretWidth = 3;
#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;
IntRect bounds;
IntRect clip;
int type;
};
#endif
class RenderObject : public CachedResourceClient {
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;
}
virtual RenderObjectChildList* virtualChildren() { return 0; }
virtual const RenderObjectChildList* virtualChildren() const { return 0; }
RenderObject* nextInPreOrder() const;
RenderObject* nextInPreOrder(RenderObject* stayWithin) const;
RenderObject* nextInPreOrderAfterChildren() const;
RenderObject* nextInPreOrderAfterChildren(RenderObject* stayWithin) const;
RenderObject* previousInPreOrder() const;
RenderObject* childAt(unsigned) const;
RenderObject* firstLeafChild() const;
RenderObject* lastLeafChild() const;
RenderObject *traverseNext(const RenderObject *stayWithin) const;
typedef bool (*TraverseNextInclusionFunction)(const RenderObject *);
RenderObject *traverseNext(const RenderObject *stayWithin, TraverseNextInclusionFunction inclusionFunction) const;
void adjustComputedFontSizesOnBlocks(float size, float visibleWidth);
void resetTextAutosizing();
RenderLayer* enclosingLayer() const;
RenderLayer* enclosingSelfPaintingLayer() const;
void addLayers(RenderLayer* parentLayer, RenderObject* newObject);
void removeLayers(RenderLayer* parentLayer);
void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
RenderBox* enclosingBox() 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; }
private:
void addAbsoluteRectForLayer(IntRect& result);
void setLayerNeedsFullRepaint();
public:
#ifndef NDEBUG
void showTreeForThis() 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*) throw();
void operator delete(void*, size_t);
private:
void* operator new(size_t) throw();
public:
RenderArena* renderArena() const { return document()->renderArena(); }
virtual bool isApplet() const { return false; }
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 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; }
virtual bool isRenderBlock() const { return false; }
virtual bool isRenderButton() const { return false; }
virtual bool isRenderImage() const { return false; }
virtual bool isRenderInline() const { return false; }
virtual bool isRenderPart() const { return false; }
virtual bool isRenderView() const { return false; }
virtual bool isReplica() const { return false; }
#if ENABLE(RUBY)
virtual bool isRuby() const { return false; }
virtual bool isRubyBase() const { return false; }
virtual bool isRubyRun() const { return false; }
virtual bool isRubyText() const { return false; }
#endif
virtual bool isSlider() const { return false; }
virtual bool isTable() const { return false; }
virtual bool isTableCell() const { return false; }
virtual bool isTableCol() 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; }
bool isRoot() const { return document()->documentElement() == m_node; }
bool isBody() const;
bool isHR() const;
bool isHTMLMarquee() const;
inline bool isAfterContent() const;
static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
bool childrenInline() const { return m_childrenInline; }
void setChildrenInline(bool b = true) { m_childrenInline = b; }
bool hasColumns() const { return m_hasColumns; }
void setHasColumns(bool b = true) { m_hasColumns = b; }
bool cellWidthChanged() const { return m_cellWidthChanged; }
void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; }
#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 isSVGHiddenContainer() const { return false; }
virtual bool isRenderPath() const { return false; }
virtual bool isSVGText() const { return false; }
virtual bool isSVGImage() const { return false; }
virtual bool isSVGForeignObject() const { return false; }
virtual const SVGRenderBase* toSVGRenderBase() const;
virtual FloatRect objectBoundingBox() const;
virtual FloatRect repaintRectInLocalCoordinates() const;
virtual TransformationMatrix localTransform() const;
virtual const TransformationMatrix& localToParentTransform() const;
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
#endif
bool isAnonymous() const { return m_isAnonymous; }
void setIsAnonymous(bool b) { m_isAnonymous = b; }
bool isAnonymousBlock() const
{
return m_isAnonymous && style()->display() == BLOCK && style()->styleType() == NOPSEUDO && !isListMarker();
}
bool isInlineContinuation() const { return (node() ? node()->renderer() != this : false) && isRenderInline(); }
bool isFloating() const { return m_floating; }
bool isPositioned() const { return m_positioned; } bool isRelPositioned() const { return m_relPositioned; } bool isText() const { return m_isText; }
bool isBox() const { return m_isBox; }
bool isInline() const { return m_inline; } bool isRunIn() const { return style()->display() == RUN_IN; } bool isDragging() const { return m_isDragging; }
bool isReplaced() const { return m_replaced; }
bool hasLayer() const { return m_hasLayer; }
bool hasBoxDecorations() const { return m_paintBackground; }
bool mustRepaintBackgroundOrBorder() const;
bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout || m_needsPositionedMovementLayout; }
bool selfNeedsLayout() const { return m_needsLayout; }
bool needsPositionedMovementLayout() const { return m_needsPositionedMovementLayout; }
bool needsPositionedMovementLayoutOnly() const { return m_needsPositionedMovementLayout && !m_needsLayout && !m_normalChildNeedsLayout && !m_posChildNeedsLayout; }
bool posChildNeedsLayout() const { return m_posChildNeedsLayout; }
bool normalChildNeedsLayout() const { return m_normalChildNeedsLayout; }
bool prefWidthsDirty() const { return m_prefWidthsDirty; }
bool isSelectionBorder() const;
bool hasClip() const { return isPositioned() && style()->hasClip(); }
bool hasOverflowClip() const { return m_hasOverflowClip; }
bool hasTransform() const { return m_hasTransform; }
bool hasMask() const { return style() && style()->hasMask(); }
void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
Color, const Color& textcolor, EBorderStyle, int adjbw1, int adjbw2);
void drawArcForBoxSide(GraphicsContext*, int x, int y, float thickness, IntSize radius, int angleStart,
int angleSpan, BoxSide, Color, const Color& textcolor, EBorderStyle, bool firstCorner);
public:
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 m_isAnonymous ? 0 : m_node; }
Document* document() const { return m_node->document(); }
void setNode(Node* node) { m_node = node; }
bool hasOutlineAnnotation() const;
bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
RenderObject* container(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 b, bool markParents = true);
void setChildNeedsLayout(bool b, bool markParents = true);
void setNeedsPositionedMovementLayout();
void setPrefWidthsDirty(bool, bool markParents = true);
void invalidateContainerPrefWidths();
void setNeedsLayoutAndPrefWidthsRecalc()
{
setNeedsLayout(true);
setPrefWidthsDirty(true);
}
void setPositioned(bool b = true) { m_positioned = b; }
void setRelPositioned(bool b = true) { m_relPositioned = b; }
void setFloating(bool b = true) { m_floating = b; }
void setInline(bool b = true) { m_inline = b; }
void setHasBoxDecorations(bool b = true) { m_paintBackground = b; }
void setIsText() { m_isText = true; }
void setIsBox() { m_isBox = true; }
void setReplaced(bool b = true) { m_replaced = b; }
void setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; }
void setHasLayer(bool b = true) { m_hasLayer = b; }
void setHasTransform(bool b = true) { m_hasTransform = b; }
void setHasReflection(bool b = true) { m_hasReflection = b; }
void scheduleRelayout();
void updateFillImages(const FillLayer*, const FillLayer*);
void updateImage(StyleImage*, StyleImage*);
virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
virtual int baselinePosition(bool firstLine, bool isRootLineBox = false) const;
virtual int innerLineHeight() const;
typedef HashMap<OverlapTestRequestClient*, IntRect> OverlapTestRequestMap;
struct PaintInfo {
PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceBlackText,
RenderObject* newPaintingRoot, ListHashSet<RenderInline*>* newOutlineObjects,
OverlapTestRequestMap* overlapTestRequests = 0)
: context(newContext)
, rect(newRect)
, phase(newPhase)
, forceBlackText(newForceBlackText)
, paintingRoot(newPaintingRoot)
, outlineObjects(newOutlineObjects)
, overlapTestRequests(overlapTestRequests)
{
}
GraphicsContext* context;
IntRect rect;
PaintPhase phase;
bool forceBlackText;
RenderObject* paintingRoot; ListHashSet<RenderInline*>* outlineObjects; OverlapTestRequestMap* overlapTestRequests;
};
virtual void paint(PaintInfo&, int tx, int ty);
virtual void layout();
void layoutIfNeeded() { if (needsLayout()) layout(); }
virtual void tryLayoutDoingPositionedMovementOnly() { }
virtual void updateFromElement() { }
#if ENABLE(DASHBOARD_SUPPORT)
virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
void collectDashboardRegions(Vector<DashboardRegionValue>&);
#endif
bool hitTest(const HitTestRequest&, HitTestResult&, const IntPoint&, int tx, int ty, HitTestFilter = HitTestAll);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
VisiblePosition positionForCoordinates(int x, int y);
virtual VisiblePosition positionForPoint(const IntPoint&);
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(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
FloatPoint absoluteToLocal(FloatPoint, bool fixed = false, bool useTransforms = false) const;
FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false) const
{
return localToContainerQuad(quad, 0, fixed);
}
FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false) const;
virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
IntSize offsetFromAncestorContainer(RenderObject*) const;
virtual void collectSelectionRects(Vector<SelectionRect>&, unsigned startOffset = 0, unsigned endOffset = UINT_MAX);
virtual void absoluteRects(Vector<IntRect>&, int, int) { }
IntRect absoluteBoundingBoxRect(bool useTransforms = false);
virtual void absoluteQuads(Vector<FloatQuad>&) { }
void absoluteFocusRingQuads(Vector<FloatQuad>&);
IntRect paintingRootRect(IntRect& topLevelRect);
virtual int minPrefWidth() const { return 0; }
virtual int maxPrefWidth() 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(); }
void getTextDecorationColors(int decorations, Color& underline, Color& overline,
Color& linethrough, bool quirksMode = false);
RenderBoxModelObject* containerForRepaint() const;
void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const IntRect& r, bool immediate = false);
void repaint(bool immediate = false);
void repaintRectangle(const IntRect&, bool immediate = false);
bool repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const IntRect& oldBounds, const IntRect& oldOutlineBox);
virtual void repaintDuringLayoutIfMoved(const IntRect& rect);
virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
bool checkForRepaintDuringLayout() const;
IntRect absoluteClippedOverflowRect()
{
return clippedOverflowRectForRepaint(0);
}
virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
void computeAbsoluteRepaintRect(IntRect& r, bool fixed = false)
{
return computeRectForRepaint(0, r, fixed);
}
virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
virtual void adjustForColumns(IntSize&, const IntPoint&) 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_hasReflection; }
int maximalOutlineSize(PaintPhase) const;
void setHasMarkupTruncation(bool b = true) { m_hasMarkupTruncation = b; }
bool hasMarkupTruncation() const { return m_hasMarkupTruncation; }
enum SelectionState {
SelectionNone, SelectionStart, SelectionInside, SelectionEnd, SelectionBoth };
SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState);; }
virtual void setSelectionState(SelectionState state) { m_selectionState = state; }
IntRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(0, clipToVisibleContent); }
virtual IntRect selectionRectForRepaint(RenderBoxModelObject* , bool = true) { return IntRect(); }
virtual bool canBeSelectionLeaf() const { return false; }
bool hasSelectedChildren() const { return m_selectionState != SelectionNone; }
Color selectionBackgroundColor() const;
Color selectionForegroundColor() const;
virtual bool shouldPaintSelectionGaps() const { return false; }
#if ENABLE(DRAG_SUPPORT)
Node* draggableNode(bool dhtmlOK, bool uaOK, int x, int y, bool& dhtmlWillDrag) const;
#endif
virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
virtual void calcVerticalMargins() { }
bool isTopMarginQuirk() const { return m_topMarginQuirk; }
bool isBottomMarginQuirk() const { return m_bottomMarginQuirk; }
void setTopMarginQuirk(bool b = true) { m_topMarginQuirk = b; }
void setBottomMarginQuirk(bool b = true) { m_bottomMarginQuirk = b; }
bool documentBeingDestroyed() const;
virtual void destroy();
virtual bool isFlexibleBox() const { return false; }
virtual bool isFlexingChildren() const { return false; }
virtual bool isStretchingChildren() const { return false; }
virtual int caretMinOffset() const;
virtual int caretMaxOffset() const;
virtual unsigned caretMaxRenderedOffset() 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;
RenderObject* paintingRootForChildren(PaintInfo& paintInfo) const
{
return (!paintInfo.paintingRoot || paintInfo.paintingRoot == this) ? 0 : paintInfo.paintingRoot;
}
bool shouldPaintWithinRoot(PaintInfo& paintInfo) const
{
return !paintInfo.paintingRoot || paintInfo.paintingRoot == this;
}
bool hasOverrideSize() const { return m_hasOverrideSize; }
void setHasOverrideSize(bool b) { m_hasOverrideSize = b; }
void remove() { if (parent()) parent()->removeChild(this); }
AnimationController* animation() const;
bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
bool shouldUseTransformFromContainer(const RenderObject* container) const;
void getTransformFromContainer(const RenderObject* container, const IntSize& offsetInContainer, TransformationMatrix&) const;
virtual void addFocusRingRects(Vector<IntRect>&, int , int ) { };
IntRect absoluteOutlineBounds() const
{
return outlineBoundsForRepaint(0);
}
protected:
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
void paintOutline(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*);
void addPDFURLRect(GraphicsContext*, const IntRect&);
virtual IntRect viewRect() const;
void adjustRectForOutlineAndShadow(IntRect&) const;
void arenaDelete(RenderArena*, void* objectBase);
virtual IntRect outlineBoundsForRepaint(RenderBoxModelObject* ) const { return IntRect(); }
class LayoutRepainter {
public:
LayoutRepainter(RenderObject& object, bool checkForRepaint, const IntRect* oldBounds = 0)
: m_object(object)
, m_repaintContainer(0)
, m_checkForRepaint(checkForRepaint)
{
if (m_checkForRepaint) {
m_repaintContainer = m_object.containerForRepaint();
m_oldBounds = oldBounds ? *oldBounds : m_object.clippedOverflowRectForRepaint(m_repaintContainer);
m_oldOutlineBox = m_object.outlineBoundsForRepaint(m_repaintContainer);
}
}
bool repaintAfterLayout()
{
return m_checkForRepaint ? m_object.repaintAfterLayoutIfNeeded(m_repaintContainer, m_oldBounds, m_oldOutlineBox) : false;
}
bool checkForRepaint() const { return m_checkForRepaint; }
private:
RenderObject& m_object;
RenderBoxModelObject* m_repaintContainer;
IntRect m_oldBounds;
IntRect m_oldOutlineBox;
bool m_checkForRepaint;
};
private:
RenderStyle* firstLineStyleSlowCase() const;
StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensitiveProperties) const;
RefPtr<RenderStyle> m_style;
Node* m_node;
RenderObject* m_parent;
RenderObject* m_previous;
RenderObject* m_next;
#ifndef NDEBUG
bool m_hasAXObject;
bool m_setNeedsLayoutForbidden : 1;
#endif
bool m_needsLayout : 1;
bool m_needsPositionedMovementLayout :1;
bool m_normalChildNeedsLayout : 1;
bool m_posChildNeedsLayout : 1;
bool m_prefWidthsDirty : 1;
bool m_floating : 1;
bool m_positioned : 1;
bool m_relPositioned : 1;
bool m_paintBackground : 1;
bool m_isAnonymous : 1;
bool m_isText : 1;
bool m_isBox : 1;
bool m_inline : 1;
bool m_replaced : 1;
bool m_isDragging : 1;
bool m_hasLayer : 1;
bool m_hasOverflowClip : 1;
bool m_hasTransform : 1;
bool m_hasReflection : 1;
bool m_hasOverrideSize : 1;
public:
bool m_hasCounterNodeMap : 1;
bool m_everHadLayout : 1;
private:
bool m_childrenInline : 1;
bool m_topMarginQuirk : 1;
bool m_bottomMarginQuirk : 1;
bool m_hasMarkupTruncation : 1;
unsigned m_selectionState : 3; bool m_hasColumns : 1;
bool m_cellWidthChanged : 1;
private:
static bool s_affectsParentBlock;
};
inline bool RenderObject::documentBeingDestroyed() const
{
return !document()->renderer();
}
inline bool RenderObject::isAfterContent() const
{
if (style()->styleType() != AFTER)
return false;
if (isText() && !isBR())
return false;
return true;
}
inline void RenderObject::setNeedsLayout(bool b, bool markParents)
{
bool alreadyNeededLayout = m_needsLayout;
m_needsLayout = b;
if (b) {
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout) {
if (markParents)
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaint();
}
} else {
m_everHadLayout = true;
m_posChildNeedsLayout = false;
m_normalChildNeedsLayout = false;
m_needsPositionedMovementLayout = false;
}
}
inline void RenderObject::setChildNeedsLayout(bool b, bool markParents)
{
bool alreadyNeededLayout = m_normalChildNeedsLayout;
m_normalChildNeedsLayout = b;
if (b) {
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout && markParents)
markContainingBlocksForLayout();
} else {
m_posChildNeedsLayout = false;
m_normalChildNeedsLayout = false;
m_needsPositionedMovementLayout = false;
}
}
inline void RenderObject::setNeedsPositionedMovementLayout()
{
bool alreadyNeededLayout = needsLayout();
m_needsPositionedMovementLayout = true;
if (!alreadyNeededLayout) {
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaint();
}
}
inline bool objectIsRelayoutBoundary(const RenderObject *obj)
{
return obj->isTextControl()
|| (obj->hasOverflowClip() && !obj->style()->width().isIntrinsicOrAuto() && !obj->style()->height().isIntrinsicOrAuto() && !obj->style()->height().isPercent() && !obj->isTableCell())
#if ENABLE(SVG)
|| obj->isSVGRoot()
#endif
;
}
inline void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderObject* newRoot)
{
ASSERT(!scheduleRelayout || !newRoot);
RenderObject* o = container();
RenderObject* last = this;
while (o) {
RenderObject* container = o->container();
if (!container && !o->isRenderView())
return;
if (!last->isText() && (last->style()->position() == FixedPosition || last->style()->position() == AbsolutePosition)) {
if ((last->style()->top().isAuto() && last->style()->bottom().isAuto()) || last->style()->top().isStatic()) {
RenderObject* parent = last->parent();
if (!parent->normalChildNeedsLayout()) {
parent->setChildNeedsLayout(true, false);
if (parent != newRoot)
parent->markContainingBlocksForLayout(scheduleRelayout, newRoot);
}
}
if (o->m_posChildNeedsLayout)
return;
o->m_posChildNeedsLayout = true;
ASSERT(!o->isSetNeedsLayoutForbidden());
} else {
if (o->m_normalChildNeedsLayout)
return;
o->m_normalChildNeedsLayout = true;
ASSERT(!o->isSetNeedsLayoutForbidden());
}
if (o == newRoot)
return;
last = o;
if (scheduleRelayout && objectIsRelayoutBoundary(last))
break;
o = container;
}
if (scheduleRelayout)
last->scheduleRelayout();
}
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)
{
float zoomFactor = renderer->style()->effectiveZoom();
if (zoomFactor == 1)
return value;
if (zoomFactor > 1)
value++;
return static_cast<int>(value / zoomFactor);
}
inline void adjustIntRectForAbsoluteZoom(IntRect& rect, RenderObject* renderer)
{
rect.setX(adjustForAbsoluteZoom(rect.x(), renderer));
rect.setY(adjustForAbsoluteZoom(rect.y(), renderer));
rect.setWidth(adjustForAbsoluteZoom(rect.width(), renderer));
rect.setHeight(adjustForAbsoluteZoom(rect.height(), renderer));
}
inline FloatPoint adjustFloatPointForAbsoluteZoom(const FloatPoint& point, RenderObject* renderer)
{
float zoomFactor = renderer->style()->effectiveZoom();
if (zoomFactor == 1)
return point;
return FloatPoint(point.x() / zoomFactor, point.y() / zoomFactor);
}
inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
{
quad.setP1(adjustFloatPointForAbsoluteZoom(quad.p1(), renderer));
quad.setP2(adjustFloatPointForAbsoluteZoom(quad.p2(), renderer));
quad.setP3(adjustFloatPointForAbsoluteZoom(quad.p3(), renderer));
quad.setP4(adjustFloatPointForAbsoluteZoom(quad.p4(), renderer));
}
}
#ifndef NDEBUG
void showTree(const WebCore::RenderObject*);
void showRenderTree(const WebCore::RenderObject* object1);
void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderObject* object2);
#endif
#endif // RenderObject_h