OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 11 matching lines...) Expand all Loading... | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
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 "core/dom/NodeList.h" | 32 #include "V8Promise.h" |
33 | 33 |
34 #include "core/dom/Node.h" | 34 #include "bindings/v8/V8Binding.h" |
35 #include "bindings/v8/V8PromiseUtilities.h" | |
36 #include <v8.h> | |
35 | 37 |
36 namespace WebCore { | 38 namespace WebCore { |
abarth-chromium
2013/06/17 18:05:06
Please add a blank line after the namespace declar
yhirano
2013/06/18 08:56:15
Done.
| |
39 void V8Promise::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& arg s) | |
40 { | |
41 args.GetReturnValue().Set(v8::Handle<v8::Value>()); | |
42 v8::Handle<v8::Function> promiseConstructor = V8PromiseUtilities::promiseCon structor(args.GetIsolate()); | |
37 | 43 |
38 void NodeList::anonymousNamedGetter(const AtomicString& name, bool& returnValue0 Enabled, RefPtr<Node>& returnValue0, bool& returnValue1Enabled, unsigned& return Value1) | 44 if (promiseConstructor.IsEmpty()) |
39 { | |
40 // Length property cannot be overridden. | |
41 DEFINE_STATIC_LOCAL(const AtomicString, length, ("length", AtomicString::Con structFromLiteral)); | |
42 if (name == length) { | |
43 returnValue1Enabled = true; | |
44 returnValue1 = this->length(); | |
45 return; | |
46 } | |
47 | |
48 Node* result = namedItem(name); | |
49 if (!result) | |
50 return; | 45 return; |
51 | 46 |
52 returnValue0Enabled = true; | 47 Vector<v8::Handle<v8::Value> > arguments; |
53 returnValue0 = result; | 48 for (int i = 0; i < args.Length(); ++i) |
49 arguments.append(args[i]); | |
50 | |
51 v8::Handle<v8::Value> promise = promiseConstructor->CallAsConstructor(argume nts.size(), arguments.data()); | |
52 if (promise.IsEmpty() || !promise->IsObject()) | |
53 return; | |
54 | |
55 v8::Handle<v8::Object> promiseWrapper = V8DOMWrapper::createWrapper(args.Hol der(), &V8Promise::info, 0, args.GetIsolate()); | |
56 promiseWrapper->SetInternalField(v8DOMWrapperObjectIndex, promise); | |
57 args.GetReturnValue().Set(promiseWrapper); | |
54 } | 58 } |
55 | 59 |
60 void V8Promise::getStaticMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) | |
61 { | |
62 v8SetReturnValue(args, V8PromiseUtilities::callStatic("getStatic", args, V8P romiseUtilities::promiseConstructor(args.GetIsolate()))); | |
63 } | |
abarth-chromium
2013/06/17 18:05:06
We should teach the code generator how to generate
yhirano
2013/06/18 08:56:15
Will do in another CL.
| |
64 | |
65 void V8Promise::getMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) | |
66 { | |
67 v8SetReturnValue(args, V8PromiseUtilities::callUnwrappedMethod("get", args, V8PromiseUtilities::promisePrototype(args.GetIsolate()))); | |
68 } | |
56 | 69 |
57 } // namespace WebCore | 70 } // namespace WebCore |
OLD | NEW |