| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define SMILTime_h | 27 #define SMILTime_h |
| 28 | 28 |
| 29 #include "wtf/Allocator.h" | 29 #include "wtf/Allocator.h" |
| 30 #include "wtf/Assertions.h" | 30 #include "wtf/Assertions.h" |
| 31 #include "wtf/HashTraits.h" | 31 #include "wtf/HashTraits.h" |
| 32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class SMILTime { | 36 class SMILTime { |
| 37 ALLOW_ONLY_INLINE_ALLOCATION(); | 37 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 38 public: | 38 public: |
| 39 SMILTime() : m_time(0) { } | 39 SMILTime() : m_time(0) { } |
| 40 SMILTime(double time) : m_time(time) { } | 40 SMILTime(double time) : m_time(time) { } |
| 41 | 41 |
| 42 static SMILTime unresolved() { return std::numeric_limits<double>::quiet_NaN
(); } | 42 static SMILTime unresolved() { return std::numeric_limits<double>::quiet_NaN
(); } |
| 43 static SMILTime indefinite() { return std::numeric_limits<double>::infinity(
); } | 43 static SMILTime indefinite() { return std::numeric_limits<double>::infinity(
); } |
| 44 | 44 |
| 45 double value() const { return m_time; } | 45 double value() const { return m_time; } |
| 46 | 46 |
| 47 bool isFinite() const { return std::isfinite(m_time); } | 47 bool isFinite() const { return std::isfinite(m_time); } |
| 48 bool isIndefinite() const { return std::isinf(m_time); } | 48 bool isIndefinite() const { return std::isinf(m_time); } |
| 49 bool isUnresolved() const { return std::isnan(m_time); } | 49 bool isUnresolved() const { return std::isnan(m_time); } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 double m_time; | 52 double m_time; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class SMILTimeWithOrigin { | 55 class SMILTimeWithOrigin { |
| 56 ALLOW_ONLY_INLINE_ALLOCATION(); | 56 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 57 public: | 57 public: |
| 58 enum Origin { | 58 enum Origin { |
| 59 ParserOrigin, | 59 ParserOrigin, |
| 60 ScriptOrigin | 60 ScriptOrigin |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 SMILTimeWithOrigin() | 63 SMILTimeWithOrigin() |
| 64 : m_origin(ParserOrigin) | 64 : m_origin(ParserOrigin) |
| 65 { | 65 { |
| 66 } | 66 } |
| 67 | 67 |
| 68 SMILTimeWithOrigin(const SMILTime& time, Origin origin) | 68 SMILTimeWithOrigin(const SMILTime& time, Origin origin) |
| 69 : m_time(time) | 69 : m_time(time) |
| 70 , m_origin(origin) | 70 , m_origin(origin) |
| 71 { | 71 { |
| 72 } | 72 } |
| 73 | 73 |
| 74 const SMILTime& time() const { return m_time; } | 74 const SMILTime& time() const { return m_time; } |
| 75 bool originIsScript() const { return m_origin == ScriptOrigin; } | 75 bool originIsScript() const { return m_origin == ScriptOrigin; } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 SMILTime m_time; | 78 SMILTime m_time; |
| 79 Origin m_origin; | 79 Origin m_origin; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 struct SMILInterval { | 82 struct SMILInterval { |
| 83 DISALLOW_ALLOCATION(); | 83 DISALLOW_NEW(); |
| 84 SMILInterval() { } | 84 SMILInterval() { } |
| 85 SMILInterval(const SMILTime& begin, const SMILTime& end) : begin(begin), end
(end) { } | 85 SMILInterval(const SMILTime& begin, const SMILTime& end) : begin(begin), end
(end) { } |
| 86 | 86 |
| 87 SMILTime begin; | 87 SMILTime begin; |
| 88 SMILTime end; | 88 SMILTime end; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 inline bool operator==(const SMILTime& a, const SMILTime& b) { return (a.isUnres
olved() && b.isUnresolved()) || a.value() == b.value(); } | 91 inline bool operator==(const SMILTime& a, const SMILTime& b) { return (a.isUnres
olved() && b.isUnresolved()) || a.value() == b.value(); } |
| 92 inline bool operator!(const SMILTime& a) { return !a.isFinite() || !a.value(); } | 92 inline bool operator!(const SMILTime& a) { return !a.isFinite() || !a.value(); } |
| 93 inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator=
=(a, b); } | 93 inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator=
=(a, b); } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 template<> struct HashTraits<blink::SMILTime> : GenericHashTraits<blink::SMILTim
e> { | 130 template<> struct HashTraits<blink::SMILTime> : GenericHashTraits<blink::SMILTim
e> { |
| 131 static blink::SMILTime emptyValue() { return blink::SMILTime::unresolved();
} | 131 static blink::SMILTime emptyValue() { return blink::SMILTime::unresolved();
} |
| 132 static void constructDeletedValue(blink::SMILTime& slot, bool) { slot = -std
::numeric_limits<double>::infinity(); } | 132 static void constructDeletedValue(blink::SMILTime& slot, bool) { slot = -std
::numeric_limits<double>::infinity(); } |
| 133 static bool isDeletedValue(blink::SMILTime value) { return value == -std::nu
meric_limits<double>::infinity(); } | 133 static bool isDeletedValue(blink::SMILTime value) { return value == -std::nu
meric_limits<double>::infinity(); } |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace WTF | 136 } // namespace WTF |
| 137 | 137 |
| 138 #endif // SMILTime_h | 138 #endif // SMILTime_h |
| OLD | NEW |