From 4987b3f5a4d0850e229bf799c2b3c5ddf3b663c8 Mon Sep 17 00:00:00 2001 From: mjs Date: Fri, 10 Dec 2004 21:09:43 +0000 Subject: [PATCH] Reviewed by Ken. REGRESSION (172-173): DHTML menus are broken at hrweb.apple.com * khtml/dom/html_document.cpp: (HTMLDocument::nameableItems): New method, wrapper for HTMLCollection creation. * khtml/dom/html_document.h: * khtml/ecma/kjs_html.cpp: (KJS::HTMLDocument::tryGet): use doc.nameableItems(), not doc.all()! * khtml/html/html_miscimpl.cpp: (HTMLCollectionImpl::traverseNextItem): Added new DOC_NAMEABLE_ITEMS type, this represents the items that can be accessed directly as a document propery, in particular forms, images, objects, applets and embeds. (HTMLCollectionImpl::updateNameCache): Fix some nameCache/idCache confusion. (HTMLFormCollectionImpl::updateNameCache): Ditto. * khtml/html/html_miscimpl.h: (DOM::HTMLCollectionImpl::): Added new type. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8185 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog-2005-08-23 | 20 ++++++++++++++++++++ WebCore/khtml/dom/html_document.cpp | 6 ++++++ WebCore/khtml/dom/html_document.h | 9 +++++++++ WebCore/khtml/ecma/kjs_html.cpp | 6 +++--- WebCore/khtml/html/html_miscimpl.cpp | 16 ++++++++++++++-- WebCore/khtml/html/html_miscimpl.h | 2 ++ 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23 index ecd0632af495..4b624355a4fc 100644 --- a/WebCore/ChangeLog-2005-08-23 +++ b/WebCore/ChangeLog-2005-08-23 @@ -1,3 +1,23 @@ +2004-12-10 Maciej Stachowiak + + Reviewed by Ken. + + REGRESSION (172-173): DHTML menus are broken at hrweb.apple.com + + * khtml/dom/html_document.cpp: + (HTMLDocument::nameableItems): New method, wrapper for HTMLCollection creation. + * khtml/dom/html_document.h: + * khtml/ecma/kjs_html.cpp: + (KJS::HTMLDocument::tryGet): use doc.nameableItems(), not doc.all()! + * khtml/html/html_miscimpl.cpp: + (HTMLCollectionImpl::traverseNextItem): Added new DOC_NAMEABLE_ITEMS type, this represents + the items that can be accessed directly as a document propery, in particular forms, images, + objects, applets and embeds. + (HTMLCollectionImpl::updateNameCache): Fix some nameCache/idCache confusion. + (HTMLFormCollectionImpl::updateNameCache): Ditto. + * khtml/html/html_miscimpl.h: + (DOM::HTMLCollectionImpl::): Added new type. + 2004-12-10 Ken Kocienda Reviewed by John diff --git a/WebCore/khtml/dom/html_document.cpp b/WebCore/khtml/dom/html_document.cpp index 3e4a057e0a72..eab1256025b0 100644 --- a/WebCore/khtml/dom/html_document.cpp +++ b/WebCore/khtml/dom/html_document.cpp @@ -190,6 +190,12 @@ HTMLCollection HTMLDocument::all() const return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL); } +HTMLCollection HTMLDocument::nameableItems() const +{ + if(!impl) return HTMLCollection(); + return HTMLCollection(impl, HTMLCollectionImpl::DOC_NAMEABLE_ITEMS); +} + DOMString HTMLDocument::cookie() const { if (!impl) return DOMString(); diff --git a/WebCore/khtml/dom/html_document.h b/WebCore/khtml/dom/html_document.h index 870381ff7b3b..6bbd8be54d9f 100644 --- a/WebCore/khtml/dom/html_document.h +++ b/WebCore/khtml/dom/html_document.h @@ -300,6 +300,15 @@ public: */ HTMLCollection all() const; + /** + * Not part of the DOM + * + * A collection of all the IMG, OBJECT, + * EMBED, APPLET, and FORM tags in + * a document. Used when looking up elements by name as properties on the document + * object, e.g. document.myForm for a form with name attribute of "myForm". + */ + HTMLCollection nameableItems() const; }; }; //namespace diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp index 3bc417958b0e..a4d85f738cdb 100644 --- a/WebCore/khtml/ecma/kjs_html.cpp +++ b/WebCore/khtml/ecma/kjs_html.cpp @@ -332,9 +332,9 @@ Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName) return Undefined(); } - DOM::HTMLCollection collAll = doc.all(); - KJS::HTMLCollection htmlcoll(exec,collAll); - return htmlcoll.getNamedItems(exec, propertyName); // Get all the items with the same name + DOM::HTMLCollection nameableItems = doc.nameableItems(); + KJS::HTMLCollection kjsCollection(exec,nameableItems); + return kjsCollection.getNamedItems(exec, propertyName); // Get all the items with the same name return Undefined(); } diff --git a/WebCore/khtml/html/html_miscimpl.cpp b/WebCore/khtml/html/html_miscimpl.cpp index 6815f25ffd41..88278fd57f90 100644 --- a/WebCore/khtml/html/html_miscimpl.cpp +++ b/WebCore/khtml/html/html_miscimpl.cpp @@ -119,6 +119,18 @@ NodeImpl *HTMLCollectionImpl::traverseNextItem(NodeImpl *current) const if(e->id() == ID_FORM) found = true; break; + case DOC_NAMEABLE_ITEMS: + if(e->id() == ID_IMG) + found = true; + if(e->id() == ID_FORM) + found = true; + if(e->id() == ID_APPLET) + found = true; + if(e->id() == ID_EMBED) + found = true; + if(e->id() == ID_OBJECT) + found = true; + break; case TABLE_TBODIES: if(e->id() == ID_TBODY) found = true; @@ -352,7 +364,7 @@ void HTMLCollectionImpl::updateNameCache() const e->id() == ID_APPLET || e->id() == ID_OBJECT || e->id() == ID_EMBED))) { // add to name cache - QPtrVector *nameVector = info->idCache.find(nameAttr); + QPtrVector *nameVector = info->nameCache.find(nameAttr); if (!nameVector) { nameVector = new QPtrVector; info->nameCache.insert(nameAttr, nameVector); @@ -656,7 +668,7 @@ void HTMLFormCollectionImpl::updateNameCache() const } if (!nameAttr.isEmpty() && idAttr != nameAttr && !foundInputElements.find(nameAttr)) { // add to name cache - QPtrVector *nameVector = info->idCache.find(nameAttr); + QPtrVector *nameVector = info->nameCache.find(nameAttr); if (!nameVector) { nameVector = new QPtrVector; info->nameCache.insert(nameAttr, nameVector); diff --git a/WebCore/khtml/html/html_miscimpl.h b/WebCore/khtml/html/html_miscimpl.h index 5d58598bdd5b..19c4d902a0f6 100644 --- a/WebCore/khtml/html/html_miscimpl.h +++ b/WebCore/khtml/html/html_miscimpl.h @@ -69,6 +69,8 @@ public: MAP_AREAS, DOC_ALL, // "all" elements (IE) NODE_CHILDREN, // first-level children (IE) + DOC_NAMEABLE_ITEMS, // all IMG, FORM, APPLET, EMBED and OBJECT elements, used to look + // up element name as document property LAST_TYPE }; -- 2.36.0