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

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:03:00 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 581c4dce5d1232f9b2494e5d89a709fdea87fbe4
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Apr 4 23:31:26 2002 +0000

    2002-04-04  Kenneth Kocienda  <kocienda at apple.com>
    
            Hack to handle displaying image URLs. The trick is to sense when
            the main URL is an image type and wrap the URL in a small generated
            HTML document and hand that off to the engine to display.
    
            Works like a charm! :)
    
            There may be some longer-term issues, but for now, this lets us
            do something we could not before. It also lets us handle some iframes
            that contain only image URLs.
    
            * Resources/image_document_template.html: Added.
            * WebKit.pbproj/project.pbxproj:
            * WebView.subproj/IFMainURLHandleClient.h:
            * WebView.subproj/IFMainURLHandleClient.mm: (loadImageDocumentTemplate),
            (-[IFMainURLHandleClient initWithDataSource:part:]), (-[IFMainURLHandleClient
            IFURLHandle:resourceDataDidBecomeAvailable:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 18b759d..493b697 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,22 @@
+2002-04-04  Kenneth Kocienda  <kocienda at apple.com>
+
+        Hack to handle displaying image URLs. The trick is to sense when
+        the main URL is an image type and wrap the URL in a small generated
+        HTML document and hand that off to the engine to display.
+
+        Works like a charm! :)
+
+        There may be some longer-term issues, but for now, this lets us
+        do something we could not before. It also lets us handle some iframes
+        that contain only image URLs.
+
+	* Resources/image_document_template.html: Added.
+	* WebKit.pbproj/project.pbxproj:
+	* WebView.subproj/IFMainURLHandleClient.h:
+	* WebView.subproj/IFMainURLHandleClient.mm: (loadImageDocumentTemplate),
+	(-[IFMainURLHandleClient initWithDataSource:part:]), (-[IFMainURLHandleClient
+	IFURLHandle:resourceDataDidBecomeAvailable:]):
+
 2002-04-04  Chris Blumenberg  <cblu at apple.com>
 
 	* English.lproj/IFError.strings:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 18b759d..493b697 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,22 @@
+2002-04-04  Kenneth Kocienda  <kocienda at apple.com>
+
+        Hack to handle displaying image URLs. The trick is to sense when
+        the main URL is an image type and wrap the URL in a small generated
+        HTML document and hand that off to the engine to display.
+
+        Works like a charm! :)
+
+        There may be some longer-term issues, but for now, this lets us
+        do something we could not before. It also lets us handle some iframes
+        that contain only image URLs.
+
+	* Resources/image_document_template.html: Added.
+	* WebKit.pbproj/project.pbxproj:
+	* WebView.subproj/IFMainURLHandleClient.h:
+	* WebView.subproj/IFMainURLHandleClient.mm: (loadImageDocumentTemplate),
+	(-[IFMainURLHandleClient initWithDataSource:part:]), (-[IFMainURLHandleClient
+	IFURLHandle:resourceDataDidBecomeAvailable:]):
+
 2002-04-04  Chris Blumenberg  <cblu at apple.com>
 
 	* English.lproj/IFError.strings:
diff --git a/WebKit/Resources/image_document_template.html b/WebKit/Resources/image_document_template.html
new file mode 100644
index 0000000..e0a4099
--- /dev/null
+++ b/WebKit/Resources/image_document_template.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+<style type="text/css">
+ at media print {
+	body {
+		display: block;
+		margin: 2cm;
+	}
+}
+ at media screen {
+	body {
+		display: block;
+		margin: 0px;
+	}
+}
+</style>
+<title>%@</title>
+</head>
+<body><img src="%@"></body>
+</html>
\ No newline at end of file
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 27619c5..da0c61e 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 38;
+	objectVersion = 36;
 	objects = {
 		014CEA440018CDF011CA2923 = {
 			buildRules = (
@@ -224,6 +224,7 @@
 				35F357800198AAB80ACA1520,
 				F515C2B90238249C01C1A525,
 				F5B67131023EDF8901C1A525,
+				25B2A7C5025D0A880ECA149E,
 			);
 			isa = PBXResourcesBuildPhase;
 		};
@@ -283,6 +284,7 @@
 				089C1666FE841158C02AAC07,
 				35F3577401986B740ACA1520,
 				F5B67130023EDF8901C1A525,
+				25B2A7C4025D0A880ECA149E,
 			);
 			isa = PBXGroup;
 			name = Resources;
@@ -456,6 +458,18 @@
 			path = History.subproj;
 			refType = 4;
 		};
+		25B2A7C4025D0A880ECA149E = {
+			isa = PBXFileReference;
+			name = image_document_template.html;
+			path = Resources/image_document_template.html;
+			refType = 4;
+		};
+		25B2A7C5025D0A880ECA149E = {
+			fileRef = 25B2A7C4025D0A880ECA149E;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		25C29825016E29620ECA149E = {
 			isa = PBXFileReference;
 			name = WebKitReallyPrivate.h;
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.h b/WebKit/WebView.subproj/IFMainURLHandleClient.h
index 51afb79..597b78c 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.h
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.h
@@ -16,6 +16,7 @@
 {
     id dataSource;
     KHTMLPart *part;
+    BOOL sentFakeDocForNonHTMLContentType;
 }
 - initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
 @end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index c4cded0..aa3ec65 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -3,6 +3,8 @@
 	    
     Copyright 2001, Apple, Inc. All rights reserved.
 */
+#include <pthread.h>
+
 #import <WebKit/IFError.h>
 #import <WebKit/IFBaseWebControllerPrivate.h>
 #import <WebKit/IFMainURLHandleClient.h>
@@ -11,6 +13,25 @@
 
 #include <khtmlview.h>
 
+static NSString *imageDocumentTemplate = NULL;
+static pthread_once_t imageDocumentTemplateControl = PTHREAD_ONCE_INIT;
+
+static void loadImageDocumentTemplate() 
+{
+    NSString *path;
+    NSBundle *bundle;
+    NSData *data;
+    
+    bundle = [NSBundle bundleForClass:[IFMainURLHandleClient class]];
+    if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
+        data = [[NSData alloc] initWithContentsOfFile:path];
+        if (data) {
+            imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+            [data release];
+        }
+    }
+}
+
 @implementation IFMainURLHandleClient
 
 - initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
@@ -19,6 +40,7 @@
         dataSource = [ds retain];
         part = p;
         part->ref();
+        sentFakeDocForNonHTMLContentType = NO;
         return self;
     }
 
@@ -32,6 +54,7 @@
     [super dealloc];
 }
 
+
 - (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
 {
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
@@ -61,26 +84,57 @@
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
 {
+    BOOL handled;
+
+    NSString *fakeHTMLDocument;
+    const char *fakeHTMLDocumentBytes;
+    NSString *urlString;
+
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
+
+    // did we handle this content type?
+    handled = NO;
     
     //FIXME: This is a temporary hack to make sure we don't load non-html content. 
     //Since the cache returns nil for contentType when the URL is in the cache (2892912),
     //I assume the contentType is text/html for that case.
     NSString *contentType = [sender contentType];
-    if(![contentType isEqualToString:@"text/html"] && contentType != nil){
+    if(contentType == nil || [contentType isEqualToString:@"text/html"]) {
+        part->slotData(sender, (const char *)[data bytes], [data length]);
+        handled = YES;
+    }
+    // handle images
+    else if ([contentType isEqualToString:@"image/gif"] || [contentType isEqualToString:@"image/jpeg"] || [contentType isEqualToString:@"image/png"]) {
+        if (!sentFakeDocForNonHTMLContentType) {
+            pthread_once(&imageDocumentTemplateControl, loadImageDocumentTemplate);
+            if (imageDocumentTemplate) {
+                urlString = [[sender url] absoluteString];
+                fakeHTMLDocument = [NSString stringWithFormat:imageDocumentTemplate, urlString, urlString];
+                fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+                part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+            }
+        }
+        handled = YES;
+        sentFakeDocForNonHTMLContentType = YES;
+    }
+    
+    if (handled) {
+        // update progress
+        IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+        loadProgress->totalToLoad = [sender contentLength];
+        loadProgress->bytesSoFar = [sender contentLengthReceived];
+        [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+        [loadProgress release];
+    }
+    else {
+        // we do not handle this content type
+        // cancel load
         [sender cancelLoadInBackground];
         IFError *error = [[IFError alloc] initWithErrorCode: IFNonHTMLContentNotSupportedError failingURL: [sender url]];
         [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
         [error release];
-        return;
     }
-    part->slotData(sender, (const char *)[data bytes], [data length]);
-    
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    [loadProgress release];
+
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.h b/WebKit/WebView.subproj/WebMainResourceClient.h
index 51afb79..597b78c 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.h
+++ b/WebKit/WebView.subproj/WebMainResourceClient.h
@@ -16,6 +16,7 @@
 {
     id dataSource;
     KHTMLPart *part;
+    BOOL sentFakeDocForNonHTMLContentType;
 }
 - initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index c4cded0..aa3ec65 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -3,6 +3,8 @@
 	    
     Copyright 2001, Apple, Inc. All rights reserved.
 */
+#include <pthread.h>
+
 #import <WebKit/IFError.h>
 #import <WebKit/IFBaseWebControllerPrivate.h>
 #import <WebKit/IFMainURLHandleClient.h>
@@ -11,6 +13,25 @@
 
 #include <khtmlview.h>
 
+static NSString *imageDocumentTemplate = NULL;
+static pthread_once_t imageDocumentTemplateControl = PTHREAD_ONCE_INIT;
+
+static void loadImageDocumentTemplate() 
+{
+    NSString *path;
+    NSBundle *bundle;
+    NSData *data;
+    
+    bundle = [NSBundle bundleForClass:[IFMainURLHandleClient class]];
+    if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
+        data = [[NSData alloc] initWithContentsOfFile:path];
+        if (data) {
+            imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+            [data release];
+        }
+    }
+}
+
 @implementation IFMainURLHandleClient
 
 - initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
@@ -19,6 +40,7 @@
         dataSource = [ds retain];
         part = p;
         part->ref();
+        sentFakeDocForNonHTMLContentType = NO;
         return self;
     }
 
@@ -32,6 +54,7 @@
     [super dealloc];
 }
 
+
 - (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
 {
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
@@ -61,26 +84,57 @@
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
 {
+    BOOL handled;
+
+    NSString *fakeHTMLDocument;
+    const char *fakeHTMLDocumentBytes;
+    NSString *urlString;
+
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
+
+    // did we handle this content type?
+    handled = NO;
     
     //FIXME: This is a temporary hack to make sure we don't load non-html content. 
     //Since the cache returns nil for contentType when the URL is in the cache (2892912),
     //I assume the contentType is text/html for that case.
     NSString *contentType = [sender contentType];
-    if(![contentType isEqualToString:@"text/html"] && contentType != nil){
+    if(contentType == nil || [contentType isEqualToString:@"text/html"]) {
+        part->slotData(sender, (const char *)[data bytes], [data length]);
+        handled = YES;
+    }
+    // handle images
+    else if ([contentType isEqualToString:@"image/gif"] || [contentType isEqualToString:@"image/jpeg"] || [contentType isEqualToString:@"image/png"]) {
+        if (!sentFakeDocForNonHTMLContentType) {
+            pthread_once(&imageDocumentTemplateControl, loadImageDocumentTemplate);
+            if (imageDocumentTemplate) {
+                urlString = [[sender url] absoluteString];
+                fakeHTMLDocument = [NSString stringWithFormat:imageDocumentTemplate, urlString, urlString];
+                fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+                part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+            }
+        }
+        handled = YES;
+        sentFakeDocForNonHTMLContentType = YES;
+    }
+    
+    if (handled) {
+        // update progress
+        IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+        loadProgress->totalToLoad = [sender contentLength];
+        loadProgress->bytesSoFar = [sender contentLengthReceived];
+        [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+        [loadProgress release];
+    }
+    else {
+        // we do not handle this content type
+        // cancel load
         [sender cancelLoadInBackground];
         IFError *error = [[IFError alloc] initWithErrorCode: IFNonHTMLContentNotSupportedError failingURL: [sender url]];
         [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
         [error release];
-        return;
     }
-    part->slotData(sender, (const char *)[data bytes], [data length]);
-    
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    [loadProgress release];
+
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.h b/WebKit/WebView.subproj/WebMainResourceLoader.h
index 51afb79..597b78c 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.h
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.h
@@ -16,6 +16,7 @@
 {
     id dataSource;
     KHTMLPart *part;
+    BOOL sentFakeDocForNonHTMLContentType;
 }
 - initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index c4cded0..aa3ec65 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -3,6 +3,8 @@
 	    
     Copyright 2001, Apple, Inc. All rights reserved.
 */
+#include <pthread.h>
+
 #import <WebKit/IFError.h>
 #import <WebKit/IFBaseWebControllerPrivate.h>
 #import <WebKit/IFMainURLHandleClient.h>
@@ -11,6 +13,25 @@
 
 #include <khtmlview.h>
 
+static NSString *imageDocumentTemplate = NULL;
+static pthread_once_t imageDocumentTemplateControl = PTHREAD_ONCE_INIT;
+
+static void loadImageDocumentTemplate() 
+{
+    NSString *path;
+    NSBundle *bundle;
+    NSData *data;
+    
+    bundle = [NSBundle bundleForClass:[IFMainURLHandleClient class]];
+    if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
+        data = [[NSData alloc] initWithContentsOfFile:path];
+        if (data) {
+            imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+            [data release];
+        }
+    }
+}
+
 @implementation IFMainURLHandleClient
 
 - initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
@@ -19,6 +40,7 @@
         dataSource = [ds retain];
         part = p;
         part->ref();
+        sentFakeDocForNonHTMLContentType = NO;
         return self;
     }
 
@@ -32,6 +54,7 @@
     [super dealloc];
 }
 
+
 - (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
 {
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
@@ -61,26 +84,57 @@
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
 {
+    BOOL handled;
+
+    NSString *fakeHTMLDocument;
+    const char *fakeHTMLDocumentBytes;
+    NSString *urlString;
+
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
+
+    // did we handle this content type?
+    handled = NO;
     
     //FIXME: This is a temporary hack to make sure we don't load non-html content. 
     //Since the cache returns nil for contentType when the URL is in the cache (2892912),
     //I assume the contentType is text/html for that case.
     NSString *contentType = [sender contentType];
-    if(![contentType isEqualToString:@"text/html"] && contentType != nil){
+    if(contentType == nil || [contentType isEqualToString:@"text/html"]) {
+        part->slotData(sender, (const char *)[data bytes], [data length]);
+        handled = YES;
+    }
+    // handle images
+    else if ([contentType isEqualToString:@"image/gif"] || [contentType isEqualToString:@"image/jpeg"] || [contentType isEqualToString:@"image/png"]) {
+        if (!sentFakeDocForNonHTMLContentType) {
+            pthread_once(&imageDocumentTemplateControl, loadImageDocumentTemplate);
+            if (imageDocumentTemplate) {
+                urlString = [[sender url] absoluteString];
+                fakeHTMLDocument = [NSString stringWithFormat:imageDocumentTemplate, urlString, urlString];
+                fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+                part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+            }
+        }
+        handled = YES;
+        sentFakeDocForNonHTMLContentType = YES;
+    }
+    
+    if (handled) {
+        // update progress
+        IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+        loadProgress->totalToLoad = [sender contentLength];
+        loadProgress->bytesSoFar = [sender contentLengthReceived];
+        [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+        [loadProgress release];
+    }
+    else {
+        // we do not handle this content type
+        // cancel load
         [sender cancelLoadInBackground];
         IFError *error = [[IFError alloc] initWithErrorCode: IFNonHTMLContentNotSupportedError failingURL: [sender url]];
         [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
         [error release];
-        return;
     }
-    part->slotData(sender, (const char *)[data bytes], [data length]);
-    
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    [loadProgress release];
+
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list