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

📄 rendertreeastext.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                if (!box.borderBottom())                    ts << " none";                else {                    ts << " (" << box.borderBottom() << "px ";                    printBorderStyle(ts, o.style()->borderBottomStyle());                    Color col = o.style()->borderBottomColor();                    if (!col.isValid())                        col = o.style()->color();                    ts << col.name() << ")";                }            }            if (o.style()->borderLeft() != prevBorder) {                prevBorder = o.style()->borderLeft();                if (!box.borderLeft())                    ts << " none";                else {                    ts << " (" << box.borderLeft() << "px ";                    printBorderStyle(ts, o.style()->borderLeftStyle());                    Color col = o.style()->borderLeftColor();                    if (!col.isValid())                        col = o.style()->color();                    ts << col.name() << ")";                }            }            ts << "]";        }    }    if (o.isTableCell()) {        const RenderTableCell& c = static_cast<const RenderTableCell&>(o);        ts << " [r=" << c.row() << " c=" << c.col() << " rs=" << c.rowSpan() << " cs=" << c.colSpan() << "]";    }    if (o.isListMarker()) {        String text = static_cast<const RenderListMarker&>(o).text();        if (!text.isEmpty()) {            if (text.length() != 1)                text = quoteAndEscapeNonPrintables(text);            else {                switch (text[0]) {                    case bullet:                        text = "bullet";                        break;                    case blackSquare:                        text = "black square";                        break;                    case whiteBullet:                        text = "white bullet";                        break;                    default:                        text = quoteAndEscapeNonPrintables(text);                }            }            ts << ": " << text;        }    }    return ts;}static void writeTextRun(TextStream& ts, const RenderText& o, const InlineTextBox& run){    // FIXME: Table cell adjustment is temporary until results can be updated.    int y = run.m_y;    if (o.containingBlock()->isTableCell())        y -= static_cast<RenderTableCell*>(o.containingBlock())->intrinsicPaddingTop();    ts << "text run at (" << run.m_x << "," << y << ") width " << run.m_width;    if (run.direction() == RTL || run.m_dirOverride) {        ts << (run.direction() == RTL ? " RTL" : " LTR");        if (run.m_dirOverride)            ts << " override";    }    ts << ": "        << quoteAndEscapeNonPrintables(String(o.text()).substring(run.start(), run.len()))        << "\n";}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 = *toRenderText(&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);            RenderView* root = view->frame()->contentRenderer();            if (root) {                view->layout();                RenderLayer* l = root->layer();                if (l)                    writeLayers(ts, l, l, IntRect(l->x(), l->y(), l->width(), l->height()), indent + 1);            }        }    }}static void write(TextStream& ts, RenderLayer& l,                  const IntRect& layerBounds, const IntRect& backgroundClipRect, const IntRect& clipRect, const IntRect& outlineClipRect,                  int layerType = 0, int indent = 0){    writeIndent(ts, indent);    ts << "layer " << layerBounds;    if (!layerBounds.isEmpty()) {        if (!backgroundClipRect.contains(layerBounds))            ts << " backgroundClip " << backgroundClipRect;        if (!clipRect.contains(layerBounds))            ts << " clip " << clipRect;        if (!outlineClipRect.contains(layerBounds))            ts << " outlineClip " << outlineClipRect;    }    if (l.renderer()->hasOverflowClip()) {        if (l.scrollXOffset())            ts << " scrollX " << l.scrollXOffset();        if (l.scrollYOffset())            ts << " scrollY " << l.scrollYOffset();        if (l.renderBox() && l.renderBox()->clientWidth() != l.scrollWidth())            ts << " scrollWidth " << l.scrollWidth();        if (l.renderBox() && l.renderBox()->clientHeight() != l.scrollHeight())            ts << " scrollHeight " << l.scrollHeight();    }    if (layerType == -1)        ts << " layerType: background only";    else if (layerType == 1)        ts << " layerType: foreground only";    ts << "\n";    if (layerType != -1)        write(ts, *l.renderer(), indent + 1);}static void writeLayers(TextStream& ts, const RenderLayer* rootLayer, RenderLayer* l,                        const IntRect& paintDirtyRect, int indent){    // Calculate the clip rects we should use.    IntRect layerBounds, damageRect, clipRectToApply, outlineRect;    l->calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect, true);    // Ensure our lists are up-to-date.    l->updateZOrderLists();    l->updateNormalFlowList();    bool shouldPaint = l->intersectsDamageRect(layerBounds, damageRect, rootLayer);    Vector<RenderLayer*>* negList = l->negZOrderList();    if (shouldPaint && negList && negList->size() > 0)        write(ts, *l, layerBounds, damageRect, clipRectToApply, outlineRect, -1, indent);    if (negList) {        for (unsigned i = 0; i != negList->size(); ++i)            writeLayers(ts, rootLayer, negList->at(i), paintDirtyRect, indent);    }    if (shouldPaint)        write(ts, *l, layerBounds, damageRect, clipRectToApply, outlineRect, negList && negList->size() > 0, indent);    Vector<RenderLayer*>* normalFlowList = l->normalFlowList();    if (normalFlowList) {        for (unsigned i = 0; i != normalFlowList->size(); ++i)            writeLayers(ts, rootLayer, normalFlowList->at(i), paintDirtyRect, indent);    }    Vector<RenderLayer*>* posList = l->posZOrderList();    if (posList) {        for (unsigned i = 0; i != posList->size(); ++i)            writeLayers(ts, rootLayer, posList->at(i), paintDirtyRect, indent);    }}static String nodePosition(Node* node){    String result;    Node* parent;    for (Node* n = node; n; n = parent) {        parent = n->parentNode();        if (!parent)            parent = n->shadowParentNode();        if (n != node)            result += " of ";        if (parent)            result += "child " + String::number(n->nodeIndex()) + " {" + getTagName(n) + "}";        else            result += "document";    }    return result;}static void writeSelection(TextStream& ts, const RenderObject* o){    Node* n = o->node();    if (!n || !n->isDocumentNode())        return;    Document* doc = static_cast<Document*>(n);    Frame* frame = doc->frame();    if (!frame)        return;    VisibleSelection selection = frame->selection()->selection();    if (selection.isCaret()) {        ts << "caret: position " << selection.start().offset() << " of " << nodePosition(selection.start().node());        if (selection.affinity() == UPSTREAM)            ts << " (upstream affinity)";        ts << "\n";    } else if (selection.isRange())        ts << "selection start: position " << selection.start().offset() << " of " << nodePosition(selection.start().node()) << "\n"           << "selection end:   position " << selection.end().offset() << " of " << nodePosition(selection.end().node()) << "\n";}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();    if (o->hasLayer()) {        RenderLayer* l = toRenderBox(o)->layer();        writeLayers(ts, l, l, IntRect(l->x(), l->y(), l->width(), l->height()));        writeSelection(ts, o);    }    return ts.release();}} // namespace WebCore

⌨️ 快捷键说明

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