WebCore:
authormitz <mitz@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2007 00:33:19 +0000 (00:33 +0000)
committermitz <mitz@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2007 00:33:19 +0000 (00:33 +0000)
        Reviewed by Adam Roben.

        - fix <rdar://problem/5313523>
        REGRESSION(Leopard): http/tests/incremental/slow-utf8-text.pl fails on Leopard

        * platform/network/mac/ResourceResponseMac.mm:
        (WebCore::ResourceResponse::doUpdateResourceResponse): Work around
        <rdar://problem/5321972> by testing for the case of a response
        with a MIME type of application/octet-stream and a Content-Type header
        starting with text/plain and setting the MIME type to text/plain in
        that case.

WebKit:

        Reviewed by Adam Roben.

        - fix <rdar://problem/5313523>
        REGRESSION(Leopard): http/tests/incremental/slow-utf8-text.pl fails on Leopard

        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::makeDocumentView): Changed to use _responseMIMEType.
        * WebView/WebDataSource.mm:
        (-[WebDataSource _MIMETypeOfResponse:]): Added. Works around
        <rdar://problem/5321972> by testing for the case of an NSHTTPURLResponse
        with a MIMEType of application/octet-stream and a Content-Type header
        starting with text/plain and returning text/plain as the MIME type in
        that case.
        (-[WebDataSource _responseMIMEType]): Added. Used to get the correct
        response MIME type.
        (-[WebDataSource _isDocumentHTML]): Changed to use _responseMIMEType.
        (-[WebDataSource _makeRepresentation]): Ditto.
        (-[WebDataSource mainResource]): Ditto.
        (-[WebDataSource subresources]): Changed to use _MIMETypeOfResponse and
        pass the MIME type explicitly.
        (-[WebDataSource subresourceForURL:]): Ditto.
        * WebView/WebDataSourcePrivate.h:
        * WebView/WebFrameView.mm:
        (-[WebFrameView _makeDocumentViewForDataSource:]): Changed to use
        _responseMIMEType.
        * WebView/WebResource.mm:
        (-[WebResource _initWithData:URL:response:MIMEType:]): Changed this
        method to take a MIME type instead of extracting it from the response,
        so that WebDataSource could pass the correct MIME type.
        * WebView/WebResourcePrivate.h:

WebKitTools:

        Reviewed by Adam Roben.

        - fix <rdar://problem/5313523>
        REGRESSION(Leopard): http/tests/incremental/slow-utf8-text.pl fails on Leopard

        * DumpRenderTree/mac/DumpRenderTree.mm:
        (dump): Changed to use _responseMIMEType.

LayoutTests:

        Reviewed by Adam Roben.

        - removing fixed test

        * platform/mac-leopard/Skipped:

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-leopard/Skipped
WebCore/ChangeLog
WebCore/platform/network/mac/ResourceResponseMac.mm
WebKit/ChangeLog
WebKit/WebCoreSupport/WebFrameLoaderClient.mm
WebKit/WebView/WebDataSource.mm
WebKit/WebView/WebDataSourcePrivate.h
WebKit/WebView/WebFrameView.mm
WebKit/WebView/WebResource.mm
WebKit/WebView/WebResourcePrivate.h
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm

index c28b1d3fbc978b2773453e301333620a7b006817..e18d0f753ed00f217cdb3a9da544c8031a496534 100644 (file)
@@ -1,3 +1,11 @@
+2007-10-18  Dan Bernstein  <dan.bernstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - removing fixed test
+
+        * platform/mac-leopard/Skipped:
+
 2007-10-18  Darin Adler  <darin@apple.com>
 
         Reviewed by Sam.
index 942a028ab45faffc6abc1d2034d406758422ff83..dcb8119cdddf41d80e6574070ab2c1afa5ac87e3 100644 (file)
@@ -1,9 +1,6 @@
 # <rdar://problem/5313520> editing/pasteboard/4076267-2.html fails on Leopard
 editing/pasteboard/4076267-2.html
 
-# <rdar://problem/5313523> http/tests/incremental/slow-utf8-text.pl fails on Leopard
-http/tests/incremental/slow-utf8-text.pl
-
 # <rdar://problem/5228256> Leopard regression test failures: security/block-test
 #security/block-test.html
 
index 60485e5d75e1626e76e0618514103b242abeef8e..5cf703984400d5cb3d9b9fe17099b72abb1eb0bb 100644 (file)
@@ -1,3 +1,17 @@
+2007-10-18  Dan Bernstein  <dan.bernstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - fix <rdar://problem/5313523>
+        REGRESSION(Leopard): http/tests/incremental/slow-utf8-text.pl fails on Leopard
+
+        * platform/network/mac/ResourceResponseMac.mm:
+        (WebCore::ResourceResponse::doUpdateResourceResponse): Work around
+        <rdar://problem/5321972> by testing for the case of a response
+        with a MIME type of application/octet-stream and a Content-Type header
+        starting with text/plain and setting the MIME type to text/plain in
+        that case.
+
 2007-10-18  Mark Rowe  <mrowe@apple.com>
 
         Fix the no-SVG build.
index 7d6c53c79161baa56c54d83841a6e284e022aa27..ea0df93ec3a1ef973bd620281ce2293f547f1fec 100644 (file)
@@ -87,6 +87,15 @@ void ResourceResponse::doUpdateResourceResponse()
         NSEnumerator *e = [headers keyEnumerator];
         while (NSString *name = [e nextObject])
             m_httpHeaderFields.set(name, [headers objectForKey:name]);
+#ifndef BUILDING_ON_TIGER
+        // FIXME: This is part of a workaround for <rdar://problem/5321972> REGRESSION: Plain text document from HTTP server detected
+        // as application/octet-stream
+        if (m_mimeType == "application/octet-stream") {
+            static const String textPlainMIMEType("text/plain");
+            if (m_httpHeaderFields.get("Content-Type").startsWith(textPlainMIMEType))
+                m_mimeType = textPlainMIMEType;
+        }
+#endif
     } else {
         m_httpStatusCode = 0;
 
index 0f18175e52d7df380c810671c1a22cdf29980da2..8670de631c229af32449d54f510f58538067830f 100644 (file)
@@ -1,3 +1,36 @@
+2007-10-18  Dan Bernstein  <dan.bernstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - fix <rdar://problem/5313523>
+        REGRESSION(Leopard): http/tests/incremental/slow-utf8-text.pl fails on Leopard
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::makeDocumentView): Changed to use _responseMIMEType.
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource _MIMETypeOfResponse:]): Added. Works around
+        <rdar://problem/5321972> by testing for the case of an NSHTTPURLResponse
+        with a MIMEType of application/octet-stream and a Content-Type header
+        starting with text/plain and returning text/plain as the MIME type in
+        that case.
+        (-[WebDataSource _responseMIMEType]): Added. Used to get the correct
+        response MIME type.
+        (-[WebDataSource _isDocumentHTML]): Changed to use _responseMIMEType.
+        (-[WebDataSource _makeRepresentation]): Ditto.
+        (-[WebDataSource mainResource]): Ditto.
+        (-[WebDataSource subresources]): Changed to use _MIMETypeOfResponse and
+        pass the MIME type explicitly.
+        (-[WebDataSource subresourceForURL:]): Ditto.
+        * WebView/WebDataSourcePrivate.h:
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView _makeDocumentViewForDataSource:]): Changed to use
+        _responseMIMEType.
+        * WebView/WebResource.mm:
+        (-[WebResource _initWithData:URL:response:MIMEType:]): Changed this
+        method to take a MIME type instead of extracting it from the response,
+        so that WebDataSource could pass the correct MIME type.
+        * WebView/WebResourcePrivate.h:
+
 2007-10-17  Darin Adler  <darin@apple.com>
 
         Reviewed by Mark Rowe.
index ed6c76d4b5e870b1ff84e876d2a3969ab2fa9e96..2db84f939e2cd00a44c804197c1da8eb83eb8337 100644 (file)
@@ -156,7 +156,7 @@ void WebFrameLoaderClient::makeDocumentView()
     WebFrameView *v = m_webFrame->_private->webFrameView;
     WebDataSource *ds = [m_webFrame.get() _dataSource];
 
