Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1423)

Unified Diff: Source/core/layout/svg/SVGLayoutSupport.cpp

Issue 975733002: Use Length for the stroke-dasharray property in SVGLayoutStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test for style-change responsive-ness. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/svg/SVGLayoutSupport.cpp
diff --git a/Source/core/layout/svg/SVGLayoutSupport.cpp b/Source/core/layout/svg/SVGLayoutSupport.cpp
index bd23d623207fc8da4fa8770a062ed7f5a95d49d0..c9c11fe84f29394d932724f66df6fbc5f39f4a52 100644
--- a/Source/core/layout/svg/SVGLayoutSupport.cpp
+++ b/Source/core/layout/svg/SVGLayoutSupport.cpp
@@ -348,6 +348,14 @@ bool SVGLayoutSupport::transformToUserSpaceAndCheckClipping(LayoutObject* object
return pointInClippingArea(object, localPoint);
}
+DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray, const LayoutStyle& style, const SVGLengthContext& lengthContext)
+{
+ DashArray dashArray;
+ for (const Length& dashLength : svgDashArray.vector())
+ dashArray.append(lengthContext.valueForLength(dashLength, style));
+ return dashArray;
+}
+
void SVGLayoutSupport::applyStrokeStyleToContext(GraphicsContext& context, const LayoutStyle& style, const LayoutObject& object)
{
ASSERT(object.node());
@@ -361,14 +369,7 @@ void SVGLayoutSupport::applyStrokeStyleToContext(GraphicsContext& context, const
context.setLineJoin(svgStyle.joinStyle());
context.setMiterLimit(svgStyle.strokeMiterLimit());
- RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
- DashArray dashArray;
- if (!dashes->isEmpty()) {
- SVGLengthList::ConstIterator it = dashes->begin();
- SVGLengthList::ConstIterator itEnd = dashes->end();
- for (; it != itEnd; ++it)
- dashArray.append(it->value(lengthContext));
- }
+ DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style, lengthContext);
pdr. 2015/03/05 21:35:59 Can we save an unnecessary copy by using a const r
fs 2015/03/06 11:27:46 There's no unnecessary copy here - for the instanc
context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeDashOffset(), style));
}
@@ -385,14 +386,7 @@ void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons
strokeData.setLineJoin(svgStyle.joinStyle());
strokeData.setMiterLimit(svgStyle.strokeMiterLimit());
- RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
- DashArray dashArray;
- if (!dashes->isEmpty()) {
- SVGLengthList::ConstIterator it = dashes->begin();
- SVGLengthList::ConstIterator itEnd = dashes->end();
- for (; it != itEnd; ++it)
- dashArray.append(it->value(lengthContext));
- }
+ DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style, lengthContext);
strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeDashOffset(), style));
}

Powered by Google App Engine
This is Rietveld 408576698