Exemple #1
0
int RenderCanvas::docWidth() const
{
    if (m_cachedDocWidth != -1)
        return m_cachedDocWidth;

    int w;
    if (m_pagedMode || !m_view)
        w = m_width;
    else
        w = 0;

    RenderObject *fc = firstChild();
    if(fc) {
        // ow: like effectiveWidth() but without the negative
        const int ow = fc->hasOverflowClip() ? fc->width() : fc->overflowWidth();
        int dw = ow + fc->marginLeft() + fc->marginRight();
        int rightmostPos = fc->rightmostPosition(false);
// kdDebug(6040) << "w " << w << " rightmostPos " << rightmostPos << " dw " << dw << " fc->rw " << fc->effectiveWidth() << " fc->width() " << fc->width() << endl;
        if( rightmostPos > dw )
            dw = rightmostPos;
        rightmostPos = rightmostAbsolutePosition();
        if ( rightmostPos > dw )
            dw = rightmostPos;
        if( dw > w )
            w = dw;
    }

    RenderLayer *layer = m_layer;
    w = kMax( w, layer->xPos() + layer->width() );
// kdDebug(6040) << "w " << w << " layer(" << layer->renderer()->renderName() << ")->width " << layer->width() << " rm " << (layer->xPos() + layer->width()) << " width() " << layer->renderer()->width() << " rw " << layer->renderer()->effectiveWidth() << endl;
    return w;
}
static void write(QTextStream &ts, const RenderObject &o, int indent = 0)
{
    writeIndent(ts, indent);
    
    ts << o << "\n";
    
    if (o.isText() && !o.isBR()) {
        const RenderText &text = static_cast<const RenderText &>(o);
        for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
            writeIndent(ts, indent+1);
            writeTextRun(ts, text, *box);
        }
    }

    for (RenderObject *child = o.firstChild(); child; child = child->nextSibling()) {
        if (child->layer()) {
            continue;
        }
        write(ts, *child, indent + 1);
    }
    
    if (o.isWidget()) {
        QWidget *widget = static_cast<const RenderWidget &>(o).widget();
        if (widget && widget->inherits("KHTMLView")) {
            KHTMLView *view = static_cast<KHTMLView *>(widget);
            RenderObject *root = KWQ(view->part())->renderer();
            if (root) {
                view->layout();
                RenderLayer* l = root->layer();
                if (l)
                    writeLayers(ts, l, l, QRect(l->xPos(), l->yPos(), l->width(), l->height()), indent+1);
            }
        }
    }
}
Exemple #3
0
void MouseEventImpl::computeLayerPos()
{
    m_layerX = m_pageX;
    m_layerY = m_pageY;

    DocumentImpl *doc = view() ? view()->document() : 0;
    if(doc)
    {
        khtml::RenderObject::NodeInfo renderInfo(true, false);
        doc->renderer()->layer()->nodeAtPoint(renderInfo, m_pageX, m_pageY);

        NodeImpl *node = renderInfo.innerNonSharedNode();
        while(node && !node->renderer())
            node = node->parent();

        if(node)
        {
            node->renderer()->enclosingLayer()->updateLayerPosition();
            for(RenderLayer *layer = node->renderer()->enclosingLayer(); layer; layer = layer->parent())
            {
                m_layerX -= layer->xPos();
                m_layerY -= layer->yPos();
            }
        }
    }
}
void write(TextStream& ts, const RenderObject& o, int indent)
{
#if ENABLE(SVG)
    if (o.isRenderPath()) {
        write(ts, static_cast<const RenderPath&>(o), indent);
        return;
    }
    if (o.isSVGContainer()) {
        write(ts, static_cast<const RenderSVGContainer&>(o), indent);
        return;
    }
    if (o.isSVGRoot()) {
        write(ts, static_cast<const RenderSVGRoot&>(o), indent);
        return;
    }
    if (o.isSVGText()) {
        if (!o.isText())
            write(ts, static_cast<const RenderSVGText&>(o), indent);
        else
            write(ts, static_cast<const RenderSVGInlineText&>(o), indent);
        return;
    }
#endif

    writeIndent(ts, indent);

    ts << o << "\n";

    if (o.isText() && !o.isBR()) {
        const RenderText& text = static_cast<const RenderText&>(o);
        for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
            writeIndent(ts, indent + 1);
            writeTextRun(ts, text, *box);
        }
    }

    for (RenderObject* child = o.firstChild(); child; child = child->nextSibling()) {
        if (child->hasLayer())
            continue;
        write(ts, *child, indent + 1);
    }

    if (o.isWidget()) {
        Widget* widget = static_cast<const RenderWidget&>(o).widget();
        if (widget && widget->isFrameView()) {
            FrameView* view = static_cast<FrameView*>(widget);
            RenderObject* root = view->frame()->contentRenderer();
            if (root) {
                view->layout();
                RenderLayer* l = root->layer();
                if (l)
                    writeLayers(ts, l, l, IntRect(l->xPos(), l->yPos(), l->width(), l->height()), indent + 1);
            }
        }
    }
}
String externalRepresentation(RenderObject* o)
{
    if (!o)
        return String();

    TextStream ts;
#if ENABLE(SVG)
    writeRenderResources(ts, o->document());
#endif
    if (o->view()->frameView())
        o->view()->frameView()->layout();
    RenderLayer* l = o->layer();
    if (l) {
        writeLayers(ts, l, l, IntRect(l->xPos(), l->yPos(), l->width(), l->height()));
        writeSelection(ts, o);
    }
    return ts.release();
}
QString externalRepresentation(RenderObject *o)
{
    debuggingRenderTreeFlag = true;
    JSEditor::setSupportsPasteCommand(true);

    QString s;
    {
        QTextStream ts(&s);
        if (o) {
            // FIXME: Hiding the vertical scrollbar is a total hack to preserve the
            // layout test results until I can figure out what the heck is going on. -dwh
            o->canvas()->view()->setVScrollBarMode(QScrollView::AlwaysOff);
            o->canvas()->view()->layout();
            RenderLayer* l = o->layer();
            if (l) {
                writeLayers(ts, l, l, QRect(l->xPos(), l->yPos(), l->width(), l->height()));
                writeSelection(ts, o);
            }
        }
    }
    return s;
}