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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGSVGElement.cpp

Issue 1685353004: Clean up Image::computeIntrinsicDimensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2014 Google, Inc. 5 * Copyright (C) 2014 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 FloatRect useViewBox = viewBox()->currentValue()->value(); 602 FloatRect useViewBox = viewBox()->currentValue()->value();
603 if (!useViewBox.isEmpty()) 603 if (!useViewBox.isEmpty())
604 return useViewBox; 604 return useViewBox;
605 if (!layoutObject() || !layoutObject()->isSVGRoot()) 605 if (!layoutObject() || !layoutObject()->isSVGRoot())
606 return FloatRect(); 606 return FloatRect();
607 if (!toLayoutSVGRoot(layoutObject())->isEmbeddedThroughSVGImage()) 607 if (!toLayoutSVGRoot(layoutObject())->isEmbeddedThroughSVGImage())
608 return FloatRect(); 608 return FloatRect();
609 609
610 // If no viewBox is specified but non-relative width/height values, then we 610 // If no viewBox is specified but non-relative width/height values, then we
611 // should always synthesize a viewBox if we're embedded through a SVGImage. 611 // should always synthesize a viewBox if we're embedded through a SVGImage.
612 return FloatRect(FloatPoint(), FloatSize(floatValueForLength(intrinsicWidth( ), 0), floatValueForLength(intrinsicHeight(), 0))); 612 return FloatRect(FloatPoint(), FloatSize(intrinsicWidth(), intrinsicHeight() ));
613 } 613 }
614 614
615 FloatSize SVGSVGElement::currentViewportSize() const 615 FloatSize SVGSVGElement::currentViewportSize() const
616 { 616 {
617 if (!layoutObject()) 617 if (!layoutObject())
618 return FloatSize(); 618 return FloatSize();
619 619
620 if (layoutObject()->isSVGRoot()) { 620 if (layoutObject()->isSVGRoot()) {
621 LayoutRect contentBoxRect = toLayoutSVGRoot(layoutObject())->contentBoxR ect(); 621 LayoutRect contentBoxRect = toLayoutSVGRoot(layoutObject())->contentBoxR ect();
622 return FloatSize(contentBoxRect.width() / layoutObject()->style()->effec tiveZoom(), contentBoxRect.height() / layoutObject()->style()->effectiveZoom()); 622 return FloatSize(contentBoxRect.width() / layoutObject()->style()->effec tiveZoom(), contentBoxRect.height() / layoutObject()->style()->effectiveZoom());
623 } 623 }
624 624
625 FloatRect viewportRect = toLayoutSVGViewportContainer(layoutObject())->viewp ort(); 625 FloatRect viewportRect = toLayoutSVGViewportContainer(layoutObject())->viewp ort();
626 return FloatSize(viewportRect.width(), viewportRect.height()); 626 return FloatSize(viewportRect.width(), viewportRect.height());
627 } 627 }
628 628
629 bool SVGSVGElement::hasIntrinsicWidth() const 629 bool SVGSVGElement::hasIntrinsicWidth() const
630 { 630 {
631 return width()->currentValue()->typeWithCalcResolved() != CSSPrimitiveValue: :UnitType::Percentage; 631 return width()->currentValue()->typeWithCalcResolved() != CSSPrimitiveValue: :UnitType::Percentage;
632 } 632 }
633 633
634 bool SVGSVGElement::hasIntrinsicHeight() const 634 bool SVGSVGElement::hasIntrinsicHeight() const
635 { 635 {
636 return height()->currentValue()->typeWithCalcResolved() != CSSPrimitiveValue ::UnitType::Percentage; 636 return height()->currentValue()->typeWithCalcResolved() != CSSPrimitiveValue ::UnitType::Percentage;
637 } 637 }
638 638
639 Length SVGSVGElement::intrinsicWidth() const 639 float SVGSVGElement::intrinsicWidth() const
640 { 640 {
641 if (width()->currentValue()->typeWithCalcResolved() == CSSPrimitiveValue::Un itType::Percentage) 641 if (width()->currentValue()->typeWithCalcResolved() == CSSPrimitiveValue::Un itType::Percentage)
642 return Length(0, Fixed); 642 return 0;
643 643
644 SVGLengthContext lengthContext(this); 644 SVGLengthContext lengthContext(this);
645 return Length(width()->currentValue()->value(lengthContext), Fixed); 645 return width()->currentValue()->value(lengthContext);
646 } 646 }
647 647
648 Length SVGSVGElement::intrinsicHeight() const 648 float SVGSVGElement::intrinsicHeight() const
649 { 649 {
650 if (height()->currentValue()->typeWithCalcResolved() == CSSPrimitiveValue::U nitType::Percentage) 650 if (height()->currentValue()->typeWithCalcResolved() == CSSPrimitiveValue::U nitType::Percentage)
651 return Length(0, Fixed); 651 return 0;
652 652
653 SVGLengthContext lengthContext(this); 653 SVGLengthContext lengthContext(this);
654 return Length(height()->currentValue()->value(lengthContext), Fixed); 654 return height()->currentValue()->value(lengthContext);
655 } 655 }
656 656
657 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie wHeight) const 657 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie wHeight) const
658 { 658 {
659 if (!m_useCurrentView || !m_viewSpec) 659 if (!m_useCurrentView || !m_viewSpec)
660 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre serveAspectRatio()->currentValue(), viewWidth, viewHeight); 660 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre serveAspectRatio()->currentValue(), viewWidth, viewHeight);
661 661
662 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight ); 662 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight );
663 RefPtrWillBeRawPtr<SVGTransformList> transformList = m_viewSpec->transform() ; 663 RefPtrWillBeRawPtr<SVGTransformList> transformList = m_viewSpec->transform() ;
664 if (transformList->isEmpty()) 664 if (transformList->isEmpty())
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 visitor->trace(m_width); 759 visitor->trace(m_width);
760 visitor->trace(m_height); 760 visitor->trace(m_height);
761 visitor->trace(m_translation); 761 visitor->trace(m_translation);
762 visitor->trace(m_timeContainer); 762 visitor->trace(m_timeContainer);
763 visitor->trace(m_viewSpec); 763 visitor->trace(m_viewSpec);
764 SVGGraphicsElement::trace(visitor); 764 SVGGraphicsElement::trace(visitor);
765 SVGFitToViewBox::trace(visitor); 765 SVGFitToViewBox::trace(visitor);
766 } 766 }
767 767
768 } // namespace blink 768 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGSVGElement.h ('k') | third_party/WebKit/Source/core/svg/graphics/SVGImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698