📄 render_object.h
字号:
bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS)
bool shouldPaintBackgroundOrBorder() const { return m_paintBackground; }
bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout; }
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 recalcMinMax() const { return m_recalcMinMax; }
bool isSelectionBorder() const;
bool hasOverflowClip() const { return m_hasOverflowClip; }
bool hasAutoScrollbars() const { return hasOverflowClip() &&
(style()->overflow() == OAUTO || style()->overflow() == OOVERLAY); }
bool scrollsOverflow() const { return hasOverflowClip() &&
(style()->overflow() == OSCROLL || hasAutoScrollbars()); }
bool includeScrollbarSize() const { return hasOverflowClip() &&
(style()->overflow() == OSCROLL || style()->overflow() == OAUTO); }
RenderStyle* getPseudoStyle(RenderStyle::PseudoId pseudo, RenderStyle* parentStyle = 0) const;
void updateDragState(bool dragOn);
RenderCanvas* canvas() const;
// don't even think about making this method virtual!
DOM::NodeImpl* element() const { return m_isAnonymous ? 0 : m_node; }
DOM::DocumentImpl* document() const { return m_node->getDocument(); }
void setNode(DOM::NodeImpl* node) { m_node = 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;
virtual void markAllDescendantsWithFloatsForLayout(RenderObject* floatToRemove = 0);
void markContainingBlocksForLayout();
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 setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; }
void scheduleRelayout();
void updateBackgroundImages(RenderStyle* oldStyle);
virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun=false);
virtual void dirtyLineBoxes(bool fullLayout, bool isRootLineBox=false);
// For inline replaced elements, this function returns the inline box that owns us. Enables
// the replaced RenderObject to quickly determine what line it is contained on and to easily
// iterate over structures on the line.
virtual InlineBox* inlineBoxWrapper() const;
virtual void setInlineBoxWrapper(InlineBox* b);
void deleteLineBoxWrapper();
virtual InlineBox *inlineBox(long offset=0, EAffinity affinity = UPSTREAM);
// for discussion of lineHeight see CSS2 spec
virtual short lineHeight( bool firstLine, bool isRootLineBox=false ) const;
// for the vertical-align property of inline elements
// the difference between this objects baseline position and the lines baseline position.
virtual short verticalPositionHint( bool firstLine ) const;
// the offset of baseline from the top of the object.
virtual short baselinePosition( bool firstLine, bool isRootLineBox=false ) const;
/*
* Paint the object and its children, clipped by (x|y|w|h).
* (tx|ty) is the calculated position of the parent
*/
struct PaintInfo
OOM_MODIFIED
{
PaintInfo(QPainter* _p, const QRect& _r, PaintAction _phase, RenderObject *_paintingRoot)
: p(_p), r(_r), phase(_phase), paintingRoot(_paintingRoot), outlineObjects(0) {}
~PaintInfo() { delete outlineObjects; }
QPainter* p;
QRect r;
PaintAction phase;
RenderObject *paintingRoot; // used to draw just one element and its visual kids
QPtrDict<RenderFlow>* outlineObjects; // used to list which outlines should be painted by a block with inline children
};
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);
// RenderBox implements this.
virtual void paintBoxDecorations(PaintInfo& i, 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() {};
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;
#if APPLE_CHANGES
// Called recursively to update the absolute positions of all widgets.
virtual void updateWidgetPositions();
QValueList<DashboardRegionValue> computeDashboardRegions();
void addDashboardRegions (QValueList<DashboardRegionValue>& regions);
void collectDashboardRegions (QValueList<DashboardRegionValue>& regions);
#endif
// 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
OOM_MODIFIED
{
friend class RenderLayer;
friend class RenderImage;
friend class RenderText;
friend class RenderInline;
friend class RenderObject;
friend class RenderFrameSet;
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;
};
// Used to signal a specific subrect within an object that must be repainted after
// layout is complete.
struct RepaintInfo
OOM_MODIFIED
{
RenderObject* m_object;
QRect m_repaintRect;
RepaintInfo(RenderObject* o, const QRect& 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);
virtual void dirtyLinesFromChangedChild(RenderObject* child, bool adding = true);
// 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);
// width and height are without margins but include paddings and borders
virtual int width() const { return 0; }
virtual int height() const { return 0; }
virtual QRect borderBox() const { return QRect(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 <div style="height:25px"> 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 QRect overflowRect(bool includeInterior=true) const { return borderBox(); }
// IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (render_flow)
// 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(); }
// 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.
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.
int scrollWidth() const;
int scrollHeight() const;
virtual bool scroll(KWQScrollDirection direction, KWQScrollGranularity 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -