diff options
Diffstat (limited to 'WebCore/svg/SVGPreserveAspectRatio.h')
-rw-r--r-- | WebCore/svg/SVGPreserveAspectRatio.h | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h index 18a89dd..2be053c 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.h +++ b/WebCore/svg/SVGPreserveAspectRatio.h @@ -22,21 +22,17 @@ #define SVGPreserveAspectRatio_h #if ENABLE(SVG) +#include "FloatRect.h" #include "PlatformString.h" #include "SVGNames.h" -#include <wtf/RefCounted.h> - namespace WebCore { class String; class TransformationMatrix; - class SVGStyledElement; - class SVGPreserveAspectRatio : public RefCounted<SVGPreserveAspectRatio> { + class SVGPreserveAspectRatio { public: - static PassRefPtr<SVGPreserveAspectRatio> create() { return adoptRef(new SVGPreserveAspectRatio); } - enum SVGPreserveAspectRatioType { SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, SVG_PRESERVEASPECTRATIO_NONE = 1, @@ -57,6 +53,7 @@ namespace WebCore { SVG_MEETORSLICE_SLICE = 2 }; + SVGPreserveAspectRatio(); virtual ~SVGPreserveAspectRatio(); void setAlign(unsigned short); @@ -64,21 +61,30 @@ namespace WebCore { void setMeetOrSlice(unsigned short); unsigned short meetOrSlice() const; + + void transformRect(FloatRect& destRect, FloatRect& srcRect); TransformationMatrix getCTM(double logicX, double logicY, double logicWidth, double logicHeight, double physX, double physY, - double physWidth, double physHeight); + double physWidth, double physHeight) const; - // Helper - bool parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate = true); - String valueAsString() const; + template<class Consumer> + static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true) + { + bool result = false; + const UChar* begin = value.characters(); + const UChar* end = begin + value.length(); + consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result)); + return result; + } - const QualifiedName& associatedAttributeName() const { return SVGNames::preserveAspectRatioAttr; } + // It's recommended to use the method above, only SVGViewSpec needs this parsing method + static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result); + + String valueAsString() const; private: - SVGPreserveAspectRatio(); - unsigned short m_align; unsigned short m_meetOrSlice; }; @@ -87,4 +93,3 @@ namespace WebCore { #endif // ENABLE(SVG) #endif // SVGPreserveAspectRatio_h - |