diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/mac')
-rw-r--r-- | Source/WebKit2/UIProcess/mac/CorrectionPanel.h | 63 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/CorrectionPanel.mm | 166 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h | 74 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm | 608 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebContextMac.mm | 33 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm | 13 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm | 39 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm | 101 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm | 4 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm | 137 |
10 files changed, 1229 insertions, 9 deletions
diff --git a/Source/WebKit2/UIProcess/mac/CorrectionPanel.h b/Source/WebKit2/UIProcess/mac/CorrectionPanel.h new file mode 100644 index 0000000..d4bc353 --- /dev/null +++ b/Source/WebKit2/UIProcess/mac/CorrectionPanel.h @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#ifndef CorrectionPanel_h +#define CorrectionPanel_h + +#if !defined(BUILDING_ON_SNOW_LEOPARD) +#import <AppKit/NSTextChecker.h> +#import <WebCore/CorrectionPanelInfo.h> +#import <wtf/RetainPtr.h> + +@class WKView; + +namespace WebKit { + +class CorrectionPanel { +public: + CorrectionPanel(); + ~CorrectionPanel(); + void show(WKView*, WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); + void dismiss(WebCore::ReasonForDismissingCorrectionPanel); + String dismissSoon(WebCore::ReasonForDismissingCorrectionPanel); + static void recordAutocorrectionResponse(WKView*, NSCorrectionResponse, const String& replacedString, const String& replacementString); + +private: + bool isShowing() const { return m_view; } + void dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally); + void handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionBubbleType); + + bool m_wasDismissedExternally; + WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissing; + RetainPtr<WKView> m_view; + RetainPtr<NSString> m_resultForSynchronousDismissal; + RetainPtr<NSCondition> m_resultCondition; +}; + +} // namespace WebKit + +#endif // !defined(BUILDING_ON_SNOW_LEOPARD) + +#endif // CorrectionPanel_h diff --git a/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm b/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm new file mode 100644 index 0000000..ab6818f --- /dev/null +++ b/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm @@ -0,0 +1,166 @@ +/* + * 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" +#if !defined(BUILDING_ON_SNOW_LEOPARD) +#import "CorrectionPanel.h" + +#import "WebPageProxy.h" +#import "WKView.h" +#import "WKViewPrivate.h" + +using namespace WebCore; + +static inline NSCorrectionBubbleType correctionBubbleType(CorrectionPanelInfo::PanelType panelType) +{ + switch (panelType) { + case CorrectionPanelInfo::PanelTypeCorrection: + return NSCorrectionBubbleTypeCorrection; + case CorrectionPanelInfo::PanelTypeReversion: + return NSCorrectionBubbleTypeReversion; + case CorrectionPanelInfo::PanelTypeSpellingSuggestions: + return NSCorrectionBubbleTypeGuesses; + } + ASSERT_NOT_REACHED(); + return NSCorrectionBubbleTypeCorrection; +} + +namespace WebKit { + +CorrectionPanel::CorrectionPanel() + : m_wasDismissedExternally(false) + , m_reasonForDismissing(ReasonForDismissingCorrectionPanelIgnored) + , m_resultCondition(AdoptNS, [[NSCondition alloc] init]) +{ +} + +CorrectionPanel::~CorrectionPanel() +{ + dismissInternal(ReasonForDismissingCorrectionPanelIgnored, false); +} + +void CorrectionPanel::show(WKView* view, CorrectionPanelInfo::PanelType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) +{ + dismissInternal(ReasonForDismissingCorrectionPanelIgnored, false); + + if (!view) + return; + + NSString* replacedStringAsNSString = replacedString; + NSString* replacementStringAsNSString = replacementString; + m_view = view; + NSCorrectionBubbleType bubbleType = correctionBubbleType(type); + + NSMutableArray* alternativeStrings = 0; + if (!alternativeReplacementStrings.isEmpty()) { + size_t size = alternativeReplacementStrings.size(); + alternativeStrings = [NSMutableArray arrayWithCapacity:size]; + for (size_t i = 0; i < size; ++i) + [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]]; + } + + NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker]; + [spellChecker showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) { + handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, bubbleType); + }]; +} + +void CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason) +{ + dismissInternal(reason, true); +} + +String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason) +{ + if (!isShowing()) + return String(); + + dismissInternal(reason, true); + [m_resultCondition.get() lock]; + while (!m_resultForSynchronousDismissal) + [m_resultCondition.get() wait]; + [m_resultCondition.get() unlock]; + return m_resultForSynchronousDismissal.get(); +} + +void CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally) +{ + m_wasDismissedExternally = dismissingExternally; + if (!isShowing()) + return; + + m_reasonForDismissing = reason; + m_resultForSynchronousDismissal.clear(); + [[NSSpellChecker sharedSpellChecker] dismissCorrectionBubbleForView:m_view.get()]; + m_view.clear(); +} + +void CorrectionPanel::recordAutocorrectionResponse(WKView* view, NSCorrectionResponse response, const String& replacedString, const String& replacementString) +{ + [[NSSpellChecker sharedSpellChecker] recordResponse:response toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:[view spellCheckerDocumentTag]]; +} + +void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionBubbleType correctionBubbleType) +{ + NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker]; + NSInteger documentTag = [m_view.get() spellCheckerDocumentTag]; + + switch (correctionBubbleType) { + case NSCorrectionBubbleTypeCorrection: + if (acceptedReplacement) + [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; + else { + if (!m_wasDismissedExternally || m_reasonForDismissing == ReasonForDismissingCorrectionPanelCancelled) + [spellChecker recordResponse:NSCorrectionResponseRejected toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; + else + [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; + } + break; + case NSCorrectionBubbleTypeReversion: + if (acceptedReplacement) + [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replaced forWord:acceptedReplacement language:nil inSpellDocumentWithTag:documentTag]; + break; + case NSCorrectionBubbleTypeGuesses: + if (acceptedReplacement) + [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; + break; + } + + if (!m_wasDismissedExternally) { + [m_view.get() handleCorrectionPanelResult:acceptedReplacement]; + return; + } + + [m_resultCondition.get() lock]; + if (acceptedReplacement) + m_resultForSynchronousDismissal.adoptNS([acceptedReplacement copy]); + [m_resultCondition.get() signal]; + [m_resultCondition.get() unlock]; +} + +} // namespace WebKit + +#endif //!defined(BUILDING_ON_SNOW_LEOPARD) + diff --git a/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h new file mode 100644 index 0000000..57311e7 --- /dev/null +++ b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h @@ -0,0 +1,74 @@ +/* + * 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. + */ + +#if ENABLE(FULLSCREEN_API) + +#import <Cocoa/Cocoa.h> +#import <wtf/RetainPtr.h> + +namespace WebKit { +class LayerTreeContext; +} + +namespace WebCore { +class IntRect; +} + +@class WKView; + +@interface WKFullScreenWindowController : NSWindowController { +@private + WKView *_webView; + RetainPtr<NSView> _webViewPlaceholder; + RetainPtr<NSView> _layerViewPlaceholder; + RetainPtr<NSView> _layerHostingView; + + BOOL _isAnimating; + BOOL _isFullScreen; + BOOL _isWindowLoaded; + BOOL _forceDisableAnimation; + BOOL _isPlaying; + CGRect _initialFrame; + uint32_t _idleDisplaySleepAssertion; + uint32_t _idleSystemSleepAssertion; + NSTimer *_tickleTimer; +} + +- (WKView*)webView; +- (void)setWebView:(WKView*)webView; + +- (void)enterFullScreen:(NSScreen *)screen; +- (void)exitFullScreen; +- (void)beganEnterFullScreenAnimation; +- (void)beganExitFullScreenAnimation; +- (void)finishedEnterFullScreenAnimation:(bool)completed; +- (void)finishedExitFullScreenAnimation:(bool)completed; +- (void)enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)context; +- (void)exitAcceleratedCompositingMode; +- (WebCore::IntRect)getFullScreenRect; + +@end + +#endif diff --git a/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm new file mode 100644 index 0000000..91eeaf6 --- /dev/null +++ b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm @@ -0,0 +1,608 @@ +/* + * Copyright (C) 2009, 2010, 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" + +#if ENABLE(FULLSCREEN_API) + +#import "WKFullScreenWindowController.h" + +#import "LayerTreeContext.h" +#import "WKAPICast.h" +#import "WKViewInternal.h" +#import "WebFullScreenManagerProxy.h" +#import "WebPageProxy.h" +#import <Carbon/Carbon.h> // For SetSystemUIMode() +#import <IOKit/pwr_mgt/IOPMLib.h> // For IOPMAssertionCreate() +#import <QuartzCore/QuartzCore.h> +#import <WebCore/FloatRect.h> +#import <WebCore/IntRect.h> +#import <WebKitSystemInterface.h> + +static const NSTimeInterval tickleTimerInterval = 1.0; + +using namespace WebKit; +using namespace WebCore; + +#if defined(BUILDING_ON_LEOPARD) +@interface CATransaction(SnowLeopardConvenienceFunctions) ++ (void)setDisableActions:(BOOL)flag; ++ (void)setAnimationDuration:(CFTimeInterval)dur; +@end + +@implementation CATransaction(SnowLeopardConvenienceFunctions) ++ (void)setDisableActions:(BOOL)flag +{ + [self setValue:[NSNumber numberWithBool:flag] forKey:kCATransactionDisableActions]; +} + ++ (void)setAnimationDuration:(CFTimeInterval)dur +{ + [self setValue:[NSNumber numberWithDouble:dur] forKey:kCATransactionAnimationDuration]; +} +@end + +#endif + +@interface WKFullScreenWindow : NSWindow +{ + NSView* _animationView; + CALayer* _backgroundLayer; +} +- (CALayer*)backgroundLayer; +- (NSView*)animationView; +@end + +@interface WKFullScreenWindowController(Private) +- (void)_requestExitFullScreenWithAnimation:(BOOL)animation; +- (void)_updateMenuAndDockForFullScreen; +- (void)_updatePowerAssertions; +- (WKFullScreenWindow *)_fullScreenWindow; +- (CFTimeInterval)_animationDuration; +- (void)_swapView:(NSView*)view with:(NSView*)otherView; +- (WebFullScreenManagerProxy*)_manager; +@end + +@interface NSWindow(IsOnActiveSpaceAdditionForTigerAndLeopard) +- (BOOL)isOnActiveSpace; +@end + +@implementation WKFullScreenWindowController + +#pragma mark - +#pragma mark Initialization +- (id)init +{ + NSWindow *window = [[WKFullScreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; + self = [super initWithWindow:window]; + [window release]; + if (!self) + return nil; + [self windowDidLoad]; + + return self; +} + +- (void)dealloc +{ + [self setWebView:nil]; + + [NSObject cancelPreviousPerformRequestsWithTarget:self]; + + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + +- (void)windowDidLoad +{ + [super windowDidLoad]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidResignActive:) name:NSApplicationDidResignActiveNotification object:NSApp]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidChangeScreenParameters:) name:NSApplicationDidChangeScreenParametersNotification object:NSApp]; +} + +#pragma mark - +#pragma mark Accessors + +- (WKView*)webView +{ + return _webView; +} + +- (void)setWebView:(WKView *)webView +{ + [webView retain]; + [_webView release]; + _webView = webView; +} + +#pragma mark - +#pragma mark Notifications + +- (void)applicationDidResignActive:(NSNotification*)notification +{ + // Check to see if the fullScreenWindow is on the active space; this function is available + // on 10.6 and later, so default to YES if the function is not available: + NSWindow* fullScreenWindow = [self _fullScreenWindow]; + BOOL isOnActiveSpace = ([fullScreenWindow respondsToSelector:@selector(isOnActiveSpace)] ? [fullScreenWindow isOnActiveSpace] : YES); + + // Replicate the QuickTime Player (X) behavior when losing active application status: + // Is the fullScreen screen the main screen? (Note: this covers the case where only a + // single screen is available.) Is the fullScreen screen on the current space? IFF so, + // then exit fullScreen mode. + if ([fullScreenWindow screen] == [[NSScreen screens] objectAtIndex:0] && isOnActiveSpace) + [self _requestExitFullScreenWithAnimation:NO]; +} + +- (void)applicationDidChangeScreenParameters:(NSNotification*)notification +{ + // The user may have changed the main screen by moving the menu bar, or they may have changed + // the Dock's size or location, or they may have changed the fullScreen screen's dimensions. + // Update our presentation parameters, and ensure that the full screen window occupies the + // entire screen: + [self _updateMenuAndDockForFullScreen]; + NSWindow* window = [self window]; + [window setFrame:[[window screen] frame] display:YES]; +} + +#pragma mark - +#pragma mark Exposed Interface + +- (void)enterFullScreen:(NSScreen *)screen +{ + if (_isFullScreen) + return; + + _isFullScreen = YES; + _isAnimating = YES; + + NSDisableScreenUpdates(); + + if (!screen) + screen = [NSScreen mainScreen]; + NSRect screenFrame = [screen frame]; + + NSRect webViewFrame = [_webView convertRectToBase:[_webView frame]]; + webViewFrame.origin = [[_webView window] convertBaseToScreen:webViewFrame.origin]; + + // In the case of a multi-monitor setup where the webView straddles two + // monitors, we must create a window large enough to contain the destination + // frame and the initial frame. + NSRect windowFrame = NSUnionRect(screenFrame, webViewFrame); + [[self window] setFrame:windowFrame display:YES]; + + CALayer* backgroundLayer = [[self _fullScreenWindow] backgroundLayer]; + NSRect backgroundFrame = {[[self window] convertScreenToBase:screenFrame.origin], screenFrame.size}; + backgroundFrame = [[[self window] contentView] convertRectFromBase:backgroundFrame]; + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [backgroundLayer setFrame:NSRectToCGRect(backgroundFrame)]; + [CATransaction commit]; + + CFTimeInterval duration = [self _animationDuration]; + [self _manager]->willEnterFullScreen(); + [self _manager]->beginEnterFullScreenAnimation(duration); +} + +- (void)beganEnterFullScreenAnimation +{ + [self _updateMenuAndDockForFullScreen]; + [self _updatePowerAssertions]; + + // In a previous incarnation, the NSWindow attached to this controller may have + // been on a different screen. Temporarily change the collectionBehavior of the window: + NSWindow* fullScreenWindow = [self window]; + NSWindowCollectionBehavior behavior = [fullScreenWindow collectionBehavior]; + [fullScreenWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; + [fullScreenWindow makeKeyAndOrderFront:self]; + [fullScreenWindow setCollectionBehavior:behavior]; + + // Start the opacity animation. We can use implicit animations here because we don't care when + // the animation finishes. + [CATransaction begin]; + [CATransaction setAnimationDuration:[self _animationDuration]]; + [[[self _fullScreenWindow] backgroundLayer] setOpacity:1]; + [CATransaction commit]; + + NSEnableScreenUpdates(); + _isAnimating = YES; +} + +- (void)finishedEnterFullScreenAnimation:(bool)completed +{ + NSDisableScreenUpdates(); + + if (completed) { + // Swap the webView placeholder into place. + if (!_webViewPlaceholder) + _webViewPlaceholder.adoptNS([[NSView alloc] init]); + [self _swapView:_webView with:_webViewPlaceholder.get()]; + + // Then insert the WebView into the full screen window + NSView* animationView = [[self _fullScreenWindow] animationView]; + [animationView addSubview:_webView positioned:NSWindowBelow relativeTo:_layerHostingView.get()]; + [_webView setFrame:[animationView bounds]]; + + // FIXME: In Barolo, orderIn will animate, which is not what we want. Find a way + // to work around this behavior. + //[[_webViewPlaceholder.get() window] orderOut:self]; + [[self window] makeKeyAndOrderFront:self]; + } + + [self _manager]->didEnterFullScreen(); + NSEnableScreenUpdates(); + + _isAnimating = NO; +} + +- (void)exitFullScreen +{ + if (!_isFullScreen) + return; + + _isFullScreen = NO; + _isAnimating = YES; + + NSDisableScreenUpdates(); + + [self _manager]->willExitFullScreen(); + [self _manager]->beginExitFullScreenAnimation([self _animationDuration]); +} + +- (void)beganExitFullScreenAnimation +{ + [self _updateMenuAndDockForFullScreen]; + [self _updatePowerAssertions]; + + // The user may have moved the fullScreen window in Spaces, so temporarily change + // the collectionBehavior of the webView's window: + NSWindow* webWindow = [[self webView] window]; + NSWindowCollectionBehavior behavior = [webWindow collectionBehavior]; + [webWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; + [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]]; + [webWindow setCollectionBehavior:behavior]; + + // Swap the webView back into its original position: + if ([_webView window] == [self window]) + [self _swapView:_webViewPlaceholder.get() with:_webView]; + + [CATransaction begin]; + [CATransaction setAnimationDuration:[self _animationDuration]]; + [[[self _fullScreenWindow] backgroundLayer] setOpacity:0]; + [CATransaction commit]; + + NSEnableScreenUpdates(); + _isAnimating = YES; +} + +- (void)finishedExitFullScreenAnimation:(bool)completed +{ + NSDisableScreenUpdates(); + + if (completed) { + [self _updateMenuAndDockForFullScreen]; + [self _updatePowerAssertions]; + [NSCursor setHiddenUntilMouseMoves:YES]; + + [[self window] orderOut:self]; + [[_webView window] makeKeyAndOrderFront:self]; + } + + [self _manager]->didExitFullScreen(); + NSEnableScreenUpdates(); + + _isAnimating = NO; +} + +- (void)enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext +{ + if (_layerHostingView) + return; + + ASSERT(!layerTreeContext.isEmpty()); + + // Create an NSView that will host our layer tree. + _layerHostingView.adoptNS([[NSView alloc] initWithFrame:[[self window] frame]]); + [_layerHostingView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + WKFullScreenWindow* window = [self _fullScreenWindow]; + [[window animationView] addSubview:_layerHostingView.get()]; + + // Create a root layer that will back the NSView. + RetainPtr<CALayer> rootLayer(AdoptNS, [[CALayer alloc] init]); +#ifndef NDEBUG + [rootLayer.get() setName:@"Hosting root layer"]; +#endif + + CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID); + [rootLayer.get() addSublayer:renderLayer]; + + [_layerHostingView.get() setLayer:rootLayer.get()]; + [_layerHostingView.get() setWantsLayer:YES]; + [[window backgroundLayer] setHidden:NO]; + [CATransaction commit]; +} + +- (void)exitAcceleratedCompositingMode +{ + if (!_layerHostingView) + return; + + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [_layerHostingView.get() removeFromSuperview]; + [_layerHostingView.get() setLayer:nil]; + [_layerHostingView.get() setWantsLayer:NO]; + [[[self _fullScreenWindow] backgroundLayer] setHidden:YES]; + [CATransaction commit]; + + _layerHostingView = 0; +} + +- (WebCore::IntRect)getFullScreenRect +{ + return enclosingIntRect([[self window] frame]); +} + +#pragma mark - +#pragma mark Internal Interface + +- (void)_updateMenuAndDockForFullScreen +{ + // NSApplicationPresentationOptions is available on > 10.6 only: +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + NSApplicationPresentationOptions options = NSApplicationPresentationDefault; + NSScreen* fullScreenScreen = [[self window] screen]; + + if (_isFullScreen) { + // Auto-hide the menu bar if the fullScreenScreen contains the menu bar: + // NOTE: if the fullScreenScreen contains the menu bar but not the dock, we must still + // auto-hide the dock, or an exception will be thrown. + if ([[NSScreen screens] objectAtIndex:0] == fullScreenScreen) + options |= (NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock); + // Check if the current screen contains the dock by comparing the screen's frame to its + // visibleFrame; if a dock is present, the visibleFrame will differ. If the current screen + // contains the dock, hide it. + else if (!NSEqualRects([fullScreenScreen frame], [fullScreenScreen visibleFrame])) + options |= NSApplicationPresentationAutoHideDock; + } + + if ([NSApp respondsToSelector:@selector(setPresentationOptions:)]) + [NSApp setPresentationOptions:options]; + else +#endif + SetSystemUIMode(_isFullScreen ? kUIModeNormal : kUIModeAllHidden, 0); +} + +#if !defined(BUILDING_ON_TIGER) // IOPMAssertionCreateWithName not defined on < 10.5 +- (void)_disableIdleDisplaySleep +{ + if (_idleDisplaySleepAssertion == kIOPMNullAssertionID) +#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK + IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion); +#else // IOPMAssertionCreate is depreciated in > 10.5 + IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullScreen."), &_idleDisplaySleepAssertion); +#endif +} + +- (void)_enableIdleDisplaySleep +{ + if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) { + IOPMAssertionRelease(_idleDisplaySleepAssertion); + _idleDisplaySleepAssertion = kIOPMNullAssertionID; + } +} + +- (void)_disableIdleSystemSleep +{ + if (_idleSystemSleepAssertion == kIOPMNullAssertionID) +#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK + IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion); +#else // IOPMAssertionCreate is depreciated in > 10.5 + IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullScreen."), &_idleSystemSleepAssertion); +#endif +} + +- (void)_enableIdleSystemSleep +{ + if (_idleSystemSleepAssertion != kIOPMNullAssertionID) { + IOPMAssertionRelease(_idleSystemSleepAssertion); + _idleSystemSleepAssertion = kIOPMNullAssertionID; + } +} + +- (void)_enableTickleTimer +{ + [_tickleTimer invalidate]; + [_tickleTimer release]; + _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain]; +} + +- (void)_disableTickleTimer +{ + [_tickleTimer invalidate]; + [_tickleTimer release]; + _tickleTimer = nil; +} + +- (void)_tickleTimerFired +{ + UpdateSystemActivity(OverallAct); +} +#endif + +- (void)_updatePowerAssertions +{ +#if !defined(BUILDING_ON_TIGER) + if (_isPlaying && _isFullScreen) { + [self _disableIdleSystemSleep]; + [self _disableIdleDisplaySleep]; + [self _enableTickleTimer]; + } else { + [self _enableIdleSystemSleep]; + [self _enableIdleDisplaySleep]; + [self _disableTickleTimer]; + } +#endif +} + +- (WebFullScreenManagerProxy*)_manager +{ + WebPageProxy* webPage = toImpl([_webView pageRef]); + if (!webPage) + return 0; + return webPage->fullScreenManager(); +} + +- (void)_requestExit +{ + [self exitFullScreen]; + _forceDisableAnimation = NO; +} + +- (void)_requestExitFullScreenWithAnimation:(BOOL)animation +{ + _forceDisableAnimation = !animation; + [self performSelector:@selector(_requestExit) withObject:nil afterDelay:0]; + +} + +- (void)_swapView:(NSView*)view with:(NSView*)otherView +{ + [otherView setFrame:[view frame]]; + [otherView setAutoresizingMask:[view autoresizingMask]]; + [otherView removeFromSuperview]; + [[view superview] replaceSubview:view with:otherView]; +} + +#pragma mark - +#pragma mark Utility Functions + +- (WKFullScreenWindow *)_fullScreenWindow +{ + ASSERT([[self window] isKindOfClass:[WKFullScreenWindow class]]); + return (WKFullScreenWindow *)[self window]; +} + +- (CFTimeInterval)_animationDuration +{ + static const CFTimeInterval defaultDuration = 0.5; + CFTimeInterval duration = defaultDuration; +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + NSUInteger modifierFlags = [NSEvent modifierFlags]; +#else + NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; +#endif + if ((modifierFlags & NSControlKeyMask) == NSControlKeyMask) + duration *= 2; + if ((modifierFlags & NSShiftKeyMask) == NSShiftKeyMask) + duration *= 10; + if (_forceDisableAnimation) { + // This will disable scale animation + duration = 0; + } + return duration; +} + +@end + +#pragma mark - +@implementation WKFullScreenWindow + +- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag +{ + UNUSED_PARAM(aStyle); + self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag]; + if (!self) + return nil; + [self setOpaque:NO]; + [self setBackgroundColor:[NSColor clearColor]]; + [self setIgnoresMouseEvents:NO]; + [self setAcceptsMouseMovedEvents:YES]; + [self setReleasedWhenClosed:NO]; + [self setHasShadow:YES]; +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + [self setMovable:NO]; +#else + [self setMovableByWindowBackground:NO]; +#endif + + NSView* contentView = [self contentView]; + _animationView = [[NSView alloc] initWithFrame:[contentView bounds]]; + + CALayer* contentLayer = [[CALayer alloc] init]; + [_animationView setLayer:contentLayer]; + [_animationView setWantsLayer:YES]; + [_animationView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; + [contentView addSubview:_animationView]; + + _backgroundLayer = [[CALayer alloc] init]; + [contentLayer addSublayer:_backgroundLayer]; + + [_backgroundLayer setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)]; + [_backgroundLayer setOpacity:0]; + return self; +} + +- (void)dealloc +{ + [_animationView release]; + [_backgroundLayer release]; + [super dealloc]; +} + +- (BOOL)canBecomeKeyWindow +{ + return YES; +} + +- (void)keyDown:(NSEvent *)theEvent +{ + if ([[theEvent charactersIgnoringModifiers] isEqual:@"\e"]) // Esacpe key-code + [self cancelOperation:self]; + else [super keyDown:theEvent]; +} + +- (void)cancelOperation:(id)sender +{ + UNUSED_PARAM(sender); + [[self windowController] _requestExitFullScreenWithAnimation:YES]; +} + +- (CALayer*)backgroundLayer +{ + return _backgroundLayer; +} + +- (NSView*)animationView +{ + return _animationView; +} +@end + +#endif diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm index 498b6e7..f7c186d 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm @@ -35,6 +35,12 @@ using namespace WebCore; NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory"; NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache"; +NSString *WebStorageDirectoryDefaultsKey = @"WebKitLocalStorageDatabasePathPreferenceKey"; + +static NSString *WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification = @"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification"; + +// FIXME: <rdar://problem/9138817> - After this "backwards compatibility" radar is removed, this code should be removed to only return an empty String. +NSString *WebIconDatabaseDirectoryDefaultsKey = @"WebIconDatabaseDirectoryDefaultsKey"; namespace WebKit { @@ -97,8 +103,18 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para #if USE(CFURLSTORAGESESSIONS) parameters.uiProcessBundleIdentifier = String([[NSBundle mainBundle] bundleIdentifier]); #endif + + // Listen for enhanced accessibility changes and propagate them to the WebProcess. + m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) { + setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]); + }]; } +void WebContext::platformInvalidateContext() +{ + [[NSNotificationCenter defaultCenter] removeObserver:(id)m_enhancedAccessibilityObserver.get()]; +} + String WebContext::platformDefaultDatabaseDirectory() const { NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebDatabaseDirectoryDefaultsKey]; @@ -107,5 +123,22 @@ String WebContext::platformDefaultDatabaseDirectory() const return [databasesDirectory stringByStandardizingPath]; } +String WebContext::platformDefaultIconDatabasePath() const +{ + // FIXME: <rdar://problem/9138817> - After this "backwards compatibility" radar is removed, this code should be removed to only return an empty String. + NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebIconDatabaseDirectoryDefaultsKey]; + if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]]) + databasesDirectory = @"~/Library/Icons/WebpageIcons.db"; + return [databasesDirectory stringByStandardizingPath]; +} + +String WebContext::platformDefaultLocalStorageDirectory() const +{ + NSString *localStorageDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebStorageDirectoryDefaultsKey]; + if (!localStorageDirectory || ![localStorageDirectory isKindOfClass:[NSString class]]) + localStorageDirectory = @"~/Library/WebKit/LocalStorage"; + return [localStorageDirectory stringByStandardizingPath]; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm index 67139b3..fd0f534 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm @@ -199,6 +199,9 @@ void WebContextMenuProxyMac::populate(const Vector<WebContextMenuItemData>& item void WebContextMenuProxyMac::showContextMenu(const IntPoint& menuLocation, const Vector<WebContextMenuItemData>& items) { + if (items.isEmpty()) + return; + populate(items); [[WKMenuTarget sharedMenuTarget] setMenuProxy:this]; @@ -215,14 +218,12 @@ void WebContextMenuProxyMac::showContextMenu(const IntPoint& menuLocation, const float vertOffset = roundf((NSMaxY(menuRect) - NSMaxY(titleFrame)) + NSHeight(titleFrame)); NSPoint location = NSMakePoint(NSMinX(menuRect), NSMaxY(menuRect) - vertOffset); - RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:menuRect]); - [m_webView addSubview:dummyView.get()]; - location = [dummyView.get() convertPoint:location fromView:m_webView]; - - WKPopupMenu(menu, location, roundf(NSWidth(menuRect)), dummyView.get(), -1, nil); + location = [m_webView convertPoint:location toView:nil]; + location = [m_webView.window convertBaseToScreen:location]; + + WKPopupContextMenu(menu, location); [m_popup.get() dismissPopUp]; - [dummyView.get() removeFromSuperview]; } void WebContextMenuProxyMac::hideContextMenu() diff --git a/Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm new file mode 100644 index 0000000..6a31346 --- /dev/null +++ b/Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011, 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 "WebCookieManagerProxy.h" + +namespace WebKit { + +void WebCookieManagerProxy::persistHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) +{ + // FIXME: The sandbox appears to prevent persisting the new policy to disk, so we must set the + // policy in the UI Process as well as in the Web Process (to make sure it gets set on any + // Private Browsing Cookie Storage). + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:policy]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm new file mode 100644 index 0000000..d533573 --- /dev/null +++ b/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebFullScreenManagerProxy.h" +#include "LayerTreeContext.h" +#include "WKFullScreenWindowController.h" +#include "WKViewInternal.h" + +#if ENABLE(FULLSCREEN_API) + +namespace WebKit { + +void WebFullScreenManagerProxy::enterFullScreen() +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] enterFullScreen:nil]; +} + +void WebFullScreenManagerProxy::exitFullScreen() +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] exitFullScreen]; +} + +void WebFullScreenManagerProxy::beganEnterFullScreenAnimation() +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] beganEnterFullScreenAnimation]; +} + +void WebFullScreenManagerProxy::finishedEnterFullScreenAnimation(bool completed) +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] finishedEnterFullScreenAnimation:completed]; +} + +void WebFullScreenManagerProxy::beganExitFullScreenAnimation() +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] beganExitFullScreenAnimation]; +} + +void WebFullScreenManagerProxy::finishedExitFullScreenAnimation(bool completed) +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] finishedExitFullScreenAnimation:completed]; +} + +void WebFullScreenManagerProxy::enterAcceleratedCompositingMode(const LayerTreeContext& context) +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] enterAcceleratedCompositingMode:context]; +} + +void WebFullScreenManagerProxy::exitAcceleratedCompositingMode() +{ + if (!m_webView) + return; + [[m_webView fullScreenWindowController] exitAcceleratedCompositingMode]; +} + +void WebFullScreenManagerProxy::getFullScreenRect(WebCore::IntRect& rect) +{ + if (!m_webView) + return; + rect = [[m_webView fullScreenWindowController] getFullScreenRect]; +} + +} // namespace WebKit + +#endif diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm index 67d184c..9657764 100644 --- a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm @@ -32,6 +32,7 @@ #import "WKView.h" #import "WebPageProxy.h" #import <WebKitSystemInterface.h> +#import <WebCore/LocalizedStrings.h> #import <wtf/text/WTFString.h> using namespace WebCore; @@ -134,8 +135,7 @@ void WebInspectorProxy::platformClose() void WebInspectorProxy::platformInspectedURLChanged(const String& urlString) { - // FIXME: this should be made localizable once WebKit2 supports it. <rdar://problem/8728860> - NSString *title = [NSString stringWithFormat:@"Web Inspector \u2014 %@", (NSString *)urlString]; + NSString *title = [NSString stringWithFormat:UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)urlString]; [m_inspectorWindow.get() setTitle:title]; } diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm index 1d3ed53..90df81e 100644 --- a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 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 @@ -26,7 +26,13 @@ #import "config.h" #import "WebPageProxy.h" +#import "DataReference.h" +#import "DictionaryPopupInfo.h" +#import "NativeWebKeyboardEvent.h" #import "PageClient.h" +#import "TextChecker.h" +#import "WebPageMessages.h" +#import "WebProcessProxy.h" #import <wtf/text/StringConcatenate.h> @interface NSApplication (Details) @@ -113,4 +119,133 @@ CGContextRef WebPageProxy::containingWindowGraphicsContext() return m_pageClient->containingWindowGraphicsContext(); } +void WebPageProxy::updateWindowIsVisible(bool windowIsVisible) +{ + if (!isValid()) + return; + process()->send(Messages::WebPage::SetWindowIsVisible(windowIsVisible), m_pageID); +} + +void WebPageProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates, const IntPoint& accessibilityViewCoordinates) +{ + if (!isValid()) + return; + + process()->send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID); +} + +void WebPageProxy::getMarkedRange(uint64_t& location, uint64_t& length) +{ + process()->sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(location, length), m_pageID); +} + +uint64_t WebPageProxy::characterIndexForPoint(const IntPoint point) +{ + uint64_t result; + process()->sendSync(Messages::WebPage::CharacterIndexForPoint(point), Messages::WebPage::CharacterIndexForPoint::Reply(result), m_pageID); + return result; +} + +WebCore::IntRect WebPageProxy::firstRectForCharacterRange(uint64_t location, uint64_t length) +{ + IntRect resultRect; + process()->sendSync(Messages::WebPage::FirstRectForCharacterRange(location, length), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID); + return resultRect; +} + +bool WebPageProxy::writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes) +{ + bool result; + const double MessageTimeout = 20; + process()->sendSync(Messages::WebPage::WriteSelectionToPasteboard(pasteboardName, pasteboardTypes), Messages::WebPage::WriteSelectionToPasteboard::Reply(result), m_pageID, MessageTimeout); + return result; +} + +bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName) +{ + bool result; + const double MessageTimeout = 20; + process()->sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, MessageTimeout); + return result; +} + +void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag) +{ + RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(dragImageHandle); + if (!dragImage) + return; + + m_pageClient->setDragImage(clientPosition, dragImage.release(), isLinkDrag); +} + +void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point) +{ + if (!isValid()) + return; + + process()->send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID); +} + +void WebPageProxy::interpretKeyEvent(uint32_t type, Vector<KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<CompositionUnderline>& underlines) +{ + m_pageClient->interceptKeyEvent(m_keyEventQueue.first(), commandsList, selectionStart, selectionEnd, underlines); +} + +// Complex text input support for plug-ins. +void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput) +{ + if (!isValid()) + return; + + process()->send(Messages::WebPage::SendComplexTextInputToPlugin(pluginComplexTextInputIdentifier, textInput), m_pageID); +} + +void WebPageProxy::uppercaseWord() +{ + process()->send(Messages::WebPage::UppercaseWord(), m_pageID); +} + +void WebPageProxy::lowercaseWord() +{ + process()->send(Messages::WebPage::LowercaseWord(), m_pageID); +} + +void WebPageProxy::capitalizeWord() +{ + process()->send(Messages::WebPage::CapitalizeWord(), m_pageID); +} + +void WebPageProxy::setSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled) +{ + if (m_isSmartInsertDeleteEnabled == isSmartInsertDeleteEnabled) + return; + + TextChecker::setSmartInsertDeleteEnabled(isSmartInsertDeleteEnabled); + m_isSmartInsertDeleteEnabled = isSmartInsertDeleteEnabled; + process()->send(Messages::WebPage::SetSmartInsertDeleteEnabled(isSmartInsertDeleteEnabled), m_pageID); +} + +void WebPageProxy::didPerformDictionaryLookup(const String& text, const DictionaryPopupInfo& dictionaryPopupInfo) +{ + m_pageClient->didPerformDictionaryLookup(text, m_viewScaleFactor, dictionaryPopupInfo); +} + +void WebPageProxy::registerWebProcessAccessibilityToken(const CoreIPC::DataReference& data) +{ + m_pageClient->accessibilityWebProcessTokenReceived(data); +} + +void WebPageProxy::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elementToken, const CoreIPC::DataReference& windowToken) +{ + if (!isValid()) + return; + + process()->send(Messages::WebPage::RegisterUIProcessAccessibilityTokens(elementToken, windowToken), m_pageID); +} + +void WebPageProxy::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) +{ + m_pageClient->setComplexTextInputEnabled(pluginComplexTextInputIdentifier, complexTextInputEnabled); +} + } // namespace WebKit |