[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/khtml/ecma
From:       Harri Porten <porten () kde ! org>
Date:       2002-12-24 17:33:18
[Download RAW message or body]

CVS commit by porten: 

proper implementation of Window::hasProperty(). With variable decls
being corrected we don't need the always-return-true hack anymore which
just caused problems (bug #51120)


  M +26 -6     kjs_window.cpp   1.306


--- kdelibs/khtml/ecma/kjs_window.cpp  #1.305:1.306
@@ -349,12 +349,32 @@ void Window::mark()
 }
 
-bool Window::hasProperty(ExecState * /*exec*/, const UString &/*p*/) const
+bool Window::hasProperty(ExecState *exec, const UString &p) const
 {
-  //fprintf( stderr, "Window::hasProperty: always saying true\n" );
+  if (p == "closed")
+    return true;
 
-  // emulate IE behaviour: it doesn't throw exceptions when undeclared
-  // variables are used. Returning true here will lead to get() returning
-  // 'undefined' in those cases.
+  // we don't want any operations on a closed window
+  if (m_part.isNull())
+    return false;
+
+  if (ObjectImp::hasProperty(exec, p))
+    return true;
+
+  if (Lookup::findEntry(&WindowTable, p))
+    return true;
+
+  QString q = p.qstring();
+  if (m_part->findFrame(p.qstring()))
   return true;
+
+  // allow shortcuts like 'Image1' instead of document.images.Image1
+  if (m_part->document().isHTMLDocument()) { // might be XML
+    DOM::HTMLCollection coll = m_part->htmlDocument().all();
+    DOM::HTMLElement element = coll.namedItem(q);
+    if (!element.isNull())
+      return true;
+  }
+
+  return false;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic