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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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/ExceptionState.h" |
35 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
36 #include "bindings/v8/V8DOMWrapper.h" | 36 #include "bindings/v8/V8DOMWrapper.h" |
37 #include "bindings/v8/V8MutationCallback.h" | 37 #include "bindings/v8/V8MutationCallback.h" |
38 #include "bindings/v8/V8Utilities.h" | 38 #include "bindings/v8/V8Utilities.h" |
39 #include "core/dom/MutationObserver.h" | 39 #include "core/dom/MutationObserver.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 43 void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
44 { | 44 { |
| 45 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Mutation
Observer", info.Holder(), info.GetIsolate()); |
45 if (info.Length() < 1) { | 46 if (info.Length() < 1) { |
46 throwTypeError(ExceptionMessages::failedToConstruct("MutationObserver",
ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); | 47 exceptionState.notEnoughArguments(1, info.Length()); |
47 return; | 48 return; |
48 } | 49 } |
49 | 50 |
50 v8::Local<v8::Value> arg = info[0]; | 51 v8::Local<v8::Value> arg = info[0]; |
51 if (!arg->IsFunction()) { | 52 if (!arg->IsFunction()) { |
52 throwTypeError("Callback argument must be a function", info.GetIsolate()
); | 53 exceptionState.throwTypeError("Callback argument must be a function"); |
| 54 exceptionState.throwIfNeeded(); |
53 return; | 55 return; |
54 } | 56 } |
55 | 57 |
56 ExecutionContext* context = getExecutionContext(); | 58 ExecutionContext* context = getExecutionContext(); |
57 v8::Handle<v8::Object> wrapper = info.Holder(); | 59 v8::Handle<v8::Object> wrapper = info.Holder(); |
58 | 60 |
59 OwnPtr<MutationCallback> callback = V8MutationCallback::create(v8::Handle<v8
::Function>::Cast(arg), context, wrapper, info.GetIsolate()); | 61 OwnPtr<MutationCallback> callback = V8MutationCallback::create(v8::Handle<v8
::Function>::Cast(arg), context, wrapper, info.GetIsolate()); |
60 RefPtr<MutationObserver> observer = MutationObserver::create(callback.releas
e()); | 62 RefPtr<MutationObserver> observer = MutationObserver::create(callback.releas
e()); |
61 | 63 |
62 V8DOMWrapper::associateObjectWithWrapper<V8MutationObserver>(observer.releas
e(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Depende
nt); | 64 V8DOMWrapper::associateObjectWithWrapper<V8MutationObserver>(observer.releas
e(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Depende
nt); |
63 info.GetReturnValue().Set(wrapper); | 65 info.GetReturnValue().Set(wrapper); |
64 } | 66 } |
65 | 67 |
66 } // namespace WebCore | 68 } // namespace WebCore |
OLD | NEW |