[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:33:40 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 544de6c59247c20684b2a359239c82173dc489ee
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Apr 3 00:47:51 2003 +0000

    WebKit:
            Added new API on WebFrame, loadData: and loadString:
    
            Reviewed by Maciej.
    
            Fixed loading of cocoa plugins.
    
            Reviewed by Chris.
    
            * History.subproj/WebBackForwardList.m:
            (-[WebBackForwardList _entries]):
            * Plugins.subproj/WebBasePluginPackage.h:
            * Plugins.subproj/WebBasePluginPackage.m:
            (-[WebBasePluginPackage bundle]):
            * Plugins.subproj/WebPluginDatabase.h:
            * Plugins.subproj/WebPluginDatabase.m:
            (-[WebPluginDatabase init]):
            (-[WebPluginDatabase loadPluginIfNeededForMIMEType:]):
            (-[WebPluginDatabase dealloc]):
            * WebKit.pbproj/project.pbxproj:
            * WebView.subproj/WebBaseResourceHandleDelegate.m:
            (-[WebBaseResourceHandleDelegate connection:willSendRequest:redirectResponse:]):
            (-[WebBaseResourceHandleDelegate connection:didReceiveResponse:]):
            * WebView.subproj/WebDataProtocol.h: Added.
            * WebView.subproj/WebDataProtocol.m: Added.
            (-[WebDataRequestParameters copyWithZone:]):
            (-[WebDataRequestParameters mutableCopyWithZone:]):
            (-[WebDataRequestParameters dealloc]):
            (+[NSURLRequest _webDataRequestURLForData:]):
            (-[NSURLRequest _webDataRequestParameters]):
            (-[NSURLRequest _webDataRequestData]):
            (-[NSURLRequest _webDataRequestSetData:]):
            (-[NSURLRequest _webDataRequestEncoding]):
            (-[NSURLRequest _webDataRequestSetEncoding:]):
            (-[NSURLRequest _webDataRequestBaseURL]):
            (-[NSURLRequest _webDataRequestSetBaseURL:]):
            (-[NSURLRequest _webDataRequestExternalRequest]):
            (+[WebDataProtocol load]):
            (+[WebDataProtocol doesURLHaveInternalDataScheme:]):
            (+[WebDataProtocol canHandleURL:]):
            (+[WebDataProtocol canonicalURLForURL:]):
            (-[WebDataProtocol startLoadingWithCacheObject:]):
            (-[WebDataProtocol stopLoading]):
            * WebView.subproj/WebDataSource.m:
            (-[WebDataSource initialRequest]):
            (-[WebDataSource request]):
            * WebView.subproj/WebDataSourcePrivate.m:
            (-[WebDataSource _commitIfReady:]):
            * WebView.subproj/WebFrame.h:
            * WebView.subproj/WebFrame.m:
            (-[WebFrame loadRequest:]):
            (-[WebFrame loadString:baseURL:]):
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _addBackForwardItemClippedAtTarget:]):
            (-[WebFrame _transitionToCommitted:]):
            * WebView.subproj/WebFrameViewPrivate.m:
            (-[WebFrameView _makeDocumentViewForDataSource:]):
            * WebView.subproj/WebView.m:
            (+[WebView canShowMIMEType:]):
    
    WebBrowser:
            Change SnippetEditor to use new loadString: API.
    
            Reviewed by Maciej.
    
            * ChangeLog:
            * Debug/SnippetController.m:
            (-[SnippetController load]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4006 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 1399899..6668f0b 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,64 @@
+2003-04-02  Richard Williamson  <rjw at apple.com>
+
+        Added new API on WebFrame, loadData: and loadString:
+        
+        Reviewed by Maciej.
+
+        Fixed loading of cocoa plugins.
+        
+        Reviewed by Chris.
+        
+        * History.subproj/WebBackForwardList.m:
+        (-[WebBackForwardList _entries]):
+        * Plugins.subproj/WebBasePluginPackage.h:
+        * Plugins.subproj/WebBasePluginPackage.m:
+        (-[WebBasePluginPackage bundle]):
+        * Plugins.subproj/WebPluginDatabase.h:
+        * Plugins.subproj/WebPluginDatabase.m:
+        (-[WebPluginDatabase init]):
+        (-[WebPluginDatabase loadPluginIfNeededForMIMEType:]):
+        (-[WebPluginDatabase dealloc]):
+        * WebKit.pbproj/project.pbxproj:
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate connection:willSendRequest:redirectResponse:]):
+        (-[WebBaseResourceHandleDelegate connection:didReceiveResponse:]):
+        * WebView.subproj/WebDataProtocol.h: Added.
+        * WebView.subproj/WebDataProtocol.m: Added.
+        (-[WebDataRequestParameters copyWithZone:]):
+        (-[WebDataRequestParameters mutableCopyWithZone:]):
+        (-[WebDataRequestParameters dealloc]):
+        (+[NSURLRequest _webDataRequestURLForData:]):
+        (-[NSURLRequest _webDataRequestParameters]):
+        (-[NSURLRequest _webDataRequestData]):
+        (-[NSURLRequest _webDataRequestSetData:]):
+        (-[NSURLRequest _webDataRequestEncoding]):
+        (-[NSURLRequest _webDataRequestSetEncoding:]):
+        (-[NSURLRequest _webDataRequestBaseURL]):
+        (-[NSURLRequest _webDataRequestSetBaseURL:]):
+        (-[NSURLRequest _webDataRequestExternalRequest]):
+        (+[WebDataProtocol load]):
+        (+[WebDataProtocol doesURLHaveInternalDataScheme:]):
+        (+[WebDataProtocol canHandleURL:]):
+        (+[WebDataProtocol canonicalURLForURL:]):
+        (-[WebDataProtocol startLoadingWithCacheObject:]):
+        (-[WebDataProtocol stopLoading]):
+        * WebView.subproj/WebDataSource.m:
+        (-[WebDataSource initialRequest]):
+        (-[WebDataSource request]):
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSource _commitIfReady:]):
+        * WebView.subproj/WebFrame.h:
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame loadRequest:]):
+        (-[WebFrame loadString:baseURL:]):
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _addBackForwardItemClippedAtTarget:]):
+        (-[WebFrame _transitionToCommitted:]):
+        * WebView.subproj/WebFrameViewPrivate.m:
+        (-[WebFrameView _makeDocumentViewForDataSource:]):
+        * WebView.subproj/WebView.m:
+        (+[WebView canShowMIMEType:]):
+
 2003-04-02  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Ken.
