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

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

Issue 217053009: Validate finiteness of HTMLMediaElement properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add more FIXMEs. Created 6 years, 8 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/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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
164 if (!std::isfinite(time)) {
165 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(time)) ;
166 return;
167 }
168
163 // When the user agent is to seek the media controller to a particular new p layback position, 169 // When the user agent is to seek the media controller to a particular new p layback position,
164 // it must follow these steps: 170 // it must follow these steps:
165 // If the new playback position is less than zero, then set it to zero. 171 // If the new playback position is less than zero, then set it to zero.
166 time = max(0.0, time); 172 time = max(0.0, time);
167 173
168 // If the new playback position is greater than the media controller duratio n, then set it 174 // If the new playback position is greater than the media controller duratio n, then set it
169 // to the media controller duration. 175 // to the media controller duration.
170 time = min(time, duration()); 176 time = min(time, duration());
171 177
172 // Set the media controller position to the new playback position. 178 // Set the media controller position to the new playback position.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 return; 217 return;
212 218
213 // then the user agent must change the MediaController into a paused media c ontroller, 219 // then the user agent must change the MediaController into a paused media c ontroller,
214 m_paused = true; 220 m_paused = true;
215 // queue a task to fire a simple event named pause at the MediaController, 221 // queue a task to fire a simple event named pause at the MediaController,
216 scheduleEvent(EventTypeNames::pause); 222 scheduleEvent(EventTypeNames::pause);
217 // and then report the controller state of the MediaController. 223 // and then report the controller state of the MediaController.
218 reportControllerState(); 224 reportControllerState();
219 } 225 }
220 226
221 void MediaController::setDefaultPlaybackRate(double rate) 227 void MediaController::setDefaultPlaybackRate(double rate, ExceptionState& except ionState)
222 { 228 {
229 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
230 if (!std::isfinite(rate)) {
231 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate)) ;
232 return;
233 }
234
223 if (m_defaultPlaybackRate == rate) 235 if (m_defaultPlaybackRate == rate)
224 return; 236 return;
225 237
226 // The defaultPlaybackRate attribute, on setting, must set the MediaControll er's media controller 238 // The defaultPlaybackRate attribute, on setting, must set the MediaControll er's media controller
227 // default playback rate to the new value, 239 // default playback rate to the new value,
228 m_defaultPlaybackRate = rate; 240 m_defaultPlaybackRate = rate;
229 241
230 // then queue a task to fire a simple event named ratechange at the MediaCon troller. 242 // then queue a task to fire a simple event named ratechange at the MediaCon troller.
231 scheduleEvent(EventTypeNames::ratechange); 243 scheduleEvent(EventTypeNames::ratechange);
232 } 244 }
233 245
234 double MediaController::playbackRate() const 246 double MediaController::playbackRate() const
235 { 247 {
236 return m_clock->playRate(); 248 return m_clock->playRate();
237 } 249 }
238 250
239 void MediaController::setPlaybackRate(double rate) 251 void MediaController::setPlaybackRate(double rate, ExceptionState& exceptionStat e)
240 { 252 {
253 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
254 if (!std::isfinite(rate)) {
255 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate)) ;
256 return;
257 }
258
241 if (m_clock->playRate() == rate) 259 if (m_clock->playRate() == rate)
242 return; 260 return;
243 261
244 // The playbackRate attribute, on setting, must set the MediaController's me dia controller 262 // The playbackRate attribute, on setting, must set the MediaController's me dia controller
245 // playback rate to the new value, 263 // playback rate to the new value,
246 m_clock->setPlayRate(rate); 264 m_clock->setPlayRate(rate);
247 265
248 for (size_t index = 0; index < m_mediaElements.size(); ++index) 266 for (size_t index = 0; index < m_mediaElements.size(); ++index)
249 m_mediaElements[index]->updatePlaybackRate(); 267 m_mediaElements[index]->updatePlaybackRate();
250 268
251 // then queue a task to fire a simple event named ratechange at the MediaCon troller. 269 // then queue a task to fire a simple event named ratechange at the MediaCon troller.
252 scheduleEvent(EventTypeNames::ratechange); 270 scheduleEvent(EventTypeNames::ratechange);
253 } 271 }
254 272
255 void MediaController::setVolume(double level, ExceptionState& exceptionState) 273 void MediaController::setVolume(double level, ExceptionState& exceptionState)
256 { 274 {
275 // FIXME: generated bindings should check isfinite: http://crbug.com/354298
276 if (!std::isfinite(level)) {
277 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(level) );
278 return;
279 }
280
257 if (m_volume == level) 281 if (m_volume == level)
258 return; 282 return;
259 283
260 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett ing, an 284 // 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. 285 // IndexSizeError exception must be raised instead.
262 if (level < 0 || level > 1) { 286 if (level < 0 || level > 1) {
263 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound)); 287 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("volume", level, 0.0, ExceptionMessages::InclusiveBound, 1.0, Exce ptionMessages::InclusiveBound));
264 return; 288 return;
265 } 289 }
266 290
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 { 637 {
614 double now = WTF::currentTime(); 638 double now = WTF::currentTime();
615 double timedelta = now - m_previousTimeupdateTime; 639 double timedelta = now - m_previousTimeupdateTime;
616 640
617 if (timedelta < maxTimeupdateEventFrequency) 641 if (timedelta < maxTimeupdateEventFrequency)
618 return; 642 return;
619 643
620 scheduleEvent(EventTypeNames::timeupdate); 644 scheduleEvent(EventTypeNames::timeupdate);
621 m_previousTimeupdateTime = now; 645 m_previousTimeupdateTime = now;
622 } 646 }
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