Reviewed by Ken.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2004 21:09:43 +0000 (21:09 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2004 21:09:43 +0000 (21:09 +0000)
<rdar://problem/3907705> 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
WebCore/khtml/dom/html_document.cpp
WebCore/khtml/dom/html_document.h
WebCore/khtml/ecma/kjs_html.cpp
WebCore/khtml/html/html_miscimpl.cpp
WebCore/khtml/html/html_miscimpl.h

index ecd0632af495568b5e068cf8b99d45657c7057a5..4b624355a4fc1acd68efd172ca7dbf3b683c77e4 100644 (file)
@@ -1,3 +1,23 @@
+2004-12-10  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Ken.
+
+       <rdar://problem/3907705> 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  <kocienda@apple.com>
 
         Reviewed by John
index 3e4a057e0a7293e9644a94f43b7f25cb6b2ffa43..eab1256025b0dab65acffe0295b2042e93f84042 100644 (file)
@@ -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();
index 870381ff7b3b36f012d99927c02a5dc41e81ee48..6bbd8be54d9f5430a92072c4a800b73488436dc5 100644 (file)
@@ -300,6 +300,15 @@ public:
      */
     HTMLCollection all() const;
 
+    /**
+     * Not part of the DOM
+     *
+     * A collection of all the <code>IMG</code>, <code>OBJECT</code>,
+     * <code>EMBED</code>, <code>APPLET</code>, and <code>FORM</code> 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
index 3bc417958b0ef0ad5ade30bf69cd0352f8e876f3..a4d85f738cdb92259efad20a2960c4683d0775e5 100644 (file)
@@ -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();
 }
index 6815f25ffd41166abd0f89800f43866ad5640f98..88278fd57f9043395d29bc243f7dec28eab644dd 100644 (file)
@@ -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<NodeImpl> *nameVector = info->idCache.find(nameAttr);
+            QPtrVector<NodeImpl> *nameVector = info->nameCache.find(nameAttr);
             if (!nameVector) {
                 nameVector = new QPtrVector<NodeImpl>;
                 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<NodeImpl> *nameVector = info->idCache.find(nameAttr);
+            QPtrVector<NodeImpl> *nameVector = info->nameCache.find(nameAttr);
             if (!nameVector) {
                 nameVector = new QPtrVector<NodeImpl>;
                 info->nameCache.insert(nameAttr, nameVector);
index 5d58598bdd5b326e609f5e996c1eee1ff6d1f2d3..19c4d902a0f66c7f25773f683bb0f67f14d840d4 100644 (file)
@@ -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
     };