[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:43:34 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 59a0b5b16e2ec42bd8d13e64599f5dba5387077f
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri May 30 01:55:26 2003 +0000

    WebKit:
    	*** Public API change ***
    	This API addition will be used (in some fashion) for Scott's WWDC
    	demo.
    
    	Implemented 'estimatedProgress' method on WebView.  This should
    	eventually replace the broken algorithm on WebBrowser.  Maybe
    	for panther.
    
            Reviewed by Chris.
    
            * WebKit.exp:
            * WebView.subproj/WebBaseResourceHandleDelegate.m:
            (-[WebBaseResourceHandleDelegate connection:didReceiveResponse:]):
            (-[WebBaseResourceHandleDelegate connection:didReceiveData:]):
            (-[WebBaseResourceHandleDelegate connectionDidFinishLoading:]):
            (-[WebBaseResourceHandleDelegate connection:didFailWithError:]):
            (-[WebBaseResourceHandleDelegate cancelWithError:]):
            * WebView.subproj/WebDataSourcePrivate.m:
            (-[WebDataSource _startLoading:]):
            * WebView.subproj/WebFramePrivate.h:
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _isLoadComplete]):
            (-[WebFrame _numPendingOrLoadingRequests:]):
            * WebView.subproj/WebView.h:
            * WebView.subproj/WebView.m:
            (-[WebView estimatedProgress]):
            * WebView.subproj/WebViewPrivate.h:
            * WebView.subproj/WebViewPrivate.m:
            (-[WebViewPrivate dealloc]):
            (-[WebView _isPerformingProgrammaticFocus]):
            (-[WebView _progressStarted]):
            (-[WebView _progressCompleted]):
            (-[WebView _incrementProgressForConnection:data:]):
            (-[WebView _completeProgressForConnection:]):
    
    	Code cleanup.  Moved variable initialization into block that
    	check for non-nil self.
    
            * WebCoreSupport.subproj/WebImageRenderer.m:
            (-[WebImageRenderer initWithMIMEType:]):
            (-[WebImageRenderer initWithData:MIMEType:]):
            (-[WebImageRenderer initWithContentsOfFile:]):
    
    WebCore:
    	Support for the 'estimatedProgress' method on
    	WebView.  Added bridge access to the number of pending or still
    	loading requests (from KHTML's perspective).  This is used to
    	more accurately guess at the total remaining bytes to load.
    
            Reviewed by Chris.
    
            * kwq/KWQLoader.h:
            * kwq/KWQLoader.mm:
            (KWQServeRequest):
            (KWQNumberOfPendingOrLoadingRequests):
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge numPendingOrLoadingRequests]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4452 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 2bef4f8..d1ddfe7 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,20 @@
+2003-05-29  Richard Williamson   <rjw at apple.com>
+
+	Support for the 'estimatedProgress' method on
+	WebView.  Added bridge access to the number of pending or still
+	loading requests (from KHTML's perspective).  This is used to
+	more accurately guess at the total remaining bytes to load.
+
+        Reviewed by Chris.
+
+        * kwq/KWQLoader.h:
+        * kwq/KWQLoader.mm:
+        (KWQServeRequest):
+        (KWQNumberOfPendingOrLoadingRequests):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge numPendingOrLoadingRequests]):
+
 2003-05-29  Ken Kocienda  <kocienda at apple.com>
 
         Reviewed by Maciej
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 2bef4f8..d1ddfe7 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,20 @@
+2003-05-29  Richard Williamson   <rjw at apple.com>
+
+	Support for the 'estimatedProgress' method on
+	WebView.  Added bridge access to the number of pending or still
+	loading requests (from KHTML's perspective).  This is used to
+	more accurately guess at the total remaining bytes to load.
+
+        Reviewed by Chris.
+
+        * kwq/KWQLoader.h:
+        * kwq/KWQLoader.mm:
+        (KWQServeRequest):
+        (KWQNumberOfPendingOrLoadingRequests):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge numPendingOrLoadingRequests]):
+
 2003-05-29  Ken Kocienda  <kocienda at apple.com>
 
         Reviewed by Maciej
diff --git a/WebCore/kwq/KWQLoader.h b/WebCore/kwq/KWQLoader.h
index 008bfdf..a5c16e3 100644
--- a/WebCore/kwq/KWQLoader.h
+++ b/WebCore/kwq/KWQLoader.h
@@ -42,6 +42,7 @@ bool KWQCheckIfReloading(khtml::DocLoader *loader);
 void KWQRetainResponse(void *response);
 void KWQReleaseResponse(void *response);
 void *KWQResponseMIMEType(void *response);
+int KWQNumberOfPendingOrLoadingRequests(khtml::DocLoader *dl);
 
 class KWQLoader
 {
diff --git a/WebCore/kwq/KWQLoader.mm b/WebCore/kwq/KWQLoader.mm
index f477028..1608a5d 100644
--- a/WebCore/kwq/KWQLoader.mm
+++ b/WebCore/kwq/KWQLoader.mm
@@ -32,6 +32,7 @@
 #import "loader.h"
 #import "WebCoreBridge.h"
 
+using khtml::Cache;
 using khtml::CachedObject;
 using khtml::CachedImage;
 using khtml::DocLoader;
@@ -55,6 +56,11 @@ bool KWQServeRequest(Loader *loader, Request *request, TransferJob *job)
     return handle != nil;
 }
 
+int KWQNumberOfPendingOrLoadingRequests(khtml::DocLoader *dl)
+{
+    return Cache::loader()->numRequests(dl);
+}
+
 bool KWQCheckIfReloading(DocLoader *loader)
 {
     return [static_cast<KWQKHTMLPart *>(loader->part())->bridge() isReloading];
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 6d7b9d6..9e5a07f 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -219,6 +219,8 @@ enum FrameBorderStyle {
 - (void)setShouldCreateRenderers:(BOOL)f;
 - (BOOL)shouldCreateRenderers;
 
+- (int)numPendingOrLoadingRequests;
+
 @end
 
 // The WebCoreBridge protocol contains methods for use by the WebCore side of the bridge.
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index d495799..a418ed8 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -51,6 +51,7 @@ using khtml::RenderWidget;
 #import "KWQDOMNode.h"
 #import "KWQFont.h"
 #import "KWQFrame.h"
+#import "KWQLoader.h"
 #import "KWQPageState.h"
 #import "KWQRenderTreeDebug.h"
 #import "KWQView.h"
@@ -942,6 +943,14 @@ static HTMLFormElementImpl *formElementFromDOMElement(id <WebDOMElement>element)
     return _shouldCreateRenderers;
 }
 
-
+- (int)numPendingOrLoadingRequests
+{
+    DocumentImpl *doc = _part->xmlDocImpl();
+    
+    if (doc)
+        return KWQNumberOfPendingOrLoadingRequests (doc->docLoader());
+    return 0;
+}
+    
 
 @end
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 0dc75ae..e570d23 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,46 @@
 2003-05-29  Richard Williamson   <rjw at apple.com>
 
+	Implemented 'estimatedProgress' method on WebView.  This should
+	eventually replace the broken algorithm on WebBrowser.  Maybe
+	for panther.
+
+        Reviewed by Chris.
+
+        * WebKit.exp:
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate connection:didReceiveResponse:]):
+        (-[WebBaseResourceHandleDelegate connection:didReceiveData:]):
+        (-[WebBaseResourceHandleDelegate connectionDidFinishLoading:]):
+        (-[WebBaseResourceHandleDelegate connection:didFailWithError:]):
+        (-[WebBaseResourceHandleDelegate cancelWithError:]):
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSource _startLoading:]):
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _isLoadComplete]):
+        (-[WebFrame _numPendingOrLoadingRequests:]):
+        * WebView.subproj/WebView.h:
+        * WebView.subproj/WebView.m:
+        (-[WebView estimatedProgress]):
+        * WebView.subproj/WebViewPrivate.h:
+        * WebView.subproj/WebViewPrivate.m:
+        (-[WebViewPrivate dealloc]):
+        (-[WebView _isPerformingProgrammaticFocus]):
+        (-[WebView _progressStarted]):
+        (-[WebView _progressCompleted]):
+        (-[WebView _incrementProgressForConnection:data:]):
+        (-[WebView _completeProgressForConnection:]):
+
+	Code cleanup.  Moved variable initialization into block that
+	check for non-nil self.
+
+        * WebCoreSupport.subproj/WebImageRenderer.m:
+        (-[WebImageRenderer initWithMIMEType:]):
+        (-[WebImageRenderer initWithData:MIMEType:]):
+        (-[WebImageRenderer initWithContentsOfFile:]):
+
+2003-05-29  Richard Williamson   <rjw at apple.com>
+
 	Fixed 3272226.  The shared image factory was being released
 	when any renderer had 0 reps!
 
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
index 62d9dae..a44041b 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
@@ -96,9 +96,9 @@ static NSMutableArray *activeImageRenderers;
     self = [super init];
     if (self != nil) {
         MIMEType = [MIME copy];
+        isNull = YES;
+        loadStatus = NSImageRepLoadStatusUnknownType;
     }
