📄 render_object.h
字号:
// 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 borderLeft() const { return style()->borderLeftWidth(); }
virtual int borderRight() const { return style()->borderRightWidth(); }
virtual void absoluteRects(QValueList<QRect>& rects, int _tx, int _ty);
QRect absoluteBoundingBoxRect();
// the rect that will be painted if this object is passed as the paintingRoot
QRect paintingRootRect(QRect& topLevelRect);
#if APPLE_CHANGES
virtual void addFocusRingRects(QPainter *painter, int _tx, int _ty);
#endif
virtual int minWidth() const { return 0; }
virtual int maxWidth() const { return 0; }
RenderStyle* style() const { return m_style; }
RenderStyle* style( bool firstLine ) const;
void getTextDecorationColors(int decorations, QColor& underline, QColor& overline,
QColor& linethrough, bool quirksMode=false);
enum BorderSide {
BSTop, BSBottom, BSLeft, BSRight
};
void drawBorder(QPainter *p, int x1, int y1, int x2, int y2, BorderSide s,
QColor c, const QColor& textcolor, EBorderStyle style,
int adjbw1, int adjbw2, bool invalidisInvert = false);
virtual void setTable(RenderTable*) {};
// Used by collapsed border tables.
virtual void collectBorders(QValueList<CollapsedBorderValue>& 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 QRect& r, bool immediate = false);
// Repaint only if our old bounds and new bounds are different.
bool repaintAfterLayoutIfNeeded(const QRect& oldBounds, const QRect& oldFullBounds);
// Repaint only if the object moved.
virtual void repaintDuringLayoutIfMoved(int oldX, int oldY);
// Called to repaint a block's floats.
virtual void repaintFloatingDescendants();
// 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 QRect getAbsoluteRepaintRect();
QRect getAbsoluteRepaintRectWithOutline(int ow);
virtual void getAbsoluteRepaintRectIncludingFloats(QRect& bounds, QRect& boundsWithChildren);
// Given a rect in the object's coordinate space, this method converts the rectangle to the view's
// coordinate space.
virtual void computeAbsoluteRepaintRect(QRect& 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 QRect floatRect() const { return borderBox(); }
bool avoidsFloats() const;
bool usesLineWidth() const;
// positioning of inline children (bidi)
virtual void position(InlineBox*, int, int, bool) {}
// Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
int maximalOutlineSize(PaintAction 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 QRect selectionRect() { return QRect(); }
// 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 background color that should be used when painting a selection.
virtual QColor selectionColor(QPainter *p) 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
OOM_MODIFIED
{
RenderObject* m_object;
QRect m_rect;
RenderObject::SelectionState m_state;
RenderObject* object() const { return m_object; }
QRect 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()) {}
};
DOM::NodeImpl* 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 QRect 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 { return !document()->renderer(); }
virtual void detach();
const QFont &font(bool firstLine) const {
return style( firstLine )->font();
}
const QFontMetrics &fontMetrics(bool firstLine) const {
return style( firstLine )->fontMetrics();
}
// 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.
QChar backslashAsCurrencySymbol() const;
virtual long caretMinOffset() const;
virtual long caretMaxOffset() const;
virtual unsigned long caretMaxRenderedOffset() const;
virtual long previousOffset (long current) const;
virtual long nextOffset (long current) const;
virtual void setPixmap(const QPixmap&, const QRect&, 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(QPainter* /*p*/, int /*_x*/, int /*_y*/,
int /*_w*/, int /*_h*/, int /*_tx*/, int /*_ty*/) {}
virtual QRect viewRect() const;
void remove();
void invalidateVerticalPositions();
short getVerticalPosition( bool firstLine ) const;
virtual void removeLeftoverAnonymousBoxes();
void arenaDelete(RenderArena *arena, void *objectBase);
private:
RenderStyle* m_style;
DOM::NodeImpl* 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_mouseInside : 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 RenderCanvas;
};
enum VerticalPositionHint {
PositionTop = -0x4000,
PositionBottom = 0x4000,
PositionUndefined = 0x3fff
};
}; //namespace
#ifdef __WINSCW__
#pragma enumsalwaysint reset
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -