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

Unified Diff: third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp

Issue 2760353002: Define default values for options dictionaries for WebAudio (Closed)
Patch Set: Rebase Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
index 0dba6c099e002a337681fab852da53f04f810e9c..4349407334875d74f8aa77edbcd497c2db2575c8 100644
--- a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
@@ -402,35 +402,16 @@ OscillatorNode* OscillatorNode::Create(BaseAudioContext* context,
node->HandleChannelOptions(options, exception_state);
- if (options.hasType()) {
- if (options.type() == "custom" && !options.hasPeriodicWave()) {
- exception_state.ThrowDOMException(kInvalidStateError,
- "'type' cannot be set to 'custom' "
- "without also specifying "
- "'periodicWave'");
- return nullptr;
- }
- if (options.type() != "custom" && options.hasPeriodicWave()) {
- exception_state.ThrowDOMException(
- kInvalidStateError, "'type' MUST be 'custom' instead of '" +
- options.type() +
- "' if 'periodicWave' is also given");
- return nullptr;
- }
-
- // At this both type and periodicWave are consistently defined. In that
- // case, don't set the type if periodicWave is specified because that
- // will cause an (incorrect) error to be signaled.
- if (options.type() != "custom")
- node->setType(options.type(), exception_state);
+ if (options.hasPeriodicWave()) {
+ // Set up the custom wave; this also sets the type to "custom",
+ // overriding any |type| option the user may have set. Per spec.
+ node->setPeriodicWave(options.periodicWave());
+ } else {
+ node->setType(options.type(), exception_state);
}
- if (options.hasDetune())
- node->detune()->setValue(options.detune());
- if (options.hasFrequency())
- node->frequency()->setValue(options.frequency());
- if (options.hasPeriodicWave())
- node->setPeriodicWave(options.periodicWave());
+ node->detune()->setValue(options.detune());
+ node->frequency()->setValue(options.frequency());
return node;
}

Powered by Google App Engine
This is Rietveld 408576698