Commit 04df0076 authored by ap's avatar ap
Browse files

Reviewed by Darin.

        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: http://svn.webkit.org/repository/webkit/trunk@18674 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2fe6f914
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
......@@ -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]
......
Test for bug 7640: Menu items are displayed as "undefined".
Node.item() should not exist.
SUCCESS
<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>
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.
......
......@@ -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();
......
......@@ -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,
......
......@@ -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))));
}
......
......@@ -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,
......
......@@ -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)
......
......@@ -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; }
......
......@@ -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);
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment