OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "bindings/v8/ExceptionMessages.h" | 35 #include "bindings/v8/ExceptionMessages.h" |
36 #include "bindings/v8/ExceptionStatePlaceholder.h" | 36 #include "bindings/v8/ExceptionStatePlaceholder.h" |
37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
38 #include "core/html/track/TextTrack.h" | 38 #include "core/html/track/TextTrack.h" |
39 #include "core/html/track/TextTrackCueList.h" | 39 #include "core/html/track/TextTrackCueList.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 static const int invalidCueIndex = -1; | 43 static const int invalidCueIndex = -1; |
44 | 44 |
45 bool TextTrackCue::isInfiniteOrNonNumber(double value, const char* method, Excep
tionState& exceptionState) | 45 bool TextTrackCue::isInfiniteOrNonNumber(double value, ExceptionState& exception
State) |
46 { | 46 { |
47 if (!std::isfinite(value)) { | 47 if (!std::isfinite(value)) { |
48 exceptionState.throwTypeError(ExceptionMessages::failedToSet(method, "Te
xtTrackCue", ExceptionMessages::notAFiniteNumber(value))); | 48 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(value)
); |
49 return true; | 49 return true; |
50 } | 50 } |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 TextTrackCue::TextTrackCue(double start, double end) | 54 TextTrackCue::TextTrackCue(double start, double end) |
55 : m_startTime(start) | 55 : m_startTime(start) |
56 , m_endTime(end) | 56 , m_endTime(end) |
57 , m_cueIndex(invalidCueIndex) | 57 , m_cueIndex(invalidCueIndex) |
58 , m_track(0) | 58 , m_track(0) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 return; | 94 return; |
95 | 95 |
96 cueWillChange(); | 96 cueWillChange(); |
97 m_id = id; | 97 m_id = id; |
98 cueDidChange(); | 98 cueDidChange(); |
99 } | 99 } |
100 | 100 |
101 void TextTrackCue::setStartTime(double value, ExceptionState& exceptionState) | 101 void TextTrackCue::setStartTime(double value, ExceptionState& exceptionState) |
102 { | 102 { |
103 // NaN, Infinity and -Infinity values should trigger a TypeError. | 103 // NaN, Infinity and -Infinity values should trigger a TypeError. |
104 if (isInfiniteOrNonNumber(value, "startTime", exceptionState)) | 104 if (isInfiniteOrNonNumber(value, exceptionState)) |
105 return; | 105 return; |
106 | 106 |
107 // TODO(93143): Add spec-compliant behavior for negative time values. | 107 // TODO(93143): Add spec-compliant behavior for negative time values. |
108 if (m_startTime == value || value < 0) | 108 if (m_startTime == value || value < 0) |
109 return; | 109 return; |
110 | 110 |
111 cueWillChange(); | 111 cueWillChange(); |
112 m_startTime = value; | 112 m_startTime = value; |
113 cueDidChange(); | 113 cueDidChange(); |
114 } | 114 } |
115 | 115 |
116 void TextTrackCue::setEndTime(double value, ExceptionState& exceptionState) | 116 void TextTrackCue::setEndTime(double value, ExceptionState& exceptionState) |
117 { | 117 { |
118 // NaN, Infinity and -Infinity values should trigger a TypeError. | 118 // NaN, Infinity and -Infinity values should trigger a TypeError. |
119 if (isInfiniteOrNonNumber(value, "endTime", exceptionState)) | 119 if (isInfiniteOrNonNumber(value, exceptionState)) |
120 return; | 120 return; |
121 | 121 |
122 // TODO(93143): Add spec-compliant behavior for negative time values. | 122 // TODO(93143): Add spec-compliant behavior for negative time values. |
123 if (m_endTime == value || value < 0) | 123 if (m_endTime == value || value < 0) |
124 return; | 124 return; |
125 | 125 |
126 cueWillChange(); | 126 cueWillChange(); |
127 m_endTime = value; | 127 m_endTime = value; |
128 cueDidChange(); | 128 cueDidChange(); |
129 } | 129 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (!active) | 173 if (!active) |
174 removeDisplayTree(); | 174 removeDisplayTree(); |
175 } | 175 } |
176 | 176 |
177 const AtomicString& TextTrackCue::interfaceName() const | 177 const AtomicString& TextTrackCue::interfaceName() const |
178 { | 178 { |
179 return EventTargetNames::TextTrackCue; | 179 return EventTargetNames::TextTrackCue; |
180 } | 180 } |
181 | 181 |
182 } // namespace WebCore | 182 } // namespace WebCore |
OLD | NEW |