Fwd: kdelibs/khtml

David Faure faure at kde.org
Tue Nov 25 13:11:10 CET 2003


In case you didn't pick it up in khtml-cvs: you might want to apply this fix.
Testcase and real website url at http://bugs.kde.org/show_bug.cgi?id=56983

----------  Forwarded Message  ----------

Subject: kdelibs/khtml
Date: Tuesday 25 November 2003 13:03
From: David Faure <faure at kde.org>
To: kde-cvs at kde.org
Cc: 56983-fixed at bugs.kde.org, khtml-cvs at kde.org

CVS commit by faure: 

Implement hasProperty and get for frames by number in Window,
to fix window[0] and parent[1] etc. (#56983)
Reviewed by Harri - thanks to Maksim for the testcase.
CCMAIL: 56983-fixed at bugs.kde.org


  M +5 -0      ChangeLog   1.113
  M +28 -3     ecma/kjs_window.cpp   1.363


--- kdelibs/khtml/ChangeLog  #1.112:1.113
@@ -1,2 +1,7 @@
+2003-11-25  David Faure  <faure at kde.org>
+
+        * ecma/kjs_window.cpp: Implement hasProperty and get for frames by number in Window,
+        to fix window[0] and parent[1] etc. (#56983)
+
 2003-11-25  Germain Garand  <germain at ebooksfrance.org>
 

--- kdelibs/khtml/ecma/kjs_window.cpp  #1.362:1.363
@@ -416,4 +416,13 @@ bool Window::hasProperty(ExecState *exec
   if (m_part->findFrame(p.qstring()))
     return true;
+  // allow window[1] or parent[1] etc. (#56983)
+  bool ok;
+  unsigned int i = p.toArrayIndex(&ok);
+  if (ok) {
+    QPtrList<KParts::ReadOnlyPart> frames = m_part->frames();
+    unsigned int len = frames.count();
+    if (i < len)
+      return true;
+  }
 
   // allow shortcuts like 'Image1' instead of document.images.Image1
@@ -696,4 +705,19 @@ Value Window::get(ExecState *exec, const
     return retrieve(kp);
 
+  // allow window[1] or parent[1] etc. (#56983)
+  bool ok;
+  unsigned int i = p.toArrayIndex(&ok);
+  if (ok) {
+    QPtrList<KParts::ReadOnlyPart> frames = m_part->frames();
+    unsigned int len = frames.count();
+    if (i < len) {
+      KParts::ReadOnlyPart* frame = frames.at(i);
+      if (frame && ::qt_cast<KHTMLPart*>(frame)) {
+        KHTMLPart *khtml = static_cast<KHTMLPart*>(frame);
+        return Window::retrieve(khtml);
+      }
+    }
+  }
+
   // allow shortcuts like 'Image1' instead of document.images.Image1
   if (isSafeScript(exec) &&
@@ -1778,5 +1802,5 @@ Value FrameArray::get(ExecState *exec, c
 
   QPtrList<KParts::ReadOnlyPart> frames = part->frames();
-  int len = frames.count();
+  unsigned int len = frames.count();
   if (p == lengthPropertyName)
     return Number(len);
@@ -1792,6 +1816,7 @@ Value FrameArray::get(ExecState *exec, c
   KParts::ReadOnlyPart *frame = part->findFrame(p.qstring());
   if (!frame) {
-    int i = (int)p.toDouble();
-    if (i >= 0 && i < len)
+    bool ok;
+    unsigned int i = p.toArrayIndex(&ok);
+    if (ok && i < len)
       frame = frames.at(i);
   }





-------------------------------------------------------

-- 
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).


More information about the Khtml-devel mailing list