| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #include "core/SVGNames.h" | 25 #include "core/SVGNames.h" |
| 26 #include "core/dom/Document.h" | 26 #include "core/dom/Document.h" |
| 27 #include "core/dom/QualifiedName.h" | 27 #include "core/dom/QualifiedName.h" |
| 28 #include "core/svg/SVGAnimatedPreserveAspectRatio.h" | 28 #include "core/svg/SVGAnimatedPreserveAspectRatio.h" |
| 29 #include "core/svg/SVGAnimatedRect.h" | 29 #include "core/svg/SVGAnimatedRect.h" |
| 30 #include "core/svg/SVGDocumentExtensions.h" | 30 #include "core/svg/SVGDocumentExtensions.h" |
| 31 #include "core/svg/SVGParsingError.h" | 31 #include "core/svg/SVGParsingError.h" |
| 32 #include "core/svg/SVGPreserveAspectRatio.h" | 32 #include "core/svg/SVGPreserveAspectRatio.h" |
| 33 #include "core/svg/SVGRect.h" | 33 #include "core/svg/SVGRect.h" |
| 34 #include "platform/heap/Handle.h" |
| 34 #include "wtf/HashSet.h" | 35 #include "wtf/HashSet.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 class AffineTransform; | 39 class AffineTransform; |
| 39 class Document; | 40 class Document; |
| 40 | 41 |
| 41 class SVGFitToViewBox { | 42 class SVGFitToViewBox : public WillBeGarbageCollectedMixin { |
| 42 public: | 43 public: |
| 43 enum PropertyMapPolicy { | 44 enum PropertyMapPolicy { |
| 44 PropertyMapPolicyAdd, | 45 PropertyMapPolicyAdd, |
| 45 PropertyMapPolicySkip, | 46 PropertyMapPolicySkip, |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 static AffineTransform viewBoxToViewTransform(const FloatRect& viewBoxRect,
PassRefPtr<SVGPreserveAspectRatio>, float viewWidth, float viewHeight); | 49 static AffineTransform viewBoxToViewTransform(const FloatRect& viewBoxRect,
PassRefPtrWillBeRawPtr<SVGPreserveAspectRatio>, float viewWidth, float viewHeigh
t); |
| 49 | 50 |
| 50 static bool isKnownAttribute(const QualifiedName&); | 51 static bool isKnownAttribute(const QualifiedName&); |
| 51 static void addSupportedAttributes(HashSet<QualifiedName>&); | 52 static void addSupportedAttributes(HashSet<QualifiedName>&); |
| 52 | 53 |
| 53 bool parseAttribute(const QualifiedName& name, const AtomicString& value, Do
cument& document, SVGParsingError& parseError) | 54 bool parseAttribute(const QualifiedName& name, const AtomicString& value, Do
cument& document, SVGParsingError& parseError) |
| 54 { | 55 { |
| 55 if (name == SVGNames::viewBoxAttr) { | 56 if (name == SVGNames::viewBoxAttr) { |
| 56 m_viewBox->setBaseValueAsString(value, parseError); | 57 m_viewBox->setBaseValueAsString(value, parseError); |
| 57 return true; | 58 return true; |
| 58 } | 59 } |
| 59 if (name == SVGNames::preserveAspectRatioAttr) { | 60 if (name == SVGNames::preserveAspectRatioAttr) { |
| 60 m_preserveAspectRatio->setBaseValueAsString(value, parseError); | 61 m_preserveAspectRatio->setBaseValueAsString(value, parseError); |
| 61 return true; | 62 return true; |
| 62 } | 63 } |
| 63 return false; | 64 return false; |
| 64 } | 65 } |
| 65 | 66 |
| 66 bool hasEmptyViewBox() const { return m_viewBox->currentValue()->isValid() &
& m_viewBox->currentValue()->value().isEmpty(); } | 67 bool hasEmptyViewBox() const { return m_viewBox->currentValue()->isValid() &
& m_viewBox->currentValue()->value().isEmpty(); } |
| 67 | 68 |
| 68 // JS API | 69 // JS API |
| 69 SVGAnimatedRect* viewBox() const { return m_viewBox.get(); } | 70 SVGAnimatedRect* viewBox() const { return m_viewBox.get(); } |
| 70 SVGAnimatedPreserveAspectRatio* preserveAspectRatio() const { return m_prese
rveAspectRatio.get(); } | 71 SVGAnimatedPreserveAspectRatio* preserveAspectRatio() const { return m_prese
rveAspectRatio.get(); } |
| 71 | 72 |
| 73 virtual void trace(Visitor*); |
| 74 |
| 72 protected: | 75 protected: |
| 73 explicit SVGFitToViewBox(SVGElement*, PropertyMapPolicy = PropertyMapPolicyA
dd); | 76 explicit SVGFitToViewBox(SVGElement*, PropertyMapPolicy = PropertyMapPolicyA
dd); |
| 74 void updateViewBox(const FloatRect&); | 77 void updateViewBox(const FloatRect&); |
| 75 void clearViewBox() { m_viewBox = nullptr; } | 78 void clearViewBox() { m_viewBox = nullptr; } |
| 76 void clearPreserveAspectRatio() { m_preserveAspectRatio = nullptr; } | 79 void clearPreserveAspectRatio() { m_preserveAspectRatio = nullptr; } |
| 77 | 80 |
| 78 private: | 81 private: |
| 79 RefPtr<SVGAnimatedRect> m_viewBox; | 82 RefPtrWillBeMember<SVGAnimatedRect> m_viewBox; |
| 80 RefPtr<SVGAnimatedPreserveAspectRatio> m_preserveAspectRatio; | 83 RefPtrWillBeMember<SVGAnimatedPreserveAspectRatio> m_preserveAspectRatio; |
| 81 }; | 84 }; |
| 82 | 85 |
| 83 } // namespace blink | 86 } // namespace blink |
| 84 | 87 |
| 85 #endif // SVGFitToViewBox_h | 88 #endif // SVGFitToViewBox_h |
| OLD | NEW |