diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:06:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:31:31 (GMT) |
commit | c411f16870f112c3407c28c22b617f613a82cff4 (patch) | |
tree | 29a1bcd590c8b31af2aab445bfe8a978dc5bf582 /src/3rdparty/webkit/WebCore/platform/mac | |
parent | 3d77b56b32a0c53ec0bbfaa07236fedb900ff336 (diff) | |
download | Qt-c411f16870f112c3407c28c22b617f613a82cff4.zip Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.gz Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.bz2 |
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-15062009 ( 65232bf00dc494ebfd978f998c88f58d18ecce1e )
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/mac')
29 files changed, 774 insertions, 310 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/mac/ClipboardMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/ClipboardMac.mm index 8117b2b..d1b66a7 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/ClipboardMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/ClipboardMac.mm @@ -36,8 +36,13 @@ #import "Page.h" #import "Pasteboard.h" #import "RenderImage.h" +#import "SecurityOrigin.h" #import "WebCoreSystemInterface.h" +#ifdef BUILDING_ON_TIGER +typedef unsigned NSUInteger; +#endif + namespace WebCore { ClipboardMac::ClipboardMac(bool forDragging, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame *frame) @@ -120,9 +125,8 @@ void ClipboardMac::clearData(const String& type) // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner NSString *cocoaType = cocoaTypeFromMIMEType(type); - if (cocoaType) { + if (cocoaType) [m_pasteboard.get() setString:@"" forType:cocoaType]; - } } void ClipboardMac::clearAllData() @@ -135,57 +139,71 @@ void ClipboardMac::clearAllData() [m_pasteboard.get() declareTypes:[NSArray array] owner:nil]; } +static NSArray *absoluteURLsFromPasteboardFilenames(NSPasteboard* pasteboard, bool onlyFirstURL) +{ + NSArray *fileList = [pasteboard propertyListForType:NSFilenamesPboardType]; + + // FIXME: Why does this code need to guard against bad values on the pasteboard? + ASSERT(!fileList || [fileList isKindOfClass:[NSArray class]]); + if (!fileList || ![fileList isKindOfClass:[NSArray class]] || ![fileList count]) + return nil; + + NSUInteger count = onlyFirstURL ? 1 : [fileList count]; + NSMutableArray *urls = [NSMutableArray array]; + for (NSUInteger i = 0; i < count; i++) { + NSString *string = [fileList objectAtIndex:i]; + + ASSERT([string isKindOfClass:[NSString class]]); // Added to understand why this if code is here + if (![string isKindOfClass:[NSString class]]) + return nil; // Non-string object in the list, bail out! FIXME: When can this happen? + + NSURL *url = [NSURL fileURLWithPath:string]; + [urls addObject:[url absoluteString]]; + } + return urls; +} + +static NSArray *absoluteURLsFromPasteboard(NSPasteboard* pasteboard, bool onlyFirstURL) +{ + // NOTE: We must always check [availableTypes containsObject:] before accessing pasteboard data + // or CoreFoundation will printf when there is not data of the corresponding type. + NSArray *availableTypes = [pasteboard types]; + + // Try NSFilenamesPboardType because it contains a list + if ([availableTypes containsObject:NSFilenamesPboardType]) { + if (NSArray* absoluteURLs = absoluteURLsFromPasteboardFilenames(pasteboard, onlyFirstURL)) + return absoluteURLs; + } + + // Fallback to NSURLPboardType (which is a single URL) + if ([availableTypes containsObject:NSURLPboardType]) { + if (NSURL *url = [NSURL URLFromPasteboard:pasteboard]) + return [NSArray arrayWithObject:[url absoluteString]]; + } + + // No file paths on the pasteboard, return nil + return nil; +} + String ClipboardMac::getData(const String& type, bool& success) const { success = false; if (policy() != ClipboardReadable) return String(); - + NSString *cocoaType = cocoaTypeFromMIMEType(type); NSString *cocoaValue = nil; - NSArray *availableTypes = [m_pasteboard.get() types]; - - // Fetch the data in different ways for the different Cocoa types + // Grab the value off the pasteboard corresponding to the cocoaType if ([cocoaType isEqualToString:NSURLPboardType]) { - // When both URL and filenames are present, filenames is superior since it can contain a list. - // must check this or we get a printf from CF when there's no data of this type - if ([availableTypes containsObject:NSFilenamesPboardType]) { - NSArray *fileList = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType]; - if (fileList && [fileList isKindOfClass:[NSArray class]]) { - unsigned count = [fileList count]; - if (count > 0) { - if (type != "text/uri-list") - count = 1; - NSMutableString *urls = [NSMutableString string]; - unsigned i; - for (i = 0; i < count; i++) { - if (i > 0) { - [urls appendString:@"\n"]; - } - NSString *string = [fileList objectAtIndex:i]; - if (![string isKindOfClass:[NSString class]]) - break; - NSURL *url = [NSURL fileURLWithPath:string]; - [urls appendString:[url absoluteString]]; - } - if (i == count) - cocoaValue = urls; - } - } - } - if (!cocoaValue) { - // must check this or we get a printf from CF when there's no data of this type - if ([availableTypes containsObject:NSURLPboardType]) { - NSURL *url = [NSURL URLFromPasteboard:m_pasteboard.get()]; - if (url) { - cocoaValue = [url absoluteString]; - } - } - } - } else if (cocoaType) { + // "URL" and "text/url-list" both map to NSURLPboardType in cocoaTypeFromMIMEType(), "URL" only wants the first URL + bool onlyFirstURL = (type == "URL"); + NSArray *absoluteURLs = absoluteURLsFromPasteboard(m_pasteboard.get(), onlyFirstURL); + cocoaValue = [absoluteURLs componentsJoinedByString:@"\n"]; + } else if ([cocoaType isEqualToString:NSStringPboardType]) { + cocoaValue = [[m_pasteboard.get() stringForType:cocoaType] precomposedStringWithCanonicalMapping]; + } else if (cocoaType) cocoaValue = [m_pasteboard.get() stringForType:cocoaType]; - } // Enforce changeCount ourselves for security. We check after reading instead of before to be // sure it doesn't change between our testing the change count and accessing the data. @@ -211,7 +229,7 @@ bool ClipboardMac::setData(const String &type, const String &data) NSURL *url = [[NSURL alloc] initWithString:cocoaData]; [url writeToPasteboard:m_pasteboard.get()]; - if ([url isFileURL]) { + if ([url isFileURL] && m_frame->document()->securityOrigin()->canLoadLocalResources()) { [m_pasteboard.get() addTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil]; NSArray *fileList = [NSArray arrayWithObject:[url path]]; [m_pasteboard.get() setPropertyList:fileList forType:NSFilenamesPboardType]; @@ -243,18 +261,15 @@ HashSet<String> ClipboardMac::types() const return HashSet<String>(); HashSet<String> result; - if (types) { - unsigned count = [types count]; - unsigned i; - for (i = 0; i < count; i++) { - NSString *pbType = [types objectAtIndex:i]; - if ([pbType isEqualToString:@"NeXT plain ascii pasteboard type"]) - continue; // skip this ancient type that gets auto-supplied by some system conversion - - String str = MIMETypeFromCocoaType(pbType); - if (!result.contains(str)) - result.add(str); - } + NSUInteger count = [types count]; + for (NSUInteger i = 0; i < count; i++) { + NSString *pbType = [types objectAtIndex:i]; + if ([pbType isEqualToString:@"NeXT plain ascii pasteboard type"]) + continue; // skip this ancient type that gets auto-supplied by some system conversion + + String str = MIMETypeFromCocoaType(pbType); + if (!result.contains(str)) + result.add(str); } return result; } @@ -323,7 +338,7 @@ void ClipboardMac::declareAndWriteDragImage(Element* element, const KURL& url, c { ASSERT(frame); if (Page* page = frame->page()) - page->dragController()->client()->declareAndWriteDragImage(m_pasteboard.get(), [DOMElement _wrapElement:element], url, title, frame); + page->dragController()->client()->declareAndWriteDragImage(m_pasteboard.get(), kit(element), url, title, frame); } DragImageRef ClipboardMac::createDragImage(IntPoint& loc) const diff --git a/src/3rdparty/webkit/WebCore/platform/mac/CookieJar.mm b/src/3rdparty/webkit/WebCore/platform/mac/CookieJar.mm index 94b7d77..d8df601 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/CookieJar.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/CookieJar.mm @@ -27,6 +27,7 @@ #import "CookieJar.h" #import "BlockExceptions.h" +#import "Document.h" #import "KURL.h" #import <wtf/RetainPtr.h> @@ -84,7 +85,7 @@ String cookies(const Document*, const KURL& url) return String(); } -void setCookies(Document*, const KURL& url, const KURL& policyBaseURL, const String& cookieStr) +void setCookies(Document* document, const KURL& url, const String& cookieStr) { BEGIN_BLOCK_OBJC_EXCEPTIONS; @@ -99,7 +100,7 @@ void setCookies(Document*, const KURL& url, const KURL& policyBaseURL, const Str NSURL *cookieURL = url; NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"] forURL:cookieURL]; - [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:filterCookies(cookies).get() forURL:cookieURL mainDocumentURL:policyBaseURL]; + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:filterCookies(cookies).get() forURL:cookieURL mainDocumentURL:document->firstPartyForCookies()]; END_BLOCK_OBJC_EXCEPTIONS; } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/DragDataMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/DragDataMac.mm index 5cf2e14..a7b751c 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/DragDataMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/DragDataMac.mm @@ -124,7 +124,7 @@ String DragData::asURL(String* title) const PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const { - return [m_pasteboardHelper->fragmentFromPasteboard([m_platformDragData draggingPasteboard]) _documentFragment]; + return core(m_pasteboardHelper->fragmentFromPasteboard([m_platformDragData draggingPasteboard])); } } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/DragImageMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/DragImageMac.mm index a20a153..842e6d4 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/DragImageMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/DragImageMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 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 @@ -22,30 +22,29 @@ * (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 "config.h" #import "DragImage.h" #import "CachedImage.h" #import "Image.h" #import "KURL.h" -#import "PlatformString.h" #import "ResourceResponse.h" namespace WebCore { - - -IntSize dragImageSize(DragImageRef image) +IntSize dragImageSize(RetainPtr<NSImage> image) { return (IntSize)[image.get() size]; } -void deleteDragImage(DragImageRef image) +void deleteDragImage(RetainPtr<NSImage>) { - //DragImageRef is a RetainPtr, so we don't need to explicitly delete it + // Since this is a RetainPtr, there's nothing additional we need to do to + // delete it. It will be released when it falls out of scope. } -DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) +RetainPtr<NSImage> scaleDragImage(RetainPtr<NSImage> image, FloatSize scale) { NSSize originalSize = [image.get() size]; NSSize newSize = NSMakeSize((originalSize.width * scale.width()), (originalSize.height * scale.height())); @@ -56,7 +55,7 @@ DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) return image; } -DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta) +RetainPtr<NSImage> dissolveDragImageToFraction(RetainPtr<NSImage> image, float delta) { RetainPtr<NSImage> dissolvedImage(AdoptNS, [[NSImage alloc] initWithSize:[image.get() size]]); @@ -76,14 +75,14 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta) return image; } -DragImageRef createDragImageFromImage(Image* image) +RetainPtr<NSImage> createDragImageFromImage(Image* image) { - DragImageRef dragImage(AdoptNS, [image->getNSImage() copy]); + RetainPtr<NSImage> dragImage(AdoptNS, [image->getNSImage() copy]); [dragImage.get() setSize:(NSSize)(image->size())]; return dragImage; } -DragImageRef createDragImageIconForCachedImage(CachedImage* image) +RetainPtr<NSImage> createDragImageIconForCachedImage(CachedImage* image) { const String& filename = image->response().suggestedFilename(); NSString *extension = nil; @@ -91,12 +90,12 @@ DragImageRef createDragImageIconForCachedImage(CachedImage* image) if (dotIndex > 0 && dotIndex < (int)(filename.length() - 1)) // require that a . exists after the first character and before the last extension = filename.substring(dotIndex + 1); - else - //It might be worth doing a further look up to pull the extension from the mimetype + else { + // It might be worth doing a further lookup to pull the extension from the MIME type. extension = @""; + } - return DragImageRef([[NSWorkspace sharedWorkspace] iconForFileType:extension]); - + return [[NSWorkspace sharedWorkspace] iconForFileType:extension]; } } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/FoundationExtras.h b/src/3rdparty/webkit/WebCore/platform/mac/FoundationExtras.h index 51a7df0..85ce8d7 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/FoundationExtras.h +++ b/src/3rdparty/webkit/WebCore/platform/mac/FoundationExtras.h @@ -23,6 +23,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import <CoreFoundation/CFBase.h> +#import <Foundation/NSObject.h> + // nil-checked CFRetain/CFRelease covers for Objective-C ids // Use CFRetain, CFRelease, HardRetain, or HardRelease instead of diff --git a/src/3rdparty/webkit/WebCore/platform/mac/GeolocationServiceMac.h b/src/3rdparty/webkit/WebCore/platform/mac/GeolocationServiceMac.h new file mode 100644 index 0000000..d0342e7 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/mac/GeolocationServiceMac.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 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 + * 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. ``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 + * 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. + */ + +#ifndef GeolocationServiceMac_h +#define GeolocationServiceMac_h + +#if ENABLE(GEOLOCATION) + +#include "GeolocationService.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/RetainPtr.h> + +#ifdef __OBJC__ +@class CLLocationManager; +@class WebCoreCoreLocationObserver; +#else +class CLLocationManager; +class WebCoreCoreLocationObserver; +#endif + +namespace WebCore { + +class GeolocationServiceMac : public GeolocationService { +public: + GeolocationServiceMac(GeolocationServiceClient*); + virtual ~GeolocationServiceMac(); + + virtual bool startUpdating(PositionOptions*); + virtual void stopUpdating(); + + virtual void suspend(); + virtual void resume(); + + virtual Geoposition* lastPosition() const { return m_lastPosition.get(); } + virtual PositionError* lastError() const { return m_lastError.get(); } + + void positionChanged(PassRefPtr<Geoposition>); + void errorOccurred(PassRefPtr<PositionError>); + +private: + RetainPtr<CLLocationManager> m_locationManager; + RetainPtr<WebCoreCoreLocationObserver> m_objcObserver; + + RefPtr<Geoposition> m_lastPosition; + RefPtr<PositionError> m_lastError; +}; + +} // namespace WebCore + +#endif // ENABLE(GEOLOCATION) + +#endif // GeolocationServiceMac_h diff --git a/src/3rdparty/webkit/WebCore/platform/mac/GeolocationServiceMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/GeolocationServiceMac.mm new file mode 100644 index 0000000..01eca4a --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/mac/GeolocationServiceMac.mm @@ -0,0 +1,219 @@ +/* + * Copyright (C) 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 + * 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. ``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 + * 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 "config.h" + +#if ENABLE(GEOLOCATION) + +#import "GeolocationServiceMac.h" + +#import "Geoposition.h" +#import "PositionError.h" +#import "PositionOptions.h" +#import "SoftLinking.h" +#import <CoreLocation/CoreLocation.h> +#import <objc/objc-runtime.h> +#import <wtf/RefPtr.h> +#import <wtf/UnusedParam.h> + +SOFT_LINK_FRAMEWORK(CoreLocation) + +SOFT_LINK_CLASS(CoreLocation, CLLocationManager) +SOFT_LINK_CLASS(CoreLocation, CLLocation) + +SOFT_LINK_CONSTANT(CoreLocation, kCLLocationAccuracyBest, double) +SOFT_LINK_CONSTANT(CoreLocation, kCLLocationAccuracyHundredMeters, double) + +#define kCLLocationAccuracyBest getkCLLocationAccuracyBest() +#define kCLLocationAccuracyHundredMeters getkCLLocationAccuracyHundredMeters() + +using namespace WebCore; + +@interface WebCoreCoreLocationObserver : NSObject<CLLocationManagerDelegate> +{ + GeolocationServiceMac* m_callback; +} + +- (id)initWithCallback:(GeolocationServiceMac*)callback; + +- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation; +- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error; + +@end + +namespace WebCore { + +GeolocationService* GeolocationService::create(GeolocationServiceClient* client) +{ + return new GeolocationServiceMac(client); +} + +GeolocationServiceMac::GeolocationServiceMac(GeolocationServiceClient* client) + : GeolocationService(client) + , m_objcObserver(AdoptNS, [[WebCoreCoreLocationObserver alloc] initWithCallback:this]) +{ +} + +GeolocationServiceMac::~GeolocationServiceMac() +{ + [m_locationManager.get() stopUpdatingLocation]; + m_locationManager.get().delegate = nil; +} + +bool GeolocationServiceMac::startUpdating(PositionOptions* options) +{ + #define CLLocationManager getCLLocationManagerClass() + if (!m_locationManager.get()) { + m_locationManager.adoptNS([[CLLocationManager alloc] init]); + m_locationManager.get().delegate = m_objcObserver.get(); + } + + if (!m_locationManager.get().locationServicesEnabled) + return false; + + if (options) { + // CLLocationAccuracy values suggested by Ron Huang. + CLLocationAccuracy accuracy = options->enableHighAccuracy() ? kCLLocationAccuracyBest : kCLLocationAccuracyHundredMeters; + m_locationManager.get().desiredAccuracy = accuracy; + } + + // This can safely be called multiple times. + [m_locationManager.get() startUpdatingLocation]; + + return true; + #undef CLLocationManager +} + +void GeolocationServiceMac::stopUpdating() +{ + [m_locationManager.get() stopUpdatingLocation]; +} + +void GeolocationServiceMac::suspend() +{ + [m_locationManager.get() stopUpdatingLocation]; +} + +void GeolocationServiceMac::resume() +{ + [m_locationManager.get() startUpdatingLocation]; +} + +void GeolocationServiceMac::positionChanged(PassRefPtr<Geoposition> position) +{ + m_lastPosition = position; + GeolocationService::positionChanged(); +} + +void GeolocationServiceMac::errorOccurred(PassRefPtr<PositionError> error) +{ + m_lastError = error; + GeolocationService::errorOccurred(); +} + +} // namespace WebCore + +@implementation WebCoreCoreLocationObserver + +- (id)initWithCallback:(GeolocationServiceMac *)callback +{ + self = [super init]; + if (self) + m_callback = callback; + return self; +} + +- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation +{ + ASSERT(m_callback); + ASSERT(newLocation); + UNUSED_PARAM(manager); + UNUSED_PARAM(oldLocation); + + // Normalize + bool canProvideAltitude = true; + bool canProvideAltitudeAccuracy = true; + double altitude = newLocation.altitude; + double altitudeAccuracy = newLocation.verticalAccuracy; + if (altitudeAccuracy < 0.0) { + canProvideAltitude = false; + canProvideAltitudeAccuracy = false; + } + + bool canProvideSpeed = true; + double speed = newLocation.speed; + if (speed < 0.0) + canProvideSpeed = false; + + bool canProvideHeading = true; + double heading = newLocation.course; + if (heading < 0.0) + canProvideHeading = false; + + WTF::RefPtr<WebCore::Coordinates> newCoordinates = WebCore::Coordinates::create( + newLocation.coordinate.latitude, + newLocation.coordinate.longitude, + canProvideAltitude, + altitude, + newLocation.horizontalAccuracy, + canProvideAltitudeAccuracy, + altitudeAccuracy, + canProvideHeading, + heading, + canProvideSpeed, + speed); + WTF::RefPtr<WebCore::Geoposition> newPosition = WebCore::Geoposition::create( + newCoordinates.release(), + [newLocation.timestamp timeIntervalSince1970] * 1000.0); // seconds -> milliseconds + + m_callback->positionChanged(newPosition.release()); +} + +- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error +{ + ASSERT(m_callback); + ASSERT(error); + + UNUSED_PARAM(manager); + + PositionError::ErrorCode code; + switch ([error code]) { + case kCLErrorDenied: + code = PositionError::PERMISSION_DENIED; + break; + case kCLErrorLocationUnknown: + code = PositionError::POSITION_UNAVAILABLE; + break; + default: + code = PositionError::POSITION_UNAVAILABLE; + break; + } + + m_callback->errorOccurred(PositionError::create(code, [error localizedDescription])); +} + +@end + +#endif // ENABLE(GEOLOCATION) diff --git a/src/3rdparty/webkit/WebCore/platform/mac/LocalCurrentGraphicsContext.h b/src/3rdparty/webkit/WebCore/platform/mac/LocalCurrentGraphicsContext.h index 856cf52..1c5cae7 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/LocalCurrentGraphicsContext.h +++ b/src/3rdparty/webkit/WebCore/platform/mac/LocalCurrentGraphicsContext.h @@ -19,7 +19,11 @@ #include <wtf/Noncopyable.h> +#ifdef __OBJC__ +@class NSGraphicsContext; +#else class NSGraphicsContext; +#endif namespace WebCore { diff --git a/src/3rdparty/webkit/WebCore/platform/mac/LocalizedStringsMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/LocalizedStringsMac.mm index d465758..ebb6d93 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/LocalizedStringsMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/LocalizedStringsMac.mm @@ -433,6 +433,110 @@ String contextMenuItemTagRightToLeft() return String(); } +String contextMenuItemTagCorrectSpellingAutomatically() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCorrectSpellingAutomatically]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagSubstitutionsMenu() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSubstitutionsMenu]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagShowSubstitutions(bool show) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowSubstitutions:show]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagSmartCopyPaste() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartCopyPaste]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagSmartQuotes() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartQuotes]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagSmartDashes() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartDashes]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagSmartLinks() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSmartLinks]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagTextReplacement() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagTextReplacement]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagTransformationsMenu() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagTransformationsMenu]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagMakeUpperCase() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagMakeUpperCase]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagMakeLowerCase() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagMakeLowerCase]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagCapitalize() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCapitalize]; + END_BLOCK_OBJC_EXCEPTIONS; + return String(); +} + +String contextMenuItemTagChangeBack(const String& replacedString) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + return [[WebCoreViewFactory sharedFactory] contextMenuItemTagChangeBack:replacedString]; + END_BLOCK_OBJC_EXCEPTIONS; + return replacedString; +} + String contextMenuItemTagInspectElement() { BEGIN_BLOCK_OBJC_EXCEPTIONS; diff --git a/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm index e4bfe32..c0e43b3 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/PasteboardMac.mm @@ -46,6 +46,7 @@ #import <wtf/StdLibExtras.h> #import <wtf/RetainPtr.h> +#import <wtf/UnusedParam.h> @interface NSAttributedString (AppKitSecretsIKnowAbout) - (id)_initWithDOMRange:(DOMRange *)domRange; @@ -138,12 +139,13 @@ void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, Pasteboard::generalPasteboard(); //Initialises pasteboard types ASSERT(selectedRange); - NSAttributedString *attributedString = [[[NSAttributedString alloc] _initWithDOMRange:[DOMRange _wrapRange:selectedRange]] autorelease]; + NSAttributedString *attributedString = [[[NSAttributedString alloc] _initWithDOMRange:kit(selectedRange)] autorelease]; #ifdef BUILDING_ON_TIGER // 4930197: Mail overrides [WebHTMLView pasteboardTypesForSelection] in order to add another type to the pasteboard // after WebKit does. On Tiger we must call this function so that Mail code will be executed, meaning that // we can't call WebCore::Pasteboard's method for setting types. - + UNUSED_PARAM(canSmartCopyOrDelete); + NSArray *types = frame->editor()->client()->pasteboardTypesForSelection(frame); // Don't write RTFD to the pasteboard when the copied attributed string has no attachments. NSMutableArray *mutableTypes = nil; @@ -182,8 +184,7 @@ void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, if ([types containsObject:NSStringPboardType]) { // Map to a plain old space because this is better for source code, other browsers do it, // and because HTML forces you to do this any time you want two spaces in a row. - String text = selectedRange->text(); - text.replace('\\', frame->backslashAsCurrencySymbol()); + String text = frame->displayStringModifiedByEncoding(selectedRange->text()); NSMutableString *s = [[[(NSString*)text copy] autorelease] mutableCopy]; NSString *NonBreakingSpaceString = [NSString stringWithCharacters:&noBreakSpace length:1]; @@ -277,7 +278,7 @@ void Pasteboard::writeImage(Node* node, const KURL& url, const String& title) ASSERT(cocoaURL); ASSERT(node->renderer() && node->renderer()->isImage()); - RenderImage* renderer = static_cast<RenderImage*>(node->renderer()); + RenderImage* renderer = toRenderImage(node->renderer()); CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage()); ASSERT(cachedImage); @@ -309,7 +310,7 @@ String Pasteboard::plainText(Frame* frame) NSArray *types = [m_pasteboard.get() types]; if ([types containsObject:NSStringPboardType]) - return [m_pasteboard.get() stringForType:NSStringPboardType]; + return [[m_pasteboard.get() stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]; NSAttributedString *attributedString = nil; NSString *string; @@ -319,13 +320,13 @@ String Pasteboard::plainText(Frame* frame) if (attributedString == nil && [types containsObject:NSRTFPboardType]) attributedString = [[NSAttributedString alloc] initWithRTF:[m_pasteboard.get() dataForType:NSRTFPboardType] documentAttributes:NULL]; if (attributedString != nil) { - string = [[attributedString string] copy]; + string = [[attributedString string] precomposedStringWithCanonicalMapping]; [attributedString release]; - return [string autorelease]; + return string; } if ([types containsObject:NSFilenamesPboardType]) { - string = [[m_pasteboard.get() propertyListForType:NSFilenamesPboardType] componentsJoinedByString:@"\n"]; + string = [[[m_pasteboard.get() propertyListForType:NSFilenamesPboardType] componentsJoinedByString:@"\n"] precomposedStringWithCanonicalMapping]; if (string != nil) return string; } @@ -337,7 +338,7 @@ String Pasteboard::plainText(Frame* frame) // helper code that should either be done in a separate patch or figured out in another way. string = frame->editor()->client()->userVisibleString(url); if ([string length] > 0) - return string; + return [string precomposedStringWithCanonicalMapping]; } @@ -367,7 +368,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP if (allowPlainText && [types containsObject:NSStringPboardType]) { chosePlainText = true; - RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), [m_pasteboard.get() stringForType:NSStringPboardType]); + RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), [[m_pasteboard.get() stringForType:NSStringPboardType] precomposedStringWithCanonicalMapping]); if (fragment) return fragment.release(); } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/PlatformMouseEventMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/PlatformMouseEventMac.mm index af7415d..74f694e 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/PlatformMouseEventMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/PlatformMouseEventMac.mm @@ -68,12 +68,12 @@ static int clickCountForEvent(NSEvent *event) } } -IntPoint globalPoint(const NSPoint& windowPoint, NSWindow* window) +IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *window) { return IntPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], screenForWindow(window))); } -IntPoint pointForEvent(NSEvent *event) +IntPoint pointForEvent(NSEvent *event, NSView *windowView) { switch ([event type]) { case NSLeftMouseDown: @@ -86,11 +86,14 @@ IntPoint pointForEvent(NSEvent *event) case NSOtherMouseUp: case NSOtherMouseDragged: case NSMouseMoved: - case NSScrollWheel: - // Note: This has its origin at the bottom left of the window. - // The Y coordinate gets flipped by ScrollView::viewportToContents. - // We should probably change both this and that to not use "bottom left origin" coordinates at all. - return IntPoint([event locationInWindow]); + case NSScrollWheel: { + // Note: This will have its origin at the bottom left of the window unless windowView is flipped. + // In those cases, the Y coordinate gets flipped by Widget::convertFromContainingWindow. + NSPoint location = [event locationInWindow]; + if (windowView) + location = [windowView convertPoint:location fromView:nil]; + return IntPoint(location); + } default: return IntPoint(); } @@ -116,25 +119,6 @@ IntPoint globalPointForEvent(NSEvent *event) } } -int eventNumberForEvent(NSEvent *event) -{ - switch ([event type]) { - case NSLeftMouseDown: - case NSLeftMouseUp: - case NSLeftMouseDragged: - case NSRightMouseDown: - case NSRightMouseUp: - case NSRightMouseDragged: - case NSOtherMouseDown: - case NSOtherMouseUp: - case NSOtherMouseDragged: - case NSMouseMoved: - return [event eventNumber]; - default: - return 0; - } -} - static MouseEventType mouseEventForNSEvent(NSEvent* event) { switch ([event type]) { @@ -158,8 +142,8 @@ static MouseEventType mouseEventForNSEvent(NSEvent* event) } } -PlatformMouseEvent::PlatformMouseEvent(NSEvent* event) - : m_position(pointForEvent(event)) +PlatformMouseEvent::PlatformMouseEvent(NSEvent* event, NSView *windowView) + : m_position(pointForEvent(event, windowView)) , m_globalPosition(globalPointForEvent(event)) , m_button(mouseButtonForEvent(event)) , m_eventType(mouseEventForNSEvent(event)) diff --git a/src/3rdparty/webkit/WebCore/platform/mac/PlatformScreenMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/PlatformScreenMac.mm index 8f12df0..5dbfcf4 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/PlatformScreenMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/PlatformScreenMac.mm @@ -45,11 +45,7 @@ int screenDepthPerComponent(Widget*) bool screenIsMonochrome(Widget*) { - NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]); - return colorSpace == NSCalibratedWhiteColorSpace - || colorSpace == NSCalibratedBlackColorSpace - || colorSpace == NSDeviceWhiteColorSpace - || colorSpace == NSDeviceBlackColorSpace; + return false; } // These functions scale between screen and page coordinates because JavaScript/DOM operations diff --git a/src/3rdparty/webkit/WebCore/platform/mac/RuntimeApplicationChecks.h b/src/3rdparty/webkit/WebCore/platform/mac/RuntimeApplicationChecks.h new file mode 100644 index 0000000..44eedfa --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/mac/RuntimeApplicationChecks.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 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 + * 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 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. + */ + +#ifndef RuntimeApplicationChecks_h +#define RuntimeApplicationChecks_h + +namespace WebCore { + +bool applicationIsAppleMail(); +bool applicationIsSafari(); + +} // namespace WebCore + +#endif // RuntimeApplicationChecks_h diff --git a/src/3rdparty/webkit/WebCore/platform/mac/RuntimeApplicationChecks.mm b/src/3rdparty/webkit/WebCore/platform/mac/RuntimeApplicationChecks.mm new file mode 100644 index 0000000..1670185 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/platform/mac/RuntimeApplicationChecks.mm @@ -0,0 +1,44 @@ +/* + * Copyright (C) 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 + * 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 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 "config.h" +#import "RuntimeApplicationChecks.h" + + +namespace WebCore { + +bool applicationIsAppleMail() +{ + static const bool isAppleMail = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.mail"]; + return isAppleMail; +} + +bool applicationIsSafari() +{ + static const bool isSafari = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"]; + return isSafari; +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/platform/mac/ScrollbarThemeMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/ScrollbarThemeMac.mm index b39b8bc..759a6e1 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/ScrollbarThemeMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/ScrollbarThemeMac.mm @@ -26,17 +26,12 @@ #include "config.h" #include "ScrollbarThemeMac.h" -#include "GraphicsContext.h" #include "ImageBuffer.h" -#include "IntRect.h" -#include "Page.h" #include "PlatformMouseEvent.h" -#include "Scrollbar.h" -#include "ScrollbarClient.h" -#include "Settings.h" -#include <wtf/StdLibExtras.h> - +#include "ScrollView.h" #include <Carbon/Carbon.h> +#include <wtf/StdLibExtras.h> +#include <wtf/UnusedParam.h> // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow. @@ -58,8 +53,10 @@ static HashSet<Scrollbar*>* gScrollbars; @implementation ScrollbarPrefsObserver -+ (void)appearancePrefsChanged:(NSNotification*)theNotification ++ (void)appearancePrefsChanged:(NSNotification*)unusedNotification { + UNUSED_PARAM(unusedNotification); + static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged(); if (!gScrollbars) return; @@ -70,8 +67,10 @@ static HashSet<Scrollbar*>* gScrollbars; } } -+ (void)behaviorPrefsChanged:(NSNotification*)theNotification ++ (void)behaviorPrefsChanged:(NSNotification*)unusedNotification { + UNUSED_PARAM(unusedNotification); + static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged(); } @@ -367,9 +366,12 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co trackInfo.attributes = 0; if (scrollbar->orientation() == HorizontalScrollbar) trackInfo.attributes |= kThemeTrackHorizontal; - trackInfo.enableState = scrollbar->client()->isActive() ? kThemeTrackActive : kThemeTrackInactive; + if (!scrollbar->enabled()) trackInfo.enableState = kThemeTrackDisabled; + else + trackInfo.enableState = scrollbar->client()->isActive() ? kThemeTrackActive : kThemeTrackInactive; + if (hasThumb(scrollbar)) trackInfo.attributes |= kThemeTrackShowThumb; else if (!hasButtons(scrollbar)) @@ -389,8 +391,8 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co bufferRect.intersect(damageRect); bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y()); - auto_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(bufferRect.size(), false); - if (!imageBuffer.get()) + OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(bufferRect.size(), false); + if (!imageBuffer) return true; HIThemeDrawTrack(&trackInfo, 0, imageBuffer->context()->platformContext(), kHIThemeOrientationNormal); diff --git a/src/3rdparty/webkit/WebCore/platform/mac/SharedBufferMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/SharedBufferMac.mm index f1d9517..c4e7528 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/SharedBufferMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/SharedBufferMac.mm @@ -39,7 +39,7 @@ using namespace WebCore; @interface WebCoreSharedBufferData : NSData { - SharedBuffer* sharedBuffer; + RefPtr<SharedBuffer> sharedBuffer; } - (id)initWithSharedBuffer:(SharedBuffer*)buffer; @@ -59,16 +59,12 @@ using namespace WebCore; { if (WebCoreObjCScheduleDeallocateOnMainThread([WebCoreSharedBufferData class], self)) return; - - sharedBuffer->deref(); [super dealloc]; } - (void)finalize { - sharedBuffer->deref(); - [super finalize]; } @@ -76,10 +72,8 @@ using namespace WebCore; { self = [super init]; - if (self) { + if (self) sharedBuffer = buffer; - sharedBuffer->ref(); - } return self; } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/SharedTimerMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/SharedTimerMac.mm index 991f527..b9eaaef 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/SharedTimerMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/SharedTimerMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,8 +26,8 @@ #import "config.h" #import "SharedTimer.h" -#include <Foundation/Foundation.h> -#include <wtf/Assertions.h> +#import <wtf/Assertions.h> +#import <wtf/UnusedParam.h> @class WebCorePowerNotifier; @@ -58,8 +58,10 @@ static void timerFired(CFRunLoopTimerRef, void*); return self; } -- (void)didWake:(NSNotification *)notification +- (void)didWake:(NSNotification *)unusedNotification { + UNUSED_PARAM(unusedNotification); + if (WebCore::sharedTimer) { WebCore::stopSharedTimer(); WebCore::timerFired(0, 0); diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreTextRenderer.h b/src/3rdparty/webkit/WebCore/platform/mac/SuddenTermination.mm index 3e77434..513d01b 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreTextRenderer.h +++ b/src/3rdparty/webkit/WebCore/platform/mac/SuddenTermination.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 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 @@ -10,31 +10,36 @@ * 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 COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef __cplusplus -extern "C" { -#endif +#import "config.h" +#import "SuddenTermination.h" + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + +namespace WebCore { -extern void WebCoreDrawTextAtPoint(const UniChar*, unsigned length, NSPoint, NSFont*, NSColor*); -extern float WebCoreTextFloatWidth(const UniChar*, unsigned length, NSFont*); -extern void WebCoreSetShouldUseFontSmoothing(bool); -extern bool WebCoreShouldUseFontSmoothing(); -extern void WebCoreSetAlwaysUsesComplexTextCodePath(bool); -extern bool WebCoreAlwaysUsesComplexTextCodePath(); -extern NSFont* WebCoreFindFont(NSString* familyName, NSFontTraitMask, int weight, int size); +void disableSuddenTermination() +{ + [[NSProcessInfo processInfo] disableSuddenTermination]; +} -#ifdef __cplusplus +void enableSuddenTermination() +{ + [[NSProcessInfo processInfo] enableSuddenTermination]; } + +} // namespace WebCore + #endif diff --git a/src/3rdparty/webkit/WebCore/platform/mac/SystemTimeMac.cpp b/src/3rdparty/webkit/WebCore/platform/mac/SystemTimeMac.cpp index dd5e500..1b2aae0 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/SystemTimeMac.cpp +++ b/src/3rdparty/webkit/WebCore/platform/mac/SystemTimeMac.cpp @@ -31,11 +31,6 @@ namespace WebCore { -double currentTime() -{ - return CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970; -} - float userIdleTime() { return static_cast<float>(CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType)); diff --git a/src/3rdparty/webkit/WebCore/platform/mac/ThreadCheck.mm b/src/3rdparty/webkit/WebCore/platform/mac/ThreadCheck.mm index b862598..ddee05c 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/ThreadCheck.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/ThreadCheck.mm @@ -32,56 +32,74 @@ namespace WebCore { -static ThreadViolationBehavior defaultThreadViolationBehavior = RaiseExceptionOnThreadViolation; - static bool didReadThreadViolationBehaviorFromUserDefaults = false; -static bool threadViolationBehaviorIsDefault; -static ThreadViolationBehavior threadViolationBehavior; +static bool threadViolationBehaviorIsDefault = true; +static ThreadViolationBehavior threadViolationBehavior[MaximumThreadViolationRound] = { RaiseExceptionOnThreadViolation, RaiseExceptionOnThreadViolation }; static void readThreadViolationBehaviorFromUserDefaults() { + didReadThreadViolationBehaviorFromUserDefaults = true; + + ThreadViolationBehavior newBehavior = LogOnFirstThreadViolation; NSString *threadCheckLevel = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebCoreThreadCheck"]; + if (!threadCheckLevel) + return; + if ([threadCheckLevel isEqualToString:@"None"]) - threadViolationBehavior = NoThreadCheck; + newBehavior = NoThreadCheck; else if ([threadCheckLevel isEqualToString:@"Exception"]) - threadViolationBehavior = RaiseExceptionOnThreadViolation; + newBehavior = RaiseExceptionOnThreadViolation; else if ([threadCheckLevel isEqualToString:@"Log"]) - threadViolationBehavior = LogOnThreadViolation; + newBehavior = LogOnThreadViolation; else if ([threadCheckLevel isEqualToString:@"LogOnce"]) - threadViolationBehavior = LogOnFirstThreadViolation; - else { - threadViolationBehavior = defaultThreadViolationBehavior; - threadViolationBehaviorIsDefault = true; - } - didReadThreadViolationBehaviorFromUserDefaults = true; + newBehavior = LogOnFirstThreadViolation; + else + ASSERT_NOT_REACHED(); + + threadViolationBehaviorIsDefault = false; + + for (unsigned i = 0; i < MaximumThreadViolationRound; ++i) + threadViolationBehavior[i] = newBehavior; } -void setDefaultThreadViolationBehavior(ThreadViolationBehavior behavior) +void setDefaultThreadViolationBehavior(ThreadViolationBehavior behavior, ThreadViolationRound round) { - defaultThreadViolationBehavior = behavior; + ASSERT(round < MaximumThreadViolationRound); + if (round >= MaximumThreadViolationRound) + return; + if (!didReadThreadViolationBehaviorFromUserDefaults) + readThreadViolationBehaviorFromUserDefaults(); if (threadViolationBehaviorIsDefault) - threadViolationBehavior = behavior; + threadViolationBehavior[round] = behavior; } -void reportThreadViolation(const char* function) +void reportThreadViolation(const char* function, ThreadViolationRound round) { + ASSERT(round < MaximumThreadViolationRound); + if (round >= MaximumThreadViolationRound) + return; if (!didReadThreadViolationBehaviorFromUserDefaults) - readThreadViolationBehaviorFromUserDefaults(); - if (threadViolationBehavior == NoThreadCheck) + readThreadViolationBehaviorFromUserDefaults(); + if (threadViolationBehavior[round] == NoThreadCheck) return; if (pthread_main_np()) return; - WebCoreReportThreadViolation(function); + WebCoreReportThreadViolation(function, round); } } // namespace WebCore // Split out the actual reporting of the thread violation to make it easier to set a breakpoint -void WebCoreReportThreadViolation(const char* function) +void WebCoreReportThreadViolation(const char* function, WebCore::ThreadViolationRound round) { using namespace WebCore; + + ASSERT(round < MaximumThreadViolationRound); + if (round >= MaximumThreadViolationRound) + return; + DEFINE_STATIC_LOCAL(HashSet<String>, loggedFunctions, ()); - switch (threadViolationBehavior) { + switch (threadViolationBehavior[round]) { case NoThreadCheck: break; case LogOnFirstThreadViolation: diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreKeyGenerator.m b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreKeyGenerator.m index c1004a7..a1e780c 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreKeyGenerator.m +++ b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreKeyGenerator.m @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,6 +27,7 @@ #import "WebCoreKeyGenerator.h" #import <wtf/Assertions.h> +#import <wtf/UnusedParam.h> static WebCoreKeyGenerator *sharedGenerator; @@ -50,8 +51,12 @@ static WebCoreKeyGenerator *sharedGenerator; return nil; } -- (NSString *)signedPublicKeyAndChallengeStringWithStrengthIndex:(unsigned)index challenge:(NSString *)challenge pageURL:(NSURL *)pageURL +- (NSString *)signedPublicKeyAndChallengeStringWithStrengthIndex:(unsigned)unusedIndex challenge:(NSString *)unusedChallenge pageURL:(NSURL *)unusedPageURL { + UNUSED_PARAM(unusedIndex); + UNUSED_PARAM(unusedChallenge); + UNUSED_PARAM(unusedPageURL); + return nil; } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreObjCExtras.mm b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreObjCExtras.mm index 4735fd7..cb8d504 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreObjCExtras.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreObjCExtras.mm @@ -34,6 +34,7 @@ #include <wtf/Assertions.h> #include <wtf/MainThread.h> #include <wtf/Threading.h> +#include <wtf/UnusedParam.h> void WebCoreObjCFinalizeOnMainThread(Class cls) { @@ -41,6 +42,8 @@ void WebCoreObjCFinalizeOnMainThread(Class cls) // WebCoreObjCScheduleDeallocateOnMainThread will crash. #if !defined(BUILDING_ON_TIGER) && !defined(DONT_FINALIZE_ON_MAIN_THREAD) objc_finalizeOnMainThread(cls); +#else + UNUSED_PARAM(cls); #endif } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.h b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.h index 126533c..cbe4aea 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.h +++ b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.h @@ -40,12 +40,21 @@ typedef struct _NSRect NSRect; #endif #ifdef __OBJC__ +@class NSArray; @class NSButtonCell; @class NSData; +@class NSDate; @class NSEvent; @class NSFont; +@class NSImage; +@class NSMenu; @class NSMutableURLRequest; +@class NSString; +@class NSTextFieldCell; +@class NSURLConnection; @class NSURLRequest; +@class NSURLResponse; +@class NSView; @class QTMovie; @class QTMovieView; #else @@ -95,8 +104,8 @@ extern void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius); extern NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange); extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar); extern BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance); -extern void (*wkDrawMediaSliderTrack)(CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration); -extern void (*wkDrawMediaUIPart)(int part, CGContextRef context, CGRect rect, BOOL active); +extern void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration); +extern void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, BOOL active); extern NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*); extern NSArray* (*wkGetExtensionsForMIMEType)(NSString*); extern NSString* (*wkGetMIMETypeForExtension)(NSString*); @@ -105,11 +114,14 @@ extern double (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response) extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response); extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response); extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous); -extern BOOL (*wkHitTestMediaUIPart)(int part, CGRect bounds, CGPoint point); -extern void (*wkMeasureMediaUIPart)(int part, CGRect *bounds, CGSize *naturalSize); +extern BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point); +extern void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize); extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*); +extern unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void); extern int (*wkQTMovieDataRate)(QTMovie*); extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*); +extern NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void); +extern float (*wkQTMovieMaxTimeSeekable)(QTMovie*); extern void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL); extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*); extern void (*wkSetDragImage)(NSImage*, NSPoint offset); @@ -121,6 +133,7 @@ extern void (*wkSetUpFontCache)(); extern void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream); extern void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error); extern void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream); +extern unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount); #ifndef BUILDING_ON_TIGER extern void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t); diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.mm b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.mm index d7ca824..05d1da6 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreSystemInterface.mm @@ -25,6 +25,7 @@ #import "config.h" #import "WebCoreSystemInterface.h" +#import <Foundation/Foundation.h> void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *); BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef); @@ -38,11 +39,10 @@ void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius); NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange); NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar); BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance); -void (*wkDrawMediaSliderTrack)(CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration); -BOOL (*wkUseSharedMediaUI)(); -BOOL (*wkHitTestMediaUIPart)(int part, CGRect bounds, CGPoint point); -void (*wkDrawMediaUIPart)(int part, CGContextRef context, CGRect rect, BOOL active); -void (*wkMeasureMediaUIPart)(int part, CGRect *bounds, CGSize *naturalSize); +void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration); +BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point); +void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, BOOL active); +void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize); NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*); NSArray* (*wkGetExtensionsForMIMEType)(NSString*); NSString* (*wkGetMIMETypeForExtension)(NSString*); @@ -51,8 +51,11 @@ NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response); BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response); void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous); void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*); +unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void); int (*wkQTMovieDataRate)(QTMovie*); float (*wkQTMovieMaxTimeLoaded)(QTMovie*); +NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void); +float (*wkQTMovieMaxTimeSeekable)(QTMovie*); void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL); void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*); void (*wkSetDragImage)(NSImage*, NSPoint offset); @@ -74,6 +77,7 @@ CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRe void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL); void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL); id (*wkCreateNSURLConnectionDelegateProxy)(void); +unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount); #ifndef BUILDING_ON_TIGER void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t); diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreTextRenderer.mm b/src/3rdparty/webkit/WebCore/platform/mac/WebCoreTextRenderer.mm deleted file mode 100644 index 0cd5967..0000000 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebCoreTextRenderer.mm +++ /dev/null @@ -1,93 +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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR - * 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 "config.h" -#import "WebCoreTextRenderer.h" - -#import "Font.h" -#import "SimpleFontData.h" -#import "GraphicsContext.h" -#import "IntPoint.h" -#import "WebFontCache.h" - -using namespace WebCore; - -void WebCoreDrawTextAtPoint(const UniChar* buffer, unsigned length, NSPoint point, NSFont* font, NSColor* textColor) -{ - NSGraphicsContext *nsContext = [NSGraphicsContext currentContext]; - CGContextRef cgContext = (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.0f, -1.0f); - - FontPlatformData f(font); - Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]); - TextRun run(buffer, length); - run.disableRoundingHacks(); - CGFloat red, green, blue, alpha; - [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha]; - graphicsContext.setFillColor(makeRGBA((int)(red * 255), (int)(green * 255), (int)(blue * 255), (int)(alpha * 255))); - renderer.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1.0f * point.y)))); - if (!flipped) - CGContextScaleCTM(cgContext, 1.0f, -1.0f); -} - -float WebCoreTextFloatWidth(const UniChar* buffer, unsigned length , NSFont* font) -{ - FontPlatformData f(font); - Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]); - TextRun run(buffer, length); - run.disableRoundingHacks(); - return renderer.floatWidth(run); -} - -static bool gShouldUseFontSmoothing = true; - -void WebCoreSetShouldUseFontSmoothing(bool smooth) -{ - gShouldUseFontSmoothing = smooth; -} - -bool WebCoreShouldUseFontSmoothing() -{ - return gShouldUseFontSmoothing; -} - -void WebCoreSetAlwaysUsesComplexTextCodePath(bool complex) -{ - Font::setCodePath(complex ? Font::Complex : Font::Auto); -} - -bool WebCoreAlwaysUsesComplexTextCodePath() -{ - return Font::codePath() == Font::Complex; -} - -NSFont* WebCoreFindFont(NSString* familyName, NSFontTraitMask traits, int weight, int size) -{ - return [WebFontCache fontWithFamily:familyName traits:traits weight:weight size:size]; -} diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.h b/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.h index b31a684..380f271 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.h +++ b/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.h @@ -24,11 +24,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <wtf/Vector.h> +#import <AppKit/NSFontManager.h> +#import <wtf/Vector.h> // This interface exists so that third party products (like Silk) can patch in to an Obj-C method to manipulate WebKit's font caching/substitution. @interface WebFontCache : NSObject + (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits weight:(int)desiredWeight size:(float)size; + (void)getTraits:(Vector<unsigned>&)traitsMasks inFamily:(NSString *)desiredFamily; +// This older version of the interface is relied upon by some clients. WebCore doesn't use it. ++ (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits size:(float)size; @end diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.mm b/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.mm index 84f60b5..22e6291 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/WebFontCache.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> * * Redistribution and use in source and binary forms, with or without @@ -28,10 +28,13 @@ */ #import "config.h" -#import "FontTraitsMask.h" #import "WebFontCache.h" +#import "FontTraitsMask.h" +#import <AppKit/AppKit.h> +#import <Foundation/Foundation.h> #import <math.h> +#import <wtf/UnusedParam.h> using namespace WebCore; @@ -51,7 +54,7 @@ typedef int NSInteger; | NSSmallCapsFontMask \ ) -static BOOL acceptableChoice(NSFontTraitMask desiredTraits, int desiredWeight, NSFontTraitMask candidateTraits, int candidateWeight) +static BOOL acceptableChoice(NSFontTraitMask desiredTraits, NSFontTraitMask candidateTraits) { desiredTraits &= ~SYNTHESIZED_FONT_TRAITS; return (candidateTraits & desiredTraits) == desiredTraits; @@ -61,7 +64,7 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight, NSFontTraitMask chosenTraits, int chosenWeight, NSFontTraitMask candidateTraits, int candidateWeight) { - if (!acceptableChoice(desiredTraits, desiredWeight, candidateTraits, candidateWeight)) + if (!acceptableChoice(desiredTraits, candidateTraits)) return NO; // A list of the traits we care about. @@ -104,8 +107,13 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight, // Workaround for <rdar://problem/5781372>. static inline void fixUpWeight(NSInteger& weight, NSString *fontName) { +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + UNUSED_PARAM(weight); + UNUSED_PARAM(fontName); +#else if (weight == 3 && [fontName rangeOfString:@"ultralight" options:NSCaseInsensitiveSearch | NSBackwardsSearch | NSLiteralSearch].location != NSNotFound) weight = 2; +#endif } static inline FontTraitsMask toTraitsMask(NSFontTraitMask appKitTraits, NSInteger appKitWeight) @@ -230,7 +238,7 @@ static inline FontTraitsMask toTraitsMask(NSFontTraitMask appKitTraits, NSIntege BOOL newWinner; if (!choseFont) - newWinner = acceptableChoice(desiredTraits, desiredWeight, fontTraits, fontWeight); + newWinner = acceptableChoice(desiredTraits, fontTraits); else newWinner = betterChoice(desiredTraits, desiredWeight, chosenTraits, chosenWeight, fontTraits, fontWeight); @@ -298,4 +306,10 @@ static inline FontTraitsMask toTraitsMask(NSFontTraitMask appKitTraits, NSIntege return [self internalFontWithFamily:desiredFamily traits:desiredTraits weight:desiredWeight size:size]; } ++ (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits size:(float)size +{ + int desiredWeight = (desiredTraits & NSBoldFontMask) ? 9 : 5; + return [self fontWithFamily:desiredFamily traits:desiredTraits weight:desiredWeight size:size]; +} + @end diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WheelEventMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/WheelEventMac.mm index 7b60494..f380e3e 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WheelEventMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/WheelEventMac.mm @@ -27,13 +27,15 @@ #import "PlatformWheelEvent.h" #import "PlatformMouseEvent.h" +#import "Scrollbar.h" #import "WebCoreSystemInterface.h" namespace WebCore { -PlatformWheelEvent::PlatformWheelEvent(NSEvent* event) - : m_position(pointForEvent(event)) +PlatformWheelEvent::PlatformWheelEvent(NSEvent* event, NSView *windowView) + : m_position(pointForEvent(event, windowView)) , m_globalPosition(globalPointForEvent(event)) + , m_granularity(ScrollByPixelWheelEvent) , m_isAccepted(false) , m_shiftKey([event modifierFlags] & NSShiftKeyMask) , m_ctrlKey([event modifierFlags] & NSControlKeyMask) @@ -42,10 +44,14 @@ PlatformWheelEvent::PlatformWheelEvent(NSEvent* event) { BOOL continuous; wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous); - m_granularity = continuous ? ScrollByPixelWheelEvent : ScrollByLineWheelEvent; - if (m_granularity == ScrollByLineWheelEvent) { - m_deltaX *= horizontalLineMultiplier(); - m_deltaY *= verticalLineMultiplier(); + if (continuous) { + m_wheelTicksX = m_deltaX / static_cast<float>(cScrollbarPixelsPerLineStep); + m_wheelTicksY = m_deltaY / static_cast<float>(cScrollbarPixelsPerLineStep); + } else { + m_wheelTicksX = m_deltaX; + m_wheelTicksY = m_deltaY; + m_deltaX *= static_cast<float>(cScrollbarPixelsPerLineStep); + m_deltaY *= static_cast<float>(cScrollbarPixelsPerLineStep); } } diff --git a/src/3rdparty/webkit/WebCore/platform/mac/WidgetMac.mm b/src/3rdparty/webkit/WebCore/platform/mac/WidgetMac.mm index 3fe8e0d..1aaf4b2 100644 --- a/src/3rdparty/webkit/WebCore/platform/mac/WidgetMac.mm +++ b/src/3rdparty/webkit/WebCore/platform/mac/WidgetMac.mm @@ -26,6 +26,10 @@ #import "config.h" #import "Widget.h" +#ifdef BUILDING_ON_TIGER +#import "AutodrainedPool.h" +#endif + #import "BlockExceptions.h" #import "Cursor.h" #import "Document.h" @@ -38,7 +42,6 @@ #import "ScrollView.h" #import "WebCoreFrameView.h" #import "WebCoreView.h" - #import <wtf/RetainPtr.h> @interface NSWindow (WebWindowDetails) @@ -218,8 +221,13 @@ void Widget::paint(GraphicsContext* p, const IntRect& r) CGContextScaleCTM(cgContext, 1, -1); BEGIN_BLOCK_OBJC_EXCEPTIONS; - NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]; - [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]] inContext:nsContext]; + { +#ifdef BUILDING_ON_TIGER + AutodrainedPool pool; +#endif + NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]; + [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]] inContext:nsContext]; + } END_BLOCK_OBJC_EXCEPTIONS; CGContextRestoreGState(cgContext); @@ -252,10 +260,10 @@ void Widget::removeFromSuperview() } } -void Widget::beforeMouseDown(NSView *view, Widget* widget) +void Widget::beforeMouseDown(NSView *unusedView, Widget* widget) { if (widget) { - ASSERT(view == widget->getOuterView()); + ASSERT_UNUSED(unusedView, unusedView == widget->getOuterView()); ASSERT(!widget->m_data->mustStayInWindow); widget->m_data->mustStayInWindow = true; } @@ -277,7 +285,9 @@ void Widget::afterMouseDown(NSView *view, Widget* widget) IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const { - if (!platformWidget() && parent()) { + if (!platformWidget()) { + if (!parent()) + return point; IntPoint result = parent()->convertFromContainingWindow(point); result.move(parent()->scrollX() - x(), parent()->scrollY() - y()); return result; @@ -292,7 +302,9 @@ IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const IntRect Widget::convertFromContainingWindow(const IntRect& rect) const { - if (!platformWidget() && parent()) { + if (!platformWidget()) { + if (!parent()) + return rect; IntRect result = parent()->convertFromContainingWindow(rect); result.move(parent()->scrollX() - x(), parent()->scrollY() - y()); return result; |