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 | |
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')
104 files changed, 2665 insertions, 422 deletions
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index f382e2e..e83c4ed 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,1045 @@ +2011-01-21 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Need API to stop loading a WKFrame + https://bugs.webkit.org/show_bug.cgi?id=52925 + + * UIProcess/API/C/WKFrame.cpp: + (WKFrameStopLoading): Call through to WebFrameProxy::stopLoading. + * UIProcess/API/C/WKFrame.h: + * UIProcess/WebFrameProxy.cpp: + (WebKit::WebFrameProxy::stopLoading): Send a message to the WebProcess to stop loading the frame + with the passed in ID. + * UIProcess/WebFrameProxy.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::stopLoadingFrame): Call stopForUserCancel on the passed-in frame. + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: Add StopLoadingFrame. + +2011-01-21 Brady Eidson <beidson@apple.com> + + Reviewed by Adam Roben. + + <rdar://problem/8894125> and https://bugs.webkit.org/show_bug.cgi?id=52916 + Expose "suggested filename" for a resource based on its resource response. + + API pieces: + * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: + (WKBundleFrameCopySuggestedFilenameForResourceURL): + * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: + + Implementation: + * WebProcess/WebPage/WebFrame.cpp: + (WebKit::WebFrame::suggestedFilenameForResourceURL): See if the DocumentLoader has + a resource for this URL and, if so, return the response's suggested filename. + * WebProcess/WebPage/WebFrame.h: + +2011-01-21 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + DrawingAreaProxyImpl::paint should return the unpainted region + https://bugs.webkit.org/show_bug.cgi?id=52918 + + * UIProcess/API/mac/WKView.mm: + (-[WKView drawRect:]): + Add unpaintedRegion parameter. + + * UIProcess/BackingStore.h: + (WebKit::BackingStore::size): + Add a size getter. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::paint): + Initialize the unpainted region to the dirty region, then subtract the painted region. + +2011-01-21 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein and Maciej Stachowiak. + + Fix for <rdar://problem/8896057> + + Give the Web Process access to the PubSub agent. + + * WebProcess/com.apple.WebProcess.sb: + +2011-01-21 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Part 2 of "Cleanup Scrollbar/ScrollbarClient relationship" + https://bugs.webkit.org/show_bug.cgi?id=52779 + + Rename ScrollbarClient -> ScrollableArea. + + * UIProcess/win/WebPopupMenuProxyWin.cpp: + (WebKit::WebPopupMenuProxyWin::onMouseWheel): + (WebKit::WebPopupMenuProxyWin::scrollToRevealSelection): + * UIProcess/win/WebPopupMenuProxyWin.h: + +2011-01-21 Adam Roben <aroben@apple.com> + + Update for WKCACFLayerRenderer -> CACFLayerView rename + + Fixes <http://webkit.org/b/52898> WKCACFLayerRenderer sounds like a render object, but isn't + + Reviewed by Simon Fraser. + + * WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp: Just removed all the unnecessary + #includes. + +2011-01-20 Darin Adler <darin@apple.com> + + Reviewed by Dan Bernstein. + + WebKit2: Implement showModalDialog + https://bugs.webkit.org/show_bug.cgi?id=52855 + + * Shared/WebPageCreationParameters.h: Added canRunModal. + + * UIProcess/API/C/WKPage.h: Added a runModal function pointer to + WKPageUIClient. Also removed a lot of redundant typedefs and added + a new one, WKPageCallback, for callbacks without arguments or return + values. + + * UIProcess/API/qt/qwkpage.cpp: + (QWKPage::QWKPage): Added a runModal function pointer of 0. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::creationParameters): Set canRunModal + based on return value of WebUIClient::canRunModal. + + * UIProcess/WebPageProxy.h: Added runModal. + Calls WebUIClient::runModal. + + * UIProcess/WebPageProxy.messages.in: Added RunModal message. + Also removed the periods from the phrases in the comments + as Maciej requested a while back. + + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::canRunModal): Added. Returns true or false + based on whether a runModal function was supplied in the + WKPageUIClient structure. + (WebKit::WebUIClient::runModal): Added. Calls the runModal + function from the WKPageUIClient structure. + * UIProcess/WebUIClient.h: Declared the above functions. + + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::canRunModal): Call through to WebPage. + (WebKit::WebChromeClient::runModal): Ditto. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::WebPage): Initialize m_canRunModal based on the + creation parameters. Initialize m_isRunningModal to false. + (WebKit::WebPage::close): Stop the nested run loop if we are running modal. + (WebKit::WebPage::runModal): Send a message to ask the UI process to run + modal and then start a nested run loop. It gets stopped when the page is closed. + * WebProcess/WebPage/WebPage.h: Defined the canRunModal function + and declared the runModal function. + +2011-01-20 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=52849 + Make window.print work with WebKit2 + + * UIProcess/API/qt/qwkpage.cpp: + (QWKPage::QWKPage): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::printFrame): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::printFrame): + * UIProcess/WebUIClient.h: + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::print): + Just pass through deelagte call to a WebKit2 client. + + * UIProcess/API/C/WKPage.h: Also added "Callback" suffix to other printing related function + types. + +2011-01-20 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Keep track of the latest update timestamp in the backing store + https://bugs.webkit.org/show_bug.cgi?id=52848 + + * Shared/UpdateInfo.h: + (WebKit::UpdateInfo::UpdateInfo): + Initialize timestamp to 0. + + * UIProcess/BackingStore.cpp: + (WebKit::BackingStore::BackingStore): + Initialize m_latestUpdateTimestamp to 0. + + (WebKit::BackingStore::incorporateUpdate): + If the update is too old, discard it. Otherwise, create a bitmap + and pass it to platformIncorporateUpdate. Finally update the timestamp. + + * UIProcess/BackingStore.h: + Add m_latestUpdateTimestamp. + + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::platformIncorporateUpdate): + Update now that we are already given the shareable bitmap. + +2011-01-20 Beth Dakin <bdakin@apple.com> + + Reviewed by Geoffrey Garen. + + Fix for <rdar://problem/8890255> + + Allow WebKitSystemInterface to draw scrollbars + when appropriate. + * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + +2011-01-20 Sam Weinig <sam@webkit.org> + + Reviewed by Dave Hyatt. + + Cleanup Scrollbar/ScrollbarClient relationship + https://bugs.webkit.org/show_bug.cgi?id=52779 + + * UIProcess/win/WebPopupMenuProxyWin.cpp: + (WebKit::WebPopupMenuProxyWin::scrollPosition): + (WebKit::WebPopupMenuProxyWin::setScrollOffset): + (WebKit::WebPopupMenuProxyWin::scrollTo): + (WebKit::WebPopupMenuProxyWin::onMouseWheel): + (WebKit::WebPopupMenuProxyWin::scrollToRevealSelection): + * UIProcess/win/WebPopupMenuProxyWin.h: + (WebKit::WebPopupMenuProxyWin::verticalScrollbar): + +2011-01-20 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Add a timestamp to UpdateInfo + https://bugs.webkit.org/show_bug.cgi?id=52844 + + * Shared/UpdateInfo.cpp: + (WebKit::UpdateInfo::encode): + (WebKit::UpdateInfo::decode): + * Shared/UpdateInfo.h: + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setSize): + (WebKit::DrawingAreaImpl::display): + +2011-01-20 Anders Carlsson <andersca@apple.com> + + Reviewed by Beth Dakin. + + Add Connection::waitForAndDispatchImmediately + https://bugs.webkit.org/show_bug.cgi?id=52841 + + * Platform/CoreIPC/Connection.h: + (CoreIPC::Connection::waitForAndDispatchImmediately): + +2011-01-20 Kevin Decker <kdecker@apple.com> + + Reviewed by Anders Carlsson. + + <rdar://problem/8880689> need a way to obtain the rendered rectangle for box elements + https://bugs.webkit.org/show_bug.cgi?id=52823 + + * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: + (WKBundleNodeHandleGetRenderRect): Added new method that will return a rendered rectangle for box elements + * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h: Ditto. + * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp: Ditto. + (WebKit::InjectedBundleNodeHandle::renderRect): Ditto. + * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h: Ditto. + +2011-01-20 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com> + + Reviewed by Andreas Kling. + + Remove null ptr deref that happens when reattaching to + a new web process. + + Implement didRelaunchProcess that sets the drawing area size + after the drawing area is re-instantiated. + + [Qt][WK2] Null ptr deref in UI process after web process has crashed + https://bugs.webkit.org/show_bug.cgi?id=52796 + + * UIProcess/API/qt/qgraphicswkview.cpp: + (QGraphicsWKView::QGraphicsWKView): + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::QWKPagePrivate): + (QWKPagePrivate::init): + (QWKPagePrivate::createDrawingAreaProxy): + (QWKPagePrivate::didRelaunchProcess): Reset drawing area size after crash. + * UIProcess/API/qt/qwkpage_p.h: + +2011-01-20 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Adam Roben. + + WebKitTestRunner needs to support layoutTestController.evaluateScriptInIsolatedWorld + https://bugs.webkit.org/show_bug.cgi?id=42327 + + Added a new API call, WKBundleFrameForJavaScriptContext, that gets the WKBundleFrameRef + that corresponds to a JSContextRef (or null if none). + + * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: + (WKBundleFrameForJavaScriptContext): Simple wrapper, defers to a WebFrame + static method. + * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: + * WebProcess/WebPage/WebFrame.cpp: + (WebKit::WebFrame::frameForContext): Follow the maze of twisty pointers. + * WebProcess/WebPage/WebFrame.h: + +2011-01-20 Alejandro G. Castro <alex@igalia.com> + + Fix compilation error in GTK WebKit2. + + * Platform/CoreIPC/gtk/ConnectionGtk.cpp: + (CoreIPC::readBytesFromSocket): + (CoreIPC::writeBytesToSocket): + +2011-01-20 Zoltan Horvath <zoltan@webkit.org> + + Reviewed by Csaba Osztrogonác. + + Refactoring of the custom allocation framework + https://bugs.webkit.org/show_bug.cgi?id=49897 + + Inheriting from FastAllocBase can result in objects getting larger (bug #33896, #46589). + The modification replaces Noncopyable and FastAllocBase classes and these inherits with their + equivalent macro implementation at the necessary places. + +2011-01-19 Simon Fraser <simon.fraser@apple.com> + + Fix the WebKit2 build. + + * WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm: + (WebKit::LayerBackedDrawingArea::syncCompositingLayers): + +2011-01-19 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Need API to get the parent frame of a frame + https://bugs.webkit.org/show_bug.cgi?id=52774 + + Add the API to get the parent frame of a frame. + + * UIProcess/API/C/WKFrame.cpp: + (WKFrameGetParentFrame): + * UIProcess/API/C/WKFrame.h: + +2011-01-19 Enrica Casucci <enrica@apple.com> + + Reviewed by Darin Adler. + + WebKit2: add support for drag and drop + https://bugs.webkit.org/show_bug.cgi?id=52343 + <rdar://problem/7660558> + + This patch contains the remaining work to support drag and drop on Mac. + I've added a PasteboardTypes class to encapsulate all the pasteboard formats + supported for drag and drop. + In this implementation we don't support the promised types, since I could not + find an efficient way to do this across processes. + The bulk of the patch consists in creating a shareable bitmap for the drag image, + pass its handle to the UI process and create a new NSImage from it to be given to + AppKit for dragging. + I've added the missing implementation of the methods in the drag client to hook + up the placement of the data in the pasteboard. + + * Shared/mac/PasteboardTypes.h: Added. + * Shared/mac/PasteboardTypes.mm: Added. + (WebKit::PasteboardTypes::forEditing): + (WebKit::PasteboardTypes::forURL): + (WebKit::PasteboardTypes::forImages): + (WebKit::PasteboardTypes::forImagesWithArchive): + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::setDragImage): Added. + * UIProcess/API/mac/WKView.mm: + (-[WKView _registerDraggedTypes]): Refactored to use the new PasteboardTypes class. + (-[WKView initWithFrame:contextRef:pageGroupRef:]): + (-[WKView _setMouseDownEvent:]): + (-[WKView _mouseHandler:]): + (-[WKView mouseDown:]): + (-[WKView mouseUp:]): + (-[WKView mouseDragged:]): + (-[WKView draggedImage:endedAt:operation:]): + (-[WKView draggingEntered:]): + (-[WKView _setDragImage:at:linkDrag:]): + * UIProcess/API/mac/WKViewInternal.h: + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::setDragImage): + (WebKit::WebPageProxy::dragEnded): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/WebCoreSupport/WebDragClient.cpp: + * WebProcess/WebCoreSupport/WebDragClient.h: + * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: Added. + (WebKit::fontFromNSFont): + (WebKit::WebDragClient::startDrag): Added implementation. + (WebKit::WebDragClient::createDragImageForLink): Ditto. + (WebKit::writeURL): Helper function. + (WebKit::writeImage): Helper function. + (WebKit::WebDragClient::declareAndWriteDragImage): Added implementation. + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::dragEnded): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Put the deprecated Connection member functions next to eachother + https://bugs.webkit.org/show_bug.cgi?id=52767 + + * Platform/CoreIPC/Connection.h: + (CoreIPC::Connection::sendSync): + (CoreIPC::Connection::send): + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + When resizing, the web process should repaint the page + https://bugs.webkit.org/show_bug.cgi?id=52764 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::didSetSize): + Incorporate the update. + + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + Return early if the update bounds rect is empty. This can happen if painting is + disabled and we get a DidSetSize message. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setSize): + If painting is disabled, just send back an empty UpdateInfo struct. Otherwise, + paint and fill in the UpdateInfo struct. + + (WebKit::DrawingAreaImpl::display): + Assert that painting is not disabled. + +2011-01-19 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=52739 + Make it possible for a WebKit2 client to print headers and footers + + * UIProcess/API/C/WKPage.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::headerHeight): + (WebKit::WebPageProxy::footerHeight): + (WebKit::WebPageProxy::drawHeader): + (WebKit::WebPageProxy::drawFooter): + * UIProcess/WebPageProxy.h: + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::headerHeight): + (WebKit::WebUIClient::footerHeight): + (WebKit::WebUIClient::drawHeader): + (WebKit::WebUIClient::drawFooter): + * UIProcess/WebUIClient.h: + Pass UIClient calls through. + + * UIProcess/API/mac/WKView.mm: + (currentPrintOperationScale): A helper to extract scale factor from the current NSPrintOperation. + (-[WKView _adjustPrintingMarginsForHeaderAndFooter]): Copied from WebKit1. Change current + print info to account for header and footer height as provided by the client. + (-[WKView knowsPageRange:]): Call -[self _adjustPrintingMarginsForHeaderAndFooter]. + (-[WKView drawPageBorderWithSize:]): When AppKit asks to print page border, call the client + to do that. Code adapted form WebKit1. + + * UIProcess/API/qt/qwkpage: + (QWKPage::QWKPage): Added zeroes for new WKPageUIClient members to avoid breaking the build. + +2011-01-19 Jessie Berlin <jberlin@apple.com> + + Reviewed by Darin Adler. + + Crash in WebDatabaseManagerProxy::getDatabaseOrigins when called after the WebProcess has + died at least once + https://bugs.webkit.org/show_bug.cgi?id=52730 + + WebDatabaseManagerProxy::invalidate was setting m_webContext to 0, and invalidate gets + called in WebContext::processDidClose. However, m_webContext is only set in the + constructor, which is only called from the constructor of WebContext, so attempting to send + a message to any new WebProcess after the first one died was causing a null deref. + + This patch moves setting m_webcontext into clearContext and clearContext is only called in + the WebContext destructor. + + This patch also adds checks for a valid WebProcessProxy before attempting to send messages to + the WebProcessProxy so that if the WebProcess has died and has not been revived, it does not + attempt to dereference a null WebProcessProxy. + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::~WebContext): + Call WebDatabaseManagerProxy::clearContext. + * UIProcess/WebContext.h: + (WebKit::WebContext::hasValidProcess): + Make this method public so that it can be called from WebDatabaseManagerProxy. + + * UIProcess/WebDatabaseManagerProxy.cpp: + (WebKit::WebDatabaseManagerProxy::getDatabasesByOrigin): + If there isn't a valid process, invalidate the callback and return early. + (WebKit::WebDatabaseManagerProxy::getDatabaseOrigins): + Ditto. + (WebKit::WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin): + If tehre isn't a valid process return early. + (WebKit::WebDatabaseManagerProxy::deleteDatabasesForOrigin): + Ditto. + (WebKit::WebDatabaseManagerProxy::deleteAllDatabases): + Ditto. + (WebKit::WebDatabaseManagerProxy::setQuotaForOrigin): + Ditto. + (WebKit::WebDatabaseManagerProxy::invalidate): + Move setting m_webContext to 0 from here ... + * UIProcess/WebDatabaseManagerProxy.h: + (WebKit::WebDatabaseManagerProxy::clearContext): + ... to here. + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Suspend/resume painting as the WKView visibility changes + https://bugs.webkit.org/show_bug.cgi?id=52738 + + * UIProcess/DrawingAreaProxy.h: + (WebKit::DrawingAreaProxy::visibilityDidChange): + Add new member function. It should really be pure virtual once setPageIsVisible + is removed. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::visibilityDidChange): + Send SuspendPainting/ResumePainting messages based on whether the view is visible or not. + + (WebKit::DrawingAreaProxyImpl::setPageIsVisible): + Make this a stub; it should really be removed. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::viewStateDidChange): + Call visibilityDidChange. + + * UIProcess/WebPageProxy.h: + (WebKit::WebPageProxy::isViewVisible): + Add new getter. + + * WebProcess/WebPage/DrawingArea.messages.in: + Add SuspendPainting and ResumePainting messages. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::DrawingAreaImpl): + Initialize m_isPaintingSuspended. + + (WebKit::DrawingAreaImpl::suspendPainting): + Set m_isPaintingSuspended to true and stop the display timer. + + (WebKit::DrawingAreaImpl::resumePainting): + Set m_isPaintingSuspended to false. + + (WebKit::DrawingAreaImpl::scheduleDisplay): + (WebKit::DrawingAreaImpl::display): + Bail if m_isPaintingSuspended is true. + +2011-01-19 Andreas Kling <kling@webkit.org> + + Reviewed by Simon Hausmann. + + [Qt][WK2] Implement formatLocalizedString() for Qt. + + * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: + (WebKit::formatLocalizedString): + +2011-01-19 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + WK2 - Multiple crashes in PlatformCALayer::replaceSublayer + https://bugs.webkit.org/show_bug.cgi?id=52695 + + Added a hostingLayer as the parent of the existing drawingLayer. + The hostingLayer is now the root which is passed to the + remote context. It never changes except to track the size + of the window. The backingLayer is now a child of the + hostingLayer, which allow it to switch between tiled and + non-tiled. + + I also now give back accurate settings for debug borders and + repaint counters. + + * WebProcess/WebPage/LayerBackedDrawingArea.cpp: + (WebKit::LayerBackedDrawingArea::LayerBackedDrawingArea): + (WebKit::LayerBackedDrawingArea::setSize): + (WebKit::LayerBackedDrawingArea::showDebugBorders): + (WebKit::LayerBackedDrawingArea::showRepaintCounter): + * WebProcess/WebPage/LayerBackedDrawingArea.h: + * WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm: + (WebKit::LayerBackedDrawingArea::platformInit): + (WebKit::LayerBackedDrawingArea::attachCompositingContext): + (WebKit::LayerBackedDrawingArea::syncCompositingLayers): + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Send a new SetSize message if the size differs from the current size + https://bugs.webkit.org/show_bug.cgi?id=52728 + + * UIProcess/DrawingAreaProxy.h: + (WebKit::DrawingAreaProxy::didSetSize): + Add UpdateInfo parameter. + + * UIProcess/DrawingAreaProxy.messages.in: + Add UpdateInfo parameter to the DidSetSize message. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::didSetSize): + If the view size differs from the current size send another SetSize message. + + * UIProcess/DrawingAreaProxyImpl.h: + Add UpdateInfo parameter to didSetSize. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setSize): + The DidSetSize message now takes an UpdateInfo parameter. + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Throttle sending of SetSize messages + https://bugs.webkit.org/show_bug.cgi?id=52727 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl): + Initialize m_isWaitingForDidSetSize to false. + + (WebKit::DrawingAreaProxyImpl::didSetSize): + Null out the backing store. + + (WebKit::DrawingAreaProxyImpl::sendSetSize): + If m_isWaitingForDidSetSize is true, do nothing. Otherwise, set m_isWaitingForDidSetSize + to true and send a SetSize message. + + * UIProcess/DrawingAreaProxyImpl.h: + Add m_isWaitingForDidSetSize. + +2011-01-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Pass WebPageCreationParameters to DrawingArea::create + https://bugs.webkit.org/show_bug.cgi?id=52726 + + * WebProcess/WebPage/DrawingArea.cpp: + (WebKit::DrawingArea::create): + * WebProcess/WebPage/DrawingArea.h: + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::create): + (WebKit::DrawingAreaImpl::DrawingAreaImpl): + * WebProcess/WebPage/DrawingAreaImpl.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::WebPage): + (WebKit::WebPage::changeAcceleratedCompositingMode): + +2011-01-19 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Laszlo Gombos and Tor Arne Vestbø. + + [Qt] Remove unnecessary "../Source" from paths + after moving source files into Source is finished. + + * DerivedSources.pro: + * WebKit2.pro: + +2011-01-18 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Sam Weinig. + + WebKitTestRunner should track loading more like DumpRenderTree + https://bugs.webkit.org/show_bug.cgi?id=52692 + + Relax the message check in didSaveFrameToPageCache a bit more, since + layout tests were still hitting the old one. + + * UIProcess/WebPageProxy.cpp: + (WebKit::isDisconnectedFrame): + (WebKit::WebPageProxy::didSaveFrameToPageCache): + +2011-01-18 Brady Eidson <beidson@apple.com> + + Reviewed by Darin Adler. + + <rdar://problem/8860833> and https://bugs.webkit.org/show_bug.cgi?id=52599 + UIProcess crash in WebPageProxy::reattachToWebProcess when web process crashes with a new tab/window. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::reattachToWebProcessWithItem): Null check item *both* places it is used. + +2011-01-18 Brady Eidson <beidson@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/8752200> and https://bugs.webkit.org/show_bug.cgi?id=52664 + Need WebKit2 API to asynchronously get the resource data for a URL + + Rename WKFrameGetMainResourceDataFunction to WKFrameGetResourceDataFunction, and add + new API to get a resource by URL: + * UIProcess/API/C/WKFrame.cpp: + (WKFrameGetMainResourceData): + (WKFrameGetResourceData): + (callGetResourceDataBlockAndDispose): + (WKFrameGetMainResourceData_b): + (WKFrameGetResourceData_b): + * UIProcess/API/C/WKFrame.h: + + Implement the new API in the UIProcess side: + * UIProcess/WebFrameProxy.cpp: + (WebKit::WebFrameProxy::getResourceData): + * UIProcess/WebFrameProxy.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::getResourceDataFromFrame): + * UIProcess/WebPageProxy.h: + + Have the WebProcess get the data and call back to the UIProcess: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::getResourceDataFromFrame): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Make PageClientImpl::scrollView do hardware blitting + https://bugs.webkit.org/show_bug.cgi?id=52689 + + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::scrollView): + Clip the scroll rect and scroll the view. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + Scroll before painting. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Artifacts when scrolling with new drawing area + https://bugs.webkit.org/show_bug.cgi?id=52682 + + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::scroll): + When scrolling, we want the intersection of the scroll rect and clip rect. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Use a CGLayer for the backing store when possible + https://bugs.webkit.org/show_bug.cgi?id=52679 + + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::paint): + If there is a layer, paint it into the given context. + + (WebKit::BackingStore::backingStoreContext): + If we can get the containing window graphics context, use it to create a + CGLayer that we'll use for the backing store. + + (WebKit::BackingStore::scroll): + Paint the layer into itself. + + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::containingWindowGraphicsContext): + Call the page client. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Pass the web page proxy to BackingStore::create + https://bugs.webkit.org/show_bug.cgi?id=52673 + + * UIProcess/BackingStore.cpp: + (WebKit::BackingStore::create): + Add WebPageProxy parameter. + + (WebKit::BackingStore::BackingStore): + Add WebPageProxy parameter. + + * UIProcess/BackingStore.h: + Add WebPageProxy member variable. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + Pass the web page proxy when creating the backing store. + + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::backingStoreContext): + Set the default blend mode. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Factor code to create the backing store bitmap context out into a new function + https://bugs.webkit.org/show_bug.cgi?id=52670 + + * UIProcess/BackingStore.h: + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::backingStoreContext): + Create the backing store context. + + (WebKit::BackingStore::incorporateUpdate): + Call backingStoreContext. + + (WebKit::BackingStore::scroll): + Assert that the context is not null. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Add PageClientImpl::containingWindowGraphicsContext + https://bugs.webkit.org/show_bug.cgi?id=52666 + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::containingWindowGraphicsContext): + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.h: + +2011-01-18 Damian Kaleta <dkaleta@apple.com> + + Reviewed by Sam Weinig. + + WK2 methods WKPageScaleWebView and WKPageGetViewScaleFactor need to have consistent names + https://bugs.webkit.org/show_bug.cgi?id=52647 + + * UIProcess/API/C/WKPage.cpp: + (WKPageSetScaleFactor): + (WKPageGetScaleFactor): + * UIProcess/API/C/WKPage.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Ask the web page proxy to scroll the view when needed + https://bugs.webkit.org/show_bug.cgi?id=52665 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::incorporateUpdate): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::scrollView): + * UIProcess/WebPageProxy.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Fix build. + + * UIProcess/win/WebView.cpp: + (WebKit::WebView::scrollView): + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add PageClient::scrollView + https://bugs.webkit.org/show_bug.cgi?id=52663 + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::scrollView): + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::scrollView): + * UIProcess/API/qt/qwkpage_p.h: + * UIProcess/PageClient.h: + * UIProcess/win/WebView.cpp: + (WebKit::PageClientImpl::scrollView): + * UIProcess/win/WebView.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Rename scrollDelta to scrollOffset everywhere. + + * Shared/UpdateInfo.cpp: + (WebKit::UpdateInfo::encode): + (WebKit::UpdateInfo::decode): + * Shared/UpdateInfo.h: + * UIProcess/BackingStore.h: + * UIProcess/mac/BackingStoreMac.mm: + (WebKit::BackingStore::incorporateUpdate): + (WebKit::BackingStore::scroll): + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::scroll): + (WebKit::WebChromeClient::delegatedScrollRequested): + * WebProcess/WebCoreSupport/WebChromeClient.h: + * WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp: + (WebKit::ChunkedUpdateDrawingArea::scroll): + * WebProcess/WebPage/ChunkedUpdateDrawingArea.h: + * WebProcess/WebPage/DrawingArea.h: + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::scroll): + (WebKit::DrawingAreaImpl::display): + * WebProcess/WebPage/DrawingAreaImpl.h: + * WebProcess/WebPage/LayerBackedDrawingArea.cpp: + (WebKit::LayerBackedDrawingArea::scroll): + * WebProcess/WebPage/LayerBackedDrawingArea.h: + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Get and paint each individual rect in -[WKView drawRect:] + https://bugs.webkit.org/show_bug.cgi?id=52660 + + * UIProcess/API/mac/WKView.mm: + (-[WKView drawRect:]): + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Assertion when loading two URLs in quick succession + https://bugs.webkit.org/show_bug.cgi?id=52649 + <rdar://problem/8764645> + + If beginLoad is called twice without didStartProvisionalLoad being called in between, + m_pendingProvisionalSandboxExtension would be non-null and an assert would fire. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::SandboxExtensionTracker::beginLoad): + Instead of asserting that m_pendingProvisionalSandboxExtension is null, invalidate it + if it is not null, since that's valid. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Implement NPN_PopUpContextMenu + https://bugs.webkit.org/show_bug.cgi?id=52646 + <rdar://problem/8735616> + + * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: + (WebKit::NPN_PopUpContextMenu): + Call NetscapePlugin::popUpContextMenu. + + * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: + (WebKit::NetscapePlugin::NetscapePlugin): + Initialize m_currentMouseEvent. + + * WebProcess/Plugins/Netscape/NetscapePlugin.h: + Add m_currentMouseEvent. + + * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: + (WebKit::NetscapePlugin::popUpContextMenu): + Convert the coordinates from the current mouse event to screen coordinates and call + WKPopupContextMenu. + + (WebKit::NetscapePlugin::platformHandleMouseEvent): + Update m_currentMouseEvent. + +2011-01-18 Jessie Berlin <jberlin@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Do not assert that the provisional and committed URLs cannot be empty/null + https://bugs.webkit.org/show_bug.cgi?id=52641 + + * UIProcess/WebFrameProxy.cpp: + (WebKit::WebFrameProxy::didStartProvisionalLoad): + (WebKit::WebFrameProxy::didCommitLoad): + (WebKit::WebFrameProxy::didFinishLoad): + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + ASSERT in plug-in code when going to youtube + https://bugs.webkit.org/show_bug.cgi?id=52638 + + * PluginProcess/PluginControllerProxy.cpp: + (WebKit::PluginControllerProxy::paintEntirePlugin): + Don't try to paint the plug-in if the plug-in frame is empty. + +2011-01-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Plug-in hosting WebProcess instances appear in Activity Monitor as WebProcess + https://bugs.webkit.org/show_bug.cgi?id=52635 + <rdar://problem/8731337> + + * PluginProcess/PluginProcess.cpp: + (WebKit::PluginProcess::initialize): + Call platformInitialize. + + * PluginProcess/PluginProcess.h: + Add platformInitialize. + + * PluginProcess/mac/PluginProcessMac.mm: + (WebKit::PluginProcess::platformInitialize): + Set the compositing render server port and the visible application name. + + * Shared/Plugins/PluginProcessCreationParameters.cpp: + (WebKit::PluginProcessCreationParameters::encode): + (WebKit::PluginProcessCreationParameters::decode): + Encode/decode the parent process name. + + * Shared/Plugins/PluginProcessCreationParameters.h: + Add parentProcessName. + + * Shared/WebProcessCreationParameters.cpp: + (WebKit::WebProcessCreationParameters::encode): + (WebKit::WebProcessCreationParameters::decode): + Encode/decode the parent process name. + + * Shared/WebProcessCreationParameters.h: + Add parentProcessName. + + * UIProcess/Launcher/mac/ProcessLauncherMac.mm: + (WebKit::ProcessLauncher::launchProcess): + Don't pass the parent process name here. + + * UIProcess/Plugins/mac/PluginProcessProxyMac.mm: + (WebKit::PluginProcessProxy::platformInitializePluginProcess): + Set the visible name. + + * UIProcess/mac/WebContextMac.mm: + (WebKit::WebContext::platformInitializeWebProcess): + Pass along the parent process name. + + * WebProcess/mac/WebProcessMac.mm: + (WebKit::WebProcess::platformInitializeWebProcess): + Set the visible name. + + * WebProcess/mac/WebProcessMainMac.mm: + (WebKit::WebProcessMain): + Don't set the visible name here. It's done in platformInitializeWebProcess. + +2011-01-18 Balazs Kelemen <kbalazs@webkit.org> + + Reviewed by Csaba Osztrogonác. + + [Qt][WK2] Not implemented warnings should not break layout tests + https://bugs.webkit.org/show_bug.cgi?id=52616 + + * WebKit2Prefix.h: Define DISABLE_NOT_IMPLEMENTED_WARNINGS on Qt. + 2011-01-17 Jon Honeycutt <jhoneycutt@apple.com> Windows build fix. Unreviewed. diff --git a/Source/WebKit2/DerivedSources.pro b/Source/WebKit2/DerivedSources.pro index 4f6c7d9..4164203 100644 --- a/Source/WebKit2/DerivedSources.pro +++ b/Source/WebKit2/DerivedSources.pro @@ -5,10 +5,10 @@ CONFIG -= debug_and_release CONFIG(standalone_package) { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = $$PWD/generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../WebCore/generated } else { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../WebCore/generated } WEBCORE_GENERATED_HEADERS_FOR_WEBKIT2 += \ diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.h b/Source/WebKit2/Platform/CoreIPC/Connection.h index b7e5b0f..1b009cf 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.h +++ b/Source/WebKit2/Platform/CoreIPC/Connection.h @@ -115,23 +115,22 @@ public: void invalidate(); void markCurrentlyDispatchedMessageAsInvalid(); - // FIXME: This variant of send is deprecated, all clients should move to the overload that takes a message. - template<typename E, typename T> bool send(E messageID, uint64_t destinationID, const T& arguments); - - template<typename T> bool send(const T& message, uint64_t destinationID); - static const unsigned long long NoTimeout = 10000000000ULL; - // FIXME: This variant of sendSync is deprecated, all clients should move to the overload that takes a message. - template<typename E, typename T, typename U> bool sendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout = NoTimeout); + template<typename T> bool send(const T& message, uint64_t destinationID); template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = NoTimeout); - - template<typename E> PassOwnPtr<ArgumentDecoder> waitFor(E messageID, uint64_t destinationID, double timeout); + template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, double timeout); PassOwnPtr<ArgumentEncoder> createSyncMessageArgumentEncoder(uint64_t destinationID, uint64_t& syncRequestID); bool sendMessage(MessageID, PassOwnPtr<ArgumentEncoder>); bool sendSyncReply(PassOwnPtr<ArgumentEncoder>); + // FIXME: These variants of senc, sendSync and waitFor are all deprecated. + // All clients should move to the overloads that take a message type. + template<typename E, typename T> bool send(E messageID, uint64_t destinationID, const T& arguments); + template<typename E, typename T, typename U> bool sendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout = NoTimeout); + template<typename E> PassOwnPtr<ArgumentDecoder> waitFor(E messageID, uint64_t destinationID, double timeout); + private: template<typename T> class Message { public: @@ -300,15 +299,6 @@ private: #endif }; -template<typename E, typename T> -bool Connection::send(E messageID, uint64_t destinationID, const T& arguments) -{ - OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); - argumentEncoder->encode(arguments); - - return sendMessage(MessageID(messageID), argumentEncoder.release()); -} - template<typename T> bool Connection::send(const T& message, uint64_t destinationID) { OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); @@ -317,6 +307,36 @@ template<typename T> bool Connection::send(const T& message, uint64_t destinatio return sendMessage(MessageID(T::messageID), argumentEncoder.release()); } +template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout) +{ + uint64_t syncRequestID = 0; + OwnPtr<ArgumentEncoder> argumentEncoder = createSyncMessageArgumentEncoder(destinationID, syncRequestID); + + // Encode the rest of the input arguments. + argumentEncoder->encode(message); + + // Now send the message and wait for a reply. + OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID, MessageID::SyncMessage), syncRequestID, argumentEncoder.release(), timeout); + if (!replyDecoder) + return false; + + // Decode the reply. + return replyDecoder->decode(const_cast<typename T::Reply&>(reply)); +} + +template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, double timeout) +{ + OwnPtr<ArgumentDecoder> decoder = waitForMessage(MessageID(T::messageID), destinationID, timeout); + if (!decoder) + return false; + + ASSERT(decoder->destinationID() == destinationID); + m_client->didReceiveMessage(this, MessageID(T::messageID), decoder.get()); + return true; +} + +// These three member functions are all deprecated. + template<typename E, typename T, typename U> inline bool Connection::sendSync(E messageID, uint64_t destinationID, const T& arguments, const U& reply, double timeout) { @@ -335,21 +355,13 @@ inline bool Connection::sendSync(E messageID, uint64_t destinationID, const T& a return replyDecoder->decode(const_cast<U&>(reply)); } -template<typename T> bool Connection::sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout) +template<typename E, typename T> +bool Connection::send(E messageID, uint64_t destinationID, const T& arguments) { - uint64_t syncRequestID = 0; - OwnPtr<ArgumentEncoder> argumentEncoder = createSyncMessageArgumentEncoder(destinationID, syncRequestID); - - // Encode the rest of the input arguments. - argumentEncoder->encode(message); - - // Now send the message and wait for a reply. - OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID, MessageID::SyncMessage), syncRequestID, argumentEncoder.release(), timeout); - if (!replyDecoder) - return false; + OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); + argumentEncoder->encode(arguments); - // Decode the reply. - return replyDecoder->decode(const_cast<typename T::Reply&>(reply)); + return sendMessage(MessageID(messageID), argumentEncoder.release()); } template<typename E> inline PassOwnPtr<ArgumentDecoder> Connection::waitFor(E messageID, uint64_t destinationID, double timeout) diff --git a/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp b/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp index 65b1254..d561110 100644 --- a/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp +++ b/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp @@ -41,7 +41,7 @@ static const size_t initialMessageBufferSize = 4096; static int readBytesFromSocket(int fileDescriptor, uint8_t* ptr, size_t length) { ASSERT(fileDescriptor > 0); - ASSERT(buffer); + ASSERT(ptr); ASSERT(length > 0); ssize_t numberOfBytesRead = 0; @@ -69,7 +69,7 @@ static int readBytesFromSocket(int fileDescriptor, uint8_t* ptr, size_t length) static bool writeBytesToSocket(int fileDescriptor, uint8_t* ptr, size_t length) { ASSERT(fileDescriptor > 0); - ASSERT(buffer); + ASSERT(ptr); ASSERT(length > 0); ssize_t numberOfBytesWritten = 0; diff --git a/Source/WebKit2/Platform/Module.h b/Source/WebKit2/Platform/Module.h index 0825bf6..ec7523c 100644 --- a/Source/WebKit2/Platform/Module.h +++ b/Source/WebKit2/Platform/Module.h @@ -39,7 +39,8 @@ namespace WebKit { -class Module : public Noncopyable { +class Module { + WTF_MAKE_NONCOPYABLE(Module); public: Module(const String& path); ~Module(); diff --git a/Source/WebKit2/Platform/SharedMemory.h b/Source/WebKit2/Platform/SharedMemory.h index 05dc0dd..9854132 100644 --- a/Source/WebKit2/Platform/SharedMemory.h +++ b/Source/WebKit2/Platform/SharedMemory.h @@ -52,7 +52,8 @@ public: ReadWrite }; - class Handle : Noncopyable { + class Handle { + WTF_MAKE_NONCOPYABLE(Handle); public: Handle(); ~Handle(); diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp index 5eb8dd4..42e9e6d 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp @@ -390,6 +390,9 @@ void PluginControllerProxy::handleKeyboardEvent(const WebKeyboardEvent& keyboard void PluginControllerProxy::paintEntirePlugin() { + if (m_frameRect.isEmpty()) + return; + m_dirtyRect = m_frameRect; paint(); } diff --git a/Source/WebKit2/PluginProcess/PluginProcess.cpp b/Source/WebKit2/PluginProcess/PluginProcess.cpp index 6c19c21..6124f9a 100644 --- a/Source/WebKit2/PluginProcess/PluginProcess.cpp +++ b/Source/WebKit2/PluginProcess/PluginProcess.cpp @@ -115,9 +115,7 @@ void PluginProcess::initialize(const PluginProcessCreationParameters& parameters m_pluginPath = parameters.pluginPath; -#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) - m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); -#endif + platformInitialize(parameters); } void PluginProcess::createWebProcessConnection() diff --git a/Source/WebKit2/PluginProcess/PluginProcess.h b/Source/WebKit2/PluginProcess/PluginProcess.h index e60d52d..6c221e7 100644 --- a/Source/WebKit2/PluginProcess/PluginProcess.h +++ b/Source/WebKit2/PluginProcess/PluginProcess.h @@ -40,6 +40,7 @@ class WebProcessConnection; struct PluginProcessCreationParameters; class PluginProcess : ChildProcess { + WTF_MAKE_NONCOPYABLE(PluginProcess); public: static PluginProcess& shared(); @@ -72,6 +73,8 @@ private: void shutdownTimerFired(); + void platformInitialize(const PluginProcessCreationParameters&); + // The connection to the UI process. RefPtr<CoreIPC::Connection> m_connection; diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm index ccf444c..3919c8b 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm @@ -24,11 +24,16 @@ */ #if ENABLE(PLUGIN_PROCESS) + +// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized +#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] #include "PluginProcess.h" #include "NetscapePlugin.h" #include "PluginProcessShim.h" +#include "PluginProcessCreationParameters.h" +#include <WebKitSystemInterface.h> #include <dlfcn.h> namespace WebKit { @@ -84,6 +89,19 @@ void PluginProcess::initializeShim() initFunc(callbacks); } +void PluginProcess::platformInitialize(const PluginProcessCreationParameters& parameters) +{ + m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); + + NSString *applicationName = [NSString stringWithFormat:UI_STRING("%@ (%@ Internet plug-in)", + "visible name of the plug-in host process. The first argument is the plug-in name " + "and the second argument is the application name."), + [[(NSString *)parameters.pluginPath lastPathComponent] stringByDeletingPathExtension], + (NSString *)parameters.parentProcessName]; + + WKSetVisibleApplicationName((CFStringRef)applicationName); +} + } // namespace WebKit #endif // ENABLE(PLUGIN_PROCESS) diff --git a/Source/WebKit2/Shared/ChildProcess.h b/Source/WebKit2/Shared/ChildProcess.h index 78fe1f4..8c5e8e3 100644 --- a/Source/WebKit2/Shared/ChildProcess.h +++ b/Source/WebKit2/Shared/ChildProcess.h @@ -27,13 +27,11 @@ #define ChildProcess_h #include "Connection.h" -#include <wtf/Noncopyable.h> namespace WebKit { class ChildProcess : protected CoreIPC::Connection::Client { WTF_MAKE_NONCOPYABLE(ChildProcess); - protected: ChildProcess(); ~ChildProcess(); diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp index 90bbf07..c95a825 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp @@ -40,6 +40,7 @@ void PluginProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) encoder->encode(pluginPath); #if PLATFORM(MAC) + encoder->encode(parentProcessName); encoder->encode(acceleratedCompositingPort); #endif } @@ -50,6 +51,8 @@ bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, return false; #if PLATFORM(MAC) + if (!decoder->decode(result.parentProcessName)) + return false; if (!decoder->decode(result.acceleratedCompositingPort)) return false; #endif diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h index 1aeef01..62cf4bb 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h @@ -50,6 +50,7 @@ struct PluginProcessCreationParameters { String pluginPath; #if PLATFORM(MAC) + String parentProcessName; CoreIPC::MachPort acceleratedCompositingPort; #endif }; diff --git a/Source/WebKit2/Shared/UpdateInfo.cpp b/Source/WebKit2/Shared/UpdateInfo.cpp index 1b504ed..182f75b 100644 --- a/Source/WebKit2/Shared/UpdateInfo.cpp +++ b/Source/WebKit2/Shared/UpdateInfo.cpp @@ -31,9 +31,10 @@ namespace WebKit { void UpdateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const { + encoder->encode(timestamp); encoder->encode(viewSize); encoder->encode(scrollRect); - encoder->encode(scrollDelta); + encoder->encode(scrollOffset); encoder->encode(updateRectBounds); encoder->encode(updateRects); encoder->encode(bitmapHandle); @@ -41,11 +42,13 @@ void UpdateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const bool UpdateInfo::decode(CoreIPC::ArgumentDecoder* decoder, UpdateInfo& result) { + if (!decoder->decode(result.timestamp)) + return false; if (!decoder->decode(result.viewSize)) return false; if (!decoder->decode(result.scrollRect)) return false; - if (!decoder->decode(result.scrollDelta)) + if (!decoder->decode(result.scrollOffset)) return false; if (!decoder->decode(result.updateRectBounds)) return false; diff --git a/Source/WebKit2/Shared/UpdateInfo.h b/Source/WebKit2/Shared/UpdateInfo.h index 850911c..2ceb164 100644 --- a/Source/WebKit2/Shared/UpdateInfo.h +++ b/Source/WebKit2/Shared/UpdateInfo.h @@ -41,17 +41,20 @@ class UpdateInfo { WTF_MAKE_NONCOPYABLE(UpdateInfo); public: - UpdateInfo() { } + UpdateInfo() : timestamp(0) { } void encode(CoreIPC::ArgumentEncoder*) const; static bool decode(CoreIPC::ArgumentDecoder*, UpdateInfo&); + // The timestamp of this update. + double timestamp; + // The size of the web view. WebCore::IntSize viewSize; // The rect and delta to be scrolled. WebCore::IntRect scrollRect; - WebCore::IntSize scrollDelta; + WebCore::IntSize scrollOffset; // The bounds of the update rects. WebCore::IntRect updateRectBounds; diff --git a/Source/WebKit2/Shared/WebMemorySampler.h b/Source/WebKit2/Shared/WebMemorySampler.h index 93254d9..c50d3bf 100644 --- a/Source/WebKit2/Shared/WebMemorySampler.h +++ b/Source/WebKit2/Shared/WebMemorySampler.h @@ -69,8 +69,8 @@ struct WebMemoryStatistics Vector<size_t> values; }; -class WebMemorySampler : public Noncopyable { - +class WebMemorySampler { + WTF_MAKE_NONCOPYABLE(WebMemorySampler); public: static WebMemorySampler* shared(); void start(const double interval=0); diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.h b/Source/WebKit2/Shared/WebPageCreationParameters.h index e698ce7..8c76f68 100644 --- a/Source/WebKit2/Shared/WebPageCreationParameters.h +++ b/Source/WebKit2/Shared/WebPageCreationParameters.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 @@ -66,9 +66,12 @@ struct WebPageCreationParameters { SessionState sessionState; uint64_t highestUsedBackForwardItemID; + bool canRunModal; + #if PLATFORM(MAC) bool isSmartInsertDeleteEnabled; #endif + #if PLATFORM(WIN) HWND nativeWindow; #endif diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp index ceae6c1..77e3a82 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp @@ -56,6 +56,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con encoder->encode(languageCode); encoder->encode(textCheckerState); #if PLATFORM(MAC) + encoder->encode(parentProcessName); encoder->encode(presenterApplicationPid); encoder->encode(nsURLCachePath); encoder->encode(nsURLCacheMemoryCapacity); @@ -95,6 +96,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web return false; #if PLATFORM(MAC) + if (!decoder->decode(parameters.parentProcessName)) + return false; if (!decoder->decode(parameters.presenterApplicationPid)) return false; if (!decoder->decode(parameters.nsURLCachePath)) diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.h b/Source/WebKit2/Shared/WebProcessCreationParameters.h index fe582b3..50d8a90 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.h +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.h @@ -73,6 +73,8 @@ struct WebProcessCreationParameters { TextCheckerState textCheckerState; #if PLATFORM(MAC) + String parentProcessName; + pid_t presenterApplicationPid; CString nsURLCachePath; diff --git a/Source/WebKit2/Shared/mac/PasteboardTypes.h b/Source/WebKit2/Shared/mac/PasteboardTypes.h new file mode 100644 index 0000000..712c4c0 --- /dev/null +++ b/Source/WebKit2/Shared/mac/PasteboardTypes.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PasteboardTypes_h +#define PasteboardTypes_h + +namespace WebKit { + +class PasteboardTypes { +public: + static NSString * const WebArchivePboardType; + static NSString * const WebURLsWithTitlesPboardType; + static NSString * const WebURLPboardType; + static NSString * const WebURLNamePboardType; + + static NSArray *forEditing(); + static NSArray *forURL(); + static NSArray *forImages(); + static NSArray *forImagesWithArchive(); +}; + +} // namespace WebKit + +#endif // PasteboardTypes_h diff --git a/Source/WebKit2/Shared/mac/PasteboardTypes.mm b/Source/WebKit2/Shared/mac/PasteboardTypes.mm new file mode 100644 index 0000000..380e24c --- /dev/null +++ b/Source/WebKit2/Shared/mac/PasteboardTypes.mm @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "PasteboardTypes.h" +#import <wtf/RetainPtr.h> + +namespace WebKit { + +NSString * const PasteboardTypes::WebArchivePboardType = @"Apple Web Archive pasteboard type"; +NSString * const PasteboardTypes::WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; +NSString * const PasteboardTypes::WebURLPboardType = @"public.url"; +NSString * const PasteboardTypes::WebURLNamePboardType = @"public.url-name"; + +static inline NSArray *retain(NSArray *array) +{ + CFRetain(array); + return array; +} + +NSArray* PasteboardTypes::forEditing() +{ + static NSArray *types = retain([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]); + return types; +} + +NSArray* PasteboardTypes::forURL() +{ + static NSArray *types = retain([NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil]); + return types; +} + +NSArray* PasteboardTypes::forImages() +{ + static NSArray *types = retain([NSArray arrayWithObjects:NSTIFFPboardType, WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, nil]); + return types; +} + +NSArray* PasteboardTypes::forImagesWithArchive() +{ + static NSArray *types = retain([NSArray arrayWithObjects:NSTIFFPboardType, WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSRTFDPboardType, WebArchivePboardType, nil]); + return types; +} + +} // namespace WebKit 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(); diff --git a/Source/WebKit2/WebKit2.pro b/Source/WebKit2/WebKit2.pro index f4e007b..c478636 100644 --- a/Source/WebKit2/WebKit2.pro +++ b/Source/WebKit2/WebKit2.pro @@ -7,15 +7,15 @@ isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../.. CONFIG(standalone_package) { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = $$PWD/generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../WebCore/generated } else { isEmpty(WEBKIT2_GENERATED_SOURCES_DIR):WEBKIT2_GENERATED_SOURCES_DIR = generated - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../../Source/WebCore/generated + isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../WebCore/generated } include($$PWD/../../WebKit.pri) include($$PWD/../../common.pri) -include($$PWD/../../Source/WebCore/features.pri) +include($$PWD/../WebCore/features.pri) include(WebKit2.pri) TEMPLATE = lib @@ -34,89 +34,88 @@ DESTDIR = $$WEBKIT2_DESTDIR mac: CONFIG += build_all WEBKIT2_INCLUDEPATH = \ - $$PWD/../.. \ # FIXME: Remove this include once we move all the source to Source. - $$PWD/../../Source \ + $$PWD/.. \ WEBKIT2_INCLUDEPATH = \ - $$PWD/../../Source/JavaScriptCore \ - $$PWD/../../Source/JavaScriptCore/assembler \ - $$PWD/../../Source/JavaScriptCore/bytecode \ - $$PWD/../../Source/JavaScriptCore/bytecompiler \ - $$PWD/../../Source/JavaScriptCore/debugger \ - $$PWD/../../Source/JavaScriptCore/interpreter \ - $$PWD/../../Source/JavaScriptCore/jit \ - $$PWD/../../Source/JavaScriptCore/parser \ - $$PWD/../../Source/JavaScriptCore/pcre \ - $$PWD/../../Source/JavaScriptCore/profiler \ - $$PWD/../../Source/JavaScriptCore/runtime \ - $$PWD/../../Source/JavaScriptCore/wtf \ - $$PWD/../../Source/JavaScriptCore/wtf/symbian \ - $$PWD/../../Source/JavaScriptCore/wtf/unicode \ - $$PWD/../../Source/JavaScriptCore/yarr \ - $$PWD/../../Source/JavaScriptCore/API \ - $$PWD/../../Source/JavaScriptCore/ForwardingHeaders \ + $$PWD/../JavaScriptCore \ + $$PWD/../JavaScriptCore/assembler \ + $$PWD/../JavaScriptCore/bytecode \ + $$PWD/../JavaScriptCore/bytecompiler \ + $$PWD/../JavaScriptCore/debugger \ + $$PWD/../JavaScriptCore/interpreter \ + $$PWD/../JavaScriptCore/jit \ + $$PWD/../JavaScriptCore/parser \ + $$PWD/../JavaScriptCore/pcre \ + $$PWD/../JavaScriptCore/profiler \ + $$PWD/../JavaScriptCore/runtime \ + $$PWD/../JavaScriptCore/wtf \ + $$PWD/../JavaScriptCore/wtf/symbian \ + $$PWD/../JavaScriptCore/wtf/unicode \ + $$PWD/../JavaScriptCore/yarr \ + $$PWD/../JavaScriptCore/API \ + $$PWD/../JavaScriptCore/ForwardingHeaders \ $$WEBKIT2_INCLUDEPATH WEBKIT2_INCLUDEPATH = \ - $$PWD/../../Source/WebCore \ - $$PWD/../../Source/WebCore/accessibility \ - $$PWD/../../Source/WebCore/bindings \ - $$PWD/../../Source/WebCore/bindings/generic \ - $$PWD/../../Source/WebCore/bindings/js \ - $$PWD/../../Source/WebCore/bridge \ - $$PWD/../../Source/WebCore/bridge/c \ - $$PWD/../../Source/WebCore/bridge/jsc \ - $$PWD/../../Source/WebCore/css \ - $$PWD/../../Source/WebCore/dom \ - $$PWD/../../Source/WebCore/dom/default \ - $$PWD/../../Source/WebCore/editing \ - $$PWD/../../Source/WebCore/history \ - $$PWD/../../Source/WebCore/html \ - $$PWD/../../Source/WebCore/html/canvas \ - $$PWD/../../Source/WebCore/inspector \ - $$PWD/../../Source/WebCore/loader \ - $$PWD/../../Source/WebCore/loader/appcache \ - $$PWD/../../Source/WebCore/loader/archive \ - $$PWD/../../Source/WebCore/loader/cache \ - $$PWD/../../Source/WebCore/loader/icon \ - $$PWD/../../Source/WebCore/mathml \ - $$PWD/../../Source/WebCore/notifications \ - $$PWD/../../Source/WebCore/page \ - $$PWD/../../Source/WebCore/page/animation \ - $$PWD/../../Source/WebCore/platform \ - $$PWD/../../Source/WebCore/platform/animation \ - $$PWD/../../Source/WebCore/platform/graphics \ - $$PWD/../../Source/WebCore/platform/graphics/filters \ - $$PWD/../../Source/WebCore/platform/graphics/transforms \ - $$PWD/../../Source/WebCore/platform/image-decoders \ - $$PWD/../../Source/WebCore/platform/mock \ - $$PWD/../../Source/WebCore/platform/network \ - $$PWD/../../Source/WebCore/platform/sql \ - $$PWD/../../Source/WebCore/platform/text \ - $$PWD/../../Source/WebCore/platform/text/transcoder \ - $$PWD/../../Source/WebCore/plugins \ - $$PWD/../../Source/WebCore/rendering \ - $$PWD/../../Source/WebCore/rendering/style \ - $$PWD/../../Source/WebCore/storage \ - $$PWD/../../Source/WebCore/svg \ - $$PWD/../../Source/WebCore/svg/animation \ - $$PWD/../../Source/WebCore/svg/graphics \ - $$PWD/../../Source/WebCore/svg/graphics/filters \ - $$PWD/../../Source/WebCore/svg/properties \ - $$PWD/../../Source/WebCore/websockets \ - $$PWD/../../Source/WebCore/wml \ - $$PWD/../../Source/WebCore/workers \ - $$PWD/../../Source/WebCore/xml \ + $$PWD/../WebCore \ + $$PWD/../WebCore/accessibility \ + $$PWD/../WebCore/bindings \ + $$PWD/../WebCore/bindings/generic \ + $$PWD/../WebCore/bindings/js \ + $$PWD/../WebCore/bridge \ + $$PWD/../WebCore/bridge/c \ + $$PWD/../WebCore/bridge/jsc \ + $$PWD/../WebCore/css \ + $$PWD/../WebCore/dom \ + $$PWD/../WebCore/dom/default \ + $$PWD/../WebCore/editing \ + $$PWD/../WebCore/history \ + $$PWD/../WebCore/html \ + $$PWD/../WebCore/html/canvas \ + $$PWD/../WebCore/inspector \ + $$PWD/../WebCore/loader \ + $$PWD/../WebCore/loader/appcache \ + $$PWD/../WebCore/loader/archive \ + $$PWD/../WebCore/loader/cache \ + $$PWD/../WebCore/loader/icon \ + $$PWD/../WebCore/mathml \ + $$PWD/../WebCore/notifications \ + $$PWD/../WebCore/page \ + $$PWD/../WebCore/page/animation \ + $$PWD/../WebCore/platform \ + $$PWD/../WebCore/platform/animation \ + $$PWD/../WebCore/platform/graphics \ + $$PWD/../WebCore/platform/graphics/filters \ + $$PWD/../WebCore/platform/graphics/transforms \ + $$PWD/../WebCore/platform/image-decoders \ + $$PWD/../WebCore/platform/mock \ + $$PWD/../WebCore/platform/network \ + $$PWD/../WebCore/platform/sql \ + $$PWD/../WebCore/platform/text \ + $$PWD/../WebCore/platform/text/transcoder \ + $$PWD/../WebCore/plugins \ + $$PWD/../WebCore/rendering \ + $$PWD/../WebCore/rendering/style \ + $$PWD/../WebCore/storage \ + $$PWD/../WebCore/svg \ + $$PWD/../WebCore/svg/animation \ + $$PWD/../WebCore/svg/graphics \ + $$PWD/../WebCore/svg/graphics/filters \ + $$PWD/../WebCore/svg/properties \ + $$PWD/../WebCore/websockets \ + $$PWD/../WebCore/wml \ + $$PWD/../WebCore/workers \ + $$PWD/../WebCore/xml \ $$WEBKIT2_INCLUDEPATH WEBKIT2_INCLUDEPATH = \ - $$PWD/../../Source/WebCore/bridge/qt \ - $$PWD/../../Source/WebCore/page/qt \ - $$PWD/../../Source/WebCore/platform/graphics/qt \ - $$PWD/../../Source/WebCore/platform/network/qt \ - $$PWD/../../Source/WebCore/platform/qt \ - $$PWD/../../WebKit/qt/Api \ - $$PWD/../../WebKit/qt/WebCoreSupport \ + $$PWD/../WebCore/bridge/qt \ + $$PWD/../WebCore/page/qt \ + $$PWD/../WebCore/platform/graphics/qt \ + $$PWD/../WebCore/platform/network/qt \ + $$PWD/../WebCore/platform/qt \ + $$PWD/../WebKit/qt/Api \ + $$PWD/../WebKit/qt/WebCoreSupport \ $$WEBKIT2_INCLUDEPATH WEBKIT2_INCLUDEPATH = \ @@ -171,7 +170,7 @@ symbian { INCLUDEPATH = $$WEBKIT2_INCLUDEPATH $$INCLUDEPATH } -PREFIX_HEADER = $$PWD/../../Source/WebKit2/WebKit2Prefix.h +PREFIX_HEADER = $$PWD/../WebKit2/WebKit2Prefix.h *-g++*:QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER" WEBKIT2_GENERATED_HEADERS = \ diff --git a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj index 20143f5..b83c16c 100644 --- a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj +++ b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj @@ -661,6 +661,9 @@ C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */ = {isa = PBXBuildFile; fileRef = C0E3AA441209E2BA00A49D01 /* Module.h */; }; C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */ = {isa = PBXBuildFile; fileRef = C517388012DF8F4F00EE3F47 /* DragControllerAction.h */; }; C5237F6012441CA300780472 /* WebEditorClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C5237F5F12441CA300780472 /* WebEditorClientMac.mm */; }; + C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */; }; + C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = C574A57F12E66681002DFE98 /* PasteboardTypes.h */; }; + C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = C574A58012E66681002DFE98 /* PasteboardTypes.mm */; }; D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */; }; D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484311FF4B6500032B39 /* WebPopupMenu.h */; }; D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */; }; @@ -1421,6 +1424,9 @@ C0E3AA481209E45000A49D01 /* ModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModuleMac.mm; sourceTree = "<group>"; }; C517388012DF8F4F00EE3F47 /* DragControllerAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragControllerAction.h; sourceTree = "<group>"; }; C5237F5F12441CA300780472 /* WebEditorClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebEditorClientMac.mm; sourceTree = "<group>"; }; + C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDragClientMac.mm; sourceTree = "<group>"; }; + C574A57F12E66681002DFE98 /* PasteboardTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardTypes.h; sourceTree = "<group>"; }; + C574A58012E66681002DFE98 /* PasteboardTypes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteboardTypes.mm; sourceTree = "<group>"; }; D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPopupMenu.cpp; sourceTree = "<group>"; }; D3B9484311FF4B6500032B39 /* WebPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenu.h; sourceTree = "<group>"; }; D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSearchPopupMenu.cpp; sourceTree = "<group>"; }; @@ -2267,6 +2273,7 @@ BC111ADE112F5B9A00337BAB /* mac */ = { isa = PBXGroup; children = ( + C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */, 51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */, F6A25FD812ADC6BD00DC40CC /* WebDatabaseManagerMac.mm */, C5237F5F12441CA300780472 /* WebEditorClientMac.mm */, @@ -2322,6 +2329,8 @@ BC111B5A112F628200337BAB /* mac */ = { isa = PBXGroup; children = ( + C574A57F12E66681002DFE98 /* PasteboardTypes.h */, + C574A58012E66681002DFE98 /* PasteboardTypes.mm */, 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */, C02BFF1D1251502E009CCBEA /* NativeWebKeyboardEventMac.mm */, BCF505E61243047B005955AE /* PlatformCertificateInfo.mm */, @@ -3059,6 +3068,7 @@ 1A64256812DE42EC00CAAE2C /* BackingStore.h in Headers */, C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */, 1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */, + C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3520,6 +3530,8 @@ 1A64256912DE42EC00CAAE2C /* BackingStore.cpp in Sources */, 1A64292D12DE5F9800CAAE2C /* BackingStoreMac.mm in Sources */, 1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */, + C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */, + C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebKit2/WebKit2Prefix.h b/Source/WebKit2/WebKit2Prefix.h index 19bee7f..7ed70cb 100644 --- a/Source/WebKit2/WebKit2Prefix.h +++ b/Source/WebKit2/WebKit2Prefix.h @@ -58,6 +58,10 @@ static const type& name() \ #define JS_EXPORTDATA #define JS_EXPORTCLASS +// Disable notImplemented() warnings not to break layout tests. +// FIXME: WebKit2 logging system should behave identical to WebKit1. +#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1 + #elif defined(__APPLE__) #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) diff --git a/Source/WebKit2/WebProcess/Downloads/Download.h b/Source/WebKit2/WebProcess/Downloads/Download.h index 2319ec7..bacdd01 100644 --- a/Source/WebKit2/WebProcess/Downloads/Download.h +++ b/Source/WebKit2/WebProcess/Downloads/Download.h @@ -63,7 +63,6 @@ class WebPage; class Download : public CoreIPC::MessageSender<Download> { WTF_MAKE_NONCOPYABLE(Download); - public: static PassOwnPtr<Download> create(uint64_t downloadID, const WebCore::ResourceRequest&); ~Download(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index 9410642..f02044c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -85,6 +85,11 @@ JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef) return toImpl(frameRef)->jsContext(); } +WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context) +{ + return toAPI(WebFrame::frameForContext(context)); +} + JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frameRef, WKBundleScriptWorldRef worldRef) { return toImpl(frameRef)->jsContextForWorld(toImpl(worldRef)); @@ -197,3 +202,8 @@ WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frameRef) return toAPI(view->scrollOffset()); } + +WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) +{ + return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()))); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index a6a20b2..59c2d75 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -46,6 +46,8 @@ WK_EXPORT WKURLRef WKBundleFrameCopyProvisionalURL(WKBundleFrameRef frame); WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame); WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world); +WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef context); + WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world); WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef frame, WKBundleRangeHandleRef rangeHandle, WKBundleScriptWorldRef world); @@ -57,6 +59,8 @@ WK_EXPORT WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frame); WK_EXPORT WKRect WKBundleFrameGetVisibleContentBounds(WKBundleFrameRef frame); WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frame); +WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index 86d913b..bf853d1 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -49,6 +49,11 @@ WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef nodeHandleRef) return toAPI(toImpl(nodeHandleRef)->elementBounds()); } +WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandleRef, bool* isReplaced) +{ + return toAPI(toImpl(nodeHandleRef)->renderRect(isReplaced)); +} + void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandleRef, WKStringRef valueRef) { toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(toWTFString(valueRef)); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h index 854677b..8953ff8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h @@ -40,6 +40,8 @@ WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCreate(JSContextRef context, J /* Additional DOM Operations */ WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef nodeHandle); +WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandle, bool* isReplaced); + /* HTMLInputElement Specific Operations */ WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index e9370c6..6ee3b31 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -104,6 +104,11 @@ IntRect InjectedBundleNodeHandle::elementBounds() const return static_cast<Element*>(m_node.get())->boundsInWindowSpace(); } + +IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const +{ + return m_node.get()->renderRect(isReplaced); +} void InjectedBundleNodeHandle::setHTMLInputElementValueForUser(const String& value) { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h index eff4600..a02f7f2 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h @@ -56,6 +56,7 @@ public: // Additional DOM Operations // Note: These should only be operations that are not exposed to JavaScript. WebCore::IntRect elementBounds() const; + WebCore::IntRect renderRect(bool*) const; void setHTMLInputElementValueForUser(const String&); bool isHTMLInputElementAutofilled() const; void setHTMLInputElementAutofilled(bool); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h index 6737bd4..3518221 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h @@ -40,7 +40,8 @@ namespace WebKit { class NPRuntimeObjectMap; // NPJSObject is an NPObject that wraps a JSObject. -class NPJSObject : public NPObject, Noncopyable { +class NPJSObject : public NPObject { + WTF_MAKE_NONCOPYABLE(NPJSObject); public: static NPJSObject* create(NPRuntimeObjectMap* objectMap, JSC::JSObject* jsObject); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index 566d48d..ba21db1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -766,10 +766,11 @@ static void NPN_UnscheduleTimer(NPP instance, uint32_t timerID) } #if PLATFORM(MAC) -static NPError NPN_PopUpContextMenu(NPP instance, NPMenu* menu) +static NPError NPN_PopUpContextMenu(NPP npp, NPMenu* menu) { - notImplemented(); - return NPERR_GENERIC_ERROR; + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + + return plugin->popUpContextMenu(menu); } static NPBool NPN_ConvertPoint(NPP npp, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double* destX, double* destY, NPCoordinateSpace destSpace) diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index 0beade2..5674ba5 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -67,6 +67,7 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) #if PLATFORM(MAC) , m_drawingModel(static_cast<NPDrawingModel>(-1)) , m_eventModel(static_cast<NPEventModel>(-1)) + , m_currentMouseEvent(0) , m_pluginHasFocus(false) , m_windowHasFocus(false) #ifndef NP_NO_CARBON diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index fb5d37e..95ff714 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -54,6 +54,7 @@ public: NPError setDrawingModel(NPDrawingModel); NPError setEventModel(NPEventModel); NPBool convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double& destX, double& destY, NPCoordinateSpace destSpace); + NPError popUpContextMenu(NPMenu*); #ifndef NP_NO_CARBON WindowRef windowRef() const; @@ -205,6 +206,8 @@ private: NPEventModel m_eventModel; RetainPtr<PlatformLayer> m_pluginLayer; + NPCocoaEvent* m_currentMouseEvent; + bool m_pluginHasFocus; bool m_windowHasFocus; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm index 1240ed7..d57e8d1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm @@ -157,6 +157,20 @@ NPBool NetscapePlugin::convertPoint(double sourceX, double sourceY, NPCoordinate return true; } + +NPError NetscapePlugin::popUpContextMenu(NPMenu* npMenu) +{ + if (!m_currentMouseEvent) + return NPERR_GENERIC_ERROR; + + double screenX, screenY; + if (!convertPoint(m_currentMouseEvent->data.mouse.pluginX, m_currentMouseEvent->data.mouse.pluginY, NPCoordinateSpacePlugin, screenX, screenY, NPCoordinateSpaceScreen)) + ASSERT_NOT_REACHED(); + + WKPopupContextMenu(reinterpret_cast<NSMenu *>(npMenu), NSMakePoint(screenX, screenY)); + return NPERR_NO_ERROR; +} + #ifndef NP_NO_CARBON typedef HashMap<WindowRef, NetscapePlugin*> WindowMap; @@ -474,7 +488,19 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent) switch (m_eventModel) { case NPEventModelCocoa: { NPCocoaEvent event = initializeMouseEvent(mouseEvent, m_frameRect.location()); - return NPP_HandleEvent(&event); + + NPCocoaEvent* previousMouseEvent = m_currentMouseEvent; + m_currentMouseEvent = &event; + + // Protect against NPP_HandleEvent causing the plug-in to be destroyed, since we + // access m_currentMouseEvent afterwards. + RefPtr<NetscapePlugin> protect(this); + + bool returnValue = NPP_HandleEvent(&event); + + m_currentMouseEvent = previousMouseEvent; + + return returnValue; } #ifndef NP_NO_CARBON diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h index d7ba853..8b60f17 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h @@ -38,7 +38,8 @@ namespace WebKit { class PluginProcessConnection; -class PluginProcessConnectionManager : Noncopyable { +class PluginProcessConnectionManager { + WTF_MAKE_NONCOPYABLE(PluginProcessConnectionManager); public: static PluginProcessConnectionManager& shared(); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index ffca3fa..6da6c6e 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Redistribution and use in source and binary forms, with or without @@ -173,13 +173,12 @@ void WebChromeClient::show() bool WebChromeClient::canRunModal() { - notImplemented(); - return false; + return m_page->canRunModal(); } void WebChromeClient::runModal() { - notImplemented(); + m_page->runModal(); } void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible) @@ -364,16 +363,16 @@ void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool) m_page->drawingArea()->setNeedsDisplay(rect); } -void WebChromeClient::scroll(const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect&) +void WebChromeClient::scroll(const IntSize& scrollOffset, const IntRect& scrollRect, const IntRect& clipRect) { m_page->pageDidScroll(); - m_page->drawingArea()->scroll(scrollRect, scrollDelta); + m_page->drawingArea()->scroll(intersection(scrollRect, clipRect), scrollOffset); } #if ENABLE(TILED_BACKING_STORE) -void WebChromeClient::delegatedScrollRequested(const IntSize& scrollDelta) +void WebChromeClient::delegatedScrollRequested(const IntSize& scrollOffset) { - m_page->pageDidRequestScroll(scrollDelta); + m_page->pageDidRequestScroll(scrollOffset); } #endif @@ -466,9 +465,10 @@ void WebChromeClient::setToolTip(const String& toolTip, TextDirection) m_page->send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip)); } -void WebChromeClient::print(Frame*) +void WebChromeClient::print(Frame* frame) { - notImplemented(); + WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame(); + m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply()); } #if ENABLE(DATABASE) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h index 44c3658..d749833 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h @@ -107,9 +107,9 @@ private: virtual void invalidateWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); - virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); + virtual void scroll(const WebCore::IntSize& scrollOffset, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect); #if ENABLE(TILED_BACKING_STORE) - virtual void delegatedScrollRequested(const WebCore::IntSize& scrollDelta); + virtual void delegatedScrollRequested(const WebCore::IntSize& scrollOffset); #endif virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp index d11017f..e3d401d 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp @@ -50,6 +50,7 @@ DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& win return DragSourceActionAny; } +#if !PLATFORM(MAC) void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) { } @@ -59,6 +60,7 @@ DragImageRef WebDragClient::createDragImageForLink(KURL&, const String&, Frame*) notImplemented(); return 0; } +#endif void WebDragClient::dragControllerDestroyed() { diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h index ce123c8..6f7cf85 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h @@ -48,6 +48,9 @@ private: virtual void startDrag(WebCore::DragImageRef dragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, WebCore::Clipboard*, WebCore::Frame*, bool linkDrag = false); virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL&, const String& label, WebCore::Frame*); +#if PLATFORM(MAC) + virtual void declareAndWriteDragImage(NSPasteboard*, DOMElement*, NSURL*, NSString*, WebCore::Frame*); +#endif virtual void dragControllerDestroyed(); WebPage* m_page; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp index 4567f35..49b31ef 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp @@ -63,6 +63,13 @@ static String formatLocalizedString(String format, ...) RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); va_end(arguments); return result.get(); +#elif PLATFORM(QT) + va_list arguments; + va_start(arguments, format); + QString result; + result.vsprintf(format.latin1().data(), arguments); + va_end(arguments); + return result; #else notImplemented(); return format; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm new file mode 100644 index 0000000..9952e3f --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "PasteboardTypes.h" +#import "ShareableBitmap.h" +#import "WebCoreArgumentCoders.h" +#import "WebDragClient.h" +#import "WebPage.h" +#import "WebPageProxyMessages.h" +#import <WebCore/CachedImage.h> +#import <WebCore/DOMPrivate.h> +#import <WebCore/DOMElementInternal.h> +#import <WebCore/FrameView.h> +#import <WebCore/GraphicsContext.h> +#import <WebCore/LegacyWebArchive.h> +#import <WebCore/RenderImage.h> +#import <WebCore/StringTruncator.h> +#import <wtf/StdLibExtras.h> +#import <WebKit/WebKitNSStringExtras.h> +#import <WebKit/WebNSURLExtras.h> + +using namespace WebCore; + +namespace WebKit { + +const float DragLabelBorderX = 4; +//Keep border_y in synch with DragController::LinkDragBorderInset +const float DragLabelBorderY = 2; +const float DragLabelRadius = 5; +const float LabelBorderYOffset = 2; + +const float MinDragLabelWidthBeforeClip = 120; +const float MaxDragLabelWidth = 320; + +const float DragLinkLabelFontsize = 11; +const float DragLinkUrlFontSize = 10; + +using namespace WebCore; + +static Font& fontFromNSFont(NSFont *font) +{ + static NSFont *currentFont; + DEFINE_STATIC_LOCAL(Font, currentRenderer, ()); + + if ([font isEqual:currentFont]) + return currentRenderer; + if (currentFont) + CFRelease(currentFont); + currentFont = font; + CFRetain(currentFont); + currentRenderer = Font(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]); + return currentRenderer; +} + +void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) +{ + if (!frame) + return; + ASSERT(clipboard); + + NSImage *dragNSImage = dragImage.get(); + RefPtr<ShareableBitmap> dragShareableImage = ShareableBitmap::createShareable(IntSize([dragNSImage size])); + OwnPtr<GraphicsContext> graphicsContext = dragShareableImage->createGraphicsContext(); + + [NSGraphicsContext saveGraphicsState]; + NSGraphicsContext* bitmapContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]; + [NSGraphicsContext setCurrentContext: bitmapContext]; + + [dragNSImage drawInRect:NSMakeRect(0, 0, [dragNSImage size].width , [dragNSImage size].height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; + [NSGraphicsContext restoreGraphicsState]; + + SharedMemory::Handle handle; + if (!dragShareableImage->createHandle(handle)) + return; + IntPoint clientPoint(at); + m_page->send(Messages::WebPageProxy::SetDragImage(clientPoint, IntSize([dragNSImage size]), handle, linkDrag)); +} + +DragImageRef WebDragClient::createDragImageForLink(KURL& url, const String& title, Frame* frame) +{ + if (!frame) + return nil; + NSString *label = 0; + if (!title.isEmpty()) + label = title; + NSURL *cocoaURL = url; + NSString *urlString = [cocoaURL _web_userVisibleString]; + + BOOL drawURLString = YES; + BOOL clipURLString = NO; + BOOL clipLabelString = NO; + + if (!label) { + drawURLString = NO; + label = urlString; + } + + NSFont *labelFont = [[NSFontManager sharedFontManager] convertFont:[NSFont systemFontOfSize:DragLinkLabelFontsize] + toHaveTrait:NSBoldFontMask]; + NSFont *urlFont = [NSFont systemFontOfSize:DragLinkUrlFontSize]; + NSSize labelSize; + labelSize.width = [label _web_widthWithFont: labelFont]; + labelSize.height = [labelFont ascender] - [labelFont descender]; + if (labelSize.width > MaxDragLabelWidth){ + labelSize.width = MaxDragLabelWidth; + clipLabelString = YES; + } + + NSSize imageSize; + imageSize.width = labelSize.width + DragLabelBorderX * 2; + imageSize.height = labelSize.height + DragLabelBorderY * 2; + if (drawURLString) { + NSSize urlStringSize; + urlStringSize.width = [urlString _web_widthWithFont: urlFont]; + urlStringSize.height = [urlFont ascender] - [urlFont descender]; + imageSize.height += urlStringSize.height; + if (urlStringSize.width > MaxDragLabelWidth) { + imageSize.width = max(MaxDragLabelWidth + DragLabelBorderY * 2, MinDragLabelWidthBeforeClip); + clipURLString = YES; + } else + imageSize.width = max(labelSize.width + DragLabelBorderX * 2, urlStringSize.width + DragLabelBorderX * 2); + } + NSImage *dragImage = [[[NSImage alloc] initWithSize: imageSize] autorelease]; + [dragImage lockFocus]; + + [[NSColor colorWithDeviceRed: 0.7f green: 0.7f blue: 0.7f alpha: 0.8f] set]; + + // Drag a rectangle with rounded corners + NSBezierPath *path = [NSBezierPath bezierPath]; + [path appendBezierPathWithOvalInRect: NSMakeRect(0, 0, DragLabelRadius * 2, DragLabelRadius * 2)]; + [path appendBezierPathWithOvalInRect: NSMakeRect(0, imageSize.height - DragLabelRadius * 2, DragLabelRadius * 2, DragLabelRadius * 2)]; + [path appendBezierPathWithOvalInRect: NSMakeRect(imageSize.width - DragLabelRadius * 2, imageSize.height - DragLabelRadius * 2, DragLabelRadius * 2, DragLabelRadius * 2)]; + [path appendBezierPathWithOvalInRect: NSMakeRect(imageSize.width - DragLabelRadius * 2, 0, DragLabelRadius * 2, DragLabelRadius * 2)]; + + [path appendBezierPathWithRect: NSMakeRect(DragLabelRadius, 0, imageSize.width - DragLabelRadius * 2, imageSize.height)]; + [path appendBezierPathWithRect: NSMakeRect(0, DragLabelRadius, DragLabelRadius + 10, imageSize.height - 2 * DragLabelRadius)]; + [path appendBezierPathWithRect: NSMakeRect(imageSize.width - DragLabelRadius - 20, DragLabelRadius, DragLabelRadius + 20, imageSize.height - 2 * DragLabelRadius)]; + [path fill]; + + NSColor *topColor = [NSColor colorWithDeviceWhite:0.0f alpha:0.75f]; + NSColor *bottomColor = [NSColor colorWithDeviceWhite:1.0f alpha:0.5f]; + if (drawURLString) { + if (clipURLString) + //urlString = [WebStringTruncator centerTruncateString: urlString toWidth:imageSize.width - (DragLabelBorderX * 2) withFont:urlFont]; + urlString = StringTruncator::centerTruncate(urlString, imageSize.width - (DragLabelBorderX * 2), fontFromNSFont(urlFont)); + [urlString _web_drawDoubledAtPoint:NSMakePoint(DragLabelBorderX, DragLabelBorderY - [urlFont descender]) + withTopColor:topColor bottomColor:bottomColor font:urlFont]; + } + + if (clipLabelString) + //label = [WebStringTruncator rightTruncateString: label toWidth:imageSize.width - (DragLabelBorderX * 2) withFont:labelFont]; + label = StringTruncator::rightTruncate(label, imageSize.width - (DragLabelBorderX * 2), fontFromNSFont(labelFont)); + [label _web_drawDoubledAtPoint:NSMakePoint (DragLabelBorderX, imageSize.height - LabelBorderYOffset - [labelFont pointSize]) + withTopColor:topColor bottomColor:bottomColor font:labelFont]; + + [dragImage unlockFocus]; + + return dragImage; +} + +static void writeURL(NSPasteboard* pasteboard, NSURL* URL, NSString* title, NSArray* types) +{ + ASSERT(URL); + + if (![title length]) { + title = [[URL path] lastPathComponent]; + if (![title length]) + title = [URL _web_userVisibleString]; + } + + if ([types containsObject:NSURLPboardType]) + [URL writeToPasteboard:pasteboard]; + if ([types containsObject:PasteboardTypes::WebURLPboardType]) + [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType]; + if ([types containsObject:PasteboardTypes::WebURLNamePboardType]) + [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType]; + if ([types containsObject:NSStringPboardType]) + [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType]; + if ([types containsObject:PasteboardTypes::WebURLsWithTitlesPboardType]) { + NSArray* URLs = [NSArray arrayWithObject:URL]; + unsigned count = [URLs count]; + + if (!count || [pasteboard availableTypeFromArray:[NSArray arrayWithObject:PasteboardTypes::WebURLsWithTitlesPboardType]] == nil) + return; + + NSArray* titles = [NSArray arrayWithObject:title]; + + if (count != [titles count]) + titles = nil; + + NSMutableArray* URLStrings = [NSMutableArray arrayWithCapacity:count]; + NSMutableArray* titlesOrEmptyStrings = [NSMutableArray arrayWithCapacity:count]; + for (unsigned index = 0; index < count; ++index) { + [URLStrings addObject:[[URLs objectAtIndex:index] _web_originalDataAsString]]; + [titlesOrEmptyStrings addObject:(titles == nil) ? @"" : [[titles objectAtIndex:index] _webkit_stringByTrimmingWhitespace]]; + } + + [pasteboard setPropertyList:[NSArray arrayWithObjects:URLStrings, titlesOrEmptyStrings, nil] + forType:PasteboardTypes::WebURLsWithTitlesPboardType]; + } +} + +static void writeImage(NSPasteboard* pasteboard, NSImage *image, DOMElement* element, NSURL* URL, NSString* title, LegacyWebArchive* archive, NSArray* types) +{ + ASSERT(image || element); + ASSERT(URL); + + writeURL(pasteboard, URL, title, types); + + if ([types containsObject:NSTIFFPboardType]) { + // FIXME: we should add handling of promised types. + if (image) + [pasteboard setData:[image TIFFRepresentation] forType:NSTIFFPboardType]; + else if (element) + [pasteboard setData:[element _imageTIFFRepresentation] forType:NSTIFFPboardType]; + } + + if (archive && [types containsObject:PasteboardTypes::WebArchivePboardType]) + [pasteboard setData:[[(NSData *)archive->rawDataRepresentation().get() retain] autorelease] forType:PasteboardTypes::WebArchivePboardType]; +} + +void WebDragClient::declareAndWriteDragImage(NSPasteboard* pasteboard, DOMElement* element, NSURL* URL, NSString* title, WebCore::Frame*) +{ + ASSERT(element); + ASSERT(pasteboard && pasteboard == [NSPasteboard pasteboardWithName:NSDragPboard]); + + NSString *extension = @""; + if (RenderObject* renderer = core(element)->renderer()) { + if (renderer->isImage()) { + if (CachedImage* image = toRenderImage(renderer)->cachedImage()) { + extension = image->image()->filenameExtension(); + if (![extension length]) + return; + } + } + } + + RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(core(element)); + NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; + [types addObjectsFromArray:(archive) ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; + [pasteboard declareTypes:types owner:nil]; + writeImage(pasteboard, nil, element, URL, title, archive.get(), types); + [types release]; + + NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil]; + [pasteboard setPropertyList:extensions forType:NSFilesPromisePboardType]; + [extensions release]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 90b9a64..f81b627 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -93,6 +93,8 @@ void InitWebCoreSystemInterface(void) #if !defined(BUILDING_ON_SNOW_LEOPARD) INIT(CreateCTTypesetterWithUniCharProviderAndOptions); + INIT(MakeScrollbarPainter); + INIT(ScrollbarPainterPaint); #else INIT(GetHyphenationLocationBeforeIndex); #endif diff --git a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp index 513621c..d629ced 100644 --- a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp +++ b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.cpp @@ -49,7 +49,7 @@ ChunkedUpdateDrawingArea::~ChunkedUpdateDrawingArea() { } -void ChunkedUpdateDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void ChunkedUpdateDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { // FIXME: Do something much smarter. setNeedsDisplay(scrollRect); diff --git a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h index ac4b424..08aa3e7 100644 --- a/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/ChunkedUpdateDrawingArea.h @@ -40,7 +40,7 @@ public: virtual ~ChunkedUpdateDrawingArea(); virtual void setNeedsDisplay(const WebCore::IntRect&); - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual void display(); #if USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp index 3b76aaf..ea5b443 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp @@ -40,31 +40,33 @@ #include "TiledDrawingArea.h" #endif +#include "WebPageCreationParameters.h" + namespace WebKit { -PassRefPtr<DrawingArea> DrawingArea::create(DrawingAreaInfo::Type type, DrawingAreaInfo::Identifier identifier, WebPage* webPage) +PassRefPtr<DrawingArea> DrawingArea::create(WebPage* webPage, const WebPageCreationParameters& parameters) { - switch (type) { + switch (parameters.drawingAreaInfo.type) { case DrawingAreaInfo::None: ASSERT_NOT_REACHED(); break; case DrawingAreaInfo::Impl: #ifdef __APPLE__ - return DrawingAreaImpl::create(identifier, webPage); + return DrawingAreaImpl::create(webPage, parameters); #else return 0; #endif case DrawingAreaInfo::ChunkedUpdate: - return adoptRef(new ChunkedUpdateDrawingArea(identifier, webPage)); + return adoptRef(new ChunkedUpdateDrawingArea(parameters.drawingAreaInfo.identifier, webPage)); #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) case DrawingAreaInfo::LayerBacked: - return adoptRef(new LayerBackedDrawingArea(identifier, webPage)); + return adoptRef(new LayerBackedDrawingArea(parameters.drawingAreaInfo.identifier, webPage)); #endif #if ENABLE(TILED_BACKING_STORE) case DrawingAreaInfo::Tiled: - return adoptRef(new TiledDrawingArea(identifier, webPage)); + return adoptRef(new TiledDrawingArea(parameters.drawingAreaInfo.identifier, webPage)); #endif } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h index 75f0b00..713994d 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h @@ -40,11 +40,12 @@ namespace WebCore { namespace WebKit { class WebPage; +class WebPageCreationParameters; class DrawingArea : public RefCounted<DrawingArea> { public: // FIXME: It might make sense to move this create function into a factory style class. - static PassRefPtr<DrawingArea> create(DrawingAreaInfo::Type, DrawingAreaInfo::Identifier, WebPage*); + static PassRefPtr<DrawingArea> create(WebPage*, const WebPageCreationParameters&); virtual ~DrawingArea(); #ifdef __APPLE__ @@ -52,7 +53,7 @@ public: #endif virtual void setNeedsDisplay(const WebCore::IntRect&) = 0; - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) = 0; + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0; virtual void pageBackgroundTransparencyChanged() { } @@ -81,6 +82,8 @@ private: // FIXME: These should be pure virtual. virtual void setSize(const WebCore::IntSize&) { } virtual void didUpdate() { } + virtual void suspendPainting() { } + virtual void resumePainting() { } }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in b/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in index 6c628fb..682ef5a 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in @@ -22,5 +22,7 @@ messages -> DrawingArea { SetSize(WebCore::IntSize size) - DidUpdate() + DidUpdate() + SuspendPainting() + ResumePainting() } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index ab4655a..2063bd6 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -29,6 +29,7 @@ #include "ShareableBitmap.h" #include "UpdateInfo.h" #include "WebPage.h" +#include "WebPageCreationParameters.h" #include "WebProcess.h" #include <WebCore/GraphicsContext.h> @@ -40,18 +41,19 @@ using namespace WebCore; namespace WebKit { -PassRefPtr<DrawingAreaImpl> DrawingAreaImpl::create(DrawingAreaInfo::Identifier identifier, WebPage* webPage) +PassRefPtr<DrawingAreaImpl> DrawingAreaImpl::create(WebPage* webPage, const WebPageCreationParameters& parameters) { - return adoptRef(new DrawingAreaImpl(identifier, webPage)); + return adoptRef(new DrawingAreaImpl(webPage, parameters)); } DrawingAreaImpl::~DrawingAreaImpl() { } -DrawingAreaImpl::DrawingAreaImpl(DrawingAreaInfo::Identifier identifier, WebPage* webPage) - : DrawingArea(DrawingAreaInfo::Impl, identifier, webPage) +DrawingAreaImpl::DrawingAreaImpl(WebPage* webPage, const WebPageCreationParameters& parameters) + : DrawingArea(DrawingAreaInfo::Impl, parameters.drawingAreaInfo.identifier, webPage) , m_isWaitingForDidUpdate(false) + , m_isPaintingSuspended(!parameters.isVisible) , m_displayTimer(WebProcess::shared().runLoop(), this, &DrawingAreaImpl::display) { } @@ -65,7 +67,7 @@ void DrawingAreaImpl::setNeedsDisplay(const IntRect& rect) scheduleDisplay(); } -void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) { unsigned scrollArea = scrollRect.width() * scrollRect.height(); @@ -81,7 +83,7 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDel // Just repaint the entire current scroll rect, we'll scroll the new rect instead. setNeedsDisplay(m_scrollRect); m_scrollRect = IntRect(); - m_scrollDelta = IntSize(); + m_scrollOffset = IntSize(); } // Get the part of the dirty region that is in the scroll rect. @@ -92,19 +94,19 @@ void DrawingAreaImpl::scroll(const IntRect& scrollRect, const IntSize& scrollDel m_dirtyRegion.subtract(scrollRect); // Move the dirty parts. - Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect); + Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollOffset), scrollRect); // And add them back. m_dirtyRegion.unite(movedDirtyRegionInScrollRect); } // Compute the scroll repaint region. - Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta)); + Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollOffset)); m_dirtyRegion.unite(scrollRepaintRegion); m_scrollRect = scrollRect; - m_scrollDelta += scrollDelta; + m_scrollOffset += scrollOffset; } void DrawingAreaImpl::attachCompositingContext() @@ -139,9 +141,15 @@ void DrawingAreaImpl::setSize(const IntSize& size) m_webPage->setSize(size); m_webPage->layoutIfNeeded(); - // FIXME: Repaint. + UpdateInfo updateInfo; + + if (m_isPaintingSuspended) { + updateInfo.timestamp = currentTime(); + updateInfo.viewSize = m_webPage->size(); + } else + display(updateInfo); - m_webPage->send(Messages::DrawingAreaProxy::DidSetSize()); + m_webPage->send(Messages::DrawingAreaProxy::DidSetSize(updateInfo)); } void DrawingAreaImpl::didUpdate() @@ -152,11 +160,31 @@ void DrawingAreaImpl::didUpdate() display(); } +void DrawingAreaImpl::suspendPainting() +{ + ASSERT(!m_isPaintingSuspended); + + m_isPaintingSuspended = true; + m_displayTimer.stop(); +} + +void DrawingAreaImpl::resumePainting() +{ + ASSERT(m_isPaintingSuspended); + + m_isPaintingSuspended = false; + + // FIXME: Repaint if needed. +} + void DrawingAreaImpl::scheduleDisplay() { if (m_isWaitingForDidUpdate) return; + if (m_isPaintingSuspended) + return; + if (m_dirtyRegion.isEmpty()) return; @@ -168,6 +196,11 @@ void DrawingAreaImpl::scheduleDisplay() void DrawingAreaImpl::display() { + ASSERT(!m_isWaitingForDidUpdate); + + if (m_isPaintingSuspended) + return; + if (m_dirtyRegion.isEmpty()) return; @@ -201,6 +234,8 @@ static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>& void DrawingAreaImpl::display(UpdateInfo& updateInfo) { + ASSERT(!m_isPaintingSuspended); + // FIXME: It would be better if we could avoid painting altogether when there is a custom representation. if (m_webPage->mainFrameHasCustomRepresentation()) return; @@ -214,11 +249,11 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) } updateInfo.scrollRect = m_scrollRect; - updateInfo.scrollDelta = m_scrollDelta; + updateInfo.scrollOffset = m_scrollOffset; m_dirtyRegion = Region(); m_scrollRect = IntRect(); - m_scrollDelta = IntSize(); + m_scrollOffset = IntSize(); RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size()); if (!bitmap->createHandle(updateInfo.bitmapHandle)) @@ -228,6 +263,7 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) m_webPage->layoutIfNeeded(); + updateInfo.timestamp = currentTime(); updateInfo.viewSize = m_webPage->size(); updateInfo.updateRectBounds = bounds; diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index 1f1b2e2..e008adc 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -36,15 +36,15 @@ struct UpdateInfo; class DrawingAreaImpl : public DrawingArea { public: - static PassRefPtr<DrawingAreaImpl> create(DrawingAreaInfo::Identifier, WebPage*); + static PassRefPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&); virtual ~DrawingAreaImpl(); private: - DrawingAreaImpl(DrawingAreaInfo::Identifier, WebPage*); + DrawingAreaImpl(WebPage*, const WebPageCreationParameters&); // DrawingArea virtual void setNeedsDisplay(const WebCore::IntRect&); - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual void attachCompositingContext(); virtual void detachCompositingContext(); virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); @@ -55,6 +55,8 @@ private: // CoreIPC message handlers. virtual void setSize(const WebCore::IntSize&); virtual void didUpdate(); + virtual void suspendPainting(); + virtual void resumePainting(); void scheduleDisplay(); void display(); @@ -62,12 +64,16 @@ private: Region m_dirtyRegion; WebCore::IntRect m_scrollRect; - WebCore::IntSize m_scrollDelta; + WebCore::IntSize m_scrollOffset; // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the // web process won't paint more frequent than the UI process can handle. bool m_isWaitingForDidUpdate; - + + // Whether painting is suspended. We'll still keep track of the dirty region but we + // won't paint until painting has resumed again. + bool m_isPaintingSuspended; + RunLoop::Timer<DrawingAreaImpl> m_displayTimer; }; diff --git a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp index 8a81cca..b104b29 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.cpp @@ -34,6 +34,8 @@ #include "WebPage.h" #include "WebProcess.h" #include <WebCore/GraphicsLayer.h> +#include <WebCore/Page.h> +#include <WebCore/Settings.h> using namespace WebCore; @@ -45,6 +47,12 @@ LayerBackedDrawingArea::LayerBackedDrawingArea(DrawingAreaInfo::Identifier ident , m_attached(false) , m_shouldPaint(true) { + m_hostingLayer = GraphicsLayer::create(this); + m_hostingLayer->setDrawsContent(false); +#ifndef NDEBUG + m_hostingLayer->setName("DrawingArea hosting layer"); +#endif + m_hostingLayer->setSize(webPage->size()); m_backingLayer = GraphicsLayer::create(this); m_backingLayer->setDrawsContent(true); m_backingLayer->setContentsOpaque(webPage->drawsBackground() && !webPage->drawsTransparentBackground()); @@ -53,6 +61,7 @@ LayerBackedDrawingArea::LayerBackedDrawingArea(DrawingAreaInfo::Identifier ident m_backingLayer->setName("DrawingArea backing layer"); #endif m_backingLayer->setSize(webPage->size()); + m_hostingLayer->addChild(m_backingLayer.get()); platformInit(); } @@ -61,7 +70,7 @@ LayerBackedDrawingArea::~LayerBackedDrawingArea() platformClear(); } -void LayerBackedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +void LayerBackedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollOffset) { // FIXME: Do something much smarter. setNeedsDisplay(scrollRect); @@ -99,6 +108,7 @@ void LayerBackedDrawingArea::setSize(const IntSize& viewSize) ASSERT(m_shouldPaint); ASSERT_ARG(viewSize, !viewSize.isEmpty()); + m_hostingLayer->setSize(viewSize); m_backingLayer->setSize(viewSize); scheduleCompositingLayerSync(); @@ -183,14 +193,12 @@ void LayerBackedDrawingArea::paintContents(const GraphicsLayer*, GraphicsContext bool LayerBackedDrawingArea::showDebugBorders() const { - // FIXME: get from settings; - return false; + return m_webPage->corePage()->settings()->showDebugBorders(); } bool LayerBackedDrawingArea::showRepaintCounter() const { - // FIXME: get from settings; - return false; + return m_webPage->corePage()->settings()->showRepaintCounter(); } #if !PLATFORM(MAC) && !PLATFORM(WIN) diff --git a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h index 1b49de2..ed05cc7 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h @@ -56,7 +56,7 @@ public: virtual ~LayerBackedDrawingArea(); virtual void setNeedsDisplay(const WebCore::IntRect&); - virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta); + virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); virtual void display(); virtual void pageBackgroundTransparencyChanged(); @@ -106,6 +106,7 @@ private: RunLoop::Timer<LayerBackedDrawingArea> m_syncTimer; + OwnPtr<WebCore::GraphicsLayer> m_hostingLayer; OwnPtr<WebCore::GraphicsLayer> m_backingLayer; #if PLATFORM(MAC) #if HAVE(HOSTED_CORE_ANIMATION) diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp index c5f117e..42eacc1 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp @@ -34,9 +34,11 @@ #include "WebPageProxyMessages.h" #include "WebProcess.h" #include <JavaScriptCore/APICast.h> +#include <JavaScriptCore/JSContextRef.h> #include <JavaScriptCore/JSLock.h> #include <JavaScriptCore/JSValueRef.h> #include <WebCore/AnimationController.h> +#include <WebCore/ArchiveResource.h> #include <WebCore/CSSComputedStyleDeclaration.h> #include <WebCore/Chrome.h> #include <WebCore/DocumentLoader.h> @@ -455,6 +457,17 @@ JSGlobalContextRef WebFrame::jsContextForWorld(InjectedBundleScriptWorld* world) return toGlobalRef(m_coreFrame->script()->globalObject(world->coreWorld())->globalExec()); } +WebFrame* WebFrame::frameForContext(JSContextRef context) +{ + JSObjectRef globalObjectRef = JSContextGetGlobalObject(context); + JSC::JSObject* globalObjectObj = toJS(globalObjectRef); + if (strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell") != 0) + return 0; + + Frame* coreFrame = static_cast<JSDOMWindowShell*>(globalObjectObj)->window()->impl()->frame(); + return static_cast<WebFrameLoaderClient*>(coreFrame->loader()->client())->webFrame(); +} + JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, InjectedBundleScriptWorld* world) { JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld()); @@ -514,4 +527,20 @@ String WebFrame::provisionalURL() const return m_coreFrame->loader()->provisionalDocumentLoader()->url().string(); } +String WebFrame::suggestedFilenameForResourceWithURL(const KURL& url) const +{ + if (!m_coreFrame) + return String(); + + DocumentLoader* loader = m_coreFrame->loader()->documentLoader(); + if (!loader) + return String(); + + RefPtr<ArchiveResource> resource = loader->subresource(url); + if (!resource) + return String(); + + return resource->response().suggestedFilename(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.h b/Source/WebKit2/WebProcess/WebPage/WebFrame.h index 3ded6f6..f254e7a 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.h +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.h @@ -90,6 +90,8 @@ public: JSGlobalContextRef jsContext(); JSGlobalContextRef jsContextForWorld(InjectedBundleScriptWorld*); + static WebFrame* frameForContext(JSContextRef); + JSValueRef jsWrapperForWorld(InjectedBundleNodeHandle*, InjectedBundleScriptWorld*); JSValueRef jsWrapperForWorld(InjectedBundleRangeHandle*, InjectedBundleScriptWorld*); @@ -107,6 +109,7 @@ public: bool allowsFollowingLink(const WebCore::KURL&) const; String provisionalURL() const; + String suggestedFilenameForResourceWithURL(const WebCore::KURL&) const; // Simple listener class used by plug-ins to know when frames finish or fail loading. class LoadListener { diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 2259387..af236e9 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -37,6 +37,7 @@ #include "PluginProxy.h" #include "PluginView.h" #include "PrintInfo.h" +#include "RunLoop.h" #include "SessionState.h" #include "ShareableBitmap.h" #include "WebBackForwardList.h" @@ -149,6 +150,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_findController(this) , m_geolocationPermissionRequestManager(this) , m_pageID(pageID) + , m_canRunModal(parameters.canRunModal) + , m_isRunningModal(false) { ASSERT(m_pageID); @@ -182,7 +185,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) platformInitialize(); Settings::setMinDOMTimerInterval(0.004); - m_drawingArea = DrawingArea::create(parameters.drawingAreaInfo.type, parameters.drawingAreaInfo.identifier, this); + m_drawingArea = DrawingArea::create(this, parameters); m_mainFrame = WebFrame::createMainFrame(this); setDrawsBackground(parameters.drawsBackground); @@ -322,7 +325,9 @@ void WebPage::changeAcceleratedCompositingMode(WebCore::GraphicsLayer* layer) if (newDrawingAreaInfo.type != drawingArea()->info().type) { m_drawingArea = 0; if (newDrawingAreaInfo.type != DrawingAreaInfo::None) { - m_drawingArea = DrawingArea::create(newDrawingAreaInfo.type, newDrawingAreaInfo.identifier, this); + WebPageCreationParameters parameters; + parameters.drawingAreaInfo = newDrawingAreaInfo; + m_drawingArea = DrawingArea::create(this, parameters); m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize)); } } @@ -375,6 +380,11 @@ void WebPage::close() m_drawingArea.clear(); WebProcess::shared().removeWebPage(m_pageID); + + if (m_isRunningModal) { + m_isRunningModal = false; + WebProcess::shared().runLoop()->stop(); + } } void WebPage::tryClose() @@ -429,6 +439,15 @@ void WebPage::loadPlainTextString(const String& string) loadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL()); } +void WebPage::stopLoadingFrame(uint64_t frameID) +{ + WebFrame* frame = WebProcess::shared().webFrame(frameID); + if (!frame) + return; + + frame->coreFrame()->loader()->stopForUserCancel(); +} + void WebPage::stopLoading() { m_mainFrame->coreFrame()->loader()->stopForUserCancel(); @@ -1134,6 +1153,23 @@ void WebPage::getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID) send(Messages::WebPageProxy::DataCallback(dataReference, callbackID)); } +void WebPage::getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID) +{ + CoreIPC::DataReference dataReference; + + RefPtr<SharedBuffer> buffer; + if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) { + if (DocumentLoader* loader = frame->coreFrame()->loader()->documentLoader()) { + if (RefPtr<ArchiveResource> subresource = loader->subresource(KURL(KURL(), resourceURL))) { + if (buffer = subresource->data()) + dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size()); + } + } + } + + send(Messages::WebPageProxy::DataCallback(dataReference, callbackID)); +} + void WebPage::getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID) { CoreIPC::DataReference dataReference; @@ -1290,6 +1326,20 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli } } +void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation) +{ + IntPoint adjustedClientPosition(clientPosition.x() + m_page->dragController()->dragOffset().x(), clientPosition.y() + m_page->dragController()->dragOffset().y()); + IntPoint adjustedGlobalPosition(globalPosition.x() + m_page->dragController()->dragOffset().x(), globalPosition.y() + m_page->dragController()->dragOffset().y()); + + m_page->dragController()->dragEnded(); + FrameView* view = m_page->mainFrame()->view(); + if (!view) + return; + // FIXME: These are fake modifier keys here, but they should be real ones instead. + PlatformMouseEvent event(adjustedClientPosition, adjustedGlobalPosition, LeftButton, MouseEventMoved, 0, false, false, false, false, currentTime()); + m_page->mainFrame()->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation); +} + WebEditCommand* WebPage::webEditCommand(uint64_t commandID) { return m_editCommandMap.get(commandID).get(); @@ -1590,7 +1640,13 @@ void WebPage::SandboxExtensionTracker::beginLoad(WebFrame* frame, const SandboxE { ASSERT(frame->isMainFrame()); - ASSERT(!m_pendingProvisionalSandboxExtension); + // If we get two beginLoad calls in succession, without a provisional load starting, then + // m_pendingProvisionalSandboxExtension will be non-null. Invalidate and null out the extension if that is the case. + if (m_pendingProvisionalSandboxExtension) { + m_pendingProvisionalSandboxExtension->invalidate(); + m_pendingProvisionalSandboxExtension = nullptr; + } + m_pendingProvisionalSandboxExtension = SandboxExtension::create(handle); } @@ -1633,7 +1689,7 @@ void WebPage::SandboxExtensionTracker::didFailProvisionalLoad(WebFrame* frame) return; m_provisionalSandboxExtension->invalidate(); - m_provisionalSandboxExtension = 0; + m_provisionalSandboxExtension = nullptr; } bool WebPage::hasLocalDataForURL(const KURL& url) @@ -1754,4 +1810,17 @@ void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, Vect } #endif +void WebPage::runModal() +{ + if (m_isClosed) + return; + if (m_isRunningModal) + return; + + m_isRunningModal = true; + send(Messages::WebPageProxy::RunModal()); + RunLoop::run(); + ASSERT(!m_isRunningModal); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 7649ab6..d29400f 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -200,6 +200,7 @@ public: bool drawsTransparentBackground() const { return m_drawsTransparentBackground; } void stopLoading(); + void stopLoadingFrame(uint64_t frameID); void setDefersLoading(bool deferLoading); #if USE(ACCELERATED_COMPOSITING) @@ -300,6 +301,7 @@ public: void replaceSelectionWithText(WebCore::Frame*, const String&); void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags); + void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation); void beginPrinting(uint64_t frameID, const PrintInfo&); void endPrinting(); @@ -310,6 +312,9 @@ public: bool mainFrameHasCustomRepresentation() const; + bool canRunModal() const { return m_canRunModal; } + void runModal(); + private: WebPage(uint64_t pageID, const WebPageCreationParameters&); @@ -364,6 +369,7 @@ private: void getContentsAsString(uint64_t callbackID); void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID); + void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID); void getRenderTreeExternalRepresentation(uint64_t callbackID); void getSelectionOrContentsAsString(uint64_t callbackID); void getSourceForFrame(uint64_t frameID, uint64_t callbackID); @@ -492,6 +498,9 @@ private: SandboxExtensionTracker m_sandboxExtensionTracker; uint64_t m_pageID; + + bool m_canRunModal; + bool m_isRunningModal; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index bd6bf1a..e001864 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -46,6 +46,8 @@ messages -> WebPage { LoadURLRequest(WebCore::ResourceRequest request, WebKit::SandboxExtension::Handle sandboxExtensionHandle) Reload(bool reloadFromOrigin) StopLoading() + + StopLoadingFrame(uint64_t frameID) RestoreSessionAndNavigateToCurrentItem(WebKit::SessionState state) @@ -56,6 +58,7 @@ messages -> WebPage { # Callbacks. GetContentsAsString(uint64_t callbackID) GetMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID) + GetResourceDataFromFrame(uint64_t frameID, WTF::String resourceURL, uint64_t callbackID) GetRenderTreeExternalRepresentation(uint64_t callbackID) GetSelectionOrContentsAsString(uint64_t callbackID) GetSourceForFrame(uint64_t frameID, uint64_t callbackID) @@ -98,6 +101,7 @@ messages -> WebPage { # Drag and drop. PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags) + DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation) # Popup menu. DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex); diff --git a/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm index f8b7e71..24fa124 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/LayerBackedDrawingAreaMac.mm @@ -44,7 +44,7 @@ void LayerBackedDrawingArea::platformInit() { setUpUpdateLayoutRunLoopObserver(); - [m_backingLayer->platformLayer() setGeometryFlipped:YES]; + [m_hostingLayer->platformLayer() setGeometryFlipped:YES]; #if HAVE(HOSTED_CORE_ANIMATION) attachCompositingContext(); #endif @@ -80,7 +80,7 @@ void LayerBackedDrawingArea::attachCompositingContext() #if HAVE(HOSTED_CORE_ANIMATION) mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); m_remoteLayerRef = WKCARemoteLayerClientMakeWithServerPort(serverPort); - WKCARemoteLayerClientSetLayer(m_remoteLayerRef.get(), m_backingLayer->platformLayer()); + WKCARemoteLayerClientSetLayer(m_remoteLayerRef.get(), m_hostingLayer->platformLayer()); uint32_t contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerRef.get()); WebProcess::shared().connection()->sendSync(DrawingAreaProxyLegacyMessage::AttachCompositingContext, m_webPage->pageID(), CoreIPC::In(contextID), CoreIPC::Out()); @@ -115,9 +115,10 @@ void LayerBackedDrawingArea::scheduleCompositingLayerSync() void LayerBackedDrawingArea::syncCompositingLayers() { + m_hostingLayer->syncCompositingStateForThisLayerOnly(); m_backingLayer->syncCompositingStateForThisLayerOnly(); - bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateRecursive(); + bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); if (!didSync) { } diff --git a/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp index c07e1f5..cae79c2 100644 --- a/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp +++ b/Source/WebKit2/WebProcess/WebPage/win/LayerBackedDrawingAreaWin.cpp @@ -27,16 +27,6 @@ #include "LayerBackedDrawingArea.h" -#include "DrawingAreaProxyMessageKinds.h" -#include "WebPage.h" -#include "WebProcess.h" -#include <WebCore/Frame.h> -#include <WebCore/FrameView.h> -#include <WebCore/GraphicsLayer.h> -#include <WebCore/Page.h> -#include <WebCore/WKCACFLayerRenderer.h> -#include <WebCore/WebCoreInstanceHandle.h> - using namespace WebCore; namespace WebKit { diff --git a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb index 2123c95..df57bde 100644 --- a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb +++ b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb @@ -124,6 +124,10 @@ (allow process-fork) (allow process-exec (literal "/System/Library/Frameworks/QTKit.framework/Versions/A/Resources/QTKitServer") (with no-sandbox)) +;; FIXME: Once <rdar://problem/8900275> has been fixed, these rules can be removed. +(allow mach-lookup (global-name "com.apple.pubsub.ipc")) +(allow network-outbound (regex #"^/private/tmp/launch-[^/]+/Render")) + ;; FIXME: Investigate these. (allow appleevent-send (appleevent-destination "com.apple.WebProcess")) (allow mach-lookup (global-name-regex #"^EPPC-")) diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index c899fcb..d394c98 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -151,6 +151,12 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters { initializeSandbox(parameters); + if (!parameters.parentProcessName.isNull()) { + // FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized + NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parameters.parentProcessName]; + WKSetVisibleApplicationName((CFStringRef)applicationName); + } + if (!parameters.nsURLCachePath.isNull()) { NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity; NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity; diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm index 5cefb59..a44dc23 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm @@ -80,14 +80,6 @@ int WebProcessMain(const CommandLine& commandLine) WTF::initializeMainThread(); RunLoop::initializeMainRunLoop(); - // Set the visible application name. - String parentProcessName = commandLine["parentprocessname"]; - if (!parentProcessName.isNull()) { - // FIXME: Localization! - NSString *applicationName = [NSString stringWithFormat:@"%@ Web Content", (NSString *)parentProcessName]; - WKSetVisibleApplicationName((CFStringRef)applicationName); - } - // Create the connection. WebProcess::shared().initialize(serverPort, RunLoop::main()); |