& regions);
// does a query on the rendertree and finds the innernode
// and overURL for the given position
// if readonly == false, it will recalc hover styles accordingly
class NodeInfo
{
friend class RenderLayer;
friend class RenderImage;
friend class RenderText;
friend class RenderInline;
friend class RenderObject;
friend class RenderFrameSet;
friend class HTMLAreaElement;
public:
NodeInfo(bool readonly, bool active, bool mouseMove = false)
: m_innerNode(0), m_innerNonSharedNode(0), m_innerURLElement(0), m_readonly(readonly), m_active(active), m_mouseMove(mouseMove)
{ }
Node* innerNode() const { return m_innerNode; }
Node* innerNonSharedNode() const { return m_innerNonSharedNode; }
Element* URLElement() const { return m_innerURLElement; }
bool readonly() const { return m_readonly; }
bool active() const { return m_active; }
bool mouseMove() const { return m_mouseMove; }
void setInnerNode(Node* n) { m_innerNode = n; }
void setInnerNonSharedNode(Node* n) { m_innerNonSharedNode = n; }
void setURLElement(Element* n) { m_innerURLElement = n; }
private:
Node* m_innerNode;
Node* m_innerNonSharedNode;
Element* m_innerURLElement;
bool m_readonly;
bool m_active;
bool m_mouseMove;
};
// Used to signal a specific subrect within an object that must be repainted after
// layout is complete.
struct RepaintInfo {
RenderObject* m_object;
IntRect m_repaintRect;
RepaintInfo(RenderObject* o, const IntRect& r) :m_object(o), m_repaintRect(r) {}
};
bool hitTest(NodeInfo& info, int x, int y, int tx, int ty, HitTestFilter hitTestFilter = HitTestAll);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty,
HitTestAction hitTestAction);
void setInnerNode(NodeInfo& info);
virtual VisiblePosition positionForCoordinates(int x, int y);
VisiblePosition positionForPoint(const IntPoint& point) { return positionForCoordinates(point.x(), point.y()); }
virtual void dirtyLinesFromChangedChild(RenderObject* child);
// Set the style of the object and update the state of the object accordingly.
virtual void setStyle(RenderStyle* style);
// Updates only the local style ptr of the object. Does not update the state of the object,
// and so only should be called when the style is known not to have changed (or from setStyle).
void setStyleInternal(RenderStyle* style);
// returns the containing block level element for this element.
RenderBlock *containingBlock() const;
// return just the width of the containing block
virtual int containingBlockWidth() const;
// return just the height of the containing block
virtual int containingBlockHeight() const;
// size of the content area (box size minus padding/border)
virtual int contentWidth() const { return 0; }
virtual int contentHeight() const { return 0; }
// intrinsic extend of replaced elements. undefined otherwise
virtual int intrinsicWidth() const { return 0; }
virtual int intrinsicHeight() const { return 0; }
// used by flexible boxes to impose a flexed width/height override
virtual int overrideSize() const { return 0; }
virtual int overrideWidth() const { return 0; }
virtual int overrideHeight() const { return 0; }
virtual void setOverrideSize(int s) {}
// relative to parent node
virtual void setPos( int /*xPos*/, int /*yPos*/ ) { }
virtual void setWidth( int /*width*/ ) { }
virtual void setHeight( int /*height*/ ) { }
virtual int xPos() const { return 0; }
virtual int yPos() const { return 0; }
// calculate client position of box
virtual bool absolutePosition(int &/*xPos*/, int &/*yPos*/, bool fixed = false);
// This function is used to deal with the extra top space that can occur in table cells (called borderTopExtra).
// The children of the cell do not factor this space in, so we have to add it in. Any code that wants to
// accurately deal with the contents of a cell must call this function instad of absolutePosition.
void absolutePositionForContent(int& xPos, int& yPos, bool fixed = false) {
absolutePosition(xPos, yPos, fixed);
yPos += borderTopExtra();
}
// width and height are without margins but include paddings and borders
virtual int width() const { return 0; }
virtual int height() const { return 0; }
virtual IntRect borderBox() const { return IntRect(0, 0, width(), height()); }
// The height of a block when you include normal flow overflow spillage out of the bottom
// of the block (e.g., a that has a 100px tall image inside
// it would have an overflow height of borderTop() + paddingTop() + 100px.
virtual int overflowHeight(bool includeInterior=true) const { return height(); }
virtual int overflowWidth(bool includeInterior=true) const { return width(); }
virtual void setOverflowHeight(int) {}
virtual void setOverflowWidth(int) {}
virtual int overflowLeft(bool includeInterior=true) const { return 0; }
virtual int overflowTop(bool includeInterior=true) const { return 0; }
virtual IntRect overflowRect(bool includeInterior=true) const { return borderBox(); }
// IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
// to return the remaining width on a given line (and the height of a single line). -dwh
virtual int offsetWidth() const { return width(); }
virtual int offsetHeight() const { return height() + borderTopExtra() + borderBottomExtra(); }
// IE exxtensions. Also supported by Gecko. We override in render flow to get the
// left and top correct. -dwh
virtual int offsetLeft() const;
virtual int offsetTop() const;
virtual RenderObject* offsetParent() const;
// More IE extensions. clientWidth and clientHeight represent the interior of an object
// excluding border and scrollbar. clientLeft/Top are just the borderLeftWidth and borderTopWidth.
int clientLeft() const { return borderLeft(); }
int clientTop() const { return borderTop(); }
int clientWidth() const;
int clientHeight() const;
// scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
// object has overflow:hidden/scroll/auto specified and also has overflow.
// scrollLeft/Top return the current scroll position. These methods are virtual so that objects like
// textareas can scroll shadow content (but pretend that they are the objects that are
// scrolling).
virtual int scrollLeft() const;
virtual int scrollTop() const;
virtual int scrollWidth() const;
virtual int scrollHeight() const;
virtual void setScrollLeft(int);
virtual void setScrollTop(int);
virtual bool scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier=1.0);
// The following seven functions are used to implement collapsing margins.
// All objects know their maximal positive and negative margins. The
// formula for computing a collapsed margin is |maxPosMargin|-|maxNegmargin|.
// For a non-collapsing, e.g., a leaf element, this formula will simply return
// the margin of the element. Blocks override the maxTopMargin and maxBottomMargin
// methods.
virtual bool isSelfCollapsingBlock() const { return false; }
virtual int collapsedMarginTop() const
{ return maxTopMargin(true)-maxTopMargin(false); }
virtual int collapsedMarginBottom() const
{ return maxBottomMargin(true)-maxBottomMargin(false); }
virtual bool isTopMarginQuirk() const { return false; }
virtual bool isBottomMarginQuirk() const { return false; }
virtual int maxTopMargin(bool positive) const {
if (positive)
if (marginTop() > 0)
return marginTop();
else
return 0;
else
if (marginTop() < 0)
return 0 - marginTop();
else
return 0;
}
virtual int maxBottomMargin(bool positive) const {
if (positive)
if (marginBottom() > 0)
return marginBottom();
else
return 0;
else
if (marginBottom() < 0)
return 0 - marginBottom();
else
return 0;
}
virtual int marginTop() const { return 0; }
virtual int marginBottom() const { return 0; }
virtual int marginLeft() const { return 0; }
virtual int marginRight() const { return 0; }
// Virtual since table cells override
virtual int paddingTop() const;
virtual int paddingBottom() const;
virtual int paddingLeft() const;
virtual int paddingRight() const;
virtual int borderTop() const { return style()->borderTopWidth(); }
virtual int borderBottom() const { return style()->borderBottomWidth(); }
virtual int borderTopExtra() const { return 0; }
virtual int borderBottomExtra() const { return 0; }
virtual int borderLeft() const { return style()->borderLeftWidth(); }
virtual int borderRight() const { return style()->borderRightWidth(); }
virtual DeprecatedValueList lineBoxRects();
virtual void absoluteRects(DeprecatedValueList& rects, int tx, int ty);
IntRect absoluteBoundingBoxRect();
// the rect that will be painted if this object is passed as the paintingRoot
IntRect paintingRootRect(IntRect& topLevelRect);
virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
virtual int minWidth() const { return 0; }
virtual int maxWidth() const { return 0; }
RenderStyle* style() const { return m_style; }
RenderStyle* firstLineStyle() const;
RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
void getTextDecorationColors(int decorations, Color& underline, Color& overline,
Color& linethrough, bool quirksMode=false);
enum BorderSide {
BSTop, BSBottom, BSLeft, BSRight
};
void drawBorderArc(GraphicsContext*, int x, int y, float thickness, IntSize radius, int angleStart,
int angleSpan, BorderSide, Color, EBorderStyle, bool firstCorner);
void drawBorder(GraphicsContext*, int x1, int y1, int x2, int y2, BorderSide,
Color, const Color& textcolor, EBorderStyle, int adjbw1, int adjbw2, bool invalidisInvert = false);
virtual void setTable(RenderTable*) {};
// Used by collapsed border tables.
virtual void collectBorders(DeprecatedValueList& borderStyles);
// Repaint the entire object. Called when, e.g., the color of a border changes, or when a border
// style changes.
void repaint(bool immediate = false);
// Repaint a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
void repaintRectangle(const IntRect& r, bool immediate = false);
// Repaint only if our old bounds and new bounds are different.
bool repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const IntRect& oldFullBounds);
// Repaint only if the object moved.
virtual void repaintDuringLayoutIfMoved(int oldX, int oldY);
// Called to repaint a block's floats.
virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
// Called before layout to repaint all dirty children (with selfNeedsLayout() set).
virtual void repaintObjectsBeforeLayout();
bool checkForRepaintDuringLayout() const;
// Returns the rect that should be repainted whenever this object changes. The rect is in the view's
// coordinate space. This method deals with outlines and overflow.
virtual IntRect getAbsoluteRepaintRect();
IntRect getAbsoluteRepaintRectWithOutline(int ow);
virtual void getAbsoluteRepaintRectIncludingFloats(IntRect& bounds, IntRect& boundsWithChildren);
// Given a rect in the object's coordinate space, this method converts the rectangle to the view's
// coordinate space.
virtual void computeAbsoluteRepaintRect(IntRect& r, bool f=false);
virtual unsigned int length() const { return 1; }
bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); };
virtual bool containsFloats() { return false; }
virtual bool containsFloat(RenderObject* o) { return false; }
virtual bool hasOverhangingFloats() { return false; }
virtual IntRect floatRect() const { return borderBox(); }
virtual void removePositionedObjects(RenderBlock*) { }
bool avoidsFloats() const;
bool shrinkToAvoidFloats() const;
// positioning of inline children (bidi)
virtual void position(InlineBox*, int, int, bool, bool) {}
bool isTransparent() const { return style()->opacity() < 1.0f; }
float opacity() const { return style()->opacity(); }
// Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
int maximalOutlineSize(PaintPhase p) const;
enum SelectionState {
SelectionNone, // The object is not selected.
SelectionStart, // The object either contains the start of a selection run or is the start of a run
SelectionInside, // The object is fully encompassed by a selection run
SelectionEnd, // The object either contains the end of a selection run or is the end of a run
SelectionBoth // The object contains an entire run or is the sole selected object in that run
};
// The current selection state for an object. For blocks, the state refers to the state of the leaf
// descendants (as described above in the SelectionState enum declaration).
virtual SelectionState selectionState() const { return SelectionNone; }
// Sets the selection state for an object.
virtual void setSelectionState(SelectionState s) { if (parent()) parent()->setSelectionState(s); }
// A single rectangle that encompasses all of the selected objects within this object. Used to determine the tightest
// possible bounding box for the selection.
virtual IntRect selectionRect() { return IntRect(); }
// Whether or not an object can be part of the leaf elements of the selection.
virtual bool canBeSelectionLeaf() const { return false; }
// Whether or not a block has selected children.
virtual bool hasSelectedChildren() const { return false; }
// Whether or not a selection can be attempted on this object.
bool canSelect() const;
// Whether or not a selection can be attempted on this object. Should only be called right before actually beginning a selection,
// since it fires the selectstart DOM event.
bool shouldSelect() const;
// Obtains the selection colors that should be used when painting a selection.
Color selectionBackgroundColor() const;
Color selectionForegroundColor() const;
// Whether or not a given block needs to paint selection gaps.
virtual bool shouldPaintSelectionGaps() const { return false; }
// This struct is used when the selection changes to cache the old and new state of the selection for each RenderObject.
struct SelectionInfo {
RenderObject* m_object;
IntRect m_rect;
RenderObject::SelectionState m_state;
RenderObject* object() const { return m_object; }
IntRect rect() const { return m_rect; }
SelectionState state() const { return m_state; }
SelectionInfo() { m_object = 0; m_state = SelectionNone; }
SelectionInfo(RenderObject* o) :m_object(o), m_rect(o->selectionRect()), m_state(o->selectionState()) {}
};
Node* draggableNode(bool dhtmlOK, bool uaOK, int x, int y, bool& dhtmlWillDrag) const;
/**
* Returns the content coordinates of the caret within this render object.
* @param offset zero-based offset determining position within the render object.
* @param override @p true if input overrides existing characters,
* @p false if it inserts them. The width of the caret depends on this one.
* @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
* useful for character range rect computations
*/
virtual IntRect caretRect(int offset, EAffinity affinity = UPSTREAM, int *extraWidthToEndOfLine = 0);
virtual int lowestPosition(bool includeOverflowInterior=true, bool includeSelf=true) const { return 0; }
virtual int rightmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const { return 0; }
virtual int leftmostPosition(bool includeOverflowInterior=true, bool includeSelf=true) const { return 0; }
virtual void calcVerticalMargins() {}
void removeFromObjectLists();
// When performing a global document tear-down, the renderer of the document is cleared. We use this
// as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
bool documentBeingDestroyed() const;
virtual void destroy();
const Font& font(bool firstLine) const {
return style(firstLine)->font();
}
// Virtual function helpers for CSS3 Flexible Box Layout
virtual bool isFlexibleBox() const { return false; }
virtual bool isFlexingChildren() const { return false; }
virtual bool isStretchingChildren() const { return false; }
// Convenience, to avoid repeating the code to dig down to get this.
UChar backslashAsCurrencySymbol() const;
virtual int caretMinOffset() const;
virtual int caretMaxOffset() const;
virtual unsigned caretMaxRenderedOffset() const;
virtual int previousOffset (int current) const;
virtual int nextOffset (int current) const;
virtual void imageChanged(CachedImage*);
virtual bool willRenderImage(CachedImage*);
virtual void selectionStartEnd(int& spos, int& epos);
RenderObject* paintingRootForChildren(PaintInfo &i) const {
// if we're the painting root, kids draw normally, and see root of 0
return (!i.paintingRoot || i.paintingRoot == this) ? 0 : i.paintingRoot;
}
bool shouldPaintWithinRoot(PaintInfo &i) const {
return !i.paintingRoot || i.paintingRoot == this;
}
protected:
virtual void printBoxDecorations(GraphicsContext*, int /*x*/, int /*y*/,
int /*w*/, int /*h*/, int /*tx*/, int /*ty*/) {}
virtual IntRect viewRect() const;
void remove() { if (parent()) parent()->removeChild(this); }
void invalidateVerticalPositions();
short getVerticalPosition(bool firstLine) const;
virtual void removeLeftoverAnonymousBoxes();
void arenaDelete(RenderArena*, void* objectBase);
private:
RenderStyle* m_style;
Node* m_node;
RenderObject *m_parent;
RenderObject *m_previous;
RenderObject *m_next;
mutable short m_verticalPosition;
bool m_needsLayout : 1;
bool m_normalChildNeedsLayout : 1;
bool m_posChildNeedsLayout : 1;
bool m_minMaxKnown : 1;
bool m_floating : 1;
bool m_positioned : 1;
bool m_relPositioned : 1;
bool m_paintBackground : 1; // if the box has something to paint in the
// background painting phase (background, border, etc)
bool m_isAnonymous : 1;
bool m_recalcMinMax : 1;
bool m_isText : 1;
bool m_inline : 1;
bool m_replaced : 1;
bool m_isDragging : 1;
bool m_hasOverflowClip : 1;
// note: do not add unnecessary bitflags, we have 32 bit already!
friend class RenderListItem;
friend class RenderContainer;
friend class RenderView;
};
enum VerticalPositionHint {
PositionTop = -0x4000,
PositionBottom = 0x4000,
PositionUndefined = 0x3fff
};
} //namespace
#ifndef NDEBUG
// Outside the WebCore namespace for ease of invocation from gdb.
void showTree(const WebCore::RenderObject*);
#endif
#endif