⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 render_object.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    if (isInline()) { ts << " inline"; }    if (isReplaced()) { ts << " replaced"; }    if (shouldPaintBackgroundOrBorder()) { ts << " paintBackground"; }    if (needsLayout()) { ts << " needsLayout"; }    if (minMaxKnown()) { ts << " minMaxKnown"; }    if (overhangingContents()) { ts << " overhangingContents"; }    if (hasFirstLine()) { ts << " hasFirstLine"; }    if (afterPageBreak()) { ts << " afterPageBreak"; }}#endifvoid RenderObject::selectionStartEnd(int& spos, int& epos){    if (parent())        parent()->selectionStartEnd(spos, epos);}void RenderObject::setStyle(RenderStyle *style){    if (m_style == style)        return;    RenderStyle::Diff d = m_style ? m_style->diff( style ) : RenderStyle::Layout;    //qDebug("m_style: %p new style, diff=%d", m_style,  d);    if ( d == RenderStyle::Visible && m_parent && m_style &&         m_style->outlineWidth() > style->outlineWidth() )        repaint();    if ( m_style &&         ( ( isFloating() && m_style->floating() != style->floating() ) ||           ( isPositioned() && m_style->position() != style->position() &&             style->position() != ABSOLUTE && style->position() != FIXED ) ) )        removeFromObjectLists();    // reset style flags    m_floating = false;    m_positioned = false;    m_relPositioned = false;    m_paintBackground = false;    if ( style->position() == STATIC ) {        if ( isRoot() )            style->setZIndex( 0 );        else            style->setHasAutoZIndex();    }    if ( layer() && style && m_style ) {        if ( ( m_style->hasAutoZIndex() != style->hasAutoZIndex() ||               m_style->zIndex() != style->zIndex() ||               m_style->visibility() != style->visibility() ) ) {            layer()->stackingContext()->dirtyZOrderLists();            layer()->dirtyZOrderLists();        }    }    RenderStyle *oldStyle = m_style;    m_style = style;    updateBackgroundImages(oldStyle);    if (m_style)        m_style->ref();    if (oldStyle)        oldStyle->deref();    setShouldPaintBackgroundOrBorder(m_style->hasBorder() || m_style->hasBackground());    m_hasFirstLine = (style->getPseudoStyle(RenderStyle::FIRST_LINE) != 0);    if (m_parent) {        if ( d >= RenderStyle::Position ) {            if (!isText() && d == RenderStyle::CbLayout) {                dirtyFormattingContext( true );            }            setNeedsLayoutAndMinMaxRecalc();        } else if (!isText() && d == RenderStyle::Visible) {            if (layer() && !isInlineFlow())                layer()->repaint();            else                repaint();        }    }}void RenderObject::dirtyFormattingContext( bool checkContainer ){    if (m_markedForRepaint && !checkContainer)        return;    m_markedForRepaint = true;    if (layer() && (style()->position() == FIXED || style()->position() == ABSOLUTE))        return;    if (m_parent && (checkContainer || style()->width().isVariable() || style()->height().isVariable() ||                     !(isFloating() || flowAroundFloats() || isTableCell())))        m_parent->dirtyFormattingContext(false);}void RenderObject::repaintDuringLayout(){    if (canvas()->needsFullRepaint() || isText())        return;    if (layer() && !isInlineFlow()) {        layer()->repaint( true );    } else {       repaint();       canvas()->deferredRepaint( this );    }}void RenderObject::setOverhangingContents(bool p){    if (m_overhangingContents == p)        return;    RenderBlock *cb = containingBlock();    if (p)    {        m_overhangingContents = true;        KHTMLAssert( cb != this || isCanvas());        if (cb && cb != this)            cb->setOverhangingContents();    }    else    {        RenderObject *n;        bool c=false;        for( n = firstChild(); n != 0; n = n->nextSibling() )        {            if (n->isPositioned() || n->overhangingContents())                c=true;        }        if (c)            return;        else        {            m_overhangingContents = false;            KHTMLAssert( cb != this );            if (cb && cb != this)                cb->setOverhangingContents(false);        }    }}void RenderObject::updateBackgroundImages(RenderStyle* oldStyle){    // FIXME: This will be slow when a large number of images is used.  Fix by using a dict.    const BackgroundLayer* oldLayers = oldStyle ? oldStyle->backgroundLayers() : 0;    const BackgroundLayer* newLayers = m_style ? m_style->backgroundLayers() : 0;    for (const BackgroundLayer* currOld = oldLayers; currOld; currOld = currOld->next()) {        if (currOld->backgroundImage() && (!newLayers || !newLayers->containsImage(currOld->backgroundImage())))            currOld->backgroundImage()->deref(this);    }    for (const BackgroundLayer* currNew = newLayers; currNew; currNew = currNew->next()) {        if (currNew->backgroundImage() && (!oldLayers || !oldLayers->containsImage(currNew->backgroundImage())))            currNew->backgroundImage()->ref(this);    }}QRect RenderObject::viewRect() const{    return containingBlock()->viewRect();}bool RenderObject::absolutePosition(int &xPos, int &yPos, bool f){    RenderObject* p = parent();    if(p) {        parent()->absolutePosition(xPos, yPos, f);        if ( p->style()->hidesOverflow() && p->layer() )            p->layer()->subtractScrollOffset( xPos, yPos );        return true;    }    else    {        xPos = yPos = 0;        return false;    }}void RenderObject::caretPos(int /*offset*/, int /*flags*/, int &_x, int &_y, int &width, int &height){    _x = _y = height = -1;    width = 1;        // the caret has a default width of one pixel. If you want                    // to check for validity, only test the x-coordinate for >= 0.}int RenderObject::paddingTop() const{    int w = 0;    Length padding = m_style->paddingTop();    if (padding.isPercent())        w = containingBlock()->contentWidth();    w = padding.minWidth(w);    if ( isTableCell() && padding.isVariable() )        w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();    return w;}int RenderObject::paddingBottom() const{    int w = 0;    Length padding = style()->paddingBottom();    if (padding.isPercent())        w = containingBlock()->contentWidth();    w = padding.minWidth(w);    if ( isTableCell() && padding.isVariable() )        w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();    return w;}int RenderObject::paddingLeft() const{    int w = 0;    Length padding = style()->paddingLeft();    if (padding.isPercent())        w = containingBlock()->contentWidth();    w = padding.minWidth(w);    if ( isTableCell() && padding.isVariable() )        w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();    return w;}int RenderObject::paddingRight() const{    int w = 0;    Length padding = style()->paddingRight();    if (padding.isPercent())        w = containingBlock()->contentWidth();    w = padding.minWidth(w);    if ( isTableCell() && padding.isVariable() )        w = static_cast<const RenderTableCell *>(this)->table()->cellPadding();    return w;}RenderObject *RenderObject::container() const{    // This method is extremely similar to containingBlock(), but with a few notable    // exceptions.    // (1) It can be used on orphaned subtrees, i.e., it can be called safely even when    // the object is not part of the primary document subtree yet.    // (2) For normal flow elements, it just returns the parent.    // (3) For absolute positioned elements, it will return a relative positioned inline.    // containingBlock() simply skips relpositioned inlines and lets an enclosing block handle    // the layout of the positioned object.  This does mean that calcAbsoluteHorizontal and    // calcAbsoluteVertical have to use container().    EPosition pos = m_style->position();    RenderObject *o = 0;    if( pos == FIXED ) {        // container() can be called on an object that is not in the        // tree yet.  We don't call canvas() since it will assert if it        // can't get back to the canvas.  Instead we just walk as high up        // as we can.  If we're in the tree, we'll get the root.  If we        // aren't we'll get the root of our little subtree (most likely        // we'll just return 0).        o = parent();        while ( o && o->parent() ) o = o->parent();    }    else if ( pos == ABSOLUTE ) {        // Same goes here.  We technically just want our containing block, but        // we may not have one if we're part of an uninstalled subtree.  We'll        // climb as high as we can though.        o = parent();        while (o && o->style()->position() == STATIC && !o->isCanvas())            o = o->parent();    }    else        o = parent();    return o;}DOM::DocumentImpl* RenderObject::document() const{    return m_node->getDocument();}void RenderObject::remove(){    removeFromObjectLists();    if ( parent() )        //have parent, take care of the tree integrity        parent()->removeChild(this);}void RenderObject::removeFromObjectLists(){    // in destruction mode, don't care.    if ( !document()->renderer() ) return;    if (isFloating()) {        RenderBlock* outermostBlock = containingBlock();        for (RenderBlock* p = outermostBlock; p && !p->isCanvas() && p->containsFloat(this);) {            outermostBlock = p;            if (p->isFloatingOrPositioned())                break;            p = p->containingBlock();        }        if (outermostBlock)            outermostBlock->markAllDescendantsWithFloatsForLayout(this);    }    if (isPositioned()) {        RenderObject *p;        for (p = parent(); p; p = p->parent()) {            if (p->isRenderBlock())                static_cast<RenderBlock*>(p)->removePositionedObject(this);        }    }}RenderArena* RenderObject::renderArena() const{    return m_node->getDocument()->renderArena();}void RenderObject::detach(){    detachCounters();    deleteInlineBoxes();    remove();    // by default no refcounting    arenaDelete(renderArena(), this);}void RenderObject::arenaDelete(RenderArena *arena, void *base){#ifndef NDEBUG    void *savedBase = baseOfRenderObjectBeingDeleted;    baseOfRenderObjectBeingDeleted = base;#endif    delete this;#ifndef NDEBUG    baseOfRenderObjectBeingDeleted = savedBase;#endif    // Recover the size left there for us by operator delete and free the memory.    arena->free(*(size_t *)base, base);}void RenderObject::arenaDelete(RenderArena *arena){    // static_cast unfortunately doesn't work, since we multiple inherit    // in eg. RenderWidget.    arenaDelete(arena, dynamic_cast<void *>(this));}FindSelectionResult RenderObject::checkSelectionPoint( int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int & offset, SelPointState &state ){#if 0    NodeInfo info(true, false);    if ( nodeAtPoint( info, _x, _y, _tx, _ty ) && info.innerNode() )    {        RenderObject* r = info.innerNode()->renderer();        if ( r ) {            if ( r == this ) {                node = info.innerNode();                offset = 0; // we have no text...                return SelectionPointInside;            }            else                return r->checkSelectionPoint( _x, _y, _tx, _ty, node, offset, state );        }    }    //kdDebug(6030) << "nodeAtPoint Failed. Fallback - hmm, SelectionPointAfter" << endl;    node = 0;    offset = 0;    return SelectionPointAfter;#endif    int off = offset;    DOM::NodeImpl* nod = node;    for (RenderObject *child = firstChild(); child; child=child->nextSibling()) {        // ignore empty text boxes, they produce totally bogus information        // for caret navigation (LS)        if (child->isText() && !static_cast<RenderText *>(child)->inlineTextBoxCount())            continue;//        kdDebug(6040) << "iterating " << (child ? child->renderName() : "") << "@" << child << (child->isText() ? " contains: \"" + QConstString(static_cast<RenderText *>(child)->text(), kMin(static_cast<RenderText *>(child)->length(), 10u)).string() + "\"" : QString::null) << endl;//        kdDebug(6040) << "---------- checkSelectionPoint recursive -----------" << endl;        khtml::FindSelectionResult pos = child->checkSelectionPoint(_x, _y, _tx+xPos(), _ty+yPos(), nod, off, state);//        kdDebug(6040) << "-------- end checkSelectionPoint recursive ---------" << endl;//        kdDebug(6030) << this << " child->findSelectionNode returned result=" << pos << " nod=" << nod << " off=" << off << endl;        switch(pos) {        case SelectionPointBeforeInLine:        case SelectionPointInside:            //kdDebug(6030) << "RenderObject::checkSelectionPoint " << this << " returning SelectionPointInside offset=" << offset << endl;            node = nod;            offset = off;            return SelectionPointInside;        case SelectionPointBefore:            //x,y is before this element -> stop here

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -