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

Side by Side Diff: Source/core/html/MediaController.cpp

Issue 265743010: Use [TypeChecking=Unrestricted] for MediaController (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/MediaController.h ('k') | Source/core/html/MediaController.idl » ('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) 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Some clocks may return times outside the range of [0..duration]. 149 // Some clocks may return times outside the range of [0..duration].
150 m_position = max(0.0, min(duration(), m_clock->currentTime())); 150 m_position = max(0.0, min(duration(), m_clock->currentTime()));
151 m_clearPositionTimer.startOneShot(0, FROM_HERE); 151 m_clearPositionTimer.startOneShot(0, FROM_HERE);
152 } 152 }
153 153
154 return m_position; 154 return m_position;
155 } 155 }
156 156
157 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState ) 157 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState )
158 { 158 {
159 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
160 if (!std::isfinite(time)) {
161 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(time)) ;
162 return;
163 }
164
165 // When the user agent is to seek the media controller to a particular new p layback position, 159 // When the user agent is to seek the media controller to a particular new p layback position,
166 // it must follow these steps: 160 // it must follow these steps:
167 // If the new playback position is less than zero, then set it to zero. 161 // If the new playback position is less than zero, then set it to zero.
168 time = max(0.0, time); 162 time = max(0.0, time);
169 163
170 // If the new playback position is greater than the media controller duratio n, then set it 164 // If the new playback position is greater than the media controller duratio n, then set it
171 // to the media controller duration. 165 // to the media controller duration.
172 time = min(time, duration()); 166 time = min(time, duration());
173 167
174 // Set the media controller position to the new playback position. 168 // Set the media controller position to the new playback position.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return; 208 return;
215 209
216 // then the user agent must change the MediaController into a paused media c ontroller, 210 // then the user agent must change the MediaController into a paused media c ontroller,
217 m_paused = true; 211 m_paused = true;
218 // queue a task to fire a simple event named pause at the MediaController, 212 // queue a task to fire a simple event named pause at the MediaController,
219 scheduleEvent(EventTypeNames::pause); 213 scheduleEvent(EventTypeNames::pause);
220 // and then report the controller state of the MediaController. 214 // and then report the controller state of the MediaController.
221 reportControllerState(); 215 reportControllerState();
222 } 216 }
223 217
224 void MediaController::setDefaultPlaybackRate(double rate, ExceptionState& except ionState) 218 void MediaController::setDefaultPlaybackRate(double rate)
225 { 219 {
226 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
227 if (!std::isfinite(rate)) {
228 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate)) ;
229 return;
230 }
231
232 if (m_defaultPlaybackRate == rate) 220 if (m_defaultPlaybackRate == rate)
233 return; 221 return;
234 222
235 // The defaultPlaybackRate attribute, on setting, must set the MediaControll er's media controller 223 // The defaultPlaybackRate attribute, on setting, must set the MediaControll er's media controller
236 // default playback rate to the new value, 224 // default playback rate to the new value,
237 m_defaultPlaybackRate = rate; 225 m_defaultPlaybackRate = rate;
238 226
239 // then queue a task to fire a simple event named ratechange at the MediaCon troller. 227 // then queue a task to fire a simple event named ratechange at the MediaCon troller.
240 scheduleEvent(EventTypeNames::ratechange); 228 scheduleEvent(EventTypeNames::ratechange);
241 } 229 }
242 230
243 double MediaController::playbackRate() const 231 double MediaController::playbackRate() const
244 { 232 {
245 return m_clock->playRate(); 233 return m_clock->playRate();
246 } 234 }
247 235
248 void MediaController::setPlaybackRate(double rate, ExceptionState& exceptionStat e) 236 void MediaController::setPlaybackRate(double rate)
249 { 237 {
250 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
251 if (!std::isfinite(rate)) {
252 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate)) ;
253 return;
254 }
255
256 if (m_clock->playRate() == rate) 238 if (m_clock->playRate() == rate)
257 return; 239 return;
258 240
259 // The playbackRate attribute, on setting, must set the MediaController's me dia controller 241 // The playbackRate attribute, on setting, must set the MediaController's me dia controller
260 // playback rate to the new value, 242 // playback rate to the new value,
261 m_clock->setPlayRate(rate); 243 m_clock->setPlayRate(rate);
262 244
263 for (size_t index = 0; index < m_mediaElements.size(); ++index) 245 for (size_t index = 0; index < m_mediaElements.size(); ++index)
264 m_mediaElements[index]->updatePlaybackRate(); 246 m_mediaElements[index]->updatePlaybackRate();
265 247
266 // then queue a task to fire a simple event named ratechange at the MediaCon troller. 248 // then queue a task to fire a simple event named ratechange at the MediaCon troller.
267 scheduleEvent(EventTypeNames::ratechange); 249 scheduleEvent(EventTypeNames::ratechange);
268 } 250 }
269 251
270 void MediaController::setVolume(double level, ExceptionState& exceptionState) 252 void MediaController::setVolume(double level, ExceptionState& exceptionState)
271 { 253 {
272 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
273 if (!std::isfinite(level)) {
274 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(level) );
275 return;
276 }
277
278 if (m_volume == level) 254 if (m_volume == level)
279 return; 255 return;
280 256
281 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an 257 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an
282 // IndexSizeError exception must be raised instead. 258 // IndexSizeError exception must be raised instead.
283 if (level < 0 || level > 1) { 259 if (level < 0 || level > 1) {
284 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound)); 260 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound));
285 return; 261 return;
286 } 262 }
287 263
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 { 598 {
623 double now = WTF::currentTime(); 599 double now = WTF::currentTime();
624 double timedelta = now - m_previousTimeupdateTime; 600 double timedelta = now - m_previousTimeupdateTime;
625 601
626 if (timedelta < maxTimeupdateEventFrequency) 602 if (timedelta < maxTimeupdateEventFrequency)
627 return; 603 return;
628 604
629 scheduleEvent(EventTypeNames::timeupdate); 605 scheduleEvent(EventTypeNames::timeupdate);
630 m_previousTimeupdateTime = now; 606 m_previousTimeupdateTime = now;
631 } 607 }
OLDNEW
« no previous file with comments | « Source/core/html/MediaController.h ('k') | Source/core/html/MediaController.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698