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

List:       kde-commits
Subject:    KDE/kdelibs/khtml/misc
From:       Germain Garand <germain () ebooksfrance ! org>
Date:       2008-10-03 2:10:07
Message-ID: 1222999807.655743.27376.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 867196 by ggarand:

give CSS stylesheets a higher priority in the Loader.

External stylesheets block rendering, so they must be loaded as fast
as possible.

Combined with a short tokenizer yeld, the chances to have a document
ready for meaningful layout at the +/-300ms mark are significantly
improved.


 M  +36 -9     loader.cpp  
 M  +3 -2      loader.h  


--- trunk/KDE/kdelibs/khtml/misc/loader.cpp #867195:867196
@@ -60,7 +60,6 @@
 #include <QtGui/QMovie>
 #include <QtGui/QWidget>
 #include <QtCore/QDebug>
-
 #include <kauthorized.h>
 #include <kio/job.h>
 #include <kio/jobuidelegate.h>
@@ -238,7 +237,7 @@
     m_wasBlocked = false;
     m_err = 0;
     // load the file
-    Cache::loader()->load(dl, this, false);
+    Cache::loader()->load(dl, this, false, true /*highPriority*/);
     m_loading = true;
 }
 
@@ -1284,31 +1283,46 @@
 Loader::Loader() : QObject()
 {
     connect(&m_timer, SIGNAL(timeout()), this, SLOT( servePendingRequests() ) );
+    m_highPriorityRequestPending = 0;
 }
 
 Loader::~Loader()
 {
+    delete m_highPriorityRequestPending;
     qDeleteAll(m_requestsPending);
     qDeleteAll(m_requestsLoading);
 }
 
-void Loader::load(DocLoader* dl, CachedObject *object, bool incremental)
+void Loader::load(DocLoader* dl, CachedObject *object, bool incremental, bool \
highPriority)  {
     Request *req = new Request(dl, object, incremental);
-    m_requestsPending.append(req);
+    if (highPriority && !m_highPriorityRequestPending) {
+        m_highPriorityRequestPending = req;
+    } else {
+        if (highPriority) {
+            m_requestsPending.prepend(req);
+        } else {
+            m_requestsPending.append(req);
+        }
+        highPriority = false;
+    }
 
     emit requestStarted( req->m_docLoader, req->object );
 
-    m_timer.setSingleShot(true);
-    m_timer.start(0);
+    if (highPriority) {
+        servePendingRequests();
+    } else {
+        m_timer.setSingleShot(true);
+        m_timer.start(0);
+    }
 }
 
 void Loader::servePendingRequests()
 {
-    while ( (m_requestsPending.count() != 0) && (m_requestsLoading.count() < \
MAX_JOB_COUNT) ) +    while ( (m_highPriorityRequestPending != 0 || \
m_requestsPending.count() != 0) && (m_requestsLoading.count() < MAX_JOB_COUNT) )  {
         // get the first pending request
-        Request *req = m_requestsPending.takeFirst();
+        Request *req = m_highPriorityRequestPending ? m_highPriorityRequestPending : \
m_requestsPending.takeFirst();  
 #ifdef LOADER_DEBUG
   kDebug( 6060 ) << "starting Loader url=" << req->object->url().string();
@@ -1342,6 +1356,10 @@
             KIO::Scheduler::scheduleJob( job );
 
         m_requestsLoading.insertMulti(job, req);
+        if (m_highPriorityRequestPending) {
+            m_highPriorityRequestPending = 0;
+            break;
+        }
     }
 }
 
@@ -1422,7 +1440,7 @@
 
   delete r;
 
-  if ( (m_requestsPending.count() != 0) && (m_requestsLoading.count() < \
MAX_JOB_COUNT / 2) ) { +  if ( (m_highPriorityRequestPending != 0 || \
m_requestsPending.count() != 0) && (m_requestsLoading.count() < MAX_JOB_COUNT / 2) ) \
{  m_timer.setSingleShot(true);
       m_timer.start(0);
   }
@@ -1448,6 +1466,8 @@
 int Loader::numRequests( DocLoader* dl ) const
 {
     int res = 0;
+    if (m_highPriorityRequestPending && m_highPriorityRequestPending->m_docLoader == \
dl) +        res++;
 
     foreach( Request* req, m_requestsPending )
         if ( req->m_docLoader == dl )
@@ -1462,6 +1482,13 @@
 
 void Loader::cancelRequests( DocLoader* dl )
 {
+    if (m_highPriorityRequestPending && m_highPriorityRequestPending->m_docLoader == \
dl) { +        CDEBUG << "canceling high priority pending request for " << \
m_highPriorityRequestPending->object->url().string() << endl; +        \
Cache::removeCacheEntry( m_highPriorityRequestPending->object ); +        delete \
m_highPriorityRequestPending; +        m_highPriorityRequestPending = 0;
+    }
+
     QMutableLinkedListIterator<Request*> pIt( m_requestsPending );
     while ( pIt.hasNext() ) {
         Request* cur = pIt.next();
--- trunk/KDE/kdelibs/khtml/misc/loader.h #867195:867196
@@ -42,7 +42,6 @@
 #include <QtCore/QTextCodec>
 #include <QtCore/QTimer>
 #include <QtCore/QSet>
-
 #include <QLinkedList>
 
 #include <kurl.h>
@@ -391,6 +390,7 @@
 	QByteArray m_sound;
     };
 
+
     /**
      * @internal
      *
@@ -473,7 +473,7 @@
 	Loader();
 	~Loader();
 
-	void load(DocLoader* dl, CachedObject *object, bool incremental = true);
+	void load(DocLoader* dl, CachedObject *object, bool incremental = true, bool \
highPriority = false);  
         int numRequests( DocLoader* dl ) const;
         void cancelRequests( DocLoader* dl );
@@ -494,6 +494,7 @@
 
     protected:
 	QLinkedList<Request*> m_requestsPending;
+	Request* m_highPriorityRequestPending;
 	QHash<KIO::Job*,Request*> m_requestsLoading;
 #ifdef HAVE_LIBJPEG
         // TODO KJPEGFormatType m_jpegloader;


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

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