-    bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[[ds response] MIMEType]] == [WebHTMLView class];
+    bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[ds _responseMIMEType]] == [WebHTMLView class];
     bool canSkipCreation = [m_webFrame.get() _frameLoader]->committingFirstRealLoad() && willProduceHTMLView;
     if (canSkipCreation) {
         [[v documentView] setDataSource:ds];
index a90b1fc6748e63d54f978af24d585dde353374e2..0fea36d14d26f2bcefbae92aa4887fc54c7e80f6 100644 (file)
@@ -136,6 +136,17 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
 }
 
+#ifndef BUILDING_ON_TIGER
+- (NSString *)_MIMETypeOfResponse:(NSURLResponse *)response
+{
+    // FIXME: This is part of a workaround for <rdar://problem/5321972> REGRESSION: Plain text document from HTTP server detected
+    // as application/octet-stream
+    NSString *MIMEType = [response MIMEType];
+    if ([MIMEType isEqualToString:@"application/octet-stream"] && [response isKindOfClass:[NSHTTPURLResponse class]] && [[[(NSHTTPURLResponse *)response allHeaderFields] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"])
+        return @"text/plain";
+    return MIMEType;
+}
+#endif
 @end
 
 @implementation WebDataSource (WebPrivate)
@@ -174,6 +185,15 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     return nil;
 }
 
+- (NSString *)_responseMIMEType
+{
+#ifdef BUILDING_ON_TIGER
+    return [[self response] MIMEType];
+#else
+    return [self _MIMETypeOfResponse:[self response]];
+#endif
+}
+
 @end
 
 @implementation WebDataSource (WebInternal)
@@ -319,13 +339,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 - (BOOL)_isDocumentHTML
 {
-    NSString *MIMEType = [[self response] MIMEType];
+    NSString *MIMEType = [self _responseMIMEType];
     return [WebView canShowMIMETypeAsHTML:MIMEType];
 }
 
 -(void)_makeRepresentation
 {
-    Class repClass = [[self class] _representationClassForMIMEType:[[self response] MIMEType]];
+    Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType]];
     
     // Check if the data source was already bound?
     if (![[self representation] isKindOfClass:repClass]) {
@@ -471,7 +491,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     NSURLResponse *response = [self response];
     return [[[WebResource alloc] initWithData:[self data]
                                           URL:[response URL] 
-                                     MIMEType:[response MIMEType]
+                                     MIMEType:[self _responseMIMEType]
                              textEncodingName:[response textEncodingName]
                                     frameName:[[self webFrame] name]] autorelease];
 }
@@ -489,7 +509,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     NSMutableArray *subresources = [[NSMutableArray alloc] initWithCapacity:[datas count]];
     for (unsigned i = 0; i < [datas count]; ++i) {
         NSURLResponse *response = [responses objectAtIndex:i];
-        [subresources addObject:[[[WebResource alloc] _initWithData:[datas objectAtIndex:i] URL:[response URL] response:response] autorelease]];
+        [subresources addObject:[[[WebResource alloc] _initWithData:[datas objectAtIndex:i] URL:[response URL] response:response MIMEType:[self _MIMETypeOfResponse:response]] autorelease]];
     }
 
     return [subresources autorelease];
@@ -505,7 +525,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     if (![[self _bridge] getData:&data andResponse:&response forURL:[URL _web_originalDataAsString]])
         return [self _archivedSubresourceForURL:URL];
 
-    return [[[WebResource alloc] _initWithData:data URL:URL response:response] autorelease];
+    return [[[WebResource alloc] _initWithData:data URL:URL response:response MIMEType:[self _MIMETypeOfResponse:response]] autorelease];
 }
 
 - (void)addSubresource:(WebResource *)subresource
