summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/Misc
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/Misc')
-rw-r--r--WebKit/mac/Misc/WebCache.mm6
-rw-r--r--WebKit/mac/Misc/WebCoreStatistics.h4
-rw-r--r--WebKit/mac/Misc/WebCoreStatistics.mm34
-rw-r--r--WebKit/mac/Misc/WebDownload.mm (renamed from WebKit/mac/Misc/WebDownload.m)21
-rw-r--r--WebKit/mac/Misc/WebElementDictionary.mm7
-rw-r--r--WebKit/mac/Misc/WebGraphicsExtras.c57
-rw-r--r--WebKit/mac/Misc/WebGraphicsExtras.h37
-rw-r--r--WebKit/mac/Misc/WebIconDatabase.mm13
-rw-r--r--WebKit/mac/Misc/WebKitErrors.m4
-rw-r--r--WebKit/mac/Misc/WebKitNSStringExtras.h2
-rw-r--r--WebKit/mac/Misc/WebKitNSStringExtras.mm (renamed from WebKit/mac/Misc/WebKitNSStringExtras.m)103
-rw-r--r--WebKit/mac/Misc/WebKitVersionChecks.h3
-rw-r--r--WebKit/mac/Misc/WebNSAttributedStringExtras.mm2
-rw-r--r--WebKit/mac/Misc/WebNSFileManagerExtras.h2
-rw-r--r--WebKit/mac/Misc/WebNSFileManagerExtras.m16
-rw-r--r--WebKit/mac/Misc/WebNSObjectExtras.mm40
-rw-r--r--WebKit/mac/Misc/WebNSPasteboardExtras.mm8
-rw-r--r--WebKit/mac/Misc/WebNSURLExtras.mm10
-rw-r--r--WebKit/mac/Misc/WebStringTruncator.mm (renamed from WebKit/mac/Misc/WebStringTruncator.m)0
19 files changed, 205 insertions, 164 deletions
diff --git a/WebKit/mac/Misc/WebCache.mm b/WebKit/mac/Misc/WebCache.mm
index 46fb341..6013a5f 100644
--- a/WebKit/mac/Misc/WebCache.mm
+++ b/WebKit/mac/Misc/WebCache.mm
@@ -26,6 +26,7 @@
#import "WebCache.h"
#import "WebPreferences.h"
+#import "WebSystemInterface.h"
#import "WebView.h"
#import "WebViewInternal.h"
#import <WebCore/ApplicationCacheStorage.h>
@@ -34,6 +35,11 @@
@implementation WebCache
++ (void)initialize
+{
+ InitWebCoreSystemInterface();
+}
+
+ (NSArray *)statistics
{
WebCore::Cache::Statistics s = WebCore::cache()->getStatistics();
diff --git a/WebKit/mac/Misc/WebCoreStatistics.h b/WebKit/mac/Misc/WebCoreStatistics.h
index a7f3fa5..d4370bf 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.h
+++ b/WebKit/mac/Misc/WebCoreStatistics.h
@@ -64,6 +64,10 @@
+ (NSDictionary *)memoryStatistics;
+ (void)returnFreeMemoryToSystem;
++ (int)cachedPageCount;
++ (int)cachedFrameCount;
++ (int)autoreleasedPageCount;
+
// Deprecated, but used by older versions of Safari.
+ (void)emptyCache;
+ (void)setCacheDisabled:(BOOL)disabled;
diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm
index 2fe5710..57b59a4 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.mm
+++ b/WebKit/mac/Misc/WebCoreStatistics.mm
@@ -38,6 +38,7 @@
#import <WebCore/GlyphPageTreeNode.h>
#import <WebCore/IconDatabase.h>
#import <WebCore/JSDOMWindow.h>
+#import <WebCore/PageCache.h>
#import <WebCore/RenderTreeAsText.h>
#import <WebCore/RenderView.h>
@@ -53,31 +54,31 @@ using namespace WebCore;
+ (size_t)javaScriptObjectsCount
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
return JSDOMWindow::commonJSGlobalData()->heap.objectCount();
}
+ (size_t)javaScriptGlobalObjectsCount
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
return JSDOMWindow::commonJSGlobalData()->heap.globalObjectCount();
}
+ (size_t)javaScriptProtectedObjectsCount
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
return JSDOMWindow::commonJSGlobalData()->heap.protectedObjectCount();
}
+ (size_t)javaScriptProtectedGlobalObjectsCount
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
return JSDOMWindow::commonJSGlobalData()->heap.protectedGlobalObjectCount();
}
+ (NSCountedSet *)javaScriptProtectedObjectTypeCounts
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
NSCountedSet *result = [NSCountedSet set];
@@ -142,13 +143,13 @@ using namespace WebCore;
+ (BOOL)shouldPrintExceptions
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
return Console::shouldPrintExceptions();
}
+ (void)setShouldPrintExceptions:(BOOL)print
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
Console::setShouldPrintExceptions(print);
}
@@ -175,7 +176,7 @@ using namespace WebCore;
+ (NSDictionary *)memoryStatistics
{
WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
Heap::Statistics jsHeapStatistics = JSDOMWindow::commonJSGlobalData()->heap.statistics();
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:fastMallocStatistics.heapSize], @"FastMallocHeapSize",
@@ -192,6 +193,21 @@ using namespace WebCore;
WTF::releaseFastMallocFreeMemory();
}
++ (int)cachedPageCount
+{
+ return pageCache()->pageCount();
+}
+
++ (int)cachedFrameCount
+{
+ return pageCache()->frameCount();
+}
+
++ (int)autoreleasedPageCount
+{
+ return pageCache()->autoreleasedPageCount();
+}
+
// Deprecated
+ (size_t)javaScriptNoGCAllowedObjectsCount
{
@@ -200,7 +216,7 @@ using namespace WebCore;
+ (size_t)javaScriptReferencedObjectsCount
{
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
return JSDOMWindow::commonJSGlobalData()->heap.protectedObjectCount();
}
diff --git a/WebKit/mac/Misc/WebDownload.m b/WebKit/mac/Misc/WebDownload.mm
index 2c53c1b..978465a 100644
--- a/WebKit/mac/Misc/WebDownload.m
+++ b/WebKit/mac/Misc/WebDownload.mm
@@ -30,11 +30,14 @@
#import <Foundation/NSURLAuthenticationChallenge.h>
#import <Foundation/NSURLDownload.h>
+#import <WebCore/AuthenticationMac.h>
#import <WebKit/WebPanelAuthenticationHandler.h>
#import <wtf/Assertions.h>
#import "WebTypesInternal.h"
+using namespace WebCore;
+
@class NSURLConnectionDelegateProxy;
// FIXME: The following are NSURLDownload SPI - it would be nice to not have to override them at
@@ -96,9 +99,6 @@
- (void)downloadDidBegin:(NSURLDownload *)download
{
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
- [[NSProcessInfo processInfo] disableSuddenTermination];
-#endif
[realDelegate downloadDidBegin:download];
}
@@ -109,6 +109,15 @@
- (void)download:(NSURLDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
+ // Try previously stored credential first.
+ if (![challenge previousFailureCount]) {
+ NSURLCredential *credential = WebCoreCredentialStorage::get([challenge protectionSpace]);
+ if (credential) {
+ [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
+ return;
+ }
+ }
+
if ([realDelegate respondsToSelector:@selector(download:didReceiveAuthenticationChallenge:)]) {
[realDelegate download:download didReceiveAuthenticationChallenge:challenge];
} else {
@@ -157,17 +166,11 @@
- (void)downloadDidFinish:(NSURLDownload *)download
{
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
- [[NSProcessInfo processInfo] enableSuddenTermination];
-#endif
[realDelegate downloadDidFinish:download];
}
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
-#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
- [[NSProcessInfo processInfo] enableSuddenTermination];
-#endif
[realDelegate download:download didFailWithError:error];
}
diff --git a/WebKit/mac/Misc/WebElementDictionary.mm b/WebKit/mac/Misc/WebElementDictionary.mm
index db7b5f4..aa703e0 100644
--- a/WebKit/mac/Misc/WebElementDictionary.mm
+++ b/WebKit/mac/Misc/WebElementDictionary.mm
@@ -28,6 +28,7 @@
#import "WebElementDictionary.h"
+#import "DOMNodeInternal.h"
#import "WebDOMOperations.h"
#import "WebFrame.h"
#import "WebFrameInternal.h"
@@ -191,7 +192,8 @@ static NSString* NSStringOrNil(String coreString)
- (NSString *)_spellingToolTip
{
- return NSStringOrNil(_result->spellingToolTip());
+ TextDirection dir;
+ return NSStringOrNil(_result->spellingToolTip(dir));
}
- (NSImage *)_image
@@ -218,7 +220,8 @@ static NSString* NSStringOrNil(String coreString)
- (NSString *)_title
{
- return NSStringOrNil(_result->title());
+ TextDirection dir;
+ return NSStringOrNil(_result->title(dir));
}
- (NSURL *)_absoluteLinkURL
diff --git a/WebKit/mac/Misc/WebGraphicsExtras.c b/WebKit/mac/Misc/WebGraphicsExtras.c
deleted file mode 100644
index 4d36b58..0000000
--- a/WebKit/mac/Misc/WebGraphicsExtras.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebGraphicsExtras.h"
-
-#import <Accelerate/Accelerate.h>
-#import <dlfcn.h>
-#import <wtf/Assertions.h>
-
-unsigned WebConvertBGRAToARGB(unsigned char *offscreenBuffer, int rowBytes, int x, int y, int width, int height)
-{
-
- static vImage_Error (*softLink_vImagePermuteChannels_ARGB8888)(const vImage_Buffer *src, const vImage_Buffer *dest, const uint8_t permuteMap[4], vImage_Flags flags) = NULL;
-
- if (!softLink_vImagePermuteChannels_ARGB8888) {
- void *framework = dlopen("/System/Library/Frameworks/Accelerate.framework/Accelerate", RTLD_NOW);
- ASSERT(framework);
- softLink_vImagePermuteChannels_ARGB8888 = dlsym(framework, "vImagePermuteChannels_ARGB8888");
- ASSERT(softLink_vImagePermuteChannels_ARGB8888);
- }
-
- void *swizzleImageBase = offscreenBuffer + y * rowBytes + x * 4;
- vImage_Buffer vImage = { swizzleImageBase, height, width, rowBytes };
- uint8_t vImagePermuteMap[4] = { 3, 2, 1, 0 }; // Where { 0, 1, 2, 3 } would leave the channels unchanged; this map converts BGRA to ARGB
- vImage_Error vImageError = softLink_vImagePermuteChannels_ARGB8888(&vImage, &vImage, vImagePermuteMap, 0);
- if (vImageError) {
- LOG_ERROR("Could not convert BGRA image to ARGB: %zd", vImageError);
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/WebKit/mac/Misc/WebGraphicsExtras.h b/WebKit/mac/Misc/WebGraphicsExtras.h
deleted file mode 100644
index 9232303..0000000
--- a/WebKit/mac/Misc/WebGraphicsExtras.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-unsigned WebConvertBGRAToARGB(unsigned char *offscreenBuffer, int rowBytes, int x, int y, int width, int height);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/WebKit/mac/Misc/WebIconDatabase.mm b/WebKit/mac/Misc/WebIconDatabase.mm
index d4df14b..62c8e2f 100644
--- a/WebKit/mac/Misc/WebIconDatabase.mm
+++ b/WebKit/mac/Misc/WebIconDatabase.mm
@@ -65,8 +65,12 @@ NSSize WebIconLargeSize = {128, 128};
static WebIconDatabaseClient* defaultClient()
{
+#if ENABLE(ICONDATABASE)
static WebIconDatabaseClient* defaultClient = new WebIconDatabaseClient();
return defaultClient;
+#else
+ return 0;
+#endif
}
@interface WebIconDatabase (WebReallyInternal)
@@ -584,6 +588,8 @@ bool importToWebCoreFormat()
// here because this code is only executed once for each icon database instance. We could
// make this configurable on a per-client basis someday if that seemed useful.
// See <rdar://problem/5320208>.
+ // FIXME: This has nothing to do with importing from the old to the new database format and should be moved elsewhere,
+ // especially because we might eventually delete all of this legacy importing code and we shouldn't delete this.
CFStringRef databasePath = iconDatabase()->databasePath().createCFString();
if (databasePath) {
CFURLRef databasePathURL = CFURLCreateWithFileSystemPath(0, databasePath, kCFURLPOSIXPathStyle, FALSE);
@@ -614,6 +620,13 @@ bool importToWebCoreFormat()
if (![pageURLToIconURL isKindOfClass:[NSMutableDictionary class]])
pageURLToIconURL = nil;
+ if (!pageURLToIconURL) {
+ // We found no Safari-2-style icon database. Bail out immediately and do not delete everything
+ // in whatever directory we ended up looking in! Return true so we won't bother to check again.
+ // FIXME: We can probably delete all of the code to convert Safari-2-style icon databases now.
+ return true;
+ }
+
NSEnumerator *enumerator = [pageURLToIconURL keyEnumerator];
NSString *url, *iconURL;
diff --git a/WebKit/mac/Misc/WebKitErrors.m b/WebKit/mac/Misc/WebKitErrors.m
index 5985d9a..ec42dc9 100644
--- a/WebKit/mac/Misc/WebKitErrors.m
+++ b/WebKit/mac/Misc/WebKitErrors.m
@@ -106,6 +106,10 @@ static NSMutableDictionary *descriptions = nil;
[[self class] _registerWebKitErrors];
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
+ NSDictionary *descriptionsForWebKitErrorDomain = [descriptions objectForKey:WebKitErrorDomain];
+ NSString *localizedDescription = [descriptionsForWebKitErrorDomain objectForKey:[NSNumber numberWithInt:code]];
+ if (localizedDescription)
+ [userInfo setObject:localizedDescription forKey:NSLocalizedDescriptionKey];
if (contentURL) {
[userInfo setObject:contentURL forKey:@"NSErrorFailingURLKey"];
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
diff --git a/WebKit/mac/Misc/WebKitNSStringExtras.h b/WebKit/mac/Misc/WebKitNSStringExtras.h
index 47056c6..f252430 100644
--- a/WebKit/mac/Misc/WebKitNSStringExtras.h
+++ b/WebKit/mac/Misc/WebKitNSStringExtras.h
@@ -28,6 +28,8 @@
#import <Cocoa/Cocoa.h>
+extern NSString *WebKitLocalCacheDefaultsKey;
+
@interface NSString (WebKitExtras)
- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor;
diff --git a/WebKit/mac/Misc/WebKitNSStringExtras.m b/WebKit/mac/Misc/WebKitNSStringExtras.mm
index f3077d3..5eb3e1f 100644
--- a/WebKit/mac/Misc/WebKitNSStringExtras.m
+++ b/WebKit/mac/Misc/WebKitNSStringExtras.mm
@@ -28,15 +28,25 @@
#import "WebKitNSStringExtras.h"
-#import <WebKit/WebNSObjectExtras.h>
-#import <WebKit/WebNSFileManagerExtras.h>
-
+#import <WebCore/Font.h>
+#import <WebCore/GraphicsContext.h>
#import <WebCore/WebCoreNSStringExtras.h>
-#import <WebCore/WebCoreTextRenderer.h>
-
+#import <WebKit/WebNSFileManagerExtras.h>
+#import <WebKit/WebNSObjectExtras.h>
#import <unicode/uchar.h>
#import <sys/param.h>
+NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
+
+static inline CGFloat webkit_CGCeiling(CGFloat value)
+{
+ if (sizeof(value) == sizeof(float))
+ return ceilf(value);
+ return ceil(value);
+}
+
+using namespace WebCore;
+
@implementation NSString (WebKitExtras)
static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
@@ -54,28 +64,50 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
{
// FIXME: Would be more efficient to change this to C++ and use Vector<UChar, 2048>.
unsigned length = [self length];
- UniChar *buffer = malloc(sizeof(UniChar) * length);
+ Vector<UniChar, 2048> buffer(length);
- [self getCharacters:buffer];
+ [self getCharacters:buffer.data()];
- if (canUseFastRenderer(buffer, length)) {
+ if (canUseFastRenderer(buffer.data(), length)) {
// The following is a half-assed attempt to match AppKit's rounding rules for drawAtPoint.
// It's probably incorrect for high DPI.
// If you change this, be sure to test all the text drawn this way in Safari, including
// the status bar, bookmarks bar, tab bar, and activity window.
- point.y = ceilf(point.y);
- WebCoreDrawTextAtPoint(buffer, length, point, font, textColor);
+ point.y = webkit_CGCeiling(point.y);
+
+ NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
+ CGContextRef cgContext = static_cast<CGContextRef>([nsContext graphicsPort]);
+ GraphicsContext graphicsContext(cgContext);
+
+ // Safari doesn't flip the NSGraphicsContext before calling WebKit, yet WebCore requires a flipped graphics context.
+ BOOL flipped = [nsContext isFlipped];
+ if (!flipped)
+ CGContextScaleCTM(cgContext, 1, -1);
+
+ Font webCoreFont(FontPlatformData(font), ![nsContext isDrawingToScreen]);
+ TextRun run(buffer.data(), length);
+ run.disableRoundingHacks();
+
+ CGFloat red;
+ CGFloat green;
+ CGFloat blue;
+ CGFloat alpha;
+ [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
+ graphicsContext.setFillColor(makeRGBA(red * 255, green * 255, blue * 255, alpha * 255));
+
+ webCoreFont.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1 * point.y))));
+
+ if (!flipped)
+ CGContextScaleCTM(cgContext, 1, -1);
} else {
- // WebTextRenderer assumes drawing from baseline.
+ // The given point is on the baseline.
if ([[NSView focusView] isFlipped])
point.y -= [font ascender];
- else {
+ else
point.y += [font descender];
- }
+
[self drawAtPoint:point withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, textColor, NSForegroundColorAttributeName, nil]];
}
-
- free(buffer);
}
- (void)_web_drawDoubledAtPoint:(NSPoint)textPoint
@@ -85,7 +117,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
{
// turn off font smoothing so translucent text draws correctly (Radar 3118455)
[NSGraphicsContext saveGraphicsState];
- CGContextSetShouldSmoothFonts([[NSGraphicsContext currentContext] graphicsPort], false);
+ CGContextSetShouldSmoothFonts(static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), false);
[self _web_drawAtPoint:textPoint
font:font
textColor:bottomColor];
@@ -100,19 +132,18 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
- (float)_web_widthWithFont:(NSFont *)font
{
unsigned length = [self length];
- float width;
- UniChar *buffer = (UniChar *)malloc(sizeof(UniChar) * length);
+ Vector<UniChar, 2048> buffer(length);
- [self getCharacters:buffer];
+ [self getCharacters:buffer.data()];
- if (canUseFastRenderer(buffer, length))
- width = WebCoreTextFloatWidth(buffer, length, font);
- else
- width = [self sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]].width;
-
- free(buffer);
-
- return width;
+ if (canUseFastRenderer(buffer.data(), length)) {
+ Font webCoreFont(FontPlatformData(font), ![[NSGraphicsContext currentContext] isDrawingToScreen]);
+ TextRun run(buffer.data(), length);
+ run.disableRoundingHacks();
+ return webCoreFont.floatWidth(run);
+ }
+
+ return [self sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]].width;
}
- (NSString *)_web_stringByAbbreviatingWithTildeInPath
@@ -295,20 +326,22 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
+ (NSString *)_webkit_localCacheDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier
{
- NSString* cacheDir = nil;
-
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSString *cacheDir = [defaults objectForKey:WebKitLocalCacheDefaultsKey];
+
+ if (!cacheDir || ![cacheDir isKindOfClass:[NSString class]]) {
#ifdef BUILDING_ON_TIGER
- cacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
+ cacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
#else
- char cacheDirectory[MAXPATHLEN];
- size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
+ char cacheDirectory[MAXPATHLEN];
+ size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
- if (cacheDirectoryLen)
- cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
+ if (cacheDirectoryLen)
+ cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
#endif
+ }
return [cacheDir stringByAppendingPathComponent:bundleIdentifier];
}
-
@end
diff --git a/WebKit/mac/Misc/WebKitVersionChecks.h b/WebKit/mac/Misc/WebKitVersionChecks.h
index 169b4cf..8b34c94 100644
--- a/WebKit/mac/Misc/WebKitVersionChecks.h
+++ b/WebKit/mac/Misc/WebKitVersionChecks.h
@@ -51,6 +51,9 @@
#define WEBKIT_FIRST_VERSION_WITH_RELOAD_FROM_ORIGIN 0x02100700 // 528.7.0
#define WEBKIT_FIRST_VERSION_WITHOUT_WEBVIEW_INIT_THREAD_WORKAROUND 0x02100700 // 528.7.0
#define WEBKIT_FIRST_VERSION_WITH_ROUND_TWO_MAIN_THREAD_EXCEPTIONS 0x02120400 // 530.4.0
+#define WEBKIT_FIRST_VERSION_WITHOUT_BUMPERCAR_BACK_FORWARD_QUIRK 0x02120700 // 530.7.0
+#define WEBKIT_FIRST_VERSION_WITHOUT_CONTENT_SNIFFING_FOR_FILE_URLS 0x02120A00 // 530.10.0
+#define WEBKIT_FIRST_VERSION_WITHOUT_LINK_ELEMENT_TEXT_CSS_QUIRK 0x02130200 // 531.2.0
#ifdef __cplusplus
extern "C" {
diff --git a/WebKit/mac/Misc/WebNSAttributedStringExtras.mm b/WebKit/mac/Misc/WebNSAttributedStringExtras.mm
index ef472aa..eb422f1 100644
--- a/WebKit/mac/Misc/WebNSAttributedStringExtras.mm
+++ b/WebKit/mac/Misc/WebNSAttributedStringExtras.mm
@@ -72,7 +72,7 @@ static NSFileWrapper *fileWrapperForElement(Element* e)
wrapper = [[kit(e->document()->frame()) _dataSource] _fileWrapperForURL:URL];
}
if (!wrapper) {
- RenderImage* renderer = static_cast<RenderImage*>(e->renderer());
+ RenderImage* renderer = toRenderImage(e->renderer());
if (renderer->cachedImage() && !renderer->cachedImage()->errorOccurred()) {
wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)(renderer->cachedImage()->image()->getTIFFRepresentation())];
[wrapper setPreferredFilename:@"image.tiff"];
diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.h b/WebKit/mac/Misc/WebNSFileManagerExtras.h
index d6e26ee..c2287f9 100644
--- a/WebKit/mac/Misc/WebNSFileManagerExtras.h
+++ b/WebKit/mac/Misc/WebNSFileManagerExtras.h
@@ -50,5 +50,7 @@
- (BOOL)moveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error;
- (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)error;
- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)path error:(NSError **)error;
+- (NSString *)destinationOfSymbolicLinkAtPath:(NSString *)path error:(NSError **)error;
+- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error;
@end
#endif
diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.m b/WebKit/mac/Misc/WebNSFileManagerExtras.m
index f32b4c0..5733598 100644
--- a/WebKit/mac/Misc/WebNSFileManagerExtras.m
+++ b/WebKit/mac/Misc/WebNSFileManagerExtras.m
@@ -246,6 +246,14 @@ static void *setMetaData(void* context)
return [self directoryContentsAtPath:path];
}
+- (NSString *)destinationOfSymbolicLinkAtPath:(NSString *)path error:(NSError **)error
+{
+ // We don't report errors via the NSError* output parameter, so ensure that the caller does not expect us to do so.
+ ASSERT_ARG(error, !error);
+
+ return [self pathContentOfSymbolicLinkAtPath:path];
+}
+
- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)path error:(NSError **)error
{
// We don't report errors via the NSError* output parameter, so ensure that the caller does not expect us to do so.
@@ -254,6 +262,14 @@ static void *setMetaData(void* context)
return [self fileSystemAttributesAtPath:path];
}
+- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error
+{
+ // We don't report errors via the NSError* output parameter, so ensure that the caller does not expect us to do so.
+ ASSERT_ARG(error, !error);
+
+ return [self fileAttributesAtPath:path traverseLink:NO];
+}
+
- (BOOL)moveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
{
// The implementation of moveItemAtPath:toPath:error: interacts with the NSFileManager's delegate.
diff --git a/WebKit/mac/Misc/WebNSObjectExtras.mm b/WebKit/mac/Misc/WebNSObjectExtras.mm
index 2d682b9..3beb641 100644
--- a/WebKit/mac/Misc/WebNSObjectExtras.mm
+++ b/WebKit/mac/Misc/WebNSObjectExtras.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,6 +28,7 @@
#import "WebNSObjectExtras.h"
+#import <wtf/Assertions.h>
@interface WebMainThreadInvoker : NSProxy
{
@@ -36,23 +37,35 @@
}
@end
+static bool returnTypeIsObject(NSInvocation *invocation)
+{
+ // Could use either _C_ID or NSObjCObjectType, but it seems that neither is
+ // both available and non-deprecated on all versions of Mac OS X we support.
+ return strchr([[invocation methodSignature] methodReturnType], '@');
+}
+
@implementation WebMainThreadInvoker
-- (id)initWithTarget:(id)theTarget
+- (id)initWithTarget:(id)passedTarget
{
- target = theTarget;
+ target = passedTarget;
return self;
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
[invocation setTarget:target];
- [invocation retainArguments];
[invocation performSelectorOnMainThread:@selector(_webkit_invokeAndHandleException:) withObject:self waitUntilDone:YES];
if (exception) {
id exceptionToThrow = [exception autorelease];
exception = nil;
@throw exceptionToThrow;
+ } else if (returnTypeIsObject(invocation)) {
+ // _webkit_invokeAndHandleException retained the return value on the main thread.
+ // Now autorelease it on the calling thread.
+ id returnValue;
+ [invocation getReturnValue:&returnValue];
+ [returnValue autorelease];
}
}
@@ -61,28 +74,35 @@
return [target methodSignatureForSelector:selector];
}
-- (void)handleException:(id)e
+- (void)handleException:(id)passedException
{
- exception = [e retain];
+ ASSERT(!exception);
+ exception = [passedException retain];
}
@end
-
@implementation NSInvocation (WebMainThreadInvoker)
- (void)_webkit_invokeAndHandleException:(WebMainThreadInvoker *)exceptionHandler
{
@try {
[self invoke];
- } @catch (id e) {
- [exceptionHandler handleException:e];
+ } @catch (id exception) {
+ [exceptionHandler handleException:exception];
+ return;
+ }
+ if (returnTypeIsObject(self)) {
+ // Retain the return value on the main thread.
+ // -[WebMainThreadInvoker forwardInvocation:] will autorelease it on the calling thread.
+ id value;
+ [self getReturnValue:&value];
+ [value retain];
}
}
@end
-
@implementation NSObject (WebNSObjectExtras)
- (id)_webkit_invokeOnMainThread
diff --git a/WebKit/mac/Misc/WebNSPasteboardExtras.mm b/WebKit/mac/Misc/WebNSPasteboardExtras.mm
index 34c39dd..3cc1c7c 100644
--- a/WebKit/mac/Misc/WebNSPasteboardExtras.mm
+++ b/WebKit/mac/Misc/WebNSPasteboardExtras.mm
@@ -28,6 +28,7 @@
#import "WebNSPasteboardExtras.h"
+#import "DOMElementInternal.h"
#import "WebArchive.h"
#import "WebFrameInternal.h"
#import "WebHTMLViewInternal.h"
@@ -211,13 +212,14 @@ static NSArray *_writableTypesForImageWithArchive (void)
}
-static CachedImage* imageFromElement(DOMElement *domElement) {
+static CachedImage* imageFromElement(DOMElement *domElement)
+{
Element* element = core(domElement);
if (!element)
return 0;
RenderObject* renderer = element->renderer();
- RenderImage* imageRenderer = static_cast<RenderImage*>(renderer);
+ RenderImage* imageRenderer = toRenderImage(renderer);
if (!imageRenderer->cachedImage() || imageRenderer->cachedImage()->errorOccurred())
return 0;
return imageRenderer->cachedImage();
@@ -266,7 +268,7 @@ static CachedImage* imageFromElement(DOMElement *domElement) {
NSString *extension = @"";
if (RenderObject* renderer = core(element)->renderer()) {
if (renderer->isImage()) {
- if (CachedImage* image = static_cast<RenderImage*>(renderer)->cachedImage()) {
+ if (CachedImage* image = toRenderImage(renderer)->cachedImage()) {
extension = image->image()->filenameExtension();
if (![extension length])
return 0;
diff --git a/WebKit/mac/Misc/WebNSURLExtras.mm b/WebKit/mac/Misc/WebNSURLExtras.mm
index a081f1a..d956f09 100644
--- a/WebKit/mac/Misc/WebNSURLExtras.mm
+++ b/WebKit/mac/Misc/WebNSURLExtras.mm
@@ -72,7 +72,10 @@ static inline BOOL isLookalikeCharacter(int charCode)
return YES;
switch (charCode) {
+ case 0x00ED: /* LATIN SMALL LETTER I WITH ACUTE */
case 0x01C3: /* LATIN LETTER RETROFLEX CLICK */
+ case 0x0251: /* LATIN SMALL LETTER ALPHA */
+ case 0x0261: /* LATIN SMALL LETTER SCRIPT G */
case 0x0337: /* COMBINING SHORT SOLIDUS OVERLAY */
case 0x0338: /* COMBINING LONG SOLIDUS OVERLAY */
case 0x05B4: /* HEBREW POINT HIRIQ */
@@ -87,8 +90,12 @@ static inline BOOL isLookalikeCharacter(int charCode)
case 0x203A: /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
case 0x2044: /* FRACTION SLASH */
case 0x2215: /* DIVISION SLASH */
- case 0x23ae: /* INTEGRAL EXTENSION */
+ case 0x2216: /* SET MINUS */
+ case 0x233F: /* APL FUNCTIONAL SYMBOL SLASH BAR */
+ case 0x23AE: /* INTEGRAL EXTENSION */
+ case 0x244A: /* OCR DOUBLE BACKSLASH */
case 0x2571: /* BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT */
+ case 0x2572: /* BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT */
case 0x29F8: /* BIG SOLIDUS */
case 0x29f6: /* SOLIDUS WITH OVERBAR */
case 0x2AFB: /* TRIPLE SOLIDUS BINARY RELATION */
@@ -97,6 +104,7 @@ static inline BOOL isLookalikeCharacter(int charCode)
case 0x3014: /* LEFT TORTOISE SHELL BRACKET */
case 0x3015: /* RIGHT TORTOISE SHELL BRACKET */
case 0x3033: /* VERTICAL KANA REPEAT MARK UPPER HALF */
+ case 0x3035: /* VERTICAL KANA REPEAT MARK LOWER HALF */
case 0x321D: /* PARENTHESIZED KOREAN CHARACTER OJEON */
case 0x321E: /* PARENTHESIZED KOREAN CHARACTER O HU */
case 0x33DF: /* SQUARE A OVER M */
diff --git a/WebKit/mac/Misc/WebStringTruncator.m b/WebKit/mac/Misc/WebStringTruncator.mm
index fb31bbb..fb31bbb 100644
--- a/WebKit/mac/Misc/WebStringTruncator.m
+++ b/WebKit/mac/Misc/WebStringTruncator.mm