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

Side by Side Diff: Source/core/layout/svg/SVGLayoutSupport.cpp

Issue 962763003: Use Length for the stroke-dashoffset property in SVGLayoutStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make font-size explicit. 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 context.setMiterLimit(svgStyle.strokeMiterLimit()); 362 context.setMiterLimit(svgStyle.strokeMiterLimit());
363 363
364 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); 364 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
365 DashArray dashArray; 365 DashArray dashArray;
366 if (!dashes->isEmpty()) { 366 if (!dashes->isEmpty()) {
367 SVGLengthList::ConstIterator it = dashes->begin(); 367 SVGLengthList::ConstIterator it = dashes->begin();
368 SVGLengthList::ConstIterator itEnd = dashes->end(); 368 SVGLengthList::ConstIterator itEnd = dashes->end();
369 for (; it != itEnd; ++it) 369 for (; it != itEnd; ++it)
370 dashArray.append(it->value(lengthContext)); 370 dashArray.append(it->value(lengthContext));
371 } 371 }
372 context.setLineDash(dashArray, svgStyle.strokeDashOffset()->value(lengthCont ext)); 372 context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeD ashOffset(), style));
373 } 373 }
374 374
375 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons t LayoutStyle& style, const LayoutObject& object) 375 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons t LayoutStyle& style, const LayoutObject& object)
376 { 376 {
377 ASSERT(object.node()); 377 ASSERT(object.node());
378 ASSERT(object.node()->isSVGElement()); 378 ASSERT(object.node()->isSVGElement());
379 379
380 const SVGLayoutStyle& svgStyle = style.svgStyle(); 380 const SVGLayoutStyle& svgStyle = style.svgStyle();
381 381
382 SVGLengthContext lengthContext(toSVGElement(object.node())); 382 SVGLengthContext lengthContext(toSVGElement(object.node()));
383 strokeData.setThickness(svgStyle.strokeWidth()->value(lengthContext)); 383 strokeData.setThickness(svgStyle.strokeWidth()->value(lengthContext));
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 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray(); 388 RefPtrWillBeRawPtr<SVGLengthList> dashes = svgStyle.strokeDashArray();
389 DashArray dashArray; 389 DashArray dashArray;
390 if (!dashes->isEmpty()) { 390 if (!dashes->isEmpty()) {
391 SVGLengthList::ConstIterator it = dashes->begin(); 391 SVGLengthList::ConstIterator it = dashes->begin();
392 SVGLengthList::ConstIterator itEnd = dashes->end(); 392 SVGLengthList::ConstIterator itEnd = dashes->end();
393 for (; it != itEnd; ++it) 393 for (; it != itEnd; ++it)
394 dashArray.append(it->value(lengthContext)); 394 dashArray.append(it->value(lengthContext));
395 } 395 }
396 strokeData.setLineDash(dashArray, svgStyle.strokeDashOffset()->value(lengthC ontext)); 396 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro keDashOffset(), style));
397 } 397 }
398 398
399 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic sContextStateSaver& stateSaver, const LayoutStyle& style, LayoutObject& renderer , LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaintServ erTransform) 399 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic sContextStateSaver& stateSaver, const LayoutStyle& style, LayoutObject& renderer , LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaintServ erTransform)
400 { 400 {
401 ASSERT(paintInfo.context == stateSaver.context()); 401 ASSERT(paintInfo.context == stateSaver.context());
402 402
403 GraphicsContext& context = *paintInfo.context; 403 GraphicsContext& context = *paintInfo.context;
404 if (paintInfo.isRenderingClipPathAsMaskImage()) { 404 if (paintInfo.isRenderingClipPathAsMaskImage()) {
405 if (resourceMode == ApplyToStrokeMode) 405 if (resourceMode == ApplyToStrokeMode)
406 return false; 406 return false;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 510
511 layer = layer->parent(); 511 layer = layer->parent();
512 } 512 }
513 513
514 ctm.scale(deviceScaleFactor); 514 ctm.scale(deviceScaleFactor);
515 515
516 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2)); 516 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2));
517 } 517 }
518 518
519 } 519 }
OLDNEW
« no previous file with comments | « Source/core/layout/style/SVGLayoutStyleTest.cpp ('k') | Source/core/layout/svg/SVGLayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698