-    isNull = YES;
-    loadStatus = NSImageRepLoadStatusUnknownType;
     return self;
 }
 
@@ -115,8 +115,8 @@ static NSMutableArray *activeImageRenderers;
             isNull = NO;
         else
             isNull = YES;
+        loadStatus = NSImageRepLoadStatusUnknownType;
     }
-    loadStatus = NSImageRepLoadStatusUnknownType;
     return self;
 }
 
@@ -125,9 +125,10 @@ static NSMutableArray *activeImageRenderers;
     NSBundle *bundle = [NSBundle bundleForClass:[self class]];
     NSString *imagePath = [bundle pathForResource:filename ofType:@"tiff"];
     self = [super initWithContentsOfFile:imagePath];
-    if (self)
+    if (self){
         isNull = NO;
-    loadStatus = NSImageRepLoadStatusUnknownType;
+        loadStatus = NSImageRepLoadStatusUnknownType;
+    }
     return self;
 }
 
diff --git a/WebKit/WebKit.exp b/WebKit/WebKit.exp
index cf53875..0479724 100644
--- a/WebKit/WebKit.exp
+++ b/WebKit/WebKit.exp
@@ -66,6 +66,9 @@ _WebReportError
 _WebReportFatalError
 _WebURLNamePboardType
 _WebURLPboardType
+_WebViewProgressStartedNotification
+_WebViewProgressEstimateChangedNotification
+_WebViewProgressFinishedNotification
 
 ##
 ## Carbon Support
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
index 704673d..d15504d 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
@@ -281,7 +281,9 @@
     response = r;
 
     [dataSource _addResponse: r];
-    
+
+    [webView _incrementProgressForConnection:con response:r];
+        
     if (implementations.delegateImplementsDidReceiveResponse)
         [resourceLoadDelegate webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource];
     else
@@ -293,6 +295,8 @@
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
 
+    [webView _incrementProgressForConnection:con data:data];
+
     if (implementations.delegateImplementsDidReceiveContentLength)
         [resourceLoadDelegate webView:webView resource:identifier didReceiveContentLength:[data length] fromDataSource:dataSource];
     else
@@ -310,6 +314,8 @@
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
 
+    [webView _completeProgressForConnection:con];
+
     if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
         [resourceLoadDelegate webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource];
     else
