OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 * 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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #if ENABLE(WEB_AUDIO) | 26 #if ENABLE(WEB_AUDIO) |
27 #include "V8PannerNode.h" | 27 #include "V8PannerNode.h" |
28 | 28 |
| 29 #include "bindings/v8/ExceptionState.h" |
29 #include "bindings/v8/V8Binding.h" | 30 #include "bindings/v8/V8Binding.h" |
30 #include "modules/webaudio/PannerNode.h" | 31 #include "modules/webaudio/PannerNode.h" |
31 | 32 |
32 namespace WebCore { | 33 namespace WebCore { |
33 | 34 |
34 void V8PannerNode::panningModelAttributeSetterCustom(v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) | 35 void V8PannerNode::panningModelAttributeSetterCustom(v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) |
35 { | 36 { |
| 37 ExceptionState exceptionState(ExceptionState::SetterContext, "panningModel",
"PannerNode", info.Holder(), info.GetIsolate()); |
36 PannerNode* imp = V8PannerNode::toNative(info.Holder()); | 38 PannerNode* imp = V8PannerNode::toNative(info.Holder()); |
37 | 39 |
38 if (value->IsNumber()) { | 40 if (value->IsNumber()) { |
39 bool ok = false; | 41 uint32_t model = toUInt32(value, exceptionState); |
40 uint32_t model = toUInt32(value, ok); | 42 if (exceptionState.throwIfNeeded()) |
41 ASSERT(ok); | 43 return; |
42 if (!imp->setPanningModel(model)) | 44 if (!imp->setPanningModel(model)) { |
43 throwTypeError("Illegal panningModel", info.GetIsolate()); | 45 exceptionState.throwTypeError("Illegal panningModel"); |
| 46 exceptionState.throwIfNeeded(); |
| 47 } |
44 return; | 48 return; |
45 } | 49 } |
46 | 50 |
47 if (value->IsString()) { | 51 if (value->IsString()) { |
48 String model = toCoreString(value.As<v8::String>()); | 52 String model = toCoreString(value.As<v8::String>()); |
49 if (model == "equalpower" || model == "HRTF" || model == "soundfield") { | 53 if (model == "equalpower" || model == "HRTF" || model == "soundfield") { |
50 imp->setPanningModel(model); | 54 imp->setPanningModel(model); |
51 return; | 55 return; |
52 } | 56 } |
53 } | 57 } |
54 | 58 |
55 throwTypeError("Illegal panningModel", info.GetIsolate()); | 59 exceptionState.throwTypeError("Illegal panningModel"); |
| 60 exceptionState.throwIfNeeded(); |
56 } | 61 } |
57 | 62 |
58 void V8PannerNode::distanceModelAttributeSetterCustom(v8::Local<v8::Value> value
, const v8::PropertyCallbackInfo<void>& info) | 63 void V8PannerNode::distanceModelAttributeSetterCustom(v8::Local<v8::Value> value
, const v8::PropertyCallbackInfo<void>& info) |
59 { | 64 { |
| 65 ExceptionState exceptionState(ExceptionState::SetterContext, "distanceModel"
, "PannerNode", info.Holder(), info.GetIsolate()); |
60 PannerNode* imp = V8PannerNode::toNative(info.Holder()); | 66 PannerNode* imp = V8PannerNode::toNative(info.Holder()); |
61 | 67 |
62 if (value->IsNumber()) { | 68 if (value->IsNumber()) { |
63 bool ok = false; | 69 uint32_t model = toUInt32(value, exceptionState); |
64 uint32_t model = toUInt32(value, ok); | 70 if (exceptionState.throwIfNeeded()) |
65 ASSERT(ok); | 71 return; |
66 if (!imp->setDistanceModel(model)) | 72 if (!imp->setDistanceModel(model)) { |
67 throwTypeError("Illegal distanceModel", info.GetIsolate()); | 73 exceptionState.throwTypeError("Illegal distanceModel"); |
| 74 exceptionState.throwIfNeeded(); |
| 75 } |
68 return; | 76 return; |
69 } | 77 } |
70 | 78 |
71 if (value->IsString()) { | 79 if (value->IsString()) { |
72 String model = toCoreString(value.As<v8::String>()); | 80 String model = toCoreString(value.As<v8::String>()); |
73 if (model == "linear" || model == "inverse" || model == "exponential") { | 81 if (model == "linear" || model == "inverse" || model == "exponential") { |
74 imp->setDistanceModel(model); | 82 imp->setDistanceModel(model); |
75 return; | 83 return; |
76 } | 84 } |
77 } | 85 } |
78 | 86 |
79 throwTypeError("Illegal distanceModel", info.GetIsolate()); | 87 exceptionState.throwTypeError("Illegal distanceModel"); |
| 88 exceptionState.throwIfNeeded(); |
80 } | 89 } |
81 | 90 |
82 } // namespace WebCore | 91 } // namespace WebCore |
83 | 92 |
84 #endif // ENABLE(WEB_AUDIO) | 93 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |