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

Side by Side Diff: Source/core/svg/animation/SMILTime.h

Issue 1321453012: Added allocator matcros to blink classes and structures in core/svg. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « Source/core/svg/SVGTransformDistance.h ('k') | Source/core/svg/graphics/SVGImage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef SMILTime_h 26 #ifndef SMILTime_h
27 #define SMILTime_h 27 #define SMILTime_h
28 28
29 #include "wtf/Allocator.h"
29 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
30 #include "wtf/HashTraits.h" 31 #include "wtf/HashTraits.h"
31 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
32 33
33 namespace blink { 34 namespace blink {
34 35
35 class SMILTime { 36 class SMILTime {
37 ALLOW_ONLY_INLINE_ALLOCATION();
36 public: 38 public:
37 SMILTime() : m_time(0) { } 39 SMILTime() : m_time(0) { }
38 SMILTime(double time) : m_time(time) { } 40 SMILTime(double time) : m_time(time) { }
39 41
40 static SMILTime unresolved() { return std::numeric_limits<double>::quiet_NaN (); } 42 static SMILTime unresolved() { return std::numeric_limits<double>::quiet_NaN (); }
41 static SMILTime indefinite() { return std::numeric_limits<double>::infinity( ); } 43 static SMILTime indefinite() { return std::numeric_limits<double>::infinity( ); }
42 44
43 double value() const { return m_time; } 45 double value() const { return m_time; }
44 46
45 bool isFinite() const { return std::isfinite(m_time); } 47 bool isFinite() const { return std::isfinite(m_time); }
46 bool isIndefinite() const { return std::isinf(m_time); } 48 bool isIndefinite() const { return std::isinf(m_time); }
47 bool isUnresolved() const { return std::isnan(m_time); } 49 bool isUnresolved() const { return std::isnan(m_time); }
48 50
49 private: 51 private:
50 double m_time; 52 double m_time;
51 }; 53 };
52 54
53 class SMILTimeWithOrigin { 55 class SMILTimeWithOrigin {
56 ALLOW_ONLY_INLINE_ALLOCATION();
54 public: 57 public:
55 enum Origin { 58 enum Origin {
56 ParserOrigin, 59 ParserOrigin,
57 ScriptOrigin 60 ScriptOrigin
58 }; 61 };
59 62
60 SMILTimeWithOrigin() 63 SMILTimeWithOrigin()
61 : m_origin(ParserOrigin) 64 : m_origin(ParserOrigin)
62 { 65 {
63 } 66 }
64 67
65 SMILTimeWithOrigin(const SMILTime& time, Origin origin) 68 SMILTimeWithOrigin(const SMILTime& time, Origin origin)
66 : m_time(time) 69 : m_time(time)
67 , m_origin(origin) 70 , m_origin(origin)
68 { 71 {
69 } 72 }
70 73
71 const SMILTime& time() const { return m_time; } 74 const SMILTime& time() const { return m_time; }
72 bool originIsScript() const { return m_origin == ScriptOrigin; } 75 bool originIsScript() const { return m_origin == ScriptOrigin; }
73 76
74 private: 77 private:
75 SMILTime m_time; 78 SMILTime m_time;
76 Origin m_origin; 79 Origin m_origin;
77 }; 80 };
78 81
79 struct SMILInterval { 82 struct SMILInterval {
83 DISALLOW_ALLOCATION();
80 SMILInterval() { } 84 SMILInterval() { }
81 SMILInterval(const SMILTime& begin, const SMILTime& end) : begin(begin), end (end) { } 85 SMILInterval(const SMILTime& begin, const SMILTime& end) : begin(begin), end (end) { }
82 86
83 SMILTime begin; 87 SMILTime begin;
84 SMILTime end; 88 SMILTime end;
85 }; 89 };
86 90
87 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(); }
88 inline bool operator!(const SMILTime& a) { return !a.isFinite() || !a.value(); } 92 inline bool operator!(const SMILTime& a) { return !a.isFinite() || !a.value(); }
89 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 12 matching lines...) Expand all
102 SMILTime operator*(const SMILTime&, const SMILTime&); 106 SMILTime operator*(const SMILTime&, const SMILTime&);
103 107
104 inline bool operator!=(const SMILInterval& a, const SMILInterval& b) 108 inline bool operator!=(const SMILInterval& a, const SMILInterval& b)
105 { 109 {
106 // Compare the "raw" values since the operator!= for SMILTime always return 110 // Compare the "raw" values since the operator!= for SMILTime always return
107 // true for non-finite times. 111 // true for non-finite times.
108 return a.begin.value() != b.begin.value() || a.end.value() != b.end.value(); 112 return a.begin.value() != b.begin.value() || a.end.value() != b.end.value();
109 } 113 }
110 114
111 struct SMILTimeHash { 115 struct SMILTimeHash {
116 STATIC_ONLY(SMILTimeHash);
112 static unsigned hash(const SMILTime& key) { return WTF::FloatHash<double>::h ash(key.value()); } 117 static unsigned hash(const SMILTime& key) { return WTF::FloatHash<double>::h ash(key.value()); }
113 static bool equal(const SMILTime& a, const SMILTime& b) { return WTF::FloatH ash<double>::equal(a.value(), b.value()); } 118 static bool equal(const SMILTime& a, const SMILTime& b) { return WTF::FloatH ash<double>::equal(a.value(), b.value()); }
114 static const bool safeToCompareToEmptyOrDeleted = true; 119 static const bool safeToCompareToEmptyOrDeleted = true;
115 }; 120 };
116 121
117 } // namespace blink 122 } // namespace blink
118 123
119 namespace WTF { 124 namespace WTF {
120 125
121 template<> struct DefaultHash<blink::SMILTime> { 126 template<> struct DefaultHash<blink::SMILTime> {
122 typedef blink::SMILTimeHash Hash; 127 typedef blink::SMILTimeHash Hash;
123 }; 128 };
124 129
125 template<> struct HashTraits<blink::SMILTime> : GenericHashTraits<blink::SMILTim e> { 130 template<> struct HashTraits<blink::SMILTime> : GenericHashTraits<blink::SMILTim e> {
126 static blink::SMILTime emptyValue() { return blink::SMILTime::unresolved(); } 131 static blink::SMILTime emptyValue() { return blink::SMILTime::unresolved(); }
127 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(); }
128 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(); }
129 }; 134 };
130 135
131 } // namespace WTF 136 } // namespace WTF
132 137
133 #endif // SMILTime_h 138 #endif // SMILTime_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGTransformDistance.h ('k') | Source/core/svg/graphics/SVGImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698