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

Unified Diff: Source/bindings/tests/results/V8TestInterface.cpp

Issue 15076011: Support union return type for anonymous named/indexed getter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: update Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/tests/results/V8TestInterface.cpp
diff --git a/Source/bindings/tests/results/V8TestInterface.cpp b/Source/bindings/tests/results/V8TestInterface.cpp
index b18fdbbb12a766e23c50520b6680541b31dd319d..32abc91e712516c10f34e855840c1a51bf8d6815 100644
--- a/Source/bindings/tests/results/V8TestInterface.cpp
+++ b/Source/bindings/tests/results/V8TestInterface.cpp
@@ -24,10 +24,12 @@
#include "RuntimeEnabledFeatures.h"
#include "V8Node.h"
+#include "V8NodeList.h"
#include "V8TestObject.h"
#include "bindings/bindings/tests/idls/TestPartialInterface.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8Collection.h"
#include "bindings/v8/V8DOMConfiguration.h"
#include "bindings/v8/V8DOMWrapper.h"
#include "bindings/v8/V8ObjectConstructor.h"
@@ -525,6 +527,27 @@ v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments&
return TestInterfaceV8Internal::constructor(args);
}
+v8::Handle<v8::Value> V8TestInterface::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
+ return v8Undefined();
+ if (info.Holder()->HasRealNamedCallbackProperty(name))
+ return v8Undefined();
+
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ TestInterface* collection = toNative(info.Holder());
+ AtomicString propertyName = toWebCoreAtomicString(name);
+ WTF::UnionType2<Node, NodeList> element = collection->getItem(propertyName);
+ if (element.isNull())
+ return v8Undefined();
+ if (element.member1())
+ return toV8Fast(element.member1(), info, collection);
+ if (element.member2())
+ return toV8Fast(element.member2(), info, collection);
+ ASSERT_NOT_REACHED();
+ return v8Undefined();
+}
+
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
{
desc->ReadOnlyPrototype();
@@ -550,6 +573,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8:
}
#endif // ENABLE(Condition11) || ENABLE(Condition12)
+ desc->InstanceTemplate()->SetNamedPropertyHandler(V8TestInterface::namedPropertyGetter, 0, 0, 0, 0);
// Custom Signature 'supplementalMethod2'
const int supplementalMethod2Argc = 2;

Powered by Google App Engine
This is Rietveld 408576698