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); }
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()); }
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()); }