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

Unified Diff: Source/core/svg/SVGRect.h

Issue 132233010: [SVG] SVGAnimatedRect migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebsaed Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGPatternElement.cpp ('k') | Source/core/svg/SVGRect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGRect.h
diff --git a/Source/core/svg/SVGRect.h b/Source/core/svg/SVGRect.h
index 775c196601215af54af9e97d021a56d5abfe41fc..b52c82ac70e8b9be3ef2b73293b202ae037bccef 100644
--- a/Source/core/svg/SVGRect.h
+++ b/Source/core/svg/SVGRect.h
@@ -20,55 +20,82 @@
#ifndef SVGRect_h
#define SVGRect_h
-#include "core/svg/properties/SVGPropertyTraits.h"
+#include "core/svg/properties/NewSVGProperty.h"
#include "platform/geometry/FloatRect.h"
-#include "wtf/text/StringBuilder.h"
namespace WebCore {
-class SVGRect : public FloatRect {
+class SVGRectTearOff;
+
+class SVGRect : public NewSVGPropertyBase {
public:
+ typedef SVGRectTearOff TearOffType;
+
struct InvalidSVGRectTag { };
- SVGRect()
- : m_isValid(true) { }
- SVGRect(InvalidSVGRectTag)
- : m_isValid(false) { }
- SVGRect(const FloatRect& rect)
- : FloatRect(rect), m_isValid(true) { }
- SVGRect(const FloatPoint& location, const FloatSize& size)
- : FloatRect(location, size), m_isValid(true) { }
- SVGRect(float x, float y, float width, float height)
- : FloatRect(x, y, width, height), m_isValid(true) { }
- SVGRect(const IntRect& intRect)
- : FloatRect(intRect), m_isValid(true) { }
- SVGRect(const LayoutRect& layoutRect)
- : FloatRect(layoutRect), m_isValid(true) { }
- SVGRect(const SkRect& skRect)
- : FloatRect(skRect), m_isValid(true) { }
+ static PassRefPtr<SVGRect> create()
+ {
+ return adoptRef(new SVGRect());
+ }
+
+ static PassRefPtr<SVGRect> create(InvalidSVGRectTag)
+ {
+ return adoptRef(new SVGRect(InvalidSVGRectTag()));
+ }
+
+ static PassRefPtr<SVGRect> create(const FloatRect& rect)
+ {
+ return adoptRef(new SVGRect(rect));
+ }
+
+ PassRefPtr<SVGRect> clone() const;
+ virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE;
+
+ const FloatRect& value() const { return m_value; }
+ void setValue(const FloatRect& v) { m_value = v; }
+
+ float x() const { return m_value.x(); }
+ float y() const { return m_value.y(); }
+ float width() const { return m_value.width(); }
+ float height() const { return m_value.height(); }
+ void setX(float f) { m_value.setX(f); }
+ void setY(float f) { m_value.setY(f); }
+ void setWidth(float f) { m_value.setWidth(f); }
+ void setHeight(float f) { m_value.setHeight(f); }
+
+ bool operator==(const SVGRect&) const;
+ bool operator!=(const SVGRect& other) const { return !operator==(other); }
+
+ virtual String valueAsString() const OVERRIDE;
+ void setValueAsString(const String&, ExceptionState&);
+
+ virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE;
+ virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> from, PassRefPtr<NewSVGPropertyBase> to, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) OVERRIDE;
+ virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElement* contextElement) OVERRIDE;
bool isValid() const { return m_isValid; }
+ void setInvalid();
+
+ static AnimatedPropertyType classType() { return AnimatedRect; }
private:
+ SVGRect();
+ SVGRect(InvalidSVGRectTag);
+ SVGRect(const FloatRect&);
+
+ template<typename CharType>
+ void parse(const CharType*& ptr, const CharType* end, ExceptionState&);
+
bool m_isValid;
+ FloatRect m_value;
};
-template<>
-struct SVGPropertyTraits<SVGRect> {
- static SVGRect initialValue() { return SVGRect(SVGRect::InvalidSVGRectTag()); }
- static String toString(const SVGRect& type)
- {
- StringBuilder builder;
- builder.append(String::number(type.x()));
- builder.append(' ');
- builder.append(String::number(type.y()));
- builder.append(' ');
- builder.append(String::number(type.width()));
- builder.append(' ');
- builder.append(String::number(type.height()));
- return builder.toString();
- }
-};
+inline PassRefPtr<SVGRect> toSVGRect(PassRefPtr<NewSVGPropertyBase> passBase)
+{
+ RefPtr<NewSVGPropertyBase> base = passBase;
+ ASSERT(base->type() == SVGRect::classType());
+ return static_pointer_cast<SVGRect>(base.release());
+}
} // namespace WebCore
« no previous file with comments | « Source/core/svg/SVGPatternElement.cpp ('k') | Source/core/svg/SVGRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698