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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 246 } |
247 | 247 |
248 static void writeSVGPaintingResource(TextStream& ts, const SVGPaintDescription&
paintDescription) | 248 static void writeSVGPaintingResource(TextStream& ts, const SVGPaintDescription&
paintDescription) |
249 { | 249 { |
250 ASSERT(paintDescription.isValid); | 250 ASSERT(paintDescription.isValid); |
251 if (!paintDescription.resource) { | 251 if (!paintDescription.resource) { |
252 ts << "[type=SOLID] [color=" << paintDescription.color << "]"; | 252 ts << "[type=SOLID] [color=" << paintDescription.color << "]"; |
253 return; | 253 return; |
254 } | 254 } |
255 | 255 |
256 RenderSVGResource* resource = paintDescription.resource; | 256 RenderSVGResourcePaintServer* paintServerContainer = paintDescription.resour
ce; |
257 // All other resources derive from RenderSVGResourceContainer | 257 SVGElement* element = paintServerContainer->element(); |
258 RenderSVGResourceContainer* container = static_cast<RenderSVGResourceContain
er*>(resource); | |
259 SVGElement* element = container->element(); | |
260 ASSERT(element); | 258 ASSERT(element); |
261 | 259 |
262 if (container->resourceType() == PatternResourceType) | 260 if (paintServerContainer->resourceType() == PatternResourceType) |
263 ts << "[type=PATTERN]"; | 261 ts << "[type=PATTERN]"; |
264 else if (container->resourceType() == LinearGradientResourceType) | 262 else if (paintServerContainer->resourceType() == LinearGradientResourceType) |
265 ts << "[type=LINEAR-GRADIENT]"; | 263 ts << "[type=LINEAR-GRADIENT]"; |
266 else if (container->resourceType() == RadialGradientResourceType) | 264 else if (paintServerContainer->resourceType() == RadialGradientResourceType) |
267 ts << "[type=RADIAL-GRADIENT]"; | 265 ts << "[type=RADIAL-GRADIENT]"; |
268 | 266 |
269 ts << " [id=\"" << element->getIdAttribute() << "\"]"; | 267 ts << " [id=\"" << element->getIdAttribute() << "\"]"; |
270 } | 268 } |
271 | 269 |
272 static void writeStyle(TextStream& ts, const RenderObject& object) | 270 static void writeStyle(TextStream& ts, const RenderObject& object) |
273 { | 271 { |
274 const RenderStyle* style = object.style(); | 272 const RenderStyle* style = object.style(); |
275 const SVGRenderStyle& svgStyle = style->svgStyle(); | 273 const SVGRenderStyle& svgStyle = style->svgStyle(); |
276 | 274 |
277 if (!object.localTransform().isIdentity()) | 275 if (!object.localTransform().isIdentity()) |
278 writeNameValuePair(ts, "transform", object.localTransform()); | 276 writeNameValuePair(ts, "transform", object.localTransform()); |
279 writeIfNotDefault(ts, "image rendering", style->imageRendering(), RenderStyl
e::initialImageRendering()); | 277 writeIfNotDefault(ts, "image rendering", style->imageRendering(), RenderStyl
e::initialImageRendering()); |
280 writeIfNotDefault(ts, "opacity", style->opacity(), RenderStyle::initialOpaci
ty()); | 278 writeIfNotDefault(ts, "opacity", style->opacity(), RenderStyle::initialOpaci
ty()); |
281 if (object.isSVGShape()) { | 279 if (object.isSVGShape()) { |
282 const RenderSVGShape& shape = static_cast<const RenderSVGShape&>(object)
; | 280 const RenderSVGShape& shape = static_cast<const RenderSVGShape&>(object)
; |
283 ASSERT(shape.element()); | 281 ASSERT(shape.element()); |
284 | 282 |
285 SVGPaintDescription strokePaintDescription = RenderSVGResource::requestP
aintDescription(shape, shape.style(), ApplyToStrokeMode); | 283 SVGPaintDescription strokePaintDescription = RenderSVGResourcePaintServe
r::requestPaintDescription(shape, shape.style(), ApplyToStrokeMode); |
286 if (strokePaintDescription.isValid) { | 284 if (strokePaintDescription.isValid) { |
287 TextStreamSeparator s(" "); | 285 TextStreamSeparator s(" "); |
288 ts << " [stroke={" << s; | 286 ts << " [stroke={" << s; |
289 writeSVGPaintingResource(ts, strokePaintDescription); | 287 writeSVGPaintingResource(ts, strokePaintDescription); |
290 | 288 |
291 SVGLengthContext lengthContext(shape.element()); | 289 SVGLengthContext lengthContext(shape.element()); |
292 double dashOffset = svgStyle.strokeDashOffset()->value(lengthContext
); | 290 double dashOffset = svgStyle.strokeDashOffset()->value(lengthContext
); |
293 double strokeWidth = svgStyle.strokeWidth()->value(lengthContext); | 291 double strokeWidth = svgStyle.strokeWidth()->value(lengthContext); |
294 RefPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); | 292 RefPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); |
295 | 293 |
296 DashArray dashArray; | 294 DashArray dashArray; |
297 SVGLengthList::ConstIterator it = dashes->begin(); | 295 SVGLengthList::ConstIterator it = dashes->begin(); |
298 SVGLengthList::ConstIterator itEnd = dashes->end(); | 296 SVGLengthList::ConstIterator itEnd = dashes->end(); |
299 for (; it != itEnd; ++it) | 297 for (; it != itEnd; ++it) |
300 dashArray.append(it->value(lengthContext)); | 298 dashArray.append(it->value(lengthContext)); |
301 | 299 |
302 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f); | 300 writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f); |
303 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0); | 301 writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0); |
304 writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.
0f); | 302 writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.
0f); |
305 writeIfNotDefault(ts, "line cap", svgStyle.capStyle(), ButtCap); | 303 writeIfNotDefault(ts, "line cap", svgStyle.capStyle(), ButtCap); |
306 writeIfNotDefault(ts, "line join", svgStyle.joinStyle(), MiterJoin); | 304 writeIfNotDefault(ts, "line join", svgStyle.joinStyle(), MiterJoin); |
307 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0); | 305 writeIfNotDefault(ts, "dash offset", dashOffset, 0.0); |
308 if (!dashArray.isEmpty()) | 306 if (!dashArray.isEmpty()) |
309 writeNameValuePair(ts, "dash array", dashArray); | 307 writeNameValuePair(ts, "dash array", dashArray); |
310 | 308 |
311 ts << "}]"; | 309 ts << "}]"; |
312 } | 310 } |
313 | 311 |
314 SVGPaintDescription fillPaintDescription = RenderSVGResource::requestPai
ntDescription(shape, shape.style(), ApplyToFillMode); | 312 SVGPaintDescription fillPaintDescription = RenderSVGResourcePaintServer:
:requestPaintDescription(shape, shape.style(), ApplyToFillMode); |
315 if (fillPaintDescription.isValid) { | 313 if (fillPaintDescription.isValid) { |
316 TextStreamSeparator s(" "); | 314 TextStreamSeparator s(" "); |
317 ts << " [fill={" << s; | 315 ts << " [fill={" << s; |
318 writeSVGPaintingResource(ts, fillPaintDescription); | 316 writeSVGPaintingResource(ts, fillPaintDescription); |
319 | 317 |
320 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f); | 318 writeIfNotDefault(ts, "opacity", svgStyle.fillOpacity(), 1.0f); |
321 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), RULE_NONZERO
); | 319 writeIfNotDefault(ts, "fill rule", svgStyle.fillRule(), RULE_NONZERO
); |
322 ts << "}]"; | 320 ts << "}]"; |
323 } | 321 } |
324 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); | 322 writeIfNotDefault(ts, "clip rule", svgStyle.clipRule(), RULE_NONZERO); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 ts << " "; | 674 ts << " "; |
677 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); | 675 writeNameAndQuotedValue(ts, "filter", svgStyle.filterResource()); |
678 ts << " "; | 676 ts << " "; |
679 writeStandardPrefix(ts, *filter, 0); | 677 writeStandardPrefix(ts, *filter, 0); |
680 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; | 678 ts << " " << filter->resourceBoundingBox(&renderer) << "\n"; |
681 } | 679 } |
682 } | 680 } |
683 } | 681 } |
684 | 682 |
685 } // namespace blink | 683 } // namespace blink |
OLD | NEW |