diff --git a/WebKit/History.subproj/WebBackForwardList.m b/WebKit/History.subproj/WebBackForwardList.m
index 1f4b6cd..2356761 100644
--- a/WebKit/History.subproj/WebBackForwardList.m
+++ b/WebKit/History.subproj/WebBackForwardList.m
@@ -294,4 +294,9 @@ static BOOL loggedPageCacheSize = NO;
     return [_private->entries objectAtIndex:index + _private->current];
 }
 
+- (NSMutableArray *)_entries
+{
+    return _private->entries;
+}
+
 @end
diff --git a/WebKit/Plugins.subproj/WebBasePluginPackage.h b/WebKit/Plugins.subproj/WebBasePluginPackage.h
index 40558a0..d1b4259 100644
--- a/WebKit/Plugins.subproj/WebBasePluginPackage.h
+++ b/WebKit/Plugins.subproj/WebBasePluginPackage.h
@@ -45,6 +45,7 @@
 - (NSString *)path;
 - (NSString *)filename;
 - (NSString *)pluginDescription;
+- (NSBundle *)bundle;
 
 - (NSEnumerator *)extensionEnumerator;
 - (NSEnumerator *)MIMETypeEnumerator;
diff --git a/WebKit/Plugins.subproj/WebBasePluginPackage.m b/WebKit/Plugins.subproj/WebBasePluginPackage.m
index 895ef12..0ae4123 100644
--- a/WebKit/Plugins.subproj/WebBasePluginPackage.m
+++ b/WebKit/Plugins.subproj/WebBasePluginPackage.m
@@ -200,6 +200,11 @@
     return [MIMEToExtensions objectForKey:MIMEType];
 }
 
+- (NSBundle *)bundle
+{
+    return bundle;
+}
+
 - (void)setName:(NSString *)theName
 {
     [name release];
diff --git a/WebKit/Plugins.subproj/WebPluginDatabase.h b/WebKit/Plugins.subproj/WebPluginDatabase.h
index 0fb0e1b..30dc5f8 100644
--- a/WebKit/Plugins.subproj/WebPluginDatabase.h
+++ b/WebKit/Plugins.subproj/WebPluginDatabase.h
@@ -10,6 +10,7 @@
 @interface WebPluginDatabase : NSObject
 {
     NSArray *plugins;
+    NSMutableArray *pendingPluginLoads;
 }
 
 + (WebPluginDatabase *)installedPlugins;
@@ -21,4 +22,6 @@
 
 - (NSArray *)plugins;
 
+- (void)loadPluginIfNeededForMIMEType:(NSString *)MIMEType;
+
 @end
diff --git a/WebKit/Plugins.subproj/WebPluginDatabase.m b/WebKit/Plugins.subproj/WebPluginDatabase.m
index af42439..e58f7d1 100644
--- a/WebKit/Plugins.subproj/WebPluginDatabase.m
+++ b/WebKit/Plugins.subproj/WebPluginDatabase.m
@@ -100,21 +100,6 @@ static WebPluginDatabase *database = nil;
     return plugins;
 }
 
