JSValue JSClipboard::types(ExecState* exec) const { Clipboard* clipboard = impl(); ListHashSet<String> types = clipboard->types(); if (types.isEmpty()) return jsNull(); MarkedArgumentBuffer list; ListHashSet<String>::const_iterator end = types.end(); for (ListHashSet<String>::const_iterator it = types.begin(); it != end; ++it) list.append(jsStringWithCache(exec, *it)); return constructArray(exec, 0, globalObject(), list); }
v8::Handle<v8::Value> V8Clipboard::typesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.Clipboard.types()"); Clipboard* clipboard = V8Clipboard::toNative(info.Holder()); ListHashSet<String> types = clipboard->types(); if (types.isEmpty()) return v8::Null(info.GetIsolate()); v8::Local<v8::Array> result = v8::Array::New(types.size()); ListHashSet<String>::const_iterator end = types.end(); int index = 0; for (ListHashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++index) result->Set(v8Integer(index, info.GetIsolate()), v8String(*it, info.GetIsolate())); return result; }
void V8Clipboard::typesAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { Clipboard* clipboard = V8Clipboard::toNative(info.Holder()); ListHashSet<String> types = clipboard->types(); if (types.isEmpty()) { v8SetReturnValueNull(info); return; } v8::Local<v8::Array> result = v8::Array::New(types.size()); ListHashSet<String>::const_iterator end = types.end(); int index = 0; for (ListHashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++index) result->Set(v8::Integer::New(index, info.GetIsolate()), v8String(*it, info.GetIsolate())); v8SetReturnValue(info, result); }