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

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: 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 dfebb9591f2e498d74511fd65e5a82c64995e22e..86aa3e05ea6eeebae20822debb66c94e7cae3a93 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"
@@ -519,6 +521,29 @@ 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);
+ RefPtr<Node> elementMember1;
+ RefPtr<NodeList> elementMember2;
+ collection->getItem(propertyName, elementMember1, elementMember2);
+ if (!elementMember1 && !elementMember2)
+ return v8Undefined();
+ if (elementMember1)
+ return toV8Fast(elementMember1.release(), info, collection);
+ if (elementMember2)
+ return toV8Fast(elementMember2.release(), info, collection);
+ ASSERT_NOT_REACHED();
haraken 2013/05/17 05:44:48 Can you write this like: if (elementMember1)
+ return v8Undefined();
+}
+
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
{
desc->ReadOnlyPrototype();
@@ -544,7 +569,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8:
}
#endif // ENABLE(Condition11) || ENABLE(Condition12)
- desc->InstanceTemplate()->SetNamedPropertyHandler(0, V8TestInterface::namedPropertySetter, 0, 0, 0);
+ desc->InstanceTemplate()->SetNamedPropertyHandler(V8TestInterface::namedPropertyGetter, V8TestInterface::namedPropertySetter, 0, 0, 0);
// Custom Signature 'supplementalMethod2'
const int supplementalMethod2Argc = 2;

Powered by Google App Engine
This is Rietveld 408576698