| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 4 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "core/svg/SVGElement.h" | 28 #include "core/svg/SVGElement.h" |
| 29 #include "core/svg/SVGParserUtilities.h" | 29 #include "core/svg/SVGParserUtilities.h" |
| 30 #include "platform/geometry/FloatRect.h" | 30 #include "platform/geometry/FloatRect.h" |
| 31 #include "platform/transforms/AffineTransform.h" | 31 #include "platform/transforms/AffineTransform.h" |
| 32 #include "wtf/text/StringImpl.h" | 32 #include "wtf/text/StringImpl.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class SVGAnimatedViewBoxRect : public SVGAnimatedRect { | 36 class SVGAnimatedViewBoxRect : public SVGAnimatedRect { |
| 37 public: | 37 public: |
| 38 static PassRefPtr<SVGAnimatedRect> create(SVGElement* contextElement) | 38 static PassRefPtrWillBeRawPtr<SVGAnimatedRect> create(SVGElement* contextEle
ment) |
| 39 { | 39 { |
| 40 return adoptRef(new SVGAnimatedViewBoxRect(contextElement)); | 40 return adoptRefWillBeNoop(new SVGAnimatedViewBoxRect(contextElement)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void setBaseValueAsString(const String&, SVGParsingError&) override; | 43 void setBaseValueAsString(const String&, SVGParsingError&) override; |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 SVGAnimatedViewBoxRect(SVGElement* contextElement) | 46 SVGAnimatedViewBoxRect(SVGElement* contextElement) |
| 47 : SVGAnimatedRect(contextElement, SVGNames::viewBoxAttr) | 47 : SVGAnimatedRect(contextElement, SVGNames::viewBoxAttr) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 }; | 50 }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 70 : m_viewBox(SVGAnimatedViewBoxRect::create(element)) | 70 : m_viewBox(SVGAnimatedViewBoxRect::create(element)) |
| 71 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(element, SVGN
ames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 71 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(element, SVGN
ames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
| 72 { | 72 { |
| 73 ASSERT(element); | 73 ASSERT(element); |
| 74 if (propertyMapPolicy == PropertyMapPolicyAdd) { | 74 if (propertyMapPolicy == PropertyMapPolicyAdd) { |
| 75 element->addToPropertyMap(m_viewBox); | 75 element->addToPropertyMap(m_viewBox); |
| 76 element->addToPropertyMap(m_preserveAspectRatio); | 76 element->addToPropertyMap(m_preserveAspectRatio); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 AffineTransform SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBox
Rect, PassRefPtr<SVGPreserveAspectRatio> preserveAspectRatio, float viewWidth, f
loat viewHeight) | 80 void SVGFitToViewBox::trace(Visitor* visitor) |
| 81 { |
| 82 visitor->trace(m_viewBox); |
| 83 visitor->trace(m_preserveAspectRatio); |
| 84 } |
| 85 |
| 86 AffineTransform SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBox
Rect, PassRefPtrWillBeRawPtr<SVGPreserveAspectRatio> preserveAspectRatio, float
viewWidth, float viewHeight) |
| 81 { | 87 { |
| 82 if (!viewBoxRect.width() || !viewBoxRect.height() || !viewWidth || !viewHeig
ht) | 88 if (!viewBoxRect.width() || !viewBoxRect.height() || !viewWidth || !viewHeig
ht) |
| 83 return AffineTransform(); | 89 return AffineTransform(); |
| 84 | 90 |
| 85 return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBox
Rect.width(), viewBoxRect.height(), viewWidth, viewHeight); | 91 return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBox
Rect.width(), viewBoxRect.height(), viewWidth, viewHeight); |
| 86 } | 92 } |
| 87 | 93 |
| 88 bool SVGFitToViewBox::isKnownAttribute(const QualifiedName& attrName) | 94 bool SVGFitToViewBox::isKnownAttribute(const QualifiedName& attrName) |
| 89 { | 95 { |
| 90 return attrName == SVGNames::viewBoxAttr || attrName == SVGNames::preserveAs
pectRatioAttr; | 96 return attrName == SVGNames::viewBoxAttr || attrName == SVGNames::preserveAs
pectRatioAttr; |
| 91 } | 97 } |
| 92 | 98 |
| 93 void SVGFitToViewBox::addSupportedAttributes(HashSet<QualifiedName>& supportedAt
tributes) | 99 void SVGFitToViewBox::addSupportedAttributes(HashSet<QualifiedName>& supportedAt
tributes) |
| 94 { | 100 { |
| 95 supportedAttributes.add(SVGNames::viewBoxAttr); | 101 supportedAttributes.add(SVGNames::viewBoxAttr); |
| 96 supportedAttributes.add(SVGNames::preserveAspectRatioAttr); | 102 supportedAttributes.add(SVGNames::preserveAspectRatioAttr); |
| 97 } | 103 } |
| 98 | 104 |
| 99 void SVGFitToViewBox::updateViewBox(const FloatRect& rect) | 105 void SVGFitToViewBox::updateViewBox(const FloatRect& rect) |
| 100 { | 106 { |
| 101 ASSERT(m_viewBox); | 107 ASSERT(m_viewBox); |
| 102 m_viewBox->baseValue()->setValue(rect); | 108 m_viewBox->baseValue()->setValue(rect); |
| 103 } | 109 } |
| 104 | 110 |
| 105 } | 111 } |
| OLD | NEW |