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

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:04:32 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit b5df1c22c9405c1d7eee96e872f0a908f26e4445
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 23 23:47:19 2003 +0000

    	Fixed: <rdar://problem/3364036>: ER: Allow plug-ins to override built-in types such as image/jpeg
    
            Reviewed by john.
    
            * Plugins.subproj/WebPluginDatabase.m:
            (-[WebPluginDatabase refresh]): Allow plug-ins to override built-in types except for our core HTML types and don't allow the QT plug-in to override any types because it handles many types that we already handle
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge viewForPluginWithURL:attributes:baseURL:MIMEType:): instead of asserting, handle the case where we ask a plug-in to map from an extension to a MIME type, but nil is returned
            (-[WebBridge frameRequiredForMIMEType:URL:]): no need to start up the plug-in DB because this is now handled by [WebView _viewClass:andRepresentationClass:forMIMEType:]
            * WebView.subproj/WebDataSource.m:
            (+[WebDataSource _representationClassForMIMEType:]): call [WebView _viewClass:andRepresentationClass:forMIMEType:]
            (-[WebDataSource _makeRepresentation]): call _representationClassForMIMEType
            * WebView.subproj/WebDataSourcePrivate.h:
            * WebView.subproj/WebFrameView.m:
            (-[WebFrameView _makeDocumentViewForDataSource:]): tweak
            (+[WebFrameView _viewClassForMIMEType:]): call [WebView _viewClass:andRepresentationClass:forMIMEType:]
            * WebView.subproj/WebView.m:
    	(+[WebView _viewClass:andRepresentationClass:forMIMEType:]): new, central place for mapping from a MIME to the document classes. We now load the plug-in DB when a non-HTML MIME type is encountered instead of loading the plug-in DB when the class for the MIME type is not found. This is required to fully fix 3364036.
            (+[WebView canShowMIMEType:]): call [WebView _viewClass:andRepresentationClass:forMIMEType:]
            (+[WebView registerViewClass:representationClass:forMIMEType:]): tweak
            * WebView.subproj/WebViewPrivate.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5251 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c336d38..0aac5f3 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,27 @@
+2003-10-23  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: <rdar://problem/3364036>: ER: Allow plug-ins to override built-in types such as image/jpeg
+
+        Reviewed by john.
+
+        * Plugins.subproj/WebPluginDatabase.m:
+        (-[WebPluginDatabase refresh]): Allow plug-ins to override built-in types except for our core HTML types and don't allow the QT plug-in to override any types because it handles many types that we already handle
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge viewForPluginWithURL:attributes:baseURL:MIMEType:): instead of asserting, handle the case where we ask a plug-in to map from an extension to a MIME type, but nil is returned 
+        (-[WebBridge frameRequiredForMIMEType:URL:]): no need to start up the plug-in DB because this is now handled by [WebView _viewClass:andRepresentationClass:forMIMEType:]
+        * WebView.subproj/WebDataSource.m:
+        (+[WebDataSource _representationClassForMIMEType:]): call [WebView _viewClass:andRepresentationClass:forMIMEType:]
+        (-[WebDataSource _makeRepresentation]): call _representationClassForMIMEType
+        * WebView.subproj/WebDataSourcePrivate.h:
+        * WebView.subproj/WebFrameView.m:
+        (-[WebFrameView _makeDocumentViewForDataSource:]): tweak
+        (+[WebFrameView _viewClassForMIMEType:]): call [WebView _viewClass:andRepresentationClass:forMIMEType:]
+        * WebView.subproj/WebView.m:
+	(+[WebView _viewClass:andRepresentationClass:forMIMEType:]): new, central place for mapping from a MIME to the document classes. We now load the plug-in DB when a non-HTML MIME type is encountered instead of loading the plug-in DB when the class for the MIME type is not found. This is required to fully fix 3364036.
+        (+[WebView canShowMIMEType:]): call [WebView _viewClass:andRepresentationClass:forMIMEType:]
+        (+[WebView registerViewClass:representationClass:forMIMEType:]): tweak
+        * WebView.subproj/WebViewPrivate.h:
+
 2003-10-23  John Sullivan  <sullivan at apple.com>
 
 	- fixed 3459272 -- Can't set up keyboard loop inside a 
diff --git a/WebKit/Plugins.subproj/WebPluginDatabase.m b/WebKit/Plugins.subproj/WebPluginDatabase.m
index f57346b..e51b177 100644
--- a/WebKit/Plugins.subproj/WebPluginDatabase.m
+++ b/WebKit/Plugins.subproj/WebPluginDatabase.m
@@ -17,14 +17,16 @@
 
 #import <CoreGraphics/CPSProcesses.h>
 