@@ -322,7 +328,9 @@
 {
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
-    
+
+    [webView _completeProgressForConnection:con];
+
     [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:result fromDataSource:dataSource];
 
     [self releaseResources];
@@ -346,7 +354,9 @@
     currentWebChallenge = nil;
 
     [connection cancel];
-    
+
+    [webView _completeProgressForConnection:connection];
+
     if (error) {
         [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
     }
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 7528e76..feb3dd3 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -176,6 +176,8 @@
     _private->loadingStartedTime = CFAbsoluteTimeGetCurrent();
     
     [self _setLoading:YES];
+
+    [_private->webView _progressStarted];
     
     [[_private->webView _frameLoadDelegateForwarder] webView:_private->webView
                                      didStartProvisionalLoadForFrame:[self webFrame]];
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 364e44a..4030e71 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -183,4 +183,6 @@ typedef enum {
 - (void)_setShouldCreateRenderers:(BOOL)f;
 - (BOOL)_shouldCreateRenderers;
 
+- (int)_numPendingOrLoadingRequests:(BOOL)recurse;
+
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index dfb5b37..6bb5db5 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -981,6 +981,8 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
                     }
                 }
 
+                [[self webView] _progressCompleted];
+                
                 if ([ds _mainDocumentError]) {
                     [[[self webView] _frameLoadDelegateForwarder] webView:_private->webView
                                                      didFailLoadWithError:[ds _mainDocumentError]
@@ -2188,6 +2190,23 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
     return [_private->bridge shouldCreateRenderers];
 }
 
+- (int)_numPendingOrLoadingRequests:(BOOL)recurse
+{
+    int num;
+
+    if (!recurse)
+        return [[self _bridge] numPendingOrLoadingRequests];
+
+    num = [[self _bridge] numPendingOrLoadingRequests];
+    NSArray *children = [self childFrames];
+    int i, count = [children count];
+    WebFrame *child;
+    for (i = 0; i < count; i++){
+        child = [children objectAtIndex: 0];
+        num += [child _numPendingOrLoadingRequests:recurse];
+    }
+    return num;
+}
 
 @end
 
diff --git a/WebKit/WebView.subproj/WebLoader.m b/WebKit/WebView.subproj/WebLoader.m
index 704673d..d15504d 100644
--- a/WebKit/WebView.subproj/WebLoader.m
+++ b/WebKit/WebView.subproj/WebLoader.m
@@ -281,7 +281,9 @@
     response = r;
 
     [dataSource _addResponse: r];
-    
+
+    [webView _incrementProgressForConnection:con response:r];
+        
     if (implementations.delegateImplementsDidReceiveResponse)
         [resourceLoadDelegate webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource];
     else
@@ -293,6 +295,8 @@
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
 
+    [webView _incrementProgressForConnection:con data:data];
+
     if (implementations.delegateImplementsDidReceiveContentLength)
         [resourceLoadDelegate webView:webView resource:identifier didReceiveContentLength:[data length] fromDataSource:dataSource];
     else
@@ -310,6 +314,8 @@
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
 
+    [webView _completeProgressForConnection:con];
+
     if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
         [resourceLoadDelegate webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource];
     else
@@ -322,7 +328,9 @@
 {
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
-    
+
+    [webView _completeProgressForConnection:con];
+
     [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:result fromDataSource:dataSource];
 
     [self releaseResources];
@@ -346,7 +354,9 @@
     currentWebChallenge = nil;
 
     [connection cancel];
-    
+
+    [webView _completeProgressForConnection:connection];
+
     if (error) {
         [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
     }
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index 4e674b7..4b03d0c 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -30,6 +30,20 @@ extern NSString *WebElementLinkTargetFrameKey;	// NSString of the target of the
 extern NSString *WebElementLinkTitleKey;	// NSString of the title of the anchor
 extern NSString *WebElementLinkLabelKey;	// NSString of the text within the anchor
 
+/*
+ @discussion Notification sent by WebView when the value of estimatedProgress.
+ @constant WebViewProgressStartedNotification Posted from whenever a load begins in the WebView, including
+ a load that is initiated in a subframe.  After receiving this notification zero or more
+ WebViewProgressEstimateChangedNotifications will be sent.  The userInfo will be nil.
+ @constant WebViewProgressEstimateChangedNotification Posted from whenever the value of
+ estimatedProgress changes.  The userInfo will be nil.
+ @constant WebViewProgressFinishedNotification Posted when the load for a WebView has finished.
+ The userInfo will be nil.
+*/
+extern NSString *WebViewProgressStartedNotification;
+extern NSString *WebViewProgressEstimateChangedNotification;
+extern NSString *WebViewProgressFinishedNotification;
+
 /*!
     @class WebView
     WebView manages the interaction between WebFrameViews and WebDataSources.  Modification
@@ -385,6 +399,19 @@ extern NSString *WebElementLinkLabelKey;	// NSString of the text within the anch
 */
 - (NSString *)groupName;
 
+
+/*!
+    @method estimatedProgress
+    @discussion An estimate of the percent complete for a document load.  This
+    value will range from 0 to 1.0 and, once a load completes, will remain at 1.0 
+    until a new load starts, at which point it will be reset to 0.  The value is an
+    estimate based on the total number of bytes expected to be received
+    for a document, including all it's possible subresources.  For more accurate progress
+    indication it is recommended that you implement a WebFrameLoadDelegate and a
+    WebResourceLoadDelegate.
+*/
+- (double)estimatedProgress;
+
 @end
 
 
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index a295e5b..1a095d2 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -52,6 +52,9 @@ NSString *WebElementLinkTargetFrameKey =	@"WebElementTargetFrame";
 NSString *WebElementLinkLabelKey = 		@"WebElementLinkLabel";
 NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
 
+NSString *WebViewProgressStartedNotification = @"WebProgressStartedNotification";
+NSString *WebViewProgressEstimateChangedNotification = @"WebProgressEstimateChangedNotification";
+NSString *WebViewProgressFinishedNotification = @"WebProgressFinishedNotification";
 
 enum { WebViewVersion = 1 };
 
@@ -661,6 +664,10 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     return _private->setName;
 }
 
+- (double)estimatedProgress
+{
+    return _private->progressValue;
+}
 
 @end
 
@@ -774,4 +781,5 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     return YES;
 }
 
+
 @end
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index f130c78..439d9d4 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -67,6 +67,13 @@ typedef struct _WebResourceDelegateImplementationCache {
     int programmaticFocusCount;
     
     WebResourceDelegateImplementationCache resourceLoadDelegateImplementations;
+
+    long long totalPageAndResourceBytesToLoad;
+    long long totalBytesReceived;
+    double progressValue;
+    
+    int numProgressTrackedFrames;
+    NSMutableDictionary *progressItems;
 }
 @end
 
@@ -201,6 +208,13 @@ Could be worth adding to the API.
 - (void)_popPerformingProgrammaticFocus;
 - (BOOL)_isPerformingProgrammaticFocus;
 
+// Methods dealing with the estimated progress completion.
+- (void)_progressStarted;
+- (void)_progressCompleted;
+- (void)_incrementProgressForConnection:(NSURLConnection *)con response:(NSURLResponse *)response;
+- (void)_incrementProgressForConnection:(NSURLConnection *)con data:(NSData *)dataSource;
+- (void)_completeProgressForConnection:(NSURLConnection *)con;
+
 @end
 
 @interface _WebSafeForwarder : NSObject
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index 38c5d49..9948439 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -1,11 +1,12 @@
 /*	
-    WebControllerPrivate.m
+    WebViewPrivate.m
     Copyright (c) 2001, 2002, Apple, Inc. All rights reserved.
 */
 
 #import <WebKit/WebViewPrivate.h>
 
 #import <WebKit/WebBackForwardList.h>
+#import <WebKit/WebBridge.h>
 #import <WebKit/WebControllerSets.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDefaultFrameLoadDelegate.h>
@@ -27,6 +28,7 @@
 
 #import <Foundation/NSURLFileTypeMappings.h>
 #import <Foundation/NSData_NSURLExtras.h>
+#import <Foundation/NSDictionary_NSURLExtras.h>
 #import <Foundation/NSString_NSURLExtras.h>
 #import <Foundation/NSURLConnection.h>
 #import <Foundation/NSURLDownloadPrivate.h>
@@ -37,6 +39,17 @@
 
 static NSMutableSet *schemesWithRepresentationsSet;
 
+ at interface WebProgressItem : NSObject
+{
+ at public
+    long long bytesReceived;
+    long long estimatedLength;
+}
+ at end
+
+ at implementation WebProgressItem
+ at end
+
 @implementation WebViewPrivate
 
 - init 
@@ -70,6 +83,8 @@ static NSMutableSet *schemesWithRepresentationsSet;
     [UIDelegateForwarder release];
     [frameLoadDelegateForwarder release];
     
+    [progressItems release];
+    
     [super dealloc];
 }
 
@@ -619,6 +634,108 @@ static NSMutableSet *schemesWithRepresentationsSet;
     return _private->programmaticFocusCount != 0;
 }
 