-- (NSArray *)MIMETypes
-{
-    NSMutableSet *MIMETypes;
-    WebBasePluginPackage *plugin;
-    uint i;
-        
-    MIMETypes = [NSMutableSet set];
-    for(i=0; i<[plugins count]; i++){
-        plugin = [plugins objectAtIndex:i];
-        [MIMETypes addObjectsFromArray:[[plugin MIMETypeEnumerator] allObjects]];
-    }
-    return [MIMETypes allObjects];
-}
-
-
 static NSArray *pluginLocations(void)
 {
     // Plug-ins are found in order of precedence.
@@ -146,7 +131,7 @@ static NSArray *pluginLocations(void)
 
     NSArray *files;
     NSString *file;
-    uint i, n;
+    uint i, j, n;
     
     for (i = 0; i < [pluginDirectories count]; i++) {
         files = [fileManager directoryContentsAtPath:[pluginDirectories objectAtIndex:i]];
@@ -174,25 +159,59 @@ static NSArray *pluginLocations(void)
 
     // Register plug-in WebDocumentViews and WebDocumentRepresentations
     NSArray *viewTypes = [[WebFrameView _viewTypes] allKeys];
-    NSArray *mimes = [self MIMETypes];
+    NSArray *mimes;
     NSString *mime;
+    WebBasePluginPackage *plugin;
+    uint pluginCount, mimeCount;
     
-    for (i = 0; i < [mimes count]; i++) {
-        mime = [mimes objectAtIndex:i];
-        
-        // Don't override previously registered types.
-        if(![viewTypes containsObject:mime]){
-            // FIXME: This won't work for the new plug-ins.
-            [WebFrame registerViewClass:[WebNetscapePluginDocumentView class] representationClass:[WebNetscapePluginRepresentation class] forMIMEType:mime];
+    pluginCount = [plugins count];
+    for (i = 0; i < pluginCount; i++) {
+        plugin = [plugins objectAtIndex:i];
+        mimes = [[plugin MIMETypeEnumerator] allObjects];
+        if ([plugin isKindOfClass:[WebNetscapePluginPackage class]]){
+            mimeCount = [mimes count];
+            for (j = 0; j < mimeCount; j++){
+                mime = [mimes objectAtIndex:j];
+                
+                // Don't override previously registered types.
+                if(![viewTypes containsObject:mime]){
+                    // Cocoa plugins must register themselves.
+                    [WebFrame registerViewClass:[WebNetscapePluginDocumentView class] representationClass:[WebNetscapePluginRepresentation class] forMIMEType:mime];
+                }
+            }
+        }
+        else {
+            if (!pendingPluginLoads)
+                pendingPluginLoads = [[NSMutableArray alloc] init];
+            [pendingPluginLoads addObject: plugin];
         }
     }
 
     return self;
 }
 
+- (void)loadPluginIfNeededForMIMEType: (NSString *)MIMEType
+{
+    NSArray *mimes;
+    WebBasePluginPackage *plugin;
+    int i, pluginCount;
+    
+    pluginCount = [pendingPluginLoads count];
+    for (i = pluginCount-1; i >= 0; i--){
+        plugin = [pendingPluginLoads objectAtIndex:i];
+        mimes = [[plugin MIMETypeEnumerator] allObjects];
+        if ([mimes containsObject: MIMEType]){
+            [[plugin bundle] load];
+            [pendingPluginLoads removeObject: plugin];
+            continue;
+        }
+    }
+}
+
 - (void)dealloc
 {
     [plugins release];
+    [pendingPluginLoads release];
     [super dealloc];
 }
 
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 5f641b0..fec476a 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -306,6 +306,7 @@
 				51443F9D0429392B00CA2D3A,
 				51443F9F0429392B00CA2D3A,
 				5110F7530432AC0800CA2D3A,
+				70ECD6CE043B727400A80181,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -424,6 +425,7 @@
 				51A8B5800428353A00CA2D3A,
 				51443F9E0429392B00CA2D3A,
 				5110F7540432AC0800CA2D3A,
+				70ECD6CF043B727400A80181,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1716,6 +1718,32 @@
 			settings = {
 			};
 		};
+		70ECD6CC043B727400A80181 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			name = WebDataProtocol.h;
+			path = WebView.subproj/WebDataProtocol.h;
+			refType = 2;
+		};
+		70ECD6CD043B727400A80181 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			name = WebDataProtocol.m;
+			path = WebView.subproj/WebDataProtocol.m;
+			refType = 2;
+		};
+		70ECD6CE043B727400A80181 = {
+			fileRef = 70ECD6CC043B727400A80181;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		70ECD6CF043B727400A80181 = {
+			fileRef = 70ECD6CD043B727400A80181;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 //700
 //701
 //702
@@ -2471,6 +2499,8 @@
 				5152FAD5033FC43400CA2ACD,
 				6523FACF032DA06B005EFCFF,
 				6523FAD0032DA06B005EFCFF,
+				70ECD6CC043B727400A80181,
+				70ECD6CD043B727400A80181,
 				39446070020F50ED0ECA1767,
 				39446071020F50ED0ECA1767,
 				39446072020F50ED0ECA1767,
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
index af6bcef..cf61631 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
@@ -13,7 +13,9 @@
 #import <WebFoundation/NSURLRequest.h>
 #import <WebFoundation/NSURLRequestPrivate.h>
 #import <WebFoundation/NSURLResponse.h>
+#import <WebFoundation/NSURLResponsePrivate.h>
 
+#import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDefaultResourceLoadDelegate.h>
 #import <WebKit/WebKitErrors.h>
@@ -127,25 +129,43 @@
 {
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
-    
     NSMutableURLRequest *mutableRequest = [newRequest mutableCopy];
+    NSURLRequest *clientRequest, *updatedRequest;
+    BOOL haveDataSchemeRequest = NO;
+    
     [mutableRequest HTTPSetUserAgent:[controller userAgentForURL:[newRequest URL]]];
     newRequest = [mutableRequest autorelease];
     
+    clientRequest = [newRequest _webDataRequestExternalRequest];
+    if (!clientRequest)
+        clientRequest = newRequest;
+    else
+        haveDataSchemeRequest = YES;
     
     if (identifier == nil) {
         // The identifier is released after the last callback, rather than in dealloc
         // to avoid potential cycles.
         if (implementations.delegateImplementsIdentifierForRequest)
-            identifier = [[resourceLoadDelegate webView: controller identifierForInitialRequest:newRequest fromDataSource:dataSource] retain];
+            identifier = [[resourceLoadDelegate webView: controller identifierForInitialRequest:clientRequest fromDataSource:dataSource] retain];
         else
-            identifier = [[[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller identifierForInitialRequest:newRequest fromDataSource:dataSource] retain];
+            identifier = [[[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller identifierForInitialRequest:clientRequest fromDataSource:dataSource] retain];
     }
 
+    // If we have a special "applewebdata" scheme URL we send a fake request to the delegate.
     if (implementations.delegateImplementsWillSendRequest)
-        newRequest = [resourceLoadDelegate webView:controller resource:identifier willSendRequest:newRequest redirectResponse:redirectResponse fromDataSource:dataSource];
+        updatedRequest = [resourceLoadDelegate webView:controller resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource];
     else
-        newRequest = [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller resource:identifier willSendRequest:newRequest redirectResponse:redirectResponse fromDataSource:dataSource];
+        updatedRequest = [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource];
+        
+    if (!haveDataSchemeRequest)
+        newRequest = updatedRequest;
+    else {
+        // If the delegate modified the request use that instead of
+        // our applewebdata request, otherwise use the original
+        // applewebdata request.
+        if (![updatedRequest isEqual:clientRequest])
+            newRequest = updatedRequest;
+    }
 
     // Store a copy of the request.
     [request autorelease];
@@ -175,6 +195,16 @@
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
 
+    // If the URL is one of our whacky applewebdata URLs that
+    // fake up a substitute URL to present to the delegate.
+    if([WebDataProtocol doesURLHaveInternalDataScheme: [r URL]] != nil){
+        NSURL *baseURL = [request _webDataRequestBaseURL];
+        if (baseURL)
+            [r setURL: baseURL];
+        else
+            [r setURL: [NSURL URLWithString: @"about:blank"]];
+    }
+
     [r retain];
     [response release];
     response = r;
diff --git a/WebKit/WebView.subproj/WebDataProtocol.h b/WebKit/WebView.subproj/WebDataProtocol.h
new file mode 100644
index 0000000..c42495c
--- /dev/null
+++ b/WebKit/WebView.subproj/WebDataProtocol.h
@@ -0,0 +1,29 @@
+/*
+    WebDataProtocol.h
+    Copyright 2003, Apple, Inc. All rights reserved.
+
+    Private header file.
+*/
+
+#import <Foundation/Foundation.h>
+
+#import <WebFoundation/NSURLRequest.h>
+#import <WebFoundation/WebProtocol.h>
+
+
+ at interface WebDataProtocol : WebProtocol
+{
+}
++ (BOOL)doesURLHaveInternalDataScheme: (NSURL *)URL;
+ at end
+
+ at interface NSURLRequest (WebDataRequest)
++ (NSURL *)_webDataRequestURLForData: (NSData *)data;
+- (NSData *)_webDataRequestData;
+- (void)_webDataRequestSetData:(NSData *)data;
+- (NSString *)_webDataRequestEncoding;
+- (void)_webDataRequestSetEncoding:(NSString *)encoding;
+- (NSURL *)_webDataRequestBaseURL;
+- (void)_webDataRequestSetBaseURL:(NSURL *)baseURL;
+- (NSURLRequest *)_webDataRequestExternalRequest;
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebDataProtocol.m b/WebKit/WebView.subproj/WebDataProtocol.m
new file mode 100644
index 0000000..9e1db9d
--- /dev/null
+++ b/WebKit/WebView.subproj/WebDataProtocol.m
@@ -0,0 +1,186 @@
+/*
+    WebDataProtocol.m
+    Copyright 2003, Apple, Inc. All rights reserved.
+*/
+#import <WebKit/WebDataProtocol.h>
+
+#import <WebFoundation/NSURLResponse.h>
+#import <WebFoundation/NSURLResponsePrivate.h>
+#import <WebFoundation/WebError.h>
+#import <WebFoundation/WebProtocolClient.h>
+
+NSString *WebDataProtocolScheme = @"applewebdata";
+
+ at interface WebDataRequestParameters : NSObject
+{
+ at public
+    NSData *data;
+    NSString *encoding;
+    NSURL *baseURL;
+}
+ at end
+
+ at implementation WebDataRequestParameters
+
+-(id)copyWithZone:(NSZone *)zone
+{
+    WebDataRequestParameters *newInstance = [[WebDataRequestParameters allocWithZone:zone] init];
+    newInstance->data = [data copyWithZone:zone];
+    newInstance->encoding = [encoding copyWithZone:zone];
+    newInstance->baseURL = [baseURL copyWithZone:zone];
+    return newInstance;
+}
+
+-(id)mutableCopyWithZone:(NSZone *)zone
+{
+    WebDataRequestParameters *newInstance = [[WebDataRequestParameters allocWithZone:zone] init];
+    newInstance->data = [data copyWithZone:zone];
+    newInstance->encoding = [encoding copyWithZone:zone];
+    newInstance->baseURL = [baseURL copyWithZone:zone];
+    return newInstance;
+}
+
+- (void)dealloc
+{
+    [data release];
+    [encoding release];
+    [baseURL release];
+    [super dealloc];
+}
+
+ at end
+
+ at implementation NSURLRequest (WebDataRequest)
+
++ (NSURL *)_webDataRequestURLForData: (NSData *)data
+{
+    static unsigned int counter = 1;
+    
+    // The URL we generate is meaningless.  The only interesting properties of the URL
+    // are it's scheme and that they be unique for the lifespan of the application.
+    NSURL *fakeURL = [NSURL URLWithString: [NSString stringWithFormat: @"%@://%p", WebDataProtocolScheme, counter++, 0]];
+    return fakeURL;
+}
+
+- (WebDataRequestParameters *)_webDataRequestParameters
+{
+    Class theClass = [WebDataRequestParameters class];
+    return [WebProtocol partOfRequest:self withClass:theClass createIfDoesNotExist:YES];
+}
+
+- (NSData *)_webDataRequestData
+{
+    WebDataRequestParameters *parameters = [self _webDataRequestParameters];
+    return parameters->data;
+}
+
+- (void)_webDataRequestSetData: (NSData *)data
+{
+    WebDataRequestParameters *parameters = [self _webDataRequestParameters];
+    [parameters->data release];
+    parameters->data = [data retain];
+}
+
+- (NSString *)_webDataRequestEncoding
+{
+    WebDataRequestParameters *parameters = [self _webDataRequestParameters];
+    return parameters->encoding;
+}
+
+- (void)_webDataRequestSetEncoding:(NSString *)encoding
+{
+    WebDataRequestParameters *parameters = [self _webDataRequestParameters];
+    [parameters->encoding release];
+    parameters->encoding = [encoding retain];
+}
+
+- (NSURL *)_webDataRequestBaseURL
+{
+    WebDataRequestParameters *parameters = [self _webDataRequestParameters];
+    return parameters->baseURL;
+}
+
+- (void)_webDataRequestSetBaseURL:(NSURL *)baseURL
+{
+    WebDataRequestParameters *parameters = [self _webDataRequestParameters];
+    [parameters->baseURL release];
+    parameters->baseURL = [baseURL retain];
+}
+
+- (NSURLRequest *)_webDataRequestExternalRequest
+{
+    WebDataRequestParameters *parameters = [WebProtocol partOfRequest:self withClass:[WebDataRequestParameters class] createIfDoesNotExist:NO];
+    NSMutableURLRequest *newRequest = nil;
+    
+    if (parameters){
+        newRequest = [[self mutableCopyWithZone: [self zone]] autorelease];
+        NSURL *baseURL = [self _webDataRequestBaseURL];
+        if (baseURL)
+            [newRequest setURL: baseURL]; 
+        else
+            [newRequest setURL: [NSURL URLWithString: @"about:blank"]];
+    } 
+    return newRequest;
+}
+
+
+ at end
+
+// Implement the required methods for the concrete subclass of WebProtocolHandler
+// that will handle our custom protocol.
+ at implementation WebDataProtocol
+
++ (void)load
+{
+    [WebProtocol registerClass: [self class]];
+}
+
++ (BOOL)doesURLHaveInternalDataScheme: (NSURL *)URL
+{
+    return ([[URL scheme] caseInsensitiveCompare: WebDataProtocolScheme] == NSOrderedSame && [[URL path] length] == 0);
+}
+
+
++ (BOOL)canHandleURL:(NSURL *)theURL
+{
+    if ([WebDataProtocol doesURLHaveInternalDataScheme:theURL]){
+        return YES;
+    }
+    return NO;
+}
+
++ (NSURL *)canonicalURLForURL:(NSURL *)URL
+{
+    return URL;
+}
+
+- (void)startLoadingWithCacheObject:(WebCacheObject *)cacheObject
+{
+    NSObject<WebProtocolClient> *client = [self client];
+    NSURLRequest *request = [self request];
+    NSData *data = [request _webDataRequestData];
+
+    if (data) {
+        NSURLResponse *response = [[NSURLResponse alloc] init];
+        [response setURL:[request URL]];
+        [response setMIMEType:@"text/html"];
+        [response setTextEncodingName:[request _webDataRequestEncoding]];
+        [client responseAvailable:response];
+        [client didLoadBytes:[data bytes] length:[data length]];
+        [client finishedLoading];
+        [response release];
+    } else {
+        int resultCode;
+
+        resultCode = WebFoundationErrorResourceUnavailable;
+
+        [client failedWithError:[WebError errorWithCode:resultCode inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]]];
+    }
+}
+
+- (void)stopLoading
+{
+}
+
+ at end
+
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index 04e569c..f787db2 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -4,6 +4,7 @@
 */
 
 #import <WebKit/WebBridge.h>
+#import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDocument.h>
 #import <WebKit/WebDownload.h>
@@ -66,11 +67,17 @@
 
 -(NSURLRequest *)initialRequest
 {
-    return _private->originalRequest;
+    NSURLRequest *clientRequest = [_private->originalRequest _webDataRequestExternalRequest];
+    if (!clientRequest)
+        clientRequest = _private->originalRequest;
+    return clientRequest;
 }
 
 -(NSMutableURLRequest *)request
 {
+    NSURLRequest *clientRequest = [_private->request _webDataRequestExternalRequest];
+    if (!clientRequest)
+        clientRequest = _private->request;
     return _private->request;
 }
 
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index d2ef348..85242cd 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -5,6 +5,7 @@
 #import <WebKit/WebDataSourcePrivate.h>
 
 #import <WebKit/WebBridge.h>
+#import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDocument.h>
 #import <WebKit/WebDownload.h>
 #import <WebKit/WebException.h>
@@ -489,12 +490,17 @@
             
         [frame _transitionToCommitted: pageCache];
 
-	NSString *urlString = [[_private->response URL] absoluteString];
-
-	// WebCore will crash if given an empty URL here.
-	if ([urlString length] == 0) {
-	    urlString = @"about:blank";
-	}
+        NSURL *baseURL = [[self request] _webDataRequestBaseURL];        
+        NSString *urlString;
+        
+        if (baseURL)
+            urlString = [baseURL absoluteString];
+        else
+            urlString = [[_private->response URL] absoluteString];
+            
+        // WebCore will crash if given an empty URL here.
+        if ([urlString length] == 0)
+            urlString = @"about:blank";
 
         [[self _bridge] openURL:urlString
                          reload:reload 
diff --git a/WebKit/WebView.subproj/WebFrame.h b/WebKit/WebView.subproj/WebFrame.h
index 1d07b20..054e156 100644
--- a/WebKit/WebView.subproj/WebFrame.h
+++ b/WebKit/WebView.subproj/WebFrame.h
@@ -58,7 +58,22 @@
     @method loadRequest:
     @param request The web request to load.
 */
--(void)loadRequest:(NSURLRequest *)request;
+- (void)loadRequest:(NSURLRequest *)request;
+
+/*!
+    @method loadData:baseURL:
+    @param data The data to use for the main page of the document.
+    @param encodingName The encoding of the data.
+    @param URL The base URL to apply to relative URLs within the document.
+*/
+- (void)loadData:(NSData *)data encodingName: (NSString *)encodingName baseURL:(NSURL *)URL;
+
+/*!
+    @method loadData:baseURL:
+    @param string The string to use for the main page of the document.
+    @param URL The base URL to apply to relative URLs within the document.
+*/
+- (void)loadString:(NSString *)string baseURL:(NSURL *)URL;
 
 /*!
     @method dataSource
@@ -126,6 +141,6 @@
     @param representationClass The WebDocumentRepresentation class to use to represent data of the given MIME type.
     @param MIMEType The MIME type to represent with an object of the given class.
 */
-+ (void) registerViewClass:(Class)viewClass representationClass: (Class)representationClass forMIMEType:(NSString *)MIMEType;
++ (void)registerViewClass:(Class)viewClass representationClass: (Class)representationClass forMIMEType:(NSString *)MIMEType;
 
 @end
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index a0a16d2..5703527 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -9,6 +9,7 @@
 
 #import <WebKit/WebBackForwardList.h>
 #import <WebKit/WebBridge.h>
+#import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebFrameViewPrivate.h>
@@ -21,8 +22,9 @@
 #import <WebKit/WebViewPrivate.h>
 #import <WebKit/WebWindowOperationsDelegate.h>
 
-#import <WebFoundation/WebNSURLExtras.h>
 #import <WebFoundation/NSURLRequest.h>
+#import <WebFoundation/WebNSURLExtras.h>
+#import <WebFoundation/WebProtocol.h>
 
 #import <WebFoundation/WebNSStringExtras.h>
 
@@ -115,6 +117,32 @@
     [newDataSource release];
 }
 
+- (void)loadData:(NSData *)data encodingName: (NSString *)encodingName baseURL:(NSURL *)URL;
+{
+    NSURL *fakeURL = [NSURLRequest _webDataRequestURLForData: data];
+    NSURLRequest *request = [[[NSURLRequest alloc] initWithURL: fakeURL] autorelease];
+    [request _webDataRequestSetData:data];
+    [request _webDataRequestSetEncoding:encodingName];
+    [request _webDataRequestSetBaseURL:URL];
+    [self loadRequest:request];
+}
+
+- (void)loadString:(NSString *)string baseURL:(NSURL *)URL
+{
+    CFStringEncoding cfencoding = CFStringGetFastestEncoding((CFStringRef)string);
+    NSStringEncoding nsencoding = CFStringConvertEncodingToNSStringEncoding(cfencoding);
+    CFStringRef cfencodingName = CFStringConvertEncodingToIANACharSetName(cfencoding);
+    
+    if (!cfencodingName || nsencoding == kCFStringEncodingInvalidId){
+        NSData *data = [string dataUsingEncoding: NSUnicodeStringEncoding];
+        [self loadData:data encodingName:@"utf-16" baseURL:URL];
+    }
+    else {
+        NSData *data = [string dataUsingEncoding: nsencoding];
+        [self loadData:data encodingName:(NSString *)cfencodingName baseURL:URL];
+    }
+}
+
 - (void)stopLoading
 {
     [self _invalidatePendingPolicyDecisionCallingDefaultAction:YES];
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index d7ba1e6..9ea2caa 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -8,6 +8,7 @@
 
 #import <WebKit/WebBackForwardList.h>
 #import <WebKit/WebBridge.h>
+#import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDataSource.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDefaultWindowOperationsDelegate.h>
@@ -256,11 +257,12 @@ Repeat load of the same URL (by any other means of navigation other than the rel
 
 
 // helper method used in various nav cases below
-- (WebHistoryItem *)_addBackForwardItemClippedAtTarget:(BOOL)doClip
+- (void)_addBackForwardItemClippedAtTarget:(BOOL)doClip
 {
-    WebHistoryItem *bfItem = [[[self webView] mainFrame] _createItemTreeWithTargetFrame:self clippedAtTarget:doClip];
-    [[[self webView] backForwardList] addItem:bfItem];
-    return bfItem;
+    if (![WebDataProtocol canHandleURL:[[[[[self webView] mainFrame] dataSource] response] URL]]){
+        WebHistoryItem *bfItem = [[[self webView] mainFrame] _createItemTreeWithTargetFrame:self clippedAtTarget:doClip];
+        [[[self webView] backForwardList] addItem:bfItem];
+    }
 }
 
 - (WebHistoryItem *)_createItem
@@ -649,7 +651,7 @@ Repeat load of the same URL (by any other means of navigation other than the rel
                 if (![ds _isClientRedirect]) {
                     // Add item to history.
 		    NSURL *URL = [[[ds _originalRequest] URL] _web_canonicalize];
-		    if ([[URL absoluteString] length] > 0) {
+		    if ([[URL absoluteString] length] > 0 && ![WebDataProtocol canHandleURL:URL]) {
 			entry = [[WebHistory sharedHistory] addItemForURL:URL];
 			if (ptitle)
 			    [entry setTitle: ptitle];
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.m b/WebKit/WebView.subproj/WebFrameViewPrivate.m
index 3339ecc..e5fba5f 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.m
+++ b/WebKit/WebView.subproj/WebFrameViewPrivate.m
@@ -83,7 +83,9 @@
 
 -(NSView <WebDocumentView> *)_makeDocumentViewForDataSource:(WebDataSource *)dataSource
 {
-    Class viewClass = [[[self class] _viewTypes] _web_objectForMIMEType:[[dataSource response] MIMEType]];
+    NSString *MIMEType = [[dataSource response] MIMEType];
+    
+    Class viewClass = [[[self class] _viewTypes] _web_objectForMIMEType:MIMEType];
     NSView <WebDocumentView> *documentView = viewClass ? [[viewClass alloc] init] : nil;
     [self _setDocumentView:documentView];
     [documentView release];
diff --git a/WebKit/WebView.subproj/WebLoader.m b/WebKit/WebView.subproj/WebLoader.m
index af6bcef..cf61631 100644
--- a/WebKit/WebView.subproj/WebLoader.m
+++ b/WebKit/WebView.subproj/WebLoader.m
@@ -13,7 +13,9 @@
 #import <WebFoundation/NSURLRequest.h>
 #import <WebFoundation/NSURLRequestPrivate.h>
 #import <WebFoundation/NSURLResponse.h>
+#import <WebFoundation/NSURLResponsePrivate.h>
 
+#import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDefaultResourceLoadDelegate.h>
 #import <WebKit/WebKitErrors.h>
@@ -127,25 +129,43 @@
 {
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
-    
     NSMutableURLRequest *mutableRequest = [newRequest mutableCopy];
+    NSURLRequest *clientRequest, *updatedRequest;
+    BOOL haveDataSchemeRequest = NO;
+    
     [mutableRequest HTTPSetUserAgent:[controller userAgentForURL:[newRequest URL]]];
     newRequest = [mutableRequest autorelease];
     
+    clientRequest = [newRequest _webDataRequestExternalRequest];
+    if (!clientRequest)
+        clientRequest = newRequest;
+    else
+        haveDataSchemeRequest = YES;
     
     if (identifier == nil) {
         // The identifier is released after the last callback, rather than in dealloc
         // to avoid potential cycles.
         if (implementations.delegateImplementsIdentifierForRequest)
-            identifier = [[resourceLoadDelegate webView: controller identifierForInitialRequest:newRequest fromDataSource:dataSource] retain];
+            identifier = [[resourceLoadDelegate webView: controller identifierForInitialRequest:clientRequest fromDataSource:dataSource] retain];
         else
-            identifier = [[[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller identifierForInitialRequest:newRequest fromDataSource:dataSource] retain];
+            identifier = [[[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller identifierForInitialRequest:clientRequest fromDataSource:dataSource] retain];
     }
 
+    // If we have a special "applewebdata" scheme URL we send a fake request to the delegate.
     if (implementations.delegateImplementsWillSendRequest)
-        newRequest = [resourceLoadDelegate webView:controller resource:identifier willSendRequest:newRequest redirectResponse:redirectResponse fromDataSource:dataSource];
+        updatedRequest = [resourceLoadDelegate webView:controller resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource];
     else
-        newRequest = [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller resource:identifier willSendRequest:newRequest redirectResponse:redirectResponse fromDataSource:dataSource];
+        updatedRequest = [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:controller resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource];
+        
+    if (!haveDataSchemeRequest)
+        newRequest = updatedRequest;
+    else {
+        // If the delegate modified the request use that instead of
+        // our applewebdata request, otherwise use the original
+        // applewebdata request.
+        if (![updatedRequest isEqual:clientRequest])
+            newRequest = updatedRequest;
+    }
 
     // Store a copy of the request.
     [request autorelease];
@@ -175,6 +195,16 @@
     ASSERT(con == connection);
     ASSERT(!reachedTerminalState);
 
+    // If the URL is one of our whacky applewebdata URLs that
+    // fake up a substitute URL to present to the delegate.
+    if([WebDataProtocol doesURLHaveInternalDataScheme: [r URL]] != nil){
+        NSURL *baseURL = [request _webDataRequestBaseURL];
+        if (baseURL)
+            [r setURL: baseURL];
+        else
+            [r setURL: [NSURL URLWithString: @"about:blank"]];
+    }
+
     [r retain];
     [response release];
     response = r;
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index ecbb4e5..d104679 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -57,6 +57,8 @@ NSString *WebElementLinkTitleKey = 		@"WebElementLinkTitle";
 
 + (BOOL)canShowMIMEType:(NSString *)MIMEType
 {
+    [[WebPluginDatabase installedPlugins] loadPluginIfNeededForMIMEType: MIMEType];
+    
     Class viewClass = [WebFrameView _viewClassForMIMEType:MIMEType];
     Class repClass = [WebDataSource _representationClassForMIMEType:MIMEType];
         

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list