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

Unified Diff: Source/bindings/tests/results/V8TestObject.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/V8TestObject.cpp
diff --git a/Source/bindings/tests/results/V8TestObject.cpp b/Source/bindings/tests/results/V8TestObject.cpp
index 604ac1076004b94dd463a262023cd03223fd5fd6..84714932c35da4db5f152d28113672d315026cd0 100644
--- a/Source/bindings/tests/results/V8TestObject.cpp
+++ b/Source/bindings/tests/results/V8TestObject.cpp
@@ -28,6 +28,7 @@
#include "V8Document.h"
#include "V8Float32Array.h"
#include "V8Node.h"
+#include "V8NodeList.h"
#include "V8SVGDocument.h"
#include "V8SVGPoint.h"
#include "V8ScriptProfile.h"
@@ -4301,10 +4302,17 @@ v8::Handle<v8::Value> V8TestObject::indexedPropertyGetter(uint32_t index, const
{
ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
TestObj* collection = toNative(info.Holder());
- RefPtr<Node> element = collection->item(index);
- if (!element)
+ WTF::UnionType2<NodeList, Node> element = collection->item(index);
+ if (element.isNull())
return v8Undefined();
- return toV8Fast(element.release(), info, collection);
+
+ v8::Handle<v8::Value> jsValue;
+ if (element.isValue0Enabled())
+ jsValue = toV8Fast(element.getValue0(), info, collection);
+ if (element.isValue1Enabled())
+ jsValue = toV8Fast(element.getValue1(), info, collection);
+
+ return jsValue;
haraken 2013/05/15 10:56:25 Can we write this like: return toV8Fast(element
}
v8::Handle<v8::Value> V8TestObject::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
@@ -4320,7 +4328,10 @@ v8::Handle<v8::Value> V8TestObject::namedPropertyGetter(v8::Local<v8::String> na
String element = collection->namedItem(propertyName);
if (element.isNull())
return v8Undefined();
- return v8String(element, info.GetIsolate());
+
+ v8::Handle<v8::Value> jsValue;
+ jsValue = v8String(element, info.GetIsolate());
+ return jsValue;
haraken 2013/05/15 10:56:25 Nit: We might not want to introduce the jsValue in
}
static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjectTemplate(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)

Powered by Google App Engine
This is Rietveld 408576698