summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-16 16:25:10 +0100
committerBen Murdoch <benm@google.com>2011-05-23 18:54:14 +0100
commitab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch)
treedb769fadd053248f85db67434a5b275224defef7 /Source/WebKit2/UIProcess/API
parent52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff)
downloadexternal_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip
external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz
external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFrame.cpp30
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFrame.h14
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.cpp12
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h58
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.h4
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm22
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.mm186
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewInternal.h1
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp16
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage.cpp27
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage_p.h7
11 files changed, 284 insertions, 93 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.cpp b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp
index 7c9ae11..cce572a 100644
--- a/Source/WebKit2/UIProcess/API/C/WKFrame.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp
@@ -75,6 +75,11 @@ WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frameRef)
return toCopiedURLAPI(toImpl(frameRef)->unreachableURL());
}
+void WKFrameStopLoading(WKFrameRef frameRef)
+{
+ toImpl(frameRef)->stopLoading();
+}
+
WKStringRef WKFrameCopyMIMEType(WKFrameRef frameRef)
{
return toCopiedAPI(toImpl(frameRef)->mimeType());
@@ -95,6 +100,11 @@ WKArrayRef WKFrameCopyChildFrames(WKFrameRef frameRef)
return toAPI(toImpl(frameRef)->childFrames().releaseRef());
}
+WKFrameRef WKFrameGetParentFrame(WKFrameRef frameRef)
+{
+ return toAPI(toImpl(frameRef)->parentFrame());
+}
+
WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frameRef)
{
return toAPI(toImpl(frameRef)->certificateInfo());
@@ -125,22 +135,32 @@ bool WKFrameIsFrameSet(WKFrameRef frameRef)
return toImpl(frameRef)->isFrameSet();
}
-void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetMainResourceDataFunction callback, void* context)
+void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetResourceDataFunction callback, void* context)
{
toImpl(frameRef)->getMainResourceData(DataCallback::create(context, callback));
}
+void WKFrameGetResourceData(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataFunction callback, void* context)
+{
+ toImpl(frameRef)->getResourceData(toImpl(resourceURL), DataCallback::create(context, callback));
+}
+
#ifdef __BLOCKS__
-static void callGetMainResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context)
+static void callGetResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context)
{
- WKFrameGetMainResourceDataBlock block = (WKFrameGetMainResourceDataBlock)context;
+ WKFrameGetResourceDataBlock block = (WKFrameGetResourceDataBlock)context;
block(data, error);
Block_release(block);
}
-void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetMainResourceDataBlock block)
+void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetResourceDataBlock block)
+{
+ WKFrameGetMainResourceData(frameRef, callGetResourceDataBlockAndDispose, Block_copy(block));
+}
+
+void WKFrameGetResourceData_b(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataBlock block)
{
- WKFrameGetMainResourceData(frameRef, callGetMainResourceDataBlockAndDispose, Block_copy(block));
+ WKFrameGetResourceData(frameRef, resourceURL, callGetResourceDataBlockAndDispose, Block_copy(block));
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.h b/Source/WebKit2/UIProcess/API/C/WKFrame.h
index f812aeb..334a27b 100644
--- a/Source/WebKit2/UIProcess/API/C/WKFrame.h
+++ b/Source/WebKit2/UIProcess/API/C/WKFrame.h
@@ -51,6 +51,8 @@ WK_EXPORT WKURLRef WKFrameCopyProvisionalURL(WKFrameRef frame);
WK_EXPORT WKURLRef WKFrameCopyURL(WKFrameRef frame);
WK_EXPORT WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frame);
+WK_EXPORT void WKFrameStopLoading(WKFrameRef frame);
+
WK_EXPORT WKStringRef WKFrameCopyMIMEType(WKFrameRef frame);
WK_EXPORT WKStringRef WKFrameCopyTitle(WKFrameRef frame);
@@ -58,6 +60,8 @@ WK_EXPORT WKPageRef WKFrameGetPage(WKFrameRef frame);
WK_EXPORT WKArrayRef WKFrameCopyChildFrames(WKFrameRef frame);
+WK_EXPORT WKFrameRef WKFrameGetParentFrame(WKFrameRef frame);
+
WK_EXPORT WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frame);
WK_EXPORT bool WKFrameCanProvideSource(WKFrameRef frame);
@@ -68,11 +72,13 @@ WK_EXPORT bool WKFrameIsDisplayingMarkupDocument(WKFrameRef frame);
WK_EXPORT bool WKFrameIsFrameSet(WKFrameRef frame);
-typedef void (*WKFrameGetMainResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
-WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetMainResourceDataFunction function, void* functionContext);
+typedef void (*WKFrameGetResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetResourceDataFunction function, void* functionContext);
+WK_EXPORT void WKFrameGetResourceData(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataFunction function, void* functionContext);
#ifdef __BLOCKS__
-typedef void (^WKFrameGetMainResourceDataBlock)(WKDataRef data, WKErrorRef error);
-WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetMainResourceDataBlock block);
+typedef void (^WKFrameGetResourceDataBlock)(WKDataRef data, WKErrorRef error);
+WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetResourceDataBlock block);
+WK_EXPORT void WKFrameGetResourceData_b(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataBlock block);
#endif
typedef void (*WKFrameGetWebArchiveFunction)(WKDataRef archiveData, WKErrorRef error, void* functionContext);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
index edcbf87..82daa4b 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -260,11 +260,16 @@ void WKPageSetPageAndTextZoomFactors(WKPageRef pageRef, double pageZoomFactor, d
toImpl(pageRef)->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor);
}
-void WKPageScaleWebView(WKPageRef pageRef, double scale, WKPoint origin)
+void WKPageSetScaleFactor(WKPageRef pageRef, double scale, WKPoint origin)
{
toImpl(pageRef)->scaleWebView(scale, toIntPoint(origin));
}
+double WKPageGetScaleFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->viewScaleFactor();
+}
+
void WKPageSetUseFixedLayout(WKPageRef pageRef, bool fixed)
{
toImpl(pageRef)->setUseFixedLayout(fixed);
@@ -285,11 +290,6 @@ WKSize WKPageFixedLayoutSize(WKPageRef pageRef)
return toAPI(toImpl(pageRef)->fixedLayoutSize());
}
-double WKPageGetViewScaleFactor(WKPageRef pageRef)
-{
- return toImpl(pageRef)->viewScaleFactor();
-}
-
void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
{
toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
index 05730e5..e4bf162 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.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
@@ -41,6 +41,8 @@
extern "C" {
#endif
+typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo);
+
// FrameLoad Client
typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
@@ -59,19 +61,6 @@ typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFr
typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
-// Progress Client
-typedef void (*WKPageDidStartProgressCallback)(WKPageRef page, const void *clientInfo);
-typedef void (*WKPageDidChangeProgressCallback)(WKPageRef page, const void *clientInfo);
-typedef void (*WKPageDidFinishProgressCallback)(WKPageRef page, const void *clientInfo);
-
-// WebProcess Client
-// FIXME: These three functions should not be part of this client.
-typedef void (*WKPageProcessDidBecomeUnresponsiveCallback)(WKPageRef page, const void *clientInfo);
-typedef void (*WKPageProcessDidBecomeResponsiveCallback)(WKPageRef page, const void *clientInfo);
-typedef void (*WKPageProcessDidCrashCallback)(WKPageRef page, const void *clientInfo);
-
-typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, const void *clientInfo);
-
struct WKPageLoaderClient {
int version;
const void * clientInfo;
@@ -93,16 +82,16 @@ struct WKPageLoaderClient {
WKPageDidReceiveAuthenticationChallengeInFrameCallback didReceiveAuthenticationChallengeInFrame;
// FIXME: Move to progress client.
- WKPageDidStartProgressCallback didStartProgress;
- WKPageDidChangeProgressCallback didChangeProgress;
- WKPageDidFinishProgressCallback didFinishProgress;
+ WKPageCallback didStartProgress;
+ WKPageCallback didChangeProgress;
+ WKPageCallback didFinishProgress;
// FIXME: These three functions should not be part of this client.
- WKPageProcessDidBecomeUnresponsiveCallback processDidBecomeUnresponsive;
- WKPageProcessDidBecomeResponsiveCallback processDidBecomeResponsive;
- WKPageProcessDidCrashCallback processDidCrash;
+ WKPageCallback processDidBecomeUnresponsive;
+ WKPageCallback processDidBecomeResponsive;
+ WKPageCallback processDidCrash;
- WKPageDidChangeBackForwardListCallback didChangeBackForwardList;
+ WKPageCallback didChangeBackForwardList;
};
typedef struct WKPageLoaderClient WKPageLoaderClient;
@@ -152,8 +141,6 @@ typedef struct WKPageResourceLoadClient WKPageResourceLoadClient;
// UI Client
typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
-typedef void (*WKPageShowPageCallback)(WKPageRef page, const void *clientInfo);
-typedef void (*WKPageCloseCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
@@ -172,18 +159,21 @@ typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, con
typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
-typedef void (*WKPageDidDrawCallback)(WKPageRef page, const void *clientInfo);
-typedef void (*WKPageDidScrollCallback)(WKPageRef page, const void *clientInfo);
typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage, const void *clientInfo);
typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
+typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
struct WKPageUIClient {
int version;
const void * clientInfo;
WKPageCreateNewPageCallback createNewPage;
- WKPageShowPageCallback showPage;
- WKPageCloseCallback close;
+ WKPageCallback showPage;
+ WKPageCallback close;
WKPageRunJavaScriptAlertCallback runJavaScriptAlert;
WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm;
WKPageRunJavaScriptPromptCallback runJavaScriptPrompt;
@@ -202,11 +192,17 @@ struct WKPageUIClient {
WKPageGetWindowFrameCallback getWindowFrame;
WKPageSetWindowFrameCallback setWindowFrame;
WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel;
- WKPageDidDrawCallback didDraw;
- WKPageDidScrollCallback pageDidScroll;
+ WKPageCallback didDraw;
+ WKPageCallback pageDidScroll;
WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota;
WKPageRunOpenPanelCallback runOpenPanel;
WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest;
+ WKPageHeaderHeightCallback headerHeight;
+ WKPageFooterHeightCallback footerHeight;
+ WKPageDrawHeaderCallback drawHeader;
+ WKPageDrawFooterCallback drawFooter;
+ WKPagePrintFrameCallback printFrame;
+ WKPageCallback runModal;
};
typedef struct WKPageUIClient WKPageUIClient;
@@ -304,8 +300,8 @@ WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page);
WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor);
WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor);
-WK_EXPORT void WKPageScaleWebView(WKPageRef page, double scale, WKPoint origin);
-WK_EXPORT double WKPageGetViewScaleFactor(WKPageRef page);
+WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin);
+WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
index 8322465..625b8f6 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -51,6 +51,7 @@ private:
virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
virtual void setViewNeedsDisplay(const WebCore::IntRect&);
virtual void displayView();
+ virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
virtual WebCore::IntSize viewSize();
virtual bool isViewWindowActive();
@@ -69,6 +70,7 @@ private:
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);
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
@@ -88,6 +90,8 @@ private:
virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&);
virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled);
+ virtual CGContextRef containingWindowGraphicsContext();
+
virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&);
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
index c37b641..60be5bc 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -37,6 +37,7 @@
#import <WebCore/Cursor.h>
#import <WebCore/FloatRect.h>
#import <WebCore/FoundationExtras.h>
+#import <WebCore/GraphicsContext.h>
#import <WebCore/KeyboardEvent.h>
#import <wtf/PassOwnPtr.h>
#import <wtf/text/CString.h>
@@ -133,6 +134,14 @@ void PageClientImpl::displayView()
[m_wkView displayIfNeeded];
}
+void PageClientImpl::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ NSRect clippedScrollRect = NSIntersectionRect(scrollRect, NSOffsetRect(scrollRect, -scrollOffset.width(), -scrollOffset.height()));
+
+ [m_wkView translateRectsNeedingDisplayInRect:clippedScrollRect by:scrollOffset];
+ [m_wkView scrollRect:clippedScrollRect by:scrollOffset];
+}
+
IntSize PageClientImpl::viewSize()
{
return IntSize([m_wkView bounds].size);
@@ -270,6 +279,14 @@ void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vect
[m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines];
}
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, const IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
+{
+ 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];
+}
+
FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
{
return [m_wkView _convertToDeviceSpace:rect];
@@ -327,6 +344,11 @@ void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputI
[m_wkView _setComplexTextInputEnabled:complexTextInputEnabled pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
}
+CGContextRef PageClientImpl::containingWindowGraphicsContext()
+{
+ return static_cast<CGContextRef>([[[m_wkView window] graphicsContext] graphicsPort]);
+}
+
void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
{
[m_wkView _setPageHasCustomRepresentation:useCustomRepresentation];
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm
index da9b7c9..400239d 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -35,7 +35,9 @@
#import "NativeWebKeyboardEvent.h"
#import "PDFViewController.h"
#import "PageClientImpl.h"
+#import "PasteboardTypes.h"
#import "PrintInfo.h"
+#import "Region.h"
#import "RunLoop.h"
#import "TextChecker.h"
#import "TextCheckerState.h"
@@ -95,6 +97,9 @@ typedef HashMap<String, ValidationVector> ValidationMap;
}
+NSString* const WebKitOriginalTopPrintingMarginKey = @"WebKitOriginalTopMargin";
+NSString* const WebKitOriginalBottomPrintingMarginKey = @"WebKitOriginalBottomMargin";
+
@interface WKViewData : NSObject {
@public
OwnPtr<PageClientImpl> _pageClient;
@@ -135,6 +140,9 @@ typedef HashMap<String, ValidationVector> ValidationMap;
bool _inBecomeFirstResponder;
bool _inResignFirstResponder;
+ NSEvent *_mouseDownEvent;
+ BOOL _ignoringMouseDraggedEvents;
+ BOOL _dragHasStarted;
}
@end
@@ -195,21 +203,10 @@ static bool useNewDrawingArea()
return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil];
}
-static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type";
-static NSString * const WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
-static NSString * const WebURLPboardType = @"public.url";
-static NSString * const WebURLNamePboardType = @"public.url-name";
-
- (void)_registerDraggedTypes
{
- NSArray *editableTypes = [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType,
-#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
- NSPICTPboardType,
-#endif
- NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil];
- NSArray *URLTypes = [NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil];
- NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes];
- [types addObjectsFromArray:URLTypes];
+ NSMutableSet *types = [[NSMutableSet alloc] initWithArray:PasteboardTypes::forEditing()];
+ [types addObjectsFromArray:PasteboardTypes::forURL()];
[self registerForDraggedTypes:[types allObjects]];
[types release];
}
@@ -235,6 +232,8 @@ static NSString * const WebURLNamePboardType = @"public.url-name";
_data->_pageClient = PageClientImpl::create(self);
_data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef));
_data->_page->initializeWebPage();
+ _data->_mouseDownEvent = nil;
+ _data->_ignoringMouseDraggedEvents = NO;
[self _registerDraggedTypes];
@@ -729,6 +728,17 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
return YES;
}
+- (void)_setMouseDownEvent:(NSEvent *)event
+{
+ ASSERT(!event || [event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown);
+
+ if (event == _data->_mouseDownEvent)
+ return;
+
+ [_data->_mouseDownEvent release];
+ _data->_mouseDownEvent = [event retain];
+}
+
#define EVENT_HANDLER(Selector, Type) \
- (void)Selector:(NSEvent *)theEvent \
{ \
@@ -751,21 +761,35 @@ EVENT_HANDLER(scrollWheel, Wheel)
#undef EVENT_HANDLER
-#define MOUSE_EVENT_HANDLER(Selector) \
- - (void)Selector:(NSEvent *)theEvent \
- { \
- NSInputManager *currentInputManager = [NSInputManager currentInputManager]; \
- if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:theEvent]) \
- return; \
- WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(theEvent, self); \
- _data->_page->handleMouseEvent(webEvent); \
- }
+- (void)_mouseHandler:(NSEvent *)event
+{
+ NSInputManager *currentInputManager = [NSInputManager currentInputManager];
+ if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event])
+ return;
+ WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(event, self);
+ _data->_page->handleMouseEvent(webEvent);
+}
-MOUSE_EVENT_HANDLER(mouseDown)
-MOUSE_EVENT_HANDLER(mouseDragged)
-MOUSE_EVENT_HANDLER(mouseUp)
+- (void)mouseDown:(NSEvent *)event
+{
+ [self _setMouseDownEvent:event];
+ _data->_ignoringMouseDraggedEvents = NO;
+ _data->_dragHasStarted = NO;
+ [self _mouseHandler:event];
+}
-#undef MOUSE_EVENT_HANDLER
+- (void)mouseUp:(NSEvent *)event
+{
+ [self _setMouseDownEvent:nil];
+ [self _mouseHandler:event];
+}
+
+- (void)mouseDragged:(NSEvent *)event
+{
+ if (_data->_ignoringMouseDraggedEvents)
+ return;
+ [self _mouseHandler:event];
+}
- (void)doCommandBySelector:(SEL)selector
{
@@ -1039,6 +1063,17 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
return resultRect;
}
+- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
+{
+ NSPoint windowImageLoc = [[self window] convertScreenToBase:aPoint];
+ NSPoint windowMouseLoc = windowImageLoc;
+
+ // Prevent queued mouseDragged events from coming after the drag and fake mouseUp event.
+ _data->_ignoringMouseDraggedEvents = YES;
+
+ _data->_page->dragEnded(IntPoint(windowMouseLoc), globalPoint(windowMouseLoc, [self window]), operation);
+}
+
- (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo
{
uint32_t flags = 0;
@@ -1058,7 +1093,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
-
+
+ _data->_page->resetDragOperation();
_data->_page->performDragControllerAction(DragControllerActionEntered, &dragData, [[draggingInfo draggingPasteboard] name]);
return NSDragOperationCopy;
}
@@ -1234,7 +1270,15 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
if (useNewDrawingArea()) {
if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) {
CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
- drawingArea->paint(context, enclosingIntRect(rect));
+
+ const NSRect *rectsBeingDrawn;
+ NSInteger numRectsBeingDrawn;
+ [self getRectsBeingDrawn:&rectsBeingDrawn count:&numRectsBeingDrawn];
+ for (NSInteger i = 0; i < numRectsBeingDrawn; ++i) {
+ Region unpaintedRegion;
+ IntRect rect = enclosingIntRect(rectsBeingDrawn[i]);
+ drawingArea->paint(context, rect, unpaintedRegion);
+ }
} else if (_data->_page->drawsBackground()) {
[_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set];
NSRectFill(rect);
@@ -1332,6 +1376,44 @@ static WebFrameProxy* frameBeingPrinted()
return [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:PrintedFrameKey] webFrame];
}
+static float currentPrintOperationScale()
+{
+ ASSERT([NSPrintOperation currentOperation]);
+ ASSERT([[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:NSPrintScalingFactor]);
+ return [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:NSPrintScalingFactor] floatValue];
+}
+
+- (void)_adjustPrintingMarginsForHeaderAndFooter
+{
+ NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
+ NSPrintInfo *info = [printOperation printInfo];
+ NSMutableDictionary *infoDictionary = [info dictionary];
+
+ // We need to modify the top and bottom margins in the NSPrintInfo to account for the space needed by the
+ // header and footer. Because this method can be called more than once on the same NSPrintInfo (see 5038087),
+ // we stash away the unmodified top and bottom margins the first time this method is called, and we read from
+ // those stashed-away values on subsequent calls.
+ float originalTopMargin;
+ float originalBottomMargin;
+ NSNumber *originalTopMarginNumber = [infoDictionary objectForKey:WebKitOriginalTopPrintingMarginKey];
+ if (!originalTopMarginNumber) {
+ ASSERT(![infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey]);
+ originalTopMargin = [info topMargin];
+ originalBottomMargin = [info bottomMargin];
+ [infoDictionary setObject:[NSNumber numberWithFloat:originalTopMargin] forKey:WebKitOriginalTopPrintingMarginKey];
+ [infoDictionary setObject:[NSNumber numberWithFloat:originalBottomMargin] forKey:WebKitOriginalBottomPrintingMarginKey];
+ } else {
+ ASSERT([originalTopMarginNumber isKindOfClass:[NSNumber class]]);
+ ASSERT([[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] isKindOfClass:[NSNumber class]]);
+ originalTopMargin = [originalTopMarginNumber floatValue];
+ originalBottomMargin = [[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] floatValue];
+ }
+
+ float scale = currentPrintOperationScale();
+ [info setTopMargin:originalTopMargin + _data->_page->headerHeight(frameBeingPrinted()) * scale];
+ [info setBottomMargin:originalBottomMargin + _data->_page->footerHeight(frameBeingPrinted()) * scale];
+}
+
- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef
{
LOG(View, "Creating an NSPrintOperation for frame '%s'", toImpl(frameRef)->url().utf8().data());
@@ -1364,6 +1446,8 @@ static WebFrameProxy* frameBeingPrinted()
if (frame->isMainFrame() && _data->_pdfViewController)
return [super knowsPageRange:range];
+ [self _adjustPrintingMarginsForHeaderAndFooter];
+
_data->_page->computePagesForPrinting(frame, PrintInfo([[NSPrintOperation currentOperation] printInfo]), _data->_printingPageRects, _data->_totalScaleFactorForPrinting);
*range = NSMakeRange(1, _data->_printingPageRects.size());
@@ -1418,6 +1502,34 @@ static WebFrameProxy* frameBeingPrinted()
CGContextRestoreGState(context);
}
+- (void)drawPageBorderWithSize:(NSSize)borderSize
+{
+ ASSERT(NSEqualSizes(borderSize, [[[NSPrintOperation currentOperation] printInfo] paperSize]));
+
+ // The header and footer rect height scales with the page, but the width is always
+ // all the way across the printed page (inset by printing margins).
+ NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
+ NSPrintInfo *printInfo = [printOperation printInfo];
+ float scale = currentPrintOperationScale();
+ NSSize paperSize = [printInfo paperSize];
+ float headerFooterLeft = [printInfo leftMargin] / scale;
+ float headerFooterWidth = (paperSize.width - ([printInfo leftMargin] + [printInfo rightMargin])) / scale;
+ WebFrameProxy* frame = frameBeingPrinted();
+ NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin] / scale - _data->_page->footerHeight(frame), headerFooterWidth, _data->_page->footerHeight(frame));
+ NSRect headerRect = NSMakeRect(headerFooterLeft, (paperSize.height - [printInfo topMargin]) / scale, headerFooterWidth, _data->_page->headerHeight(frame));
+
+ NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+ [currentContext saveGraphicsState];
+ NSRectClip(headerRect);
+ _data->_page->drawHeader(frame, headerRect);
+ [currentContext restoreGraphicsState];
+
+ [currentContext saveGraphicsState];
+ NSRectClip(footerRect);
+ _data->_page->drawFooter(frame, footerRect);
+ [currentContext restoreGraphicsState];
+}
+
// FIXME 3491344: This is an AppKit-internal method that we need to override in order
// to get our shrink-to-fit to work with a custom pagination scheme. We can do this better
// if AppKit makes it SPI/API.
@@ -1792,4 +1904,22 @@ static WebFrameProxy* frameBeingPrinted()
_data->_pdfViewController->setZoomFactor(zoomFactor);
}
+- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag
+{
+ // We need to prevent re-entering this call to avoid crashing in AppKit.
+ // Given the asynchronous nature of WebKit2 this can now happen.
+ if (_data->_dragHasStarted)
+ return;
+
+ _data->_dragHasStarted = YES;
+ [super dragImage:image
+ at:clientPoint
+ offset:NSZeroSize
+ event:(linkDrag) ? [NSApp currentEvent] :_data->_mouseDownEvent
+ pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
+ source:self
+ slideBack:YES];
+ _data->_dragHasStarted = NO;
+}
+
@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
index 1c70b38..cba241d 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
@@ -62,5 +62,6 @@ namespace WebKit {
- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference;
- (double)_customRepresentationZoomFactor;
- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor;
+- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
@end
diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
index f01c5b2..ec23760 100644
--- a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
@@ -66,24 +66,14 @@ QGraphicsWKView::QGraphicsWKView(QWKContext* context, BackingStoreType backingSt
setFocusPolicy(Qt::StrongFocus);
setAcceptHoverEvents(true);
- PassOwnPtr<DrawingAreaProxy> drawingAreaProxy;
- d->page = new QWKPage(context);
-
- switch (backingStoreType) {
#if ENABLE(TILED_BACKING_STORE)
- case Tiled:
- drawingAreaProxy = TiledDrawingAreaProxy::create(this, toImpl(page()->pageRef()));
+ if (backingStoreType == Tiled)
connect(this, SIGNAL(scaleChanged()), this, SLOT(onScaleChanged()));
- break;
#endif
- case Simple:
- default:
- drawingAreaProxy = ChunkedUpdateDrawingAreaProxy::create(this, toImpl(page()->pageRef()));
- break;
- }
- d->page->d->init(this, drawingAreaProxy);
+ d->page = new QWKPage(context);
+ d->page->d->init(this, backingStoreType);
connect(d->page, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted()));
connect(d->page, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool)));
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
index 638d9e3..72c1322 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -88,6 +88,7 @@ QWKPagePrivate::QWKPagePrivate(QWKPage* qq, QWKContext* c)
, context(c)
, preferences(0)
, createNewPageFn(0)
+ , backingStoreType(QGraphicsWKView::Simple)
{
memset(actions, 0, sizeof(actions));
page = context->d->context->createWebPage(this, 0);
@@ -100,10 +101,10 @@ QWKPagePrivate::~QWKPagePrivate()
delete history;
}
-void QWKPagePrivate::init(QGraphicsItem* view, PassOwnPtr<DrawingAreaProxy> proxy)
+void QWKPagePrivate::init(QGraphicsItem* view, QGraphicsWKView::BackingStoreType backingStoreType)
{
this->view = view;
- page->setDrawingArea(proxy);
+ this->backingStoreType = backingStoreType;
page->initializeWebPage();
}
@@ -131,7 +132,7 @@ PassOwnPtr<DrawingAreaProxy> QWKPagePrivate::createDrawingAreaProxy()
QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view);
#if ENABLE(TILED_BACKING_STORE)
- if (page->drawingArea()->info().type == DrawingAreaInfo::Tiled)
+ if (backingStoreType == QGraphicsWKView::Tiled)
return TiledDrawingAreaProxy::create(wkView, page.get());
#endif
return ChunkedUpdateDrawingAreaProxy::create(wkView, page.get());
@@ -147,6 +148,11 @@ void QWKPagePrivate::displayView()
// FIXME: Implement.
}
+void QWKPagePrivate::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
+{
+ // FIXME: Implement.
+}
+
WebCore::IntSize QWKPagePrivate::viewSize()
{
// FIXME: Implement.
@@ -380,6 +386,13 @@ void QWKPagePrivate::touchEvent(QTouchEvent* event)
#endif
}
+void QWKPagePrivate::didRelaunchProcess()
+{
+ QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view);
+ if (wkView)
+ q->setViewportSize(wkView->size().toSize());
+}
+
QWKPage::QWKPage(QWKContext* context)
: d(new QWKPagePrivate(this, context))
{
@@ -440,7 +453,13 @@ QWKPage::QWKPage(QWKContext* context)
0, /* pageDidScroll */
0, /* exceededDatabaseQuota */
0, /* runOpenPanel */
- 0 /* decidePolicyForGeolocationPermissionRequest */
+ 0, /* decidePolicyForGeolocationPermissionRequest */
+ 0, /* headerHeight */
+ 0, /* footerHeight */
+ 0, /* drawHeader */
+ 0, /* drawFooter */
+ 0, /* printFrame */
+ 0 /* runModal */
};
WKPageSetPageUIClient(pageRef(), &uiClient);
}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
index 85135c2..420ff62 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
@@ -24,6 +24,7 @@
#include "DrawingAreaProxy.h"
#include "PageClient.h"
#include "qwkpage.h"
+#include "qgraphicswkview.h"
#include "WebPageProxy.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
@@ -41,12 +42,13 @@ public:
static QWKPagePrivate* get(QWKPage* page) { return page->d; }
- void init(QGraphicsItem*, WTF::PassOwnPtr<WebKit::DrawingAreaProxy>);
+ void init(QGraphicsItem*, QGraphicsWKView::BackingStoreType);
// PageClient
virtual PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
virtual void setViewNeedsDisplay(const WebCore::IntRect&);
virtual void displayView();
+ virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
virtual WebCore::IntSize viewSize();
virtual bool isViewWindowActive();
@@ -60,7 +62,7 @@ public:
#endif // USE(ACCELERATED_COMPOSITING)
virtual void pageDidRequestScroll(const WebCore::IntSize&);
virtual void processDidCrash() { }
- virtual void didRelaunchProcess() { }
+ virtual void didRelaunchProcess();
virtual void didChangeContentsSize(const WebCore::IntSize&);
virtual void didFindZoomableArea(const WebCore::IntRect&);
virtual void setCursor(const WebCore::Cursor&);
@@ -119,6 +121,7 @@ public:
QPoint tripleClick;
QBasicTimer tripleClickTimer;
+ QGraphicsWKView::BackingStoreType backingStoreType;
};
class QtViewportAttributesPrivate : public QSharedData {