summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess/API/mac
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebKit2/UIProcess/API/mac
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebKit2/UIProcess/API/mac')
-rw-r--r--Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm1
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.h16
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.mm93
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.h12
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm55
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.mm193
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewInternal.h9
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h2
8 files changed, 229 insertions, 152 deletions
diff --git a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
index e622c9d..715bba7 100644
--- a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
+++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
@@ -27,6 +27,7 @@
#import "FindIndicatorWindow.h"
#import "FindIndicator.h"
+#import "WKView.h"
#import <WebCore/GraphicsContext.h>
static const double bounceAnimationDuration = 0.12;
diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
index 2c4a235..d22d8b5 100644
--- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
@@ -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
@@ -49,7 +49,7 @@ public:
~PDFViewController();
WKView* wkView() const { return m_wkView; }
- void setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference&);
+ void setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference&);
double zoomFactor() const;
void setZoomFactor(double);
@@ -57,16 +57,26 @@ public:
static Class pdfPreviewViewClass();
NSPrintOperation *makePrintOperation(NSPrintInfo *);
-
+ void openPDFInFinder();
+
private:
explicit PDFViewController(WKView *wkView);
static Class pdfDocumentClass();
static NSBundle* pdfKitBundle();
+ NSString *pathToPDFOnDisk();
+
WKView* m_wkView;
+
RetainPtr<WKPDFView> m_wkPDFView;
PDFView* m_pdfView;
+
+ RetainPtr<NSString> m_suggestedFilename;
+ RetainPtr<CFDataRef> m_pdfData;
+
+ RetainPtr<NSString> m_pathToPDFOnDisk;
+ bool m_hasWrittenPDFToDisk;
};
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
index 6ab425d..5d9b860 100644
--- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
@@ -87,6 +87,7 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
[self addSubview:_pdfPreviewView.get()];
_pdfView = [_pdfPreviewView.get() performSelector:@selector(pdfView)];
+ [_pdfView setDelegate:self];
}
return self;
@@ -179,6 +180,13 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
[notificationCenter removeObserver:self name:_webkit_PDFViewPageChangedNotification object:_pdfView];
}
+// PDFView delegate methods
+
+- (void)PDFViewOpenPDFInNativeApplication:(PDFView *)sender
+{
+ _pdfViewController->openPDFInFinder();
+}
+
@end
namespace WebKit {
@@ -192,6 +200,7 @@ PDFViewController::PDFViewController(WKView *wkView)
: m_wkView(wkView)
, m_wkPDFView(AdoptNS, [[WKPDFView alloc] initWithFrame:[m_wkView bounds] PDFViewController:this])
, m_pdfView([m_wkPDFView.get() pdfView])
+ , m_hasWrittenPDFToDisk(false)
{
[m_wkView addSubview:m_wkPDFView.get()];
}
@@ -231,20 +240,20 @@ static RetainPtr<CFDataRef> convertPostScriptDataSourceToPDF(const CoreIPC::Data
return result;
}
-void PDFViewController::setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference& dataReference)
+void PDFViewController::setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
{
- RetainPtr<CFDataRef> data;
-
if (equalIgnoringCase(mimeType, "application/postscript")) {
- data = convertPostScriptDataSourceToPDF(dataReference);
- if (!data)
+ m_pdfData = convertPostScriptDataSourceToPDF(dataReference);
+ if (!m_pdfData)
return;
} else {
// Make sure to copy the data.
- data.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size()));
+ m_pdfData.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size()));
}
- RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)data.get()]);
+ m_suggestedFilename = suggestedFilename;
+
+ RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)m_pdfData.get()]);
[m_wkPDFView.get() setDocument:pdfDocument.get()];
}
@@ -295,4 +304,74 @@ NSPrintOperation *PDFViewController::makePrintOperation(NSPrintInfo *printInfo)
return [[m_pdfView document] getPrintOperationForPrintInfo:printInfo autoRotate:YES];
}
+void PDFViewController::openPDFInFinder()
+{
+ // We don't want to open the PDF until we have a document to write. (see 4892525).
+ if (![m_pdfView document]) {
+ NSBeep();
+ return;
+ }
+
+ NSString *path = pathToPDFOnDisk();
+ if (!path)
+ return;
+
+ if (!m_hasWrittenPDFToDisk) {
+ // Create a PDF file with the minimal permissions (only accessible to the current user, see 4145714).
+ RetainPtr<NSNumber> permissions(AdoptNS, [[NSNumber alloc] initWithInt:S_IRUSR]);
+ RetainPtr<NSDictionary> fileAttributes(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:permissions.get(), NSFilePosixPermissions, nil]);
+
+ if (![[NSFileManager defaultManager] createFileAtPath:path contents:(NSData *)m_pdfData.get() attributes:fileAttributes.get()])
+ return;
+
+ m_hasWrittenPDFToDisk = true;
+ }
+
+ [[NSWorkspace sharedWorkspace] openFile:path];
+}
+
+static NSString *temporaryPDFDirectoryPath()
+{
+ static NSString *temporaryPDFDirectoryPath;
+
+ if (!temporaryPDFDirectoryPath) {
+ NSString *temporaryDirectoryTemplate = [NSTemporaryDirectory() stringByAppendingPathComponent:@"WebKitPDFs-XXXXXX"];
+ CString templateRepresentation = [temporaryDirectoryTemplate fileSystemRepresentation];
+
+ if (mkdtemp(templateRepresentation.mutableData()))
+ temporaryPDFDirectoryPath = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:templateRepresentation.data() length:templateRepresentation.length()] copy];
+ }
+
+ return temporaryPDFDirectoryPath;
+}
+
+NSString *PDFViewController::pathToPDFOnDisk()
+{
+ if (m_pathToPDFOnDisk)
+ return m_pathToPDFOnDisk.get();
+
+ NSString *pdfDirectoryPath = temporaryPDFDirectoryPath();
+ if (!pdfDirectoryPath)
+ return nil;
+
+ NSString *path = [pdfDirectoryPath stringByAppendingPathComponent:m_suggestedFilename.get()];
+
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ if ([fileManager fileExistsAtPath:path]) {
+ NSString *pathTemplatePrefix = [pdfDirectoryPath stringByAppendingString:@"XXXXXX-"];
+ NSString *pathTemplate = [pathTemplatePrefix stringByAppendingPathComponent:m_suggestedFilename.get()];
+ CString pathTemplateRepresentation = [pathTemplate fileSystemRepresentation];
+
+ int fd = mkstemps(pathTemplateRepresentation.mutableData(), pathTemplateRepresentation.length() - strlen([pathTemplatePrefix fileSystemRepresentation]) + 1);
+ if (fd < 0)
+ return nil;
+
+ close(fd);
+ path = [fileManager stringWithFileSystemRepresentation:pathTemplateRepresentation.data() length:pathTemplateRepresentation.length()];
+ }
+
+ m_pathToPDFOnDisk.adoptNS([path copy]);
+ return path;
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
index b557c1a..e01cf66 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -69,7 +69,6 @@ private:
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
- virtual void setEditCommandState(const String& commandName, bool isEnabled, int state);
virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines);
virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
@@ -86,11 +85,6 @@ private:
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
virtual void exitAcceleratedCompositingMode();
-#if USE(ACCELERATED_COMPOSITING)
- virtual void pageDidEnterAcceleratedCompositing();
- virtual void pageDidLeaveAcceleratedCompositing();
-#endif
-
virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&);
virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled);
virtual void setAutodisplay(bool);
@@ -100,11 +94,15 @@ private:
virtual void didChangeScrollbarsForMainFrame() const;
virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
- virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&);
+ virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
virtual double customRepresentationZoomFactor();
virtual void setCustomRepresentationZoomFactor(double);
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+
+ virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&);
+
WKView* m_wkView;
RetainPtr<WebEditorUndoTargetObjC> m_undoTarget;
};
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
index fd70a67..88bb9a4 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -27,6 +27,7 @@
#import "PageClientImpl.h"
#import "DataReference.h"
+#import "DictionaryPopupInfo.h"
#import "FindIndicator.h"
#import "NativeWebKeyboardEvent.h"
#import "WKAPICast.h"
@@ -40,6 +41,7 @@
#import <WebCore/FoundationExtras.h>
#import <WebCore/GraphicsContext.h>
#import <WebCore/KeyboardEvent.h>
+#import <WebCore/NotImplemented.h>
#import <wtf/PassOwnPtr.h>
#import <wtf/text/CString.h>
#import <wtf/text/WTFString.h>
@@ -279,11 +281,6 @@ void PageClientImpl::clearAllEditCommands()
[[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
}
-void PageClientImpl::setEditCommandState(const String& commandName, bool isEnabled, int newState)
-{
- [m_wkView _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:newState];
-}
-
void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines)
{
commandsList = [m_wkView _interceptKeyEvent:event.nativeEvent()];
@@ -294,7 +291,6 @@ void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize&
{
OwnPtr<GraphicsContext> graphicsContext = dragImage->createGraphicsContext();
RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:CGBitmapContextCreateImage(graphicsContext->platformContext()) size:imageSize]);
- [dragNSImage.get() setFlipped:YES];
[m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
}
@@ -352,16 +348,6 @@ void PageClientImpl::exitAcceleratedCompositingMode()
{
[m_wkView _exitAcceleratedCompositingMode];
}
-
-void PageClientImpl::pageDidEnterAcceleratedCompositing()
-{
- [m_wkView _pageDidEnterAcceleratedCompositing];
-}
-
-void PageClientImpl::pageDidLeaveAcceleratedCompositing()
-{
- [m_wkView _pageDidLeaveAcceleratedCompositing];
-}
#endif // USE(ACCELERATED_COMPOSITING)
void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled)
@@ -375,11 +361,21 @@ void PageClientImpl::setAutodisplay(bool newState)
[m_wkView displayIfNeeded];
[[m_wkView window] setAutodisplay:newState];
+
+ // For some reason, painting doesn't happen for a long time without this call, <rdar://problem/8975229>.
+ if (newState)
+ [m_wkView displayIfNeeded];
}
CGContextRef PageClientImpl::containingWindowGraphicsContext()
{
- return static_cast<CGContextRef>([[[m_wkView window] graphicsContext] graphicsPort]);
+ NSWindow *window = [m_wkView window];
+
+ // Don't try to get the graphics context if the NSWindow doesn't have a window device.
+ if ([window windowNumber] <= 0)
+ return 0;
+
+ return static_cast<CGContextRef>([[window graphicsContext] graphicsPort]);
}
void PageClientImpl::didChangeScrollbarsForMainFrame() const
@@ -392,9 +388,9 @@ void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
[m_wkView _setPageHasCustomRepresentation:useCustomRepresentation];
}
-void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference)
+void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
{
- [m_wkView _didFinishLoadingDataForCustomRepresentation:dataReference];
+ [m_wkView _didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference];
}
double PageClientImpl::customRepresentationZoomFactor()
@@ -407,4 +403,25 @@ void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor)
[m_wkView _setCustomRepresentationZoomFactor:zoomFactor];
}
+void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::didPerformDictionaryLookup(const String& text, double scaleFactor, const DictionaryPopupInfo& dictionaryPopupInfo)
+{
+ NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(NSDictionary *)dictionaryPopupInfo.fontInfo.fontAttributeDictionary.get()];
+ NSFont *font = [NSFont fontWithDescriptor:fontDescriptor size:((scaleFactor != 1) ? [fontDescriptor pointSize] * scaleFactor : 0)];
+
+ RetainPtr<NSMutableAttributedString> attributedString(AdoptNS, [[NSMutableAttributedString alloc] initWithString:nsStringFromWebCoreString(text)]);
+ [attributedString.get() addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, [attributedString.get() length])];
+
+ NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
+ textBaselineOrigin.y += [font ascender];
+
+ // If the dictionary lookup is being triggered by a hot key, force the overlay style.
+ NSDictionary *options = (dictionaryPopupInfo.type == DictionaryPopupInfo::HotKey) ? [NSDictionary dictionaryWithObject:NSDefinitionPresentationTypeOverlay forKey:NSDefinitionPresentationTypeKey] : 0;
+ [m_wkView showDefinitionForAttributedString:attributedString.get() range:NSMakeRange(0, [attributedString.get() length]) options:options baselineOriginProvider:^(NSRange adjustedRange) { return (NSPoint)textBaselineOrigin; }];
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm
index da29e04..e432549 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -31,7 +31,6 @@
#import "DrawingAreaProxyImpl.h"
#import "FindIndicator.h"
#import "FindIndicatorWindow.h"
-#import "LayerBackedDrawingAreaProxy.h"
#import "LayerTreeContext.h"
#import "Logging.h"
#import "NativeWebKeyboardEvent.h"
@@ -52,7 +51,6 @@
#import "WebEventFactory.h"
#import "WebPage.h"
#import "WebPageProxy.h"
-#import "WebProcessManager.h"
#import "WebProcessProxy.h"
#import "WebSystemInterface.h"
#import <QuartzCore/QuartzCore.h>
@@ -208,6 +206,8 @@ static bool useNewDrawingArea()
if (!self)
return nil;
+ [NSApp registerServicesMenuSendTypes:PasteboardTypes::forSelection() returnTypes:PasteboardTypes::forEditing()];
+
InitWebCoreSystemInterface();
RunLoop::initializeMainRunLoop();
@@ -496,6 +496,30 @@ WEBCORE_COMMAND(yankAndSelect)
#undef WEBCORE_COMMAND
+- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
+{
+ Vector<String> pasteboardTypes;
+ size_t numTypes = [types count];
+ for (size_t i = 0; i < numTypes; ++i)
+ pasteboardTypes.append([types objectAtIndex:i]);
+ return _data->_page->writeSelectionToPasteboard([pasteboard name], pasteboardTypes);
+}
+
+- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
+{
+ BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->selectionState().isNone);
+ BOOL isValidReturnType = NO;
+ if (!returnType)
+ isValidReturnType = YES;
+ else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->selectionState().isContentEditable) {
+ // We can insert strings in any editable context. We can insert other types, like images, only in rich edit contexts.
+ isValidReturnType = _data->_page->selectionState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType];
+ }
+ if (isValidSendType && isValidReturnType)
+ return self;
+ return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType];
+}
+
/*
When possible, editing-related methods should be implemented in WebCore with the
@@ -548,6 +572,18 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
return (NSToolbarItem *)item;
}
+static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int32_t state, WKErrorRef error, void* context)
+{
+ // If the process exits before the command can be validated, we'll be called back with an error.
+ if (error)
+ return;
+
+ WKView* wkView = static_cast<WKView*>(context);
+ ASSERT(wkView);
+
+ [wkView _setUserInterfaceItemState:nsStringFromWebCoreString(toImpl(commandName)->string()) enabled:isEnabled state:state];
+}
+
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
SEL action = [item action];
@@ -643,8 +679,7 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
// If we are not already awaiting validation for this command, start the asynchronous validation process.
// FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
// we asked for the same command; there is no guarantee the answer is still valid.
- // FIXME: The function called here should be renamed validateCommand because it is not specific to menu items.
- _data->_page->validateMenuItem(commandName);
+ _data->_page->validateCommand(commandName, ValidateCommandCallback::create(self, validateCommandCallback));
}
// Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called.
@@ -715,6 +750,23 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
_data->_page->unmarkAllMisspellings();
}
+- (BOOL)isGrammarCheckingEnabled
+{
+ return TextChecker::state().isGrammarCheckingEnabled;
+}
+
+- (void)setGrammarCheckingEnabled:(BOOL)flag
+{
+ if (static_cast<bool>(flag) == TextChecker::state().isGrammarCheckingEnabled)
+ return;
+
+ TextChecker::setGrammarCheckingEnabled(flag);
+ _data->_page->process()->updateTextCheckerState();
+
+ if (!flag)
+ _data->_page->unmarkAllBadGrammar();
+}
+
- (IBAction)toggleGrammarChecking:(id)sender
{
bool grammarCheckingEnabled = !TextChecker::state().isGrammarCheckingEnabled;
@@ -1496,6 +1548,13 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
return _data->_page->drawsBackground();
}
+- (BOOL)mouseDownCanMoveWindow
+{
+ // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent,
+ // but we don't want a drag in the NSView to move the window, even if it's transparent.
+ return NO;
+}
+
- (void)viewDidHide
{
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
@@ -1506,6 +1565,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
_data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
}
+- (id)accessibilityFocusedUIElement
+{
+ return _data->_remoteAccessibilityChild.get();
+}
+
- (BOOL)accessibilityIsIgnored
{
return NO;
@@ -1802,95 +1866,6 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
_data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut);
}
-#if USE(ACCELERATED_COMPOSITING)
-- (void)_startAcceleratedCompositing:(CALayer *)rootLayer
-{
- if (!_data->_oldLayerHostingView) {
- NSView *hostingView = [[NSView alloc] initWithFrame:[self bounds]];
-#if !defined(BUILDING_ON_LEOPARD)
- [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
-#endif
-
- [self addSubview:hostingView];
- [hostingView release];
- _data->_oldLayerHostingView = hostingView;
- }
-
- // Make a container layer, which will get sized/positioned by AppKit and CA.
- CALayer *viewLayer = [CALayer layer];
-
-#ifndef NDEBUG
- [viewLayer setName:@"hosting layer"];
-#endif
-
-#if defined(BUILDING_ON_LEOPARD)
- // Turn off default animations.
- NSNull *nullValue = [NSNull null];
- NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:
- nullValue, @"anchorPoint",
- nullValue, @"bounds",
- nullValue, @"contents",
- nullValue, @"contentsRect",
- nullValue, @"opacity",
- nullValue, @"position",
- nullValue, @"sublayerTransform",
- nullValue, @"sublayers",
- nullValue, @"transform",
- nil];
- [viewLayer setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]];
-#endif
-
-#if !defined(BUILDING_ON_LEOPARD)
- // If we aren't in the window yet, we'll use the screen's scale factor now, and reset the scale
- // via -viewDidMoveToWindow.
- CGFloat scaleFactor = [self window] ? [[self window] userSpaceScaleFactor] : [[NSScreen mainScreen] userSpaceScaleFactor];
- [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
-#endif
-
- [_data->_oldLayerHostingView setLayer:viewLayer];
- [_data->_oldLayerHostingView setWantsLayer:YES];
-
- // Parent our root layer in the container layer
- [viewLayer addSublayer:rootLayer];
-}
-
-- (void)_stopAcceleratedCompositing
-{
- if (_data->_oldLayerHostingView) {
- [_data->_oldLayerHostingView setLayer:nil];
- [_data->_oldLayerHostingView setWantsLayer:NO];
- [_data->_oldLayerHostingView removeFromSuperview];
- _data->_oldLayerHostingView = nil;
- }
-}
-
-- (void)_switchToDrawingAreaTypeIfNecessary:(DrawingAreaInfo::Type)type
-{
- DrawingAreaInfo::Type existingDrawingAreaType = _data->_page->drawingArea() ? _data->_page->drawingArea()->info().type : DrawingAreaInfo::None;
- if (existingDrawingAreaType == type)
- return;
-
- OwnPtr<DrawingAreaProxy> newDrawingArea;
- switch (type) {
- case DrawingAreaInfo::Impl:
- case DrawingAreaInfo::None:
- break;
- case DrawingAreaInfo::ChunkedUpdate: {
- newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get());
- break;
- }
- case DrawingAreaInfo::LayerBacked: {
- newDrawingArea = LayerBackedDrawingAreaProxy::create(self, _data->_page.get());
- break;
- }
- }
-
- newDrawingArea->setSize(IntSize([self frame].size), IntSize());
-
- _data->_page->drawingArea()->detachCompositingContext();
- _data->_page->setDrawingArea(newDrawingArea.release());
-}
-
- (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext
{
ASSERT(!_data->_layerHostingView);
@@ -1899,6 +1874,9 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
// Create an NSView that will host our layer tree.
_data->_layerHostingView.adoptNS([[NSView alloc] initWithFrame:[self bounds]]);
[_data->_layerHostingView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
[self addSubview:_data->_layerHostingView.get()];
// Create a root layer that will back the NSView.
@@ -1912,31 +1890,21 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
[_data->_layerHostingView.get() setLayer:rootLayer.get()];
[_data->_layerHostingView.get() setWantsLayer:YES];
+
+ [CATransaction commit];
}
- (void)_exitAcceleratedCompositingMode
{
ASSERT(_data->_layerHostingView);
+ [_data->_layerHostingView.get() removeFromSuperview];
[_data->_layerHostingView.get() setLayer:nil];
[_data->_layerHostingView.get() setWantsLayer:NO];
- [_data->_layerHostingView.get() removeFromSuperview];
_data->_layerHostingView = nullptr;
}
-- (void)_pageDidEnterAcceleratedCompositing
-{
- [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::LayerBacked];
-}
-
-- (void)_pageDidLeaveAcceleratedCompositing
-{
- // FIXME: we may want to avoid flipping back to the non-layer-backed drawing area until the next page load, to avoid thrashing.
- [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::ChunkedUpdate];
-}
-#endif // USE(ACCELERATED_COMPOSITING)
-
- (void)_setAccessibilityWebProcessToken:(NSData *)data
{
#if !defined(BUILDING_ON_SNOW_LEOPARD)
@@ -1978,11 +1946,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
_data->_pdfViewController = PDFViewController::create(self);
}
-- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference
+- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference
{
ASSERT(_data->_pdfViewController);
- _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), dataReference);
+ _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), suggestedFilename, dataReference);
}
- (double)_customRepresentationZoomFactor
@@ -2056,5 +2024,14 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
return _frameSizeUpdatesDisabledCount > 0;
}
+- (void)performDictionaryLookupAtCurrentMouseLocation
+{
+ NSPoint thePoint = [NSEvent mouseLocation];
+ thePoint = [[self window] convertScreenToBase:thePoint];
+ thePoint = [self convertPoint:thePoint fromView:nil];
+
+ _data->_page->performDictionaryLookupAtLocation(FloatPoint(thePoint.x, thePoint.y));
+}
+
@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
index 9e77e30..4147658 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
@@ -52,18 +52,11 @@ namespace WebKit {
- (void)_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext;
- (void)_exitAcceleratedCompositingMode;
-#if USE(ACCELERATED_COMPOSITING)
-- (void)_startAcceleratedCompositing:(CALayer *)rootLayer;
-- (void)_stopAcceleratedCompositing;
-- (void)_pageDidEnterAcceleratedCompositing;
-- (void)_pageDidLeaveAcceleratedCompositing;
-#endif
-
- (void)_setAccessibilityWebProcessToken:(NSData *)data;
- (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation;
-- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference;
+- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference;
- (double)_customRepresentationZoomFactor;
- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor;
- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
index 5d6125e..cece1c7 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
@@ -33,4 +33,6 @@
- (void)enableFrameSizeUpdates;
- (BOOL)frameSizeUpdatesDisabled;
+- (void)performDictionaryLookupAtCurrentMouseLocation;
+
@end