OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // Some clocks may return times outside the range of [0..duration]. | 153 // Some clocks may return times outside the range of [0..duration]. |
154 m_position = max(0.0, min(duration(), m_clock->currentTime())); | 154 m_position = max(0.0, min(duration(), m_clock->currentTime())); |
155 m_clearPositionTimer.startOneShot(0, FROM_HERE); | 155 m_clearPositionTimer.startOneShot(0, FROM_HERE); |
156 } | 156 } |
157 | 157 |
158 return m_position; | 158 return m_position; |
159 } | 159 } |
160 | 160 |
161 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState ) | 161 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState ) |
162 { | 162 { |
163 if (!std::isfinite(time)) { | |
acolwell GONE FROM CHROMIUM
2014/03/31 21:58:29
nit: You should probably add FIXME's to above this
| |
164 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(time)) ; | |
165 return; | |
166 } | |
167 | |
163 // When the user agent is to seek the media controller to a particular new p layback position, | 168 // When the user agent is to seek the media controller to a particular new p layback position, |
164 // it must follow these steps: | 169 // it must follow these steps: |
165 // If the new playback position is less than zero, then set it to zero. | 170 // If the new playback position is less than zero, then set it to zero. |
166 time = max(0.0, time); | 171 time = max(0.0, time); |
167 | 172 |
168 // If the new playback position is greater than the media controller duratio n, then set it | 173 // If the new playback position is greater than the media controller duratio n, then set it |
169 // to the media controller duration. | 174 // to the media controller duration. |
170 time = min(time, duration()); | 175 time = min(time, duration()); |
171 | 176 |
172 // Set the media controller position to the new playback position. | 177 // Set the media controller position to the new playback position. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 return; | 216 return; |
212 | 217 |
213 // then the user agent must change the MediaController into a paused media c ontroller, | 218 // then the user agent must change the MediaController into a paused media c ontroller, |
214 m_paused = true; | 219 m_paused = true; |
215 // queue a task to fire a simple event named pause at the MediaController, | 220 // queue a task to fire a simple event named pause at the MediaController, |
216 scheduleEvent(EventTypeNames::pause); | 221 scheduleEvent(EventTypeNames::pause); |
217 // and then report the controller state of the MediaController. | 222 // and then report the controller state of the MediaController. |
218 reportControllerState(); | 223 reportControllerState(); |
219 } | 224 } |
220 | 225 |
221 void MediaController::setDefaultPlaybackRate(double rate) | 226 void MediaController::setDefaultPlaybackRate(double rate, ExceptionState& except ionState) |
222 { | 227 { |
228 if (!std::isfinite(rate)) { | |
229 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate)) ; | |
230 return; | |
231 } | |
232 | |
223 if (m_defaultPlaybackRate == rate) | 233 if (m_defaultPlaybackRate == rate) |
224 return; | 234 return; |
225 | 235 |
226 // The defaultPlaybackRate attribute, on setting, must set the MediaControll er's media controller | 236 // The defaultPlaybackRate attribute, on setting, must set the MediaControll er's media controller |
227 // default playback rate to the new value, | 237 // default playback rate to the new value, |
228 m_defaultPlaybackRate = rate; | 238 m_defaultPlaybackRate = rate; |
229 | 239 |
230 // then queue a task to fire a simple event named ratechange at the MediaCon troller. | 240 // then queue a task to fire a simple event named ratechange at the MediaCon troller. |
231 scheduleEvent(EventTypeNames::ratechange); | 241 scheduleEvent(EventTypeNames::ratechange); |
232 } | 242 } |
233 | 243 |
234 double MediaController::playbackRate() const | 244 double MediaController::playbackRate() const |
235 { | 245 { |
236 return m_clock->playRate(); | 246 return m_clock->playRate(); |
237 } | 247 } |
238 | 248 |
239 void MediaController::setPlaybackRate(double rate) | 249 void MediaController::setPlaybackRate(double rate, ExceptionState& exceptionStat e) |
240 { | 250 { |
251 if (!std::isfinite(rate)) { | |
252 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate)) ; | |
253 return; | |
254 } | |
255 | |
241 if (m_clock->playRate() == rate) | 256 if (m_clock->playRate() == rate) |
242 return; | 257 return; |
243 | 258 |
244 // The playbackRate attribute, on setting, must set the MediaController's me dia controller | 259 // The playbackRate attribute, on setting, must set the MediaController's me dia controller |
245 // playback rate to the new value, | 260 // playback rate to the new value, |
246 m_clock->setPlayRate(rate); | 261 m_clock->setPlayRate(rate); |
247 | 262 |
248 for (size_t index = 0; index < m_mediaElements.size(); ++index) | 263 for (size_t index = 0; index < m_mediaElements.size(); ++index) |
249 m_mediaElements[index]->updatePlaybackRate(); | 264 m_mediaElements[index]->updatePlaybackRate(); |
250 | 265 |
251 // then queue a task to fire a simple event named ratechange at the MediaCon troller. | 266 // then queue a task to fire a simple event named ratechange at the MediaCon troller. |
252 scheduleEvent(EventTypeNames::ratechange); | 267 scheduleEvent(EventTypeNames::ratechange); |
253 } | 268 } |
254 | 269 |
255 void MediaController::setVolume(double level, ExceptionState& exceptionState) | 270 void MediaController::setVolume(double level, ExceptionState& exceptionState) |
256 { | 271 { |
272 if (!std::isfinite(level)) { | |
273 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(level) ); | |
274 return; | |
275 } | |
276 | |
257 if (m_volume == level) | 277 if (m_volume == level) |
258 return; | 278 return; |
259 | 279 |
260 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an | 280 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an |
261 // IndexSizeError exception must be raised instead. | 281 // IndexSizeError exception must be raised instead. |
262 if (level < 0 || level > 1) { | 282 if (level < 0 || level > 1) { |
263 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound)); | 283 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound)); |
264 return; | 284 return; |
265 } | 285 } |
266 | 286 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 { | 633 { |
614 double now = WTF::currentTime(); | 634 double now = WTF::currentTime(); |
615 double timedelta = now - m_previousTimeupdateTime; | 635 double timedelta = now - m_previousTimeupdateTime; |
616 | 636 |
617 if (timedelta < maxTimeupdateEventFrequency) | 637 if (timedelta < maxTimeupdateEventFrequency) |
618 return; | 638 return; |
619 | 639 |
620 scheduleEvent(EventTypeNames::timeupdate); | 640 scheduleEvent(EventTypeNames::timeupdate); |
621 m_previousTimeupdateTime = now; | 641 m_previousTimeupdateTime = now; |
622 } | 642 } |
OLD | NEW |