Chromium Code Reviews| Index: Source/bindings/v8/custom/V8PromiseCustom.cpp |
| diff --git a/Source/core/dom/NodeList.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp |
| similarity index 54% |
| copy from Source/core/dom/NodeList.cpp |
| copy to Source/bindings/v8/custom/V8PromiseCustom.cpp |
| index fb06c70817bff7406297e671ca5dd5f5ff7f29e6..467dac21b20b7430d7baae5c421f0e360cf34bc9 100644 |
| --- a/Source/core/dom/NodeList.cpp |
| +++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp |
| @@ -29,29 +29,42 @@ |
| */ |
| #include "config.h" |
| -#include "core/dom/NodeList.h" |
| +#include "V8Promise.h" |
| -#include "core/dom/Node.h" |
| +#include "bindings/v8/V8Binding.h" |
| +#include "bindings/v8/V8PromiseUtilities.h" |
| +#include <v8.h> |
| 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.
|
| - |
| -void NodeList::anonymousNamedGetter(const AtomicString& name, bool& returnValue0Enabled, RefPtr<Node>& returnValue0, bool& returnValue1Enabled, unsigned& returnValue1) |
| +void V8Promise::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args) |
| { |
| - // Length property cannot be overridden. |
| - DEFINE_STATIC_LOCAL(const AtomicString, length, ("length", AtomicString::ConstructFromLiteral)); |
| - if (name == length) { |
| - returnValue1Enabled = true; |
| - returnValue1 = this->length(); |
| + args.GetReturnValue().Set(v8::Handle<v8::Value>()); |
| + v8::Handle<v8::Function> promiseConstructor = V8PromiseUtilities::promiseConstructor(args.GetIsolate()); |
| + |
| + if (promiseConstructor.IsEmpty()) |
| return; |
| - } |
| - Node* result = namedItem(name); |
| - if (!result) |
| + Vector<v8::Handle<v8::Value> > arguments; |
| + for (int i = 0; i < args.Length(); ++i) |
| + arguments.append(args[i]); |
| + |
| + v8::Handle<v8::Value> promise = promiseConstructor->CallAsConstructor(arguments.size(), arguments.data()); |
| + if (promise.IsEmpty() || !promise->IsObject()) |
| return; |
| - returnValue0Enabled = true; |
| - returnValue0 = result; |
| + v8::Handle<v8::Object> promiseWrapper = V8DOMWrapper::createWrapper(args.Holder(), &V8Promise::info, 0, args.GetIsolate()); |
| + promiseWrapper->SetInternalField(v8DOMWrapperObjectIndex, promise); |
| + args.GetReturnValue().Set(promiseWrapper); |
| +} |
| + |
| +void V8Promise::getStaticMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) |
| +{ |
| + v8SetReturnValue(args, V8PromiseUtilities::callStatic("getStatic", args, V8PromiseUtilities::promiseConstructor(args.GetIsolate()))); |
| } |
|
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.
|
| +void V8Promise::getMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) |
| +{ |
| + v8SetReturnValue(args, V8PromiseUtilities::callUnwrappedMethod("get", args, V8PromiseUtilities::promisePrototype(args.GetIsolate()))); |
| +} |
| } // namespace WebCore |