OLD | NEW |
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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "V8MutationObserver.h" | 32 #include "V8MutationObserver.h" |
33 | 33 |
34 #include "bindings/v8/ExceptionMessages.h" | 34 #include "bindings/v8/ExceptionMessages.h" |
| 35 #include "bindings/v8/ExceptionState.h" |
35 #include "bindings/v8/V8Binding.h" | 36 #include "bindings/v8/V8Binding.h" |
36 #include "bindings/v8/V8DOMWrapper.h" | 37 #include "bindings/v8/V8DOMWrapper.h" |
37 #include "bindings/v8/V8MutationCallback.h" | 38 #include "bindings/v8/V8MutationCallback.h" |
38 #include "bindings/v8/V8Utilities.h" | 39 #include "bindings/v8/V8Utilities.h" |
39 #include "core/dom/MutationObserver.h" | 40 #include "core/dom/MutationObserver.h" |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 44 void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
44 { | 45 { |
| 46 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Mutation
Observer", info.Holder(), info.GetIsolate()); |
45 if (info.Length() < 1) { | 47 if (info.Length() < 1) { |
46 throwTypeError(ExceptionMessages::failedToConstruct("MutationObserver",
ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); | 48 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 49 exceptionState.throwIfNeeded(); |
47 return; | 50 return; |
48 } | 51 } |
49 | 52 |
50 v8::Local<v8::Value> arg = info[0]; | 53 v8::Local<v8::Value> arg = info[0]; |
51 if (!arg->IsFunction()) { | 54 if (!arg->IsFunction()) { |
52 throwTypeError("Callback argument must be a function", info.GetIsolate()
); | 55 exceptionState.throwTypeError("Callback argument must be a function"); |
| 56 exceptionState.throwIfNeeded(); |
53 return; | 57 return; |
54 } | 58 } |
55 | 59 |
56 ExecutionContext* context = getExecutionContext(); | 60 ExecutionContext* context = getExecutionContext(); |
57 v8::Handle<v8::Object> wrapper = info.Holder(); | 61 v8::Handle<v8::Object> wrapper = info.Holder(); |
58 | 62 |
59 OwnPtr<MutationCallback> callback = V8MutationCallback::create(v8::Handle<v8
::Function>::Cast(arg), context, wrapper, info.GetIsolate()); | 63 OwnPtr<MutationCallback> callback = V8MutationCallback::create(v8::Handle<v8
::Function>::Cast(arg), context, wrapper, info.GetIsolate()); |
60 RefPtr<MutationObserver> observer = MutationObserver::create(callback.releas
e()); | 64 RefPtr<MutationObserver> observer = MutationObserver::create(callback.releas
e()); |
61 | 65 |
62 V8DOMWrapper::associateObjectWithWrapper<V8MutationObserver>(observer.releas
e(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Depende
nt); | 66 V8DOMWrapper::associateObjectWithWrapper<V8MutationObserver>(observer.releas
e(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Depende
nt); |
63 info.GetReturnValue().Set(wrapper); | 67 info.GetReturnValue().Set(wrapper); |
64 } | 68 } |
65 | 69 |
66 } // namespace WebCore | 70 } // namespace WebCore |
OLD | NEW |