diff options
author | Ben Murdoch <benm@google.com> | 2011-05-16 16:25:10 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-23 18:54:14 +0100 |
commit | ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch) | |
tree | db769fadd053248f85db67434a5b275224defef7 /Source/WebKit2/UIProcess | |
parent | 52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff) | |
download | external_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')
41 files changed, 723 insertions, 215 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 { diff --git a/Source/WebKit2/UIProcess/BackingStore.cpp b/Source/WebKit2/UIProcess/BackingStore.cpp index 06d66af..b468b6b 100644 --- a/Source/WebKit2/UIProcess/BackingStore.cpp +++ b/Source/WebKit2/UIProcess/BackingStore.cpp @@ -25,6 +25,9 @@ #include "BackingStore.h" +#include "ShareableBitmap.h" +#include "UpdateInfo.h" + using namespace WebCore; #if !PLATFORM(MAC) @@ -33,13 +36,15 @@ using namespace WebCore; namespace WebKit { -PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size) +PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, WebPageProxy* webPageProxy) { - return adoptPtr(new BackingStore(size)); + return adoptPtr(new BackingStore(size, webPageProxy)); } -BackingStore::BackingStore(const IntSize& size) +BackingStore::BackingStore(const IntSize& size, WebPageProxy* webPageProxy) : m_size(size) + , m_webPageProxy(webPageProxy) + , m_latestUpdateTimestamp(0) { ASSERT(!m_size.isEmpty()); } @@ -48,4 +53,22 @@ BackingStore::~BackingStore() { } +void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) +{ + if (updateInfo.timestamp < m_latestUpdateTimestamp) { + // The update is too old, discard it. + return; + } + + ASSERT(m_size == updateInfo.viewSize); + + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle); + if (!bitmap) + return; + + incorporateUpdate(bitmap.get(), updateInfo); + + m_latestUpdateTimestamp = updateInfo.timestamp; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/BackingStore.h b/Source/WebKit2/UIProcess/BackingStore.h index e196a55..a3ea065 100644 --- a/Source/WebKit2/UIProcess/BackingStore.h +++ b/Source/WebKit2/UIProcess/BackingStore.h @@ -40,6 +40,7 @@ namespace WebCore { namespace WebKit { +class ShareableBitmap; class UpdateInfo; class WebPageProxy; @@ -47,9 +48,11 @@ class BackingStore { WTF_MAKE_NONCOPYABLE(BackingStore); public: - static PassOwnPtr<BackingStore> create(const WebCore::IntSize&); + static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, WebPageProxy*); ~BackingStore(); + const WebCore::IntSize& size() const { return m_size; } + #if PLATFORM(MAC) typedef CGContextRef PlatformGraphicsContext; #endif @@ -58,13 +61,19 @@ public: void incorporateUpdate(const UpdateInfo&); private: - explicit BackingStore(const WebCore::IntSize&); + BackingStore(const WebCore::IntSize&, WebPageProxy*); - void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + void incorporateUpdate(ShareableBitmap*, const UpdateInfo&); + void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); WebCore::IntSize m_size; + WebPageProxy* m_webPageProxy; + double m_latestUpdateTimestamp; #if PLATFORM(MAC) + CGContextRef backingStoreContext(); + + RetainPtr<CGLayerRef> m_cgLayer; RetainPtr<CGContextRef> m_bitmapContext; #endif }; diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h index a58a0d9..3eb24da 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h @@ -65,6 +65,10 @@ public: virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext) = 0; virtual void sizeDidChange() = 0; + + // FIXME: visibilityDidChange() should be pure virtual. + virtual void visibilityDidChange() { } + virtual void setPageIsVisible(bool isVisible) = 0; #if USE(ACCELERATED_COMPOSITING) @@ -89,7 +93,7 @@ private: // CoreIPC message handlers. // FIXME: These should be pure virtual. virtual void update(const UpdateInfo&) { } - virtual void didSetSize() { } + virtual void didSetSize(const UpdateInfo&) { } }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in index 7e340d4..ec065c7 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in @@ -22,5 +22,5 @@ messages -> DrawingAreaProxy { Update(WebKit::UpdateInfo updateInfo) - DidSetSize() + DidSetSize(WebKit::UpdateInfo updateInfo) } diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp index 02b0dd2..3207094 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp @@ -26,6 +26,7 @@ #include "DrawingAreaProxyImpl.h" #include "DrawingAreaMessages.h" +#include "Region.h" #include "UpdateInfo.h" #include "WebPageProxy.h" #include "WebProcessProxy.h" @@ -45,6 +46,7 @@ PassOwnPtr<DrawingAreaProxyImpl> DrawingAreaProxyImpl::create(WebPageProxy* webP DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy) : DrawingAreaProxy(DrawingAreaInfo::Impl, webPageProxy) + , m_isWaitingForDidSetSize(false) { } @@ -52,12 +54,15 @@ DrawingAreaProxyImpl::~DrawingAreaProxyImpl() { } -void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect) +void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion) { + unpaintedRegion = rect; + if (!m_backingStore) return; m_backingStore->paint(context, rect); + unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size())); } void DrawingAreaProxyImpl::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) @@ -81,9 +86,20 @@ void DrawingAreaProxyImpl::sizeDidChange() sendSetSize(); } -void DrawingAreaProxyImpl::setPageIsVisible(bool pageIsVisible) +void DrawingAreaProxyImpl::visibilityDidChange() +{ + if (!m_webPageProxy->isViewVisible()) { + // Suspend painting. + m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID()); + return; + } + + // Resume painting. + m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID()); +} + +void DrawingAreaProxyImpl::setPageIsVisible(bool) { - // FIXME: Implement. } void DrawingAreaProxyImpl::attachCompositingContext(uint32_t contextID) @@ -104,26 +120,39 @@ void DrawingAreaProxyImpl::update(const UpdateInfo& updateInfo) m_webPageProxy->process()->send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID()); } -void DrawingAreaProxyImpl::didSetSize() +void DrawingAreaProxyImpl::didSetSize(const UpdateInfo& updateInfo) { + ASSERT(m_isWaitingForDidSetSize); + m_isWaitingForDidSetSize = false; + + if (m_size != updateInfo.viewSize) + sendSetSize(); + + m_backingStore = nullptr; + + incorporateUpdate(updateInfo); } void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo) { - // FIXME: Check for the update bounds being empty here. + if (updateInfo.updateRectBounds.isEmpty()) + return; if (!m_backingStore) - m_backingStore = BackingStore::create(updateInfo.viewSize); + m_backingStore = BackingStore::create(updateInfo.viewSize, m_webPageProxy); m_backingStore->incorporateUpdate(updateInfo); + bool shouldScroll = !updateInfo.scrollRect.isEmpty(); + + if (shouldScroll) + m_webPageProxy->scrollView(updateInfo.scrollRect, updateInfo.scrollOffset); + for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) m_webPageProxy->setViewNeedsDisplay(updateInfo.updateRects[i]); - if (!updateInfo.scrollRect.isEmpty()) { - m_webPageProxy->setViewNeedsDisplay(updateInfo.scrollRect); + if (shouldScroll) m_webPageProxy->displayView(); - } } void DrawingAreaProxyImpl::sendSetSize() @@ -131,6 +160,10 @@ void DrawingAreaProxyImpl::sendSetSize() if (!m_webPageProxy->isValid()) return; + if (m_isWaitingForDidSetSize) + return; + + m_isWaitingForDidSetSize = true; m_webPageProxy->process()->send(Messages::DrawingArea::SetSize(m_size), m_webPageProxy->pageID()); } diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h index 0de7ada..bf7b878 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h @@ -31,12 +31,14 @@ namespace WebKit { +class Region; + class DrawingAreaProxyImpl : public DrawingAreaProxy { public: static PassOwnPtr<DrawingAreaProxyImpl> create(WebPageProxy*); virtual ~DrawingAreaProxyImpl(); - void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&); + void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, Region& unpaintedRegion); private: explicit DrawingAreaProxyImpl(WebPageProxy*); @@ -46,17 +48,22 @@ private: virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext); virtual void sizeDidChange(); + virtual void visibilityDidChange(); virtual void setPageIsVisible(bool); virtual void attachCompositingContext(uint32_t contextID); virtual void detachCompositingContext(); // CoreIPC message handlers virtual void update(const UpdateInfo&); - virtual void didSetSize(); + virtual void didSetSize(const UpdateInfo&); void incorporateUpdate(const UpdateInfo&); void sendSetSize(); + // Whether we've sent a SetSize message and are now waiting for a DidSetSize message. + // Used to throttle SetSize messages so we don't send them faster than the Web process can handle. + bool m_isWaitingForDidSetSize; + OwnPtr<BackingStore> m_backingStore; }; diff --git a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm index c285bae..a725d6b 100644 --- a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm +++ b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm @@ -49,32 +49,6 @@ extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, u namespace WebKit { -#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) -static const char* processName() -{ - return [[[NSProcessInfo processInfo] processName] fileSystemRepresentation]; -} -#else -// -[NSProcessInfo processName] isn't thread-safe on Leopard and Snow Leopard so we have our own implementation. -static const char* createProcessName() -{ - uint32_t bufferSize = MAXPATHLEN; - char executablePath[bufferSize]; - - if (_NSGetExecutablePath(executablePath, &bufferSize)) - return ""; - - const char *processName = strrchr(executablePath, '/') + 1; - return strdup(processName); -} - -static const char* processName() -{ - static const char* processName = createProcessName(); - return processName; -} -#endif - static void setUpTerminationNotificationHandler(pid_t pid) { #if HAVE(DISPATCH_H) @@ -226,7 +200,7 @@ void ProcessLauncher::launchProcess() CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8(); const char* path = [webProcessAppExecutablePath fileSystemRepresentation]; - const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), "-parentprocessname", processName(), 0 }; + const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), 0 }; // Register ourselves. kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0); diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h index 5767b3c..e483aef 100644 --- a/Source/WebKit2/UIProcess/PageClient.h +++ b/Source/WebKit2/UIProcess/PageClient.h @@ -26,6 +26,7 @@ #ifndef PageClient_h #define PageClient_h +#include "ShareableBitmap.h" #include "WebPageProxy.h" #include "WebPopupMenuProxy.h" #include <wtf/Forward.h> @@ -58,6 +59,9 @@ public: // Tell the view to immediately display its invalid rect. virtual void displayView() = 0; + // Tell the view to scroll scrollRect by scrollOffset. + virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0; + // Return the size of the view the page is associated with. virtual WebCore::IntSize viewSize() = 0; @@ -95,7 +99,8 @@ public: virtual void setEditCommandState(const String& commandName, bool isEnabled, int state) = 0; #if PLATFORM(MAC) virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&) = 0; - virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&, uint32_t, uint32_t, Vector<WebCore::CompositionUnderline>&) = 0; + virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) = 0; + virtual void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0; #endif #if PLATFORM(WIN) virtual void compositionSelectionChanged(bool) = 0; @@ -121,6 +126,8 @@ public: #if PLATFORM(MAC) virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) = 0; + + virtual CGContextRef containingWindowGraphicsContext() = 0; #endif // Custom representations. diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h index c265f2e..a150d67 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h @@ -41,7 +41,8 @@ namespace WebKit { class PluginProcessProxy; class WebProcessProxy; -class PluginProcessManager : Noncopyable { +class PluginProcessManager { + WTF_MAKE_NONCOPYABLE(PluginProcessManager); public: static PluginProcessManager& shared(); diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm index 81c8620..eaf8aef 100644 --- a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm +++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm @@ -35,6 +35,7 @@ namespace WebKit { void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters) { #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION) + parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; mach_port_t renderServerPort = WKInitializeRenderServer(); if (renderServerPort != MACH_PORT_NULL) parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND); diff --git a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp index 485f892..1e0c251 100644 --- a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp +++ b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp @@ -253,7 +253,8 @@ Vector<String> PluginInfoStore::pluginsDirectories() return directories; } -class PathWalker : public Noncopyable { +class PathWalker { + WTF_MAKE_NONCOPYABLE(PathWalker); public: PathWalker(const String& directory) { diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.h b/Source/WebKit2/UIProcess/VisitedLinkProvider.h index 015515c..a428d5b 100644 --- a/Source/WebKit2/UIProcess/VisitedLinkProvider.h +++ b/Source/WebKit2/UIProcess/VisitedLinkProvider.h @@ -31,13 +31,13 @@ #include <WebCore/LinkHash.h> #include <wtf/Forward.h> #include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> namespace WebKit { class WebContext; -class VisitedLinkProvider : Noncopyable { +class VisitedLinkProvider { + WTF_MAKE_NONCOPYABLE(VisitedLinkProvider); public: explicit VisitedLinkProvider(WebContext*); diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp index 2c75cf2..1bb6bc4 100644 --- a/Source/WebKit2/UIProcess/WebContext.cpp +++ b/Source/WebKit2/UIProcess/WebContext.cpp @@ -114,6 +114,9 @@ WebContext::~WebContext() m_geolocationManagerProxy->invalidate(); m_geolocationManagerProxy->clearContext(); + m_databaseManagerProxy->invalidate(); + m_databaseManagerProxy->clearContext(); + #ifndef NDEBUG webContextCounter.decrement(); #endif diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h index 9996198..e973160 100644 --- a/Source/WebKit2/UIProcess/WebContext.h +++ b/Source/WebKit2/UIProcess/WebContext.h @@ -67,6 +67,7 @@ public: ProcessModel processModel() const { return m_processModel; } WebProcessProxy* process() const { return m_process.get(); } + bool hasValidProcess() const { return m_process && m_process->isValid(); } void processDidFinishLaunching(WebProcessProxy*); void processDidClose(WebProcessProxy*); @@ -142,7 +143,6 @@ private: virtual Type type() const { return APIType; } void ensureWebProcess(); - bool hasValidProcess() const { return m_process && m_process->isValid(); } void platformInitializeWebProcess(WebProcessCreationParameters&); // History client diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp index 6f382b7..1bc0303 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp @@ -100,8 +100,6 @@ WebDatabaseManagerProxy::~WebDatabaseManagerProxy() void WebDatabaseManagerProxy::invalidate() { invalidateCallbackMap(m_arrayCallbacks); - - m_webContext = 0; } void WebDatabaseManagerProxy::initializeClient(const WKDatabaseManagerClient* client) @@ -112,6 +110,10 @@ void WebDatabaseManagerProxy::initializeClient(const WKDatabaseManagerClient* cl void WebDatabaseManagerProxy::getDatabasesByOrigin(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; + if (!m_webContext->hasValidProcess()) { + callback->invalidate(); + return; + } uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabasesByOrigin(callbackID), 0); @@ -164,6 +166,10 @@ void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndData void WebDatabaseManagerProxy::getDatabaseOrigins(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; + if (!m_webContext->hasValidProcess()) { + callback->invalidate(); + return; + } uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabaseOrigins(callbackID), 0); @@ -188,21 +194,29 @@ void WebDatabaseManagerProxy::didGetDatabaseOrigins(const Vector<String>& origin void WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, WebSecurityOrigin* origin) { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabaseWithNameForOrigin(databaseIdentifier, origin->databaseIdentifier()), 0); } void WebDatabaseManagerProxy::deleteDatabasesForOrigin(WebSecurityOrigin* origin) { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabasesForOrigin(origin->databaseIdentifier()), 0); } void WebDatabaseManagerProxy::deleteAllDatabases() { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::DeleteAllDatabases(), 0); } void WebDatabaseManagerProxy::setQuotaForOrigin(WebSecurityOrigin* origin, uint64_t quota) { + if (!m_webContext->hasValidProcess()) + return; m_webContext->process()->send(Messages::WebDatabaseManager::SetQuotaForOrigin(origin->databaseIdentifier(), quota), 0); } diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h index 9878232..3658845 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h @@ -55,6 +55,7 @@ public: virtual ~WebDatabaseManagerProxy(); void invalidate(); + void clearContext() { m_webContext = 0; } void initializeClient(const WKDatabaseManagerClient*); diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.cpp b/Source/WebKit2/UIProcess/WebFrameProxy.cpp index d3a36f9..779cf61 100644 --- a/Source/WebKit2/UIProcess/WebFrameProxy.cpp +++ b/Source/WebKit2/UIProcess/WebFrameProxy.cpp @@ -29,6 +29,7 @@ #include "WebContext.h" #include "WebFormSubmissionListenerProxy.h" #include "WebFramePolicyListenerProxy.h" +#include "WebPageMessages.h" #include "WebPageProxy.h" #include <WebCore/DOMImplementation.h> #include <WebCore/Image.h> @@ -81,6 +82,17 @@ bool WebFrameProxy::isMainFrame() const return this == m_page->mainFrame(); } +void WebFrameProxy::stopLoading() const +{ + if (!m_page) + return; + + if (!m_page->isValid()) + return; + + m_page->process()->send(Messages::WebPage::StopLoadingFrame(m_frameID), m_page->pageID()); +} + bool WebFrameProxy::canProvideSource() const { return isDisplayingMarkupDocument(); @@ -117,7 +129,6 @@ bool WebFrameProxy::isDisplayingMarkupDocument() const void WebFrameProxy::didStartProvisionalLoad(const String& url) { - ASSERT(!url.isEmpty()); ASSERT(m_loadState == LoadStateFinished); ASSERT(m_provisionalURL.isEmpty()); m_loadState = LoadStateProvisional; @@ -143,7 +154,6 @@ void WebFrameProxy::didFailProvisionalLoad() void WebFrameProxy::didCommitLoad(const String& contentType, const PlatformCertificateInfo& certificateInfo) { ASSERT(m_loadState == LoadStateProvisional); - ASSERT(!m_provisionalURL.isEmpty()); m_loadState = LoadStateCommitted; m_url = m_provisionalURL; m_provisionalURL = String(); @@ -157,7 +167,6 @@ void WebFrameProxy::didFinishLoad() { ASSERT(m_loadState == LoadStateCommitted); ASSERT(m_provisionalURL.isEmpty()); - ASSERT(!m_url.isEmpty()); m_loadState = LoadStateFinished; } @@ -305,4 +314,14 @@ void WebFrameProxy::getMainResourceData(PassRefPtr<DataCallback> callback) m_page->getMainResourceDataOfFrame(this, callback); } +void WebFrameProxy::getResourceData(WebURL* resourceURL, PassRefPtr<DataCallback> callback) +{ + if (!m_page) { + callback->invalidate(); + return; + } + + m_page->getResourceDataFromFrame(this, resourceURL, callback); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.h b/Source/WebKit2/UIProcess/WebFrameProxy.h index 84c1eb8..6cc2130 100644 --- a/Source/WebKit2/UIProcess/WebFrameProxy.h +++ b/Source/WebKit2/UIProcess/WebFrameProxy.h @@ -86,6 +86,8 @@ public: bool isFrameSet() const { return m_isFrameSet; } LoadState loadState() const { return m_loadState; } + + void stopLoading() const; const String& url() const { return m_url; } const String& provisionalURL() const { return m_provisionalURL; } @@ -107,6 +109,7 @@ public: void getWebArchive(PassRefPtr<DataCallback>); void getMainResourceData(PassRefPtr<DataCallback>); + void getResourceData(WebURL*, PassRefPtr<DataCallback>); void didStartProvisionalLoad(const String& url); void didReceiveServerRedirectForProvisionalLoad(const String& url); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index f433fbd..0be2f11 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -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 @@ -227,7 +227,9 @@ void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item) m_backForwardList->goToItem(item); reattachToWebProcess(); - process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID); + + if (item) + process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID); } void WebPageProxy::initializeWebPage() @@ -475,6 +477,11 @@ void WebPageProxy::displayView() m_pageClient->displayView(); } +void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset) +{ + m_pageClient->scrollView(scrollRect, scrollOffset); +} + void WebPageProxy::viewStateDidChange(ViewStateFlags flags) { if (!isValid()) @@ -490,6 +497,7 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags) bool isVisible = m_pageClient->isViewVisible(); if (isVisible != m_isVisible) { m_isVisible = isVisible; + m_drawingArea->visibilityDidChange(); m_drawingArea->setPageIsVisible(isVisible); } } @@ -609,6 +617,24 @@ void WebPageProxy::didPerformDragControllerAction(uint64_t resultOperation) m_currentDragOperation = static_cast<DragOperation>(resultOperation); } +#if PLATFORM(MAC) +void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag) +{ + RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(imageSize, dragImageHandle); + if (!dragImage) + return; + + m_pageClient->setDragImage(clientPosition, imageSize, dragImage.release(), isLinkDrag); +} +#endif + +void WebPageProxy::dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation) +{ + if (!isValid()) + return; + process()->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID); +} + void WebPageProxy::handleMouseEvent(const WebMouseEvent& event) { if (!isValid()) @@ -960,6 +986,14 @@ void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<D process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID); } +void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback) +{ + RefPtr<DataCallback> callback = prpCallback; + uint64_t callbackID = callback->callbackID(); + m_dataCallbacks.set(callbackID, callback.get()); + process()->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID); +} + void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback) { RefPtr<DataCallback> callback = prpCallback; @@ -1067,6 +1101,11 @@ void WebPageProxy::didCreateSubframe(uint64_t frameID, uint64_t parentFrameID) parentFrame->appendChild(subFrame.get()); } +static bool isDisconnectedFrame(WebFrameProxy* frame) +{ + return !frame->page() || !frame->page()->mainFrame() || !frame->isDescendantOf(frame->page()->mainFrame()); +} + void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID) { MESSAGE_CHECK(m_mainFrame); @@ -1074,7 +1113,7 @@ void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID) WebFrameProxy* subframe = process()->webFrame(frameID); MESSAGE_CHECK(subframe); - if (!subframe->parentFrame()) + if (isDisconnectedFrame(subframe)) return; MESSAGE_CHECK(subframe->isDescendantOf(m_mainFrame.get())); @@ -1633,6 +1672,14 @@ void WebPageProxy::runOpenPanel(uint64_t frameID, const WebOpenPanelParameters:: didCancelForOpenPanel(); } +void WebPageProxy::printFrame(uint64_t frameID) +{ + WebFrameProxy* frame = process()->webFrame(frameID); + MESSAGE_CHECK(frame); + + m_uiClient.printFrame(this, frame); +} + #if PLATFORM(QT) void WebPageProxy::didChangeContentsSize(const WebCore::IntSize& size) { @@ -2231,7 +2278,6 @@ WebPageCreationParameters WebPageProxy::creationParameters() const parameters.isFocused = m_pageClient->isViewFocused(); parameters.isVisible = m_pageClient->isViewVisible(); parameters.isInWindow = m_pageClient->isViewInWindow(); - parameters.drawingAreaInfo = m_drawingArea->info(); parameters.store = m_pageGroup->preferences()->store(); parameters.pageGroupData = m_pageGroup->data(); @@ -2242,6 +2288,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const parameters.userAgent = userAgent(); parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex()); parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID(); + parameters.canRunModal = m_uiClient.canRunModal(); #if PLATFORM(MAC) parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled; @@ -2315,6 +2362,26 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, request->deny(); } +float WebPageProxy::headerHeight(WebFrameProxy* frame) +{ + return m_uiClient.headerHeight(this, frame); +} + +float WebPageProxy::footerHeight(WebFrameProxy* frame) +{ + return m_uiClient.footerHeight(this, frame); +} + +void WebPageProxy::drawHeader(WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + m_uiClient.drawHeader(this, frame, rect); +} + +void WebPageProxy::drawFooter(WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + m_uiClient.drawFooter(this, frame, rect); +} + void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference) { m_pageClient->didFinishLoadingDataForCustomRepresentation(dataReference); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index 4a9e478..dc43e19 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.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 @@ -173,6 +173,7 @@ public: void setViewNeedsDisplay(const WebCore::IntRect&); void displayView(); + void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); enum { ViewWindowIsActive = 1 << 0, @@ -184,6 +185,7 @@ public: void viewStateDidChange(ViewStateFlags flags); WebCore::IntSize viewSize() const; + bool isViewVisible() const { return m_isVisible; } void executeEditCommand(const String& commandName); void validateMenuItem(const String& commandName); @@ -197,6 +199,7 @@ public: uint64_t characterIndexForPoint(const WebCore::IntPoint); WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t); void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput); + CGContextRef containingWindowGraphicsContext(); #endif #if PLATFORM(WIN) void didChangeCompositionSelection(bool); @@ -264,12 +267,18 @@ public: void getContentsAsString(PassRefPtr<StringCallback>); void getMainResourceDataOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>); + void getResourceDataFromFrame(WebFrameProxy*, WebURL*, PassRefPtr<DataCallback>); void getRenderTreeExternalRepresentation(PassRefPtr<StringCallback>); void getSelectionOrContentsAsString(PassRefPtr<StringCallback>); void getSourceForFrame(WebFrameProxy*, PassRefPtr<StringCallback>); void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>); void runJavaScriptInMainFrame(const String&, PassRefPtr<StringCallback>); + float headerHeight(WebFrameProxy*); + float footerHeight(WebFrameProxy*); + void drawHeader(WebFrameProxy*, const WebCore::FloatRect&); + void drawFooter(WebFrameProxy*, const WebCore::FloatRect&); + void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID); void backForwardRemovedItem(uint64_t itemID); @@ -277,7 +286,10 @@ public: // Drag and drop support. void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String&); void didPerformDragControllerAction(uint64_t resultOperation); - + void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation); +#if PLATFORM(MAC) + void setDragImage(const WebCore::IntPoint& clientPosition, const WebCore::IntSize& imageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag); +#endif void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); @@ -426,8 +438,10 @@ private: void didChangeViewportData(const WebCore::ViewportArguments&); void pageDidScroll(); void runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data&); + void printFrame(uint64_t frameID); void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage, uint64_t& newQuota); void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier); + void runModal() { m_uiClient.runModal(this); } void reattachToWebProcess(); void reattachToWebProcessWithItem(WebBackForwardListItem*); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index 2d576be..6456851 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -1,4 +1,4 @@ -# 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 @@ -21,7 +21,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. messages -> WebPageProxy { - # UI messages. + # UI messages CreateNewPage(WebCore::WindowFeatures windowFeatures, uint32_t modifiers, int32_t mouseButton) -> (uint64_t newPageID, WebKit::WebPageCreationParameters newPageParameters) ShowPage() ClosePage() @@ -53,6 +53,8 @@ messages -> WebPageProxy { RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose) PageDidScroll() RunOpenPanel(uint64_t frameID, WebKit::WebOpenPanelParameters::Data parameters) + PrintFrame(uint64_t frameID) -> () + RunModal() #if ENABLE(TILED_BACKING_STORE) PageDidRequestScroll(WebCore::IntSize delta) @@ -62,23 +64,23 @@ messages -> WebPageProxy { DidFindZoomableArea(WebCore::IntRect area) #endif - # Policy messages. + # Policy messages DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WTF::String url, uint64_t listenerID) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID) DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID) - # Progress messages. + # Progress messages DidChangeProgress(double value) DidFinishProgress() DidStartProgress() - # Frame lifetime messages. + # Frame lifetime messages DidCreateMainFrame(uint64_t frameID) DidCreateSubframe(uint64_t frameID, uint64_t parentFrameID) DidSaveFrameToPageCache(uint64_t frameID); DidRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID); - # Frame load messages. + # Frame load messages DidCommitLoadForFrame(uint64_t frameID, WTF::String mimeType, bool hasCustomRepresentation, WebKit::PlatformCertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) DidFailLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) DidFailProvisionalLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) @@ -96,7 +98,7 @@ messages -> WebPageProxy { FrameDidBecomeFrameSet(uint64_t frameID, bool value) - # Resource load messages. + # Resource load messages DidInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceRequest request) DidSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse) DidReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceResponse response) @@ -107,21 +109,21 @@ messages -> WebPageProxy { # Custom representations DidFinishLoadingDataForCustomRepresentation(CoreIPC::DataReference data) - # Forms messages. + # Forms messages WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) - # Callback messages. + # Callback messages DataCallback(CoreIPC::DataReference resultData, uint64_t callbackID) StringCallback(WTF::String resultString, uint64_t callbackID) DidReceiveAccessibilityPageToken(CoreIPC::DataReference data) #if PLATFORM(MAC) - # Keyboard support messages. + # Keyboard support messages InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline> underlines) #endif - # BackForward messages. + # BackForward messages BackForwardAddItem(uint64_t itemID) BackForwardGoToItem(uint64_t itemID) BackForwardItemAtIndex(int32_t itemIndex) -> (uint64_t itemID) @@ -129,64 +131,67 @@ messages -> WebPageProxy { BackForwardForwardListCount() -> (int32_t count) BackForwardClear() - # Undo/Redo messages. + # Undo/Redo messages RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction) ClearAllEditCommands() - # Selection messages. + # Selection messages SelectionStateChanged(WebKit::SelectionState selectionState) #if PLATFORM(WIN) DidChangeCompositionSelection(bool hasChanged) #endif - # Find messages. + # Find messages DidCountStringMatches(WTF::String string, uint32_t matchCount) SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut) DidFindString(WTF::String string, uint32_t matchCount) DidFailToFindString(WTF::String string) - # PopupMenu messages. + # PopupMenu messages ShowPopupMenu(WebCore::IntRect rect, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data) HidePopupMenu() - # ContextMenu messages. + # ContextMenu messages ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::ContextMenuState state, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData) #if USE(ACCELERATED_COMPOSITING) - # Accelerated compositing messages. + # Accelerated compositing messages DidChangeAcceleratedCompositing(bool compositing) -> (WebKit::DrawingAreaInfo newDrawingArea) #endif - # Authentication messages. + # Authentication messages CanAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, WebCore::ProtectionSpace protectionSpace) -> (bool canAuthenticate) DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID) - # Database messages. + # Database messages ExceededDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, WTF::String databaseName, WTF::String databaseDisplayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage) -> (uint64_t newQuota) - # Geolocation messages. + # Geolocation messages RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier) - # Plug-in complex text input support messages. #if PLATFORM(MAC) + # Plug-in complex text input support messages SetComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) #endif - # Speech messages. #if PLATFORM(MAC) + # Speech messages GetIsSpeaking() -> (bool isSpeaking) Speak(WTF::String string) StopSpeaking() #endif - # Spelling and grammar. + # Spelling and grammar messages CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results) UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord) GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses) LearnWord(WTF::String word); IgnoreWord(WTF::String word); - # Drag and drop. + # Drag and drop messages DidPerformDragControllerAction(uint64_t resultOperation) +#if PLATFORM(MAC) + SetDragImage(WebCore::IntPoint clientPosition, WebCore::IntSize imageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag) +#endif } diff --git a/Source/WebKit2/UIProcess/WebUIClient.cpp b/Source/WebKit2/UIProcess/WebUIClient.cpp index e95af34..9f2c7ab 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.cpp +++ b/Source/WebKit2/UIProcess/WebUIClient.cpp @@ -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 @@ -273,4 +273,57 @@ bool WebUIClient::decidePolicyForGeolocationPermissionRequest(WebPageProxy* page return true; } +float WebUIClient::headerHeight(WebPageProxy* page, WebFrameProxy* frame) +{ + if (!m_client.headerHeight) + return 0; + + return m_client.headerHeight(toAPI(page), toAPI(frame), m_client.clientInfo); +} + +float WebUIClient::footerHeight(WebPageProxy* page, WebFrameProxy* frame) +{ + if (!m_client.footerHeight) + return 0; + + return m_client.footerHeight(toAPI(page), toAPI(frame), m_client.clientInfo); +} + +void WebUIClient::drawHeader(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + if (!m_client.drawHeader) + return; + + m_client.drawHeader(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo); +} + +void WebUIClient::drawFooter(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect) +{ + if (!m_client.drawFooter) + return; + + m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo); +} + +void WebUIClient::printFrame(WebPageProxy* page, WebFrameProxy* frame) +{ + if (!m_client.printFrame) + return; + + m_client.printFrame(toAPI(page), toAPI(frame), m_client.clientInfo); +} + +bool WebUIClient::canRunModal() const +{ + return m_client.runModal; +} + +void WebUIClient::runModal(WebPageProxy* page) +{ + if (!m_client.runModal) + return; + + m_client.runModal(toAPI(page), m_client.clientInfo); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebUIClient.h b/Source/WebKit2/UIProcess/WebUIClient.h index a25b37f..b873a8d 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.h +++ b/Source/WebKit2/UIProcess/WebUIClient.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 @@ -86,6 +86,16 @@ public: bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebOpenPanelParameters::Data&, WebOpenPanelResultListenerProxy*); bool decidePolicyForGeolocationPermissionRequest(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, GeolocationPermissionRequestProxy*); + + // Printing. + float headerHeight(WebPageProxy*, WebFrameProxy*); + float footerHeight(WebPageProxy*, WebFrameProxy*); + void drawHeader(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&); + void drawFooter(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&); + void printFrame(WebPageProxy*, WebFrameProxy*); + + bool canRunModal() const; + void runModal(WebPageProxy*); }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm index 979f755..eacfefa 100644 --- a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm +++ b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm @@ -28,6 +28,7 @@ #include "CGUtilities.h" #include "ShareableBitmap.h" #include "UpdateInfo.h" +#include "WebPageProxy.h" #include <WebCore/GraphicsContext.h> using namespace WebCore; @@ -36,34 +37,70 @@ namespace WebKit { void BackingStore::paint(PlatformGraphicsContext context, const IntRect& rect) { - ASSERT(m_bitmapContext); + if (m_cgLayer) { + CGContextSaveGState(context); + CGContextClipToRect(context, rect); + + CGContextScaleCTM(context, 1, -1); + CGContextDrawLayerAtPoint(context, CGPointMake(0, -m_size.height()), m_cgLayer.get()); + + CGContextRestoreGState(context); + return; + } + ASSERT(m_bitmapContext); paintBitmapContext(context, m_bitmapContext.get(), rect.location(), rect); } -void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) +CGContextRef BackingStore::backingStoreContext() { - ASSERT(m_size == updateInfo.viewSize); + if (m_cgLayer) + return CGLayerGetContext(m_cgLayer.get()); - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle); - if (!bitmap) - return; + // Try to create a layer. + if (CGContextRef containingWindowContext = m_webPageProxy->containingWindowGraphicsContext()) { + m_cgLayer.adoptCF(CGLayerCreateWithContext(containingWindowContext, NSSizeToCGSize(m_size), 0)); + CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get()); + + CGContextSetBlendMode(layerContext, kCGBlendModeCopy); + + // We want the origin to be in the top left corner so flip the backing store context. + CGContextTranslateCTM(layerContext, 0, m_size.height()); + CGContextScaleCTM(layerContext, 1, -1); + + if (m_bitmapContext) { + // Paint the contents of the bitmap into the layer context. + paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height())); + m_bitmapContext = nullptr; + } + + return layerContext; + } if (!m_bitmapContext) { RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); m_bitmapContext.adoptCF(CGBitmapContextCreate(0, m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); - + + CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy); + // We want the origin to be in the top left corner so flip the backing store context. CGContextTranslateCTM(m_bitmapContext.get(), 0, m_size.height()); CGContextScaleCTM(m_bitmapContext.get(), 1, -1); } - scroll(updateInfo.scrollRect, updateInfo.scrollDelta); + return m_bitmapContext.get(); +} + +void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo) +{ + CGContextRef context = backingStoreContext(); + + scroll(updateInfo.scrollRect, updateInfo.scrollOffset); IntPoint updateRectLocation = updateInfo.updateRectBounds.location(); - GraphicsContext graphicsContext(m_bitmapContext.get()); + GraphicsContext graphicsContext(context); // Paint all update rects. for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) { @@ -75,18 +112,30 @@ void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo) } } -void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { - if (scrollDelta.isZero()) + if (scrollOffset.isZero()) return; - CGContextSaveGState(m_bitmapContext.get()); + if (m_cgLayer) { + CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get()); - CGContextClipToRect(m_bitmapContext.get(), scrollRect); + // Scroll the layer by painting it into itself with the given offset. + CGContextSaveGState(layerContext); + CGContextClipToRect(layerContext, scrollRect); + CGContextScaleCTM(layerContext, 1, -1); + CGContextDrawLayerAtPoint(layerContext, CGPointMake(scrollOffset.width(), -m_size.height() - scrollOffset.height()), m_cgLayer.get()); + CGContextRestoreGState(layerContext); - CGPoint destination = CGPointMake(scrollRect.x() + scrollDelta.width(), scrollRect.y() + scrollDelta.height()); - paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect); + return; + } + + ASSERT(m_bitmapContext); + CGContextSaveGState(m_bitmapContext.get()); + CGContextClipToRect(m_bitmapContext.get(), scrollRect); + CGPoint destination = CGPointMake(scrollRect.x() + scrollOffset.width(), scrollRect.y() + scrollOffset.height()); + paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect); CGContextRestoreGState(m_bitmapContext.get()); } diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm index ce4c3e6..4d1679f 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm @@ -74,7 +74,8 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para cachePath = reinterpret_cast<CFStringRef>(NSHomeDirectory()); NSURLCache *urlCache = [NSURLCache sharedURLCache]; - + + parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; parameters.nsURLCachePath = fileSystemRepresentation([(NSString *)cachePath.get() stringByStandardizingPath]); parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity]; parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity]; diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm index 36905fb..cd3e6f1 100644 --- a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm @@ -25,6 +25,7 @@ #include "WebPageProxy.h" +#include "PageClient.h" #include <WebCore/Language.h> #include <wtf/text/StringConcatenate.h> @@ -110,4 +111,9 @@ void WebPageProxy::stopSpeaking() [NSApp stopSpeaking:nil]; } +CGContextRef WebPageProxy::containingWindowGraphicsContext() +{ + return m_pageClient->containingWindowGraphicsContext(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp index 64b9fb5..40e3556 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp @@ -432,28 +432,28 @@ void WebPopupMenuProxyWin::invalidateItem(int index) ::InvalidateRect(m_popup, &r, TRUE); } -// ScrollbarClient - int WebPopupMenuProxyWin::scrollSize(ScrollbarOrientation orientation) const { return ((orientation == VerticalScrollbar) && m_scrollbar) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0; } -void WebPopupMenuProxyWin::setScrollOffsetFromAnimation(const IntPoint& offset) +int WebPopupMenuProxyWin::scrollPosition(Scrollbar*) const { - if (m_scrollbar) - m_scrollbar->setValue(offset.y(), Scrollbar::FromScrollAnimator); + return m_scrollOffset; } -void WebPopupMenuProxyWin::valueChanged(Scrollbar* scrollBar) +void WebPopupMenuProxyWin::setScrollOffset(const IntPoint& offset) +{ + scrollTo(offset.y()); +} + +void WebPopupMenuProxyWin::scrollTo(int offset) { ASSERT(m_scrollbar); if (!m_popup) return; - int offset = scrollBar->value(); - if (m_scrollOffset == offset) return; @@ -720,7 +720,8 @@ LRESULT WebPopupMenuProxyWin::onMouseWheel(HWND hWnd, UINT message, WPARAM wPara else --i; } - scrollbar()->scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i)); + + ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i)); return 0; } @@ -922,12 +923,12 @@ bool WebPopupMenuProxyWin::scrollToRevealSelection() int index = focusedIndex(); if (index < m_scrollOffset) { - m_scrollbar->setValue(index, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(index); return true; } if (index >= m_scrollOffset + visibleItems()) { - m_scrollbar->setValue(index - visibleItems() + 1, Scrollbar::NotFromScrollAnimator); + ScrollableArea::scrollToYOffsetWithoutAnimation(index - visibleItems() + 1); return true; } diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h index 7a53c2c..d1dc466 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h @@ -30,7 +30,7 @@ #include "WebPopupItem.h" #include "WebPopupMenuProxy.h" #include <WebCore/Scrollbar.h> -#include <WebCore/ScrollbarClient.h> +#include <WebCore/ScrollableArea.h> typedef struct HWND__* HWND; typedef struct HDC__* HDC; @@ -40,7 +40,7 @@ namespace WebKit { class WebView; -class WebPopupMenuProxyWin : public WebPopupMenuProxy, private WebCore::ScrollbarClient { +class WebPopupMenuProxyWin : public WebPopupMenuProxy, private WebCore::ScrollableArea { public: static PassRefPtr<WebPopupMenuProxyWin> create(WebView* webView, WebPopupMenuProxy::Client* client) { @@ -58,13 +58,17 @@ private: WebCore::Scrollbar* scrollbar() const { return m_scrollbar.get(); } - // ScrollBarClient - virtual int scrollSize(WebCore::ScrollbarOrientation orientation) const; - virtual void setScrollOffsetFromAnimation(const WebCore::IntPoint&); - virtual void valueChanged(WebCore::Scrollbar*); + // ScrollableArea + virtual int scrollSize(WebCore::ScrollbarOrientation) const; + virtual int scrollPosition(WebCore::Scrollbar*) const; + virtual void setScrollOffset(const WebCore::IntPoint&); virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&); virtual bool isActive() const { return true; } virtual bool scrollbarCornerPresent() const { return false; } + virtual WebCore::Scrollbar* verticalScrollbar() const { return m_scrollbar.get(); } + + // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. + void scrollTo(int offset); static bool registerWindowClass(); static LRESULT CALLBACK WebPopupMenuProxyWndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/Source/WebKit2/UIProcess/win/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp index 4b3992c..4516f54 100644 --- a/Source/WebKit2/UIProcess/win/WebView.cpp +++ b/Source/WebKit2/UIProcess/win/WebView.cpp @@ -591,6 +591,12 @@ void WebView::displayView() ::UpdateWindow(m_window); } +void WebView::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset) +{ + // FIXME: Actually scroll the view contents. + setViewNeedsDisplay(scrollRect); +} + WebCore::IntSize WebView::viewSize() { RECT clientRect; diff --git a/Source/WebKit2/UIProcess/win/WebView.h b/Source/WebKit2/UIProcess/win/WebView.h index c80334e..dfb5ed1 100644 --- a/Source/WebKit2/UIProcess/win/WebView.h +++ b/Source/WebKit2/UIProcess/win/WebView.h @@ -107,6 +107,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(); |