+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.
#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>
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
#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]
#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]