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

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

Issue 19263002: Get rid of special casing for SVGNumber in the bindings generator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix style issues Created 7 years, 5 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/SVGFEConvolveMatrixElement.cpp ('k') | Source/core/svg/SVGNumberList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGNumber.h
diff --git a/Source/core/dom/StringCallback.cpp b/Source/core/svg/SVGNumber.h
similarity index 63%
copy from Source/core/dom/StringCallback.cpp
copy to Source/core/svg/SVGNumber.h
index 092f70e2686db60343298828cb8ab55c8059ff2c..db47ed0dfb2ec33e7d6a538895fe9d8ff16ba61c 100644
--- a/Source/core/dom/StringCallback.cpp
+++ b/Source/core/svg/SVGNumber.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,44 +28,49 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "core/dom/StringCallback.h"
+#ifndef SVGNumber_h
+#define SVGNumber_h
-#include "core/dom/ScriptExecutionContext.h"
-#include "wtf/text/WTFString.h"
+#include "core/svg/properties/SVGPropertyTraits.h"
namespace WebCore {
-namespace {
-
-class DispatchCallbackTask : public ScriptExecutionContext::Task {
+class SVGNumber {
+ WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<DispatchCallbackTask> create(PassRefPtr<StringCallback> callback, const String& data)
+ SVGNumber()
+ : m_value(0)
{
- return adoptPtr(new DispatchCallbackTask(callback, data));
}
- virtual void performTask(ScriptExecutionContext*)
+ SVGNumber(float value)
+ : m_value(value)
{
- m_callback->handleEvent(m_data);
}
-private:
- DispatchCallbackTask(PassRefPtr<StringCallback> callback, const String& data)
- : m_callback(callback)
- , m_data(data)
+ SVGNumber& operator+=(const SVGNumber& rhs)
{
+ m_value += rhs.value();
+ return *this;
}
- RefPtr<StringCallback> m_callback;
- const String m_data;
+ float value() const { return m_value; }
+ float& valueRef() { return m_value; }
+ String valueAsString() const { return String::number(m_value); }
+ void setValue(float value) { m_value = value; }
+
+private:
+ float m_value;
};
-} // namespace
+COMPILE_ASSERT(sizeof(SVGNumber) == sizeof(float), SVGNumber_same_size_as_float);
-void StringCallback::scheduleCallback(ScriptExecutionContext* context, const String& data)
-{
- context->postTask(DispatchCallbackTask::create(this, data));
-}
+template<>
+struct SVGPropertyTraits<SVGNumber> {
+ static SVGNumber initialValue() { return SVGNumber(); }
+ static String toString(const SVGNumber& type) { return type.valueAsString(); }
+};
} // namespace WebCore
+
+#endif // SVGNumber_h
« no previous file with comments | « Source/core/svg/SVGFEConvolveMatrixElement.cpp ('k') | Source/core/svg/SVGNumberList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698