2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved.
3 * (C) 2005 Rob Buis <buis@kde.org>
4 * (C) 2006 Alexander Kellett <lypanov@kde.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "core/rendering/svg/SVGRenderTreeAsText.h"
33 #include "core/rendering/InlineTextBox.h"
34 #include "core/rendering/RenderTreeAsText.h"
35 #include "core/rendering/svg/RenderSVGGradientStop.h"
36 #include "core/rendering/svg/RenderSVGImage.h"
37 #include "core/rendering/svg/RenderSVGInlineText.h"
38 #include "core/rendering/svg/RenderSVGResourceClipper.h"
39 #include "core/rendering/svg/RenderSVGResourceFilter.h"
40 #include "core/rendering/svg/RenderSVGResourceLinearGradient.h"
41 #include "core/rendering/svg/RenderSVGResourceMarker.h"
42 #include "core/rendering/svg/RenderSVGResourceMasker.h"
43 #include "core/rendering/svg/RenderSVGResourcePattern.h"
44 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h"
45 #include "core/rendering/svg/RenderSVGResourceSolidColor.h"
46 #include "core/rendering/svg/RenderSVGRoot.h"
47 #include "core/rendering/svg/RenderSVGShape.h"
48 #include "core/rendering/svg/RenderSVGText.h"
49 #include "core/rendering/svg/SVGInlineTextBox.h"
50 #include "core/rendering/svg/SVGRootInlineBox.h"
51 #include "core/svg/LinearGradientAttributes.h"
52 #include "core/svg/PatternAttributes.h"
53 #include "core/svg/RadialGradientAttributes.h"
54 #include "core/svg/SVGCircleElement.h"
55 #include "core/svg/SVGEllipseElement.h"
56 #include "core/svg/SVGLineElement.h"
57 #include "core/svg/SVGLinearGradientElement.h"
58 #include "core/svg/SVGPathElement.h"
59 #include "core/svg/SVGPathUtilities.h"
60 #include "core/svg/SVGPatternElement.h"
61 #include "core/svg/SVGPointList.h"
62 #include "core/svg/SVGPolyElement.h"
63 #include "core/svg/SVGRadialGradientElement.h"
64 #include "core/svg/SVGRectElement.h"
65 #include "core/svg/SVGStopElement.h"
66 #include "platform/graphics/DashArray.h"
67 #include "platform/graphics/GraphicsTypes.h"
74 /** class + iomanip to help streaming list separators, i.e. ", " in string "a, b, c, d"
75 * Can be used in cases where you don't know which item in the list is the first
76 * one to be printed, but still want to avoid strings like ", b, c".
78 class TextStreamSeparator {
80 TextStreamSeparator(const String& s)
82 , m_needToSeparate(false)
87 friend TextStream& operator<<(TextStream&, TextStreamSeparator&);
90 bool m_needToSeparate;
93 TextStream& operator<<(TextStream& ts, TextStreamSeparator& sep)
95 if (sep.m_needToSeparate)
96 ts << sep.m_separator;
98 sep.m_needToSeparate = true;
102 template<typename ValueType>
103 static void writeNameValuePair(TextStream& ts, const char* name, ValueType value)
105 ts << " [" << name << "=" << value << "]";
108 template<typename ValueType>
109 static void writeNameAndQuotedValue(TextStream& ts, const char* name, ValueType value)
111 ts << " [" << name << "=\"" << value << "\"]";
114 static void writeIfNotEmpty(TextStream& ts, const char* name, const String& value)
116 if (!value.isEmpty())
117 writeNameValuePair(ts, name, value);
120 template<typename ValueType>
121 static void writeIfNotDefault(TextStream& ts, const char* name, ValueType value, ValueType defaultValue)
123 if (value != defaultValue)
124 writeNameValuePair(ts, name, value);
127 TextStream& operator<<(TextStream& ts, const AffineTransform& transform)
129 if (transform.isIdentity())
133 << transform.a() << "," << transform.b()
135 << transform.c() << "," << transform.d()
137 << transform.e() << "," << transform.f()
143 static TextStream& operator<<(TextStream& ts, const WindRule rule)
159 template<typename Enum>
160 String SVGEnumerationToString(Enum value)
162 const SVGEnumerationStringEntries& entries = getStaticStringEntries<Enum>();
164 SVGEnumerationStringEntries::const_iterator it = entries.begin();
165 SVGEnumerationStringEntries::const_iterator itEnd = entries.end();
166 for (; it != itEnd; ++it) {
167 if (value == it->first)
171 ASSERT_NOT_REACHED();
177 static TextStream& operator<<(TextStream& ts, const SVGUnitTypes::SVGUnitType& unitType)
179 ts << SVGEnumerationToString<SVGUnitTypes::SVGUnitType>(unitType);
183 static TextStream& operator<<(TextStream& ts, const SVGMarkerUnitsType& markerUnit)
185 ts << SVGEnumerationToString<SVGMarkerUnitsType>(markerUnit);
189 TextStream& operator<<(TextStream& ts, const Color& c)
191 return ts << c.nameForRenderTreeAsText();
194 // FIXME: Maybe this should be in KCanvasRenderingStyle.cpp
195 static TextStream& operator<<(TextStream& ts, const DashArray& a)
198 DashArray::const_iterator end = a.end();
199 for (DashArray::const_iterator it = a.begin(); it != end; ++it) {
208 // FIXME: Maybe this should be in GraphicsTypes.cpp
209 static TextStream& operator<<(TextStream& ts, LineCap style)
225 // FIXME: Maybe this should be in GraphicsTypes.cpp
226 static TextStream& operator<<(TextStream& ts, LineJoin style)
242 static TextStream& operator<<(TextStream& ts, const SVGSpreadMethodType& type)
244 ts << SVGEnumerationToString<SVGSpreadMethodType>(type).upper();
248 static void writeSVGPaintingResource(TextStream& ts, RenderSVGResource* resource)
250 if (resource->resourceType() == SolidColorResourceType) {
251 ts << "[type=SOLID] [color=" << static_cast<RenderSVGResourceSolidColor*>(resource)->color() << "]";
255 // All other resources derive from RenderSVGResourceContainer
256 RenderSVGResourceContainer* container = static_cast<RenderSVGResourceContainer*>(resource);
257 SVGElement* element = container->element();
260 if (resource->resourceType() == PatternResourceType)
261 ts << "[type=PATTERN]";
262 else if (resource->resourceType() == LinearGradientResourceType)
263 ts << "[type=LINEAR-GRADIENT]";
264 else if (resource->resourceType() == RadialGradientResourceType)
265 ts << "[type=RADIAL-GRADIENT]";
267 ts << " [id=\"" << element->getIdAttribute() << "\"]";
270 static void writeStyle(TextStream& ts, const RenderObject& object)
272 const RenderStyle* style = object.style();
273 const SVGRenderStyle& svgStyle = style->svgStyle();
275 if (!object.localTransform().isIdentity())
276 writeNameValuePair(ts, "transform", object.localTransform());
277 writeIfNotDefault(ts, "image rendering", style->imageRendering(), RenderStyle::initialImageRendering());
278 writeIfNotDefault(ts, "opacity", style->opacity(), RenderStyle::initialOpacity());
279 if (object.isSVGShape()) {
280 const RenderSVGShape& shape = static_cast<const RenderSVGShape&>(object);
281 ASSERT(shape.element());
284 if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<RenderSVGShape*>(&shape), shape.style(), hasFallback)) {
285 TextStreamSeparator s(" ");
286 ts << " [stroke={" << s;
287 writeSVGPaintingResource(ts, strokePaintingResource);
289 SVGLengthContext lengthContext(shape.element());
290 double dashOffset = svgStyle.strokeDashOffset()->value(lengthContext);
291 double strokeWidth = svgStyle.strokeWidth()->value(lengthContext);
292 RefPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
295 SVGLengthList::ConstIterator it = dashes->begin();
296 SVGLengthList::ConstIterator itEnd = dashes->end();
297 for (; it != itEnd; ++it)
298 dashArray.append(it->value(lengthContext));
300 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f);
301 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0);
302 writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.0f);
303 writeIfNotDefault(ts, "line cap", svgStyle.capStyle(), ButtCap);
304 writeIfNotDefault(ts, "line join", svgStyle.joinStyle(), MiterJoin);
305 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0);
306 if (!dashArray.isEmpty())
307 writeNameValuePair(ts, "dash array", dashArray);
312 if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(const_cast<RenderSVGShape*>(&shape), shape.style(), hasFallback)) {
313 TextStreamSeparator s(" ");
314 ts << " [fill={" << s;
315 writeSVGPaintingResource(ts, fillPaintingResource);
317 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f);
318 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), RULE_NONZERO);
321 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO);
324 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource());
325 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource());
326 writeIfNotEmpty(ts, "end marker", svgStyle.markerEndResource());
329 static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& object)
331 ts << " " << enclosingIntRect(const_cast<RenderObject&>(object).absoluteClippedOverflowRect());
332 writeStyle(ts, object);
336 static TextStream& operator<<(TextStream& ts, const RenderSVGShape& shape)
338 writePositionAndStyle(ts, shape);
340 SVGElement* svgElement = shape.element();
342 SVGLengthContext lengthContext(svgElement);
344 if (isSVGRectElement(*svgElement)) {
345 SVGRectElement& element = toSVGRectElement(*svgElement);
346 writeNameValuePair(ts, "x", element.x()->currentValue()->value(lengthContext));
347 writeNameValuePair(ts, "y", element.y()->currentValue()->value(lengthContext));
348 writeNameValuePair(ts, "width", element.width()->currentValue()->value(lengthContext));
349 writeNameValuePair(ts, "height", element.height()->currentValue()->value(lengthContext));
350 } else if (isSVGLineElement(*svgElement)) {
351 SVGLineElement& element = toSVGLineElement(*svgElement);
352 writeNameValuePair(ts, "x1", element.x1()->currentValue()->value(lengthContext));
353 writeNameValuePair(ts, "y1", element.y1()->currentValue()->value(lengthContext));
354 writeNameValuePair(ts, "x2", element.x2()->currentValue()->value(lengthContext));
355 writeNameValuePair(ts, "y2", element.y2()->currentValue()->value(lengthContext));
356 } else if (isSVGEllipseElement(*svgElement)) {
357 SVGEllipseElement& element = toSVGEllipseElement(*svgElement);
358 writeNameValuePair(ts, "cx", element.cx()->currentValue()->value(lengthContext));
359 writeNameValuePair(ts, "cy", element.cy()->currentValue()->value(lengthContext));
360 writeNameValuePair(ts, "rx", element.rx()->currentValue()->value(lengthContext));
361 writeNameValuePair(ts, "ry", element.ry()->currentValue()->value(lengthContext));
362 } else if (isSVGCircleElement(*svgElement)) {
363 SVGCircleElement& element = toSVGCircleElement(*svgElement);
364 writeNameValuePair(ts, "cx", element.cx()->currentValue()->value(lengthContext));
365 writeNameValuePair(ts, "cy", element.cy()->currentValue()->value(lengthContext));
366 writeNameValuePair(ts, "r", element.r()->currentValue()->value(lengthContext));
367 } else if (isSVGPolyElement(*svgElement)) {
368 writeNameAndQuotedValue(ts, "points", toSVGPolyElement(*svgElement).points()->currentValue()->valueAsString());
369 } else if (isSVGPathElement(*svgElement)) {
371 // FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
372 buildStringFromByteStream(toSVGPathElement(*svgElement).pathByteStream(), pathString, NormalizedParsing);
373 writeNameAndQuotedValue(ts, "data", pathString);
375 ASSERT_NOT_REACHED();
379 static TextStream& operator<<(TextStream& ts, const RenderSVGRoot& root)
381 return writePositionAndStyle(ts, root);
384 static void writeRenderSVGTextBox(TextStream& ts, const RenderSVGText& text)
386 SVGRootInlineBox* box = toSVGRootInlineBox(text.firstRootBox());
390 ts << " " << enclosingIntRect(FloatRect(text.location(), FloatSize(box->logicalWidth(), box->logicalHeight())));
392 // FIXME: Remove this hack, once the new text layout engine is completly landed. We want to preserve the old layout test results for now.
393 ts << " contains 1 chunk(s)";
395 if (text.parent() && (text.parent()->style()->visitedDependentColor(CSSPropertyColor) != text.style()->visitedDependentColor(CSSPropertyColor)))
396 writeNameValuePair(ts, "color", text.resolveColor(CSSPropertyColor).nameForRenderTreeAsText());
399 static inline void writeSVGInlineTextBox(TextStream& ts, SVGInlineTextBox* textBox, int indent)
401 Vector<SVGTextFragment>& fragments = textBox->textFragments();
402 if (fragments.isEmpty())
405 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(textBox->renderer());
407 const SVGRenderStyle& svgStyle = textRenderer.style()->svgStyle();
408 String text = textBox->renderer().text();
410 unsigned fragmentsSize = fragments.size();
411 for (unsigned i = 0; i < fragmentsSize; ++i) {
412 SVGTextFragment& fragment = fragments.at(i);
413 writeIndent(ts, indent + 1);
415 unsigned startOffset = fragment.characterOffset;
416 unsigned endOffset = fragment.characterOffset + fragment.length;
418 // FIXME: Remove this hack, once the new text layout engine is completly landed. We want to preserve the old layout test results for now.
420 ETextAnchor anchor = svgStyle.textAnchor();
421 bool isVerticalText = svgStyle.isVerticalWritingMode();
422 if (anchor == TA_MIDDLE) {
423 ts << "(middle anchor";
427 } else if (anchor == TA_END) {
432 } else if (isVerticalText)
434 startOffset -= textBox->start();
435 endOffset -= textBox->start();
438 ts << "text run " << i + 1 << " at (" << fragment.x << "," << fragment.y << ")";
439 ts << " startOffset " << startOffset << " endOffset " << endOffset;
441 ts << " height " << fragment.height;
443 ts << " width " << fragment.width;
445 if (!textBox->isLeftToRightDirection() || textBox->dirOverride()) {
446 ts << (textBox->isLeftToRightDirection() ? " LTR" : " RTL");
447 if (textBox->dirOverride())
451 ts << ": " << quoteAndEscapeNonPrintables(text.substring(fragment.characterOffset, fragment.length)) << "\n";
455 static inline void writeSVGInlineTextBoxes(TextStream& ts, const RenderText& text, int indent)
457 for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
458 if (!box->isSVGInlineTextBox())
461 writeSVGInlineTextBox(ts, toSVGInlineTextBox(box), indent);
465 static void writeStandardPrefix(TextStream& ts, const RenderObject& object, int indent)
467 writeIndent(ts, indent);
468 ts << object.renderName();
471 ts << " {" << object.node()->nodeName() << "}";
474 static void writeChildren(TextStream& ts, const RenderObject& object, int indent)
476 for (RenderObject* child = object.slowFirstChild(); child; child = child->nextSibling())
477 write(ts, *child, indent + 1);
480 static inline void writeCommonGradientProperties(TextStream& ts, SVGSpreadMethodType spreadMethod, const AffineTransform& gradientTransform, SVGUnitTypes::SVGUnitType gradientUnits)
482 writeNameValuePair(ts, "gradientUnits", gradientUnits);
484 if (spreadMethod != SVGSpreadMethodPad)
485 ts << " [spreadMethod=" << spreadMethod << "]";
487 if (!gradientTransform.isIdentity())
488 ts << " [gradientTransform=" << gradientTransform << "]";
491 void writeSVGResourceContainer(TextStream& ts, const RenderObject& object, int indent)
493 writeStandardPrefix(ts, object, indent);
495 Element* element = toElement(object.node());
496 const AtomicString& id = element->getIdAttribute();
497 writeNameAndQuotedValue(ts, "id", id);
499 RenderSVGResourceContainer* resource = toRenderSVGResourceContainer(const_cast<RenderObject*>(&object));
502 if (resource->resourceType() == MaskerResourceType) {
503 RenderSVGResourceMasker* masker = toRenderSVGResourceMasker(resource);
504 writeNameValuePair(ts, "maskUnits", masker->maskUnits());
505 writeNameValuePair(ts, "maskContentUnits", masker->maskContentUnits());
507 } else if (resource->resourceType() == FilterResourceType) {
508 RenderSVGResourceFilter* filter = toRenderSVGResourceFilter(resource);
509 writeNameValuePair(ts, "filterUnits", filter->filterUnits());
510 writeNameValuePair(ts, "primitiveUnits", filter->primitiveUnits());
512 // Creating a placeholder filter which is passed to the builder.
514 IntRect dummyIntRect;
515 RefPtr<SVGFilter> dummyFilter = SVGFilter::create(AffineTransform(), dummyIntRect, dummyRect, dummyRect, true);
516 if (RefPtr<SVGFilterBuilder> builder = filter->buildPrimitives(dummyFilter.get())) {
517 if (FilterEffect* lastEffect = builder->lastEffect())
518 lastEffect->externalRepresentation(ts, indent + 1);
520 } else if (resource->resourceType() == ClipperResourceType) {
521 writeNameValuePair(ts, "clipPathUnits", toRenderSVGResourceClipper(resource)->clipPathUnits());
523 } else if (resource->resourceType() == MarkerResourceType) {
524 RenderSVGResourceMarker* marker = toRenderSVGResourceMarker(resource);
525 writeNameValuePair(ts, "markerUnits", marker->markerUnits());
526 ts << " [ref at " << marker->referencePoint() << "]";
528 if (marker->angle() == -1)
529 ts << "auto" << "]\n";
531 ts << marker->angle() << "]\n";
532 } else if (resource->resourceType() == PatternResourceType) {
533 RenderSVGResourcePattern* pattern = static_cast<RenderSVGResourcePattern*>(resource);
535 // Dump final results that are used for rendering. No use in asking SVGPatternElement for its patternUnits(), as it may
536 // link to other patterns using xlink:href, we need to build the full inheritance chain, aka. collectPatternProperties()
537 PatternAttributes attributes;
538 toSVGPatternElement(pattern->element())->collectPatternAttributes(attributes);
540 writeNameValuePair(ts, "patternUnits", attributes.patternUnits());
541 writeNameValuePair(ts, "patternContentUnits", attributes.patternContentUnits());
543 AffineTransform transform = attributes.patternTransform();
544 if (!transform.isIdentity())
545 ts << " [patternTransform=" << transform << "]";
547 } else if (resource->resourceType() == LinearGradientResourceType) {
548 RenderSVGResourceLinearGradient* gradient = static_cast<RenderSVGResourceLinearGradient*>(resource);
550 // Dump final results that are used for rendering. No use in asking SVGGradientElement for its gradientUnits(), as it may
551 // link to other gradients using xlink:href, we need to build the full inheritance chain, aka. collectGradientProperties()
552 LinearGradientAttributes attributes;
553 toSVGLinearGradientElement(gradient->element())->collectGradientAttributes(attributes);
554 writeCommonGradientProperties(ts, attributes.spreadMethod(), attributes.gradientTransform(), attributes.gradientUnits());
556 ts << " [start=" << gradient->startPoint(attributes) << "] [end=" << gradient->endPoint(attributes) << "]\n";
557 } else if (resource->resourceType() == RadialGradientResourceType) {
558 RenderSVGResourceRadialGradient* gradient = toRenderSVGResourceRadialGradient(resource);
560 // Dump final results that are used for rendering. No use in asking SVGGradientElement for its gradientUnits(), as it may
561 // link to other gradients using xlink:href, we need to build the full inheritance chain, aka. collectGradientProperties()
562 RadialGradientAttributes attributes;
563 toSVGRadialGradientElement(gradient->element())->collectGradientAttributes(attributes);
564 writeCommonGradientProperties(ts, attributes.spreadMethod(), attributes.gradientTransform(), attributes.gradientUnits());
566 FloatPoint focalPoint = gradient->focalPoint(attributes);
567 FloatPoint centerPoint = gradient->centerPoint(attributes);
568 float radius = gradient->radius(attributes);
569 float focalRadius = gradient->focalRadius(attributes);
571 ts << " [center=" << centerPoint << "] [focal=" << focalPoint << "] [radius=" << radius << "] [focalRadius=" << focalRadius << "]\n";
574 writeChildren(ts, object, indent);
577 void writeSVGContainer(TextStream& ts, const RenderObject& container, int indent)
579 // Currently RenderSVGResourceFilterPrimitive has no meaningful output.
580 if (container.isSVGResourceFilterPrimitive())
582 writeStandardPrefix(ts, container, indent);
583 writePositionAndStyle(ts, container);
585 writeResources(ts, container, indent);
586 writeChildren(ts, container, indent);
589 void write(TextStream& ts, const RenderSVGRoot& root, int indent)
591 writeStandardPrefix(ts, root, indent);
593 writeChildren(ts, root, indent);
596 void writeSVGText(TextStream& ts, const RenderSVGText& text, int indent)
598 writeStandardPrefix(ts, text, indent);
599 writeRenderSVGTextBox(ts, text);
601 writeResources(ts, text, indent);
602 writeChildren(ts, text, indent);
605 void writeSVGInlineText(TextStream& ts, const RenderSVGInlineText& text, int indent)
607 writeStandardPrefix(ts, text, indent);
608 ts << " " << enclosingIntRect(FloatRect(text.firstRunOrigin(), text.floatLinesBoundingBox().size())) << "\n";
609 writeResources(ts, text, indent);
610 writeSVGInlineTextBoxes(ts, text, indent);
613 void writeSVGImage(TextStream& ts, const RenderSVGImage& image, int indent)
615 writeStandardPrefix(ts, image, indent);
616 writePositionAndStyle(ts, image);
618 writeResources(ts, image, indent);
621 void write(TextStream& ts, const RenderSVGShape& shape, int indent)
623 writeStandardPrefix(ts, shape, indent);
625 writeResources(ts, shape, indent);
628 void writeSVGGradientStop(TextStream& ts, const RenderSVGGradientStop& stop, int indent)
630 writeStandardPrefix(ts, stop, indent);
632 SVGStopElement* stopElement = toSVGStopElement(stop.node());
635 RenderStyle* style = stop.style();
639 ts << " [offset=" << stopElement->offset()->currentValue()->value() << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n";
642 void writeResources(TextStream& ts, const RenderObject& object, int indent)
644 const RenderStyle* style = object.style();
645 const SVGRenderStyle& svgStyle = style->svgStyle();
647 // FIXME: We want to use SVGResourcesCache to determine which resources are present, instead of quering the resource <-> id cache.
648 // For now leave the DRT output as is, but later on we should change this so cycles are properly ignored in the DRT output.
649 RenderObject& renderer = const_cast<RenderObject&>(object);
650 if (!svgStyle.maskerResource().isEmpty()) {
651 if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(object.document(), svgStyle.maskerResource())) {
652 writeIndent(ts, indent);
654 writeNameAndQuotedValue(ts, "masker", svgStyle.maskerResource());
656 writeStandardPrefix(ts, *masker, 0);
657 ts << " " << masker->resourceBoundingBox(&renderer) << "\n";
660 if (!svgStyle.clipperResource().isEmpty()) {
661 if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(object.document(), svgStyle.clipperResource())) {
662 writeIndent(ts, indent);
664 writeNameAndQuotedValue(ts, "clipPath", svgStyle.clipperResource());
666 writeStandardPrefix(ts, *clipper, 0);
667 ts << " " << clipper->resourceBoundingBox(&renderer) << "\n";
670 if (!svgStyle.filterResource().isEmpty()) {
671 if (RenderSVGResourceFilter* filter = getRenderSVGResourceById<RenderSVGResourceFilter>(object.document(), svgStyle.filterResource())) {
672 writeIndent(ts, indent);
674 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource());
676 writeStandardPrefix(ts, *filter, 0);
677 ts << " " << filter->resourceBoundingBox(&renderer) << "\n";