OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 349 } |
350 | 350 |
351 DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray
, const ComputedStyle& style, const SVGLengthContext& lengthContext) | 351 DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray
, const ComputedStyle& style, const SVGLengthContext& lengthContext) |
352 { | 352 { |
353 DashArray dashArray; | 353 DashArray dashArray; |
354 for (const Length& dashLength : svgDashArray.vector()) | 354 for (const Length& dashLength : svgDashArray.vector()) |
355 dashArray.append(lengthContext.valueForLength(dashLength, style)); | 355 dashArray.append(lengthContext.valueForLength(dashLength, style)); |
356 return dashArray; | 356 return dashArray; |
357 } | 357 } |
358 | 358 |
359 void SVGLayoutSupport::applyStrokeStyleToContext(GraphicsContext& context, const
ComputedStyle& style, const LayoutObject& object) | |
360 { | |
361 ASSERT(object.node()); | |
362 ASSERT(object.node()->isSVGElement()); | |
363 | |
364 const SVGComputedStyle& svgStyle = style.svgStyle(); | |
365 | |
366 SVGLengthContext lengthContext(toSVGElement(object.node())); | |
367 context.setStrokeThickness(lengthContext.valueForLength(svgStyle.strokeWidth
())); | |
368 context.setLineCap(svgStyle.capStyle()); | |
369 context.setLineJoin(svgStyle.joinStyle()); | |
370 context.setMiterLimit(svgStyle.strokeMiterLimit()); | |
371 | |
372 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style
, lengthContext); | |
373 context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeD
ashOffset(), style)); | |
374 } | |
375 | |
376 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons
t ComputedStyle& style, const LayoutObject& object) | 359 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons
t ComputedStyle& style, const LayoutObject& object) |
377 { | 360 { |
378 ASSERT(object.node()); | 361 ASSERT(object.node()); |
379 ASSERT(object.node()->isSVGElement()); | 362 ASSERT(object.node()->isSVGElement()); |
380 | 363 |
381 const SVGComputedStyle& svgStyle = style.svgStyle(); | 364 const SVGComputedStyle& svgStyle = style.svgStyle(); |
382 | 365 |
383 SVGLengthContext lengthContext(toSVGElement(object.node())); | 366 SVGLengthContext lengthContext(toSVGElement(object.node())); |
384 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth())
); | 367 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth())
); |
385 strokeData.setLineCap(svgStyle.capStyle()); | 368 strokeData.setLineCap(svgStyle.capStyle()); |
386 strokeData.setLineJoin(svgStyle.joinStyle()); | 369 strokeData.setLineJoin(svgStyle.joinStyle()); |
387 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); | 370 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); |
388 | 371 |
389 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style
, lengthContext); | 372 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style
, lengthContext); |
390 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro
keDashOffset(), style)); | 373 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro
keDashOffset(), style)); |
391 } | 374 } |
392 | 375 |
393 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic
sContextStateSaver& stateSaver, const ComputedStyle& style, LayoutObject& layout
Object, LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPai
ntServerTransform) | |
394 { | |
395 ASSERT(paintInfo.context == stateSaver.context()); | |
396 | |
397 GraphicsContext& context = *paintInfo.context; | |
398 if (paintInfo.isRenderingClipPathAsMaskImage()) { | |
399 if (resourceMode == ApplyToStrokeMode) | |
400 return false; | |
401 context.setFillColor(SVGComputedStyle::initialFillPaintColor()); | |
402 return true; | |
403 } | |
404 | |
405 SVGPaintServer paintServer = SVGPaintServer::requestForLayoutObject(layoutOb
ject, style, resourceMode); | |
406 if (!paintServer.isValid()) | |
407 return false; | |
408 | |
409 if (additionalPaintServerTransform && paintServer.isTransformDependent()) | |
410 paintServer.prependTransform(*additionalPaintServerTransform); | |
411 | |
412 const SVGComputedStyle& svgStyle = style.svgStyle(); | |
413 float paintAlpha = resourceMode == ApplyToFillMode ? svgStyle.fillOpacity()
: svgStyle.strokeOpacity(); | |
414 paintServer.apply(context, resourceMode, paintAlpha, stateSaver); | |
415 | |
416 if (resourceMode == ApplyToFillMode) | |
417 context.setFillRule(svgStyle.fillRule()); | |
418 else | |
419 applyStrokeStyleToContext(context, style, layoutObject); | |
420 | |
421 return true; | |
422 } | |
423 | |
424 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) | 376 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) |
425 { | 377 { |
426 ASSERT(object->isText()); | 378 ASSERT(object->isText()); |
427 // <br> is marked as text, but is not handled by the SVG layout code-path. | 379 // <br> is marked as text, but is not handled by the SVG layout code-path. |
428 return object->isSVGInlineText() && !toLayoutSVGInlineText(object)->hasEmpty
Text(); | 380 return object->isSVGInlineText() && !toLayoutSVGInlineText(object)->hasEmpty
Text(); |
429 } | 381 } |
430 | 382 |
431 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const ComputedStyl
e& style) | 383 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const ComputedStyl
e& style) |
432 { | 384 { |
433 const SVGComputedStyle& svgStyle = style.svgStyle(); | 385 const SVGComputedStyle& svgStyle = style.svgStyle(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 456 |
505 layer = layer->parent(); | 457 layer = layer->parent(); |
506 } | 458 } |
507 | 459 |
508 ctm.scale(deviceScaleFactor); | 460 ctm.scale(deviceScaleFactor); |
509 | 461 |
510 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); | 462 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); |
511 } | 463 } |
512 | 464 |
513 } | 465 } |
OLD | NEW |