[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/khtml
From: Maks Orlovich <maksim () kde ! org>
Date: 2010-06-19 18:53:35
Message-ID: 20100619190132.5315AAC8D8 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1140093 by orlovich:
Factor out the duplicated code between checkEmitLoadEvent and checkCompleted.
M +45 -51 khtml_part.cpp
M +6 -0 khtmlpart_p.h
--- trunk/KDE/kdelibs/khtml/khtml_part.cpp #1140092:1140093
@@ -2320,61 +2320,74 @@
setUserStyleSheet( KUrl( settings()->userStyleSheet() ) );
}
-void KHTMLPart::checkCompleted()
+bool KHTMLPartPrivate::fullyLoaded(bool* pendingRedirections) const
{
-// kDebug( 6050 ) << this;
-// kDebug( 6050 ) << " parsing: " << (d->m_doc && d->m_doc->parsing());
-// kDebug( 6050 ) << " complete: " << d->m_bComplete;
+ *pendingRedirections = false;
- // restore the cursor position
- if (d->m_doc && !d->m_doc->parsing() && !d->m_focusNodeRestored)
- {
- if (d->m_focusNodeNumber >= 0)
- d->m_doc->setFocusNode(d->m_doc->nodeWithAbsIndex(d->m_focusNodeNumber));
-
- d->m_focusNodeRestored = true;
- }
-
- bool bPendingChildRedirection = false;
// Any frame that hasn't completed yet ?
- ConstFrameIt it = d->m_frames.constBegin();
- const ConstFrameIt end = d->m_frames.constEnd();
+ ConstFrameIt it = m_frames.constBegin();
+ const ConstFrameIt end = m_frames.constEnd();
for (; it != end; ++it ) {
if ( !(*it)->m_bCompleted )
{
//kDebug( 6050 ) << this << " is waiting for " << (*it)->m_part;
- return;
+ return false;
}
// Check for frames with pending redirections
if ( (*it)->m_bPendingRedirection )
- bPendingChildRedirection = true;
+ *pendingRedirections = true;
}
// Any object that hasn't completed yet ?
{
- ConstFrameIt oi = d->m_objects.constBegin();
- const ConstFrameIt oiEnd = d->m_objects.constEnd();
+ ConstFrameIt oi = m_objects.constBegin();
+ const ConstFrameIt oiEnd = m_objects.constEnd();
for (; oi != oiEnd; ++oi )
if ( !(*oi)->m_bCompleted )
- return;
+ return false;
}
- // Are we still parsing - or have we done the completed stuff already ?
- if ( d->m_bComplete || (d->m_doc && d->m_doc->parsing()) )
- return;
+ // Are we still parsing
+ if ( m_doc && m_doc->parsing() )
+ return false;
// Still waiting for images/scripts from the loader ?
int requests = 0;
- if ( d->m_doc && d->m_doc->docLoader() )
- requests = khtml::Cache::loader()->numRequests( d->m_doc->docLoader() );
+ if ( m_doc && m_doc->docLoader() )
+ requests = khtml::Cache::loader()->numRequests( m_doc->docLoader() );
if ( requests > 0 )
{
//kDebug(6050) << "still waiting for images/scripts from the loader - requests:" << requests;
- return;
+ return false;
}
+ return true;
+}
+
+void KHTMLPart::checkCompleted()
+{
+// kDebug( 6050 ) << this;
+// kDebug( 6050 ) << " parsing: " << (d->m_doc && d->m_doc->parsing());
+// kDebug( 6050 ) << " complete: " << d->m_bComplete;
+
+ // restore the cursor position
+ if (d->m_doc && !d->m_doc->parsing() && !d->m_focusNodeRestored)
+ {
+ if (d->m_focusNodeNumber >= 0)
+ d->m_doc->setFocusNode(d->m_doc->nodeWithAbsIndex(d->m_focusNodeNumber));
+
+ d->m_focusNodeRestored = true;
+ }
+
+ bool fullyLoaded, pendingChildRedirections;
+ fullyLoaded = d->fullyLoaded(&pendingChildRedirections);
+
+ // Are we still loading, or already have done the relevant work?
+ if (!fullyLoaded || d->m_bComplete)
+ return;
+
// OK, completed.
// Now do what should be done when we are really completed.
d->m_bComplete = true;
@@ -2410,7 +2423,7 @@
pendingAction = true;
}
- else if ( bPendingChildRedirection )
+ else if ( pendingChildRedirections )
{
pendingAction = true;
}
@@ -2445,31 +2458,12 @@
void KHTMLPart::checkEmitLoadEvent()
{
- if ( d->m_bLoadEventEmitted || !d->m_doc || d->m_doc->parsing() ) return;
+ bool fullyLoaded, pendingChildRedirections;
+ fullyLoaded = d->fullyLoaded(&pendingChildRedirections);
- ConstFrameIt it = d->m_frames.constBegin();
- const ConstFrameIt end = d->m_frames.constEnd();
- for (; it != end; ++it )
- if ( !(*it)->m_bCompleted ) // still got a frame running -> too early
- return;
+ // ### might want to wait on pendingChildRedirections here, too
+ if ( d->m_bLoadEventEmitted || !d->m_doc || !fullyLoaded ) return;
- ConstFrameIt oi = d->m_objects.constBegin();
- const ConstFrameIt oiEnd = d->m_objects.constEnd();
-
- for (; oi != oiEnd; ++oi )
- if ( !(*oi)->m_bCompleted ) // still got a object running -> too early
- return;
-
- // Still waiting for images/scripts from the loader ?
- // (onload must happen afterwards, #45607)
- // ## This makes this method very similar to checkCompleted. A brave soul should try merging them.
- int requests = 0;
- if ( d->m_doc && d->m_doc->docLoader() )
- requests = khtml::Cache::loader()->numRequests( d->m_doc->docLoader() );
-
- if ( requests > 0 )
- return;
-
d->m_bLoadEventEmitted = true;
if (d->m_doc)
d->m_doc->close();
--- trunk/KDE/kdelibs/khtml/khtmlpart_p.h #1140092:1140093
@@ -504,6 +504,12 @@
}
void propagateInitialDomainTo(KHTMLPart* kid);
+
+ // Check whether the frame is fully loaded.
+ // The return value doesn't consider any pending redirections.
+ // If the return value is true, however, pendingRedirections will
+ // report if there are any
+ bool fullyLoaded(bool* pendingRedirections) const;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic