Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / svg / SVGRenderTreeAsText.cpp
index 15726cb..0966adf 100644 (file)
@@ -69,7 +69,7 @@
 #include <math.h>
 #include <memory>
 
-namespace WebCore {
+namespace blink {
 
 /** class + iomanip to help streaming list separators, i.e. ", " in string "a, b, c, d"
  * Can be used in cases where you don't know which item in the list is the first
@@ -270,7 +270,7 @@ static void writeSVGPaintingResource(TextStream& ts, RenderSVGResource* resource
 static void writeStyle(TextStream& ts, const RenderObject& object)
 {
     const RenderStyle* style = object.style();
-    const SVGRenderStyle* svgStyle = style->svgStyle();
+    const SVGRenderStyle& svgStyle = style->svgStyle();
 
     if (!object.localTransform().isIdentity())
         writeNameValuePair(ts, "transform", object.localTransform());
@@ -287,9 +287,9 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
             writeSVGPaintingResource(ts, strokePaintingResource);
 
             SVGLengthContext lengthContext(shape.element());
-            double dashOffset = svgStyle->strokeDashOffset()->value(lengthContext);
-            double strokeWidth = svgStyle->strokeWidth()->value(lengthContext);
-            RefPtr<SVGLengthList> dashes = svgStyle->strokeDashArray();
+            double dashOffset = svgStyle.strokeDashOffset()->value(lengthContext);
+            double strokeWidth = svgStyle.strokeWidth()->value(lengthContext);
+            RefPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
 
             DashArray dashArray;
             SVGLengthList::ConstIterator it = dashes->begin();
@@ -297,11 +297,11 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
             for (; it != itEnd; ++it)
                 dashArray.append(it->value(lengthContext));
 
-            writeIfNotDefault(ts, "opacity", svgStyle->strokeOpacity(), 1.0f);
+            writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f);
             writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0);
-            writeIfNotDefault(ts, "miter limit", svgStyle->strokeMiterLimit(), 4.0f);
-            writeIfNotDefault(ts, "line cap", svgStyle->capStyle(), ButtCap);
-            writeIfNotDefault(ts, "line join", svgStyle->joinStyle(), MiterJoin);
+            writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.0f);
+            writeIfNotDefault(ts, "line cap", svgStyle.capStyle(), ButtCap);
+            writeIfNotDefault(ts, "line join", svgStyle.joinStyle(), MiterJoin);
             writeIfNotDefault(ts, "dash offset", dashOffset, 0.0);
             if (!dashArray.isEmpty())
                 writeNameValuePair(ts, "dash array", dashArray);
@@ -314,16 +314,16 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
             ts << " [fill={" << s;
             writeSVGPaintingResource(ts, fillPaintingResource);
 
-            writeIfNotDefault(ts, "opacity", svgStyle->fillOpacity(), 1.0f);
-            writeIfNotDefault(ts, "fill rule", svgStyle->fillRule(), RULE_NONZERO);
+            writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f);
+            writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), RULE_NONZERO);
             ts << "}]";
         }
-        writeIfNotDefault(ts, "clip rule", svgStyle->clipRule(), RULE_NONZERO);
+        writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO);
     }
 
-    writeIfNotEmpty(ts, "start marker", svgStyle->markerStartResource());
-    writeIfNotEmpty(ts, "middle marker", svgStyle->markerMidResource());
-    writeIfNotEmpty(ts, "end marker", svgStyle->markerEndResource());
+    writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource());
+    writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource());
+    writeIfNotEmpty(ts, "end marker", svgStyle.markerEndResource());
 }
 
 static TextStream& writePositionAndStyle(TextStream& ts, const RenderObject& object)
@@ -402,10 +402,10 @@ static inline void writeSVGInlineTextBox(TextStream& ts, SVGInlineTextBox* textB
     if (fragments.isEmpty())
         return;
 
-    RenderSVGInlineText& textRenderer = toRenderSVGInlineText(textBox->textRenderer());
+    RenderSVGInlineText& textRenderer = toRenderSVGInlineText(textBox->renderer());
 
-    const SVGRenderStyle* svgStyle = textRenderer.style()->svgStyle();
-    String text = textBox->textRenderer().text();
+    const SVGRenderStyle& svgStyle = textRenderer.style()->svgStyle();
+    String text = textBox->renderer().text();
 
     unsigned fragmentsSize = fragments.size();
     for (unsigned i = 0; i < fragmentsSize; ++i) {
@@ -417,8 +417,8 @@ static inline void writeSVGInlineTextBox(TextStream& ts, SVGInlineTextBox* textB
 
         // FIXME: Remove this hack, once the new text layout engine is completly landed. We want to preserve the old layout test results for now.
         ts << "chunk 1 ";
-        ETextAnchor anchor = svgStyle->textAnchor();
-        bool isVerticalText = svgStyle->isVerticalWritingMode();
+        ETextAnchor anchor = svgStyle.textAnchor();
+        bool isVerticalText = svgStyle.isVerticalWritingMode();
         if (anchor == TA_MIDDLE) {
             ts << "(middle anchor";
             if (isVerticalText)
@@ -642,36 +642,36 @@ void writeSVGGradientStop(TextStream& ts, const RenderSVGGradientStop& stop, int
 void writeResources(TextStream& ts, const RenderObject& object, int indent)
 {
     const RenderStyle* style = object.style();
-    const SVGRenderStyle* svgStyle = style->svgStyle();
+    const SVGRenderStyle& svgStyle = style->svgStyle();
 
     // FIXME: We want to use SVGResourcesCache to determine which resources are present, instead of quering the resource <-> id cache.
     // For now leave the DRT output as is, but later on we should change this so cycles are properly ignored in the DRT output.
     RenderObject& renderer = const_cast<RenderObject&>(object);
-    if (!svgStyle->maskerResource().isEmpty()) {
-        if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(object.document(), svgStyle->maskerResource())) {
+    if (!svgStyle.maskerResource().isEmpty()) {
+        if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(object.document(), svgStyle.maskerResource())) {
             writeIndent(ts, indent);
             ts << " ";
-            writeNameAndQuotedValue(ts, "masker", svgStyle->maskerResource());
+            writeNameAndQuotedValue(ts, "masker", svgStyle.maskerResource());
             ts << " ";
             writeStandardPrefix(ts, *masker, 0);
             ts << " " << masker->resourceBoundingBox(&renderer) << "\n";
         }
     }
-    if (!svgStyle->clipperResource().isEmpty()) {
-        if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(object.document(), svgStyle->clipperResource())) {
+    if (!svgStyle.clipperResource().isEmpty()) {
+        if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(object.document(), svgStyle.clipperResource())) {
             writeIndent(ts, indent);
             ts << " ";
-            writeNameAndQuotedValue(ts, "clipPath", svgStyle->clipperResource());
+            writeNameAndQuotedValue(ts, "clipPath", svgStyle.clipperResource());
             ts << " ";
             writeStandardPrefix(ts, *clipper, 0);
             ts << " " << clipper->resourceBoundingBox(&renderer) << "\n";
         }
     }
-    if (!svgStyle->filterResource().isEmpty()) {
-        if (RenderSVGResourceFilter* filter = getRenderSVGResourceById<RenderSVGResourceFilter>(object.document(), svgStyle->filterResource())) {
+    if (!svgStyle.filterResource().isEmpty()) {
+        if (RenderSVGResourceFilter* filter = getRenderSVGResourceById<RenderSVGResourceFilter>(object.document(), svgStyle.filterResource())) {
             writeIndent(ts, indent);
             ts << " ";
-            writeNameAndQuotedValue(ts, "filter", svgStyle->filterResource());
+            writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource());
             ts << " ";
             writeStandardPrefix(ts, *filter, 0);
             ts << " " << filter->resourceBoundingBox(&renderer) << "\n";
@@ -679,4 +679,4 @@ void writeResources(TextStream& ts, const RenderObject& object, int indent)
     }
 }
 
-} // namespace WebCore
+} // namespace blink