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

Side by Side Diff: Source/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp

Issue 121113004: Improve handling of failed integer type conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 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) 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 "V8BiquadFilterNode.h" 27 #include "V8BiquadFilterNode.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/BiquadFilterNode.h" 31 #include "modules/webaudio/BiquadFilterNode.h"
31 32
32 namespace WebCore { 33 namespace WebCore {
33 34
34 void V8BiquadFilterNode::typeAttributeSetterCustom(v8::Local<v8::Value> value, c onst v8::PropertyCallbackInfo<void>& info) 35 void V8BiquadFilterNode::typeAttributeSetterCustom(v8::Local<v8::Value> value, c onst v8::PropertyCallbackInfo<void>& info)
35 { 36 {
37 ExceptionState exceptionState(ExceptionState::SetterContext, "type", "Biquad FilterNode", info.Holder(), info.GetIsolate());
36 BiquadFilterNode* imp = V8BiquadFilterNode::toNative(info.Holder()); 38 BiquadFilterNode* imp = V8BiquadFilterNode::toNative(info.Holder());
37 39
38 if (value->IsNumber()) { 40 if (value->IsNumber()) {
39 bool ok = false; 41 uint32_t type = toUInt32(value, exceptionState);
40 uint32_t type = toUInt32(value, ok); 42 if (exceptionState.throwIfNeeded())
41 ASSERT(ok); 43 return;
42 if (!imp->setType(type)) 44 if (!imp->setType(type)) {
43 throwTypeError("Illegal BiquadFilterNode type", info.GetIsolate()); 45 exceptionState.throwTypeError("Illegal BiquadFilterNode type");
46 exceptionState.throwIfNeeded();
47 }
44 return; 48 return;
45 } 49 }
46 50
47 if (value->IsString()) { 51 if (value->IsString()) {
48 String type = toCoreString(value.As<v8::String>()); 52 String type = toCoreString(value.As<v8::String>());
49 if (type == "lowpass" || type == "highpass" || type == "bandpass" || typ e == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" | | type == "allpass") { 53 if (type == "lowpass" || type == "highpass" || type == "bandpass" || typ e == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" | | type == "allpass") {
50 imp->setType(type); 54 imp->setType(type);
51 return; 55 return;
52 } 56 }
53 } 57 }
54 58
55 throwTypeError("Illegal BiquadFilterNode type", info.GetIsolate()); 59 exceptionState.throwTypeError("Illegal BiquadFilterNode type");
60 exceptionState.throwIfNeeded();
56 } 61 }
57 62
58 } // namespace WebCore 63 } // namespace WebCore
59 64
60 #endif // ENABLE(WEB_AUDIO) 65 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8BindingMacros.h ('k') | Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698