Patch: Parts onload accounting

Koos Vriezen koos.vriezen at xs4all.nl
Fri Feb 21 15:09:17 GMT 2003


Hi,

Check objects also for onload event, see patch. m_bCompleted of
khtml::ChildFrame is set to true for parts other than frames. If a part
want to be accounted for in the onload event, it should emit 'started()'
in openURL. Also attached a patch for kjavaappletviewer to make use of
this.

Comments?

Koos
-------------- next part --------------
Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.817
diff -u -3 -p -r1.817 khtml_part.cpp
--- khtml_part.cpp	18 Feb 2003 03:17:29 -0000	1.817
+++ khtml_part.cpp	21 Feb 2003 14:57:44 -0000
@@ -1734,6 +1734,11 @@ void KHTMLPart::checkCompleted()
       bPendingChildRedirection = true;
   }
 
+  // Any object that hasn't completed yet ?
+  for (it = d->m_objects.begin(); it != d->m_objects.end(); ++it )
+    if ( !(*it).m_bCompleted )
+      return;
+
   // Are we still parsing - or have we done the completed stuff already ?
   if ( d->m_bComplete || (d->m_doc && d->m_doc->parsing()) )
     return;
@@ -1820,6 +1825,10 @@ void KHTMLPart::checkEmitLoadEvent()
     if ( !(*it).m_bCompleted ) // still got a frame running -> too early
       return;
 
+  for (it = d->m_objects.begin(); it != d->m_objects.end(); ++it )
+    if ( !(*it).m_bCompleted ) // still got a object running -> too early
+      return;
+
 #ifndef Q_WS_QWS
   if (d->m_javaContext && !d->m_javaContext->appletsLoaded())
       return;
@@ -3295,12 +3304,12 @@ bool KHTMLPart::processObjectRequest( kh
     child->m_part = part;
     assert( ((void*) child->m_part) != 0);
 
+    connect( part, SIGNAL( started( KIO::Job *) ),
+             this, SLOT( slotChildStarted( KIO::Job *) ) );
+    connect( part, SIGNAL( completed() ),
+             this, SLOT( slotChildCompleted() ) );
     if ( child->m_type != khtml::ChildFrame::Object )
     {
-      connect( part, SIGNAL( started( KIO::Job *) ),
-               this, SLOT( slotChildStarted( KIO::Job *) ) );
-      connect( part, SIGNAL( completed() ),
-               this, SLOT( slotChildCompleted() ) );
       connect( part, SIGNAL( completed(bool) ),
                this, SLOT( slotChildCompleted(bool) ) );
       connect( part, SIGNAL( setStatusBarText( const QString & ) ),
@@ -3373,7 +3382,9 @@ bool KHTMLPart::processObjectRequest( kh
   // point the run object is to find out exactly the mimetype.
   child->m_args.serviceType = mimetype;
 
-  child->m_bCompleted = false;
+  // if not a frame set child as completed
+  child->m_bCompleted = child->m_type == khtml::ChildFrame::Object;
+
   if ( child->m_extension )
     child->m_extension->setURLArgs( child->m_args );
 
@@ -3828,6 +3839,10 @@ khtml::ChildFrame *KHTMLPart::frame( con
     FrameIt it = d->m_frames.begin();
     FrameIt end = d->m_frames.end();
     for (; it != end; ++it )
+      if ( (KParts::ReadOnlyPart *)(*it).m_part == part )
+        return &(*it);
+
+    for (d->m_objects.begin(); it != d->m_objects.end(); ++it )
       if ( (KParts::ReadOnlyPart *)(*it).m_part == part )
         return &(*it);
 
-------------- next part --------------
Index: java/kjavaappletviewer.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletviewer.h,v
retrieving revision 1.1
diff -u -3 -p -r1.1 kjavaappletviewer.h
--- java/kjavaappletviewer.h	3 Feb 2003 17:11:25 -0000	1.1
+++ java/kjavaappletviewer.h	21 Feb 2003 14:58:56 -0000
@@ -75,9 +75,9 @@ public: 
         { return m_browserextension; }
 public slots:
     virtual bool openURL (const KURL & url);
+    void appletLoaded ();
 protected:
     bool openFile();
-    void timerEvent (QTimerEvent *);
 private:
     KJavaAppletWidget * m_view;
     KConfig * m_config;
Index: java/kjavaappletviewer.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletviewer.cpp,v
retrieving revision 1.1
diff -u -3 -p -r1.1 kjavaappletviewer.cpp
--- java/kjavaappletviewer.cpp	3 Feb 2003 17:11:25 -0000	1.1
+++ java/kjavaappletviewer.cpp	21 Feb 2003 14:58:57 -0000
@@ -176,9 +176,11 @@ KJavaAppletViewer::KJavaAppletViewer (QW
                 if (name == "__KHTML__PLUGINBASEURL")
                     baseurl = value;
                 else if (name == "__KHTML__CODEBASE" ||
-                         name.lower()==QString::fromLatin1("java_codebase"))
-                    codebase = value;
-                else if (name == "__KHTML__CLASSID")
+                         name.lower()==QString::fromLatin1("codebase") ||
+                         name.lower()==QString::fromLatin1("java_codebase")) {
+                    if (!value.isEmpty ())
+                        codebase = value;
+                } else if (name == "__KHTML__CLASSID")
                 //else if (name.lower()==QString::fromLatin1("classid"))
                     classid = value;
                 else if (name.lower()==QString::fromLatin1("code") ||
@@ -210,6 +212,7 @@ KJavaAppletViewer::KJavaAppletViewer (QW
     applet->setAppletClass (classname);
     setInstance (KJavaAppletViewerFactory::instance ());
     KParts::Part::setWidget (m_view);
+    connect (applet->getContext(), SIGNAL(appletLoaded()), this, SLOT(appletLoaded()));
 }
 
 KJavaAppletViewer::~KJavaAppletViewer () {
@@ -234,6 +237,7 @@ bool KJavaAppletViewer::openURL (const K
         applet->setSize (m_view->sizeHint());
         m_view->showApplet ();
     }
+    emit started (0L);
     return url.isValid ();
 }
 
@@ -241,7 +245,8 @@ bool KJavaAppletViewer::openFile () {
     return false;
 }
 
-void KJavaAppletViewer::timerEvent (QTimerEvent *) {
+void KJavaAppletViewer::appletLoaded () {
+    emit completed();
 }
 
 KAboutData* KJavaAppletViewer::createAboutData () {


More information about the kfm-devel mailing list