| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef AnimatableUnknown_h | 31 #ifndef ExceptionState_h |
| 32 #define AnimatableUnknown_h | 32 #define ExceptionState_h |
| 33 | 33 |
| 34 #include "core/animation/AnimatableValue.h" | 34 #include "wtf/Noncopyable.h" |
| 35 #include <v8.h> |
| 35 | 36 |
| 36 namespace WebCore { | 37 namespace WebCore { |
| 37 | 38 |
| 38 class AnimatableUnknown : public AnimatableValue { | 39 typedef int ExceptionCode; |
| 40 |
| 41 class ExceptionState { |
| 42 WTF_MAKE_NONCOPYABLE(ExceptionState); |
| 39 public: | 43 public: |
| 40 virtual ~AnimatableUnknown() { } | 44 explicit ExceptionState(v8::Isolate* isolate) |
| 45 : m_code(0) |
| 46 , m_exceptionThrown(false) |
| 47 , m_isolate(isolate) { } |
| 41 | 48 |
| 42 static PassRefPtr<AnimatableUnknown> create(PassRefPtr<CSSValue> value) | 49 virtual void throwDOMException(const ExceptionCode&, const char* message =
0); |
| 50 virtual void throwTypeError(const char* message = 0); |
| 51 |
| 52 bool hadException() const { return m_exceptionThrown || m_code; } |
| 53 |
| 54 bool throwIfNeeded() |
| 43 { | 55 { |
| 44 return adoptRef(new AnimatableUnknown(value)); | 56 if (m_code) { |
| 57 throwDOMException(m_code); |
| 58 return true; |
| 59 } |
| 60 return m_exceptionThrown; |
| 45 } | 61 } |
| 46 | 62 |
| 47 virtual PassRefPtr<CSSValue> toCSSValue() const OVERRIDE { return m_value; } | 63 // FIXME: Remove the rest of the public methods/operators once the transitio
n is done. |
| 64 typedef void* ExceptionState::*UnspecifiedBoolType; |
| 65 operator UnspecifiedBoolType*() const |
| 66 { |
| 67 return m_code ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; |
| 68 } |
| 69 |
| 70 operator ExceptionCode& () { return m_code; } |
| 71 |
| 72 ExceptionState& operator=(const ExceptionCode& ec) |
| 73 { |
| 74 throwDOMException(ec); |
| 75 return *this; |
| 76 } |
| 48 | 77 |
| 49 protected: | 78 protected: |
| 50 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue* val
ue, double fraction) const OVERRIDE | 79 ExceptionCode m_code; |
| 51 { | |
| 52 return defaultInterpolateTo(this, value, fraction); | |
| 53 } | |
| 54 | |
| 55 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue* value) co
nst OVERRIDE | |
| 56 { | |
| 57 return defaultAddWith(this, value); | |
| 58 } | |
| 59 | 80 |
| 60 private: | 81 private: |
| 61 explicit AnimatableUnknown(PassRefPtr<CSSValue> value) | 82 bool m_exceptionThrown; |
| 62 : AnimatableValue(TypeUnknown) | 83 v8::Isolate* m_isolate; |
| 63 , m_value(value) | 84 }; |
| 64 { | |
| 65 ASSERT(m_value); | |
| 66 } | |
| 67 | 85 |
| 68 RefPtr<CSSValue> m_value; | 86 class NonThrowExceptionState : public ExceptionState { |
| 87 public: |
| 88 NonThrowExceptionState(); |
| 89 virtual void throwDOMException(const ExceptionCode&, const char* = 0) OVERRI
DE FINAL; |
| 90 virtual void throwTypeError(const char* = 0) OVERRIDE FINAL; |
| 69 }; | 91 }; |
| 70 | 92 |
| 71 } // namespace WebCore | 93 } // namespace WebCore |
| 72 | 94 |
| 73 #endif // AnimatableUnknown_h | 95 #endif // ExceptionState_h |
| OLD | NEW |