Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jan 2007 19:42:33 +0000 (19:42 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jan 2007 19:42:33 +0000 (19:42 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=7640
        Menu items are displayed as "undefined"

WebCore:
        * bindings/js/kjs_dom.cpp:
        (KJS::DOMNodeProtoFunc::callAsFunction):
        * bindings/js/kjs_domnode.h:
        (KJS::DOMNode::):
        Removed Node::item. No idea why it was there in the first place.

        * bindings/js/kjs_html.cpp:
        (KJS::HTMLElementFunction::callAsFunction):
        * bindings/js/kjs_html.h:
        (KJS::JSHTMLElement::):
        Added HTMLSelectElement::item. It is not in DOM2 IDL, but the spec seems to mentions it anyway:
        "The contained options can be directly accessed through the select element as a collection."

        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::namedItem):
        (WebCore::HTMLSelectElement::item):
        * html/HTMLSelectElement.h:
        * html/HTMLSelectElement.idl:
        Added this method to DOM and IDL, too. Made namedItem() non-virtual.

LayoutTests:
        * fast/dom/Window/window-properties-expected.txt: Updated the results.

        * fast/dom/node-item-expected.txt: Added.
        * fast/dom/node-item.html: Added.
        Check that there is no Node:item or HTMLElement:item.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@18674 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-properties-expected.txt
LayoutTests/fast/dom/node-item-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/node-item.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/kjs_dom.cpp
WebCore/bindings/js/kjs_domnode.h
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_html.h
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLSelectElement.h
WebCore/html/HTMLSelectElement.idl

index 12a500d377e0c16aebcb9cfe6f5377cd46ae73b5..9d0639c25bd4a3b5979cba50b9177acac65080f9 100644 (file)
@@ -1,3 +1,16 @@
+2007-01-08  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=7640
+        Menu items are displayed as "undefined"
+
+        * fast/dom/Window/window-properties-expected.txt: Updated the results.
+
+        * fast/dom/node-item-expected.txt: Added.
+        * fast/dom/node-item.html: Added.
+        Check that there is no Node:item or HTMLElement:item.
+
 2007-01-08  Darin Adler  <darin@apple.com>
 
         - added a W3C list style test that was cited in a bug
index aab43db06b366c3b76d78c8ede705d43c771ef95..8a5bc36c9c4f0c36a502e5da6a74e17caa20798f 100644 (file)
@@ -95,7 +95,6 @@ window.DocumentFragment.prototype.isDefaultNamespace [function]
 window.DocumentFragment.prototype.isEqualNode [function]
 window.DocumentFragment.prototype.isSameNode [function]
 window.DocumentFragment.prototype.isSupported [function]
-window.DocumentFragment.prototype.item [function]
 window.DocumentFragment.prototype.lookupNamespaceURI [function]
 window.DocumentFragment.prototype.lookupPrefix [function]
 window.DocumentFragment.prototype.normalize [function]
@@ -139,7 +138,6 @@ window.Element.prototype.isDefaultNamespace [function]
 window.Element.prototype.isEqualNode [function]
 window.Element.prototype.isSameNode [function]
 window.Element.prototype.isSupported [function]
-window.Element.prototype.item [function]
 window.Element.prototype.lookupNamespaceURI [function]
 window.Element.prototype.lookupPrefix [function]
 window.Element.prototype.normalize [function]
@@ -241,7 +239,6 @@ window.HTMLElement.prototype.isDefaultNamespace [function]
 window.HTMLElement.prototype.isEqualNode [function]
 window.HTMLElement.prototype.isSameNode [function]
 window.HTMLElement.prototype.isSupported [function]
-window.HTMLElement.prototype.item [function]
 window.HTMLElement.prototype.lookupNamespaceURI [function]
 window.HTMLElement.prototype.lookupPrefix [function]
 window.HTMLElement.prototype.normalize [function]
@@ -326,7 +323,6 @@ window.Node.prototype.isDefaultNamespace [function]
 window.Node.prototype.isEqualNode [function]
 window.Node.prototype.isSameNode [function]
 window.Node.prototype.isSupported [function]
-window.Node.prototype.item [function]
 window.Node.prototype.lookupNamespaceURI [function]
 window.Node.prototype.lookupPrefix [function]
 window.Node.prototype.normalize [function]
@@ -469,7 +465,6 @@ window.XMLDocument.prototype.isDefaultNamespace [function]
 window.XMLDocument.prototype.isEqualNode [function]
 window.XMLDocument.prototype.isSameNode [function]
 window.XMLDocument.prototype.isSupported [function]
-window.XMLDocument.prototype.item [function]
 window.XMLDocument.prototype.lookupNamespaceURI [function]
 window.XMLDocument.prototype.lookupPrefix [function]
 window.XMLDocument.prototype.normalize [function]
@@ -675,7 +670,6 @@ window.document.body.firstChild.isDefaultNamespace [function]
 window.document.body.firstChild.isEqualNode [function]
 window.document.body.firstChild.isSameNode [function]
 window.document.body.firstChild.isSupported [function]
-window.document.body.firstChild.item [function]
 window.document.body.firstChild.lang [string]
 window.document.body.firstChild.lastChild [object Text]
 window.document.body.firstChild.lastChild.ATTRIBUTE_NODE [number]
@@ -708,7 +702,6 @@ window.document.body.firstChild.lastChild.isDefaultNamespace [function]
 window.document.body.firstChild.lastChild.isEqualNode [function]
 window.document.body.firstChild.lastChild.isSameNode [function]
 window.document.body.firstChild.lastChild.isSupported [function]
-window.document.body.firstChild.lastChild.item [function]
 window.document.body.firstChild.lastChild.lastChild [null]
 window.document.body.firstChild.lastChild.length [number]
 window.document.body.firstChild.lastChild.localName [string]
@@ -767,7 +760,6 @@ window.document.body.firstChild.nextSibling.isDefaultNamespace [function]
 window.document.body.firstChild.nextSibling.isEqualNode [function]
 window.document.body.firstChild.nextSibling.isSameNode [function]
 window.document.body.firstChild.nextSibling.isSupported [function]
-window.document.body.firstChild.nextSibling.item [function]
 window.document.body.firstChild.nextSibling.lastChild [null]
 window.document.body.firstChild.nextSibling.length [number]
 window.document.body.firstChild.nextSibling.localName [string]
@@ -834,7 +826,6 @@ window.document.body.firstChild.nextSibling.nextSibling.isDefaultNamespace [func
 window.document.body.firstChild.nextSibling.nextSibling.isEqualNode [function]
 window.document.body.firstChild.nextSibling.nextSibling.isSameNode [function]
 window.document.body.firstChild.nextSibling.nextSibling.isSupported [function]
-window.document.body.firstChild.nextSibling.nextSibling.item [function]
 window.document.body.firstChild.nextSibling.nextSibling.lang [string]
 window.document.body.firstChild.nextSibling.nextSibling.lastChild [null]
 window.document.body.firstChild.nextSibling.nextSibling.localName [string]
@@ -872,7 +863,6 @@ window.document.body.firstChild.nextSibling.nextSibling.nextSibling.isDefaultNam
 window.document.body.firstChild.nextSibling.nextSibling.nextSibling.isEqualNode [function]
 window.document.body.firstChild.nextSibling.nextSibling.nextSibling.isSameNode [function]
 window.document.body.firstChild.nextSibling.nextSibling.nextSibling.isSupported [function]
-window.document.body.firstChild.nextSibling.nextSibling.nextSibling.item [function]
 window.document.body.firstChild.nextSibling.nextSibling.nextSibling.lastChild [null]
 window.document.body.firstChild.nextSibling.nextSibling.nextSibling.length [number]
 window.document.body.firstChild.nextSibling.nextSibling.nextSibling.localName [string]
@@ -1031,7 +1021,6 @@ window.document.body.isDefaultNamespace [function]
 window.document.body.isEqualNode [function]
 window.document.body.isSameNode [function]
 window.document.body.isSupported [function]
-window.document.body.item [function]
 window.document.body.lang [string]
 window.document.body.lastChild [object HTMLScriptElement]
 window.document.body.lastChild.ATTRIBUTE_NODE [number]
@@ -1096,7 +1085,6 @@ window.document.body.lastChild.isDefaultNamespace [function]
 window.document.body.lastChild.isEqualNode [function]
 window.document.body.lastChild.isSameNode [function]
 window.document.body.lastChild.isSupported [function]
-window.document.body.lastChild.item [function]
 window.document.body.lastChild.lang [string]
 window.document.body.lastChild.lastChild [object Text]
 window.document.body.lastChild.lastChild.ATTRIBUTE_NODE [number]
@@ -1129,7 +1117,6 @@ window.document.body.lastChild.lastChild.isDefaultNamespace [function]
 window.document.body.lastChild.lastChild.isEqualNode [function]
 window.document.body.lastChild.lastChild.isSameNode [function]
 window.document.body.lastChild.lastChild.isSupported [function]
-window.document.body.lastChild.lastChild.item [function]
 window.document.body.lastChild.lastChild.lastChild [null]
 window.document.body.lastChild.lastChild.length [number]
 window.document.body.lastChild.lastChild.localName [string]
@@ -1204,7 +1191,6 @@ window.document.body.lastChild.previousSibling.isDefaultNamespace [function]
 window.document.body.lastChild.previousSibling.isEqualNode [function]
 window.document.body.lastChild.previousSibling.isSameNode [function]
 window.document.body.lastChild.previousSibling.isSupported [function]
-window.document.body.lastChild.previousSibling.item [function]
 window.document.body.lastChild.previousSibling.lastChild [null]
 window.document.body.lastChild.previousSibling.length [number]
 window.document.body.lastChild.previousSibling.localName [string]
@@ -1340,7 +1326,6 @@ window.document.body.parentNode.isDefaultNamespace [function]
 window.document.body.parentNode.isEqualNode [function]
 window.document.body.parentNode.isSameNode [function]
 window.document.body.parentNode.isSupported [function]
-window.document.body.parentNode.item [function]
 window.document.body.parentNode.lang [string]
 window.document.body.parentNode.lastChild [printed above as window.document.body]
 window.document.body.parentNode.localName [string]
@@ -1494,7 +1479,6 @@ window.document.isDefaultNamespace [function]
 window.document.isEqualNode [function]
 window.document.isSameNode [function]
 window.document.isSupported [function]
-window.document.item [function]
 window.document.lastChild [printed above as window.document.body.parentNode]
 window.document.lastModified [string]
 window.document.linkColor [string]
diff --git a/LayoutTests/fast/dom/node-item-expected.txt b/LayoutTests/fast/dom/node-item-expected.txt
new file mode 100644 (file)
index 0000000..618bf61
--- /dev/null
@@ -0,0 +1,6 @@
+Test for bug 7640: Menu items are displayed as "undefined".
+
+Node.item() should not exist.
+
+SUCCESS
+
diff --git a/LayoutTests/fast/dom/node-item.html b/LayoutTests/fast/dom/node-item.html
new file mode 100644 (file)
index 0000000..35e75d9
--- /dev/null
@@ -0,0 +1,20 @@
+<body>
+<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=7640">bug 7640</a>:
+Menu items are displayed as "undefined".</p>
+<p>Node.item() should not exist.</p>
+<div id=result>&nbsp;</div>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    divElement = document.getElementById("result");
+    textNode = divElement.firstChild;
+
+    if (textNode.item != undefined)
+        document.getElementById("result").firstChild.data="FAILURE: Node.item = " + textNode.item;
+    else if (divElement.item != undefined)
+        document.getElementById("result").firstChild.data="FAILURE: HTMLDivElement.item = " + divElement.item;
+    else
+        document.getElementById("result").firstChild.data="SUCCESS";
+</script>
+</body>
index 9725be63871955d00e67a40afa4f56a10d4729b5..0d847bce96238b1fcaeab9d7b124e9017d3f971f 100644 (file)
@@ -1,3 +1,30 @@
+2007-01-08  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=7640
+        Menu items are displayed as "undefined"
+
+        * bindings/js/kjs_dom.cpp:
+        (KJS::DOMNodeProtoFunc::callAsFunction):
+        * bindings/js/kjs_domnode.h:
+        (KJS::DOMNode::):
+        Removed Node::item. No idea why it was there in the first place.
+
+        * bindings/js/kjs_html.cpp:
+        (KJS::HTMLElementFunction::callAsFunction):
+        * bindings/js/kjs_html.h:
+        (KJS::JSHTMLElement::):
+        Added HTMLSelectElement::item. It is not in DOM2 IDL, but the spec seems to mentions it anyway:
+        "The contained options can be directly accessed through the select element as a collection."
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::namedItem):
+        (WebCore::HTMLSelectElement::item):
+        * html/HTMLSelectElement.h:
+        * html/HTMLSelectElement.idl:
+        Added this method to DOM and IDL, too. Made namedItem() non-virtual.
+
 2007-01-08  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Maciej.
index d77996d77df7fc4465a1fc51000403ca2900c281..0640d26478c57a3a673ab4b607b4ad62307cdb1b 100644 (file)
@@ -101,8 +101,6 @@ namespace KJS {
   isDefaultNamespace    DOMNode::IsDefaultNamespace DontDelete|Function 1
   lookupNamespaceURI    DOMNode::LookupNamespaceURI DontDelete|Function 1
   lookupPrefix  DOMNode::LookupPrefix   DontDelete|Function 1
-# "DOM level 0" (from Gecko DOM reference; also in WinIE)
-  item          DOMNode::Item           DontDelete|Function 1
 @end
 */
 KJS_IMPLEMENT_PROTOFUNC(DOMNodeProtoFunc)
@@ -327,8 +325,6 @@ JSValue* DOMNodeProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, co
      if (node.replaceChild(toNode(args[0]), toNode(args[1]), exception))
         return args[1];
       return jsNull();
-    case DOMNode::Item:
-      return thisObj->get(exec, args[0]->toInt32(exec));
   }
 
   return jsUndefined();
index 6d3da58d57e89ae1e68df8757ae6762bd5b05a5a..55fa15910348fc868df6c9a7da3687634ca3d019 100644 (file)
@@ -49,7 +49,7 @@ public:
     virtual UString toString(ExecState*) const;
     
     enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
-        ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling, Item,
+        ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling,
         Attributes, NamespaceURI, Prefix, LocalName, OwnerDocument, InsertBefore,
         ReplaceChild, RemoveChild, AppendChild, HasAttributes, HasChildNodes,
         CloneNode, Normalize, IsSupported, Contains, IsSameNode, IsEqualNode, TextContent,
index b6fb2d2b6774c0fb32c1341239a11e3b6e0beb83..982e88d71155914bc096470fea911c952788b97b 100644 (file)
@@ -531,6 +531,7 @@ const JSHTMLElement::Accessors* JSHTMLElement::accessors() const
   length        KJS::JSHTMLElement::SelectLength  DontDelete
   form          KJS::JSHTMLElement::SelectForm    DontDelete|ReadOnly
   options       KJS::JSHTMLElement::SelectOptions DontDelete|ReadOnly
+  item          KJS::JSHTMLElement::SelectItem    DontDelete|Function 1
   namedItem     KJS::JSHTMLElement::SelectNamedItem       DontDelete|Function 1
   disabled      KJS::JSHTMLElement::SelectDisabled        DontDelete
   multiple      KJS::JSHTMLElement::SelectMultiple        DontDelete
@@ -1159,6 +1160,9 @@ JSValue *HTMLElementFunction::callAsFunction(ExecState* exec, JSObject* thisObj,
             select.focus();
             return jsUndefined();
         }
+        else if (id == JSHTMLElement::SelectItem) {
+            return toJS(exec, select.item(args[0]->toUInt32(exec)));
+        }
         else if (id == JSHTMLElement::SelectNamedItem) {
             return toJS(exec, select.namedItem(Identifier(args[0]->toString(exec))));
         }
index 1863e68c8cdf48697ccd7d7068c9948db97b9f6c..b98fde7ae3dc7e477a16506c3a319050e468da37 100644 (file)
@@ -124,7 +124,7 @@ namespace KJS {
     enum {
            SelectAdd,
            SelectTabIndex, SelectValue, SelectSelectedIndex, SelectLength,
-           SelectRemove, SelectForm, SelectBlur, SelectType, SelectOptions,
+           SelectRemove, SelectForm, SelectBlur, SelectType, SelectOptions, SelectItem,
            SelectDisabled, SelectMultiple, SelectName, SelectNamedItem, SelectSize, SelectFocus,
            ObjectHspace, ObjectHeight, ObjectAlign,
            ObjectBorder, ObjectCode, ObjectType, ObjectVspace, ObjectArchive,
index 4edbf9ac250a5e7121aaffd0f51fc077508c972f..dafa8d47d34e683d6f14e78e754f86f1e36d2f75 100644 (file)
@@ -919,7 +919,12 @@ void HTMLSelectElement::setSize(int size)
 
 Node* HTMLSelectElement::namedItem(const String &name, bool caseSensitive)
 {
-    return (options()->namedItem(name, caseSensitive));
+    return options()->namedItem(name, caseSensitive);
+}
+
+Node* HTMLSelectElement::item(unsigned index)
+{
+    return options()->item(index);
 }
 
 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, ExceptionCode& ec)
index f31512dd7fbba1dc3d04f6be9acc6a9d08d9cf7e..059b8cd857eecd139fada73785bfb28de9f49d79 100644 (file)
@@ -122,7 +122,8 @@ public:
     void setOption(unsigned index, HTMLOptionElement*, ExceptionCode&);
     void setLength(unsigned, ExceptionCode&);
 
-    virtual Node* namedItem(const String& name, bool caseSensitive = true);
+    Node* namedItem(const String& name, bool caseSensitive = true);
+    Node* item(unsigned index);
 
     HTMLCollection::CollectionInfo* collectionInfo() { return &m_collectionInfo; }
     
index 6f9395efa773a53015d5f916c6568c6896b1c9f3..f37b70157e7918b5b6aa74ec06dc85c82e78d74e 100644 (file)
@@ -51,6 +51,9 @@ module html {
         void               blur();
         void               focus();
 
+        // This method is not in DOM Level 2 IDL, but it is mentioned in the standard:
+        // "The contained options can be directly accessed through the select element as a collection."
+        Node item(in [IsIndex] unsigned long index);
     };
 
 }