summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/WebView
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch)
treed49911209b132da58d838efa852daf28d516df21 /WebKit/mac/WebView
parent87eb0cb35bad8784770ebc807e6c982432e47107 (diff)
downloadexternal_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2
Initial Contribution
Diffstat (limited to 'WebKit/mac/WebView')
-rw-r--r--WebKit/mac/WebView/WebArchiver.mm2
-rw-r--r--WebKit/mac/WebView/WebDataSource.mm42
-rw-r--r--WebKit/mac/WebView/WebDocumentPrivate.h8
-rw-r--r--WebKit/mac/WebView/WebFrame.mm26
-rw-r--r--WebKit/mac/WebView/WebHTMLView.mm11
-rw-r--r--WebKit/mac/WebView/WebPDFView.mm8
-rw-r--r--WebKit/mac/WebView/WebResource.mm5
-rw-r--r--WebKit/mac/WebView/WebResourcePrivate.h2
-rw-r--r--WebKit/mac/WebView/WebView.mm11
9 files changed, 73 insertions, 42 deletions
diff --git a/WebKit/mac/WebView/WebArchiver.mm b/WebKit/mac/WebView/WebArchiver.mm
index 19d5f1c..4c68191 100644
--- a/WebKit/mac/WebView/WebArchiver.mm
+++ b/WebKit/mac/WebView/WebArchiver.mm
@@ -170,7 +170,7 @@ using namespace WebCore;
NSString *iframeMarkup = [[NSString alloc] initWithFormat:@"<iframe frameborder=\"no\" marginwidth=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"%@\"></iframe>", [[[frame _dataSource] response] URL]];
WebResource *iframeResource = [[WebResource alloc] initWithData:[iframeMarkup dataUsingEncoding:NSUTF8StringEncoding]
- URL:blankURL()
+ URL:[NSURL URLWithString:@"about:blank"]
MIMEType:@"text/html"
textEncodingName:@"UTF-8"
frameName:nil];
diff --git a/WebKit/mac/WebView/WebDataSource.mm b/WebKit/mac/WebView/WebDataSource.mm
index 7be4aff..cd033b1 100644
--- a/WebKit/mac/WebView/WebDataSource.mm
+++ b/WebKit/mac/WebView/WebDataSource.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,9 +55,9 @@
#import <WebCore/ResourceRequest.h>
#import <WebCore/SharedBuffer.h>
#import <WebCore/WebCoreObjCExtras.h>
-#import <WebCore/WebCoreURLResponse.h>
#import <WebKit/DOMHTML.h>
#import <WebKit/DOMPrivate.h>
+#import <WebKitSystemInterface.h>
using namespace WebCore;
@@ -135,6 +135,20 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
Class repClass;
return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
}
+
+- (NSString *)_MIMETypeOfResponse:(NSURLResponse *)response
+{
+#ifdef BUILDING_ON_TIGER
+ return [response MIMEType];
+#else
+ // 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)
@@ -175,7 +189,11 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (NSString *)_responseMIMEType
{
- return [[self response] _webcore_MIMEType];
+#ifdef BUILDING_ON_TIGER
+ return [[self response] MIMEType];
+#else
+ return [self _MIMETypeOfResponse:[self response]];
+#endif
}
@end
@@ -301,10 +319,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
// May return nil if not initialized with a URL.
- (NSURL *)_URL
{
- KURL url = _private->loader->url();
- if (url.isEmpty())
- return nil;
- return url;
+ KURL URL = _private->loader->url();
+ return URL.isEmpty() ? nil : URL.getNSURL();
}
- (WebArchive *)_popSubframeArchiveWithName:(NSString *)frameName
@@ -366,7 +382,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
_private->loader = loader;
loader->ref();
- LOG(Loading, "creating datasource for %@", static_cast<NSURL *>(_private->loader->request().url()));
+ LOG(Loading, "creating datasource for %@", _private->loader->request().url().getNSURL());
++WebDataSourceCount;
@@ -460,10 +476,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (NSURL *)unreachableURL
{
- KURL unreachableURL = _private->loader->unreachableURL();
- if (unreachableURL.isEmpty())
- return nil;
- return unreachableURL;
+ KURL URL = _private->loader->unreachableURL();
+ return URL.isEmpty() ? nil : URL.getNSURL();
}
- (WebArchive *)webArchive
@@ -497,7 +511,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];
@@ -513,7 +527,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
diff --git a/WebKit/mac/WebView/WebDocumentPrivate.h b/WebKit/mac/WebView/WebDocumentPrivate.h
index f09d3bd..dff4c03 100644
--- a/WebKit/mac/WebView/WebDocumentPrivate.h
+++ b/WebKit/mac/WebView/WebDocumentPrivate.h
@@ -55,6 +55,14 @@
// The text is all black according to the parameter.
- (NSImage *)selectionImageForcingBlackText:(BOOL)forceBlackText;
+// NSImage of the portion of the selection that's in view. This does not draw backgrounds.
+// The text is all white according to the parameter.
+// NOTE: This method is deprecated. It has been supplanted by selectionImageForcingBlackText:,
+// and implementations typically just call that method, so its name no longer matches its
+// behavior. It will be removed when doing so won't cause trouble for people using the latest
+// WebKit with beta releases of Safari 3.0.
+- (NSImage *)selectionImageForcingWhiteText:(BOOL)forceWhiteText;
+
// Rect tightly enclosing the entire selected area, in coordinates of selectionView.
// NOTE: This method is equivalent to selectionRect and shouldn't be used; use selectionRect instead.
- (NSRect)selectionImageRect;
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index 25c6246..71ac0eb 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -123,7 +123,7 @@ NSString *WebPageCacheDataSourceKey = @"WebPageCacheDataSourceKey";
NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
@interface WebFrame (ForwardDecls)
-- (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL unreachableURL:(NSURL *)unreachableURL;
+- (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL;
- (WebHistoryItem *)_createItem:(BOOL)useOriginal;
- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip;
@end
@@ -766,15 +766,15 @@ static NSURL *createUniqueWebDataURL()
return URL;
}
-- (void)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL unreachableURL:(NSURL *)unreachableURL
+- (void)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL
{
KURL responseURL;
- if (!baseURL) {
- baseURL = blankURL();
+ if (!URL) {
+ URL = [NSURL URLWithString:@"about:blank"];
responseURL = createUniqueWebDataURL();
}
- ResourceRequest request([baseURL absoluteURL]);
+ ResourceRequest request([URL absoluteURL]);
// hack because Mail checks for this property to detect data / archive loads
[NSURLProtocol setProperty:@"" forKey:@"WebDataRequest" inRequest:(NSMutableURLRequest *)request.nsURLRequest()];
@@ -785,27 +785,27 @@ static NSURL *createUniqueWebDataURL()
}
-- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL
+- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL
{
if (!MIMEType)
MIMEType = @"text/html";
- [self _loadData:data MIMEType:MIMEType textEncodingName:encodingName baseURL:baseURL unreachableURL:nil];
+ [self _loadData:data MIMEType:MIMEType textEncodingName:encodingName baseURL:URL unreachableURL:nil];
}
-- (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL unreachableURL:(NSURL *)unreachableURL
+- (void)_loadHTMLString:(NSString *)string baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL
{
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
- [self _loadData:data MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL unreachableURL:unreachableURL];
+ [self _loadData:data MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:URL unreachableURL:unreachableURL];
}
-- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
+- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)URL
{
- [self _loadHTMLString:string baseURL:baseURL unreachableURL:nil];
+ [self _loadHTMLString:string baseURL:URL unreachableURL:nil];
}
-- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL
+- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)URL forUnreachableURL:(NSURL *)unreachableURL
{
- [self _loadHTMLString:string baseURL:baseURL unreachableURL:unreachableURL];
+ [self _loadHTMLString:string baseURL:URL unreachableURL:unreachableURL];
}
- (void)loadArchive:(WebArchive *)archive
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index 485b850..987d7df 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
* (C) 2006, 2007 Graham Dennis (graham.dennis@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
@@ -3110,7 +3110,7 @@ noPromisedData:
KURL imageURL = page->dragController()->draggingImageURL();
ASSERT(!imageURL.isEmpty());
- draggingImageURL = imageURL;
+ draggingImageURL = imageURL.getNSURL();
wrapper = [[self _dataSource] _fileWrapperForURL:draggingImageURL];
}
@@ -5551,6 +5551,13 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
return nil;
}
+- (NSImage *)selectionImageForcingWhiteText:(BOOL)forceWhiteText
+{
+ // NOTE: this method is obsolete and doesn't behave as its name suggests.
+ // See comment in WebDocumentPrivate.h.
+ return [self selectionImageForcingBlackText:forceWhiteText];
+}
+
- (NSRect)selectionImageRect
{
if ([self _hasSelection])
diff --git a/WebKit/mac/WebView/WebPDFView.mm b/WebKit/mac/WebView/WebPDFView.mm
index 0c3da43..630b6de 100644
--- a/WebKit/mac/WebView/WebPDFView.mm
+++ b/WebKit/mac/WebView/WebPDFView.mm
@@ -53,6 +53,7 @@
#import <WebCore/KeyboardEvent.h>
#import <WebCore/MouseEvent.h>
#import <WebCore/PlatformKeyboardEvent.h>
+#import <WebKitSystemInterface.h>
using namespace WebCore;
using namespace EventNames;
@@ -883,6 +884,13 @@ static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selec
return selectionImage;
}
+- (NSImage *)selectionImageForcingWhiteText:(BOOL)forceWhiteText
+{
+ // NOTE: this method is obsolete and doesn't behave as its name suggests.
+ // See comment in WebDocumentPrivate.h.
+ return [self selectionImageForcingBlackText:forceWhiteText];
+}
+
- (NSRect)selectionImageRect
{
// FIXME: deal with clipping?
diff --git a/WebKit/mac/WebView/WebResource.mm b/WebKit/mac/WebView/WebResource.mm
index 9866d39..5f2928d 100644
--- a/WebKit/mac/WebView/WebResource.mm
+++ b/WebKit/mac/WebView/WebResource.mm
@@ -31,7 +31,6 @@
#import "WebFrameBridge.h"
#import "WebNSDictionaryExtras.h"
#import "WebNSURLExtras.h"
-#import <WebCore/WebCoreURLResponse.h>
static NSString * const WebResourceDataKey = @"WebResourceData";
static NSString * const WebResourceFrameNameKey = @"WebResourceFrameName";
@@ -249,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 _webcore_MIMEType]
+ MIMEType:MIMEType
textEncodingName:[response textEncodingName]
frameName:nil
response:response
diff --git a/WebKit/mac/WebView/WebResourcePrivate.h b/WebKit/mac/WebView/WebResourcePrivate.h
index 3a7ee41..34ae701 100644
--- a/WebKit/mac/WebView/WebResourcePrivate.h
+++ b/WebKit/mac/WebView/WebResourcePrivate.h
@@ -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;
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index d259294..f5285f4 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -921,7 +921,7 @@ static bool debugWidget = true;
return needsQuirks;
needsQuirks = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_IE_COMPATIBLE_KEYBOARD_EVENT_DISPATCH)
- && ![[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"];
+ && ![[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"];
checked = YES;
return needsQuirks;
@@ -979,7 +979,6 @@ static bool debugWidget = true;
settings->setUserStyleSheetLocation([NSURL URLWithString:@""]);
settings->setNeedsAdobeFrameReloadingQuirk([self _needsAdobeFrameReloadingQuirk]);
settings->setNeedsKeyboardEventDisambiguationQuirks([self _needsKeyboardEventDisambiguationQuirks]);
- settings->setNeedsSiteSpecificQuirks(_private->useSiteSpecificSpoofing);
}
static inline IMP getMethod(id o, SEL s)
@@ -1454,7 +1453,7 @@ WebFrameLoadDelegateImplementationCache* WebViewGetFrameLoadDelegateImplementati
return usesTestModeFocusRingColor();
}
-// This is only used by versions of Safari up to and including 3.0 and should be removed in a future release.
+// This is only used by older versions of Safari and should be removed in a future release.
+ (NSString *)_minimumRequiredSafariBuildNumber
{
return @"420+";
@@ -4104,11 +4103,7 @@ static NSString *createMacOSXVersionString()
- (NSString *)_userAgentWithApplicationName:(NSString *)applicationName andWebKitVersion:(NSString *)version
{
- // Note: Do *not* move the initialization of osVersion into the declaration.
- // Garbage collection won't correctly mark the global variable in that case <rdar://problem/5733674>.
- static NSString *osVersion;
- if (!osVersion)
- osVersion = createMacOSXVersionString();
+ static NSString *osVersion = createMacOSXVersionString();
NSString *language = [NSUserDefaults _webkit_preferredLanguageCode];
if ([applicationName length])
return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko) %@",