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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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) 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 LayoutStyle& style, const LayoutObject& object) 359 void SVGLayoutSupport::applyStrokeStyleToContext(GraphicsContext& context, const ComputedStyle& style, const LayoutObject& object)
360 { 360 {
361 ASSERT(object.node()); 361 ASSERT(object.node());
362 ASSERT(object.node()->isSVGElement()); 362 ASSERT(object.node()->isSVGElement());
363 363
364 const SVGLayoutStyle& svgStyle = style.svgStyle(); 364 const SVGComputedStyle& svgStyle = style.svgStyle();
365 365
366 SVGLengthContext lengthContext(toSVGElement(object.node())); 366 SVGLengthContext lengthContext(toSVGElement(object.node()));
367 context.setStrokeThickness(lengthContext.valueForLength(svgStyle.strokeWidth ())); 367 context.setStrokeThickness(lengthContext.valueForLength(svgStyle.strokeWidth ()));
368 context.setLineCap(svgStyle.capStyle()); 368 context.setLineCap(svgStyle.capStyle());
369 context.setLineJoin(svgStyle.joinStyle()); 369 context.setLineJoin(svgStyle.joinStyle());
370 context.setMiterLimit(svgStyle.strokeMiterLimit()); 370 context.setMiterLimit(svgStyle.strokeMiterLimit());
371 371
372 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style , lengthContext); 372 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style , lengthContext);
373 context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeD ashOffset(), style)); 373 context.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.strokeD ashOffset(), style));
374 } 374 }
375 375
376 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons t LayoutStyle& style, const LayoutObject& object) 376 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, cons t ComputedStyle& style, const LayoutObject& object)
377 { 377 {
378 ASSERT(object.node()); 378 ASSERT(object.node());
379 ASSERT(object.node()->isSVGElement()); 379 ASSERT(object.node()->isSVGElement());
380 380
381 const SVGLayoutStyle& svgStyle = style.svgStyle(); 381 const SVGComputedStyle& svgStyle = style.svgStyle();
382 382
383 SVGLengthContext lengthContext(toSVGElement(object.node())); 383 SVGLengthContext lengthContext(toSVGElement(object.node()));
384 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth()) ); 384 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth()) );
385 strokeData.setLineCap(svgStyle.capStyle()); 385 strokeData.setLineCap(svgStyle.capStyle());
386 strokeData.setLineJoin(svgStyle.joinStyle()); 386 strokeData.setLineJoin(svgStyle.joinStyle());
387 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); 387 strokeData.setMiterLimit(svgStyle.strokeMiterLimit());
388 388
389 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style , lengthContext); 389 DashArray dashArray = resolveSVGDashArray(*svgStyle.strokeDashArray(), style , lengthContext);
390 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro keDashOffset(), style)); 390 strokeData.setLineDash(dashArray, lengthContext.valueForLength(svgStyle.stro keDashOffset(), style));
391 } 391 }
392 392
393 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic sContextStateSaver& stateSaver, const LayoutStyle& style, LayoutObject& layoutOb ject, LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaint ServerTransform) 393 bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, Graphic sContextStateSaver& stateSaver, const ComputedStyle& style, LayoutObject& layout Object, LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPai ntServerTransform)
394 { 394 {
395 ASSERT(paintInfo.context == stateSaver.context()); 395 ASSERT(paintInfo.context == stateSaver.context());
396 396
397 GraphicsContext& context = *paintInfo.context; 397 GraphicsContext& context = *paintInfo.context;
398 if (paintInfo.isRenderingClipPathAsMaskImage()) { 398 if (paintInfo.isRenderingClipPathAsMaskImage()) {
399 if (resourceMode == ApplyToStrokeMode) 399 if (resourceMode == ApplyToStrokeMode)
400 return false; 400 return false;
401 context.setFillColor(SVGLayoutStyle::initialFillPaintColor()); 401 context.setFillColor(SVGComputedStyle::initialFillPaintColor());
402 return true; 402 return true;
403 } 403 }
404 404
405 SVGPaintServer paintServer = SVGPaintServer::requestForLayoutObject(layoutOb ject, style, resourceMode); 405 SVGPaintServer paintServer = SVGPaintServer::requestForLayoutObject(layoutOb ject, style, resourceMode);
406 if (!paintServer.isValid()) 406 if (!paintServer.isValid())
407 return false; 407 return false;
408 408
409 if (additionalPaintServerTransform && paintServer.isTransformDependent()) 409 if (additionalPaintServerTransform && paintServer.isTransformDependent())
410 paintServer.prependTransform(*additionalPaintServerTransform); 410 paintServer.prependTransform(*additionalPaintServerTransform);
411 411
412 const SVGLayoutStyle& svgStyle = style.svgStyle(); 412 const SVGComputedStyle& svgStyle = style.svgStyle();
413 float paintAlpha = resourceMode == ApplyToFillMode ? svgStyle.fillOpacity() : svgStyle.strokeOpacity(); 413 float paintAlpha = resourceMode == ApplyToFillMode ? svgStyle.fillOpacity() : svgStyle.strokeOpacity();
414 paintServer.apply(context, resourceMode, paintAlpha, stateSaver); 414 paintServer.apply(context, resourceMode, paintAlpha, stateSaver);
415 415
416 if (resourceMode == ApplyToFillMode) 416 if (resourceMode == ApplyToFillMode)
417 context.setFillRule(svgStyle.fillRule()); 417 context.setFillRule(svgStyle.fillRule());
418 else 418 else
419 applyStrokeStyleToContext(context, style, layoutObject); 419 applyStrokeStyleToContext(context, style, layoutObject);
420 420
421 return true; 421 return true;
422 } 422 }
423 423
424 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) 424 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object)
425 { 425 {
426 ASSERT(object->isText()); 426 ASSERT(object->isText());
427 // <br> is marked as text, but is not handled by the SVG layout code-path. 427 // <br> is marked as text, but is not handled by the SVG layout code-path.
428 return object->isSVGInlineText() && !toLayoutSVGInlineText(object)->hasEmpty Text(); 428 return object->isSVGInlineText() && !toLayoutSVGInlineText(object)->hasEmpty Text();
429 } 429 }
430 430
431 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const LayoutStyle& style) 431 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const ComputedStyl e& style)
432 { 432 {
433 const SVGLayoutStyle& svgStyle = style.svgStyle(); 433 const SVGComputedStyle& svgStyle = style.svgStyle();
434 434
435 return style.hasIsolation() || style.opacity() < 1 || style.hasBlendMode() 435 return style.hasIsolation() || style.opacity() < 1 || style.hasBlendMode()
436 || svgStyle.hasFilter() || svgStyle.hasMasker() || svgStyle.hasClipper() ; 436 || svgStyle.hasFilter() || svgStyle.hasMasker() || svgStyle.hasClipper() ;
437 } 437 }
438 438
439 bool SVGLayoutSupport::willIsolateBlendingDescendantsForObject(const LayoutObjec t* object) 439 bool SVGLayoutSupport::willIsolateBlendingDescendantsForObject(const LayoutObjec t* object)
440 { 440 {
441 if (object->isSVGHiddenContainer()) 441 if (object->isSVGHiddenContainer())
442 return false; 442 return false;
443 if (!object->isSVGRoot() && !object->isSVGContainer()) 443 if (!object->isSVGRoot() && !object->isSVGContainer())
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 layer = layer->parent(); 505 layer = layer->parent();
506 } 506 }
507 507
508 ctm.scale(deviceScaleFactor); 508 ctm.scale(deviceScaleFactor);
509 509
510 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));
511 } 511 }
512 512
513 } 513 }
OLDNEW
« no previous file with comments | « Source/core/layout/svg/SVGLayoutSupport.h ('k') | Source/core/layout/svg/SVGLayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698