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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 static AffineTransform viewBoxToViewTransform(const FloatRect& viewBoxRect,
PassRefPtr<SVGPreserveAspectRatio>, float viewWidth, float viewHeight); | 48 static AffineTransform viewBoxToViewTransform(const FloatRect& viewBoxRect,
PassRefPtr<SVGPreserveAspectRatio>, float viewWidth, float viewHeight); |
49 | 49 |
50 static bool isKnownAttribute(const QualifiedName&); | 50 static bool isKnownAttribute(const QualifiedName&); |
51 static void addSupportedAttributes(HashSet<QualifiedName>&); | 51 static void addSupportedAttributes(HashSet<QualifiedName>&); |
52 | 52 |
53 bool parseAttribute(const QualifiedName& name, const AtomicString& value, Do
cument& document, SVGParsingError& parseError) | 53 bool parseAttribute(const QualifiedName& name, const AtomicString& value, Do
cument& document, SVGParsingError& parseError) |
54 { | 54 { |
55 if (name == SVGNames::viewBoxAttr) { | 55 if (name == SVGNames::viewBoxAttr) { |
56 m_viewBox->setBaseValueAsString(value, parseError); | 56 m_viewBox->setBaseValueAsString(value, parseError); |
57 if (m_viewBox->baseValue()->width() < 0.0f) { | |
58 document.accessSVGExtensions().reportError("A negative value for
ViewBox width is not allowed"); | |
59 m_viewBox->baseValue()->setInvalid(); | |
60 } | |
61 if (m_viewBox->baseValue()->height() < 0.0f) { | |
62 document.accessSVGExtensions().reportError("A negative value for
ViewBox height is not allowed"); | |
63 m_viewBox->baseValue()->setInvalid(); | |
64 } | |
65 return true; | 57 return true; |
66 } | 58 } |
67 if (name == SVGNames::preserveAspectRatioAttr) { | 59 if (name == SVGNames::preserveAspectRatioAttr) { |
68 m_preserveAspectRatio->setBaseValueAsString(value, parseError); | 60 m_preserveAspectRatio->setBaseValueAsString(value, parseError); |
69 return true; | 61 return true; |
70 } | 62 } |
71 return false; | 63 return false; |
72 } | 64 } |
73 | 65 |
74 bool hasEmptyViewBox() const { return m_viewBox->currentValue()->isValid() &
& m_viewBox->currentValue()->value().isEmpty(); } | 66 bool hasEmptyViewBox() const { return m_viewBox->currentValue()->isValid() &
& m_viewBox->currentValue()->value().isEmpty(); } |
75 | 67 |
76 // JS API | 68 // JS API |
77 SVGAnimatedRect* viewBox() const { return m_viewBox.get(); } | 69 SVGAnimatedRect* viewBox() const { return m_viewBox.get(); } |
78 SVGAnimatedPreserveAspectRatio* preserveAspectRatio() const { return m_prese
rveAspectRatio.get(); } | 70 SVGAnimatedPreserveAspectRatio* preserveAspectRatio() const { return m_prese
rveAspectRatio.get(); } |
79 | 71 |
80 protected: | 72 protected: |
81 explicit SVGFitToViewBox(SVGElement*, PropertyMapPolicy = PropertyMapPolicyA
dd); | 73 explicit SVGFitToViewBox(SVGElement*, PropertyMapPolicy = PropertyMapPolicyA
dd); |
82 void updateViewBox(const FloatRect&); | 74 void updateViewBox(const FloatRect&); |
83 void clearViewBox() { m_viewBox = nullptr; } | 75 void clearViewBox() { m_viewBox = nullptr; } |
84 void clearPreserveAspectRatio() { m_preserveAspectRatio = nullptr; } | 76 void clearPreserveAspectRatio() { m_preserveAspectRatio = nullptr; } |
85 | 77 |
86 private: | 78 private: |
87 RefPtr<SVGAnimatedRect> m_viewBox; | 79 RefPtr<SVGAnimatedRect> m_viewBox; |
88 RefPtr<SVGAnimatedPreserveAspectRatio> m_preserveAspectRatio; | 80 RefPtr<SVGAnimatedPreserveAspectRatio> m_preserveAspectRatio; |
89 }; | 81 }; |
90 | 82 |
91 } // namespace blink | 83 } // namespace blink |
92 | 84 |
93 #endif // SVGFitToViewBox_h | 85 #endif // SVGFitToViewBox_h |
OLD | NEW |