+#import <Foundation/NSString_NSURLExtras.h>
 #import <Foundation/NSURLFileTypeMappings.h>
 
+#define QuickTimePluginIdentifier       @"com.apple.QuickTime Plugin.plugin"
 #define JavaCocoaPluginIdentifier 	@"com.apple.JavaPluginCocoa"
-
 #define JavaCarbonPluginIdentifier 	@"com.apple.JavaAppletPlugin"
+#define JavaCFMPluginFilename		@"Java Applet Plugin Enabler"
 #define JavaCarbonPluginBadVersion 	@"1.0.0"
 
-#define JavaCFMPluginFilename		@"Java Applet Plugin Enabler"
+
 
 @implementation WebPluginDatabase
 
@@ -96,13 +98,15 @@ static BOOL sIsCocoa = FALSE;
 
 - (WebBasePluginPackage *)pluginForKey:(NSString *)key withEnumeratorSelector:(SEL)enumeratorSelector
 {
-    WebBasePluginPackage *plugin, *CFMPlugin=nil, *machoPlugin=nil, *webPlugin=nil;
+    WebBasePluginPackage *plugin, *CFMPlugin=nil, *machoPlugin=nil, *webPlugin=nil, *QTPlugin=nil;
     NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
     key = [key lowercaseString];
 
     while ((plugin = [pluginEnumerator nextObject]) != nil) {
         if ([[[plugin performSelector:enumeratorSelector] allObjects] containsObject:key]) {
-            if ([plugin isKindOfClass:[WebPluginPackage class]]) {
+            if ([[[plugin bundle] bundleIdentifier] _web_isCaseInsensitiveEqualToString:QuickTimePluginIdentifier]) {
+                QTPlugin = plugin;
+            } else if ([plugin isKindOfClass:[WebPluginPackage class]]) {
                 if (webPlugin == nil) {
                     webPlugin = plugin;
                 }
@@ -125,12 +129,16 @@ static BOOL sIsCocoa = FALSE;
         }
     }
 
+    // Allow other plug-ins to win over QT because if the user has installed a plug-in that can handle a type
+    // that the QT plug-in can handle, they probably intended to override QT.
     if ([self canUsePlugin:webPlugin]) {
         return webPlugin;
     } else if (machoPlugin) {
         return machoPlugin;
     } else if (CFMPlugin) {
         return CFMPlugin;
+    } else if (QTPlugin) {
+        return QTPlugin;
     } else {
         return nil;
     }
@@ -250,16 +258,19 @@ static NSArray *pluginLocations(void)
     }
     
     // Register netscape plug-in WebDocumentViews and WebDocumentRepresentations
-    // but do not override other document views and representations.
     NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
     WebBasePluginPackage *plugin;
     while ((plugin = [pluginEnumerator nextObject]) != nil) {
         if ([plugin isKindOfClass:[WebNetscapePluginPackage class]]) {
+            BOOL isQuickTime = [[[plugin bundle] bundleIdentifier] _web_isCaseInsensitiveEqualToString:QuickTimePluginIdentifier];
             NSEnumerator *MIMEEnumerator = [plugin MIMETypeEnumerator];
             while ((MIMEType = [MIMEEnumerator nextObject]) != nil) {
-                if ([MIMEToViewClass objectForKey:MIMEType] == nil) {
-                    [WebView registerViewClass:[WebNetscapePluginDocumentView class] representationClass:[WebNetscapePluginRepresentation class] forMIMEType:MIMEType];
+                if ([WebView canShowMIMETypeAsHTML:MIMEType] || (isQuickTime && [MIMEToViewClass objectForKey:MIMEType] != nil)) {
+                    // Don't allow plug-ins to override our core HTML types and don't allow the QT plug-in to override any types 
+                    // because it claims many that we can handle ourselves.
+                    continue;
                 }
+                [WebView registerViewClass:[WebNetscapePluginDocumentView class] representationClass:[WebNetscapePluginRepresentation class] forMIMEType:MIMEType];
             }
         } else {
             if (![plugin isLoaded]) {
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 6b36243..ced38c7 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -654,7 +654,7 @@
     NSView *view = nil;
     int errorCode = 0;
     
-    if ([MIMEType length] > 0) {
+    if ([MIMEType length] != 0) {
         pluginPackage = [[WebPluginDatabase installedPlugins] pluginForMIMEType:MIMEType];
     } else {
         MIMEType = nil;
@@ -664,8 +664,10 @@
     if (!pluginPackage && [extension length] != 0) {
         pluginPackage = [[WebPluginDatabase installedPlugins] pluginForExtension:extension];
         if (pluginPackage) {
-            MIMEType = [pluginPackage MIMETypeForExtension:extension];
-            ASSERT(MIMEType);
+            NSString *newMIMEType = [pluginPackage MIMETypeForExtension:extension];
+            if ([newMIMEType length] != 0) {
+                MIMEType = newMIMEType;
+            }
         }
     }
 
@@ -810,11 +812,8 @@ static BOOL loggedObjectCacheSize = NO;
         }
     }
     
-    // Have the plug-in DB register document views.
-    [[WebPluginDatabase installedPlugins] loadPluginIfNeededForMIMEType:MIMEType];
-    
-    Class result = [WebFrameView _viewClassForMIMEType:MIMEType];
-    if (!result) {
+    Class viewClass = [WebFrameView _viewClassForMIMEType:MIMEType];
+    if (!viewClass) {
         // Want to display a "plugin not found" dialog/image, so let a plugin get made.
         return NO;
     }
@@ -822,8 +821,8 @@ static BOOL loggedObjectCacheSize = NO;
     // 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 !([result isSubclassOfClass:[WebNetscapePluginDocumentView class]] ||
-            [result conformsToProtocol:@protocol(WebPlugin)]);
+    return !([viewClass isSubclassOfClass:[WebNetscapePluginDocumentView class]] ||
+             [viewClass conformsToProtocol:@protocol(WebPlugin)]);
 }
 
 - (void)loadEmptyDocumentSynchronously
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index 6a05344..e68f96a 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -89,11 +89,6 @@
     _private->representation = [representation retain];
 }
 
-- (Class)_representationClass
-{
-    return [[self class] _representationClassForMIMEType:[[self response] MIMEType]];
-}
-
 - (void)_setLoading:(BOOL)loading
 {
     ASSERT_ARG(loading, loading == NO || loading == YES);
@@ -458,6 +453,7 @@
         NSEnumerator *enumerator = [[WebImageView supportedImageMIMETypes] objectEnumerator];
         NSString *mime;
         while ((mime = [enumerator nextObject]) != nil) {
+            // Don't clobber previously-registered rep classes.
             [repTypes setObject:[WebImageRepresentation class] forKey:mime];
         }
         addedImageTypes = YES;
@@ -468,12 +464,8 @@
 
 + (Class)_representationClassForMIMEType:(NSString *)MIMEType
 {
-    // Getting the image types is slow, so don't do it until we have to.
-    Class c = [[self _repTypesAllowImageTypeOmission:YES] _web_objectForMIMEType:MIMEType];
-    if (c == nil) {
-        c = [[self _repTypesAllowImageTypeOmission:NO] _web_objectForMIMEType:MIMEType];
-    }
-    return c;
+    Class repClass;
+    return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
 }
 
 - (WebBridge *)_bridge
@@ -538,8 +530,8 @@
 
 -(void)_makeRepresentation
 {
-    Class repClass = [self _representationClass];
-
+    Class repClass = [[self class] _representationClassForMIMEType:[[self response] MIMEType]];
+    
     // Check if the data source was already bound?
     if (![[self representation] isKindOfClass:repClass]) {
         id newRep = repClass != nil ? [[repClass alloc] init] : nil;
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index e8aca4f..81a658e 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -117,7 +117,6 @@
 - (void)_stopLoading;
 - (NSURL *)_URL;
 - (WebView *)_webView;
-- (Class)_representationClass;
 - (void)_setRepresentation:(id<WebDocumentRepresentation>)representation;
 - (void)_setWebView:(WebView *)webView;
 - (void)_startLoading:(NSDictionary *)pageCache;
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index 4363ae8..648b41a 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -99,10 +99,8 @@ enum {
 }
 
 -(NSView <WebDocumentView> *)_makeDocumentViewForDataSource:(WebDataSource *)dataSource
-{
-    NSString *MIMEType = [[dataSource response] MIMEType];
-    
-    Class viewClass = [[self class] _viewClassForMIMEType:MIMEType];
+{    
+    Class viewClass = [[self class] _viewClassForMIMEType:[[dataSource response] MIMEType]];
     NSView <WebDocumentView> *documentView = viewClass ? [[viewClass alloc] init] : nil;
     [self _setDocumentView:documentView];
     [documentView release];
@@ -294,7 +292,7 @@ static NSMutableDictionary *viewTypes;
         ASSERT(enumerator != nil);
         NSString *mime;
         while ((mime = [enumerator nextObject]) != nil) {
-            // Don't clobber previously-registered user image types
+            // Don't clobber previously-registered view classes.
             if ([viewTypes objectForKey:mime] == nil) {
                 [viewTypes setObject:[WebImageView class] forKey:mime];
             }
@@ -310,15 +308,10 @@ static NSMutableDictionary *viewTypes;
     return ([viewTypes objectForKey:MIMEType] == [WebHTMLView class]);
 }
 
-
 + (Class)_viewClassForMIMEType:(NSString *)MIMEType
 {
-    // Getting the image types is slow, so don't do it until we have to.
-    Class c = [[self _viewTypesAllowImageTypeOmission:YES] _web_objectForMIMEType:MIMEType];
-    if (c == nil) {
-        c = [[self _viewTypesAllowImageTypeOmission:NO] _web_objectForMIMEType:MIMEType];
-    }
-    return c;
+    Class viewClass;
+    return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType] ? viewClass : nil;
 }
 
 - (void)_goBack
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index c922b0f..ced6cc2 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -141,6 +141,63 @@ NSString *_WebMainFrameURLKey = @"mainFrameURL";
 
 @implementation WebView (WebPrivate)
 
++ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
+{
+    MIMEType = [MIMEType lowercaseString];
+    Class viewClass;
+    Class repClass;
+    
+    // Simple optimization that avoids loading the plug-in DB and image types for the HTML case.
+    if ([self canShowMIMETypeAsHTML:MIMEType]) {
+        viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] objectForKey:MIMEType];
+        repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] objectForKey:MIMEType];
+        if (viewClass && repClass) {
+            if (vClass) {
+                *vClass = viewClass;
+            }
+            if (rClass) {
+                *rClass = repClass;
+            }
+            return YES;
+        }
+    }
+    
+    // Load the plug-in DB allowing plug-ins to install types.
+    [[WebPluginDatabase installedPlugins] loadPluginIfNeededForMIMEType:MIMEType];
+    viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] objectForKey:MIMEType];
+    repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] objectForKey:MIMEType];
+    if (viewClass && repClass) {
+        if (vClass) {
+            *vClass = viewClass;
+        }
+        if (rClass) {
+            *rClass = repClass;
+        }
+        return YES;
+    }
+    
+    // Load the image types and get the view class and rep class. This should be the fullest picture of all handled types.
+    viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:NO] objectForKey:MIMEType];
+    repClass = [[WebDataSource _repTypesAllowImageTypeOmission:NO] objectForKey:MIMEType];
+    if (viewClass && repClass) {
+        // Special-case WebTextView for text types that shouldn't be shown.
+        if (viewClass == [WebTextView class] &&
+            repClass == [WebTextRepresentation class] &&
+            [[WebTextView unsupportedTextMIMETypes] containsObject:MIMEType]) {
+            return NO;
+        }
+        if (vClass) {
+            *vClass = viewClass;
+        }
+        if (rClass) {
+            *rClass = repClass;
+        }
+        return YES;
+    }
+    
+    return NO;
+}
+
 + (void)_setAlwaysUseATSU:(BOOL)f
 {
     [WebTextRenderer _setAlwaysUseATSU:f];
@@ -1038,26 +1095,7 @@ NSMutableDictionary *countInvocations;
 
 + (BOOL)canShowMIMEType:(NSString *)MIMEType
 {
-    Class viewClass = [WebFrameView _viewClassForMIMEType:MIMEType];
-    Class repClass = [WebDataSource _representationClassForMIMEType:MIMEType];
-
-    if (!viewClass || !repClass) {
-	[[WebPluginDatabase installedPlugins] loadPluginIfNeededForMIMEType: MIMEType];
-        viewClass = [WebFrameView _viewClassForMIMEType:MIMEType];
-        repClass = [WebDataSource _representationClassForMIMEType:MIMEType];
-    }
-    
-    // Special-case WebTextView for text types that shouldn't be shown.
-    if (viewClass && repClass) {
-        if (viewClass == [WebTextView class] &&
-            repClass == [WebTextRepresentation class] &&
-            [[WebTextView unsupportedTextMIMETypes] containsObject:MIMEType]) {
-            return NO;
-        }
-        return YES;
-    }
-    
-    return NO;
+    return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType];
 }
 
 + (BOOL)canShowMIMETypeAsHTML:(NSString *)MIMEType
@@ -1676,7 +1714,7 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     return NO;
 }
 
-+ (void) registerViewClass:(Class)viewClass representationClass: (Class)representationClass forMIMEType:(NSString *)MIMEType
++ (void)registerViewClass:(Class)viewClass representationClass:(Class)representationClass forMIMEType:(NSString *)MIMEType
 {
     [[WebFrameView _viewTypesAllowImageTypeOmission:YES] setObject:viewClass forKey:MIMEType];
     [[WebDataSource _repTypesAllowImageTypeOmission:YES] setObject:representationClass forKey:MIMEType];
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index a6d4b24..d9546db 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -105,6 +105,8 @@ extern NSString *_WebMainFrameURLKey;
 
 @interface WebView (WebPrivate)
 
++ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
+
 /*!
     @method canShowFile:
     @abstract Checks if the WebKit can show the content of the file at the specified path.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list