summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/V8Collection.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/V8Collection.h')
-rw-r--r--WebCore/bindings/v8/V8Collection.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/WebCore/bindings/v8/V8Collection.h b/WebCore/bindings/v8/V8Collection.h
index e72dc07..0a4134e 100644
--- a/WebCore/bindings/v8/V8Collection.h
+++ b/WebCore/bindings/v8/V8Collection.h
@@ -177,6 +177,18 @@ namespace WebCore {
}
+ // A template for indexed getters on collections of strings.
+ template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+ {
+ // FIXME: assert that object must be a collection type
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ V8ClassIndex::V8WrapperType wrapperType = V8DOMWrapper::domWrapperType(info.Holder());
+ Collection* collection = V8DOMWrapper::convertToNativeObject<Collection>(wrapperType, info.Holder());
+ String result = collection->item(index);
+ return v8String(result);
+ }
+
+
// Add indexed getter to the function template for a collection.
template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type)
{
@@ -208,6 +220,13 @@ namespace WebCore {
desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
}
+
+ // Add indexed getter returning a string to a function template for a collection.
+ template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc)
+ {
+ desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>);
+ }
+
v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
} // namespace WebCore