| Summary: | KHTML renders incorrectly http://www.linkedfeed.com/ | ||
|---|---|---|---|
| Product: | [Applications] konqueror | Reporter: | Glennie Vignarajah <glennie> | 
| Component: | general | Assignee: | Konqueror Bugs <konqueror-bugs-null> | 
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | maksim | 
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Debian testing | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| 
        
          Description
        
        
          Glennie Vignarajah
        
        
        
        
          2006-03-12 18:31:08 UTC
        
       We do support so-called AJAX. Problem here is this: code expects for .. in .. on a NodeList to return indeces. Hello, So is this because KHTML misinterprets javascript (then this should be fixed) or a programing error (in which case I can close the bug report) ? SVN commit 517975 by orlovich:
Enumerate indeces as collection/NodeList properties.
Makes www.linkedfeed.com show up
BUG:123507
 M  +27 -2     kjs_dom.cpp  
 M  +2 -0      kjs_dom.h  
 M  +24 -2     kjs_html.cpp  
 M  +1 -0      kjs_html.h  
--- branches/KDE/3.5/kdelibs/khtml/ecma/kjs_dom.cpp #517974:517975
@@ -589,8 +589,17 @@
 {
   if (p == lengthPropertyName)
     return true;
-  // ## missing: accept p if array index or item id...
-  return ObjectImp::hasProperty(exec, p);
+
+  if (ObjectImp::hasProperty(exec, p))
+    return true;
+
+  bool ok;
+  unsigned long pos = p.toULong(&ok);
+  if (ok && pos < list.length())
+    return true;
+
+  // ## missing: accept p if item id...
+  return false;
 }
 
 Value DOMNodeList::tryGet(ExecState *exec, const Identifier &p) const
@@ -633,6 +642,22 @@
   return result;
 }
 
+ReferenceList DOMNodeList::propList(ExecState *exec, bool recursive)
+{
+  ReferenceList properties = ObjectImp::propList(exec,recursive);
+
+  for (unsigned i = 0; i < list.length(); ++i) {
+    if (!ObjectImp::hasProperty(exec,Identifier::from(i))) {
+      properties.append(Reference(this, i));
+    }
+  }
+
+  if (!ObjectImp::hasProperty(exec, lengthPropertyName))
+    properties.append(Reference(this, lengthPropertyName));
+
+  return properties;
+}
+
 // Need to support both get and call, so that list[0] and list(0) work.
 Value DOMNodeList::call(ExecState *exec, Object &thisObj, const List &args)
 {
--- branches/KDE/3.5/kdelibs/khtml/ecma/kjs_dom.h #517974:517975
@@ -81,6 +81,8 @@
     virtual Value call(ExecState *exec, Object &thisObj, const List&args);
     virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
     virtual bool implementsCall() const { return true; }
+    virtual ReferenceList propList(ExecState *exec, bool recursive);
+
     // no put - all read-only
     virtual const ClassInfo* classInfo() const { return &info; }
     virtual bool toBoolean(ExecState *) const { return true; }
--- branches/KDE/3.5/kdelibs/khtml/ecma/kjs_html.cpp #517974:517975
@@ -3133,8 +3133,8 @@
     return !hidden;
 }
 
-// We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length'
-// ## this breaks "for (..in..)" though.
+// We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length',
+// and for indices in "for (..in..)"
 bool KJS::HTMLCollection::hasProperty(ExecState *exec, const Identifier &p) const
 {
   if (p == lengthPropertyName)
@@ -3142,9 +3142,31 @@
   if ( collection.handle()->getType() == HTMLCollectionImpl::SELECT_OPTIONS &&
        ( p == "selectedIndex" || p == "value" ) )
     return true;
+
+  bool ok;
+  unsigned long pos = p.toULong(&ok);
+  if (ok && pos < collection.length())
+    return true;
+
   return DOMObject::hasProperty(exec, p);
 }
 
+ReferenceList KJS::HTMLCollection::propList(ExecState *exec, bool recursive)
+{
+  ReferenceList properties = ObjectImp::propList(exec,recursive);
+
+  for (unsigned i = 0; i < collection.length(); ++i) {
+    if (!ObjectImp::hasProperty(exec,Identifier::from(i))) {
+      properties.append(Reference(this, i));
+    }
+  }
+
+  if (!ObjectImp::hasProperty(exec, lengthPropertyName))
+    properties.append(Reference(this, lengthPropertyName));
+
+  return properties;
+}
+
 Value KJS::HTMLCollection::tryGet(ExecState *exec, const Identifier &propertyName) const
 {
 #ifdef KJS_VERBOSE
--- branches/KDE/3.5/kdelibs/khtml/ecma/kjs_html.h #517974:517975
@@ -178,6 +178,7 @@
     virtual bool implementsCall() const { return true; }
     virtual bool toBoolean(ExecState *) const;
     virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
+    virtual ReferenceList propList(ExecState *exec, bool recursive);
     enum { Item, NamedItem, Tags };
     Value getNamedItems(ExecState *exec, const Identifier &propertyName) const;
     virtual const ClassInfo* classInfo() const { return &info; }
It's actually sort of both: khtml behaved differently from other browsers, but that bit of code is also quite poor, and it's skimming right on the edge of erroring out... |