本文整理汇总了C++中HTMLDocument::documentNamedItems方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLDocument::documentNamedItems方法的具体用法?C++ HTMLDocument::documentNamedItems怎么用?C++ HTMLDocument::documentNamedItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLDocument
的用法示例。
在下文中一共展示了HTMLDocument::documentNamedItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nameGetter
JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
{
JSHTMLDocument* thisObj = jsCast<JSHTMLDocument*>(asObject(slotBase));
HTMLDocument* document = toHTMLDocument(thisObj->impl());
AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
if (!atomicPropertyName || !document->documentNamedItemMap().contains(atomicPropertyName))
return jsUndefined();
if (UNLIKELY(!document->documentNamedItemMap().containsSingle(atomicPropertyName))) {
RefPtr<HTMLCollection> collection = document->documentNamedItems(atomicPropertyName);
ASSERT(!collection->isEmpty());
ASSERT(!collection->hasExactlyOneItem());
return toJS(exec, thisObj->globalObject(), WTF::getPtr(collection));
}
Node* node = document->documentNamedItemMap().getElementByDocumentNamedItem(atomicPropertyName, document);
Frame* frame;
if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
return toJS(exec, frame);
return toJS(exec, thisObj->globalObject(), node);
}
示例2: nameGetter
JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(asObject(slotBase));
HTMLDocument* document = static_cast<HTMLDocument*>(thisObj->impl());
String name = identifierToString(propertyName);
RefPtr<HTMLCollection> collection = document->documentNamedItems(name);
unsigned length = collection->length();
if (!length)
return jsUndefined();
if (length == 1) {
Node* node = collection->firstItem();
Frame* frame;
if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
return toJS(exec, frame);
return toJS(exec, node);
}
return toJS(exec, collection.get());
}
示例3: nameGetter
JSValue* JSHTMLDocument::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
{
JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(slot.slotBase());
HTMLDocument* doc = static_cast<HTMLDocument*>(thisObj->impl());
String name = propertyName;
RefPtr<HTMLCollection> collection = doc->documentNamedItems(name);
unsigned length = collection->length();
if (!length)
return jsUndefined();
if (length == 1) {
Node* node = collection->firstItem();
Frame* frame;
if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
return Window::retrieve(frame);
return toJS(exec, node);
}
return toJS(exec, collection.get());
}