Commit 4d79549e authored by eric@webkit.org's avatar eric@webkit.org

Reviewed by Simon Fraser.

        SVGRenderTreeAsText cleanup/code sharing.

        No test changes, only code cleanup.

        * rendering/RenderText.cpp:
        (WebCore::RenderText::firstRunOrigin):
        * rendering/RenderText.h:
        * rendering/SVGRenderTreeAsText.cpp:
        (WebCore::writeStandardPrefix):
        (WebCore::writeChildren):
        (WebCore::write):
        (WebCore::writeRenderResources):

git-svn-id: svn://svn.chromium.org/blink/trunk@42803 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3b64f2a3
2009-04-23 Eric Seidel <eric@webkit.org>
Reviewed by Simon Fraser.
SVGRenderTreeAsText cleanup/code sharing.
No test changes, only code cleanup.
* rendering/RenderText.cpp:
(WebCore::RenderText::firstRunOrigin):
* rendering/RenderText.h:
* rendering/SVGRenderTreeAsText.cpp:
(WebCore::writeStandardPrefix):
(WebCore::writeChildren):
(WebCore::write):
(WebCore::writeRenderResources):
2009-04-23 Beth Dakin <bdakin@apple.com>
Reviewed by Darin Adler.
......@@ -763,6 +763,11 @@ bool RenderText::containsOnlyWhitespace(unsigned from, unsigned len) const
return currPos >= (from + len);
}
IntPoint RenderText::firstRunOrigin() const
{
return IntPoint(firstRunX(), firstRunY());
}
int RenderText::firstRunX() const
{
return m_firstTextBox ? m_firstTextBox->m_x : 0;
......
......@@ -84,6 +84,7 @@ public:
IntRect linesBoundingBox() const;
IntPoint firstRunOrigin() const;
int firstRunX() const;
int firstRunY() const;
......
......@@ -448,92 +448,54 @@ static inline void writeSVGInlineText(TextStream& ts, const RenderSVGInlineText&
writeSVGInlineTextBox(ts, static_cast<SVGInlineTextBox*>(box), indent);
}
static String getTagName(SVGStyledElement* elem)
static void writeStandardPrefix(TextStream& ts, const RenderObject& object, int indent)
{
if (elem)
return elem->nodeName();
return "";
writeIndent(ts, indent);
ts << object.renderName();
if (object.node())
ts << " {" << object.node()->nodeName() << "}";
}
void write(TextStream& ts, const RenderSVGContainer& container, int indent)
static void writeChildren(TextStream& ts, const RenderObject& object, int indent)
{
writeIndent(ts, indent);
ts << container.renderName();
if (container.node()) {
String tagName = getTagName(static_cast<SVGStyledElement*>(container.node()));
if (!tagName.isEmpty())
ts << " {" << tagName << "}";
}
for (RenderObject* child = object.firstChild(); child; child = child->nextSibling())
write(ts, *child, indent + 1);
}
void write(TextStream& ts, const RenderSVGContainer& container, int indent)
{
writeStandardPrefix(ts, container, indent);
ts << container << "\n";
for (RenderObject* child = container.firstChild(); child; child = child->nextSibling())
write(ts, *child, indent + 1);
writeChildren(ts, container, indent);
}
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 << "}";
}
writeStandardPrefix(ts, root, indent);
ts << root << "\n";
for (RenderObject* child = root.firstChild(); child; child = child->nextSibling())
write(ts, *child, indent + 1);
writeChildren(ts, root, indent);
}
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 << "}";
}
writeStandardPrefix(ts, text, indent);
ts << text << "\n";
for (RenderObject* child = text.firstChild(); child; child = child->nextSibling())
write(ts, *child, indent + 1);
writeChildren(ts, text, indent);
}
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();
writeStandardPrefix(ts, text, indent);
ts << " at (" << text.firstRunX() << "," << text.firstRunY() << ") size " << linesBox.width() << "x" << linesBox.height() << "\n";
// Why not just linesBoundingBox()?
ts << " " << FloatRect(text.firstRunOrigin(), text.linesBoundingBox().size()) << "\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 << "}";
}
writeStandardPrefix(ts, path, indent);
ts << path << "\n";
}
......@@ -554,6 +516,7 @@ void writeRenderResources(TextStream& ts, Node* parent)
continue;
String elementId = svgElement->getAttribute(HTMLNames::idAttr);
// FIXME: These names are lies!
if (resource->isPaintServer()) {
RefPtr<SVGPaintServer> paintServer = WTF::static_pointer_cast<SVGPaintServer>(resource);
ts << "KRenderingPaintServer {id=\"" << elementId << "\" " << *paintServer << "}" << "\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment