Fix object element support so that fallback content works. With this change Safari...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 May 2005 20:44:35 +0000 (20:44 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 May 2005 20:44:35 +0000 (20:44 +0000)
        Reviewed by Maciej

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge determineObjectFromMIMEType:URL:]):
        * WebView.subproj/WebDataSource.m:
        (-[WebDataSource _receivedMainResourceError:complete:]):
        * WebView.subproj/WebMainResourceClient.m:
        (-[WebMainResourceClient continueAfterContentPolicy:response:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9094 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m
WebKit/WebView.subproj/WebDataSource.m
WebKit/WebView.subproj/WebMainResourceClient.m
WebKit/WebView.subproj/WebMainResourceLoader.m

index 0c95e9e5d0a024362b77cfe2e57475c0ac9d9612..74259217e22f9c022ab7498ef598eff74dccd12f 100644 (file)
@@ -1,3 +1,16 @@
+2005-05-03  David Hyatt  <hyatt@apple.com>
+
+       Fix object element support so that fallback content works.  With this change Safari passes the Acid2 test.
+       
+        Reviewed by Maciej
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge determineObjectFromMIMEType:URL:]):
+        * WebView.subproj/WebDataSource.m:
+        (-[WebDataSource _receivedMainResourceError:complete:]):
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient continueAfterContentPolicy:response:]):
+
 2005-05-03  Darin Adler  <darin@apple.com>
 
         * WebView.subproj/WebUIDelegate.h: Fixed incorrect comment.
index c42508d5f05d609a5f301af730985f2b550c472d..997f70119e431bdff9b2dbe95cf5529c8b2c047c 100644 (file)
@@ -22,6 +22,7 @@
 #import <WebKit/WebHistoryItemPrivate.h>
 #import <WebKit/WebHTMLRepresentationPrivate.h>
 #import <WebKit/WebHTMLViewInternal.h>
+#import <WebKit/WebImageView.h>
 #import <WebKit/WebJavaPlugIn.h>
 #import <WebKit/WebJavaScriptTextInputPanel.h>
 #import <WebKit/WebKitErrorsPrivate.h>
@@ -1053,30 +1054,36 @@ static BOOL loggedObjectCacheSize = NO;
     return cacheSize * multiplier;
 }
 
-- (BOOL)frameRequiredForMIMEType:(NSString *)MIMEType URL:(NSURL *)URL
+- (ObjectElementType)determineObjectFromMIMEType:(NSString*)MIMEType URL:(NSURL*)URL
 {
     if ([MIMEType length] == 0) {
+        // Try to guess the MIME type based off the extension.
         NSString *extension = [[URL path] pathExtension];
-        if ([extension length] > 0 && [[WebPluginDatabase installedPlugins] pluginForExtension:extension] != nil) {
-            // If no MIME type is specified, use a plug-in if we have one that can handle the extension.
-            return NO;
-        } else {
-            // Else, create a frame and attempt to load the URL in there.
-            return YES;
+        if ([extension length] > 0) {
+            MIMEType = [[NSURLFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+            if ([MIMEType length] == 0 && [[WebPluginDatabase installedPlugins] pluginForExtension:extension])
+                // If no MIME type is specified, use a plug-in if we have one that can handle the extension.
+                return ObjectElementPlugin;
         }
     }
-    
+
+    if ([MIMEType length] == 0)
+        return ObjectElementFrame; // Go ahead and hope that we can display the content.
+                
     Class viewClass = [WebFrameView _viewClassForMIMEType:MIMEType];
-    if (!viewClass) {
-        // Want to display a "plugin not found" dialog/image, so let a plugin get made.
-        return NO;
-    }
-        
+    if (!viewClass)
+        // Nothing is registered at all.
+        return ObjectElementNone;
+    
+    if ([viewClass isSubclassOfClass:[WebImageView class]])
+        return ObjectElementImage;
+    
     // If we're a supported type other than a plugin, we want to make a frame.
     // Ultimately we should just use frames for all mime types (plugins and HTML/XML/text documents),
     // but for now we're burdened with making a distinction between the two.
-    return !([viewClass isSubclassOfClass:[WebNetscapePluginDocumentView class]] || 
-             [viewClass isSubclassOfClass:[WebPluginDocumentView class]]);
+    if ([viewClass isSubclassOfClass:[WebNetscapePluginDocumentView class]] || [viewClass isSubclassOfClass:[WebPluginDocumentView class]])
+        return ObjectElementPlugin;
+    return ObjectElementFrame;
 }
 
 - (void)loadEmptyDocumentSynchronously
index 445e53325cb9016c1c6ef07ff881867870bf0556..83ab8b07d28bddba4e143edc5cbba062df36f24f 100644 (file)
     if (isComplete) {
         // Can't call [self _bridge] because we might not have commited yet
         [[[self webFrame] _bridge] stop];
-    }        
+        [[[self webFrame] _bridge] mainResourceError];
+    }
+
     [[self webFrame] _receivedMainResourceError:error];
     [[self _webView] _mainReceivedError:error
                            fromDataSource:self
index f3e7c72a8a818bb60e850c287820e82462be8d44..433e37a3e56692b5d668bbf5c17b54f519051d31 100644 (file)
@@ -30,6 +30,7 @@
 #import <WebKit/WebNSURLExtras.h>
 #import <WebKit/WebPolicyDelegatePrivate.h>
 #import <WebKit/WebViewPrivate.h>
+#import <WebKit/WebBridge.h>
 
 // FIXME: More that is in common with WebSubresourceClient should move up into WebBaseResourceHandleDelegate.
 
 
     [self retain];
 
+    if ([r isKindOfClass:[NSHTTPURLResponse class]]) {
+        int status = [(NSHTTPURLResponse *)r statusCode];
+        if (status < 200 || status >= 300)
+            // Handle <object> fallback for error cases.
+            [[[dataSource webFrame] _bridge] mainResourceError];
+    }
+
     [super connection:connection didReceiveResponse:r];
 
     if (![dataSource _isStopping]
index f3e7c72a8a818bb60e850c287820e82462be8d44..433e37a3e56692b5d668bbf5c17b54f519051d31 100644 (file)
@@ -30,6 +30,7 @@
 #import <WebKit/WebNSURLExtras.h>
 #import <WebKit/WebPolicyDelegatePrivate.h>
 #import <WebKit/WebViewPrivate.h>
+#import <WebKit/WebBridge.h>
 
 // FIXME: More that is in common with WebSubresourceClient should move up into WebBaseResourceHandleDelegate.
 
 
     [self retain];
 
+    if ([r isKindOfClass:[NSHTTPURLResponse class]]) {
+        int status = [(NSHTTPURLResponse *)r statusCode];
+        if (status < 200 || status >= 300)
+            // Handle <object> fallback for error cases.
+            [[[dataSource webFrame] _bridge] mainResourceError];
+    }
+
     [super connection:connection didReceiveResponse:r];
 
     if (![dataSource _isStopping]