Commit fdb27973 authored by ap's avatar ap

2007-01-09 Mitz Pettel <mitz@webkit.org>

        Reviewed by Darin.

        - changes for http://bugs.webkit.org/show_bug.cgi?id=11078
          Forms Don't Submit (ASP Pages)

JavaScriptCore:
        * JavaScriptCore.exp:
        * kjs/value.cpp:
        (KJS::JSValue::toInt32): Folded toInt32Inline into this method, which was its
        only caller.
        (KJS::JSValue::toUInt32): Added a variant that reports if the conversion has
        succeeded.
        * kjs/value.h:

WebCore:
        * bindings/js/kjs_html.cpp:
        (KJS::JSHTMLCollectionProtoFunc::callAsFunction): Changed item() to fall back
        to namedItem() if its argument does not convert to a number.

LayoutTests:
        * fast/dom/collection-namedItem-via-item-expected.txt: Added.
        * fast/dom/collection-namedItem-via-item.html: Added.



git-svn-id: svn://svn.chromium.org/blink/trunk@18715 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0961d165
2007-01-09 Mitz Pettel <mitz@webkit.org>
Reviewed by Darin.
- changes for http://bugs.webkit.org/show_bug.cgi?id=11078
Forms Don't Submit (ASP Pages)
* JavaScriptCore.exp:
* kjs/value.cpp:
(KJS::JSValue::toInt32): Folded toInt32Inline into this method, which was its
only caller.
(KJS::JSValue::toUInt32): Added a variant that reports if the conversion has
succeeded.
* kjs/value.h:
2007-01-09 Darin Adler <darin@apple.com>
Reviewed by Maciej.
......
......@@ -247,6 +247,7 @@ __ZNK3KJS6JSCell9getUInt32ERj
__ZNK3KJS7JSValue7toInt32EPNS_9ExecStateE
__ZNK3KJS7JSValue7toInt32EPNS_9ExecStateERb
__ZNK3KJS7JSValue8toUInt32EPNS_9ExecStateE
__ZNK3KJS7JSValue8toUInt32EPNS_9ExecStateERb
__ZNK3KJS7JSValue9toIntegerEPNS_9ExecStateE
__ZNK3KJS7UString10UTF8StringEv
__ZNK3KJS7UString14toStrictUInt32EPb
......
......@@ -55,7 +55,13 @@ double JSValue::toInteger(ExecState *exec) const
return roundValue(exec, const_cast<JSValue*>(this));
}
inline int32_t JSValue::toInt32Inline(ExecState* exec, bool& ok) const
int32_t JSValue::toInt32(ExecState* exec) const
{
bool ok;
return toInt32(exec, ok);
}
int32_t JSValue::toInt32(ExecState* exec, bool& ok) const
{
ok = true;
......@@ -78,26 +84,25 @@ inline int32_t JSValue::toInt32Inline(ExecState* exec, bool& ok) const
return static_cast<int32_t>(d32);
}
int32_t JSValue::toInt32(ExecState* exec) const
uint32_t JSValue::toUInt32(ExecState* exec) const
{
bool ok;
return toInt32(exec, ok);
return toUInt32(exec, ok);
}
int32_t JSValue::toInt32(ExecState* exec, bool& ok) const
uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const
{
return toInt32Inline(exec, ok);
}
ok = true;
uint32_t JSValue::toUInt32(ExecState *exec) const
{
uint32_t i;
if (getUInt32(i))
return i;
double d = roundValue(exec, const_cast<JSValue*>(this));
if (isNaN(d) || isInf(d))
if (isNaN(d) || isInf(d)) {
ok = false;
return 0;
}
double d32 = fmod(d, D32);
if (d32 < 0)
......
......@@ -94,11 +94,12 @@ public:
JSObject *toObject(ExecState *exec) const;
// Integer conversions.
double toInteger(ExecState *exec) const;
double toInteger(ExecState*) const;
int32_t toInt32(ExecState*) const;
int32_t toInt32(ExecState*, bool& ok) const;
uint32_t toUInt32(ExecState *exec) const;
uint16_t toUInt16(ExecState *exec) const;
uint32_t toUInt32(ExecState*) const;
uint32_t toUInt32(ExecState*, bool& ok) const;
uint16_t toUInt16(ExecState*) const;
// Garbage collection.
void mark();
......@@ -108,7 +109,6 @@ private:
// Implementation details.
JSCell *downcast();
const JSCell *downcast() const;
inline int32_t toInt32Inline(ExecState*, bool& ok) const;
// Give a compile time error if we try to copy one of these.
JSValue(const JSValue&);
......
2007-01-09 Mitz Pettel <mitz@webkit.org>
Reviewed by Darin.
- test for http://bugs.webkit.org/show_bug.cgi?id=11078
Forms Don't Submit (ASP Pages)
* fast/dom/collection-namedItem-via-item-expected.txt: Added.
* fast/dom/collection-namedItem-via-item.html: Added.
2007-01-09 Darin Adler <darin@apple.com>
Reviewed by Mitz.
Test for http://bugs.webkit.org/show_bug.cgi?id=11078 Forms Don't Submit (ASP Pages).
PASS: document.all.item('1') == document.all.item(1)
PASS: document.all.item('target') == document.getElementById('target')
PASS: document.all.item('foo') == undefined
<head>
<script>
function log(test)
{
var result = eval(test);
document.getElementById("results").appendChild(document.createTextNode((result ? "PASS" : "FAIL") + ": " + test + "\n"));
}
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
log("document.all.item('1') == document.all.item(1)");
log("document.all.item('target') == document.getElementById('target')");
log("document.all.item('foo') == undefined");
}
</script>
</head>
<body onload="test()">
<p>
Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=11078">http://bugs.webkit.org/show_bug.cgi?id=11078</a>
Forms Don't Submit (ASP Pages)</i>.
</p>
<pre id="results"></pre>
<div id="target"></div>
<div id="1"></div>
</body>
2007-01-09 Mitz Pettel <mitz@webkit.org>
Reviewed by Darin.
- fix http://bugs.webkit.org/show_bug.cgi?id=11078
Forms Don't Submit (ASP Pages)
Test: fast/dom/collection-namedItem-via-item.html
* bindings/js/kjs_html.cpp:
(KJS::JSHTMLCollectionProtoFunc::callAsFunction): Changed item() to fall back
to namedItem() if its argument does not convert to a number.
2007-01-09 Darin Adler <darin@apple.com>
Reviewed by Maciej.
......
......@@ -1677,10 +1677,16 @@ JSValue* JSHTMLCollectionProtoFunc::callAsFunction(ExecState* exec, JSObject* th
HTMLCollection &coll = *static_cast<JSHTMLCollection*>(thisObj)->impl();
switch (id) {
case JSHTMLCollection::Item:
return toJS(exec,coll.item(args[0]->toUInt32(exec)));
case JSHTMLCollection::Tags:
return toJS(exec, coll.base()->getElementsByTagName(args[0]->toString(exec)).get());
case JSHTMLCollection::Item:
{
bool ok;
uint32_t index = args[0]->toUInt32(exec, ok);
if (ok)
return toJS(exec, coll.item(index));
}
// Fall through
case JSHTMLCollection::NamedItem:
return static_cast<JSHTMLCollection*>(thisObj)->getNamedItems(exec, Identifier(args[0]->toString(exec)));
default:
......
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