diff options
Diffstat (limited to 'Source/WebCore/platform/mac')
-rw-r--r-- | Source/WebCore/platform/mac/ClipboardMac.mm | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/CookieJar.mm | 109 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/DragImageMac.mm | 6 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/EmptyProtocolDefinitions.h | 5 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/FileChooserMac.mm | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/FileSystemMac.mm | 1 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/LocalizedStringsMac.mm | 50 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/PasteboardMac.mm | 15 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/ScrollAnimatorMac.h | 7 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/ScrollAnimatorMac.mm | 9 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/ScrollbarThemeMac.mm | 31 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WebCoreSystemInterface.h | 15 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WebCoreSystemInterface.mm | 7 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WheelEventMac.mm | 27 |
14 files changed, 239 insertions, 49 deletions
diff --git a/Source/WebCore/platform/mac/ClipboardMac.mm b/Source/WebCore/platform/mac/ClipboardMac.mm index 10d196a..a41982a 100644 --- a/Source/WebCore/platform/mac/ClipboardMac.mm +++ b/Source/WebCore/platform/mac/ClipboardMac.mm @@ -370,7 +370,7 @@ void ClipboardMac::writeRange(Range* range, Frame* frame) { ASSERT(range); ASSERT(frame); - Pasteboard::writeSelection(m_pasteboard.get(), range, frame->editor()->smartInsertDeleteEnabled() && frame->selection()->granularity() == WordGranularity, frame); + Pasteboard::writeSelection(m_pasteboard.get(), 0, range, frame->editor()->smartInsertDeleteEnabled() && frame->selection()->granularity() == WordGranularity, frame); } void ClipboardMac::writePlainText(const String& text) diff --git a/Source/WebCore/platform/mac/CookieJar.mm b/Source/WebCore/platform/mac/CookieJar.mm index df24b03..e788949 100644 --- a/Source/WebCore/platform/mac/CookieJar.mm +++ b/Source/WebCore/platform/mac/CookieJar.mm @@ -28,8 +28,10 @@ #import "BlockExceptions.h" #import "Cookie.h" +#import "CookieStorage.h" #import "Document.h" #import "KURL.h" +#import "WebCoreSystemInterface.h" #import <wtf/RetainPtr.h> #ifdef BUILDING_ON_TIGER @@ -79,7 +81,14 @@ String cookies(const Document*, const KURL& url) BEGIN_BLOCK_OBJC_EXCEPTIONS; NSURL *cookieURL = url; - NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL]; + NSArray *cookies; +#if USE(CFURLSTORAGESESSIONS) + if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get()) + cookies = wkHTTPCookiesForURL(cookieStorage, cookieURL); + else +#endif + cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL]; + return [[NSHTTPCookie requestHeaderFieldsWithCookies:filterCookies(cookies).get()] objectForKey:@"Cookie"]; END_BLOCK_OBJC_EXCEPTIONS; @@ -91,7 +100,14 @@ String cookieRequestHeaderFieldValue(const Document*, const KURL& url) BEGIN_BLOCK_OBJC_EXCEPTIONS; NSURL *cookieURL = url; - NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL]; + NSArray *cookies; +#if USE(CFURLSTORAGESESSIONS) + if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get()) + cookies = wkHTTPCookiesForURL(cookieStorage, cookieURL); + else +#endif + cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL]; + return [[NSHTTPCookie requestHeaderFieldsWithCookies:cookies] objectForKey:@"Cookie"]; END_BLOCK_OBJC_EXCEPTIONS; @@ -112,8 +128,14 @@ void setCookies(Document* document, const KURL& url, const String& cookieStr) String cookieString = cookieStr.contains('=') ? cookieStr : cookieStr + "="; NSURL *cookieURL = url; - NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"] forURL:cookieURL]; - [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:filterCookies(cookies).get() forURL:cookieURL mainDocumentURL:document->firstPartyForCookies()]; + RetainPtr<NSArray> filteredCookies = filterCookies([NSHTTPCookie cookiesWithResponseHeaderFields:[NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"] forURL:cookieURL]); + +#if USE(CFURLSTORAGESESSIONS) + if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get()) + wkSetHTTPCookiesForURL(cookieStorage, filteredCookies.get(), cookieURL, document->firstPartyForCookies()); + else +#endif + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:filteredCookies.get() forURL:cookieURL mainDocumentURL:document->firstPartyForCookies()]; END_BLOCK_OBJC_EXCEPTIONS; } @@ -122,7 +144,14 @@ bool cookiesEnabled(const Document*) { BEGIN_BLOCK_OBJC_EXCEPTIONS; - NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy]; + NSHTTPCookieAcceptPolicy cookieAcceptPolicy; +#if USE(CFURLSTORAGESESSIONS) + if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get()) + cookieAcceptPolicy = wkGetHTTPCookieAcceptPolicy(cookieStorage); + else +#endif + cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy]; + return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain; END_BLOCK_OBJC_EXCEPTIONS; @@ -135,7 +164,13 @@ bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies) BEGIN_BLOCK_OBJC_EXCEPTIONS; NSURL *cookieURL = url; - NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL]; + NSArray *cookies; +#if USE(CFURLSTORAGESESSIONS) + if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get()) + cookies = wkHTTPCookiesForURL(cookieStorage, cookieURL); + else +#endif + cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL]; NSUInteger count = [cookies count]; rawCookies.reserveCapacity(count); @@ -162,14 +197,27 @@ void deleteCookie(const Document*, const KURL& url, const String& cookieName) NSURL *cookieURL = url; NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; - NSArray *cookies = [cookieStorage cookiesForURL:cookieURL]; + NSArray *cookies; +#if USE(CFURLSTORAGESESSIONS) + CFHTTPCookieStorageRef cfCookieStorage = privateBrowsingCookieStorage().get(); + if (cfCookieStorage) + cookies = wkHTTPCookiesForURL(cfCookieStorage, cookieURL); + else +#endif + cookies = [cookieStorage cookiesForURL:cookieURL]; + NSString *cookieNameString = (NSString *) cookieName; NSUInteger count = [cookies count]; for (NSUInteger i = 0; i < count; ++i) { NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i]; if ([[cookie name] isEqualToString:cookieNameString]) { - [cookieStorage deleteCookie:cookie]; +#if USE(CFURLSTORAGESESSIONS) + if (cfCookieStorage) + wkDeleteHTTPCookie(cfCookieStorage, cookie); + else +#endif + [cookieStorage deleteCookie:cookie]; break; } } @@ -177,4 +225,49 @@ void deleteCookie(const Document*, const KURL& url, const String& cookieName) END_BLOCK_OBJC_EXCEPTIONS; } +void getHostnamesWithCookies(HashSet<String>& hostnames) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; + NSArray *cookies = [cookieStorage cookies]; + + for (NSHTTPCookie* cookie in cookies) + hostnames.add([cookie domain]); + + END_BLOCK_OBJC_EXCEPTIONS; +} + +void deleteCookiesForHostname(const String& hostname) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; + NSArray *cookies = [cookieStorage cookies]; + if (!cookies) + return; + + for (NSHTTPCookie* cookie in cookies) { + if (hostname == String([cookie domain])) + [cookieStorage deleteCookie:cookie]; + } + + END_BLOCK_OBJC_EXCEPTIONS; +} + +void deleteAllCookies() +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; + NSArray *cookies = [cookieStorage cookies]; + if (!cookies) + return; + + for (NSHTTPCookie* cookie in cookies) + [cookieStorage deleteCookie:cookie]; + + END_BLOCK_OBJC_EXCEPTIONS; +} + } diff --git a/Source/WebCore/platform/mac/DragImageMac.mm b/Source/WebCore/platform/mac/DragImageMac.mm index fc58173..8f60fd4 100644 --- a/Source/WebCore/platform/mac/DragImageMac.mm +++ b/Source/WebCore/platform/mac/DragImageMac.mm @@ -158,8 +158,7 @@ static float widthWithFont(NSString *string, NSFont *font) if (canUseFastRenderer(buffer.data(), length)) { Font webCoreFont(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]); TextRun run(buffer.data(), length); - run.disableRoundingHacks(); - return webCoreFont.floatWidth(run); + return webCoreFont.width(run); } return [string sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]].width; @@ -197,8 +196,7 @@ static void drawAtPoint(NSString *string, NSPoint point, NSFont *font, NSColor * Font webCoreFont(FontPlatformData(font, [font pointSize]), ![nsContext isDrawingToScreen], Antialiased); TextRun run(buffer.data(), length); - run.disableRoundingHacks(); - + CGFloat red; CGFloat green; CGFloat blue; diff --git a/Source/WebCore/platform/mac/EmptyProtocolDefinitions.h b/Source/WebCore/platform/mac/EmptyProtocolDefinitions.h index 04bf236..b73177b 100644 --- a/Source/WebCore/platform/mac/EmptyProtocolDefinitions.h +++ b/Source/WebCore/platform/mac/EmptyProtocolDefinitions.h @@ -23,9 +23,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EmptyProtocolDefinitions_h -#define EmptyProtocolDefinitions_h - #if defined(__OBJC__) #define EMPTY_PROTOCOL(NAME) \ @@ -50,5 +47,3 @@ EMPTY_PROTOCOL(NSURLDownloadDelegate) #undef EMPTY_PROTOCOL #endif /* defined(__OBJC__) */ - -#endif /* EmptyProtocolDefinitions_h */ diff --git a/Source/WebCore/platform/mac/FileChooserMac.mm b/Source/WebCore/platform/mac/FileChooserMac.mm index 03532ff..d9c2426 100644 --- a/Source/WebCore/platform/mac/FileChooserMac.mm +++ b/Source/WebCore/platform/mac/FileChooserMac.mm @@ -47,9 +47,9 @@ String FileChooser::basenameForWidth(const Font& font, int width) const else if (m_filenames.size() == 1) strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:(m_filenames[0])]; else - return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false); + return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font); - return StringTruncator::centerTruncate(strToTruncate, width, font, false); + return StringTruncator::centerTruncate(strToTruncate, width, font); } } diff --git a/Source/WebCore/platform/mac/FileSystemMac.mm b/Source/WebCore/platform/mac/FileSystemMac.mm index bbeb76a..8cdd382 100644 --- a/Source/WebCore/platform/mac/FileSystemMac.mm +++ b/Source/WebCore/platform/mac/FileSystemMac.mm @@ -32,6 +32,7 @@ #import "PlatformString.h" #import <wtf/RetainPtr.h> #import <wtf/text/CString.h> +#import <wtf/UnusedParam.h> namespace WebCore { diff --git a/Source/WebCore/platform/mac/LocalizedStringsMac.mm b/Source/WebCore/platform/mac/LocalizedStringsMac.mm new file mode 100644 index 0000000..2dc44e9 --- /dev/null +++ b/Source/WebCore/platform/mac/LocalizedStringsMac.mm @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011 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 "config.h" +#import "LocalizedStrings.h" + +#import <wtf/Assertions.h> +#import <wtf/RetainPtr.h> +#import <wtf/Threading.h> +#import <wtf/text/WTFString.h> + +namespace WebCore { + +String localizedString(const char* key) +{ + static NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"]; + + ASSERT(isMainThread()); + + RetainPtr<CFStringRef> keyString(AdoptCF, CFStringCreateWithCStringNoCopy(NULL, key, kCFStringEncodingUTF8, kCFAllocatorNull)); + NSString *notFound = @"localized string not found"; + NSString *result = [bundle localizedStringForKey:(NSString *)keyString.get() value:notFound table:nil]; + + ASSERT_WITH_MESSAGE(result != notFound, "could not find localizable string %s in bundle", key); + return result; +} + +} // namespace WebCore diff --git a/Source/WebCore/platform/mac/PasteboardMac.mm b/Source/WebCore/platform/mac/PasteboardMac.mm index 65180a0..8c6610a 100644 --- a/Source/WebCore/platform/mac/PasteboardMac.mm +++ b/Source/WebCore/platform/mac/PasteboardMac.mm @@ -34,6 +34,7 @@ #import "Editor.h" #import "EditorClient.h" #import "Frame.h" +#import "FrameView.h" #import "FrameLoaderClient.h" #import "HitTestResult.h" #import "HTMLAnchorElement.h" @@ -56,7 +57,6 @@ @interface NSAttributedString (AppKitSecretsIKnowAbout) - (id)_initWithDOMRange:(DOMRange *)domRange; @end - namespace WebCore { // FIXME: It's not great to have these both here and in WebKit. @@ -138,21 +138,22 @@ static NSAttributedString *stripAttachmentCharacters(NSAttributedString *string) return result; } -void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) +void Pasteboard::writeSelection(NSPasteboard* pasteboard, NSArray* pasteboardTypes, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { if (!WebArchivePboardType) Pasteboard::generalPasteboard(); // Initializes pasteboard types. ASSERT(selectedRange); - NSAttributedString *attributedString = [[[NSAttributedString alloc] initWithString:selectedRange->text()] autorelease]; - + // Using different API for WebKit and WebKit2. + // FIXME - We need to have a way to create the NSAttributedString for WebKit2 that doesn't require accessing the WebFrame. + NSAttributedString *attributedString = (frame->view()->platformWidget()) ? [[[NSAttributedString alloc] _initWithDOMRange:kit(selectedRange)] autorelease] : [[[NSAttributedString alloc] initWithString:selectedRange->text()] 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); + NSArray *types = pasteboardTypes ? pasteboardTypes : frame->editor()->client()->pasteboardTypesForSelection(frame); // Don't write RTFD to the pasteboard when the copied attributed string has no attachments. NSMutableArray *mutableTypes = nil; if (![attributedString containsAttachments]) { @@ -162,7 +163,7 @@ void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, } [pasteboard declareTypes:types owner:nil]; #else - NSArray *types = selectionPasteboardTypes(canSmartCopyOrDelete, [attributedString containsAttachments]); + NSArray *types = pasteboardTypes ? pasteboardTypes : selectionPasteboardTypes(canSmartCopyOrDelete, [attributedString containsAttachments]); [pasteboard declareTypes:types owner:nil]; frame->editor()->client()->didSetSelectionTypesForPasteboard(); #endif @@ -214,7 +215,7 @@ void Pasteboard::writePlainText(NSPasteboard* pasteboard, const String& text) void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { - Pasteboard::writeSelection(m_pasteboard.get(), selectedRange, canSmartCopyOrDelete, frame); + Pasteboard::writeSelection(m_pasteboard.get(), 0, selectedRange, canSmartCopyOrDelete, frame); } void Pasteboard::writePlainText(const String& text) diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.h b/Source/WebCore/platform/mac/ScrollAnimatorMac.h index 3f7612a..2bafbf5 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.h +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.h @@ -70,7 +70,10 @@ public: void immediateScrollToPoint(const FloatPoint& newPosition); void immediateScrollByDeltaX(float deltaX); void immediateScrollByDeltaY(float deltaY); - + + void setIsDrawingIntoLayer(bool b) { m_drawingIntoLayer = b; } + bool isDrawingIntoLayer() const { return m_drawingIntoLayer; } + private: RetainPtr<id> m_scrollAnimationHelper; RetainPtr<ScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate; @@ -114,6 +117,7 @@ private: bool m_inScrollGesture; bool m_momentumScrollInProgress; bool m_ignoreMomentumScrolls; + CFTimeInterval m_lastMomemtumScrollTimestamp; FloatSize m_overflowScrollDelta; FloatSize m_stretchScrollForce; @@ -126,6 +130,7 @@ private: FloatSize m_origVelocity; Timer<ScrollAnimatorMac> m_snapRubberBandTimer; #endif + bool m_drawingIntoLayer; }; } // namespace WebCore diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm index c1154d5..67c0904 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -357,7 +357,7 @@ static NSSize abs(NSSize size) { if (!_animator) return nil; - if (!_animator->scrollableArea()->scrollbarWillRenderIntoCompositingLayer()) + if (!_animator->isDrawingIntoLayer()) return nil; // FIXME: This should attempt to return an actual layer. @@ -459,6 +459,7 @@ ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) , m_startTime(0) , m_snapRubberBandTimer(this, &ScrollAnimatorMac::snapRubberBandTimerFired) #endif + , m_drawingIntoLayer(false) { m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]); m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); @@ -726,9 +727,9 @@ void ScrollAnimatorMac::handleWheelEvent(PlatformWheelEvent& wheelEvent) wheelEvent.accept(); - bool isMometumScrollEvent = (wheelEvent.phase() != PlatformWheelEventPhaseNone); + bool isMometumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone); if (m_ignoreMomentumScrolls && (isMometumScrollEvent || m_snapRubberBandTimer.isActive())) { - if (wheelEvent.phase() == PlatformWheelEventPhaseEnded) + if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) m_ignoreMomentumScrolls = false; return; } @@ -819,7 +820,7 @@ void ScrollAnimatorMac::smoothScrollWithEvent(PlatformWheelEvent& wheelEvent) isHorizontallyStretched = stretchAmount.width(); isVerticallyStretched = stretchAmount.height(); - PlatformWheelEventPhase phase = wheelEvent.phase(); + PlatformWheelEventPhase phase = wheelEvent.momentumPhase(); // If we are starting momentum scrolling then do some setup. if (!m_momentumScrollInProgress && (phase == PlatformWheelEventPhaseBegan || phase == PlatformWheelEventPhaseChanged)) diff --git a/Source/WebCore/platform/mac/ScrollbarThemeMac.mm b/Source/WebCore/platform/mac/ScrollbarThemeMac.mm index c35dfa0..5a3796d 100644 --- a/Source/WebCore/platform/mac/ScrollbarThemeMac.mm +++ b/Source/WebCore/platform/mac/ScrollbarThemeMac.mm @@ -54,12 +54,11 @@ static ScrollbarPainterMap* scrollbarMap() static ScrollbarPainterMap* map = new ScrollbarPainterMap; return map; } - + } @interface ScrollbarPrefsObserver : NSObject { - } + (void)registerAsObserver; @@ -167,7 +166,6 @@ void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar) void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar) { - scrollbarMap()->remove(scrollbar); } @@ -429,23 +427,25 @@ static int scrollbarPartToHIPressedState(ScrollbarPart part) bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect) { #if USE(WK_SCROLLBAR_PAINTER) - float value = 0.0f; - float totalSize = 0.0f; + float value = 0; + float overhang = 0; if (scrollbar->currentPos() < 0) { // Scrolled past the top. - value = 0.0f; - totalSize = scrollbar->totalSize() - scrollbar->currentPos(); + value = 0; + overhang = -scrollbar->currentPos(); } else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->totalSize()) { // Scrolled past the bottom. - value = 1.0f; - totalSize = scrollbar->visibleSize() + scrollbar->currentPos(); + value = 1; + overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollbar->totalSize(); } else { // Within the bounds of the scrollable area. value = scrollbar->currentPos() / scrollbar->maximum(); - totalSize = scrollbar->totalSize(); } + ScrollAnimatorMac* scrollAnimator = static_cast<ScrollAnimatorMac*>(scrollbar->scrollableArea()->scrollAnimator()); + scrollAnimator->setIsDrawingIntoLayer(context->isCALayerContext()); + context->save(); context->clip(damageRect); context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y()); @@ -453,8 +453,11 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co wkScrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(), scrollbar->enabled(), value, - static_cast<CGFloat>(scrollbar->visibleSize()) / totalSize, + (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), scrollbar->frameRect()); + + scrollAnimator->setIsDrawingIntoLayer(false); + context->restore(); return true; #endif @@ -510,14 +513,14 @@ bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, co IntRect bufferRect(scrollbar->frameRect()); bufferRect.intersect(damageRect); - bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y()); OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(bufferRect.size()); if (!imageBuffer) return true; - + + imageBuffer->context()->translate(scrollbar->frameRect().x() - bufferRect.x(), scrollbar->frameRect().y() - bufferRect.y()); HIThemeDrawTrack(&trackInfo, 0, imageBuffer->context()->platformContext(), kHIThemeOrientationNormal); - context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, scrollbar->frameRect().location()); + context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, bufferRect.location()); } return true; diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.h b/Source/WebCore/platform/mac/WebCoreSystemInterface.h index e6d6cf6..df65ff2 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.h +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.h @@ -50,11 +50,13 @@ typedef struct _NSRect NSRect; @class NSDate; @class NSEvent; @class NSFont; +@class NSHTTPCookie; @class NSImage; @class NSMenu; @class NSMutableURLRequest; @class NSString; @class NSTextFieldCell; +@class NSURL; @class NSURLConnection; @class NSURLRequest; @class NSURLResponse; @@ -68,10 +70,12 @@ class NSData; class NSDate; class NSEvent; class NSFont; +class NSHTTPCookie; class NSImage; class NSMenu; class NSMutableArray; class NSMutableURLRequest; +class NSURL; class NSURLRequest; class NSString; class NSTextFieldCell; @@ -235,6 +239,17 @@ extern CFTypeRef (*wkCreateAXTextMarker)(const void *bytes, size_t len); extern BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length); extern AXUIElementRef (*wkCreateAXUIElementRef)(id element); +typedef const struct __CFURLStorageSession* CFURLStorageSessionRef; +extern CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef); +extern NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*); + +typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef; +extern CFHTTPCookieStorageRef (*wkCreatePrivateInMemoryHTTPCookieStorage)(CFURLStorageSessionRef); +extern unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef); +extern NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *); +extern void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *); +extern void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *); + } #endif diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.mm b/Source/WebCore/platform/mac/WebCoreSystemInterface.mm index 24bdcb1..50ac236 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.mm +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.mm @@ -172,3 +172,10 @@ CFTypeRef (*wkCreateAXTextMarker)(const void *bytes, size_t len); BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length); AXUIElementRef (*wkCreateAXUIElementRef)(id element); +CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef); +NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*); +CFHTTPCookieStorageRef (*wkCreatePrivateInMemoryHTTPCookieStorage)(CFURLStorageSessionRef); +unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef); +NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *); +void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *); +void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *); diff --git a/Source/WebCore/platform/mac/WheelEventMac.mm b/Source/WebCore/platform/mac/WheelEventMac.mm index 74265d1..4e9a8b7 100644 --- a/Source/WebCore/platform/mac/WheelEventMac.mm +++ b/Source/WebCore/platform/mac/WheelEventMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006, 2010 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2004, 2006, 2010, 2011 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 @@ -33,7 +33,7 @@ namespace WebCore { -static PlatformWheelEventPhase phaseForEvent(NSEvent *event) +static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event) { #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) uint32_t phase = PlatformWheelEventPhaseNone; @@ -54,6 +54,27 @@ static PlatformWheelEventPhase phaseForEvent(NSEvent *event) #endif } +static PlatformWheelEventPhase phaseForEvent(NSEvent *event) +{ +#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + uint32_t phase = PlatformWheelEventPhaseNone; + if ([event phase] & NSEventPhaseBegan) + phase |= PlatformWheelEventPhaseBegan; + if ([event phase] & NSEventPhaseStationary) + phase |= PlatformWheelEventPhaseStationary; + if ([event phase] & NSEventPhaseChanged) + phase |= PlatformWheelEventPhaseChanged; + if ([event phase] & NSEventPhaseEnded) + phase |= PlatformWheelEventPhaseEnded; + if ([event phase] & NSEventPhaseCancelled) + phase |= PlatformWheelEventPhaseCancelled; + return static_cast<PlatformWheelEventPhase>(phase); +#else + UNUSED_PARAM(event); + return PlatformWheelEventPhaseNone; +#endif +} + PlatformWheelEvent::PlatformWheelEvent(NSEvent* event, NSView *windowView) : m_position(pointForEvent(event, windowView)) , m_globalPosition(globalPointForEvent(event)) @@ -64,10 +85,10 @@ PlatformWheelEvent::PlatformWheelEvent(NSEvent* event, NSView *windowView) , m_altKey([event modifierFlags] & NSAlternateKeyMask) , m_metaKey([event modifierFlags] & NSCommandKeyMask) , m_phase(phaseForEvent(event)) + , m_momentumPhase(momentumPhaseForEvent(event)) , m_timestamp([event timestamp]) { BOOL continuous; - wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous); if (continuous) { m_wheelTicksX = m_deltaX / static_cast<float>(Scrollbar::pixelsPerLineStep()); |