Implement WebIDL-style string constants in WebAudio (part 2)
authorcrogers@google.com <crogers@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2013 21:33:16 +0000 (21:33 +0000)
committercrogers@google.com <crogers@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2013 21:33:16 +0000 (21:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105977

Reviewed by Kentaro Hara.

Source/WebCore:

See Deprecation Notes for more detail:
https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#DeprecationNotes

PannerNode, BiquadFilterNode, OscillatorNode constants must support WebIDL-style string constants.
Legacy support in the setters for the old integer values should be supported.
This patch handles the changes for BiquadFilterNode and PannerNode.

Test: webaudio/pannernode-basic.html

* GNUmakefile.list.am:
* Modules/webaudio/BiquadFilterNode.cpp:
(WebCore::BiquadFilterNode::type):
(WebCore):
(WebCore::BiquadFilterNode::setType):
* Modules/webaudio/BiquadFilterNode.h:
(BiquadFilterNode):
* Modules/webaudio/BiquadFilterNode.idl:
* Modules/webaudio/PannerNode.cpp:
(WebCore::PannerNode::panningModel):
(WebCore):
(WebCore::PannerNode::setPanningModel):
(WebCore::PannerNode::distanceModel):
(WebCore::PannerNode::setDistanceModel):
* Modules/webaudio/PannerNode.h:
(PannerNode):
* Modules/webaudio/PannerNode.idl:
* Target.pri:
* UseJSC.cmake:
* UseV8.cmake:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBiquadFilterNodeCustom.cpp: Copied from Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp.
(WebCore):
(WebCore::JSBiquadFilterNode::setType):
* bindings/js/JSPannerNodeCustom.cpp: Copied from Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp.
(WebCore):
(WebCore::JSPannerNode::setPanningModel):
(WebCore::JSPannerNode::setDistanceModel):
* bindings/v8/custom/V8BiquadFilterNodeCustom.cpp: Copied from Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp.
(WebCore):
(WebCore::V8BiquadFilterNode::typeAccessorSetter):
* bindings/v8/custom/V8PannerNodeCustom.cpp: Added.
(WebCore):
(WebCore::V8PannerNode::panningModelAccessorSetter):
(WebCore::V8PannerNode::distanceModelAccessorSetter):

LayoutTests:

* webaudio/audiopannernode-basic-expected.txt: Removed.
* webaudio/audiopannernode-basic.html: Removed.
* webaudio/biquad-getFrequencyResponse-expected.txt:
* webaudio/biquad-getFrequencyResponse.html:
* webaudio/biquadfilternode-basic-expected.txt:
* webaudio/biquadfilternode-basic.html:
* webaudio/pannernode-basic-expected.txt: Added.
* webaudio/pannernode-basic.html: Added.
* webaudio/resources/biquad-testing.js:
* webaudio/resources/distance-model-testing.js:
(createGraph):
(.return.renderedBuffer):
(checkDistanceResult):
* webaudio/resources/panner-model-testing.js:
(createGraph):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138849 268f45cc-cd09-0410-ab3c-d52691b4dbfc

29 files changed:
LayoutTests/ChangeLog
LayoutTests/webaudio/audiopannernode-basic-expected.txt [deleted file]
LayoutTests/webaudio/audiopannernode-basic.html [deleted file]
LayoutTests/webaudio/biquad-getFrequencyResponse-expected.txt
LayoutTests/webaudio/biquad-getFrequencyResponse.html
LayoutTests/webaudio/biquadfilternode-basic-expected.txt
LayoutTests/webaudio/biquadfilternode-basic.html
LayoutTests/webaudio/pannernode-basic-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/pannernode-basic.html [new file with mode: 0644]
LayoutTests/webaudio/resources/biquad-testing.js
LayoutTests/webaudio/resources/distance-model-testing.js
LayoutTests/webaudio/resources/panner-model-testing.js
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp
Source/WebCore/Modules/webaudio/BiquadFilterNode.h
Source/WebCore/Modules/webaudio/BiquadFilterNode.idl
Source/WebCore/Modules/webaudio/PannerNode.cpp
Source/WebCore/Modules/webaudio/PannerNode.h
Source/WebCore/Modules/webaudio/PannerNode.idl
Source/WebCore/Target.pri
Source/WebCore/UseJSC.cmake
Source/WebCore/UseV8.cmake
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSPannerNodeCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/custom/V8PannerNodeCustom.cpp [new file with mode: 0644]

index 2bd72d6e9973b1cf51926974a4b283d8591319dd..85aaac0a98f5d6f50c1fc81295e040622a25bb29 100644 (file)
@@ -1,3 +1,26 @@
+2013-01-04  Chris Rogers  <crogers@google.com>
+
+        Implement WebIDL-style string constants in WebAudio (part 2)
+        https://bugs.webkit.org/show_bug.cgi?id=105977
+
+        Reviewed by Kentaro Hara.
+
+        * webaudio/audiopannernode-basic-expected.txt: Removed.
+        * webaudio/audiopannernode-basic.html: Removed.
+        * webaudio/biquad-getFrequencyResponse-expected.txt:
+        * webaudio/biquad-getFrequencyResponse.html:
+        * webaudio/biquadfilternode-basic-expected.txt:
+        * webaudio/biquadfilternode-basic.html:
+        * webaudio/pannernode-basic-expected.txt: Added.
+        * webaudio/pannernode-basic.html: Added.
+        * webaudio/resources/biquad-testing.js:
+        * webaudio/resources/distance-model-testing.js:
+        (createGraph):
+        (.return.renderedBuffer):
+        (checkDistanceResult):
+        * webaudio/resources/panner-model-testing.js:
+        (createGraph):
+
 2013-01-04  Terry Anderson  <tdanderson@chromium.org>
 
         Unreviewed gardening. The following two tests are flaky on XP:
diff --git a/LayoutTests/webaudio/audiopannernode-basic-expected.txt b/LayoutTests/webaudio/audiopannernode-basic-expected.txt
deleted file mode 100644 (file)
index 5a9774e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-Basic test for AudioPannerNode.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-PASS AudioPannerNode has one input.
-PASS AudioPannerNode has one output.
-PASS panningModel default value is HRTF.
-PASS refDistance default value is 1.
-PASS maxDistance default value is 10000.
-PASS rolloffFactor default value is 1.
-PASS coneInnerAngle default value is 360.
-PASS coneOuterAngle default value is 360.
-PASS coneOuterGain default value is 0.
-PASS panningModel set to EQUALPOWER model and read correctly.
-PASS panningModel set to HRTF model and read correctly.
-PASS Setting panningModel to SOUNDFIELD correctly throws exception because it is not implemented.
-PASS Illegal panningModel correctly throws exception.
-PASS distanceModel set to LINEAR_DISTANCE and read correctly.
-PASS distanceModel set to INVERSE_DISTANCE and read correctly.
-PASS distanceModel set to EXPONENTIAL_DISTANCE and read correctly.
-PASS Illegal distanceModel correctly throws exception.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/webaudio/audiopannernode-basic.html b/LayoutTests/webaudio/audiopannernode-basic.html
deleted file mode 100644 (file)
index 36d4207..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src="resources/audio-testing.js"></script>
-<script src="../fast/js/resources/js-test-pre.js"></script>
-</head>
-
-<body>
-<div id="description"></div>
-<div id="console"></div>
-
-<script>
-description("Basic test for AudioPannerNode.");
-
-function runTest() {
-    if (window.testRunner) {
-        testRunner.dumpAsText();
-        testRunner.waitUntilDone();
-    }
-
-    window.jsTestIsAsync = true;
-
-    var context = new webkitAudioContext();
-    var panner = context.createPanner();
-    
-    if (panner.numberOfInputs === 1)
-        testPassed("AudioPannerNode has one input.");
-    else
-        testFailed("AudioPannerNode should have one input.");
-
-    if (panner.numberOfOutputs === 1)
-        testPassed("AudioPannerNode has one output.");
-    else
-        testFailed("AudioPannerNode should have one output.");
-
-    if (panner.panningModel === panner.HRTF)
-        testPassed("panningModel default value is HRTF.");
-    else
-        testFailed("panningModel default value is not HRTF.");
-    if (panner.refDistance === 1)
-        testPassed("refDistance default value is 1.");
-    else
-        testFailed("refDistance default value should be 1.");
-
-    if (panner.maxDistance === 10000)
-        testPassed("maxDistance default value is 10000.");
-    else
-        testFailed("maxDistance default value should be 10000.");
-
-    if (panner.rolloffFactor === 1)
-        testPassed("rolloffFactor default value is 1.");
-    else
-        testFailed("rolloffFactor default value should be 1.");
-
-    if (panner.coneInnerAngle === 360)
-        testPassed("coneInnerAngle default value is 360.");
-    else
-        testFailed("coneInnerAngle default value should be 360.");
-
-    if (panner.coneOuterAngle === 360)
-        testPassed("coneOuterAngle default value is 360.");
-    else
-        testFailed("coneOuterAngle default value should be 360.");
-
-    if (panner.coneOuterGain === 0)
-        testPassed("coneOuterGain default value is 0.");
-    else
-        testFailed("coneOuterGain default value should be 0.");
-
-    // Set the panning model and see if it can be read back correctly.
-    panner.panningModel = panner.EQUALPOWER;
-    if (panner.panningModel === 0)
-        testPassed("panningModel set to EQUALPOWER model and read correctly.");
-    else
-        testFailed("panningModel set to EQUALPOWER (0) but returned " + panner.panningModel);
-    
-    panner.panningModel = panner.HRTF;
-    if (panner.panningModel === 1)
-        testPassed("panningModel set to HRTF model and read correctly.");
-    else
-        testFailed("panningModel set to HRTF (1) but returned " + panner.panningModel);
-
-    // SOUNDFIELD should throw exception because it is not
-    // currently implemented.  (See https://bugs.webkit.org/show_bug.cgi?id=77367)
-    try {
-        panner.panningModel = panner.SOUNDFIELD;
-        testFailed("Setting panningModel to SOUNDFIELD should throw exception because it is not implemented.");
-    } catch(e) {
-        testPassed("Setting panningModel to SOUNDFIELD correctly throws exception because it is not implemented.");
-    }
-
-    // Other invalid models should throw an exception.
-    try {
-        panner.panningModel = panner.SOUNDFIELD + 1;
-        testFailed("Illegal panningModel should throw exception.");
-    } catch(e) {
-        testPassed("Illegal panningModel correctly throws exception.");
-    }
-
-    panner.distanceModel = panner.LINEAR_DISTANCE;
-    if (panner.distanceModel === 0)
-        testPassed("distanceModel set to LINEAR_DISTANCE and read correctly.");
-    else
-        testFailed("distanceModel set to LINEAR_DISTANCE (0) but returned " + panner.distanceModel);
-
-    panner.distanceModel = panner.INVERSE_DISTANCE;
-    if (panner.distanceModel === 1)
-        testPassed("distanceModel set to INVERSE_DISTANCE and read correctly.");
-    else
-        testFailed("distanceModel set to INVERSE_DISTANCE (1) but returned " + panner.distanceModel);
-
-    panner.distanceModel = panner.EXPONENTIAL_DISTANCE;
-    if (panner.distanceModel === 2)
-        testPassed("distanceModel set to EXPONENTIAL_DISTANCE and read correctly.");
-    else
-        testFailed("distanceModel set to EXPONENTIAL_DISTANCE (2) but returned " + panner.distanceModel);
-
-    try {
-        panner.distanceModel = panner.EXPONENTIAL_DISTANCE + 1;
-        testFailed("Illegal distanceModel should throw exception.");
-    } catch(e) {
-        testPassed("Illegal distanceModel correctly throws exception.");
-    }
-
-    finishJSTest();
-}
-
-runTest();
-successfullyParsed = true;
-</script>
-
-<script src="../fast/js/resources/js-test-post.js"></script>
-</body>
-</html>
index 9301182390ee526854155ce9462af79e591e594b..8ee7326c5c63a306a0c066b343e1fa47256df90a 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS Magnitude response within acceptable threshold.
 PASS Phase response within acceptable threshold.
-PASS Peaking filter frequency response was correct.
+PASS Frequency response was correct.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 4762da628307076999fd5b9223490537418a854f..9ec2089c528675a6f20c33b9866b24183cba1c19 100644 (file)
@@ -107,7 +107,7 @@ function frequencyResponseReference(filter, frequencies)
 {
     var sampleRate = filter.context.sampleRate;
     var normalizedFreq = normalizedFrequency(filter.frequency.value, sampleRate);
-    var filterCoefficients = createFilter(filter.type, normalizedFreq, filter.Q.value, filter.gain.value);
+    var filterCoefficients = createFilter(filterTypeIndex[filter.type], normalizedFreq, filter.Q.value, filter.gain.value);
 
     var magnitudes = [];
     var phases = [];
@@ -283,7 +283,7 @@ function runTest()
     filter = context.createBiquadFilter();
 
     // Arbitrarily test a peaking filter, but any kind of filter can be tested.
-    filter.type = filter.PEAKING;
+    filter.type = "peaking";
     filter.frequency.value = filterCutoff;
     filter.Q.value = filterQ;
     filter.gain.value = filterGain;
@@ -296,9 +296,9 @@ function runTest()
     var success = compareResponses(filter, frequencies, magResponse, phaseResponse);
 
     if (success) {
-        testPassed(filterTypeName[filter.type] + " frequency response was correct.");
+        testPassed("Frequency response was correct.");
     } else {
-        testFailed(filterTypeName[filter.type] + " frequency response was incorrect.");
+        testFailed("Frequency response was incorrect.");
     }
 
     finishJSTest();
index 9251f005ee45156576b18bc09b72c0be8deb31e2..a3e1cae6081e9d847940427584c5eb14ca085421 100644 (file)
@@ -2,21 +2,31 @@ Basic tests for BiquadFilterNode.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
-PASS BiquadFilterNode has one iutput.
+PASS BiquadFilterNode has one input.
 PASS BiquadFilterNode has one output.
 PASS Biquad filter defaults to low-pass filter.
 PASS The default value of frequency is 350.
 PASS The default value of Q is 1.
 PASS The default value of gain is 0.
-PASS Biquad filter type 0 is settable.
-PASS Biquad filter type 1 is settable.
-PASS Biquad filter type 2 is settable.
-PASS Biquad filter type 3 is settable.
-PASS Biquad filter type 4 is settable.
-PASS Biquad filter type 5 is settable.
-PASS Biquad filter type 6 is settable.
-PASS Biquad filter type 7 is settable.
+PASS Biquad filter type 'lowpass' is settable.
+PASS Biquad filter type 'highpass' is settable.
+PASS Biquad filter type 'bandpass' is settable.
+PASS Biquad filter type 'lowshelf' is settable.
+PASS Biquad filter type 'highshelf' is settable.
+PASS Biquad filter type 'peaking' is settable.
+PASS Biquad filter type 'notch' is settable.
+PASS Biquad filter type 'allpass' is settable.
+PASS Biquad filter type 0 is settable using legacy integer value.
+PASS Biquad filter type 1 is settable using legacy integer value.
+PASS Biquad filter type 2 is settable using legacy integer value.
+PASS Biquad filter type 3 is settable using legacy integer value.
+PASS Biquad filter type 4 is settable using legacy integer value.
+PASS Biquad filter type 5 is settable using legacy integer value.
+PASS Biquad filter type 6 is settable using legacy integer value.
+PASS Biquad filter type 7 is settable using legacy integer value.
 PASS Illegal filter type correctly throws exception.
+PASS Setting .type to illegal string value threw TypeError.
+PASS Setting .type to illegal type of Float32Array threw TypeError.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 367fc08381febdb35abf74ec5f15770de979eb5f..9751dd6c5bb932259574f3d80efbf72f835f0042 100644 (file)
@@ -26,16 +26,16 @@ function runTest() {
     var filter = context.createBiquadFilter();
    
     if (filter.numberOfInputs === 1) 
-        testPassed("BiquadFilterNode has one iutput.");
+        testPassed("BiquadFilterNode has one input.");
     else
-        testFailed("BiquadFilterNode should have one iutput.");
+        testFailed("BiquadFilterNode should have one input.");
     
     if (filter.numberOfOutputs === 1) 
         testPassed("BiquadFilterNode has one output.");
     else
         testFailed("BiquadFilterNode should have one output.");
     
-    if (filter.type === filter.LOWPASS)
+    if (filter.type === "lowpass")
         testPassed("Biquad filter defaults to low-pass filter.");
     else
         testFailed("Biquad filter should default to low-pass filter.");
@@ -56,23 +56,23 @@ function runTest() {
         testFailed("The default value of gain should be 0.");
 
     // Check that all legal filter types can be set.
-    var filterTypeArray = [filter.LOWPASS,
-                           filter.HIGHPASS,
-                           filter.BANDPASS,
-                           filter.LOWSHELF,
-                           filter.HIGHSHELF,
-                           filter.PEAKING,
-                           filter.NOTCH,
-                           filter.ALLPASS];
+    var filterTypeArray = [{type: "lowpass", integerType: filter.LOWPASS},
+                           {type: "highpass", integerType: filter.HIGHPASS},
+                           {type: "bandpass", integerType: filter.BANDPASS},
+                           {type: "lowshelf", integerType: filter.LOWSHELF},
+                           {type: "highshelf", integerType: filter.HIGHSHELF},
+                           {type: "peaking", integerType: filter.PEAKING},
+                           {type: "notch", integerType: filter.NOTCH},
+                           {type: "allpass", integerType: filter.ALLPASS}];
 
     for (var i = 0; i < filterTypeArray.length; ++i) {
         try {
-            filter.type = filterTypeArray[i];
-            if (filter.type === filterTypeArray[i] && filterTypeArray[i] === i) {
-                var message = "Biquad filter type " + i + " is settable.";
+            filter.type = filterTypeArray[i].type;
+            if (filter.type === filterTypeArray[i].type) {
+                var message = "Biquad filter type '" + filterTypeArray[i].type + "' is settable.";
                 testPassed(message);
             } else {
-                var message = "Biquad filter type " + i + " was not correctly set.";
+                var message = "Biquad filter type '" + filterTypeArray[i].type + "' was not correctly set.";
                 testFailed(message);
             }
         } catch(e) {
@@ -81,6 +81,24 @@ function runTest() {
         }
     }
 
+    // For legacy support, verify that we can set the type attribute as an integer value and
+    // verify that this translates correctly to the WebIDL enum value.
+    for (var i = 0; i < filterTypeArray.length; ++i) {
+        try {
+            filter.type = filterTypeArray[i].integerType;
+            if (filter.type === filterTypeArray[i].type && filterTypeArray[i].integerType === i) {
+                var message = "Biquad filter type " + i + " is settable using legacy integer value.";
+                testPassed(message);
+            } else {
+                var message = "Biquad filter type " + i + " was not correctly set using legacy integer value.";
+                testFailed(message);
+            }
+        } catch(e) {
+            var message = "Biquad filter type " + i + " should not throw exception using legacy integer value.";
+            testFailed(message);
+        }
+    }
+
     // Check that illegal filter type throws.
     try {
         filter.type = filter.ALLPASS + 1;
@@ -89,6 +107,10 @@ function runTest() {
         testPassed("Illegal filter type correctly throws exception.");
     }
 
+    // Check specifically that we throw a TypeError.
+    shouldThrowTypeError(function() { filter.type = "xyz12349jfksd"; }, "Setting .type to illegal string value");
+    shouldThrowTypeError(function() { filter.type = new Float32Array(1); }, "Setting .type to illegal type of Float32Array");
+
     finishJSTest();
 }
 
diff --git a/LayoutTests/webaudio/pannernode-basic-expected.txt b/LayoutTests/webaudio/pannernode-basic-expected.txt
new file mode 100644 (file)
index 0000000..451f517
--- /dev/null
@@ -0,0 +1,30 @@
+Basic tests for PannerNode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS PannerNode has one input.
+PASS PannerNode has one output.
+PASS refDistance default value is 1.
+PASS maxDistance default value is 10000.
+PASS rolloffFactor default value is 1.
+PASS coneInnerAngle default value is 360.
+PASS coneOuterAngle default value is 360.
+PASS coneOuterGain default value is 0.
+PASS PannerNode defaults to 'HRTF' panningModel.
+PASS PannerNode defaults to 'inverse' distanceModel.
+PASS panningModel: 'equalpower' is settable.
+PASS panningModel: 'HRTF' is settable.
+PASS panningModel: 0 is settable using legacy integer value.
+PASS panningModel: 1 is settable using legacy integer value.
+PASS distanceModel: 'linear' is settable.
+PASS distanceModel: 'inverse' is settable.
+PASS distanceModel: 'exponential' is settable.
+PASS distanceModel: 0 is settable using legacy integer value.
+PASS distanceModel: 1 is settable using legacy integer value.
+PASS distanceModel: 2 is settable using legacy integer value.
+PASS Setting .type to illegal string value threw TypeError.
+PASS Setting .type to illegal type of Float32Array threw TypeError.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/webaudio/pannernode-basic.html b/LayoutTests/webaudio/pannernode-basic.html
new file mode 100644 (file)
index 0000000..e98899d
--- /dev/null
@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/audio-testing.js"></script>
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Basic tests for PannerNode.");
+
+var context = 0;
+
+function runTest() {
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+    
+    window.jsTestIsAsync = true;
+
+    context = new webkitAudioContext();
+    var panner = context.createPanner();
+   
+    if (panner.numberOfInputs === 1) 
+        testPassed("PannerNode has one input.");
+    else
+        testFailed("PannerNode should have one input.");
+    
+    if (panner.numberOfOutputs === 1) 
+        testPassed("PannerNode has one output.");
+    else
+        testFailed("PannerNode should have one output.");
+
+    if (panner.refDistance === 1)
+        testPassed("refDistance default value is 1.");
+    else
+        testFailed("refDistance default value should be 1.");
+    
+    if (panner.maxDistance === 10000)
+        testPassed("maxDistance default value is 10000.");
+    else
+        testFailed("maxDistance default value should be 10000.");
+    
+    if (panner.rolloffFactor === 1)
+        testPassed("rolloffFactor default value is 1.");
+    else
+        testFailed("rolloffFactor default value should be 1.");
+    
+    if (panner.coneInnerAngle === 360)
+        testPassed("coneInnerAngle default value is 360.");
+    else
+        testFailed("coneInnerAngle default value should be 360.");
+    
+    if (panner.coneOuterAngle === 360)
+        testPassed("coneOuterAngle default value is 360.");
+    else
+        testFailed("coneOuterAngle default value should be 360.");
+    
+    if (panner.coneOuterGain === 0)
+        testPassed("coneOuterGain default value is 0.");
+    else
+        testFailed("coneOuterGain default value should be 0.");
+
+    if (panner.panningModel === "HRTF")
+        testPassed("PannerNode defaults to 'HRTF' panningModel.");
+    else
+        testFailed("PannerNode should default to 'HRTF' panningModel.");
+    
+    if (panner.distanceModel === "inverse")
+        testPassed("PannerNode defaults to 'inverse' distanceModel.");
+    else
+        testFailed("PannerNode should default to 'inverse' distanceModel.");
+
+    // Check that the .panningModel attribute can be set to all legal values.
+    var panningModels = [{value: "equalpower", integerValue: panner.EQUALPOWER},
+                         {value: "HRTF", integerValue: panner.HRTF},
+                         // FIXME: enable "soundfield" once feature is implemented: https://bugs.webkit.org/show_bug.cgi?id=77367
+                         // {value: "soundfield", integerValue: panner.SOUNDFIELD}
+                        ];
+
+    for (var i = 0; i < panningModels.length; ++i) {
+        try {
+            panner.panningModel = panningModels[i].value;
+            if (panner.panningModel === panningModels[i].value) {
+                var message = "panningModel: '" + panningModels[i].value + "' is settable.";
+                testPassed(message);
+            } else {
+                var message = "panningModel: '" + panningModels[i].value + "' was not correctly set.";
+                testFailed(message);
+            }
+        } catch(e) {
+            var message = "Setting panningModel to '" + panningModels[i].value + "' should not throw exception.";
+            testFailed(message);
+        }
+    }
+
+    // For legacy support, verify that we can set the .panningModel attribute as an integer value and
+    // verify that this translates correctly to the WebIDL enum value.
+    for (var i = 0; i < panningModels.length; ++i) {
+        try {
+            panner.panningModel = panningModels[i].integerValue;
+            if (panner.panningModel === panningModels[i].value && panningModels[i].integerValue === i) {
+                var message = "panningModel: " + panningModels[i].integerValue + " is settable using legacy integer value.";
+                testPassed(message);
+            } else {
+                var message = "panningModel: " + panningModels[i].integerValue + " was not correctly set using legacy integer value.";
+                testFailed(message);
+            }
+        } catch(e) {
+            var message = "Setting panningModel to " + panningModels[i].integerValue + " should not throw exception using legacy integer value.";
+            testFailed(message);
+        }
+    }
+
+    // Check that the .distanceModel attribute can be set to all legal values.
+    var distanceModels = [{value: "linear", integerValue: panner.LINEAR_DISTANCE},
+                          {value: "inverse", integerValue: panner.INVERSE_DISTANCE},
+                          {value: "exponential", integerValue: panner.EXPONENTIAL_DISTANCE}
+                        ];
+
+    for (var i = 0; i < distanceModels.length; ++i) {
+        try {
+            panner.distanceModel = distanceModels[i].value;
+            if (panner.distanceModel === distanceModels[i].value) {
+                var message = "distanceModel: '" + distanceModels[i].value + "' is settable.";
+                testPassed(message);
+            } else {
+                var message = "distanceModel: '" + distanceModels[i].value + "' was not correctly set.";
+                testFailed(message);
+            }
+        } catch(e) {
+            var message = "Setting distanceModel to '" + distanceModels[i].value + "' should not throw exception.";
+            testFailed(message);
+        }
+    }
+
+    // For legacy support, verify that we can set the .distanceModel attribute as an integer value and
+    // verify that this translates correctly to the WebIDL enum value.
+    for (var i = 0; i < distanceModels.length; ++i) {
+        try {
+            panner.distanceModel = distanceModels[i].integerValue;
+            if (panner.distanceModel === distanceModels[i].value && distanceModels[i].integerValue === i) {
+                var message = "distanceModel: " + distanceModels[i].integerValue + " is settable using legacy integer value.";
+                testPassed(message);
+            } else {
+                var message = "distanceModel: " + distanceModels[i].integerValue + " was not correctly set using legacy integer value.";
+                testFailed(message);
+            }
+        } catch(e) {
+            var message = "Setting distanceModel to " + distanceModels[i].integerValue + " should not throw exception using legacy integer value.";
+            testFailed(message);
+        }
+    }
+
+    // Check that we throw a TypeError for illegal .distanceModel values.
+    shouldThrowTypeError(function() { panner.distanceModel = "xyz12349jfksd"; }, "Setting .type to illegal string value");
+    shouldThrowTypeError(function() { panner.distanceModel = new Float32Array(1); }, "Setting .type to illegal type of Float32Array");
+
+    finishJSTest();
+}
+
+runTest();
+
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 97bc9e92016b8085fa6c01c4e3857e161355cb81..027af11a977336f38a4677011369217cde8a49d3 100644 (file)
@@ -367,6 +367,15 @@ var filterTypeName = ["Lowpass filter",
                       "Notch filter",
                       "Allpass filter"];
 
+var filterTypeIndex = {"lowpass": 0,
+                       "highpass": 1,
+                       "bandpass": 2,
+                       "lowshelf": 3,
+                       "highshelf": 4,
+                       "peaking": 5,
+                       "notch": 6,
+                       "allpass": 7};
+
 function createFilter(filterType, freq, q, gain) {
     return filterCreatorFunction[filterType](freq, q, gain);
 }
index 129eb55ebc7b82bad57c218e940c6f60b9f75ac8..97f2eba5fe5410ac8992655e890cc0da9d7577c1 100644 (file)
@@ -55,6 +55,7 @@ function exponentialDistance(panner, x, y, z) {
 // This array must be arranged in the numeric order of the distance
 // model values.
 var distanceModelFunction = [linearDistance, inverseDistance, exponentialDistance];
+var distanceModelIndex = {"linear": 0, "inverse": 1, "exponential": 2};
 
 function createGraph(context, distanceModel, nodeCount) {
     bufferSource = new Array(nodeCount);
@@ -83,7 +84,7 @@ function createGraph(context, distanceModel, nodeCount) {
         bufferSource[k].buffer = impulse;
 
         panner[k] = context.createPanner();
-        panner[k].panningModel = panner.EQUALPOWER;
+        panner[k].panningModel = "equalpower";
         panner[k].distanceModel = distanceModel;
 
         var distanceStep = (panner[k].maxDistance - panner[k].refDistance) / nodeCount;
@@ -150,7 +151,9 @@ function checkDistanceResult(model, expectedModel) {
         // distance.
         for (var k = 0; k < renderedData.length; ++k) {
             if (renderedData[k] != 0) {
-                var distanceFunction = distanceModelFunction[panner[impulseCount].distanceModel];
+                // Convert from string to index.
+                var modelIndex = distanceModelIndex[panner[impulseCount].distanceModel];
+                var distanceFunction = distanceModelFunction[modelIndex];
                 var expected = distanceFunction(panner[impulseCount], 0, 0, position[impulseCount]);
 
                 // Adjust for the center-panning of the EQUALPOWER panning
index 1888800fe10c860f7c5121ef9b71f8fef5223e3a..598549eccd8d9025d38507375f892e28c3d7a0b6 100644 (file)
@@ -46,8 +46,8 @@ function createGraph(context, nodeCount) {
         bufferSource[k].buffer = impulse;
 
         panner[k] = context.createPanner();
-        panner[k].panningModel = panner.EQUALPOWER;
-        panner[k].distanceModel = 0; // Linear distance model.
+        panner[k].panningModel = "equalpower";
+        panner[k].distanceModel = "linear";
 
         var angle = angleStep * k;
         position[k] = {angle : angle, x : Math.cos(angle), z : Math.sin(angle)};
index 8cb9cf9a559e88ac9dced03963a9edf4a902364b..ba7a9a68bb8d7b7c0037487c15aff82d074b96e5 100644 (file)
@@ -1,3 +1,56 @@
+2013-01-04  Chris Rogers  <crogers@google.com>
+
+        Implement WebIDL-style string constants in WebAudio (part 2)
+        https://bugs.webkit.org/show_bug.cgi?id=105977
+
+        Reviewed by Kentaro Hara.
+
+        See Deprecation Notes for more detail:
+        https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#DeprecationNotes
+
+        PannerNode, BiquadFilterNode, OscillatorNode constants must support WebIDL-style string constants.
+        Legacy support in the setters for the old integer values should be supported.
+        This patch handles the changes for BiquadFilterNode and PannerNode.
+             
+        Test: webaudio/pannernode-basic.html
+
+        * GNUmakefile.list.am:
+        * Modules/webaudio/BiquadFilterNode.cpp:
+        (WebCore::BiquadFilterNode::type):
+        (WebCore):
+        (WebCore::BiquadFilterNode::setType):
+        * Modules/webaudio/BiquadFilterNode.h:
+        (BiquadFilterNode):
+        * Modules/webaudio/BiquadFilterNode.idl:
+        * Modules/webaudio/PannerNode.cpp:
+        (WebCore::PannerNode::panningModel):
+        (WebCore):
+        (WebCore::PannerNode::setPanningModel):
+        (WebCore::PannerNode::distanceModel):
+        (WebCore::PannerNode::setDistanceModel):
+        * Modules/webaudio/PannerNode.h:
+        (PannerNode):
+        * Modules/webaudio/PannerNode.idl:
+        * Target.pri:
+        * UseJSC.cmake:
+        * UseV8.cmake:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBiquadFilterNodeCustom.cpp: Copied from Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp.
+        (WebCore):
+        (WebCore::JSBiquadFilterNode::setType):
+        * bindings/js/JSPannerNodeCustom.cpp: Copied from Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp.
+        (WebCore):
+        (WebCore::JSPannerNode::setPanningModel):
+        (WebCore::JSPannerNode::setDistanceModel):
+        * bindings/v8/custom/V8BiquadFilterNodeCustom.cpp: Copied from Source/WebCore/Modules/webaudio/BiquadFilterNode.cpp.
+        (WebCore):
+        (WebCore::V8BiquadFilterNode::typeAccessorSetter):
+        * bindings/v8/custom/V8PannerNodeCustom.cpp: Added.
+        (WebCore):
+        (WebCore::V8PannerNode::panningModelAccessorSetter):
+        (WebCore::V8PannerNode::distanceModelAccessorSetter):
+
 2013-01-04  Rick Byers  <rbyers@chromium.org>
 
         window.Touch and TouchList should exist when touch events are enabled
index f810a02767809d652c93c3e26d95fadf084cae93..d76de801526f859e19c2b838da44a1433b4e7504 100644 (file)
@@ -2256,6 +2256,7 @@ webcore_sources += \
        Source/WebCore/bindings/js/JSAttrCustom.cpp \
        Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp \
        Source/WebCore/bindings/js/JSAudioContextCustom.cpp \
+       Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp \
        Source/WebCore/bindings/js/JSBlobCustom.cpp \
        Source/WebCore/bindings/js/JSCDATASectionCustom.cpp \
        Source/WebCore/bindings/js/JSCSSFontFaceRuleCustom.cpp \
@@ -2384,6 +2385,7 @@ webcore_sources += \
        Source/WebCore/bindings/js/JSNodeIteratorCustom.cpp \
        Source/WebCore/bindings/js/JSNodeListCustom.cpp \
        Source/WebCore/bindings/js/JSOscillatorNodeCustom.cpp \
+       Source/WebCore/bindings/js/JSPannerNodeCustom.cpp \
        Source/WebCore/bindings/js/JSPluginElementFunctions.cpp \
        Source/WebCore/bindings/js/JSPluginElementFunctions.h \
        Source/WebCore/bindings/js/JSPopStateEventCustom.cpp \
index d752e2c3920c4e08865924f6e45b9551ebfe7cfe..2f51a48293b61f273105ddae649c936ce1870f79 100644 (file)
@@ -40,17 +40,62 @@ BiquadFilterNode::BiquadFilterNode(AudioContext* context, float sampleRate)
     setNodeType(NodeTypeBiquadFilter);
 }
 
-void BiquadFilterNode::setType(unsigned short type, ExceptionCode& ec)
+String BiquadFilterNode::type() const
 {
-    if (type > BiquadProcessor::Allpass) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
+    switch (const_cast<BiquadFilterNode*>(this)->biquadProcessor()->type()) {
+    case BiquadProcessor::LowPass:
+        return "lowpass";
+    case BiquadProcessor::HighPass:
+        return "highpass";
+    case BiquadProcessor::BandPass:
+        return "bandpass";
+    case BiquadProcessor::LowShelf:
+        return "lowshelf";
+    case BiquadProcessor::HighShelf:
+        return "highshelf";
+    case BiquadProcessor::Peaking:
+        return "peaking";
+    case BiquadProcessor::Notch:
+        return "notch";
+    case BiquadProcessor::Allpass:
+        return "allpass";
+    default:
+        ASSERT_NOT_REACHED();
+        return "lowpass";
     }
+}
+
+void BiquadFilterNode::setType(const String& type)
+{
+    if (type == "lowpass")
+        setType(BiquadProcessor::LowPass);
+    else if (type == "highpass")
+        setType(BiquadProcessor::HighPass);
+    else if (type == "bandpass")
+        setType(BiquadProcessor::BandPass);
+    else if (type == "lowshelf")
+        setType(BiquadProcessor::LowShelf);
+    else if (type == "highshelf")
+        setType(BiquadProcessor::HighShelf);
+    else if (type == "peaking")
+        setType(BiquadProcessor::Peaking);
+    else if (type == "notch")
+        setType(BiquadProcessor::Notch);
+    else if (type == "allpass")
+        setType(BiquadProcessor::Allpass);
+    else
+        ASSERT_NOT_REACHED();
+}
+
+bool BiquadFilterNode::setType(unsigned type)
+{
+    if (type > BiquadProcessor::Allpass)
+        return false;
     
     biquadProcessor()->setType(static_cast<BiquadProcessor::FilterType>(type));
+    return true;
 }
 
-
 void BiquadFilterNode::getFrequencyResponse(const Float32Array* frequencyHz,
                                             Float32Array* magResponse,
                                             Float32Array* phaseResponse)
index f6699af8046a7f9693cce2f78e51e5bc48db90da..dde2aec7726e49e77c1ab63600eb4052355fc3b2 100644 (file)
@@ -50,9 +50,10 @@ public:
     {
         return adoptRef(new BiquadFilterNode(context, sampleRate));      
     }
-    
-    unsigned short type() { return biquadProcessor()->type(); }
-    void setType(unsigned short type, ExceptionCode&);
+
+    String type() const;
+    bool setType(unsigned); // Returns true on success.
+    void setType(const String&);
 
     AudioParam* frequency() { return biquadProcessor()->parameter1(); }
     AudioParam* q() { return biquadProcessor()->parameter2(); }
index af20d0be8df9a64dcd45846fe7bf2a2c661206f6..f374af525353d3241847cfb85f69c9ad539b8c26 100644 (file)
@@ -36,8 +36,7 @@
     const unsigned short NOTCH = 6;
     const unsigned short ALLPASS = 7;
 
-    attribute unsigned short type
-        setter raises(DOMException);
+    [CustomSetter] attribute DOMString type;
     
     readonly attribute AudioParam frequency; // in Hertz
     readonly attribute AudioParam detune; // in Cents
index 96d4d81817ba9ed53fc14e3e2c2b10cb2ffd7118..312499b910a1f47a828709187de8bc846111b693 100644 (file)
@@ -35,6 +35,7 @@
 #include "AudioNodeOutput.h"
 #include "ExceptionCode.h"
 #include "HRTFPanner.h"
+#include "ScriptExecutionContext.h"
 #include <wtf/MathExtras.h>
 
 using namespace std;
@@ -151,7 +152,34 @@ AudioListener* PannerNode::listener()
     return context()->listener();
 }
 
-void PannerNode::setPanningModel(unsigned short model, ExceptionCode& ec)
+String PannerNode::panningModel() const
+{
+    switch (m_panningModel) {
+    case EQUALPOWER:
+        return "equalpower";
+    case HRTF:
+        return "HRTF";
+    case SOUNDFIELD:
+        return "soundfield";
+    default:
+        ASSERT_NOT_REACHED();
+        return "HRTF";
+    }
+}
+
+void PannerNode::setPanningModel(const String& model)
+{
+    if (model == "equalpower")
+        setPanningModel(EQUALPOWER);
+    else if (model == "HRTF")
+        setPanningModel(HRTF);
+    else if (model == "soundfield")
+        setPanningModel(SOUNDFIELD);
+    else
+        ASSERT_NOT_REACHED();
+}
+
+bool PannerNode::setPanningModel(unsigned model)
 {
     switch (model) {
     case EQUALPOWER:
@@ -164,14 +192,43 @@ void PannerNode::setPanningModel(unsigned short model, ExceptionCode& ec)
         break;
     case SOUNDFIELD:
         // FIXME: Implement sound field model. See // https://bugs.webkit.org/show_bug.cgi?id=77367.
-        // For now, fall through to throw an exception.
-    default:
-        ec = NOT_SUPPORTED_ERR;
+        context()->scriptExecutionContext()->addConsoleMessage(JSMessageSource, WarningMessageLevel, "'soundfield' panning model not implemented.");
         break;
+    default:
+        return false;
     }
+    
+    return true;
 }
 
-void PannerNode::setDistanceModel(unsigned short model, ExceptionCode& ec)
+String PannerNode::distanceModel() const
+{
+    switch (const_cast<PannerNode*>(this)->m_distanceEffect.model()) {
+    case DistanceEffect::ModelLinear:
+        return "linear";
+    case DistanceEffect::ModelInverse:
+        return "inverse";
+    case DistanceEffect::ModelExponential:
+        return "exponential";
+    default:
+        ASSERT_NOT_REACHED();
+        return "inverse";
+    }
+}
+
+void PannerNode::setDistanceModel(const String& model)
+{
+    if (model == "linear")
+        setDistanceModel(DistanceEffect::ModelLinear);
+    else if (model == "inverse")
+        setDistanceModel(DistanceEffect::ModelInverse);
+    else if (model == "exponential")
+        setDistanceModel(DistanceEffect::ModelExponential);
+    else
+        ASSERT_NOT_REACHED();
+}
+
+bool PannerNode::setDistanceModel(unsigned model)
 {
     switch (model) {
     case DistanceEffect::ModelLinear:
@@ -180,9 +237,10 @@ void PannerNode::setDistanceModel(unsigned short model, ExceptionCode& ec)
         m_distanceEffect.setModel(static_cast<DistanceEffect::ModelType>(model), true);
         break;
     default:
-        ec = NOT_SUPPORTED_ERR;
-        break;
+        return false;
     }
+
+    return true;
 }
 
 void PannerNode::getAzimuthElevation(double* outAzimuth, double* outElevation)
index b8cc1de7d863923d5994dbf85b170919be099daa..c7766044fe84ac34cc901cf75086b06aa2c0bacd 100644 (file)
@@ -79,8 +79,9 @@ public:
     AudioListener* listener();
 
     // Panning model
-    unsigned short panningModel() const { return m_panningModel; }
-    void setPanningModel(unsigned short, ExceptionCode&);
+    String panningModel() const;
+    bool setPanningModel(unsigned); // Returns true on success.
+    void setPanningModel(const String&);
 
     // Position
     FloatPoint3D position() const { return m_position; }
@@ -95,8 +96,9 @@ public:
     void setVelocity(float x, float y, float z) { m_velocity = FloatPoint3D(x, y, z); }
 
     // Distance parameters
-    unsigned short distanceModel() { return m_distanceEffect.model(); }
-    void setDistanceModel(unsigned short, ExceptionCode&);
+    String distanceModel() const;
+    bool setDistanceModel(unsigned); // Returns true on success.
+    void setDistanceModel(const String&);
 
     float refDistance() { return static_cast<float>(m_distanceEffect.refDistance()); }
     void setRefDistance(float refDistance) { m_distanceEffect.setRefDistance(refDistance); }
index 5cf1f7c7eba4ec5f96fdf060271b2e13a8d70c26..ac4cddd710e1039854ed9474a3e7a85cae757711 100644 (file)
@@ -37,8 +37,7 @@
     const unsigned short EXPONENTIAL_DISTANCE = 2;
 
     // Default model for stereo is HRTF 
-    attribute unsigned short panningModel
-        setter raises(DOMException);
+    [CustomSetter] attribute DOMString panningModel;
 
     // Uses a 3D cartesian coordinate system 
     void setPosition(in float x, in float y, in float z);
@@ -46,8 +45,7 @@
     void setVelocity(in float x, in float y, in float z);
 
     // Distance model
-    attribute unsigned short distanceModel
-        setter raises(DOMException);
+    [CustomSetter] attribute DOMString distanceModel;
 
     attribute float refDistance;
     attribute float maxDistance;
index 0c4a0cadda299bff47b3411909719768bc376a0a..f064c06e43917ae938edefd3bceecd8e3eaa1520 100644 (file)
@@ -3421,8 +3421,10 @@ enable?(WEB_AUDIO) {
     SOURCES += \
         bindings/js/JSAudioBufferSourceNodeCustom.cpp \
         bindings/js/JSAudioContextCustom.cpp \
+        bindings/js/JSBiquadFilterNodeCustom.cpp \
         bindings/js/JSDOMWindowWebAudioCustom.cpp \
         bindings/js/JSOscillatorNodeCustom.cpp \
+        bindings/js/JSPannerNodeCustom.cpp \
         bindings/js/JSScriptProcessorNodeCustom.cpp \
         Modules/webaudio/AsyncAudioDecoder.cpp \
         Modules/webaudio/AudioBasicInspectorNode.cpp \
index a301dc97a870fbbf47589fdc2b3722aa9c064294..0c087eed911d986b581c7d078ef757be67a6a199 100644 (file)
@@ -268,7 +268,9 @@ if (ENABLE_WEB_AUDIO)
     list(APPEND WebCore_SOURCES
         bindings/js/JSAudioBufferSourceNodeCustom.cpp
         bindings/js/JSAudioContextCustom.cpp
+        bindings/js/JSBiquadFilterNodeCustom.cpp
         bindings/js/JSOscillatorNodeCustom.cpp
+        bindings/js/JSPannerNodeCustom.cpp
         bindings/js/JSScriptProcessorNodeCustom.cpp
     )
 endif ()
index 11b4476db040ee041080b754b347aa08ca68a446..d324745939904de8839c80ec2489d9437e8446c2 100644 (file)
@@ -76,6 +76,7 @@ list(APPEND WebCore_SOURCES
     bindings/v8/custom/V8ArrayBufferCustom.cpp
     bindings/v8/custom/V8ArrayBufferViewCustom.cpp
     bindings/v8/custom/V8AudioContextCustom.cpp
+    bindings/v8/custom/V8BiquadFilterNodeCustom.cpp
     bindings/v8/custom/V8CSSRuleCustom.cpp
     bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
     bindings/v8/custom/V8CSSValueCustom.cpp
@@ -139,6 +140,7 @@ list(APPEND WebCore_SOURCES
     bindings/v8/custom/V8NotificationCenterCustom.cpp
     bindings/v8/custom/V8OscillatorNodeCustom.cpp
     bindings/v8/custom/V8PerformanceEntryCustom.cpp
+    bindings/v8/custom/V8PannerNodeCustom.cpp
     bindings/v8/custom/V8PopStateEventCustom.cpp
     bindings/v8/custom/V8SQLResultSetRowListCustom.cpp
     bindings/v8/custom/V8SQLTransactionCustom.cpp
index 484e76dd5ce360b4b7015cda091f882054ad9357..51fbd77244450820b0c3fea3f86b458679da2f35 100644 (file)
             'bindings/v8/custom/V8ArrayBufferViewCustom.h',
             'bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp',
             'bindings/v8/custom/V8AudioContextCustom.cpp',
+            'bindings/v8/custom/V8BiquadFilterNodeCustom.cpp',
             'bindings/v8/custom/V8BlobCustom.cpp',
             'bindings/v8/custom/V8CSSRuleCustom.cpp',
             'bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp',
             'bindings/v8/custom/V8NotificationCustom.cpp',
             'bindings/v8/custom/V8NotificationCenterCustom.cpp',
             'bindings/v8/custom/V8OscillatorNodeCustom.cpp',
+            'bindings/v8/custom/V8PannerNodeCustom.cpp',
             'bindings/v8/custom/V8PerformanceEntryCustom.cpp',
             'bindings/v8/custom/V8PopStateEventCustom.cpp',
             'bindings/v8/custom/V8SQLResultSetRowListCustom.cpp',
index 14e1978cc593cdf9113060c141b1f689ab740101..2b74c51b3e43b777b3ff90bcb179e3e57d2c515d 100644 (file)
                FD7F299713D4C0CB00AD9535 /* WaveShaperProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7F299013D4C0CB00AD9535 /* WaveShaperProcessor.h */; };
                FD82D7F713D4C8BD004E4372 /* JSWaveShaperNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD82D7F513D4C8BD004E4372 /* JSWaveShaperNode.cpp */; };
                FD82D7F813D4C8BD004E4372 /* JSWaveShaperNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD82D7F613D4C8BD004E4372 /* JSWaveShaperNode.h */; };
+               FD8AA63C1695148E00D2EA68 /* JSBiquadFilterNodeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD8AA63B1695148E00D2EA68 /* JSBiquadFilterNodeCustom.cpp */; };
+               FD8AA63E169514A700D2EA68 /* JSPannerNodeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */; };
                FD8C46EB154608E700A5910C /* AudioScheduledSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD8C46E9154608E700A5910C /* AudioScheduledSourceNode.cpp */; };
                FD8C46EC154608E700A5910C /* AudioScheduledSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD8C46EA154608E700A5910C /* AudioScheduledSourceNode.h */; };
                FDA15E9D12B03EE1003A583A /* JSAudioBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDA15E8112B03EE1003A583A /* JSAudioBuffer.cpp */; };
                FD7F299013D4C0CB00AD9535 /* WaveShaperProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WaveShaperProcessor.h; sourceTree = "<group>"; };
                FD82D7F513D4C8BD004E4372 /* JSWaveShaperNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWaveShaperNode.cpp; sourceTree = "<group>"; };
                FD82D7F613D4C8BD004E4372 /* JSWaveShaperNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWaveShaperNode.h; sourceTree = "<group>"; };
+               FD8AA63B1695148E00D2EA68 /* JSBiquadFilterNodeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBiquadFilterNodeCustom.cpp; sourceTree = "<group>"; };
+               FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPannerNodeCustom.cpp; sourceTree = "<group>"; };
                FD8C46E9154608E700A5910C /* AudioScheduledSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioScheduledSourceNode.cpp; sourceTree = "<group>"; };
                FD8C46EA154608E700A5910C /* AudioScheduledSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioScheduledSourceNode.h; sourceTree = "<group>"; };
                FDA15E8112B03EE1003A583A /* JSAudioBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioBuffer.cpp; sourceTree = "<group>"; };
                                BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */,
                                FDEAAAEF12B02EE400DCF33B /* JSAudioBufferSourceNodeCustom.cpp */,
                                FDEAAAF012B02EE400DCF33B /* JSAudioContextCustom.cpp */,
+                               FD8AA63B1695148E00D2EA68 /* JSBiquadFilterNodeCustom.cpp */,
                                8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */,
                                49EED14B1051971900099FAB /* JSCanvasRenderingContext2DCustom.cpp */,
                                49EED14D1051971A00099FAB /* JSCanvasRenderingContextCustom.cpp */,
                                BCD9C2610C17AA67005C90A2 /* JSNodeListCustom.cpp */,
                                31FE6E6C1501A3BF0004EBC4 /* JSNotificationCustom.cpp */,
                                FDBD1DFB167FE27D0051A11E /* JSOscillatorNodeCustom.cpp */,
+                               FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */,
                                A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
                                E1AD12D51295D0BD00ACA989 /* JSProcessingInstructionCustom.cpp */,
                                4998AED313FC417F0090B1AA /* JSRequestAnimationFrameCallbackCustom.cpp */,
                                419BC2DE1685329900D64D6D /* VisitedLinkState.cpp in Sources */,
                                5DA97ECE168E787B000E3676 /* SystemVersionMac.mm in Sources */,
                                FDBD1DFC167FE27D0051A11E /* JSOscillatorNodeCustom.cpp in Sources */,
+                               FD8AA63C1695148E00D2EA68 /* JSBiquadFilterNodeCustom.cpp in Sources */,
+                               FD8AA63E169514A700D2EA68 /* JSPannerNodeCustom.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp b/Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp
new file mode 100644 (file)
index 0000000..8ad9c9c
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "JSBiquadFilterNode.h"
+
+#include "BiquadFilterNode.h"
+#include "ExceptionCode.h"
+#include <runtime/Error.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSBiquadFilterNode::setType(ExecState* exec, JSValue value)
+{
+    BiquadFilterNode* imp = static_cast<BiquadFilterNode*>(impl());
+
+#if ENABLE(LEGACY_WEB_AUDIO)
+    if (value.isNumber()) {
+        uint32_t type = value.toUInt32(exec);
+        if (!imp->setType(type))
+            throwError(exec, createTypeError(exec, "Illegal BiquadFilterNode type"));
+        return;
+    }
+#endif
+
+    if (value.isString()) {
+        String type = value.toString(exec)->value(exec);
+        if (type == "lowpass" || type == "highpass" || type == "bandpass" || type == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" || type == "allpass") {
+            imp->setType(type);
+            return;
+        }
+    }
+    
+    throwError(exec, createTypeError(exec, "Illegal BiquadFilterNode type"));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/WebCore/bindings/js/JSPannerNodeCustom.cpp b/Source/WebCore/bindings/js/JSPannerNodeCustom.cpp
new file mode 100644 (file)
index 0000000..6913de4
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "JSPannerNode.h"
+
+#include "ExceptionCode.h"
+#include "PannerNode.h"
+#include <runtime/Error.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSPannerNode::setPanningModel(ExecState* exec, JSValue value)
+{
+    PannerNode* imp = static_cast<PannerNode*>(impl());
+
+#if ENABLE(LEGACY_WEB_AUDIO)
+    if (value.isNumber()) {
+        uint32_t model = value.toUInt32(exec);
+        if (!imp->setPanningModel(model))
+            throwError(exec, createTypeError(exec, "Illegal panningModel"));
+        return;
+    }
+#endif
+
+    if (value.isString()) {
+        String model = value.toString(exec)->value(exec);
+        if (model == "equalpower" || model == "HRTF" || model == "soundfield") {
+            imp->setPanningModel(model);
+            return;
+        }
+    }
+    
+    throwError(exec, createTypeError(exec, "Illegal panningModel"));
+}
+
+void JSPannerNode::setDistanceModel(ExecState* exec, JSValue value)
+{
+    PannerNode* imp = static_cast<PannerNode*>(impl());
+
+#if ENABLE(LEGACY_WEB_AUDIO)
+    if (value.isNumber()) {
+        uint32_t model = value.toUInt32(exec);
+        if (!imp->setDistanceModel(model))
+            throwError(exec, createTypeError(exec, "Illegal distanceModel"));
+        return;
+    }
+#endif
+
+    if (value.isString()) {
+        String model = value.toString(exec)->value(exec);
+        if (model == "linear" || model == "inverse" || model == "exponential") {
+            imp->setDistanceModel(model);
+            return;
+        }
+    }
+    
+    throwError(exec, createTypeError(exec, "Illegal distanceModel"));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/WebCore/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp b/Source/WebCore/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp
new file mode 100644 (file)
index 0000000..57170f8
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "V8BiquadFilterNode.h"
+
+#include "BiquadFilterNode.h"
+#include "ExceptionCode.h"
+#include "V8Binding.h"
+
+namespace WebCore {
+
+void V8BiquadFilterNode::typeAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+    BiquadFilterNode* imp = V8BiquadFilterNode::toNative(info.Holder());
+
+#if ENABLE(LEGACY_WEB_AUDIO)    
+    if (value->IsNumber()) {
+        bool ok = false;
+        uint32_t type = toUInt32(value, ok);
+        ASSERT(ok);
+        if (!imp->setType(type))
+            throwError(v8TypeError, "Illegal BiquadFilterNode type", info.GetIsolate());
+        return;
+    }
+#endif
+
+    if (value->IsString()) {
+        String type = toWebCoreString(value);
+        if (type == "lowpass" || type == "highpass" || type == "bandpass" || type == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" || type == "allpass") {
+            imp->setType(type);
+            return;
+        }
+    }
+    
+    throwError(v8TypeError, "Illegal BiquadFilterNode type", info.GetIsolate());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/WebCore/bindings/v8/custom/V8PannerNodeCustom.cpp b/Source/WebCore/bindings/v8/custom/V8PannerNodeCustom.cpp
new file mode 100644 (file)
index 0000000..e1f76f9
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "V8PannerNode.h"
+
+#include "ExceptionCode.h"
+#include "PannerNode.h"
+#include "V8Binding.h"
+
+namespace WebCore {
+
+void V8PannerNode::panningModelAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+    PannerNode* imp = V8PannerNode::toNative(info.Holder());
+
+#if ENABLE(LEGACY_WEB_AUDIO)    
+    if (value->IsNumber()) {
+        bool ok = false;
+        uint32_t model = toUInt32(value, ok);
+        ASSERT(ok);
+        if (!imp->setPanningModel(model))
+            throwError(v8TypeError, "Illegal panningModel", info.GetIsolate());
+        return;
+    }
+#endif
+
+    if (value->IsString()) {
+        String model = toWebCoreString(value);
+        if (model == "equalpower" || model == "HRTF" || model == "soundfield") {
+            imp->setPanningModel(model);
+            return;
+        }
+    }
+    
+    throwError(v8TypeError, "Illegal panningModel", info.GetIsolate());
+}
+
+void V8PannerNode::distanceModelAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+    PannerNode* imp = V8PannerNode::toNative(info.Holder());
+
+#if ENABLE(LEGACY_WEB_AUDIO)    
+    if (value->IsNumber()) {
+        bool ok = false;
+        uint32_t model = toUInt32(value, ok);
+        ASSERT(ok);
+        if (!imp->setDistanceModel(model))
+            throwError(v8TypeError, "Illegal distanceModel", info.GetIsolate());
+        return;
+    }
+#endif
+
+    if (value->IsString()) {
+        String model = toWebCoreString(value);
+        if (model == "linear" || model == "inverse" || model == "exponential") {
+            imp->setDistanceModel(model);
+            return;
+        }
+    }
+    
+    throwError(v8TypeError, "Illegal distanceModel", info.GetIsolate());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)