本文整理汇总了C++中HTMLCollection::namedItem方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLCollection::namedItem方法的具体用法?C++ HTMLCollection::namedItem怎么用?C++ HTMLCollection::namedItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLCollection
的用法示例。
在下文中一共展示了HTMLCollection::namedItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getItem
v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Arguments& args)
{
INC_STATS("DOM.HTMLCollection.callAsFunction()");
if (args.Length() < 1)
return v8::Undefined();
HTMLCollection* imp = V8HTMLCollection::toNative(args.Holder());
if (args.Length() == 1)
return getItem(imp, args[0]);
// If there is a second argument it is the index of the item we want.
String name = toWebCoreString(args[0]);
v8::Local<v8::Uint32> index = args[1]->ToArrayIndex();
if (index.IsEmpty())
return v8::Undefined();
unsigned current = index->Uint32Value();
Node* node = imp->namedItem(name);
while (node) {
if (!current)
return toV8(node);
node = imp->nextNamedItem(name);
current--;
}
return v8::Undefined();
}
示例2: nameGetter
JSValue JSHTMLCollection::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
{
JSHTMLCollection* collection = jsCast<JSHTMLCollection*>(asObject(slotBase));
const AtomicString& name = propertyNameToAtomicString(propertyName);
HTMLCollection* impl = collection->impl();
#if ENABLE(MICRODATA)
if (impl->type() == ItemProperties)
return toJS(exec, collection->globalObject(), static_cast<HTMLPropertiesCollection*>(impl)->propertyNodeList(name));
#endif
return toJS(exec, collection->globalObject(), impl->namedItem(name));
}
示例3: encode
// HTMLCollections are strange objects, they support both get and call,
// so that document.forms.item(0) and document.forms(0) both work.
static EncodedJSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec)
{
if (exec->argumentCount() < 1)
return JSValue::encode(jsUndefined());
// Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
JSHTMLCollection* jsCollection = static_cast<JSHTMLCollection*>(exec->callee());
HTMLCollection* collection = jsCollection->impl();
// Also, do we need the TypeError test here ?
if (exec->argumentCount() == 1) {
// Support for document.all(<index>) etc.
bool ok;
UString string = exec->argument(0).toString(exec);
unsigned index = Identifier::toUInt32(string, ok);
if (ok)
return JSValue::encode(toJS(exec, jsCollection->globalObject(), collection->item(index)));
// Support for document.images('<name>') etc.
return JSValue::encode(getNamedItems(exec, jsCollection, Identifier(exec, string)));
}
// The second arg, if set, is the index of the item we want
bool ok;
UString string = exec->argument(0).toString(exec);
unsigned index = Identifier::toUInt32(exec->argument(1).toString(exec), ok);
if (ok) {
String pstr = ustringToString(string);
Node* node = collection->namedItem(pstr);
while (node) {
if (!index)
return JSValue::encode(toJS(exec, jsCollection->globalObject(), node));
node = collection->nextNamedItem(pstr);
--index;
}
}
return JSValue::encode(jsUndefined());
}
示例4: jsUndefined
// HTMLCollections are strange objects, they support both get and call,
// so that document.forms.item(0) and document.forms(0) both work.
static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
{
if (args.size() < 1)
return jsUndefined();
// Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
JSHTMLCollection* jsCollection = static_cast<JSHTMLCollection*>(function);
HTMLCollection* collection = jsCollection->impl();
// Also, do we need the TypeError test here ?
if (args.size() == 1) {
// Support for document.all(<index>) etc.
bool ok;
UString string = args.at(0).toString(exec);
unsigned index = string.toUInt32(&ok, false);
if (ok)
return toJS(exec, jsCollection->globalObject(), collection->item(index));
// Support for document.images('<name>') etc.
return getNamedItems(exec, jsCollection, Identifier(exec, string));
}
// The second arg, if set, is the index of the item we want
bool ok;
UString string = args.at(0).toString(exec);
unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
if (ok) {
String pstr = string;
Node* node = collection->namedItem(pstr);
while (node) {
if (!index)
return toJS(exec, jsCollection->globalObject(), node);
node = collection->nextNamedItem(pstr);
--index;
}
}
return jsUndefined();
}
示例5: ENABLE
v8::Handle<v8::Value> V8HTMLCollection::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();
HTMLCollection* imp = V8HTMLCollection::toNative(info.Holder());
#if ENABLE(MICRODATA)
if (imp->type() == ItemProperties) {
if (!static_cast<HTMLPropertiesCollection*>(imp)->hasNamedItem(toWebCoreAtomicString(name)))
return v8Undefined();
RefPtr<PropertyNodeList> item = static_cast<HTMLPropertiesCollection*>(imp)->propertyNodeList(toWebCoreAtomicString(name));
if (!item)
return v8Undefined();
return toV8(item.release(), info.Holder(), info.GetIsolate());
}
#endif
Node* item = imp->namedItem(toWebCoreAtomicString(name));
if (!item)
return v8Undefined();
return toV8(item, info.Holder(), info.GetIsolate());
}