📄 render_object.h
字号:
bool isPseudoAnonymous() const { return isAnonymous() && !node()->isDocumentNode(); } 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 isInline() const { return m_inline; } bool isCompact() const { return style()->display() == COMPACT; } // compact bool isRunIn() const { return style()->display() == RUN_IN; } // run-in object bool mouseInside() const; bool isReplaced() const { return m_replaced; } bool isReplacedBlock() const { return isInline() && isReplaced() && isRenderBlock(); } bool shouldPaintBackgroundOrBorder() const { return m_paintBackground; } bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout; } bool markedForRepaint() const { return m_markedForRepaint; } void setMarkedForRepaint(bool m) { m_markedForRepaint = m; } bool selfNeedsLayout() const { return m_needsLayout; } bool posChildNeedsLayout() const { return m_posChildNeedsLayout; } bool normalChildNeedsLayout() const { return m_normalChildNeedsLayout; } bool minMaxKnown() const{ return m_minMaxKnown; } bool overhangingContents() const { return m_overhangingContents; } bool hasFirstLine() const { return m_hasFirstLine; } bool isSelectionBorder() const { return m_isSelectionBorder; } bool recalcMinMax() const { return m_recalcMinMax; } RenderCanvas* canvas() const; // don't even think about making this method virtual! DOM::DocumentImpl* document() const; DOM::NodeImpl* element() const { return isAnonymous() ? 0L : m_node; } DOM::NodeImpl* node() const { return m_node; } /** * returns the object containing this one. can be different from parent for * positioned elements */ RenderObject *container() const; void setOverhangingContents(bool p=true); void markContainingBlocksForLayout(); void dirtyFormattingContext( bool checkContainer ); void repaintDuringLayout(); void setNeedsLayout(bool b, bool markParents = true); void setChildNeedsLayout(bool b, bool markParents = true); void setMinMaxKnown(bool b=true) { m_minMaxKnown = b; if ( !b ) { RenderObject *o = this; RenderObject *root = this; while( o ) { // ### && !o->m_recalcMinMax ) { o->m_recalcMinMax = true; root = o; o = o->m_parent; } } } void setNeedsLayoutAndMinMaxRecalc() { setMinMaxKnown(false); setNeedsLayout(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 setMouseInside(bool b=true) { m_mouseInside = b; } void setShouldPaintBackgroundOrBorder(bool b=true) { m_paintBackground = b; } void setRenderText() { m_isText = true; } void setReplaced(bool b=true) { m_replaced = b; } void setIsSelectionBorder(bool b=true) { m_isSelectionBorder = b; } void scheduleRelayout(RenderObject *clippedObj = 0); void updateBackgroundImages(RenderStyle* oldStyle); virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox); virtual short lineHeight( bool firstLine ) const; virtual short verticalPositionHint( bool firstLine ) const; virtual short baselinePosition( bool firstLine ) const; short getVerticalPosition( bool firstLine, RenderObject* ref=0 ) const; /* * Print the object and its children, clipped by (x|y|w|h). * (tx|ty) is the calculated position of the parent */ struct PaintInfo { PaintInfo(QPainter* _p, const QRect& _r, PaintAction _phase) : p(_p), r(_r), phase(_phase) {} QPainter* p; QRect r; PaintAction phase; }; virtual void paint( PaintInfo& i, int tx, int ty); void paintBorder(QPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style, bool begin=true, bool end=true); void paintOutline(QPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style); virtual void paintBoxDecorations(PaintInfo&, int /*_tx*/, int /*_ty*/) {} virtual void paintBackgroundExtended(QPainter* /*p*/, const QColor& /*c*/, const BackgroundLayer */*bgLayer*/, int /*clipy*/, int /*cliph*/, int /*_tx*/, int /*_ty*/, int /*w*/, int /*height*/, int /*bleft*/, int /*bright*/ ) {} /* * This function calculates the minimum & maximum width that the object * can be set to. * * when the Element calls setMinMaxKnown(true), calcMinMaxWidth() will * be no longer called. * * when a element has a fixed size, m_minWidth and m_maxWidth should be * set to the same value. This has the special meaning that m_width, * contains the actual value. * * assumes calcMinMaxWidth has already been called for all children. */ virtual void calcMinMaxWidth() { } /* * Does the min max width recalculations after changes. */ void recalcMinMaxWidths(); /* * Calculates the actual width of the object (only for non inline * objects) */ virtual void calcWidth() {} /* * This function should cause the Element to calculate its * width and height and the layout of its content * * when the Element calls setNeedsLayout(false), layout() is no * longer called during relayouts, as long as there is no * style sheet change. When that occurs, m_needsLayout will be * set to true and the Element receives layout() calls * again. */ virtual void layout() = 0; /* This function performs a layout only if one is needed. */ void layoutIfNeeded() { if (needsLayout()) layout(); } // used for element state updates that can not be fixed with a // repaint and do not need a relayout virtual void updateFromElement() {} // The corresponding closing element has been parsed. ### remove me virtual void close() { } virtual int availableHeight() const { return 0; } // Whether or not the element shrinks to its max width (rather than filling the width // of a containing block). HTML4 buttons, legends, and floating/compact elements do this. bool sizesToMaxWidth() const; /* * NeesPageClear indicates the object crossed a page-break but could not break itself and now * needs to be moved clear by its parent. */ void setNeedsPageClear(bool b = true) { m_needsPageClear = b; } virtual bool needsPageClear() const { return m_needsPageClear; } /* * ContainsPageBreak indicates the object contains a clean page-break. * ### should be removed and replaced with (crossesPageBreak && !needsPageClear) */ void setContainsPageBreak(bool b = true) { m_containsPageBreak = b; } virtual bool containsPageBreak() const { return m_containsPageBreak; } virtual int pageTopAfter(int y) const { if (parent()) return parent()->pageTopAfter(y); else return 0; } virtual int crossesPageBreak(int top, int bottom) const { if (parent()) return parent()->crossesPageBreak(top, bottom); else return 0; } // Checks if a page-break before child is possible at the given page-break level // false means the child should attempt the break self. virtual bool canClear(RenderObject */*child*/, PageBreakLevel level) { if (parent()) return parent()->canClear(this, level); else return false; } void setAfterPageBreak(bool b = true) { m_afterPageBreak = b; }; void setBeforePageBreak(bool b = true) { m_beforePageBreak = b; }; virtual bool afterPageBreak() const { return m_afterPageBreak; } virtual bool beforePageBreak() const { return m_beforePageBreak; } // 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 RenderImage; friend class RenderFlow; friend class RenderInline; friend class RenderText; friend class RenderWidget; friend class RenderObject; friend class RenderFrameSet; friend class RenderLayer; friend class DOM::HTMLAreaElementImpl; public: NodeInfo(bool readonly, bool active) : m_innerNode(0), m_innerNonSharedNode(0), m_innerURLElement(0), m_readonly(readonly), m_active(active) { } DOM::NodeImpl* innerNode() const { return m_innerNode; } DOM::NodeImpl* innerNonSharedNode() const { return m_innerNonSharedNode; } DOM::NodeImpl* URLElement() const { return m_innerURLElement; } bool readonly() const { return m_readonly; } bool active() const { return m_active; } private: void setInnerNode(DOM::NodeImpl* n) { m_innerNode = n; } void setInnerNonSharedNode(DOM::NodeImpl* n) { m_innerNonSharedNode = n; } void setURLElement(DOM::NodeImpl* n) { m_innerURLElement = n; } DOM::NodeImpl* m_innerNode; DOM::NodeImpl* m_innerNonSharedNode; DOM::NodeImpl* m_innerURLElement; bool m_readonly; bool m_active; }; /** contains stateful information for a checkSelectionPoint call */ struct SelPointState { /** last node that was before the current position */ DOM::NodeImpl *m_lastNode; /** offset of last node */ long m_lastOffset; /** true when the last node had the result SelectionAfterInLine */ bool m_afterInLine; SelPointState() : m_lastNode(0), m_lastOffset(0), m_afterInLine(false) {} }; virtual FindSelectionResult checkSelectionPoint( int _x, int _y, int _tx, int _ty, DOM::NodeImpl*&, int & offset, SelPointState & ); virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, HitTestAction, bool inside = false); // set the style of the object. virtual void setStyle(RenderStyle *style); // returns the containing block level element for this element. RenderBlock *containingBlock() const; // return just the width of the containing block virtual short 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 short contentWidth() const { return 0; } virtual int contentHeight() const { return 0; } // intrinsic extend of replaced elements. undefined otherwise virtual short intrinsicWidth() const { return 0; } virtual int intrinsicHeight() const { return 0; } // 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; } /** Leftmost coordinate of this inline element relative to containing
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -