summaryrefslogtreecommitdiff
path: root/src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp112
1 files changed, 101 insertions, 11 deletions
diff --git a/src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp b/src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp
index 28e506ad90..5d70505f57 100644
--- a/src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/SVGRenderTreeAsText.cpp
@@ -34,10 +34,13 @@
#include "HTMLNames.h"
#include "InlineTextBox.h"
#include "NodeRenderStyle.h"
+#include "Path.h"
#include "RenderImage.h"
#include "RenderPath.h"
#include "RenderSVGContainer.h"
#include "RenderSVGInlineText.h"
+#include "RenderSVGResourceClipper.h"
+#include "RenderSVGResourceMasker.h"
#include "RenderSVGRoot.h"
#include "RenderSVGText.h"
#include "RenderTreeAsText.h"
@@ -46,7 +49,6 @@
#include "SVGPaintServerGradient.h"
#include "SVGPaintServerPattern.h"
#include "SVGPaintServerSolid.h"
-#include "SVGResourceClipper.h"
#include "SVGRootInlineBox.h"
#include "SVGStyledElement.h"
#include <math.h>
@@ -179,7 +181,7 @@ TextStream& operator<<(TextStream& ts, const FloatSize& s)
return ts;
}
-TextStream& operator<<(TextStream& ts, const TransformationMatrix& transform)
+TextStream& operator<<(TextStream& ts, const AffineTransform& transform)
{
if (transform.isIdentity())
ts << "identity";
@@ -195,6 +197,37 @@ TextStream& operator<<(TextStream& ts, const TransformationMatrix& transform)
return ts;
}
+static TextStream& operator<<(TextStream& ts, const WindRule rule)
+{
+ switch (rule) {
+ case RULE_NONZERO:
+ ts << "NON-ZERO";
+ break;
+ case RULE_EVENODD:
+ ts << "EVEN-ODD";
+ break;
+ }
+
+ return ts;
+}
+
+static TextStream& operator<<(TextStream& ts, const SVGUnitTypes::SVGUnitType& unitType)
+{
+ switch (unitType) {
+ case SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN:
+ ts << "unknown";
+ break;
+ case SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE:
+ ts << "userSpaceOnUse";
+ break;
+ case SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX:
+ ts << "objectBoundingBox";
+ break;
+ }
+
+ return ts;
+}
+
TextStream& operator<<(TextStream& ts, const Color& c)
{
return ts << c.name();
@@ -298,10 +331,9 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
writeIfNotDefault(ts, "fill rule", svgStyle->fillRule(), RULE_NONZERO);
ts << "}]";
}
+ writeIfNotDefault(ts, "clip rule", svgStyle->clipRule(), RULE_NONZERO);
}
- if (!svgStyle->clipPath().isEmpty())
- writeNameAndQuotedValue(ts, "clip path", svgStyle->clipPath());
writeIfNotEmpty(ts, "start marker", svgStyle->startMarker());
writeIfNotEmpty(ts, "middle marker", svgStyle->midMarker());
writeIfNotEmpty(ts, "end marker", svgStyle->endMarker());
@@ -310,7 +342,7 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& object)
{
- ts << " " << object.absoluteTransform().mapRect(object.repaintRectInLocalCoordinates());
+ ts << " " << const_cast<RenderObject&>(object).absoluteClippedOverflowRect();
writeStyle(ts, object);
return ts;
}
@@ -464,11 +496,37 @@ static void writeChildren(TextStream& ts, const RenderObject& object, int indent
write(ts, *child, indent + 1);
}
+void writeSVGResource(TextStream& ts, const RenderObject& object, int indent)
+{
+ writeStandardPrefix(ts, object, indent);
+
+ Element* element = static_cast<Element*>(object.node());
+ const AtomicString& id = element->getIDAttribute();
+ writeNameAndQuotedValue(ts, "id", id);
+
+ RenderSVGResource* resource = const_cast<RenderObject&>(object).toRenderSVGResource();
+ if (resource->resourceType() == MaskerResourceType) {
+ RenderSVGResourceMasker* masker = static_cast<RenderSVGResourceMasker*>(resource);
+ ASSERT(masker);
+ writeNameValuePair(ts, "maskUnits", masker->maskUnits());
+ writeNameValuePair(ts, "maskContentUnits", masker->maskContentUnits());
+ } else if (resource->resourceType() == ClipperResourceType) {
+ RenderSVGResourceClipper* clipper = static_cast<RenderSVGResourceClipper*>(resource);
+ ASSERT(clipper);
+ writeNameValuePair(ts, "clipPathUnits", clipper->clipPathUnits());
+ }
+
+ // FIXME: Handle other RenderSVGResource* classes here, after converting them from SVGResource*.
+ ts << "\n";
+ writeChildren(ts, object, indent);
+}
+
void writeSVGContainer(TextStream& ts, const RenderObject& container, int indent)
{
writeStandardPrefix(ts, container, indent);
writePositionAndStyle(ts, container);
ts << "\n";
+ writeResources(ts, container, indent);
writeChildren(ts, container, indent);
}
@@ -484,6 +542,7 @@ void writeSVGText(TextStream& ts, const RenderBlock& text, int indent)
writeStandardPrefix(ts, text, indent);
writeRenderSVGTextBox(ts, text);
ts << "\n";
+ writeResources(ts, text, indent);
writeChildren(ts, text, indent);
}
@@ -493,20 +552,51 @@ void writeSVGInlineText(TextStream& ts, const RenderText& text, int indent)
// Why not just linesBoundingBox()?
ts << " " << FloatRect(text.firstRunOrigin(), text.linesBoundingBox().size()) << "\n";
+ writeResources(ts, text, indent);
writeSVGInlineTextBoxes(ts, text, indent);
}
+void writeSVGImage(TextStream& ts, const RenderImage& image, int indent)
+{
+ writeStandardPrefix(ts, image, indent);
+ writePositionAndStyle(ts, image);
+ ts << "\n";
+ writeResources(ts, image, indent);
+}
+
void write(TextStream& ts, const RenderPath& path, int indent)
{
writeStandardPrefix(ts, path, indent);
ts << path << "\n";
+ writeResources(ts, path, indent);
}
-void writeSVGImage(TextStream& ts, const RenderImage& image, int indent)
+void writeResources(TextStream& ts, const RenderObject& object, int indent)
{
- writeStandardPrefix(ts, image, indent);
- writePositionAndStyle(ts, image);
- ts << "\n";
+ const RenderStyle* style = object.style();
+ const SVGRenderStyle* svgStyle = style->svgStyle();
+
+ if (!svgStyle->maskElement().isEmpty()) {
+ if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(object.document(), svgStyle->maskElement())) {
+ writeIndent(ts, indent);
+ ts << " ";
+ writeNameAndQuotedValue(ts, "masker", svgStyle->maskElement());
+ ts << " ";
+ writeStandardPrefix(ts, *masker, 0);
+ ts << " " << masker->resourceBoundingBox(object.objectBoundingBox()) << "\n";
+ }
+ }
+ if (!svgStyle->clipPath().isEmpty()) {
+ if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(object.document(), svgStyle->clipPath())) {
+ writeIndent(ts, indent);
+ ts << " ";
+ writeNameAndQuotedValue(ts, "clipPath", svgStyle->clipPath());
+ ts << " ";
+ writeStandardPrefix(ts, *clipper, 0);
+ ts << " " << clipper->resourceBoundingBox(object.objectBoundingBox()) << "\n";
+ }
+ }
+ // FIXME: Handle other RenderSVGResource* classes here, after converting them from SVGResource*.
}
void writeRenderResources(TextStream& ts, Node* parent)
@@ -521,11 +611,11 @@ void writeRenderResources(TextStream& ts, Node* parent)
continue;
SVGStyledElement* styled = static_cast<SVGStyledElement*>(svgElement);
- RefPtr<SVGResource> resource(styled->canvasResource());
+ RefPtr<SVGResource> resource(styled->canvasResource(node->renderer()));
if (!resource)
continue;
- String elementId = svgElement->getAttribute(HTMLNames::idAttr);
+ String elementId = svgElement->getAttribute(svgElement->idAttributeName());
// FIXME: These names are lies!
if (resource->isPaintServer()) {
RefPtr<SVGPaintServer> paintServer = WTF::static_pointer_cast<SVGPaintServer>(resource);