Changeset 24866 in webkit


Ignore:
Timestamp:
Aug 4, 2007 12:29:55 AM (17 years ago)
Author:
beidson
Message:

WebCore:

Reviewed by Oliver

Fix for http://bugs.webkit.org/show_bug.cgi?id=14824 and <rdar://problem/5372989>

Two issues -
1 - The WebCore MIMEType registry was designed assuming the list of types would never change

That is false, as WebKit has API and SPI calls which directly mutate the MIMETypeRegistry

2 - DOMImplementation didn't consult the registry for any MIMEType that started with "text/",

instead maintaining it's own hard coded rules

  • dom/DOMImplementation.cpp: (WebCore::DOMImplementation::isTextMIMEType): For now, call through to the MIMETypeRegistry until we decided a different fate for this function
  • platform/MIMETypeRegistry.cpp: (WebCore::initialiseSupportedNonImageMimeTypes): "SupportedNonImageMIMETypes" is really a misnomer for "MIMETypes we should show as HTML" but that line has slowly been blurred since Tiger. In an attempt to start to unblur it, remove "text/" and "text/plain" (WebCore::MIMETypeRegistry::shouldTreatAsText): The decision is very close to the old DOMImplementation method, except we don't automatically hand off "text/" types as true if they are in the set of supported MIMETypes (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): Non-const (can be changed!) (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Non-const (can be changed!) (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): Non-const (can be changed!)
  • platform/MIMETypeRegistry.h:

WebKit:

Reviewed by Oliver

Fix for http://bugs.webkit.org/show_bug.cgi?id=14824 and <rdar://problem/5372989>

When unregistering a MIMEType, remove it from the WebCore registry unconditionally
When registrying a MIMEType whose view class is WebHTMLView, add it to the WebCore registry

  • WebView/WebView.mm: (+[WebView _unregisterViewClassAndRepresentationClassForMIMEType:]): (+[WebView _registerViewClass:representationClass:forURLScheme:]): (+[WebView registerViewClass:representationClass:forMIMEType:]):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r24864 r24866  
     12007-08-03  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Oliver
     4
     5        Fix for http://bugs.webkit.org/show_bug.cgi?id=14824 and <rdar://problem/5372989>
     6
     7        Two issues -
     8        1 - The WebCore MIMEType registry was designed assuming the list of types would never change
     9            That is false, as WebKit has API and SPI calls which directly mutate the MIMETypeRegistry
     10        2 - DOMImplementation didn't consult the registry for any MIMEType that started with "text/",
     11            instead maintaining it's own hard coded rules
     12
     13        * dom/DOMImplementation.cpp:
     14        (WebCore::DOMImplementation::isTextMIMEType): For now, call through to the MIMETypeRegistry
     15          until we decided a different fate for this function
     16
     17        * platform/MIMETypeRegistry.cpp:
     18        (WebCore::initialiseSupportedNonImageMimeTypes):  "SupportedNonImageMIMETypes" is really a misnomer for
     19          "MIMETypes we should show as HTML" but that line has slowly been blurred since Tiger.  In an attempt
     20          to start to unblur it, remove "text/" and "text/plain"
     21        (WebCore::MIMETypeRegistry::shouldTreatAsText):  The decision is very close to the old DOMImplementation
     22          method, except we don't automatically hand off "text/" types as true if they are in the set of supported
     23          MIMETypes
     24        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): Non-const (can be changed!)
     25        (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Non-const (can be changed!)
     26        (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): Non-const (can be changed!)
     27        * platform/MIMETypeRegistry.h:
     28
    1292007-08-03  Adele Peterson  <adele@apple.com>
    230
  • trunk/WebCore/dom/DOMImplementation.cpp

    r24289 r24866  
    3838#include "ImageDocument.h"
    3939#include "MediaList.h"
     40#include "MIMETypeRegistry.h"
    4041#include "Page.h"
    4142#include "PluginDocument.h"
     
    330331bool DOMImplementation::isTextMIMEType(const String& mimeType)
    331332{
    332     if (mimeType == "application/x-javascript" ||
    333         (mimeType.startsWith("text/") && mimeType != "text/html" &&
    334          mimeType != "text/xml" && mimeType != "text/xsl"))
    335         return true;
    336    
    337     return false;
     333    return MIMETypeRegistry::shouldTreatAsText(mimeType);
    338334}
    339335
  • trunk/WebCore/platform/MIMETypeRegistry.cpp

    r24418 r24866  
    113113      "text/xml",
    114114      "text/xsl",
    115       "text/plain",
    116       "text/",
    117115      "application/x-javascript",
    118116      "application/xml",
     
    187185}
    188186
    189 const HashSet<String> &MIMETypeRegistry::getSupportedImageMIMETypes()
     187bool MIMETypeRegistry::shouldTreatAsText(const String& mimeType)
     188{
     189    return mimeType == "application/x-javascript" || (mimeType.startsWith("text/") && !isSupportedNonImageMIMEType(mimeType));
     190}
     191
     192HashSet<String> &MIMETypeRegistry::getSupportedImageMIMETypes()
    190193{
    191194    if (!supportedImageMIMETypes)
     
    194197}
    195198
    196 const HashSet<String> &MIMETypeRegistry::getSupportedImageResourceMIMETypes()
     199HashSet<String> &MIMETypeRegistry::getSupportedImageResourceMIMETypes()
    197200{
    198201    if (!supportedImageResourceMIMETypes)
     
    201204}
    202205
    203 const HashSet<String> &MIMETypeRegistry::getSupportedNonImageMIMETypes()
     206HashSet<String> &MIMETypeRegistry::getSupportedNonImageMIMETypes()
    204207{
    205208    if (!supportedNonImageMIMETypes)
  • trunk/WebCore/platform/MIMETypeRegistry.h

    r24418 r24866  
    5555    // Check to see if a mime type is a valid Java applet mime type
    5656    static bool isJavaAppletMIMEType(const String& mimeType);
     57   
     58    // Check to see if a mime type should be treated as text
     59    // application/javascript is one that should be even though it doesn't start with text/
     60    // text/html is one that *shouldn't* be by default even though it *does* start with text/
     61    static bool shouldTreatAsText(const String& mimeType);
    5762
    58     static const HashSet<String>& getSupportedImageMIMETypes();
    59     static const HashSet<String>& getSupportedImageResourceMIMETypes();
    60     static const HashSet<String>& getSupportedNonImageMIMETypes();
     63    static HashSet<String>& getSupportedImageMIMETypes();
     64    static HashSet<String>& getSupportedImageResourceMIMETypes();
     65    static HashSet<String>& getSupportedNonImageMIMETypes();
    6166};
    6267
  • trunk/WebKit/ChangeLog

    r24848 r24866  
     12007-08-03  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Oliver
     4
     5        Fix for http://bugs.webkit.org/show_bug.cgi?id=14824 and <rdar://problem/5372989>
     6
     7        When unregistering a MIMEType, remove it from the WebCore registry unconditionally
     8        When registrying a MIMEType whose view class is WebHTMLView, add it to the WebCore registry
     9
     10        * WebView/WebView.mm:
     11        (+[WebView _unregisterViewClassAndRepresentationClassForMIMEType:]):
     12        (+[WebView _registerViewClass:representationClass:forURLScheme:]):
     13        (+[WebView registerViewClass:representationClass:forMIMEType:]):
     14
    1152007-08-03  Timothy Hatcher  <timothy@apple.com>
    216
  • trunk/WebKit/WebView/WebView.mm

    r24827 r24866  
    104104#import <WebCore/HistoryItem.h>
    105105#import <WebCore/Logging.h>
     106#import <WebCore/MIMETypeRegistry.h>
    106107#import <WebCore/Page.h>
    107108#import <WebCore/PageCache.h>
     
    11001101    [[WebFrameView _viewTypesAllowImageTypeOmission:NO] removeObjectForKey:MIMEType];
    11011102    [[WebDataSource _repTypesAllowImageTypeOmission:NO] removeObjectForKey:MIMEType];
     1103   
     1104    // FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
     1105    // in the WebCore MIMEType registry.  For now we're doing this in a safe, limited manner
     1106    // to fix <INSERT RADAR HERE> - a future revamping of the entire system is neccesary for future robustness
     1107    MIMETypeRegistry::getSupportedNonImageMIMETypes().remove(MIMEType);
    11021108}
    11031109
     
    11071113    [self registerViewClass:viewClass representationClass:representationClass forMIMEType:MIMEType];
    11081114
     1115    // FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
     1116    // in the WebCore MIMEType registry.  For now we're doing this in a safe, limited manner
     1117    // to fix <INSERT RADAR HERE> - a future revamping of the entire system is neccesary for future robustness
     1118    if ([viewClass class] == [WebHTMLView class])
     1119        MIMETypeRegistry::getSupportedNonImageMIMETypes().add(MIMEType);
     1120   
    11091121    // This is used to make _representationExistsForURLScheme faster.
    11101122    // Without this set, we'd have to create the MIME type each time.
     
    24892501    [[WebFrameView _viewTypesAllowImageTypeOmission:YES] setObject:viewClass forKey:MIMEType];
    24902502    [[WebDataSource _repTypesAllowImageTypeOmission:YES] setObject:representationClass forKey:MIMEType];
     2503   
     2504    // FIXME: We also need to maintain MIMEType registrations (which can be dynamically changed)
     2505    // in the WebCore MIMEType registry.  For now we're doing this in a safe, limited manner
     2506    // to fix <INSERT RADAR HERE> - a future revamping of the entire system is neccesary for future robustness
     2507    if ([viewClass class] == [WebHTMLView class])
     2508        MIMETypeRegistry::getSupportedNonImageMIMETypes().add(MIMEType);
    24912509}
    24922510
Note: See TracChangeset for help on using the changeset viewer.