[webkit-changes] cvs commit: WebCore/khtml/ecma kjs_dom.cpp
kjs_dom.h
Eric
eseidel at opensource.apple.com
Tue Oct 4 23:08:09 PDT 2005
eseidel 05/10/04 23:08:08
Modified: . ChangeLog
khtml/ecma kjs_dom.cpp kjs_dom.h
Log:
Bug #: 4285884
Submitted by: eseidel
Reviewed by: mjs
Support direct named attribute lookkup, like FireFox,IE.
This was causing a JavaScript exception for gap.com
<rdar://problem/4285884> Gap.com throws exception "Undefined value" because of Safari doesn't support indexing into a named node map by name
* khtml/ecma/kjs_dom.cpp:
(KJS::DOMNodeList::getOwnPropertySlot): if cleanup
(KJS::DOMNamedNodeMap::nameGetter):
(KJS::DOMNamedNodeMap::getOwnPropertySlot):
* khtml/ecma/kjs_dom.h: added nameGetter
Revision Changes Path
1.196 +14 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -r1.195 -r1.196
--- ChangeLog 5 Oct 2005 05:35:05 -0000 1.195
+++ ChangeLog 5 Oct 2005 06:08:05 -0000 1.196
@@ -1,5 +1,19 @@
2005-10-04 Eric Seidel <eseidel at apple.com>
+ Reviewed by mjs.
+
+ Support direct named attribute lookkup, like FireFox,IE.
+ This was causing a JavaScript exception for gap.com
+ <rdar://problem/4285884> Gap.com throws exception "Undefined value" because of Safari doesn't support indexing into a named node map by name
+
+ * khtml/ecma/kjs_dom.cpp:
+ (KJS::DOMNodeList::getOwnPropertySlot): if cleanup
+ (KJS::DOMNamedNodeMap::nameGetter):
+ (KJS::DOMNamedNodeMap::getOwnPropertySlot):
+ * khtml/ecma/kjs_dom.h: added nameGetter
+
+2005-10-04 Eric Seidel <eseidel at apple.com>
+
No review, build fix only.
Fix to include "config.h" in every file.
1.100 +30 -30 WebCore/khtml/ecma/kjs_dom.cpp
Index: kjs_dom.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- kjs_dom.cpp 3 Oct 2005 21:12:12 -0000 1.99
+++ kjs_dom.cpp 5 Oct 2005 06:08:08 -0000 1.100
@@ -86,15 +86,6 @@
namespace KJS {
-class DOMNodeListFunc : public DOMFunction {
- friend class DOMNodeList;
-public:
- DOMNodeListFunc(ExecState *exec, int id, int len);
- virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &);
-private:
- int id;
-};
-
// -------------------------------------------------------------------------
/* Source for DOMNodeProtoTable. Use "make hashtables" to regenerate.
@begin DOMNodeProtoTable 13
@@ -710,6 +701,8 @@
@end
*/
+IMPLEMENT_PROTOFUNC(DOMNodeListFunc)
+
const ClassInfo DOMNodeList::info = { "NodeList", 0, &DOMNodeListTable, 0 };
DOMNodeList::~DOMNodeList()
@@ -763,11 +756,9 @@
if (ok && idx < list.length()) {
slot.setCustomIndex(this, idx, indexGetter);
return true;
- } else {
- if (list.itemById(propertyName.domString())) {
- slot.setCustom(this, nameGetter);
- return true;
- }
+ } else if (list.itemById(propertyName.domString())) {
+ slot.setCustom(this, nameGetter);
+ return true;
}
return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
@@ -786,12 +777,6 @@
return Undefined();
}
-DOMNodeListFunc::DOMNodeListFunc(ExecState *exec, int i, int len)
- : id(i)
-{
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
-}
-
// Not a prototype class currently, but should probably be converted to one
ValueImp *DOMNodeListFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args)
{
@@ -1431,20 +1416,35 @@
return getDOMNode(exec, thisObj->m_impl->item(slot.index()));
}
+ValueImp *DOMNamedNodeMap::nameGetter(ExecState *exec, const Identifier& propertyName, const PropertySlot& slot)
+{
+ DOMNamedNodeMap *thisObj = static_cast<DOMNamedNodeMap *>(slot.slotBase());
+ return getDOMNode(exec, thisObj->m_impl->getNamedItem(propertyName.domString()));
+}
+
bool DOMNamedNodeMap::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- NamedNodeMapImpl &map = *m_impl;
if (propertyName == lengthPropertyName) {
- slot.setCustom(this, lengthGetter);
- return true;
- }
+ slot.setCustom(this, lengthGetter);
+ return true;
+ } else {
+ // Look in the prototype (for functions) before assuming it's an item's name
+ ValueImp *proto = prototype();
+ if (proto->isObject() && static_cast<ObjectImp *>(proto)->hasProperty(exec, propertyName))
+ return false;
+
+ // name or index ?
+ bool ok;
+ unsigned idx = propertyName.toUInt32(&ok);
+ if (ok && idx < m_impl->length()) {
+ slot.setCustomIndex(this, idx, indexGetter);
+ return true;
+ }
- // array index ?
- bool ok;
- unsigned idx = propertyName.toUInt32(&ok);
- if (ok && idx < map.length()) {
- slot.setCustomIndex(this, idx, indexGetter);
- return true;
+ if (m_impl->getNamedItem(propertyName.domString())) {
+ slot.setCustom(this, nameGetter);
+ return true;
+ }
}
return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
1.51 +1 -0 WebCore/khtml/ecma/kjs_dom.h
Index: kjs_dom.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- kjs_dom.h 27 Sep 2005 22:37:03 -0000 1.50
+++ kjs_dom.h 5 Oct 2005 06:08:08 -0000 1.51
@@ -218,6 +218,7 @@
private:
static ValueImp *lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot);
static ValueImp *indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot);
+ static ValueImp *nameGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
SharedPtr<DOM::NamedNodeMapImpl> m_impl;
};
More information about the webkit-changes
mailing list