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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 342
343 bool SVGLayoutSupport::transformToUserSpaceAndCheckClipping(LayoutObject* object , const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatP oint& localPoint) 343 bool SVGLayoutSupport::transformToUserSpaceAndCheckClipping(LayoutObject* object , const AffineTransform& localTransform, const FloatPoint& pointInParent, FloatP oint& localPoint)
344 { 344 {
345 if (!localTransform.isInvertible()) 345 if (!localTransform.isInvertible())
346 return false; 346 return false;
347 localPoint = localTransform.inverse().mapPoint(pointInParent); 347 localPoint = localTransform.inverse().mapPoint(pointInParent);
348 return pointInClippingArea(object, localPoint); 348 return pointInClippingArea(object, localPoint);
349 } 349 }
350 350
351 DashArray SVGLayoutSupport::resolveSVGDashArray(const SVGDashArray& svgDashArray , const LayoutStyle& style, const SVGLengthContext& lengthContext)
352 {
353 DashArray dashArray;
354 for (const Length& dashLength : svgDashArray.vector())
355 dashArray.append(lengthContext.valueForLength(dashLength, style));
356 return dashArray;
357 }
358
351 void SVGLayoutSupport::applyStrokeStyleToContext(GraphicsContext& context, const LayoutStyle& style, const LayoutObject& object) 359 void SVGLayoutSupport::applyStrokeStyleToContext(GraphicsContext& context, const LayoutStyle& style, const LayoutObject& object)
352 { 360 {
353 ASSERT(object.node()); 361 ASSERT(object.node());
354 ASSERT(object.node()->isSVGElement()); 362 ASSERT(object.node()->isSVGElement());
355 363
356 const SVGLayoutStyle& svgStyle = style.svgStyle(); 364 const SVGLayoutStyle& svgStyle = style.svgStyle();
357 365
358 SVGLengthContext lengthContext(toSVGElement(object.node())); 366 SVGLengthContext lengthContext(toSVGElement(object.node()));
359 context.setStrokeThickness(svgStyle.strokeWidth()->value(lengthContext)); 367 context.setStrokeThickness(svgStyle.strokeWidth()->value(lengthContext));
360 context.setLineCap(svgStyle.capStyle()); 368 context.setLineCap(svgStyle.capStyle());
361 context.setLineJoin(svgStyle.joinStyle()); 369 context.setLineJoin(svgStyle.joinStyle());
362 context.setMiterLimit(svgStyle.strokeMiterLimit()); 370 context.setMiterLimit(svgStyle.strokeMiterLimit());
363 371
364 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); 372 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
365 DashArray dashArray;
366 if (!dashes->isEmpty()) {
367 SVGLengthList::ConstIterator it = dashes->begin();
368 SVGLengthList::ConstIterator itEnd = dashes->end();
369 for (; it != itEnd; ++it)
370 dashArray.append(it->value(lengthContext));
371 }
372 context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeD ashOffset(), style)); 373 context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeD ashOffset(), style));
373 } 374 }
374 375
375 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons t LayoutStyle& style, const LayoutObject& object) 376 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons t LayoutStyle& style, const LayoutObject& object)
376 { 377 {
377 ASSERT(object.node()); 378 ASSERT(object.node());
378 ASSERT(object.node()->isSVGElement()); 379 ASSERT(object.node()->isSVGElement());
379 380
380 const SVGLayoutStyle& svgStyle = style.svgStyle(); 381 const SVGLayoutStyle& svgStyle = style.svgStyle();
381 382
382 SVGLengthContext lengthContext(toSVGElement(object.node())); 383 SVGLengthContext lengthContext(toSVGElement(object.node()));
383 strokeData.setThickness(svgStyle.strokeWidth()->value(lengthContext)); 384 strokeData.setThickness(svgStyle.strokeWidth()->value(lengthContext));
384 strokeData.setLineCap(svgStyle.capStyle()); 385 strokeData.setLineCap(svgStyle.capStyle());
385 strokeData.setLineJoin(svgStyle.joinStyle()); 386 strokeData.setLineJoin(svgStyle.joinStyle());
386 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); 387 strokeData.setMiterLimit(svgStyle.strokeMiterLimit());
387 388
388 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); 389 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style , lengthContext);
389 DashArray dashArray;
390 if (!dashes->isEmpty()) {
391 SVGLengthList::ConstIterator it = dashes->begin();
392 SVGLengthList::ConstIterator itEnd = dashes->end();
393 for (; it != itEnd; ++it)
394 dashArray.append(it->value(lengthContext));
395 }
396 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro keDashOffset(), style)); 390 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro keDashOffset(), style));
397 } 391 }
398 392
399 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic sContextStateSaver& stateSaver, const LayoutStyle& style, LayoutObject& renderer , LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaintServ erTransform) 393 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic sContextStateSaver& stateSaver, const LayoutStyle& style, LayoutObject& renderer , LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaintServ erTransform)
400 { 394 {
401 ASSERT(paintInfo.context == stateSaver.context()); 395 ASSERT(paintInfo.context == stateSaver.context());
402 396
403 GraphicsContext& context = *paintInfo.context; 397 GraphicsContext& context = *paintInfo.context;
404 if (paintInfo.isRenderingClipPathAsMaskImage()) { 398 if (paintInfo.isRenderingClipPathAsMaskImage()) {
405 if (resourceMode == ApplyToStrokeMode) 399 if (resourceMode == ApplyToStrokeMode)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 504
511 layer = layer->parent(); 505 layer = layer->parent();
512 } 506 }
513 507
514 ctm.scale(deviceScaleFactor); 508 ctm.scale(deviceScaleFactor);
515 509
516 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2)); 510 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2));
517 } 511 }
518 512
519 } 513 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698