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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 } | 365 } |
366 | 366 |
367 DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray
, const ComputedStyle& style, const SVGLengthContext& lengthContext) | 367 DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray
, const ComputedStyle& style, const SVGLengthContext& lengthContext) |
368 { | 368 { |
369 DashArray dashArray; | 369 DashArray dashArray; |
370 for (const Length& dashLength : svgDashArray.vector()) | 370 for (const Length& dashLength : svgDashArray.vector()) |
371 dashArray.append(lengthContext.valueForLength(dashLength, style)); | 371 dashArray.append(lengthContext.valueForLength(dashLength, style)); |
372 return dashArray; | 372 return dashArray; |
373 } | 373 } |
374 | 374 |
375 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons
t ComputedStyle& style, const LayoutObject& object) | 375 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons
t ComputedStyle& style, const LayoutObject& object, float dashScaleFactor) |
376 { | 376 { |
377 ASSERT(object.node()); | 377 ASSERT(object.node()); |
378 ASSERT(object.node()->isSVGElement()); | 378 ASSERT(object.node()->isSVGElement()); |
379 | 379 |
380 const SVGComputedStyle& svgStyle = style.svgStyle(); | 380 const SVGComputedStyle& svgStyle = style.svgStyle(); |
381 | 381 |
382 SVGLengthContext lengthContext(toSVGElement(object.node())); | 382 SVGLengthContext lengthContext(toSVGElement(object.node())); |
383 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth())
); | 383 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth())
); |
384 strokeData.setLineCap(svgStyle.capStyle()); | 384 strokeData.setLineCap(svgStyle.capStyle()); |
385 strokeData.setLineJoin(svgStyle.joinStyle()); | 385 strokeData.setLineJoin(svgStyle.joinStyle()); |
386 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); | 386 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); |
387 | 387 |
388 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style
, lengthContext); | 388 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style
, lengthContext); |
389 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro
keDashOffset(), style)); | 389 float dashOffset = lengthContext.valueForLength(svgStyle.strokeDashOffset(),
style); |
| 390 // Apply scaling from 'pathLength'. |
| 391 if (dashScaleFactor != 1) { |
| 392 ASSERT(dashScaleFactor >= 0); |
| 393 dashOffset *= dashScaleFactor; |
| 394 for (auto& dashItem : dashArray) |
| 395 dashItem *= dashScaleFactor; |
| 396 } |
| 397 strokeData.setLineDash(dashArray, dashOffset); |
390 } | 398 } |
391 | 399 |
392 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) | 400 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) |
393 { | 401 { |
394 ASSERT(object->isText()); | 402 ASSERT(object->isText()); |
395 // <br> is marked as text, but is not handled by the SVG layout code-path. | 403 // <br> is marked as text, but is not handled by the SVG layout code-path. |
396 return object->isSVGInlineText() && !toLayoutSVGInlineText(object)->hasEmpty
Text(); | 404 return object->isSVGInlineText() && !toLayoutSVGInlineText(object)->hasEmpty
Text(); |
397 } | 405 } |
398 | 406 |
399 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const ComputedStyl
e& style) | 407 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const ComputedStyl
e& style) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 478 |
471 // FIXME: trying to compute a device space transform at record time is wrong
. All clients | 479 // FIXME: trying to compute a device space transform at record time is wrong
. All clients |
472 // should be updated to avoid relying on this information, and the method sh
ould be removed. | 480 // should be updated to avoid relying on this information, and the method sh
ould be removed. |
473 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * Su
btreeContentTransformScope::currentContentTransformation(); | 481 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * Su
btreeContentTransformScope::currentContentTransformation(); |
474 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); | 482 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); |
475 | 483 |
476 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); | 484 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(),
2)) / 2)); |
477 } | 485 } |
478 | 486 |
479 } // namespace blink | 487 } // namespace blink |
OLD | NEW |