index 02130e17d61d74498cde625cef1a844783b77e55..a394b535fd89db7d9e99e9e1a95a90a806a8f630 100644 (file)
@@ -35,4 +35,6 @@
 - (void)_addSubframeArchives:(NSArray *) archives;
 
 - (NSError *)_mainDocumentError;
+
+- (NSString *)_responseMIMEType;
 @end
index 969e92535ea443bd763889d4e461becc4f79e600..35f8c9ab88a3c5a4558b09238742777361f1997c 100644 (file)
@@ -29,7 +29,7 @@
 #import "WebFrameView.h"
 
 #import "WebClipView.h"
-#import "WebDataSource.h"
+#import "WebDataSourcePrivate.h"
 #import "WebDocument.h"
 #import "WebDynamicScrollBarsView.h"
 #import "WebFrame.h"
@@ -187,7 +187,7 @@ enum {
 
 -(NSView <WebDocumentView> *)_makeDocumentViewForDataSource:(WebDataSource *)dataSource
 {
-    NSString* MIMEType = [[dataSource response] MIMEType];
+    NSString* MIMEType = [dataSource _responseMIMEType];
     if (!MIMEType)
         MIMEType = @"text/html";
     Class viewClass = [[self class] _viewClassForMIMEType:MIMEType];
index e2b070c6b768ed9f2c25fa5799440f11a6af8fb0..5f2928d78351d21520559dcf1d4415e7057f56c4 100644 (file)
@@ -248,13 +248,13 @@ static NSString * const WebResourceResponseKey =          @"WebResourceResponse"
     return self;
 }
 
-- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response
+- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response MIMEType:(NSString *)MIMEType
 {
     // Pass NO for copyData since the data doesn't need to be copied since we know that callers will no longer modify it.
     // Copying it will also cause a performance regression.
     return [self _initWithData:data
                            URL:URL
-                      MIMEType:[response MIMEType]
+                      MIMEType:MIMEType
               textEncodingName:[response textEncodingName]
                      frameName:nil
                       response:response
index 3a7ee41675bfbe046e868ad291762ec6cb1b3faa..34ae70155586ea9b0c3d0d04601d046c78c15a63 100644 (file)
@@ -38,7 +38,7 @@
            response:(NSURLResponse *)response
            copyData:(BOOL)copyData;
 
-- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response;
+- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response MIMEType:(NSString *)MIMEType;
 
 - (BOOL)_shouldIgnoreWhenUnarchiving;
 - (void)_ignoreWhenUnarchiving;
index 077fe15970c2bc80f026bac48bff612d1104c19e..9126356da6c3d710220ae53186fb72b73a060281 100644 (file)
@@ -1,3 +1,13 @@
+2007-10-18  Dan Bernstein  <dan.bernstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - fix <rdar://problem/5313523>
+        REGRESSION(Leopard): http/tests/incremental/slow-utf8-text.pl fails on Leopard
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (dump): Changed to use _responseMIMEType.
+
 2007-10-17  Adam Roben  <aroben@apple.com>
 
         Make it possible to have Windows-specific tests and results
index 7cf45b7eabed8db53f8e10e7efbe2091627b8470..e117519db35f6e29ac161ca8db82edd4b9e1ee1f 100644 (file)
@@ -51,7 +51,7 @@
 #import <WebKit/DOMRange.h>
 #import <WebKit/WebBackForwardList.h>
 #import <WebKit/WebCoreStatistics.h>
-#import <WebKit/WebDataSource.h>
+#import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDocumentPrivate.h>
 #import <WebKit/WebEditingDelegate.h>
 #import <WebKit/WebFrameView.h>
@@ -840,7 +840,7 @@ void dump()
         NSString *result = nil;
         
         bool dumpAsText = layoutTestController->dumpAsText();
-        dumpAsText |= [[[[mainFrame dataSource] response] MIMEType] isEqualToString:@"text/plain"];
+        dumpAsText |= [[[mainFrame dataSource] _responseMIMEType] isEqualToString:@"text/plain"];
         layoutTestController->setDumpAsText(dumpAsText);
         if (layoutTestController->dumpAsText()) {
             result = dumpFramesAsText(mainFrame);