+#define UnknownTotalBytes -1
+#define WebProgressItemDefaultEstimatedLength 1024*16
+
+- (void)_progressStarted
+{
+    if (_private->numProgressTrackedFrames == 0){
+        _private->totalPageAndResourceBytesToLoad = 0;
+        _private->totalBytesReceived = 0;
+        _private->progressValue = 0;
+        [[NSNotificationCenter defaultCenter] postNotificationName:WebViewProgressStartedNotification object:self];
+    }
+    _private->numProgressTrackedFrames++;
+}
+
+- (void)_progressCompleted
+{
+    _private->numProgressTrackedFrames--;
+    ASSERT (_private->numProgressTrackedFrames >= 0);
+    if (_private->numProgressTrackedFrames == 0){
+        [_private->progressItems release];
+        _private->progressItems = nil;
+        _private->progressValue = 1;
+        [[NSNotificationCenter defaultCenter] postNotificationName:WebViewProgressFinishedNotification object:self];
+    }
+}
+
+- (void)_incrementProgressForConnection:(NSURLConnection *)con response:(NSURLResponse *)response;
+{
+    if (!con)
+        return;
+
+    WebProgressItem *item = [[WebProgressItem alloc] init];
+
+    if (!item)
+        return;
+
+    long long length = [response expectedContentLength];
+    if (length < 0){
+        length = WebProgressItemDefaultEstimatedLength;
+    }
+    item->estimatedLength = length;
+    _private->totalPageAndResourceBytesToLoad += length;
+    
+    if (!_private->progressItems)
+        _private->progressItems = [[NSMutableDictionary alloc] init];
+        
+    [_private->progressItems _web_setObject:item forUncopiedKey:con];
+    [item release];
+}
+
+- (void)_incrementProgressForConnection:(NSURLConnection *)con data:(NSData *)data
+{
+    if (!con)
+        return;
+
+    WebProgressItem *item = [_private->progressItems objectForKey:con];
+
+    if (!item)
+        return;
+
+    unsigned bytesReceived = [data length];
+    double increment = 0, percentOfRemainingBytes;
+    long long remainingBytes, estimatedBytesForPendingRequests;
+
+    item->bytesReceived += bytesReceived;
+    if (item->bytesReceived > item->estimatedLength){
+        _private->totalPageAndResourceBytesToLoad += ((item->bytesReceived*2) - item->estimatedLength);
+        item->estimatedLength = item->bytesReceived*2;
+    }
+    
+    int numPendingOrLoadingRequests = [[self mainFrame] _numPendingOrLoadingRequests:YES];
+    estimatedBytesForPendingRequests = WebProgressItemDefaultEstimatedLength * numPendingOrLoadingRequests;
+    remainingBytes = ((_private->totalPageAndResourceBytesToLoad + estimatedBytesForPendingRequests) - _private->totalBytesReceived);
+    percentOfRemainingBytes = (double)bytesReceived / (double)remainingBytes;
+    increment = (1.0 - _private->progressValue) * percentOfRemainingBytes;
+    
+    _private->totalBytesReceived += bytesReceived;
+    
+    _private->progressValue += increment;
+
+    if (_private->progressValue < 0.0)
+        _private->progressValue = 0.0;
+
+    if (_private->progressValue > 1.0)
+        _private->progressValue = 1.0;
+
+    [[NSNotificationCenter defaultCenter] postNotificationName:WebViewProgressEstimateChangedNotification object:self];
+}
+
+- (void)_completeProgressForConnection:(NSURLConnection *)con
+{
+    WebProgressItem *item = [_private->progressItems objectForKey:con];
+
+    if (!item)
+        return;
+        
+    // Adjust the total expected bytes to account for any overage/underage.
+    long long delta = item->bytesReceived - item->estimatedLength;
+    _private->totalPageAndResourceBytesToLoad += delta;
+    item->estimatedLength = item->bytesReceived;
+}
+
 @end
 
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list