| 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
|
|
|