summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/Misc
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/Misc')
-rw-r--r--WebKit/mac/Misc/WebCache.mm4
-rw-r--r--WebKit/mac/Misc/WebCoreStatistics.h6
-rw-r--r--WebKit/mac/Misc/WebCoreStatistics.mm37
-rw-r--r--WebKit/mac/Misc/WebDownload.mm2
-rw-r--r--WebKit/mac/Misc/WebElementDictionary.mm2
-rw-r--r--WebKit/mac/Misc/WebIconDatabase.mm11
-rw-r--r--WebKit/mac/Misc/WebKitNSStringExtras.h1
-rw-r--r--WebKit/mac/Misc/WebKitNSStringExtras.mm21
-rw-r--r--WebKit/mac/Misc/WebKitStatistics.h3
-rw-r--r--WebKit/mac/Misc/WebNSAttributedStringExtras.mm8
-rw-r--r--WebKit/mac/Misc/WebNSDictionaryExtras.h1
-rw-r--r--WebKit/mac/Misc/WebNSDictionaryExtras.m7
-rw-r--r--WebKit/mac/Misc/WebNSFileManagerExtras.h11
-rw-r--r--WebKit/mac/Misc/WebNSFileManagerExtras.m92
-rw-r--r--WebKit/mac/Misc/WebNSObjectExtras.h1
-rw-r--r--WebKit/mac/Misc/WebNSObjectExtras.mm5
-rw-r--r--WebKit/mac/Misc/WebNSPasteboardExtras.mm18
-rw-r--r--WebKit/mac/Misc/WebNSPrintOperationExtras.h2
-rw-r--r--WebKit/mac/Misc/WebNSPrintOperationExtras.m12
-rw-r--r--WebKit/mac/Misc/WebNSURLExtras.mm37
-rw-r--r--WebKit/mac/Misc/WebQuotaManager.h (renamed from WebKit/mac/Misc/EmptyProtocolDefinitions.h)51
-rw-r--r--WebKit/mac/Misc/WebUserContentURLPattern.h39
-rw-r--r--WebKit/mac/Misc/WebUserContentURLPattern.mm89
23 files changed, 327 insertions, 133 deletions
diff --git a/WebKit/mac/Misc/WebCache.mm b/WebKit/mac/Misc/WebCache.mm
index b29f720..747d213 100644
--- a/WebKit/mac/Misc/WebCache.mm
+++ b/WebKit/mac/Misc/WebCache.mm
@@ -25,6 +25,7 @@
#import "WebCache.h"
+#import "WebNSObjectExtras.h"
#import "WebPreferences.h"
#import "WebSystemInterface.h"
#import "WebView.h"
@@ -126,6 +127,9 @@
+ (void)setDisabled:(BOOL)disabled
{
+ if (!pthread_main_np())
+ return [[self _webkit_invokeOnMainThread] setDisabled:disabled];
+
WebCore::cache()->setDisabled(disabled);
}
diff --git a/WebKit/mac/Misc/WebCoreStatistics.h b/WebKit/mac/Misc/WebCoreStatistics.h
index d205083..1565c26 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.h
+++ b/WebKit/mac/Misc/WebCoreStatistics.h
@@ -83,8 +83,12 @@
@end
@interface WebFrame (WebKitDebug)
-- (NSString *)renderTreeAsExternalRepresentation;
+- (NSString *)renderTreeAsExternalRepresentationForPrinting:(BOOL)forPrinting;
- (NSString *)counterValueForElement:(DOMElement*)element;
- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels;
- (int)numberOfPages:(float)pageWidthInPixels:(float)pageHeightInPixels;
+- (NSString *)pageProperty:(const char*)propertyName:(int)pageNumber;
+- (bool)isPageBoxVisible:(int)pageNumber;
+- (NSString *)pageSizeAndMarginsInPixels:(int)pageNumber:(int)width:(int)height:(int)marginTop:(int)marginRight:(int)marginBottom:(int)marginLeft;
+- (void)printToCGContext:(CGContextRef)cgContext:(float)pageWidthInPixels:(float)pageHeightInPixels;
@end
diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm
index 9e8ae05..a5d5ae1 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.mm
+++ b/WebKit/mac/Misc/WebCoreStatistics.mm
@@ -37,6 +37,7 @@
#import <WebCore/Frame.h>
#import <WebCore/GCController.h>
#import <WebCore/GlyphPageTreeNode.h>
+#import <WebCore/GraphicsContext.h>
#import <WebCore/IconDatabase.h>
#import <WebCore/JSDOMWindow.h>
#import <WebCore/PageCache.h>
@@ -196,10 +197,9 @@ using namespace WebCore;
JSLock lock(SilenceAssertionsOnly);
Heap::Statistics jsHeapStatistics = JSDOMWindow::commonJSGlobalData()->heap.statistics();
return [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:fastMallocStatistics.heapSize], @"FastMallocHeapSize",
- [NSNumber numberWithInt:fastMallocStatistics.freeSizeInHeap], @"FastMallocFreeSizeInHeap",
- [NSNumber numberWithInt:fastMallocStatistics.freeSizeInCaches], @"FastMallocFreeSizeInCaches",
- [NSNumber numberWithInt:fastMallocStatistics.returnedSize], @"FastMallocReturnedSize",
+ [NSNumber numberWithInt:fastMallocStatistics.reservedVMBytes], @"FastMallocReservedVMBytes",
+ [NSNumber numberWithInt:fastMallocStatistics.committedVMBytes], @"FastMallocCommittedVMBytes",
+ [NSNumber numberWithInt:fastMallocStatistics.freeListBytes], @"FastMallocFreeListBytes",
[NSNumber numberWithInt:jsHeapStatistics.size], @"JavaScriptHeapSize",
[NSNumber numberWithInt:jsHeapStatistics.free], @"JavaScriptFreeSize",
nil];
@@ -256,9 +256,9 @@ using namespace WebCore;
@implementation WebFrame (WebKitDebug)
-- (NSString *)renderTreeAsExternalRepresentation
+- (NSString *)renderTreeAsExternalRepresentationForPrinting:(BOOL)forPrinting
{
- return externalRepresentation(_private->coreFrame);
+ return externalRepresentation(_private->coreFrame, forPrinting ? RenderAsTextPrintingMode : RenderAsTextBehaviorNormal);
}
- (NSString *)counterValueForElement:(DOMElement*)element
@@ -276,4 +276,29 @@ using namespace WebCore;
return PrintContext::numberOfPages(_private->coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
}
+- (NSString *)pageProperty:(const char *)propertyName:(int)pageNumber
+{
+ return PrintContext::pageProperty(_private->coreFrame, propertyName, pageNumber);
+}
+
+- (bool)isPageBoxVisible:(int)pageNumber
+{
+ return PrintContext::isPageBoxVisible(_private->coreFrame, pageNumber);
+}
+
+- (NSString *)pageSizeAndMarginsInPixels:(int)pageNumber:(int)width:(int)height:(int)marginTop:(int)marginRight:(int)marginBottom:(int)marginLeft
+{
+ return PrintContext::pageSizeAndMarginsInPixels(_private->coreFrame, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft);
+}
+
+- (void)printToCGContext:(CGContextRef)cgContext:(float)pageWidthInPixels:(float)pageHeightInPixels
+{
+ Frame* coreFrame = _private->coreFrame;
+ if (!coreFrame)
+ return;
+
+ GraphicsContext graphicsContext(cgContext);
+ PrintContext::spoolAllPagesWithBoundaries(coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
+}
+
@end
diff --git a/WebKit/mac/Misc/WebDownload.mm b/WebKit/mac/Misc/WebDownload.mm
index 01ed767..82c1259 100644
--- a/WebKit/mac/Misc/WebDownload.mm
+++ b/WebKit/mac/Misc/WebDownload.mm
@@ -56,7 +56,7 @@ using namespace WebCore;
directory:(NSString *)directory;
@end
-@interface WebDownloadInternal : NSObject
+@interface WebDownloadInternal : NSObject <NSURLDownloadDelegate>
{
@public
id realDelegate;
diff --git a/WebKit/mac/Misc/WebElementDictionary.mm b/WebKit/mac/Misc/WebElementDictionary.mm
index 7779392..6b2eb3d 100644
--- a/WebKit/mac/Misc/WebElementDictionary.mm
+++ b/WebKit/mac/Misc/WebElementDictionary.mm
@@ -43,6 +43,7 @@
#import <WebKit/DOMCore.h>
#import <WebKit/DOMExtensions.h>
#import <runtime/InitializeThreading.h>
+#import <wtf/Threading.h>
using namespace WebCore;
@@ -64,6 +65,7 @@ static void cacheValueForKey(const void *key, const void *value, void *self)
+ (void)initialize
{
JSC::initializeThreading();
+ WTF::initializeMainThreadToProcessMainThread();
#ifndef BUILDING_ON_TIGER
WebCoreObjCFinalizeOnMainThread(self);
#endif
diff --git a/WebKit/mac/Misc/WebIconDatabase.mm b/WebKit/mac/Misc/WebIconDatabase.mm
index 62c8e2f..7d0a350 100644
--- a/WebKit/mac/Misc/WebIconDatabase.mm
+++ b/WebKit/mac/Misc/WebIconDatabase.mm
@@ -40,7 +40,10 @@
#import <WebCore/IconDatabase.h>
#import <WebCore/Image.h>
#import <WebCore/IntSize.h>
+#import <WebCore/SharedBuffer.h>
#import <WebCore/ThreadCheck.h>
+#import <runtime/InitializeThreading.h>
+#import <wtf/Threading.h>
using namespace WebCore;
@@ -87,6 +90,12 @@ static WebIconDatabaseClient* defaultClient()
@implementation WebIconDatabase
++ (void)initialize
+{
+ JSC::initializeThreading();
+ WTF::initializeMainThreadToProcessMainThread();
+}
+
+ (WebIconDatabase *)sharedIconDatabase
{
static WebIconDatabase *database = nil;
@@ -95,7 +104,7 @@ static WebIconDatabaseClient* defaultClient()
return database;
}
-- init
+- (id)init
{
[super init];
WebCoreThreadViolationCheckRoundOne();
diff --git a/WebKit/mac/Misc/WebKitNSStringExtras.h b/WebKit/mac/Misc/WebKitNSStringExtras.h
index f252430..ddc49f0 100644
--- a/WebKit/mac/Misc/WebKitNSStringExtras.h
+++ b/WebKit/mac/Misc/WebKitNSStringExtras.h
@@ -32,6 +32,7 @@ extern NSString *WebKitLocalCacheDefaultsKey;
@interface NSString (WebKitExtras)
+- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor allowingFontSmoothing:(BOOL)fontSmoothingIsAllowed;
- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor;
- (void)_web_drawDoubledAtPoint:(NSPoint)textPoint withTopColor:(NSColor *)topColor bottomColor:(NSColor *)bottomColor font:(NSFont *)font;
diff --git a/WebKit/mac/Misc/WebKitNSStringExtras.mm b/WebKit/mac/Misc/WebKitNSStringExtras.mm
index da46630..8fc12bd 100644
--- a/WebKit/mac/Misc/WebKitNSStringExtras.mm
+++ b/WebKit/mac/Misc/WebKitNSStringExtras.mm
@@ -62,12 +62,16 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor
{
- // FIXME: Would be more efficient to change this to C++ and use Vector<UChar, 2048>.
+ [self _web_drawAtPoint:point font:font textColor:textColor allowingFontSmoothing:YES];
+}
+
+- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor allowingFontSmoothing:(BOOL)fontSmoothingIsAllowed
+{
unsigned length = [self length];
Vector<UniChar, 2048> buffer(length);
[self getCharacters:buffer.data()];
-
+
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.
@@ -84,7 +88,7 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
if (!flipped)
CGContextScaleCTM(cgContext, 1, -1);
- Font webCoreFont(FontPlatformData(font), ![nsContext isDrawingToScreen]);
+ Font webCoreFont(FontPlatformData(font), ![nsContext isDrawingToScreen], fontSmoothingIsAllowed ? AutoSmoothing : Antialiased);
TextRun run(buffer.data(), length);
run.disableRoundingHacks();
@@ -116,17 +120,10 @@ static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
font:(NSFont *)font
{
// turn off font smoothing so translucent text draws correctly (Radar 3118455)
- [NSGraphicsContext saveGraphicsState];
- CGContextSetShouldSmoothFonts(static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), false);
- [self _web_drawAtPoint:textPoint
- font:font
- textColor:bottomColor];
+ [self _web_drawAtPoint:textPoint font:font textColor:bottomColor allowingFontSmoothing:NO];
textPoint.y += 1;
- [self _web_drawAtPoint:textPoint
- font:font
- textColor:topColor];
- [NSGraphicsContext restoreGraphicsState];
+ [self _web_drawAtPoint:textPoint font:font textColor:topColor allowingFontSmoothing:NO];
}
- (float)_web_widthWithFont:(NSFont *)font
diff --git a/WebKit/mac/Misc/WebKitStatistics.h b/WebKit/mac/Misc/WebKitStatistics.h
index 32241b5..040a40b 100644
--- a/WebKit/mac/Misc/WebKitStatistics.h
+++ b/WebKit/mac/Misc/WebKitStatistics.h
@@ -28,6 +28,9 @@
#import <Foundation/Foundation.h>
+// These values are only incremented and decremented if the WebView is subclassed and
+// +[WebView shouldIncludeInWebKitStatistics] returns YES. By default WebView returns NO.
+
@interface WebKitStatistics : NSObject
+ (int)webViewCount;
diff --git a/WebKit/mac/Misc/WebNSAttributedStringExtras.mm b/WebKit/mac/Misc/WebNSAttributedStringExtras.mm
index eb422f1..2469da8 100644
--- a/WebKit/mac/Misc/WebNSAttributedStringExtras.mm
+++ b/WebKit/mac/Misc/WebNSAttributedStringExtras.mm
@@ -154,12 +154,12 @@ static NSFileWrapper *fileWrapperForElement(Element* e)
RenderStyle* style = renderer->style();
NSFont *font = style->font().primaryFont()->getNSFont();
[attrs.get() setObject:font forKey:NSFontAttributeName];
- if (style->color().isValid())
- [attrs.get() setObject:nsColor(style->color()) forKey:NSForegroundColorAttributeName];
+ if (style->visitedDependentColor(CSSPropertyColor).alpha())
+ [attrs.get() setObject:nsColor(style->visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
else
[attrs.get() removeObjectForKey:NSForegroundColorAttributeName];
- if (style->backgroundColor().isValid())
- [attrs.get() setObject:nsColor(style->backgroundColor()) forKey:NSBackgroundColorAttributeName];
+ if (style->visitedDependentColor(CSSPropertyBackgroundColor).alpha())
+ [attrs.get() setObject:nsColor(style->visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
else
[attrs.get() removeObjectForKey:NSBackgroundColorAttributeName];
diff --git a/WebKit/mac/Misc/WebNSDictionaryExtras.h b/WebKit/mac/Misc/WebNSDictionaryExtras.h
index 95445f8..0bbc5d5 100644
--- a/WebKit/mac/Misc/WebNSDictionaryExtras.h
+++ b/WebKit/mac/Misc/WebNSDictionaryExtras.h
@@ -43,5 +43,6 @@
- (void)_webkit_setInt:(int)value forKey:(id)key;
- (void)_webkit_setFloat:(float)value forKey:(id)key;
- (void)_webkit_setBool:(BOOL)value forKey:(id)key;
+- (void)_webkit_setLongLong:(long long)value forKey:(id)key;
- (void)_webkit_setUnsignedLongLong:(unsigned long long)value forKey:(id)key;
@end
diff --git a/WebKit/mac/Misc/WebNSDictionaryExtras.m b/WebKit/mac/Misc/WebNSDictionaryExtras.m
index a47fd0b..366f361 100644
--- a/WebKit/mac/Misc/WebNSDictionaryExtras.m
+++ b/WebKit/mac/Misc/WebNSDictionaryExtras.m
@@ -108,6 +108,13 @@
[object release];
}
+- (void)_webkit_setLongLong:(long long)value forKey:(id)key
+{
+ NSNumber *object = [[NSNumber alloc] initWithLongLong:value];
+ [self setObject:object forKey:key];
+ [object release];
+}
+
- (void)_webkit_setUnsignedLongLong:(unsigned long long)value forKey:(id)key
{
NSNumber *object = [[NSNumber alloc] initWithUnsignedLongLong:value];
diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.h b/WebKit/mac/Misc/WebNSFileManagerExtras.h
index c2287f9..dcf62d0 100644
--- a/WebKit/mac/Misc/WebNSFileManagerExtras.h
+++ b/WebKit/mac/Misc/WebNSFileManagerExtras.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005, 2010 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,19 +28,10 @@
#import <Foundation/Foundation.h>
-#define WEB_UREAD (00400) /* Read by owner */
-#define WEB_UWRITE (00200) /* Write by owner */
-#define WEB_UEXEC (00100) /* Execute/Search by owner */
-
@interface NSFileManager (WebNSFileManagerExtras)
-
-- (void)_webkit_backgroundRemoveFileAtPath:(NSString *)path;
-- (void)_webkit_backgroundRemoveLeftoverFiles:(NSString *)path;
-- (BOOL)_webkit_removeFileOnlyAtPath:(NSString *)path;
- (void)_webkit_setMetadataURL:(NSString *)URLString referrer:(NSString *)referrer atPath:(NSString *)path;
- (NSString *)_webkit_startupVolumeName;
- (NSString *)_webkit_pathWithUniqueFilenameForPath:(NSString *)path;
-
@end
diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.m b/WebKit/mac/Misc/WebNSFileManagerExtras.m
index fb1286f..f10781b 100644
--- a/WebKit/mac/Misc/WebNSFileManagerExtras.m
+++ b/WebKit/mac/Misc/WebNSFileManagerExtras.m
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,74 +30,13 @@
#import "WebKitNSStringExtras.h"
#import "WebNSURLExtras.h"
+#import <JavaScriptCore/Assertions.h>
#import <WebCore/FoundationExtras.h>
#import <WebKitSystemInterface.h>
-#import <pthread.h>
-#import <sys/mount.h>
-#import <JavaScriptCore/Assertions.h>
+#import <sys/stat.h>
@implementation NSFileManager (WebNSFileManagerExtras)
-- (BOOL)_webkit_removeFileOnlyAtPath:(NSString *)path
-{
- struct statfs buf;
- BOOL result = unlink([path fileSystemRepresentation]) == 0;
-
- // For mysterious reasons, MNT_DOVOLFS is the flag for "supports resource fork"
- if ((statfs([path fileSystemRepresentation], &buf) == 0) && !(buf.f_flags & MNT_DOVOLFS)) {
- NSString *lastPathComponent = [path lastPathComponent];
- if ([lastPathComponent length] != 0 && ![lastPathComponent isEqualToString:@"/"]) {
- NSString *resourcePath = [[path stringByDeletingLastPathComponent] stringByAppendingString:[@"._" stringByAppendingString:lastPathComponent]];
- if (unlink([resourcePath fileSystemRepresentation]) != 0) {
- result = NO;
- }
- }
- }
-
- return result;
-}
-
-- (void)_webkit_backgroundRemoveFileAtPath:(NSString *)path
-{
- NSFileManager *manager;
- NSString *moveToSubpath;
- NSString *moveToPath;
- int i;
-
- manager = [NSFileManager defaultManager];
-
- i = 0;
- moveToSubpath = [path stringByDeletingLastPathComponent];
- do {
- moveToPath = [NSString stringWithFormat:@"%@/.tmp%d", moveToSubpath, i];
- i++;
- } while ([manager fileExistsAtPath:moveToPath]);
-
- if ([manager moveItemAtPath:path toPath:moveToPath error:NULL])
- [NSThread detachNewThreadSelector:@selector(_performRemoveFileAtPath:) toTarget:self withObject:moveToPath];
-}
-
-- (void)_webkit_backgroundRemoveLeftoverFiles:(NSString *)path
-{
- NSFileManager *manager;
- NSString *leftoverSubpath;
- NSString *leftoverPath;
- int i;
-
- manager = [NSFileManager defaultManager];
- leftoverSubpath = [path stringByDeletingLastPathComponent];
-
- i = 0;
- while (1) {
- leftoverPath = [NSString stringWithFormat:@"%@/.tmp%d", leftoverSubpath, i];
- if (![manager fileExistsAtPath:leftoverPath]) {
- break;
- }
- [NSThread detachNewThreadSelector:@selector(_performRemoveFileAtPath:) toTarget:self withObject:leftoverPath];
- i++;
- }
-}
-
- (NSString *)_webkit_carbonPathForPath:(NSString *)posixPath
{
OSStatus error;
@@ -199,14 +138,22 @@ static void *setMetaData(void* context)
return [path substringToIndex:[path length]-1];
}
+// -[NSFileManager fileExistsAtPath:] returns NO if there is a broken symlink at the path.
+// So we use this function instead, which returns YES if there is anything there, including
+// a broken symlink.
+static BOOL fileExists(NSString *path)
+{
+ struct stat statBuffer;
+ return !lstat([path fileSystemRepresentation], &statBuffer);
+}
+
- (NSString *)_webkit_pathWithUniqueFilenameForPath:(NSString *)path
{
// "Fix" the filename of the path.
NSString *filename = [[path lastPathComponent] _webkit_filenameByFixingIllegalCharacters];
path = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:filename];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- if ([fileManager fileExistsAtPath:path]) {
+ if (fileExists(path)) {
// Don't overwrite existing file by appending "-n", "-n.ext" or "-n.ext.ext" to the filename.
NSString *extensions = nil;
NSString *pathWithoutExtensions;
@@ -221,15 +168,11 @@ static void *setMetaData(void* context)
pathWithoutExtensions = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:lastPathComponent];
}
- NSString *pathWithAppendedNumber;
- unsigned i;
-
- for (i = 1; 1; i++) {
- pathWithAppendedNumber = [NSString stringWithFormat:@"%@-%d", pathWithoutExtensions, i];
+ for (unsigned i = 1; ; i++) {
+ NSString *pathWithAppendedNumber = [NSString stringWithFormat:@"%@-%d", pathWithoutExtensions, i];
path = [extensions length] ? [pathWithAppendedNumber stringByAppendingPathExtension:extensions] : pathWithAppendedNumber;
- if (![fileManager fileExistsAtPath:path]) {
+ if (!fileExists(path))
break;
- }
}
}
@@ -238,8 +181,8 @@ static void *setMetaData(void* context)
@end
-
#ifdef BUILDING_ON_TIGER
+
@implementation NSFileManager (WebNSFileManagerTigerForwardCompatibility)
- (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error
@@ -293,4 +236,5 @@ static void *setMetaData(void* context)
}
@end
+
#endif
diff --git a/WebKit/mac/Misc/WebNSObjectExtras.h b/WebKit/mac/Misc/WebNSObjectExtras.h
index f327966..0114bcc 100644
--- a/WebKit/mac/Misc/WebNSObjectExtras.h
+++ b/WebKit/mac/Misc/WebNSObjectExtras.h
@@ -54,5 +54,6 @@ static inline IMP method_setImplementation(Method m, IMP i)
#endif
@interface NSObject (WebNSObjectExtras)
++ (id)_webkit_invokeOnMainThread;
- (id)_webkit_invokeOnMainThread;
@end
diff --git a/WebKit/mac/Misc/WebNSObjectExtras.mm b/WebKit/mac/Misc/WebNSObjectExtras.mm
index 3beb641..d00726b 100644
--- a/WebKit/mac/Misc/WebNSObjectExtras.mm
+++ b/WebKit/mac/Misc/WebNSObjectExtras.mm
@@ -105,6 +105,11 @@ static bool returnTypeIsObject(NSInvocation *invocation)
@implementation NSObject (WebNSObjectExtras)
++ (id)_webkit_invokeOnMainThread
+{
+ return [[[WebMainThreadInvoker alloc] initWithTarget:self] autorelease];
+}
+
- (id)_webkit_invokeOnMainThread
{
return [[[WebMainThreadInvoker alloc] initWithTarget:self] autorelease];
diff --git a/WebKit/mac/Misc/WebNSPasteboardExtras.mm b/WebKit/mac/Misc/WebNSPasteboardExtras.mm
index 3cc1c7c..7caa47a 100644
--- a/WebKit/mac/Misc/WebNSPasteboardExtras.mm
+++ b/WebKit/mac/Misc/WebNSPasteboardExtras.mm
@@ -37,17 +37,18 @@
#import "WebURLsWithTitles.h"
#import "WebViewPrivate.h"
#import <WebCore/Element.h>
+#import <WebCore/Image.h>
#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/RenderImage.h>
#import <WebKit/DOMExtensions.h>
#import <WebKit/DOMPrivate.h>
+#import <WebKitSystemInterface.h>
#import <wtf/Assertions.h>
-#import <wtf/StdLibExtras.h>
#import <wtf/RetainPtr.h>
-#import <WebKitSystemInterface.h>
+#import <wtf/StdLibExtras.h>
@interface NSFilePromiseDragSource : NSObject
-- initWithSource:(id)draggingSource;
+- (id)initWithSource:(id)draggingSource;
- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pboard;
@end
@@ -140,12 +141,17 @@ static NSArray *_writableTypesForImageWithArchive (void)
if ([types containsObject:NSFilenamesPboardType]) {
NSArray *files = [self propertyListForType:NSFilenamesPboardType];
+ // FIXME: Maybe it makes more sense to allow multiple files and only use the first one?
if ([files count] == 1) {
NSString *file = [files objectAtIndex:0];
+ // FIXME: We are filtering out directories because that's what the original code used to
+ // do. Without this check, if the URL points to a local directory, Safari will open the
+ // parent directory of the directory in Finder. This check should go away as soon as
+ // possible.
BOOL isDirectory;
- if([[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory] && !isDirectory){
- return [[NSURL fileURLWithPath:file] _webkit_canonicalize];
- }
+ if ([[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory] && isDirectory)
+ return nil;
+ return [[NSURL fileURLWithPath:file] _webkit_canonicalize];
}
}
diff --git a/WebKit/mac/Misc/WebNSPrintOperationExtras.h b/WebKit/mac/Misc/WebNSPrintOperationExtras.h
index 44eb3df..3535369 100644
--- a/WebKit/mac/Misc/WebNSPrintOperationExtras.h
+++ b/WebKit/mac/Misc/WebNSPrintOperationExtras.h
@@ -31,5 +31,7 @@
@interface NSPrintOperation (WebKitExtras)
- (float)_web_pageSetupScaleFactor;
+- (float)_web_availablePaperWidth;
+- (float)_web_availablePaperHeight;
@end
diff --git a/WebKit/mac/Misc/WebNSPrintOperationExtras.m b/WebKit/mac/Misc/WebNSPrintOperationExtras.m
index 4c45f17..0982b96 100644
--- a/WebKit/mac/Misc/WebNSPrintOperationExtras.m
+++ b/WebKit/mac/Misc/WebNSPrintOperationExtras.m
@@ -35,4 +35,16 @@
return [[[[self printInfo] dictionary] objectForKey:NSPrintScalingFactor] floatValue];
}
+- (float)_web_availablePaperWidth
+{
+ NSPrintInfo *printInfo = [self printInfo];
+ return [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin];
+}
+
+- (float)_web_availablePaperHeight
+{
+ NSPrintInfo *printInfo = [self printInfo];
+ return [printInfo paperSize].height - [printInfo topMargin] - [printInfo bottomMargin];
+}
+
@end
diff --git a/WebKit/mac/Misc/WebNSURLExtras.mm b/WebKit/mac/Misc/WebNSURLExtras.mm
index 2affbed..00819e4 100644
--- a/WebKit/mac/Misc/WebNSURLExtras.mm
+++ b/WebKit/mac/Misc/WebNSURLExtras.mm
@@ -1050,6 +1050,41 @@ static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t lengt
return YES;
}
+static BOOL allCharactersAllowedByTLDRules(const UChar* buffer, int32_t length)
+{
+ // Skip trailing dot for root domain.
+ if (buffer[length - 1] == '.')
+ --length;
+
+ if (length > 3
+ && buffer[length - 3] == '.'
+ && buffer[length - 2] == 0x0440 // CYRILLIC SMALL LETTER ER
+ && buffer[length - 1] == 0x0444) // CYRILLIC SMALL LETTER EF
+ {
+ // Rules defined by <http://www.cctld.ru/ru/docs/rulesrf.php>. This code only checks requirements that matter for presentation purposes.
+ for (int32_t i = length - 4; i; --i) {
+ UChar ch = buffer[i];
+
+ // Only modern Russian letters, digits and dashes are allowed.
+ if ((ch >= 0x0430 && ch <= 0x044f)
+ || ch == 0x0451
+ || (ch >= '0' && ch <= '9')
+ || ch == '-')
+ continue;
+
+ // Only check top level domain. Lower level registrars may have different rules.
+ if (ch == '.')
+ break;
+
+ return NO;
+ }
+ return YES;
+ }
+
+ // Not a known top level domain with special rules.
+ return NO;
+}
+
// Return value of nil means no mapping is necessary.
// If makeString is NO, then return value is either nil or self to indicate mapping is necessary.
// If makeString is YES, then return value is either nil or the mapped string.
@@ -1087,7 +1122,7 @@ static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t lengt
if (numCharactersConverted == length && memcmp(sourceBuffer, destinationBuffer, length * sizeof(UChar)) == 0) {
return nil;
}
- if (!encode && !allCharactersInIDNScriptWhiteList(destinationBuffer, numCharactersConverted)) {
+ if (!encode && !allCharactersInIDNScriptWhiteList(destinationBuffer, numCharactersConverted) && !allCharactersAllowedByTLDRules(destinationBuffer, numCharactersConverted)) {
return nil;
}
return makeString ? (NSString *)[NSString stringWithCharacters:destinationBuffer length:numCharactersConverted] : (NSString *)self;
diff --git a/WebKit/mac/Misc/EmptyProtocolDefinitions.h b/WebKit/mac/Misc/WebQuotaManager.h
index c52d8ce..45074e4 100644
--- a/WebKit/mac/Misc/EmptyProtocolDefinitions.h
+++ b/WebKit/mac/Misc/WebQuotaManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,26 +23,43 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(__OBJC__)
+@class WebSecurityOrigin;
-#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
-#define DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS 0
-#else
-#define DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS 1
-#endif
+/*!
+ @protocol WebQuotaManager
+ @discussion This protocol is used to view and manipulate a per-origin storage quota.
+*/
+@protocol WebQuotaManager
-#if !DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS
+/*!
+ @method initWithOrigin:
+ @param The security origin this will manage.
+ @result A new WebQuotaManager object.
+*/
+- (id)initWithOrigin:(WebSecurityOrigin *)origin;
-#define EMPTY_PROTOCOL(NAME) \
-@protocol NAME <NSObject> \
-@end
+/*!
+ @method origin
+ @result The security origin this manager is managing.
+*/
+- (WebSecurityOrigin *)origin;
-EMPTY_PROTOCOL(NSTableViewDataSource)
-EMPTY_PROTOCOL(NSTableViewDelegate)
-EMPTY_PROTOCOL(NSWindowDelegate)
+/*!
+ @method usage
+ @result The current total usage of all relevant items in this security origin in bytes.
+*/
+- (unsigned long long)usage;
-#undef EMPTY_PROTOCOL
+/*!
+ @method quota
+ @result The current quota of security origin in bytes.
+*/
+- (unsigned long long)quota;
-#endif /* !DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS */
+/*!
+ @method setQuota:
+ @param Sets a new quota, in bytes, on this security origin.
+*/
+- (void)setQuota:(unsigned long long)quota;
-#endif /* defined(__OBJC__) */
+@end
diff --git a/WebKit/mac/Misc/WebUserContentURLPattern.h b/WebKit/mac/Misc/WebUserContentURLPattern.h
new file mode 100644
index 0000000..e7ccac4
--- /dev/null
+++ b/WebKit/mac/Misc/WebUserContentURLPattern.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Apple 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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.
+ */
+
+@class WebUserContentURLPatternPrivate;
+
+@interface WebUserContentURLPattern : NSObject {
+ WebUserContentURLPatternPrivate *_private;
+}
+
+- (id)initWithPatternString:(NSString *)patternString;
+
+- (BOOL)isValid;
+- (NSString *)scheme;
+- (NSString *)host;
+- (BOOL)matchesSubdomains;
+- (BOOL)matchesURL:(NSURL *)url;
+
+@end
diff --git a/WebKit/mac/Misc/WebUserContentURLPattern.mm b/WebKit/mac/Misc/WebUserContentURLPattern.mm
new file mode 100644
index 0000000..883f2e6
--- /dev/null
+++ b/WebKit/mac/Misc/WebUserContentURLPattern.mm
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 Apple 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "WebUserContentURLPattern.h"
+
+#import <WebCore/KURL.h>
+#import <WebCore/UserContentURLPattern.h>
+
+using namespace WebCore;
+
+@interface WebUserContentURLPatternPrivate : NSObject
+{
+@public
+ UserContentURLPattern pattern;
+}
+@end
+
+@implementation WebUserContentURLPatternPrivate
+@end
+
+@implementation WebUserContentURLPattern
+
+- (id)initWithPatternString:(NSString *)patternString
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _private = [[WebUserContentURLPatternPrivate alloc] init];
+ _private->pattern = UserContentURLPattern(patternString);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_private release];
+ _private = nil;
+
+ [super dealloc];
+}
+
+- (BOOL)isValid
+{
+ return _private->pattern.isValid();
+}
+
+- (NSString *)scheme
+{
+ return _private->pattern.scheme();
+}
+
+- (NSString *)host
+{
+ return _private->pattern.host();
+}
+
+- (BOOL)matchesSubdomains
+{
+ return _private->pattern.matchSubdomains();
+}
+
+- (BOOL)matchesURL:(NSURL *)url
+{
+ return _private->pattern.matches(url);
+}
+
+@end