📄 svgrendertreeastext.cpp
字号:
if (!svgStyle->clipPath().isEmpty()) ts << " [clip path=\"" << svgStyle->clipPath() << "\"]"; if (!svgStyle->startMarker().isEmpty()) ts << " [start marker=" << svgStyle->startMarker() << "]"; if (!svgStyle->midMarker().isEmpty()) ts << " [middle marker=" << svgStyle->midMarker() << "]"; if (!svgStyle->endMarker().isEmpty()) ts << " [end marker=" << svgStyle->endMarker() << "]"; if (!svgStyle->filter().isEmpty()) ts << " [filter=" << svgStyle->filter() << "]";}static TextStream& operator<<(TextStream& ts, const RenderPath& path){ ts << " " << path.absoluteTransform().mapRect(path.relativeBBox()); writeStyle(ts, path); ts << " [data=\"" << path.path().debugString() << "\"]"; return ts;}static TextStream& operator<<(TextStream& ts, const RenderSVGContainer& container){ ts << " " << container.absoluteTransform().mapRect(container.relativeBBox()); writeStyle(ts, container); return ts;}static TextStream& operator<<(TextStream& ts, const RenderSVGRoot& root){ ts << " " << root.absoluteTransform().mapRect(root.relativeBBox()); writeStyle(ts, root); return ts;}static TextStream& operator<<(TextStream& ts, const RenderSVGText& text){ SVGRootInlineBox* box = static_cast<SVGRootInlineBox*>(text.firstRootBox()); if (!box) return ts; Vector<SVGTextChunk>& chunks = const_cast<Vector<SVGTextChunk>& >(box->svgTextChunks()); ts << " at (" << text.x() << "," << text.y() << ") size " << box->width() << "x" << box->height() << " contains " << chunks.size() << " chunk(s)"; if (text.parent() && (text.parent()->style()->color() != text.style()->color())) ts << " [color=" << text.style()->color().name() << "]"; return ts;}static inline bool containsInlineTextBox(SVGTextChunk& chunk, SVGInlineTextBox* box){ Vector<SVGInlineBoxCharacterRange>::iterator boxIt = chunk.boxes.begin(); Vector<SVGInlineBoxCharacterRange>::iterator boxEnd = chunk.boxes.end(); bool found = false; for (; boxIt != boxEnd; ++boxIt) { SVGInlineBoxCharacterRange& range = *boxIt; if (box == static_cast<SVGInlineTextBox*>(range.box)) { found = true; break; } } return found;}static inline void writeSVGInlineTextBox(TextStream& ts, SVGInlineTextBox* textBox, int indent){ SVGRootInlineBox* rootBox = textBox->svgRootInlineBox(); if (!rootBox) return; Vector<SVGTextChunk>& chunks = const_cast<Vector<SVGTextChunk>& >(rootBox->svgTextChunks()); Vector<SVGTextChunk>::iterator it = chunks.begin(); Vector<SVGTextChunk>::iterator end = chunks.end(); // Write text chunks unsigned int i = 1; for (; it != end; ++it) { SVGTextChunk& cur = *it; // Write inline box character ranges Vector<SVGInlineBoxCharacterRange>::iterator boxIt = cur.boxes.begin(); Vector<SVGInlineBoxCharacterRange>::iterator boxEnd = cur.boxes.end(); if (!containsInlineTextBox(cur, textBox)) { i++; continue; } writeIndent(ts, indent + 1); unsigned int j = 1; ts << "chunk " << i << " "; if (cur.anchor == TA_MIDDLE) { ts << "(middle anchor"; if (cur.isVerticalText) ts << ", vertical"; ts << ") "; } else if (cur.anchor == TA_END) { ts << "(end anchor"; if (cur.isVerticalText) ts << ", vertical"; ts << ") "; } else if (cur.isVerticalText) ts << "(vertical) "; unsigned int totalOffset = 0; for (; boxIt != boxEnd; ++boxIt) { SVGInlineBoxCharacterRange& range = *boxIt; unsigned int offset = range.endOffset - range.startOffset; ASSERT(cur.start + totalOffset <= cur.end); totalOffset += offset; if (textBox != static_cast<SVGInlineTextBox*>(range.box)) { j++; continue; } FloatPoint topLeft = topLeftPositionOfCharacterRange(cur.start + totalOffset - offset, cur.start + totalOffset); ts << "text run " << j << " at (" << topLeft.x() << "," << topLeft.y() << ") "; ts << "startOffset " << range.startOffset << " endOffset " << range.endOffset; if (cur.isVerticalText) ts << " height " << cummulatedHeightOfInlineBoxCharacterRange(range); else ts << " width " << cummulatedWidthOfInlineBoxCharacterRange(range); if (textBox->direction() == RTL || textBox->m_dirOverride) { ts << (textBox->direction() == RTL ? " RTL" : " LTR"); if (textBox->m_dirOverride) ts << " override"; } ts << ": " << quoteAndEscapeNonPrintables(String(textBox->textRenderer()->text()).substring(textBox->start() + range.startOffset, offset)) << "\n"; j++; } i++; }}static inline void writeSVGInlineText(TextStream& ts, const RenderSVGInlineText& text, int indent){ for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) writeSVGInlineTextBox(ts, static_cast<SVGInlineTextBox*>(box), indent);}static String getTagName(SVGStyledElement* elem){ if (elem) return elem->nodeName(); return "";}void write(TextStream& ts, const RenderSVGContainer& container, int indent){ writeIndent(ts, indent); ts << container.renderName(); if (container.node()) { String tagName = getTagName(static_cast<SVGStyledElement*>(container.node())); if (!tagName.isEmpty()) ts << " {" << tagName << "}"; } ts << container << "\n"; for (RenderObject* child = container.firstChild(); child; child = child->nextSibling()) write(ts, *child, indent + 1);}void write(TextStream& ts, const RenderSVGRoot& root, int indent){ writeIndent(ts, indent); ts << root.renderName(); if (root.node()) { String tagName = getTagName(static_cast<SVGStyledElement*>(root.node())); if (!tagName.isEmpty()) ts << " {" << tagName << "}"; } ts << root << "\n"; for (RenderObject* child = root.firstChild(); child; child = child->nextSibling()) write(ts, *child, indent + 1);}void write(TextStream& ts, const RenderSVGText& text, int indent){ writeIndent(ts, indent); ts << text.renderName(); if (text.node()) { String tagName = getTagName(static_cast<SVGStyledElement*>(text.node())); if (!tagName.isEmpty()) ts << " {" << tagName << "}"; } ts << text << "\n"; for (RenderObject* child = text.firstChild(); child; child = child->nextSibling()) write(ts, *child, indent + 1);}void write(TextStream& ts, const RenderSVGInlineText& text, int indent){ writeIndent(ts, indent); ts << text.renderName(); if (text.node()) { String tagName = getTagName(static_cast<SVGStyledElement*>(text.node())); if (!tagName.isEmpty()) ts << " {" << tagName << "}"; } IntRect linesBox = text.linesBoundingBox(); ts << " at (" << text.firstRunX() << "," << text.firstRunY() << ") size " << linesBox.width() << "x" << linesBox.height() << "\n"; writeSVGInlineText(ts, text, indent);}void write(TextStream& ts, const RenderPath& path, int indent){ writeIndent(ts, indent); ts << path.renderName(); if (path.node()) { String tagName = getTagName(static_cast<SVGStyledElement*>(path.node())); if (!tagName.isEmpty()) ts << " {" << tagName << "}"; } ts << path << "\n";}void writeRenderResources(TextStream& ts, Node* parent){ ASSERT(parent); Node* node = parent; do { if (!node->isSVGElement()) continue; SVGElement* svgElement = static_cast<SVGElement*>(node); if (!svgElement->isStyled()) continue; SVGStyledElement* styled = static_cast<SVGStyledElement*>(svgElement); RefPtr<SVGResource> resource(styled->canvasResource()); if (!resource) continue; String elementId = svgElement->getAttribute(HTMLNames::idAttr); if (resource->isPaintServer()) { RefPtr<SVGPaintServer> paintServer = WTF::static_pointer_cast<SVGPaintServer>(resource); ts << "KRenderingPaintServer {id=\"" << elementId << "\" " << *paintServer << "}" << "\n"; } else ts << "KCanvasResource {id=\"" << elementId << "\" " << *resource << "}" << "\n"; } while ((node = node->traverseNextNode(parent)));}} // namespace WebCore#endif // ENABLE(SVG)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -