| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. |
| 3 * (C) 2005 Rob Buis <buis@kde.org> | 3 * (C) 2005 Rob Buis <buis@kde.org> |
| 4 * (C) 2006 Alexander Kellett <lypanov@kde.org> | 4 * (C) 2006 Alexander Kellett <lypanov@kde.org> |
| 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "core/rendering/svg/RenderSVGGradientStop.h" | 35 #include "core/rendering/svg/RenderSVGGradientStop.h" |
| 36 #include "core/rendering/svg/RenderSVGImage.h" | 36 #include "core/rendering/svg/RenderSVGImage.h" |
| 37 #include "core/rendering/svg/RenderSVGInlineText.h" | 37 #include "core/rendering/svg/RenderSVGInlineText.h" |
| 38 #include "core/rendering/svg/RenderSVGResourceClipper.h" | 38 #include "core/rendering/svg/RenderSVGResourceClipper.h" |
| 39 #include "core/rendering/svg/RenderSVGResourceFilter.h" | 39 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
| 40 #include "core/rendering/svg/RenderSVGResourceLinearGradient.h" | 40 #include "core/rendering/svg/RenderSVGResourceLinearGradient.h" |
| 41 #include "core/rendering/svg/RenderSVGResourceMarker.h" | 41 #include "core/rendering/svg/RenderSVGResourceMarker.h" |
| 42 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 42 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
| 43 #include "core/rendering/svg/RenderSVGResourcePattern.h" | 43 #include "core/rendering/svg/RenderSVGResourcePattern.h" |
| 44 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h" | 44 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h" |
| 45 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" | |
| 46 #include "core/rendering/svg/RenderSVGRoot.h" | 45 #include "core/rendering/svg/RenderSVGRoot.h" |
| 47 #include "core/rendering/svg/RenderSVGShape.h" | 46 #include "core/rendering/svg/RenderSVGShape.h" |
| 48 #include "core/rendering/svg/RenderSVGText.h" | 47 #include "core/rendering/svg/RenderSVGText.h" |
| 49 #include "core/rendering/svg/SVGInlineTextBox.h" | 48 #include "core/rendering/svg/SVGInlineTextBox.h" |
| 50 #include "core/rendering/svg/SVGRootInlineBox.h" | 49 #include "core/rendering/svg/SVGRootInlineBox.h" |
| 51 #include "core/svg/LinearGradientAttributes.h" | 50 #include "core/svg/LinearGradientAttributes.h" |
| 52 #include "core/svg/PatternAttributes.h" | 51 #include "core/svg/PatternAttributes.h" |
| 53 #include "core/svg/RadialGradientAttributes.h" | 52 #include "core/svg/RadialGradientAttributes.h" |
| 54 #include "core/svg/SVGCircleElement.h" | 53 #include "core/svg/SVGCircleElement.h" |
| 55 #include "core/svg/SVGEllipseElement.h" | 54 #include "core/svg/SVGEllipseElement.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 238 } |
| 240 return ts; | 239 return ts; |
| 241 } | 240 } |
| 242 | 241 |
| 243 static TextStream& operator<<(TextStream& ts, const SVGSpreadMethodType& type) | 242 static TextStream& operator<<(TextStream& ts, const SVGSpreadMethodType& type) |
| 244 { | 243 { |
| 245 ts << SVGEnumerationToString<SVGSpreadMethodType>(type).upper(); | 244 ts << SVGEnumerationToString<SVGSpreadMethodType>(type).upper(); |
| 246 return ts; | 245 return ts; |
| 247 } | 246 } |
| 248 | 247 |
| 249 static void writeSVGPaintingResource(TextStream& ts, RenderSVGResource* resource
) | 248 static void writeSVGPaintingResource(TextStream& ts, const SVGPaintDescription&
paintDescription) |
| 250 { | 249 { |
| 251 if (resource->resourceType() == SolidColorResourceType) { | 250 ASSERT(paintDescription.isValid); |
| 252 ts << "[type=SOLID] [color=" << static_cast<RenderSVGResourceSolidColor*
>(resource)->color() << "]"; | 251 if (!paintDescription.resource) { |
| 252 ts << "[type=SOLID] [color=" << paintDescription.color << "]"; |
| 253 return; | 253 return; |
| 254 } | 254 } |
| 255 | 255 |
| 256 RenderSVGResource* resource = paintDescription.resource; |
| 256 // All other resources derive from RenderSVGResourceContainer | 257 // All other resources derive from RenderSVGResourceContainer |
| 257 RenderSVGResourceContainer* container = static_cast<RenderSVGResourceContain
er*>(resource); | 258 RenderSVGResourceContainer* container = static_cast<RenderSVGResourceContain
er*>(resource); |
| 258 SVGElement* element = container->element(); | 259 SVGElement* element = container->element(); |
| 259 ASSERT(element); | 260 ASSERT(element); |
| 260 | 261 |
| 261 if (resource->resourceType() == PatternResourceType) | 262 if (resource->resourceType() == PatternResourceType) |
| 262 ts << "[type=PATTERN]"; | 263 ts << "[type=PATTERN]"; |
| 263 else if (resource->resourceType() == LinearGradientResourceType) | 264 else if (resource->resourceType() == LinearGradientResourceType) |
| 264 ts << "[type=LINEAR-GRADIENT]"; | 265 ts << "[type=LINEAR-GRADIENT]"; |
| 265 else if (resource->resourceType() == RadialGradientResourceType) | 266 else if (resource->resourceType() == RadialGradientResourceType) |
| 266 ts << "[type=RADIAL-GRADIENT]"; | 267 ts << "[type=RADIAL-GRADIENT]"; |
| 267 | 268 |
| 268 ts << " [id=\"" << element->getIdAttribute() << "\"]"; | 269 ts << " [id=\"" << element->getIdAttribute() << "\"]"; |
| 269 } | 270 } |
| 270 | 271 |
| 271 static void writeStyle(TextStream& ts, const RenderObject& object) | 272 static void writeStyle(TextStream& ts, const RenderObject& object) |
| 272 { | 273 { |
| 273 const RenderStyle* style = object.style(); | 274 const RenderStyle* style = object.style(); |
| 274 const SVGRenderStyle& svgStyle = style->svgStyle(); | 275 const SVGRenderStyle& svgStyle = style->svgStyle(); |
| 275 | 276 |
| 276 if (!object.localTransform().isIdentity()) | 277 if (!object.localTransform().isIdentity()) |
| 277 writeNameValuePair(ts, "transform", object.localTransform()); | 278 writeNameValuePair(ts, "transform", object.localTransform()); |
| 278 writeIfNotDefault(ts, "image rendering", style->imageRendering(), RenderStyl
e::initialImageRendering()); | 279 writeIfNotDefault(ts, "image rendering", style->imageRendering(), RenderStyl
e::initialImageRendering()); |
| 279 writeIfNotDefault(ts, "opacity", style->opacity(), RenderStyle::initialOpaci
ty()); | 280 writeIfNotDefault(ts, "opacity", style->opacity(), RenderStyle::initialOpaci
ty()); |
| 280 if (object.isSVGShape()) { | 281 if (object.isSVGShape()) { |
| 281 const RenderSVGShape& shape = static_cast<const RenderSVGShape&>(object)
; | 282 const RenderSVGShape& shape = static_cast<const RenderSVGShape&>(object)
; |
| 282 ASSERT(shape.element()); | 283 ASSERT(shape.element()); |
| 283 | 284 |
| 284 bool hasFallback; | 285 SVGPaintDescription strokePaintDescription = RenderSVGResource::requestP
aintDescription(shape, shape.style(), ApplyToStrokeMode); |
| 285 if (RenderSVGResource* strokePaintingResource = RenderSVGResource::reque
stPaintingResource(ApplyToStrokeMode, shape, shape.style(), hasFallback)) { | 286 if (strokePaintDescription.isValid) { |
| 286 TextStreamSeparator s(" "); | 287 TextStreamSeparator s(" "); |
| 287 ts << " [stroke={" << s; | 288 ts << " [stroke={" << s; |
| 288 writeSVGPaintingResource(ts, strokePaintingResource); | 289 writeSVGPaintingResource(ts, strokePaintDescription); |
| 289 | 290 |
| 290 SVGLengthContext lengthContext(shape.element()); | 291 SVGLengthContext lengthContext(shape.element()); |
| 291 double dashOffset = svgStyle.strokeDashOffset()->value(lengthContext
); | 292 double dashOffset = svgStyle.strokeDashOffset()->value(lengthContext
); |
| 292 double strokeWidth = svgStyle.strokeWidth()->value(lengthContext); | 293 double strokeWidth = svgStyle.strokeWidth()->value(lengthContext); |
| 293 RefPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); | 294 RefPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); |
| 294 | 295 |
| 295 DashArray dashArray; | 296 DashArray dashArray; |
| 296 SVGLengthList::ConstIterator it = dashes->begin(); | 297 SVGLengthList::ConstIterator it = dashes->begin(); |
| 297 SVGLengthList::ConstIterator itEnd = dashes->end(); | 298 SVGLengthList::ConstIterator itEnd = dashes->end(); |
| 298 for (; it != itEnd; ++it) | 299 for (; it != itEnd; ++it) |
| 299 dashArray.append(it->value(lengthContext)); | 300 dashArray.append(it->value(lengthContext)); |
| 300 | 301 |
| 301 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f); | 302 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f); |
| 302 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0); | 303 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0); |
| 303 writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.
0f); | 304 writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.
0f); |
| 304 writeIfNotDefault(ts, "line cap", svgStyle.capStyle(), ButtCap); | 305 writeIfNotDefault(ts, "line cap", svgStyle.capStyle(), ButtCap); |
| 305 writeIfNotDefault(ts, "line join", svgStyle.joinStyle(), MiterJoin); | 306 writeIfNotDefault(ts, "line join", svgStyle.joinStyle(), MiterJoin); |
| 306 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0); | 307 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0); |
| 307 if (!dashArray.isEmpty()) | 308 if (!dashArray.isEmpty()) |
| 308 writeNameValuePair(ts, "dash array", dashArray); | 309 writeNameValuePair(ts, "dash array", dashArray); |
| 309 | 310 |
| 310 ts << "}]"; | 311 ts << "}]"; |
| 311 } | 312 } |
| 312 | 313 |
| 313 if (RenderSVGResource* fillPaintingResource = RenderSVGResource::request
PaintingResource(ApplyToFillMode, shape, shape.style(), hasFallback)) { | 314 SVGPaintDescription fillPaintDescription = RenderSVGResource::requestPai
ntDescription(shape, shape.style(), ApplyToFillMode); |
| 315 if (fillPaintDescription.isValid) { |
| 314 TextStreamSeparator s(" "); | 316 TextStreamSeparator s(" "); |
| 315 ts << " [fill={" << s; | 317 ts << " [fill={" << s; |
| 316 writeSVGPaintingResource(ts, fillPaintingResource); | 318 writeSVGPaintingResource(ts, fillPaintDescription); |
| 317 | 319 |
| 318 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f); | 320 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f); |
| 319 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), RULE_NONZERO
); | 321 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), RULE_NONZERO
); |
| 320 ts << "}]"; | 322 ts << "}]"; |
| 321 } | 323 } |
| 322 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); | 324 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); |
| 323 } | 325 } |
| 324 | 326 |
| 325 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource()); | 327 writeIfNotEmpty(ts, "start marker", svgStyle.markerStartResource()); |
| 326 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource()); | 328 writeIfNotEmpty(ts, "middle marker", svgStyle.markerMidResource()); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 ts << " "; | 676 ts << " "; |
| 675 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); | 677 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); |
| 676 ts << " "; | 678 ts << " "; |
| 677 writeStandardPrefix(ts, *filter, 0); | 679 writeStandardPrefix(ts, *filter, 0); |
| 678 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; | 680 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; |
| 679 } | 681 } |
| 680 } | 682 } |
| 681 } | 683 } |
| 682 | 684 |
| 683 } // namespace blink | 685 } // namespace blink |
| OLD | NEW |