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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp

Issue 2020753002: Throw exception if curve is too short for setValueCurveAtTime (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 void AudioParamTimeline::setValueCurveAtTime(DOMFloat32Array* curve, double time , double duration, ExceptionState& exceptionState) 188 void AudioParamTimeline::setValueCurveAtTime(DOMFloat32Array* curve, double time , double duration, ExceptionState& exceptionState)
189 { 189 {
190 ASSERT(isMainThread()); 190 ASSERT(isMainThread());
191 ASSERT(curve); 191 ASSERT(curve);
192 192
193 if (!isNonNegativeAudioParamTime(time, exceptionState) 193 if (!isNonNegativeAudioParamTime(time, exceptionState)
194 || !isPositiveAudioParamTime(duration, exceptionState, "Duration")) 194 || !isPositiveAudioParamTime(duration, exceptionState, "Duration"))
195 return; 195 return;
196 196
197 if (curve->length() < 2) {
198 exceptionState.throwDOMException(
199 InvalidStateError,
200 ExceptionMessages::indexExceedsMinimumBound(
201 "curve length",
202 curve->length(),
203 2U));
204 return;
205 }
206
197 insertEvent(ParamEvent::createSetValueCurveEvent(curve, time, duration), exc eptionState); 207 insertEvent(ParamEvent::createSetValueCurveEvent(curve, time, duration), exc eptionState);
198 } 208 }
199 209
200 void AudioParamTimeline::insertEvent(const ParamEvent& event, ExceptionState& ex ceptionState) 210 void AudioParamTimeline::insertEvent(const ParamEvent& event, ExceptionState& ex ceptionState)
201 { 211 {
202 ASSERT(isMainThread()); 212 ASSERT(isMainThread());
203 213
204 // Sanity check the event. Be super careful we're not getting infected with NaN or Inf. These 214 // Sanity check the event. Be super careful we're not getting infected with NaN or Inf. These
205 // should have been handled by the caller. 215 // should have been handled by the caller.
206 bool isValid = event.getType() < ParamEvent::LastType 216 bool isValid = event.getType() < ParamEvent::LastType
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 for (; writeIndex < numberOfValues; ++writeIndex) 866 for (; writeIndex < numberOfValues; ++writeIndex)
857 values[writeIndex] = value; 867 values[writeIndex] = value;
858 868
859 // This value is used to set the .value attribute of the AudioParam. it sho uld be the last 869 // This value is used to set the .value attribute of the AudioParam. it sho uld be the last
860 // computed value. 870 // computed value.
861 return values[numberOfValues - 1]; 871 return values[numberOfValues - 1];
862 } 872 }
863 873
864 } // namespace blink 874 } // namespace blink
865 875
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698