diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebKit2 | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebKit2')
321 files changed, 13799 insertions, 2274 deletions
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index bacf704..fa45768 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,5070 @@ +2011-04-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + UI process thinks the page is unresponsive when a plug-in is showing a context menu + https://bugs.webkit.org/show_bug.cgi?id=58943 + <rdar://problem/9299901> + + Change the HandleMouseEvent message to have a delayed reply and make the PluginControllerProxy + respond to it immediately, before even passing the event to the plug-in. Since it doesn't matter + for mouse events whether the plug-in handled them or not we can do this. + + Another solution could have been to make handleMouseEvent an asynchronous message, but that could + mess up the message ordering so this seemed like the least intrusive change. + + * PluginProcess/PluginControllerProxy.cpp: + (WebKit::PluginControllerProxy::handleMouseEvent): + * PluginProcess/PluginControllerProxy.h: + * PluginProcess/PluginControllerProxy.messages.in: + +2011-04-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Terminate hung plug-in processes after 45 seconds + https://bugs.webkit.org/show_bug.cgi?id=58932 + <rdar://problem/8083219> + + * UIProcess/Plugins/PluginProcessManager.cpp: + (WebKit::PluginProcessManager::pluginSyncMessageSendTimedOut): + Find the plug-in process proxy and terminate it. + + (WebKit::PluginProcessManager::pluginProcessWithPath): + Add new helper function. + + (WebKit::PluginProcessManager::getOrCreatePluginProcess): + Call pluginProcessWithPath. + + * UIProcess/Plugins/PluginProcessProxy.cpp: + (WebKit::PluginProcessProxy::terminate): + Terminate the process. + + * UIProcess/Plugins/PluginProcessProxy.h: + * UIProcess/WebProcessProxy.cpp: + (WebKit::WebProcessProxy::pluginSyncMessageSendTimedOut): + Call PluginProcessManager::pluginSyncMessageSendTimedOut. + + * UIProcess/WebProcessProxy.h: + * UIProcess/WebProcessProxy.messages.in: + Add PluginSyncMessageSendTimedOut message. + + * WebProcess/Plugins/PluginProcessConnection.cpp: + (WebKit::defaultSyncMessageTimeout): + (WebKit::PluginProcessConnection::PluginProcessConnection): + Set a sync message timeout on the plug-in process connection. + + (WebKit::PluginProcessConnection::syncMessageSendTimedOut): + Send a message to the web process proxy. + +2011-04-19 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Adele Peterson. + + WebKit2: Merge SelectionState and TextInputState + https://bugs.webkit.org/show_bug.cgi?id=58919 + + Combined TextInputState and EditorState in one structure, which is updated whenever we get + a chance to. There is no sense to keep possibly stale SelectionState data when we have already + requested the most recent data synchronously. + + This also simplifies the code, as we don't need to pass the state around in a separate variable. + + * GNUmakefile.am: + * Scripts/webkit2/messages.py: + * Shared/EditorState.h: Copied from Source/WebKit2/Shared/SelectionState.h. + (WebKit::EditorState::EditorState): + * Shared/SelectionState.h: Removed. + * Shared/mac/TextInputState.h: Removed. + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::interpretKeyEvent): + * UIProcess/API/mac/WKView.mm: + (-[WKView validRequestorForSendType:returnType:]): + (-[WKView validateUserInterfaceItem:]): + (-[WKView shouldDelayWindowOrderingForEvent:]): + (-[WKView doCommandBySelector:]): + (-[WKView insertText:replacementRange:]): + (-[WKView _handleStyleKeyEquivalent:]): + (-[WKView _executeSavedKeypressCommands]): + (-[WKView inputContext]): + (-[WKView hasMarkedText]): + (-[WKView unmarkText]): + (-[WKView setMarkedText:selectedRange:replacementRange:]): + (-[WKView attributedSubstringForProposedRange:actualRange:]): + (-[WKView _interpretKeyEvent:savingCommandsTo:WebCore::]): + (-[WKView _updateSecureInputState]): + * UIProcess/API/mac/WKViewInternal.h: + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::editorStateChanged): + * UIProcess/WebPageProxy.h: + (WebKit::WebPageProxy::editorState): + (WebKit::WebPageProxy::hasSelectedRange): + (WebKit::WebPageProxy::isContentEditable): + * UIProcess/WebPageProxy.messages.in: + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::setComposition): + (WebKit::WebPageProxy::confirmComposition): + (WebKit::WebPageProxy::insertText): + (WebKit::WebPageProxy::executeKeypressCommands): + (WebKit::WebPageProxy::writeSelectionToPasteboard): + (WebKit::WebPageProxy::readSelectionFromPasteboard): + (WebKit::WebPageProxy::interpretQueuedKeyEvent): + * UIProcess/win/WebView.cpp: + (WebKit::WebView::compositionSelectionChanged): + (WebKit::WebView::onIMEComposition): + (WebKit::WebView::onIMEEndComposition): + (WebKit::WebView::onIMERequestCharPosition): + (WebKit::WebView::onIMERequest): + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::respondToChangedSelection): + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::editorState): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::handleEditingKeyboardEvent): + (WebKit::WebPage::setComposition): + (WebKit::WebPage::confirmComposition): + (WebKit::WebPage::insertText): + (WebKit::WebPage::executeKeypressCommands): + * win/WebKit2.vcproj: + +2011-04-19 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Timothy Hatcher. + + 100% reproducible crash when right-clicking any element in Web Inspector on any page + https://bugs.webkit.org/show_bug.cgi?id=58822 + + Web Inspector changes selection from JavaScript, and checks in UI process are insufficient + when selection is changing asynchronously. + + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::writeSelectionToPasteboard): Check that there is a selection, matching WK1 + and UI process side. Perhaps the check should really be in WebCore, but for now, it's a + WebKit responsibility. + (WebKit::WebPage::readSelectionFromPasteboard): Same check, for no other reason but consistency. + +2011-04-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add syncMessageSendTimedOut CoreIPC Connection::Client member function + https://bugs.webkit.org/show_bug.cgi?id=58928 + + * Platform/CoreIPC/Connection.cpp: + (CoreIPC::Connection::waitForSyncReply): + Call syncMessageSendTimedOut. + + * Platform/CoreIPC/Connection.h: + Add syncMessageSendTimedOut to Connection::Client. + + * PluginProcess/PluginProcess.cpp: + * PluginProcess/PluginProcess.h: + * PluginProcess/WebProcessConnection.cpp: + * PluginProcess/WebProcessConnection.h: + * UIProcess/Plugins/PluginProcessProxy.cpp: + * UIProcess/Plugins/PluginProcessProxy.h: + * UIProcess/WebProcessProxy.cpp: + * UIProcess/WebProcessProxy.h: + * WebProcess/Plugins/PluginProcessConnection.cpp: + * WebProcess/Plugins/PluginProcessConnection.h: + * WebProcess/WebProcess.cpp: + * WebProcess/WebProcess.h: + Add syncMessageSendTimedOut stubs. + +2011-04-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Alexey Proskuryakov. + + Replace the didFailToSendSyncMessage Connection::Client function with a flag + https://bugs.webkit.org/show_bug.cgi?id=58923 + + * Platform/CoreIPC/Connection.cpp: + (CoreIPC::Connection::Connection): + Initialize m_shouldExitOnSyncMessageSendFailure to false. + + (CoreIPC::Connection::setShouldExitOnSyncMessageSendFailure): + Set m_didCloseOnConnectionWorkQueueCallback. + + (CoreIPC::Connection::sendSyncMessage): + Call didFailToSendSyncMessage if we fail to send the sync message for some reason. + + (CoreIPC::Connection::didFailToSendSyncMessage): + if m_shouldExitOnSyncMessageSendFailure is true, exit. + + * Platform/CoreIPC/Connection.h: + Remove didFailToSendSyncMessage from Connection::Client. + + * PluginProcess/PluginProcess.cpp: + * PluginProcess/PluginProcess.h: + Remove didFailToSendSyncMessage. + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::initialize): + * WebProcess/WebProcess.h: + Remove didFailToSendSyncMessage. Call setShouldExitOnSyncMessageSendFailure on our + UI process connection. + +2011-04-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add a way to set the default sync message timeout for a CoreIPC connection + https://bugs.webkit.org/show_bug.cgi?id=58908 + + * Platform/CoreIPC/Connection.cpp: + (CoreIPC::Connection::Connection): + Initialize m_defaultSyncMessageTimeout. + + (CoreIPC::Connection::setDefaultSyncMessageTimeout): + Set the m_defaultSyncMessageTimeout member variable. + + (CoreIPC::Connection::waitForSyncReply): + Handle the timeout being one of our two special magic values. + + * Platform/CoreIPC/Connection.h: + Add a DefaultTimeout constant and change the NoTimeout constant to be -1. + +2011-04-19 Vsevolod Vlasov <vsevik@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: Rename lengthReceived to encodedDataLength/dataLength + https://bugs.webkit.org/show_bug.cgi?id=58883 + + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + (WebKit::WebFrameLoaderClient::dispatchDidReceiveContentLength): + * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: + +2011-04-19 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Antonio Gomes. + + WebKit2: Typo fix in WebPopupMenu::Type. + https://bugs.webkit.org/show_bug.cgi?id=58891 + + Fixed a typo, Seperator -> Separator. + Also removed m_ prefix on an argument variable name. + + * Shared/WebPopupItem.h: + * UIProcess/mac/WebPopupMenuProxyMac.mm: + (WebKit::WebPopupMenuProxyMac::populate): + * WebProcess/WebCoreSupport/WebPopupMenu.cpp: + (WebKit::WebPopupMenu::populateItems): + +2011-04-19 Jon Honeycutt <jhoneycutt@apple.com> + + WKContextDownloadURLRequest() should return a WKDownloadRef + https://bugs.webkit.org/show_bug.cgi?id=58867 + Part of <rdar://problem/8931717> + + Reviewed by Steve Falkenburg. + + * UIProcess/API/C/WKContext.cpp: + (WKContextDownloadURLRequest): + Return the result of calling WebContext::download(). + + * UIProcess/API/C/WKContext.h: + Updated return type of WKContextDownloadURLRequest(). + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::download): + Return the DownloadProxy returned by createDownloadProxy(). + (WebKit::WebContext::createDownloadProxy): + Return the DownloadProxy. + + * UIProcess/WebContext.h: + Changed return type of download() and createDownloadProxy(). + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::receivedPolicyDecision): + Call the DownloadProxy's downloadID() function to get the ID. + +2011-04-18 Jia Pu <jpu@apple.com> + + Reviewed by Mark Rowe. + + WebKit needs to stop importing <AppKit/NSTextChecker.h> + https://bugs.webkit.org/show_bug.cgi?id=58798 + <rdar://problem/9294938> + + Use public header <AppKit/NSSpellChecker.h> instead. + + * UIProcess/mac/CorrectionPanel.h: + * UIProcess/mac/CorrectionPanel.mm: + (correctionIndicatorType): + (WebKit::CorrectionPanel::show): + (WebKit::CorrectionPanel::dismissInternal): + (WebKit::CorrectionPanel::handleAcceptedReplacement): + * UIProcess/mac/TextCheckerMac.mm: + * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: + +2011-04-05 Jer Noble <jer.noble@apple.com> + + Reviewed by Sam Weinig. + + WebKit2: WKTR should support WebKit2 full screen APIs + https://bugs.webkit.org/show_bug.cgi?id=56318 + + Add a new WKBundlePage API for Full Screen events, and move some of the implementation + of WebFullScreenManager into the new InjectedBundlePageFullScreenClient class, so that + the default behavior can be overridden by a WKBundlePageFullScreenClient. + + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/FullScreen/WebFullScreenManager.cpp: + (WebKit::WebFullScreenManager::supportsFullScreen): Moved contents into InjectedBundlePageFullScreenClient. + (WebKit::WebFullScreenManager::enterFullScreenForElement): Ditto. + (WebKit::WebFullScreenManager::exitFullScreenForElement): Ditto. + * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: + (WKBundlePageSetFullScreenClient): Added. + (WKBundlePageWillEnterFullScreenForElement): Added. + (WKBundlePageDidEnterFullScreenForElement): Added. + (WKBundlePageWillExitFullScreenForElement): Added. + (WKBundlePageDidExitFullScreenForElement): Added. + * WebProcess/InjectedBundle/API/c/WKBundlePage.h: + * WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp: Added. + (WebKit::InjectedBundlePageFullScreenClient::supportsFullScreen): Added. + (WebKit::InjectedBundlePageFullScreenClient::enterFullScreenForElement): Added. + (WebKit::InjectedBundlePageFullScreenClient::exitFullScreenForElement): Added. + * WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h: Added. + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::initializeInjectedBundleFullScreenClient): Added. + * WebProcess/WebPage/WebPage.h: + (WebKit::WebPage::injectedBundleFullScreenClient): Added. + +2011-04-18 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Maciej Stachowiak. + + Re-add a null check lost in r83081 + https://bugs.webkit.org/show_bug.cgi?id=58846 + + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::getSelectedRange): + +2011-04-18 Andreas Kling <kling@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt][WK2] Clean up tool-tip/status-bar confusion. + https://bugs.webkit.org/show_bug.cgi?id=58844 + + Tool-tips were incorrectly hooked up to the status bar text. + Chrome::setStatusbarText() now correctly causes the QWKPage::statusBarMessage() signal. + + New API: + - QWKPage::toolTipChanged(const QString& toolTip) [signal] + + QGraphicsWKView will automatically listen for this and set its own toolTip(). + + * UIProcess/API/qt/ClientImpl.cpp: + (qt_wk_setStatusText): + * UIProcess/API/qt/ClientImpl.h: + * UIProcess/API/qt/qgraphicswkview.cpp: + (QGraphicsWKView::QGraphicsWKView): + (QGraphicsWKViewPrivate::onToolTipChanged): + * UIProcess/API/qt/qgraphicswkview.h: + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::toolTipChanged): + (QWKPage::QWKPage): + * UIProcess/API/qt/qwkpage.h: + +2011-04-18 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Dan Bernstein. + + sandbox violation for ~/Library/Dictionaries + https://bugs.webkit.org/show_bug.cgi?id=58841 + <rdar://problem/9294770> + + * WebProcess/com.apple.WebProcess.sb: Add to sandbox profile. + No obvious harm from allowing this, though it's not 100% clear + why it's needed. + +2011-04-18 Anders Carlsson <andersca@apple.com> + + Try to fix the Windows build. + + * Scripts/webkit2/messages.py: + +2011-04-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Get rid of WebProcessProxyLegacyMessage + https://bugs.webkit.org/show_bug.cgi?id=58825 + + * GNUmakefile.am: + * Platform/CoreIPC/MessageID.h: + * Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h: Removed. + * UIProcess/WebProcessProxy.cpp: + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/Plugins/PluginProcessConnectionManager.cpp: + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + * WebProcess/WebPage/WebPage.cpp: + * win/WebKit2.vcproj: + +2011-04-18 Anders Carlsson <andersca@apple.com> + + Fix build. + + * UIProcess/Plugins/PluginInfoStore.h: + +2011-04-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Use the message generator for the GetPluginProcessConnection message + https://bugs.webkit.org/show_bug.cgi?id=58815 + + * Platform/CoreIPC/HandleMessage.h: + (CoreIPC::callMemberFunction): + (CoreIPC::handleMessageDelayed): + Add helper functions. + + * UIProcess/Plugins/PluginInfoStore.h: + Mark class noncopyable. + + * UIProcess/Plugins/PluginProcessManager.cpp: + (WebKit::PluginProcessManager::getPluginProcessConnection): + This now takes a delayed reply. + + * UIProcess/Plugins/PluginProcessProxy.cpp: + (WebKit::PluginProcessProxy::getPluginProcessConnection): + This now takes a delayed reply. + + (WebKit::PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch): + (WebKit::PluginProcessProxy::didCreateWebProcessConnection): + Call DelayedReply::send. + + * UIProcess/WebProcessProxy.cpp: + (WebKit::WebProcessProxy::getPluginProcessConnection): + This now takes a delayed reply. + + (WebKit::WebProcessProxy::didReceiveSyncMessage): + No need to handle this message here. + + * UIProcess/WebProcessProxy.messages.in: + Add GetPluginProcessConnection message. + + * WebProcess/Plugins/PluginProcessConnectionManager.cpp: + (WebKit::PluginProcessConnectionManager::getPluginProcessConnection): + Don't use deprecatedSendSync. + +2011-04-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Finish implementing delayed sync replies in the CoreIPC message generator + https://bugs.webkit.org/show_bug.cgi?id=58814 + + Put the DelayedReply function definitions in the .cpp file and fix bugs found by + actually trying to compile the generated files. + + * Scripts/webkit2/messages.py: + * Scripts/webkit2/messages_unittest.py: + +2011-04-18 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Reproducible crash in Find on Page, on pages that use accelerated compositing + https://bugs.webkit.org/show_bug.cgi?id=58793 + <rdar://problem/9295870> + + Move the call to PageOverlay::setNeedsDisplay() back to WebPage::installPageOverlay; + it needs to be called after we've told the drawing area that a page overlay has been installed. + + * WebProcess/WebPage/PageOverlay.cpp: + (WebKit::PageOverlay::setPage): + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::installPageOverlay): + +2011-04-18 Jeff Miller <jeffm@apple.com> + + Reviewed by Timothy Hatcher. + + WKFrameLoadState should be a uint32_t to match our API conventions + https://bugs.webkit.org/show_bug.cgi?id=58785 + + * UIProcess/API/C/WKFrame.h: typedef WKFrameLoadState as a uint32_t and define its values as an anonymous enum. + +2011-04-18 Carlos Garcia Campos <cgarcia@igalia.com> + + Unreviewed. Fix WebKit2 GTK build after 84017. + + * GNUmakefile.am: + * Shared/NativeWebMouseEvent.h: + (WebKit::NativeWebMouseEvent::nativeEvent): + * Shared/gtk/NativeWebMouseEventGtk.cpp: Copied from Source/WebKit2/Shared/NativeWebMouseEvent.h. + (WebKit::NativeWebMouseEvent::NativeWebMouseEvent): + * UIProcess/gtk/WebView.cpp: + (WebKit::WebView::handleMouseEvent): + +2011-04-17 David Kilzer <ddkilzer@apple.com> + + <http://webkit.org/b/58463> Switch HTTP pipelining from user default to private setting + <rdar://problem/9268729> + + Reviewed by Dan Bernstein. + + This replaces support for the WebKitEnableHTTPPipelining user + default with methods on the WebCore::ResourceRequest class in + WebCore, the WebView class in WebKit1, and the WebContext class + in WebKit2. It also removes support for the + WebKitForceHTTPPipeliningPriorityHigh user default which was not + needed. + + * UIProcess/API/C/WKContext.cpp: + (_WKContextSetHTTPPipeliningEnabled): Added. + * UIProcess/API/C/WKContextPrivate.h: + (_WKContextSetHTTPPipeliningEnabled): Added declaration. + * UIProcess/WebContext.cpp: + (WebKit::WebContext::setHTTPPipeliningEnabled): Added. + (WebKit::WebContext::httpPipeliningEnabled): Added. + * UIProcess/WebContext.h: + (WebKit::WebContext::setHTTPPipeliningEnabled): Added declaration. + (WebKit::WebContext::httpPipeliningEnabled): Added declaration. + +2011-04-17 Sam Weinig <sam@webkit.org> + + Reviewed by Geoffrey Garen. + + Make more strings in WebKit2 localizable + https://bugs.webkit.org/show_bug.cgi?id=58757 + + * UIProcess/API/mac/PDFViewController.mm: + (-[WKPDFView menuForEvent:]): + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::setViewportArguments): + (WebKit::PageClientImpl::registerEditCommand): + * UIProcess/WebEditCommandProxy.cpp: + (WebKit::WebEditCommandProxy::nameForEditAction): + * UIProcess/WebEditCommandProxy.h: + Use WebCore's localization macro to make more strings localizable. + +2011-04-17 Patrick Gansterer <paroga@webkit.org> + + Reviewed by Adam Barth. + + Rename PLATFORM(CA) to USE(CA) + https://bugs.webkit.org/show_bug.cgi?id=58742 + + * WebProcess/WebPage/LayerTreeHost.cpp: + * WebProcess/WebPage/win/LayerTreeHostWin.cpp: + (WebKit::LayerTreeHost::supportsAcceleratedCompositing): + +2011-04-17 Patrick Gansterer <paroga@webkit.org> + + Reviewed by Adam Barth. + + Rename PLATFORM(CG) to USE(CG) + https://bugs.webkit.org/show_bug.cgi?id=58729 + + * Shared/ShareableBitmap.h: + * Shared/WebCoreArgumentCoders.cpp: + * Shared/WebCoreArgumentCoders.h: + * Shared/WebGraphicsContext.cpp: + (WebKit::WebGraphicsContext::WebGraphicsContext): + * Shared/WebGraphicsContext.h: + * Shared/win/PlatformCertificateInfo.cpp: + (WebKit::PlatformCertificateInfo::PlatformCertificateInfo): + * UIProcess/win/WebView.cpp: + (WebKit::WebView::setFindIndicator): + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::drawRectToPDF): + (WebKit::WebPage::drawPagesToPDF): + * WebProcess/WebPage/win/WebPageWin.cpp: + (WebKit::WebPage::platformPreferencesDidChange): + * config.h: + +2011-04-16 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Crash when NPP_Write returns -1 when writing the manual stream + https://bugs.webkit.org/show_bug.cgi?id=58735 + <rdar://problem/9124993> + + If NPP_Write returns -1 we must cancel the stream. + + * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: + (WebKit::NetscapePluginStream::deliverDataToPlugin): + +2011-04-16 Sam Weinig <sam@webkit.org> + + Reviewed by Simon Fraser. + + Pages in the PageCache don't have the correct visited link coloring after being restored + https://bugs.webkit.org/show_bug.cgi?id=58721 + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::visitedLinkStateChanged): + (WebKit::WebProcess::allVisitedLinkStateChanged): + Mark all pages in the page cache as needing visited link style recalc + whenever visited link information changes. + +2011-04-15 Daniel Bates <dbates@webkit.org> + + Attempt to fix the Qt Linux Release build after changeset 84064 <http://trac.webkit.org/changeset/84064> + (https://bugs.webkit.org/show_bug.cgi?id=58686). + + * UIProcess/API/qt/qwkpage_p.h: Remove takeFocus(). + +2011-04-15 Shishir Agrawal <shishir@chromium.org> + + Reviewed by James Robinson. + + Add a flag to guard Page Visibility API changes. + https://bugs.webkit.org/show_bug.cgi?id=58464 + + * Configurations/FeatureDefines.xcconfig: + +2011-04-15 Jeff Miller <jeffm@apple.com> + + Reviewed by Sam Weinig. + + Add takeFocus callback to WKPageUIClient + https://bugs.webkit.org/show_bug.cgi?id=58686 + + On Windows, we need to handle moving focus out of the web view in the client, so add a takeFocus callback to WKPageUIClient + and stop handling taking focus in the framework in WKView.mm on the Mac. + + * UIProcess/API/C/WKPage.h: Added WKFocusDirection enum and takeFocus to WKPageUIClient. + * UIProcess/API/mac/PageClientImpl.h: Removed takeFocus(). + * UIProcess/API/mac/PageClientImpl.mm: Removed takeFocus(). + * UIProcess/API/mac/WKView.mm: Removed _takeFocus(). + * UIProcess/API/mac/WKViewInternal.h: Removed _takeFocus(). + * UIProcess/API/qt/ClientImpl.cpp: + (qt_wk_takeFocus): Added. + * UIProcess/API/qt/ClientImpl.h: Added qt_wk_takeFocus. + * UIProcess/API/qt/qwkpage.cpp: Remove takeFocus(). + (QWKPage::QWKPage): Added takeFocus() callback. + * UIProcess/PageClient.h: Removed takeFocus(). + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::takeFocus): Call m_uiClient to take focus. + * UIProcess/WebPageProxy.h: Pass FocusDirection as a uint32_t to takeFocus(). + * UIProcess/WebPageProxy.messages.in: Pass FocusDirection as a uint32_t in TakeFocus message. + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::takeFocus): Added. + * UIProcess/WebUIClient.h: Added takeFocus(). + * UIProcess/win/WebView.cpp: Removed takeFocus(), which was never implemented on Windows. + * UIProcess/win/WebView.h: Removed takeFocus(). + * WebProcess/WebCoreSupport/WebChromeClient.cpp: + (WebKit::WebChromeClient::takeFocus): Pass FocusDirection as a uint32_t in TakeFocus message. + +2011-04-15 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Sam Weinig. + + WebKit2: Stop using deprecated NSInputManager + https://bugs.webkit.org/show_bug.cgi?id=58709 + + Changed all mouse related functions to give NSInputContext a chance to handle the event, + added logging. Removed -rightMouseMoved: method, which was added by accident. + + * UIProcess/API/mac/WKView.mm: + (-[WKView mouseMoved:]): + (-[WKView mouseDown:]): + (-[WKView mouseUp:]): + (-[WKView mouseDragged:]): + +2011-04-15 Jon Honeycutt <jhoneycutt@apple.com> + + Potential crash getting a JS wrapper. + + <rdar://problem/8988741> + + Reviewed by Brian Weinstein. + + * WebProcess/WebPage/WebFrame.cpp: + (WebKit::WebFrame::jsWrapperForWorld): + Ensure that we have a valid m_coreFrame, because it can be cleared by + invalidate(). + +2011-04-08 Luiz Agostini <luiz.agostini@openbossa.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] QWebPage MIME type handling inconsistency with other web browsers + https://bugs.webkit.org/show_bug.cgi?id=46968 + + Implementing mime type sniffing based on + http://tools.ietf.org/html/draft-abarth-mime-sniff-06. + + * WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp: + (WebCore::WebFrameNetworkingContext::WebFrameNetworkingContext): + (WebCore::WebFrameNetworkingContext::MIMESniffingEnabled): + * WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h: + +2011-04-15 Oliver Hunt <oliver@apple.com> + + GC allocate Structure + https://bugs.webkit.org/show_bug.cgi?id=58483 + + Rolling r83894 r83827 r83810 r83809 r83808 back in with + a workaround for the gcc bug seen by the gtk bots + + * WebProcess/Plugins/Netscape/JSNPMethod.h: + (WebKit::JSNPMethod::createStructure): + * WebProcess/Plugins/Netscape/JSNPObject.h: + (WebKit::JSNPObject::createStructure): + +2011-04-15 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add API to get the bundle page overlay fade in fraction. + + * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp: + (WKBundlePageOverlayFractionFadedIn): + * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h: + +2011-04-15 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Fade the find page overlay + https://bugs.webkit.org/show_bug.cgi?id=58697 + + * WebProcess/WebPage/FindController.cpp: + Make the color components floats. + + (WebKit::overlayBackgroundColor): + (WebKit::holeShadowColor): + (WebKit::holeFillColor): + Add helper functions for returning the colors given the fraction faded in. + + (WebKit::FindController::drawRect): + Use the new helper functions. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::installPageOverlay): + Start the fade animation unless we're replacing an already existing page overlay + with another. + +2011-04-15 Anders Carlsson <andersca@apple.com> + + Fix Windows build. + + * WebProcess/WebPage/PageOverlay.cpp: + (WebKit::PageOverlay::fadeAnimationTimerFired): + +2011-04-15 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add the ability for PageOverlays to fade in and out + https://bugs.webkit.org/show_bug.cgi?id=58694 + + * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: + (WKBundlePageUninstallPageOverlay): + WebPage::uninstallPageOverlay now takes a boolean. Default to false for now. + + * WebProcess/WebPage/FindController.cpp: + (WebKit::FindController::findString): + Pass false to uninstallPageOverlay. + + (WebKit::FindController::hideFindUI): + Pass true to uninstallPageOverlay. + + * WebProcess/WebPage/PageOverlay.cpp: + (WebKit::PageOverlay::PageOverlay): + Initialize new member variables. + + (WebKit::PageOverlay::bounds): + Get rid of an unnecessary webPage() getter. + + (WebKit::PageOverlay::setPage): + Stop the animation timer. + + (WebKit::PageOverlay::startFadeInAnimation): + Update m_fractionFadedIn and call startFadeAnimation. + + (WebKit::PageOverlay::startFadeOutAnimation): + Ditto. + + (WebKit::PageOverlay::startFadeAnimation): + Initialize m_fadeAnimationStartTime and start the fade animation timer. + + (WebKit::PageOverlay::fadeAnimationTimerFired): + Update m_fractionFadedIn and call setNeedsDisplay(). + + * WebProcess/WebPage/PageOverlay.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::uninstallPageOverlay): + If fadeOut is true, tell the page overlay to start the fade out animation. + When the fade animation is complete, the page overlay will uninstall itself. + +2011-04-15 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + Views should be made visible before painting in WM_PRINTCLIENT messages + https://bugs.webkit.org/show_bug.cgi?id=58676 + <rdar://problem/9279211> + + * UIProcess/win/WebView.cpp: + (WebKit::WebView::onPrintClientEvent): If our view isn't currently visible set it to visible + before painting, then reset it back to not visible after painting. + (WebKit::WebView::onShowWindowEvent): Call setIsVisible instead of duplicating logic. + (WebKit::WebView::setIsVisible): Set the m_isVisible flag and call viewStateDidChange. + * UIProcess/win/WebView.h: + +2011-04-15 Jon Lee <jonlee@apple.com> + + Reviewed by Anders Carlsson. + + onClick does not function with <select> elements in WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=57904 + <rdar://problem/9217757> + + Reviewed by Anders Carlsson. + + * Shared/NativeWebMouseEvent.h: Copied from Source/WebKit2/UIProcess/WebPopupMenuProxy.h. + (WebKit::NativeWebMouseEvent::nativeEvent): + * Shared/mac/NativeWebMouseEventMac.mm: Added. + (WebKit::NativeWebMouseEvent::NativeWebMouseEvent): + * Shared/qt/NativeWebMouseEventQt.cpp: Copied from Source/WebKit2/UIProcess/WebPopupMenuProxy.h. + (WebKit::NativeWebMouseEvent::NativeWebMouseEvent): + * Shared/win/NativeWebMouseEventWin.cpp: Copied from Source/WebKit2/UIProcess/WebPopupMenuProxy.h. + (WebKit::NativeWebMouseEvent::NativeWebMouseEvent): + * UIProcess/API/mac/WKView.mm: + (-[WKView mouseMoved:]): + (-[WKView _mouseHandler:]): Pre-compiler mouse handler calls need to use the new NativeWebMouseEvent class + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::mouseMoveEvent): + (QWKPagePrivate::mousePressEvent): + (QWKPagePrivate::mouseReleaseEvent): + (QWKPagePrivate::mouseDoubleClickEvent): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::handleMouseEvent): keep track of mouse down event in order to be able to send a fake mouse up event on the select element + (WebKit::WebPageProxy::currentMouseDownEvent): for access by the popup menu proxy to dispatch the fake mouse up event + (WebKit::WebPageProxy::didReceiveEvent): clear out the cached mouse down event + (WebKit::WebPageProxy::processDidCrash): clear out the cached events since we assume that didReceiveEvent did not called prior to the crash + * UIProcess/WebPageProxy.h: + * UIProcess/WebPopupMenuProxy.h: + * UIProcess/mac/WebPopupMenuProxyMac.mm: + (WebKit::WebPopupMenuProxyMac::showPopupMenu): after notifying the popup menu client that the value changed, fake mouse up and mouse move events are posted + * UIProcess/win/WebPopupMenuProxyWin.cpp: + (WebKit::WebPopupMenuProxyWin::showPopupMenu): after notifying the popup menu client that the value changed, fake mouse up and mouse move events are posted + * UIProcess/win/WebView.cpp: + (WebKit::WebView::onMouseEvent): + * WebKit2.pro: + * WebKit2.xcodeproj/project.pbxproj: + * win/WebKit2.vcproj: + +2011-04-15 Alexey Proskuryakov <ap@apple.com> + + Qt build fix. + + * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::selectionStateChanged): Wrap the variable + in PLATFORM(MAC), too, as it's unused on other platforms. + +2011-04-15 Brady Eidson <beidson@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/9287880> and https://bugs.webkit.org/show_bug.cgi?id=58596 + WK2: Past searches not remembered for <input type=search results="5" autosave="foo"> + + Add SaveRecentSearches and LoadRecentSearches messages: + * UIProcess/WebPageProxy.messages.in: + * UIProcess/WebPageProxy.h: + + Message up to the UIProcess for the save/load operations: + * WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp: + (WebKit::WebSearchPopupMenu::saveRecentSearches): + (WebKit::WebSearchPopupMenu::loadRecentSearches): + * WebProcess/WebCoreSupport/WebPopupMenu.h: + (WebKit::WebPopupMenu::page): + + Save the values to disk CFPreference-style: + * UIProcess/cf/WebPageProxyCF.cpp: + (WebKit::autosaveKey): + (WebKit::WebPageProxy::saveRecentSearches): + (WebKit::WebPageProxy::loadRecentSearches): + + Stubbed out for non-CF platforms: + * UIProcess/gtk/WebPageProxyGtk.cpp: + (WebKit::WebPageProxy::saveRecentSearches): + (WebKit::WebPageProxy::loadRecentSearches): + * UIProcess/qt/WebPageProxyQt.cpp: + (WebKit::WebPageProxy::saveRecentSearches): + (WebKit::WebPageProxy::loadRecentSearches): + +2011-04-14 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Dan Bernstein. + + WebKit2: Password field input does not switch to ASCII-compatible source + https://bugs.webkit.org/show_bug.cgi?id=58583 + <rdar://problem/9059651> + + The implementation is more modern than what we have in WK1. Instead of returning a null + input context (as in non-editable content), we now set page context's properties. + + * UIProcess/PageClient.h: + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: (WebKit::PageClientImpl::updateSecureInputState): + Forward updateSecureInputState() call from WebPageProxy to WKView. + + * UIProcess/API/mac/WKView.mm: + (-[WKView dealloc]): ASSERT that we didn't somehow leave secure input events enabled. + (-[WKView becomeFirstResponder]): Update secure event mode. + (-[WKView resignFirstResponder]): Disable secure event mode. + (-[WKView setMarkedText:selectedRange:replacementRange:]): Prevent most advanced editing + behaviors in password fields, matching NSSecureTextInputField. + (-[WKView attributedSubstringForProposedRange:actualRange:]): Disable TSM Document Access + in password fields. There is also a check in web process, but it doest't hurt to check twice. + (-[WKView _windowDidBecomeKey:]): Call _updateSecureInputState. + (-[WKView _windowDidResignKey:]): Call _updateSecureInputState. + (-[WKView _updateSecureInputState]): Update secure event mode and allowed input sources. + + * UIProcess/API/mac/WKViewInternal.h: Added _updateSecureInputState. + + * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::selectionStateChanged): Update secure + input state when going in or out a password field. + +2011-04-14 Jer Noble <jer.noble@apple.com> + + Reviewed by Eric Carlson. + + REGRESSION: Rendering in <video> element appears to render quickly to catch up if it has been playing in a background tab + https://bugs.webkit.org/show_bug.cgi?id=58637 + + Notify AVFoundation that no one will be rendering when the view or window moves off screen. + + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::isViewVisible): Return false if the view's window is not visible. + * UIProcess/API/mac/WKView.mm: + (-[WKView addWindowObserversForWindow:]): Observe orderOut and orderIn events. + (-[WKView removeWindowObservers]): Ditto. + (-[WKView _windowDidOrderOffScreen:]): Added. + (-[WKView _windowDidOrderOnScreen:]): Added. + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::suspendPainting): Call LayerTreeHost::pauseRendering. + (WebKit::DrawingAreaImpl::resumePainting): Call LayerTreeHost::resumeRendering. + * WebProcess/WebPage/LayerTreeHost.h: + (WebKit::LayerTreeHost::pauseRendering): Added stub. + (WebKit::LayerTreeHost::resumeRendering): Added stub. + * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h: + * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm: + (WebKit::LayerTreeHostCAMac::pauseRendering): Added. Post a notification with our + intention to stop rendering. + (WebKit::LayerTreeHostCAMac::resumeRendering): Added. Post a notification with our + intention to start rendering. + +2011-04-15 Jessie Berlin <jberlin@apple.com> + + Reviewed by Sam Weinig. + + WebKit2: Need a way to keep the WebProcess alive for testing purposes. + https://bugs.webkit.org/show_bug.cgi?id=58592 + + * UIProcess/API/C/WKContext.cpp: + (WKContextDisableProcessTermination): + (WKContextEnableProcessTermination): + * UIProcess/API/C/WKContextPrivate.h: + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::WebContext): + Initialize m_processTerminationEnabled to true. + (WebKit::WebContext::enableProcessTermination): + Set m_processTerminationEnabled to true, and try to terminate the web process. + (WebKit::WebContext::shouldTerminate): + If !m_processTerminationEnabled, return false. + * UIProcess/WebContext.h: + (WebKit::WebContext::disableProcessTermination): + Set m_processTerminationEnabled to false; + +2011-04-15 Nancy Piedra <nancy.piedra@nokia.com> + + Reviewed by Laszlo Gombos. + + [Qt][Symbian] Need to export ViewportAttributes class + https://bugs.webkit.org/show_bug.cgi?id=58651 + + On Symbian, if the ViewportAttributes class is not exported we get + linking errors. + + Since this is a compilation issue, no new tests added. + + * UIProcess/API/qt/qwkpage.h: + +2011-04-15 Anna Cavender <annacc@chromium.org> + + Reviewed by Eric Carlson. + + Renaming TRACK feature define to VIDEO_TRACK + https://bugs.webkit.org/show_bug.cgi?id=53556 + + * Configurations/FeatureDefines.xcconfig: + +2011-04-14 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Select All context menu item doesn't work in Flash + https://bugs.webkit.org/show_bug.cgi?id=58615 + <rdar://problem/9225761> + + In some cases, -[NSWindow isKeyWindow] will return false even if + a window is the key window, so we have to compare our window + against -[NSApplication keyWindow]. + + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::isViewWindowActive): + +2011-04-14 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Add CFPreference based backend for WebKit2 preferences + https://bugs.webkit.org/show_bug.cgi?id=58605 + + * UIProcess/cf/WebPreferencesCF.cpp: + (WebKit::cfStringFromWebCoreString): + (WebKit::makeKey): + (WebKit::setStringValueIfInUserDefaults): + (WebKit::setBoolValueIfInUserDefaults): + (WebKit::setUInt32ValueIfInUserDefaults): + (WebKit::setDoubleValueIfInUserDefaults): + (WebKit::WebPreferences::platformInitializeStore): + (WebKit::WebPreferences::platformUpdateStringValueForKey): + (WebKit::WebPreferences::platformUpdateBoolValueForKey): + (WebKit::WebPreferences::platformUpdateUInt32ValueForKey): + (WebKit::WebPreferences::platformUpdateDoubleValueForKey): + Implement platform functions using CFPreferences API. + +2011-04-14 Brady Eidson <beidson@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/8665102> and https://bugs.webkit.org/show_bug.cgi?id=58595 + Menu is not displayed for <input type=search results="5"> + + * WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp: + (WebKit::WebSearchPopupMenu::enabled): Return true, like all good search popup menus should. + + * WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm: + (WebKit::WebPopupMenu::setUpPlatformData): Remember the shouldPopOver-ness. + + * Shared/PlatformPopupMenuData.cpp: + (WebKit::PlatformPopupMenuData::encode): Remember the shouldPopOver-ness. + (WebKit::PlatformPopupMenuData::decode): Remember the shouldPopOver-ness. + * Shared/PlatformPopupMenuData.h: + + * UIProcess/mac/WebPopupMenuProxyMac.mm: + (WebKit::WebPopupMenuProxyMac::showPopupMenu): Use the shouldPopOver-ness to adjust display position. + +2011-04-14 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Crash in NetscapePluginModule::tryGetSitesWithData when NPP_GetSitesWithData returns null + https://bugs.webkit.org/show_bug.cgi?id=58578 + <rdar://problem/9275201> + + It's OK for NPP_GetSitesWithData to return null. + + * Shared/Plugins/Netscape/NetscapePluginModule.cpp: + (WebKit::NetscapePluginModule::tryGetSitesWithData): + +2011-04-14 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Make creating WebPreferences lazy + https://bugs.webkit.org/show_bug.cgi?id=58570 + + * UIProcess/WebPageGroup.cpp: + (WebKit::WebPageGroup::WebPageGroup): + (WebKit::WebPageGroup::~WebPageGroup): + (WebKit::WebPageGroup::setPreferences): + (WebKit::WebPageGroup::preferences): + * UIProcess/WebPageGroup.h: + Don't create the WebPreference object until it is requested. + +2011-04-14 Pratik Solanki <psolanki@apple.com> + + Reviewed by David Kilzer. + + Set minimum priority for fast lane connections + https://bugs.webkit.org/show_bug.cgi?id=58353 + + * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: + (InitWebCoreSystemInterface): Support for new WKSI method WKSetHTTPPipeliningMinimumFastLanePriority. + +2011-04-14 Anders Carlsson <andersca@apple.com> + + Clang warning fixes. + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/mac/TextCheckerMac.mm: + * WebProcess/Downloads/mac/DownloadMac.mm: + +2011-04-14 Jessie Berlin <jberlin@apple.com> + + Reviewed by Timothy Hatcher. + + WebKit2: Add an option for a PageGroup to be invisible to the History Client. + https://bugs.webkit.org/show_bug.cgi?id=58547 + + * Shared/WebPageGroupData.cpp: + (WebKit::WebPageGroupData::encode): + (WebKit::WebPageGroupData::decode): + * Shared/WebPageGroupData.h: + + * UIProcess/WebInspectorProxy.cpp: + (WebKit::WebInspectorProxy::inspectorPageGroup): + The Web Inspector should not be visible to the History Client, because its HTML-based nature + should not be exposed through the API. + + * UIProcess/WebPageGroup.cpp: + (WebKit::WebPageGroup::create): + (WebKit::WebPageGroup::WebPageGroup): + * UIProcess/WebPageGroup.h: + + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + (WebKit::WebFrameLoaderClient::updateGlobalHistory): + Do not send the message to the WebContent for the history client. + (WebKit::WebFrameLoaderClient::updateGlobalHistoryRedirectLinks): + Ditto. + (WebKit::WebFrameLoaderClient::setTitle): + Ditto. + + * WebProcess/WebPage/WebPageGroupProxy.h: + (WebKit::WebPageGroupProxy::isVisibleToHistoryClient): + +2011-04-14 Balazs Kelemen <kbalazs@webkit.org> + + Reviewed by Andreas Kling. + + [Qt][WK2] Make Qt port compiling with ENABLE_PLUGIN_PROCESS=1 + https://bugs.webkit.org/show_bug.cgi?id=55719 + + Guard functionality related to complex text and implementations + that rely on MachPort with PLATFORM(MAC). + Based on Oleg Romashin's patch. + + * PluginProcess/PluginControllerProxy.cpp: + * PluginProcess/PluginControllerProxy.messages.in: + * PluginProcess/PluginProcess.cpp: + (WebKit::PluginProcess::createWebProcessConnection): + * PluginProcess/WebProcessConnection.cpp: + (WebKit::WebProcessConnection::createPlugin): + * Shared/Plugins/PluginProcessCreationParameters.cpp: + (WebKit::PluginProcessCreationParameters::decode): Fix bad C++ that + does not compile with gcc-linux. + * UIProcess/Plugins/PluginProcessProxy.cpp: + (WebKit::PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch): + (WebKit::PluginProcessProxy::didCreateWebProcessConnection): + * UIProcess/Plugins/PluginProcessProxy.h: + * UIProcess/Plugins/PluginProcessProxy.messages.in: + * WebKit2.pro: Move implementation that does not need external + visibility from WebKit2API.pri. Adding the headers as well. + * WebKit2API.pri: + * WebProcess/Plugins/PluginProcessConnectionManager.cpp: + (WebKit::PluginProcessConnectionManager::getPluginProcessConnection): + * WebProcess/WebPage/WebPage.cpp: + +2011-04-13 James Robinson <jamesr@chromium.org> + + Reviewed by Simon Fraser. + + Allow setting composited backing stores for scrollbars and scroll corners + https://bugs.webkit.org/show_bug.cgi?id=57202 + + Update WebPopupMenuProxyWin to reflect ScrollableArea interface changes. + + * UIProcess/win/WebPopupMenuProxyWin.h: + (WebKit::WebPopupMenuProxyWin::invalidateScrollCornerRect): + (WebKit::WebPopupMenuProxyWin::scrollCornerPresent): + (WebKit::WebPopupMenuProxyWin::scrollCornerRect): + +2011-04-13 Jon Lee <jonlee@apple.com> + + Reviewed by Maciej Stachowiak. + + REGRESSION(r81880): Paste menu is disabled for many edit fields (yahoo and google search, yahoo mail msg, forms, etc) + https://bugs.webkit.org/show_bug.cgi?id=58284 + <rdar://problem/9246149> + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::setFocused): Check for whether we are not supposed to be focused AND whether our platform behavior dictates to clear out the selection + +2011-04-13 Dan Bernstein <mitz@apple.com> + + Reviewed by Sam Weinig. + + Fixed a bug where WKView changed the cursor when the mouse was moving over other views. + + * UIProcess/API/mac/WKView.mm: + (-[WKView mouseMoved:]): If getting this message because this view is the first responder, + ignore it unless it is inside the visible rect. + +2011-04-13 Enrica Casucci <enrica@apple.com> + + Reviewed by Dan Bernstein. + + Should not rely on WKEditableLinkBehavior being in synch + with WebCore::EditableLinkBehavior. + https://bugs.webkit.org/show_bug.cgi?id=58473 + + Adding conversion routines. + + * UIProcess/API/C/WKAPICast.h: + (WebKit::toAPI): + (WebKit::toEditableLinkBehavior): + * UIProcess/API/C/WKPreferences.cpp: + (WKPreferencesSetEditableLinkBehavior): + (WKPreferencesGetEditableLinkBehavior): + +2011-04-13 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + After closing the last window, re-opening my last visited website is over 2X slower + https://bugs.webkit.org/show_bug.cgi?id=58488 + <rdar://problem/9233518> + + Give the web process a 60 second termination timeout. + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::WebProcess): + +2011-04-13 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Convert WebProcess over to using disableTermination/enableTermination + https://bugs.webkit.org/show_bug.cgi?id=58485 + + * PluginProcess/PluginProcess.cpp: + (WebKit::PluginProcess::getSitesWithData): + (WebKit::PluginProcess::clearSiteData): + Use the LocalTerminationDisabler RAII class. + + * Shared/ChildProcess.h: + (WebKit::ChildProcess::LocalTerminationDisabler::LocalTerminationDisabler): + (WebKit::ChildProcess::LocalTerminationDisabler::~LocalTerminationDisabler): + Add RAII class for calling disableTermination/enableTermination. + + * WebProcess/ApplicationCache/WebApplicationCacheManager.cpp: + (WebKit::WebApplicationCacheManager::getApplicationCacheOrigins): + (WebKit::WebApplicationCacheManager::deleteEntriesForOrigin): + (WebKit::WebApplicationCacheManager::deleteAllEntries): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/Cookies/WebCookieManager.cpp: + (WebKit::WebCookieManager::getHostnamesWithCookies): + (WebKit::WebCookieManager::deleteCookiesForHostname): + (WebKit::WebCookieManager::deleteAllCookies): + (WebKit::WebCookieManager::startObservingCookieChanges): + (WebKit::WebCookieManager::setHTTPCookieAcceptPolicy): + (WebKit::WebCookieManager::getHTTPCookieAcceptPolicy): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/Downloads/Download.cpp: + (WebKit::Download::Download): + Call disableTermination(). + + (WebKit::Download::~Download): + Call enableTermination(). + + * WebProcess/Downloads/DownloadManager.cpp: + (WebKit::DownloadManager::downloadFinished): + Remove call to terminateIfPossible. + + * WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp: + (WebKit::WebKeyValueStorageManager::getKeyValueStorageOrigins): + (WebKit::WebKeyValueStorageManager::deleteEntriesForOrigin): + (WebKit::WebKeyValueStorageManager::deleteAllEntries): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/MediaCache/WebMediaCacheManager.cpp: + (WebKit::WebMediaCacheManager::getHostnamesWithMediaCache): + (WebKit::WebMediaCacheManager::clearCacheForHostname): + (WebKit::WebMediaCacheManager::clearCacheForAllHostnames): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/ResourceCache/WebResourceCacheManager.cpp: + (WebKit::WebResourceCacheManager::getCacheOrigins): + (WebKit::WebResourceCacheManager::clearCacheForOrigin): + (WebKit::WebResourceCacheManager::clearCacheForAllOrigins): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/WebCoreSupport/WebDatabaseManager.cpp: + (WebKit::WebDatabaseManager::getDatabasesByOrigin): + (WebKit::WebDatabaseManager::getDatabaseOrigins): + (WebKit::WebDatabaseManager::deleteDatabaseWithNameForOrigin): + (WebKit::WebDatabaseManager::deleteDatabasesForOrigin): + (WebKit::WebDatabaseManager::deleteAllDatabases): + (WebKit::WebDatabaseManager::setQuotaForOrigin): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::createWebPage): + Call disableTermination(). + + (WebKit::WebProcess::removeWebPage): + Call enableTermination(). + + (WebKit::WebProcess::shouldTerminate): + Move logic from terminateIfPossible over here. + + (WebKit::WebProcess::terminate): + Move logic from terminateIfPossible over here. + + (WebKit::WebProcess::getSitesWithPluginData): + (WebKit::WebProcess::clearPluginSiteData): + Use the LocalTerminationDisabler RAII class. + + * WebProcess/WebProcess.h: + Publically inherit from ChildProcess, LocalTerminationDisabler needs to be accessible + from the WebProcess class. + +2011-04-13 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Adam Roben. + + Follow-up to: WebKit2 will load two copies of the same plugin, but should not + https://bugs.webkit.org/show_bug.cgi?id=49075 + + Use pathGetFileName instead of Win32 PathFindFileNameW. + + * UIProcess/Plugins/win/PluginInfoStoreWin.cpp: + (WebKit::PluginInfoStore::shouldUsePlugin): + +2011-04-13 Sam Weinig <sam@webkit.org> + + Reviewed by Gavin Barraclough. + + WebKit2 doesn't keep overlay scrollers shown while scroll gesture held + <rdar://problem/9260518> + + * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: + (InitWebCoreSystemInterface): + Initialize new WKSI functions. + +2011-04-13 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Oliver Hunt. + + WebKit2 will load two copies of the same plugin, but should not + https://bugs.webkit.org/show_bug.cgi?id=49075 + <rdar://problem/8635947> + + * UIProcess/Plugins/win/PluginInfoStoreWin.cpp: + (WebKit::PluginInfoStore::shouldUsePlugin): Don't use a plug-in if we've already allowed a plug-in with the same filename. + +2011-04-13 Timothy Hatcher <timothy@apple.com> + + Hide the dictionary panel when navigating or crashing. + + <rdar://problem/9261202> + + Reviewed by Sam Weinig. + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::dismissDictionaryLookupPanel): Added. Call WKHideWordDefinitionWindow. + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::didCommitLoadForFrame): Call PageClient::dismissDictionaryLookupPanel. + (WebKit::WebPageProxy::processDidCrash): Call dismissCorrectionPanel and PageClient::dismissDictionaryLookupPanel. + +2011-04-13 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Add support for disabling/enabling termination to ChildProcess + https://bugs.webkit.org/show_bug.cgi?id=58476 + + Add ChildProcess::disableTermination and ChildProcess::enableTermination and convert + the PluginProcess class over to using them. + + * PluginProcess/PluginProcess.cpp: + (WebKit::PluginProcess::PluginProcess): + The child process now takes a terminationTimeout argument. Get rid of the shutdown timer. + + (WebKit::PluginProcess::removeWebProcessConnection): + Call enableTermination(). + + (WebKit::PluginProcess::shouldTerminate): + Always return true. + + (WebKit::PluginProcess::createWebProcessConnection): + Call disableTermination(). + + (WebKit::PluginProcess::getSitesWithData): + Call disableTermination()/enableTermination(). + + (WebKit::PluginProcess::clearSiteData): + Ditto. + + * Shared/ChildProcess.cpp: + (WebKit::ChildProcess::disableTermination): + Increment the counter and stop the timer. + + (WebKit::ChildProcess::enableTermination): + Decrement the counter; if it's zero, start the timer. + + (WebKit::ChildProcess::terminationTimerFired): + Call shouldTerminate(). If it returns true, call terminate(). + + (WebKit::ChildProcess::terminate): + Call RunLoop::quit(). + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::WebProcess): + Just initialize the termination timeout to 0 for now. + + (WebKit::WebProcess::shouldTerminate): + Always return true; this isn't used yet. + + * WebProcess/WebProcess.h: + +2011-04-13 Enrica Casucci <enrica@apple.com> + + Reviewed by Dan Bernstein. + + REGRESSION: Links are clickable when a contentEditable is set to true. + https://bugs.webkit.org/show_bug.cgi?id=58473 + <rdar://problem/9256793> + + Added support for editable link behavior property. + + * Shared/WebPreferencesStore.cpp: + * Shared/WebPreferencesStore.h: + * UIProcess/API/C/WKPreferences.cpp: + (WKPreferencesSetEditableLinkBehavior): + (WKPreferencesGetEditableLinkBehavior): + * UIProcess/API/C/WKPreferencesPrivate.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::updatePreferences): + +2011-04-12 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Oliver Hunt. + + REGRESSION (WebKit2): Input methods are active in non-editable content + https://bugs.webkit.org/show_bug.cgi?id=58404 + <rdar://problem/9275940> + + * UIProcess/API/mac/WKView.mm: + (-[WKView insertText:]): Re-add the old variant of this function, because it's not only part + of deprecated NSTextInput protocol, but it's also part of NSResponder, and it's called when + the input context in nil. + (-[WKView inputContext]): Return nil when not in editable content. + +2011-04-12 Brady Eidson <beidson@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/9029193> and https://bugs.webkit.org/show_bug.cgi?id=58406 + Bringing up the context menu on a link might also follow the link. + + This patch adds a flag that is set just before the WebProcess tells the UIProcess to show a context menu. + + As long as this flag is set, the WebProcess will ignore any other mouse events that might have queued up + by the time the UIProcess gets around to showing the menu. + + After the UIProcess is done showing the menu, it messages back telling the WebProcess to clear the flag + and resume normal MouseEvent handling. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::showContextMenu): No matter what internalShowContextMenu does, always notify + the WebProcess that any context menu is now hidden. + (WebKit::WebPageProxy::internalShowContextMenu): + * UIProcess/WebPageProxy.h: + + * WebProcess/WebPage/WebContextMenu.cpp: + (WebKit::WebContextMenu::show): Since we're telling the UIProcess to show the menu, tell the WebPage a + context menu is showing so it will stop handling mouse events. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::WebPage): + (WebKit::WebPage::mouseEvent): Don't try to handle mouse events if a context menu is flagged as showing. + + Add accessors to twiddle the "context menu showing" flag: + * WebProcess/WebPage/WebPage.h: + (WebKit::WebPage::contextMenuShowing): + (WebKit::WebPage::contextMenuHidden): + * WebProcess/WebPage/WebPage.messages.in: Add the ContextMenuHidden message. + +2011-04-12 Sam Weinig <sam@webkit.org> + + Reviewed by Maciej Stachowiak. + + Quarantine related sandbox denial when downloading files + <rdar://problem/9203736> + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-12 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Sandbox violations dragging an image to the desktop. + <rdar://problem/9261834> + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-12 Sam Weinig <sam@webkit.org> + + Reviewed by Cameron Zwarich. + + Sandbox violations trying to access ~/Library/Keyboard Layouts and ~/Library/Input Methods + <rdar://problem/8973159> + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-12 Enrica Casucci <enrica@apple.com> + + Reviewed by Alexey Proskuryakov and Sam Weinig. + + Implement non-activating clicks to allow dragging out of a background window. + https://bugs.webkit.org/show_bug.cgi?id=55053 + <rdar://problem/9042197> + + Added methods to WKView to support non activating click. Unfortunately both + methods require a synchronous call to the WebProcess to decide what to do. + acceptFirstMouse is called only if shouldDelayWindowOrderingForEvent returns + true. In order to minimize the number of synchronous calls, we send the request + only if our window is not the key window. + + * UIProcess/API/mac/WKView.mm: + (-[WKView acceptsFirstMouse:]): + (-[WKView shouldDelayWindowOrderingForEvent:]): + * UIProcess/WebPageProxy.h: + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent): + (WebKit::WebPageProxy::acceptsFirstMouse): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::shouldDelayWindowOrderingEvent): + (WebKit::WebPage::acceptsFirstMouse): + +2011-04-12 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Oliver Hunt. + + Crash when serializing a null AttributedString + https://bugs.webkit.org/show_bug.cgi?id=58393 + <rdar://problem/9275326> + + * Shared/mac/AttributedString.mm: + (WebKit::AttributedString::encode): + (WebKit::AttributedString::decode): + Prefix the serialized value with an isNull tag. + +2011-04-12 Enrica Casucci <enrica@apple.com> + + Reviewed by Alexey Proskuryakov. + + Infinite recursion in WebHTMLView executeSavedKeypressCommands. + https://bugs.webkit.org/show_bug.cgi?id=58382 + <rdar://problem/9239370> + + Execution of some editing commands could trigger a call to selectedRange that + internally calls executeSavedKeypressCommands creating an infinite recursion. + + * UIProcess/API/mac/WKView.mm: + (-[WKView _executeSavedKeypressCommands]): Added flag to avoid recursion. + (-[WKView _interpretKeyEvent:withCachedTextInputState:savingCommandsTo:WebCore::]): + Added flag initialization. + +2011-04-12 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + Page tears and stutters in WebKit2 when page is > 2048 pixels wide + https://bugs.webkit.org/show_bug.cgi?id=58330 + + Turn off tiling for nonCompositedContentLayer to avoid tearing when + scrolling very wide (> 2048) windows. + + * WebProcess/WebPage/ca/LayerTreeHostCA.cpp: + (WebKit::LayerTreeHostCA::initialize): + +2011-04-12 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Assertion in DrawingAreaImpl::resumePainting() (m_isPaintingSuspended) when clicking a link at twitter.com + https://bugs.webkit.org/show_bug.cgi?id=58377 + <rdar://problem/8976531> + + Remove the assertion. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::resumePainting): + +2011-04-11 Stephanie Lewis <slewis@apple.com> + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=58280 + <rdar://problem/9252824> javascript in an inconsistent state due to serialization returning an un-handled exception + Change use of SerializedScriptValue::Create to use the same api as the rest of WebKit2. This has the benefit + of handling any exceptions so Javascript is not in an inconsistent state. + + * Shared/API/c/WKSerializedScriptValue.h: fix a typo + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::runJavaScriptInMainFrame): + +2011-04-12 Jeff Miller <jeffm@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Pressing Tab in Web Inspector's console does not cycle through completion options + https://bugs.webkit.org/show_bug.cgi?id=56020 + + Safari was always calling TranslateMessage() on key events since it has no way to know whether + WebKit handled the event without a PageUIClient (which Safari only installs on pages inside + a Safari window), which was generating a WM_CHAR message containing the tab in this case. The fix + is for Safari to never call TranslateMessage() on key events outside of a Safari window, but this + means the WebPageProxy needs to do this for unhandled key events if there is no didNotHandleKeyEvent + callback in the PageUIClient. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::didReceiveEvent): Call TranslateMessage() on Windows for unhandled key events that can't be handled by the PageUIClient. + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::canNotHandleKeyEvent): Added. + * UIProcess/WebUIClient.h: Added canNotHandleKeyEvent(). + +2011-04-12 Alice Liu <alice.liu@apple.com> + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=58292 + Provide new setting to allow site icon loading despite disabling automatic image loading in general. + + * Shared/WebPreferencesStore.h: Add macro for setting default value. + * UIProcess/API/C/WKPreferences.cpp: + (WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference): Added setter. + (WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference): Added getter. + * UIProcess/API/C/WKPreferences.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::updatePreferences): Add to list of WebCore settings that get propagated to WebKit preferences. + +2011-04-12 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Spelling and Grammar Checking: Make sure to remove the markings from the document + when spelling and/or grammar checking is disabled. + https://bugs.webkit.org/show_bug.cgi?id=58350 + + * UIProcess/API/mac/WKView.mm: + (-[WKView toggleContinuousSpellChecking:]): + Move the call to unmark the errors to the WebProcess. + (-[WKView setGrammarCheckingEnabled:]): + Ditto. + (-[WKView toggleGrammarChecking:]): + Ditto. + + * UIProcess/WebPageProxy.cpp: + Remove unused functions. + * UIProcess/WebPageProxy.h: + Ditto. + * WebProcess/WebPage/WebPage.messages.in: + Ditto. + * WebProcess/WebPage/WebPage.h: + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::setTextCheckerState): + If grammar or spelling checking is disabled, unmark all the pages. + Doing it here allows makes it possible to unmark all pages in a cross-platform way that is + triggered both by selecting the the context menu items and by any other methods of updating + the enabled / disabled state. + +2011-04-12 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Cisco Meeting Center will not download or launch from Safari + https://bugs.webkit.org/show_bug.cgi?id=58366 + <rdar://problem/8987139> + + It's OK if a plug-in has less (or more) MIME type descriptions than actual MIME types. + + * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm: + (WebKit::getPluginInfoFromCarbonResources): + +2011-04-12 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Call PluginControllerProxy::platformGeometryDidChange before Plugin::geometryDidChange + https://bugs.webkit.org/show_bug.cgi?id=58361 + + Since Plugin::geometryDidChange ends up calling plug-in code it can resize the plug-in which causes + platformGeometryDidChange to be called with the wrong rect. + + * PluginProcess/PluginControllerProxy.cpp: + (WebKit::PluginControllerProxy::geometryDidChange): + Call platformGeometryDidChange. + + * PluginProcess/PluginControllerProxy.h: + * PluginProcess/mac/PluginControllerProxyMac.mm: + (WebKit::PluginControllerProxy::platformGeometryDidChange): + Remove the parameters to platformGeometryDidChange and just use m_frameRect instead. + +2011-04-12 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Move three Mac specific functions to PluginControllerProxyMac.mm. + +2011-04-12 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Cache the window and plug-in element NPObjects + https://bugs.webkit.org/show_bug.cgi?id=58355 + + * PluginProcess/PluginControllerProxy.cpp: + (WebKit::PluginControllerProxy::PluginControllerProxy): + (WebKit::PluginControllerProxy::~PluginControllerProxy): + (WebKit::PluginControllerProxy::windowScriptNPObject): + (WebKit::PluginControllerProxy::pluginElementNPObject): + * PluginProcess/PluginControllerProxy.h: + +2011-04-12 Alejandro G. Castro <alex@igalia.com> + + Fixed GTK compilation after r83454. + + * UIProcess/gtk/WebView.cpp: + (WebKit::WebView::findStringInCustomRepresentation): + (WebKit::WebView::countStringMatchesInCustomRepresentation): + * UIProcess/gtk/WebView.h: + +2011-04-11 Daniel Bates <dbates@webkit.org> + + Attempt to fix the Qt Linux Release build after changeset 83550 <http://trac.webkit.org/changeset/83550> + (https://bugs.webkit.org/show_bug.cgi?id=54159). + + * WebKit2API.pri: Append UIProcess/API/C/WKResourceCacheManager.cpp to the list WEBKIT2_API_SOURCES. + +2011-04-11 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Move focus management out of WebKit via the UIClient + <rdar://problem/8784068> + https://bugs.webkit.org/show_bug.cgi?id=58278 + + * UIProcess/API/C/WKPage.h: + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + * UIProcess/API/qt/qwkpage.cpp: + (QWKPage::QWKPage): + * UIProcess/API/qt/qwkpage_p.h: + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::setFocus): + * UIProcess/WebUIClient.cpp: + (WebKit::WebUIClient::focus): + (WebKit::WebUIClient::unfocus): + * UIProcess/WebUIClient.h: + * UIProcess/gtk/WebView.cpp: + * UIProcess/gtk/WebView.h: + * UIProcess/win/WebView.h: + Remove PageClient::setFocus() in favor of WebUIClient::focus and WebUIClient::unfocus. + +2011-04-11 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Maciej Stachowiak. + + WebKit2: Cannot use Ctrl-Delete as a custom keyboard shortcut + https://bugs.webkit.org/show_bug.cgi?id=58265 + <rdar://problem/9221468> + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::keyEvent): Added a comment explaining that doing work after DOM event + dispatch isn't great. + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::performNonEditingBehaviorForSelector): Added a comment explaining how this + might be moved down to WebCore. + (WebKit::WebPage::performDefaultBehaviorForKeyEvent): This is now empty, since both Space + and Backspace behaviors are implemented in WebCore. + +2011-04-11 Anders Carlsson <andersca@apple.com> + + Try to fix the Windows build. + + * UIProcess/win/WebInspectorProxyWin.cpp: + (WebKit::WebInspectorProxy::platformCreateInspectorPage): + +2011-04-11 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Dan Bernstein. + + REGRESSION (r83081): Esc key no longer removes current Kotoeri text operation + https://bugs.webkit.org/show_bug.cgi?id=58274 + <rdar://problem/9263683> + + * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::getMarkedRange): Wrap the returned + temporary in RefPtr. + +2011-04-11 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Remove m_urlAtProcessExit from WebPageProxy + https://bugs.webkit.org/show_bug.cgi?id=58275 + + Get rid of m_urlAtProcessExit and replace some zeros with nullptrs. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::processDidCrash): + * UIProcess/WebPageProxy.h: + +2011-04-11 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Remove the WebContext member variable from WebPageProxy + https://bugs.webkit.org/show_bug.cgi?id=58271 + <rdar://problem/9148125> + + * UIProcess/API/C/WKPage.cpp: + (WKPageGetContext): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::create): + (WebKit::WebPageProxy::WebPageProxy): + (WebKit::WebPageProxy::process): + (WebKit::WebPageProxy::reattachToWebProcess): + (WebKit::WebPageProxy::canShowMIMEType): + (WebKit::WebPageProxy::receivedPolicyDecision): + (WebKit::WebPageProxy::didStartProvisionalLoadForFrame): + (WebKit::WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame): + (WebKit::WebPageProxy::didFailProvisionalLoadForFrame): + (WebKit::WebPageProxy::didCommitLoadForFrame): + (WebKit::WebPageProxy::didFinishDocumentLoadForFrame): + (WebKit::WebPageProxy::didFinishLoadForFrame): + (WebKit::WebPageProxy::didFailLoadForFrame): + (WebKit::WebPageProxy::didSameDocumentNavigationForFrame): + (WebKit::WebPageProxy::didReceiveTitleForFrame): + (WebKit::WebPageProxy::didFirstLayoutForFrame): + (WebKit::WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame): + (WebKit::WebPageProxy::didRemoveFrameFromHierarchy): + (WebKit::WebPageProxy::didDisplayInsecureContentForFrame): + (WebKit::WebPageProxy::didRunInsecureContentForFrame): + (WebKit::WebPageProxy::decidePolicyForNavigationAction): + (WebKit::WebPageProxy::decidePolicyForNewWindowAction): + (WebKit::WebPageProxy::decidePolicyForResponse): + (WebKit::WebPageProxy::unableToImplementPolicy): + (WebKit::WebPageProxy::willSubmitForm): + (WebKit::WebPageProxy::mouseDidMoveOverElement): + (WebKit::WebPageProxy::showContextMenu): + (WebKit::WebPageProxy::contextMenuItemSelected): + * UIProcess/WebPageProxy.h: + * UIProcess/WebProcessProxy.cpp: + (WebKit::WebProcessProxy::createWebPage): + * UIProcess/mac/WebInspectorProxyMac.mm: + (WebKit::WebInspectorProxy::platformCreateInspectorPage): + +2011-04-11 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Adam Roben. + + Ignore context change callbacks when not on the main thread + https://bugs.webkit.org/show_bug.cgi?id=58256 + <rdar://problem/9266090> + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp: + (WebKit::LayerTreeHostCAWin::contextDidChangeCallback): Do nothing when not called + on the main thread. This should only happen when no changes have actually + been committed to the context, eg. when a video frame has been added to an image + queue, so return without triggering animations etc. + +2011-04-11 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + First step towards simplifying WebPageProxy/WebProcessProxy/WebContext ownership + https://bugs.webkit.org/show_bug.cgi?id=58266 + <rdar://problem/9148125> + + With this patch, the WKView holds a strong reference to a WebPageProxy. The + WebPageProxy in turn holds a strong reference to its WebProcessProxy. Finally, + The WebProcessProxy holds a strong reference to its WebContext. + + The WebContext holds a strong reference to the running WebProcessProxy which results + in a reference cycle that's broken when the web process exits. + + The reason for is to avoid crashes where WebPageProxy::process() returns null if the web process + has crashed but has not yet been relaunched. + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::disconnectProcess): + Add comment. + + (WebKit::WebContext::createWebPage): + Return a PassRefPtr. + + (WebKit::WebContext::relaunchProcessIfNecessary): + Change this to return a WebPageProxy. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::create): + This now takes a PassRefPtr<WebProcessProxy>. + + (WebKit::WebPageProxy::WebPageProxy): + Ditto. + + (WebKit::WebPageProxy::~WebPageProxy): + Call close() if necessary. + + (WebKit::WebPageProxy::reattachToWebProcess): + Replace the current process with the new process. + + * UIProcess/WebProcessProxy.cpp: + (WebKit::WebProcessProxy::create): + Take a PassRefPtr<WebContext>. + + (WebKit::WebProcessProxy::WebProcessProxy): + Ditto. + + (WebKit::WebProcessProxy::webPage): + Remove .get() now that the page map uses weak references. + + (WebKit::WebProcessProxy::createWebPage): + This now returns the created web page proxy. + +2011-04-11 Adam Roben <aroben@apple.com> + + Dispatch sent messages to windows owned by the web process when waiting a sync CoreIPC reply + + On Windows, windowed plugins' HWNDs are created as children of the WKView's window. This + creates a cross-process window hierarchy, which in turn attaches the input states of the UI + process's and web process's main threads (as if ::AttachThreadInput has been called). Having + the input states attached means that changes to the input state (e.g., changing the focus + window) can result in synchronous window messages being sent between the processes. This can + result in deadlocks if the UI process changes the input state while handling a synchronous + CoreIPC message from the web process. Since the web process isn't running its message loop + while waiting for the reply, it never processes the messages Windows is sending it from the + UI process. + + The solution taken in this patch is to continue to dispatch sent (not posted) messages to + windows created by the web process while waiting for a sync CoreIPC reply. Someday we can + hopefully reduce the number of cases in which the UI process modifies the thread's input + state while handling a synchronous message; see the bug for details. + + Fixes <http://webkit.org/b/58239> <rdar://problem/8769302> REGRESSION (WebKit2): Deadlock + clicking Flash plugin + + Reviewed by Anders Carlsson. + + * Platform/CoreIPC/BinarySemaphore.h: + (CoreIPC::BinarySemaphore::event): Added. Simple getter to expose the underlying event + HANDLE. + + * Platform/CoreIPC/Connection.cpp: + (CoreIPC::Connection::SyncMessageState::waitWhileDispatchingSentMessages): New Windows-only + function that is used instead of wait() so that sent messages will continue to be + dispatched. + (CoreIPC::Connection::waitForSyncReply): Use waitWhileDispatchingSentMessages instead of + wait on Windows. Our Client gives us the set of windows that need to have windows delivered + to them. + + * Platform/CoreIPC/Connection.h: Added new + windowsToReceiveSentMessagesWhileWaitingForSyncReply function to Client. + + * Platform/RunLoop.h: Added new dispatchSentMessagesUntil function to be used while waiting + for a sync CoreIPC reply. + + * Platform/win/RunLoopWin.cpp: + (RunLoop::dispatchSentMessagesUntil): Added. If we have no windows to dispatch messages to, + then just wait on the semaphore. Otherwise spin a ::MsgWaitForMultipleObjectsEx loop to + detect when the semaphore is signaled, the timeout elapses, or sent messages are available, + and handle each case appropriately. + + * UIProcess/WebProcessProxy.h: Added new CoreIPC::Connection::Client function. + + * UIProcess/win/WebProcessProxyWin.cpp: Added. + (WebKit::WebProcessProxy::windowsToReceiveSentMessagesWhileWaitingForSyncReply): Just return + an empty Vector. The web process never modifies the thread's input state while responding to + a synchronous message, so we don't have anything to worry about here. + + * WebProcess/WebProcess.h: Added new CoreIPC::Connection::Client function. + + * WebProcess/win/WebProcessWin.cpp: + (WebKit::addWindowToVectorIfOwnedByCurrentThread): New helper function to be called by + ::EnumThreadWindows/::EnumChildWindows. Does what it says. + (WebKit::WebProcess::windowsToReceiveSentMessagesWhileWaitingForSyncReply): Added. Returns + all top-level windows created by this thread, descendants of those windows created by this + thread, and descendants of WKViews' windows created by this thread. + + * win/WebKit2.vcproj: Added WebProcessProxyWin.cpp. + +2011-04-11 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 7: Implement getGuessesForWord, learnWord, and ignoreWord. + + * UIProcess/API/C/win/WKTextChecker.cpp: + (WKTextCheckerChangeSpellingToWord): + * UIProcess/API/C/win/WKTextChecker.h: + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::changeSpellingToWord): + Make this function const since it does not modify the WebPageProxy and making it const + allows WebTextChecker::changeSpellingToWord to take a const WebPageProxy. + (WebKit::WebPageProxy::learnWord): + * UIProcess/WebPageProxy.h: + + * UIProcess/TextChecker.h: + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::getGuessesForWord): + Ask the TextCheckerClient for the guesses. + (WebKit::TextChecker::learnWord): + Tell the TextCheckerClient. + (WebKit::TextChecker::ignoreWord): + Ditto. + * UIProcess/gtk/TextCheckerGtk.cpp: + (WebKit::TextChecker::learnWord): + Add an unused param that is necessary for Windows. + * UIProcess/mac/TextCheckerMac.mm: + (WebKit::TextChecker::learnWord): + Ditto. + * UIProcess/qt/TextCheckerQt.cpp: + (WebKit::TextChecker::learnWord): + Ditto. + + * UIProcess/win/WebTextChecker.cpp: + (WebKit::WebTextChecker::changeSpellingToWord): + Tell the page. + * UIProcess/win/WebTextChecker.h: + + * UIProcess/win/WebTextCheckerClient.cpp: + (WebKit::WebTextCheckerClient::guessesForWord): + (WebKit::WebTextCheckerClient::learnWord): + (WebKit::WebTextCheckerClient::ignoreWord): + * UIProcess/win/WebTextCheckerClient.h: + +2011-04-11 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Remove unused WebProcessProxy functions + https://bugs.webkit.org/show_bug.cgi?id=58262 + + * UIProcess/WebProcessProxy.cpp: + * UIProcess/WebProcessProxy.h: + +2011-04-11 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Crash in WebPageProxy::countStringMatches + https://bugs.webkit.org/show_bug.cgi?id=58255 + <rdar://problem/9243837> + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::countStringMatches): + Return early if the page is not valid. + +2011-04-11 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + WebKit2: links don’t update to look visited + <rdar://problem/8806254> + https://bugs.webkit.org/show_bug.cgi?id=58252 + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::visitedLinkStateChanged): + (WebKit::WebProcess::allVisitedLinkStateChanged): + * WebProcess/WebProcess.h: + Remove use of vestigial sharedPageGroup and instead iterate set of + page groups in use by the process. + +2011-04-11 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Windows 7 Gestures Window Bounce shouldn't require a sync message + https://bugs.webkit.org/show_bug.cgi?id=58167 + <rdar://problem/9259813> + + Instead of making GestureDidScroll sync, have WebPageWin call from WebProcess -> + UIProcess when the gesture causes the page to scroll to the beginning or the + end of the document. + + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::gestureDidScroll): Not a sync message anymore. + (WebKit::WebPageProxy::setGestureScrollingLimitReached): Tell the page client that the gesture + scrolling limnit was reached. + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: Add a new message. + * UIProcess/win/WebView.cpp: + (WebKit::WebView::WebView): Initialize new variable. + (WebKit::WebView::onGesture): Use the state of the member variable, not the response from + the sync message. + * UIProcess/win/WebView.h: + (WebKit::WebView::setGestureScrollingLimitReached): + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + * WebProcess/WebPage/win/WebPageWin.cpp: + (WebKit::scrollbarAtTopOfBottomOrDocument): Returns whether or not the scrollbar is at the + top or bottom of the document. + (WebKit::WebPage::gestureDidScroll): Track whether or not we started at the beginning + or end of the document, and whether or not we ended at the beginning or end of the document, + and send a message if the value changed. + +2011-04-04 Jer Noble <jer.noble@apple.com> + + Reviewed by Maciej Stachowiak. + + WK2: PDF: Find in page + https://bugs.webkit.org/show_bug.cgi?id=57765 + + Support searching text within PDF documents. Find requests must be routed from the + WebPageProxy, through the PageClient, and to the WKView, where they can be passed to + the PDFViewController. + + * UIProcess/API/mac/PDFViewController.h: + * UIProcess/API/mac/PDFViewController.mm: + (_PDFSelectionsAreEqual): Copied from WebPDFView. + (-[WKPDFView _nextMatchFor:direction:caseSensitive:wrap:fromSelection:startInSelection:]): Copied from WebPDFView. + (-[WKPDFView _countMatches:caseSensitive:]): Added. + (WebKit::PDFViewController::findString): Added. + (WebKit::PDFViewController::countStringMatches): Added. + * UIProcess/PageClient.h: + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::findStringInCustomRepresentation): Added. + (WebKit::PageClientImpl::countStringMatchesInCustomRepresentation): Added. + * UIProcess/API/mac/WKViewInternal.h: + * UIProcess/API/mac/WKView.mm: + (-[WKView _findStringInCustomRepresentation:withFindOptions:maxMatchCount:]): Added. + (-[WKView _countStringMatchesInCustomRepresentation:withFindOptions:maxMatchCount:]): Added. + * UIProcess/WebPageProxy.h: Moved a number of find-related functions from private: to public: so + they could be called from PDFViewController. + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::findString): Added. + (WebKit::WebPageProxy::countStringMatches): Added. + * UIProcess/win/WebView.cpp: + (WebKit::WebView::findStringInCustomRepresentation): Added stub. + (WebKit::WebView::countStringMatchesInCustomRepresentation): Ditto. + * UIProcess/win/WebView.h: + * UIProcess/API/qt/qwkpage_p.h: + (QWKPagePrivate::findStringInCustomRepresentation): Added stub. + (QWKPagePrivate::countStringMatchesInCustomRepresentation): Added stub. + +2011-04-11 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 6: Update the Spelling UI with the spelling and grammar mistakes. + + * UIProcess/API/C/win/WKAPICastWin.h: + (WebKit::toAPI): + Make it possible to go from a WebCore::GrammarDetail to a WebGrammarDetail. + + * UIProcess/API/C/win/WKGrammarDetail.cpp: + (WKGrammarDetailCreate): + (WKGrammarDetailGetLocation): + (WKGrammarDetailGetLength): + (WKGrammarDetailCopyGuesses): + (WKGrammarDetailCopyUserDescription): + * UIProcess/API/C/win/WKGrammarDetail.h: + + * UIProcess/API/C/win/WKTextChecker.cpp: + (WKTextCheckerCheckSpelling): + Tell the WebTextChecker. + * UIProcess/API/C/win/WKTextChecker.h: + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::contextMenuItemSelected): + If the show/hide spelling UI is selected and the spelling UI is not showing, make sure to + advance to the next misspelling (in this case, the first). + This behavior matches that in WebCore and WKView.mm. + (WebKit::WebPageProxy::advanceToNextMisspelling): + Make this function const since it does not modify the WebPageProxy and making it const + allows WebTextChecker::checkSpelling to take a const WebPageProxy. + (WebKit::WebPageProxy::spellDocumentTag): + (WebKit::WebPageProxy::updateSpellingUIWithMisspelledWord): + (WebKit::WebPageProxy::updateSpellingUIWithGrammarString): + * UIProcess/WebPageProxy.h: + + * UIProcess/TextChecker.h: + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::uniqueSpellDocumentTag): + Tell the TextCheckerClient which WebPageProxy this tag is for. + (WebKit::TextChecker::updateSpellingUIWithMisspelledWord): + Tell the TextCheckerClient. + (WebKit::TextChecker::updateSpellingUIWithGrammarString): + Ditto. + * UIProcess/mac/TextCheckerMac.mm: + (WebKit::TextChecker::uniqueSpellDocumentTag): + Add the new argument that is unused by this port. + (WebKit::TextChecker::updateSpellingUIWithMisspelledWord): + Ditto. + (WebKit::TextChecker::updateSpellingUIWithGrammarString): + Ditto. + * UIProcess/gtk/TextCheckerGtk.cpp: + (WebKit::TextChecker::uniqueSpellDocumentTag): + Ditto. + (WebKit::TextChecker::updateSpellingUIWithMisspelledWord): + Ditto. + (WebKit::TextChecker::updateSpellingUIWithGrammarString): + Ditto. + * UIProcess/qt/TextCheckerQt.cpp: + (WebKit::TextChecker::uniqueSpellDocumentTag): + Ditto. + (WebKit::TextChecker::updateSpellingUIWithMisspelledWord): + Ditto. + (WebKit::TextChecker::updateSpellingUIWithGrammarString): + Ditto. + + * UIProcess/win/WebGrammarDetail.cpp: + (WebKit::WebGrammarDetail::create): + (WebKit::WebGrammarDetail::WebGrammarDetail): + (WebKit::WebGrammarDetail::guesses): + * UIProcess/win/WebGrammarDetail.h: + (WebKit::WebGrammarDetail::location): + (WebKit::WebGrammarDetail::length): + (WebKit::WebGrammarDetail::userDescription): + + * UIProcess/win/WebTextChecker.cpp: + (WebKit::WebTextChecker::checkSpelling): + Tell the page to advance to the next misspelling. This matches the WK1 WebView.cpp logic. + + * UIProcess/win/WebTextChecker.h: + * UIProcess/win/WebTextCheckerClient.cpp: + (WebKit::WebTextCheckerClient::uniqueSpellDocumentTag): + (WebKit::WebTextCheckerClient::toggleSpellingUIIsShowing): + (WebKit::WebTextCheckerClient::updateSpellingUIWithMisspelledWord): + (WebKit::WebTextCheckerClient::updateSpellingUIWithGrammarString): + * UIProcess/win/WebTextCheckerClient.h: + +2011-04-10 Maciej Stachowiak <mjs@apple.com> + + Not reviewed. + + Remove extra inadvertantly commiteed changes from last change. + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-10 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Dan Bernstein. + + REGRESSION: WebProcess spews sandboxing violations for outbound network traffic + https://bugs.webkit.org/show_bug.cgi?id=58215 + <rdar://problem/9251695> + + * WebProcess/com.apple.WebProcess.sb: Restore some previously removed rules. + +2011-04-10 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com> + + Reviewed by Eric Seidel. + + Require no undefined symbols during compilation. + + [Qt] [WK2] WebKitTestRunner, QtWebProcess and WTRInjectBundle should fail to compile when there's undefined symbols + https://bugs.webkit.org/show_bug.cgi?id=54896 + + Add -Wl,--no-undefined to catch missing symbols early. + + * WebProcess.pro: + +2011-04-09 Geoffrey Garen <ggaren@apple.com> + + Not reviewed. + + Try recommitting some things svn left out of my last commit. + + * WebProcess/Plugins/Netscape/NPJSObject.h: + +2011-04-09 Geoffrey Garen <ggaren@apple.com> + + Not reviewed. + + Try recommitting some things svn left out of my last commit. + + * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp: + (WebKit::NPRuntimeObjectMap::evaluate): + +2011-04-08 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Safari doesn't respect cmd-arrows (and variations) as custom keyboard shortcuts + https://bugs.webkit.org/show_bug.cgi?id=58175 + <rdar://problem/9060555> + + The problem is that command handling should be different for events that come as keyDown: + and those that come as performKeyEquivalent:. WebKit1 only tries custom "key bindings" + when handling a keyDown:, letting a performKeyEquivalent: run through the whole responder + chain first. + + This would be very difficult to implement in WebKit2 because of how it re-sends the same + event after web process handling. Luckily, we can both fix the bug and make the behavior + more robust by not hardcoding key combinations. + + * WebProcess/WebPage/WebPage.h: Edit performNonEditingBehaviorForSelector. + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::executeKeypressCommandsInternal): When executing commands, also try + executing editor commands in their non-editing meaning, which is usually scrolling. + (WebKit::WebPage::performNonEditingBehaviorForSelector): Naive implementation with a chain + of ifs, which is hopefully ok performance-wise for a dozen check. + (WebKit::WebPage::performDefaultBehaviorForKeyEvent): Only kept two commands here that I + couldn't easily move. + +2011-04-08 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Show the substitutions panel on Mac and make sure the menu items titles are + updated correctly. + https://bugs.webkit.org/show_bug.cgi?id=58179 + + * UIProcess/API/mac/WKView.mm: + (-[WKView validateUserInterfaceItem:]): + The title of the context menu item should be opposite of whether or not the spelling panel + is visible. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::contextMenuItemSelected): + If the "Show/Hide" Substitutions item is selected, call toggleSubstitutionsPanelIsShowing. + (WebKit::WebPageProxy::substitutionsPanelIsShowing): + Ask the TextChecker. + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + + * UIProcess/TextChecker.h: + * UIProcess/mac/TextCheckerMac.mm: + (WebKit::TextChecker::substitutionsPanelIsShowing): + As the shared NSSpellChecker if the substitutionsPanel is visible. + (WebKit::TextChecker::toggleSubstitutionsPanelIsShowing): + Order the substitutionsPanel out or front (copied from WKView.mm). + + * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: + (WebKit::WebEditorClient::substitutionsPanelIsShowing): + Send a sync message to the UI process to find out. + It needs to be sync because the editor code relies on the value returned. + +2011-04-08 Dan Bernstein <mitz@apple.com> + + Reviewed by Adele Peterson. + + Fixed a bug where right-to-left frames incorrectly reported that they were pinned to the left + when they were actually not. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::didChangeScrollOffsetForMainFrame): Do not assume that the minimum scroll offset + is zero, because it is not. + +2011-04-08 Anders Carlsson <andersca@apple.com> + + Fix the Windows build. + + * UIProcess/win/WebView.cpp: + (WebKit::WebView::Drop): + +2011-04-08 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 5: Implement the code show and hide the Spelling UI via the context menu item (both + Windows and Mac). + + * UIProcess/API/C/win/WKTextChecker.h: + Add the new WKTextCheckerClient funtions. + + * UIProcess/API/mac/WKView.mm: + (-[WKView validateUserInterfaceItem:]): + The title of the context menu item should be opposite of whether or not the spelling panel + is visible. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::contextMenuItemSelected): + If the "Show/Hide Spelling and Grammar" item is selected, call toggleSpellingUIIsShowing. + (WebKit::WebPageProxy::spellingUIIsShowing): + Call through to TextChecker. + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + + * UIProcess/TextChecker.h: + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::spellingUIIsShowing): + Call the TextCheckerClient. + (WebKit::TextChecker::toggleSpellingUIIsShowing): + Ditto. + * UIProcess/mac/TextCheckerMac.mm: + (WebKit::TextChecker::spellingUIIsShowing): + Ask the shared NSSpellChecker if the spellingPanel is visible. + (WebKit::TextChecker::toggleSpellingUIIsShowing): + Order the spellingPanel out or front (copied from WKView.mm). + * UIProcess/qt/TextCheckerQt.cpp: + (WebKit::TextChecker::spellingUIIsShowing): + Call notImplemented. + (WebKit::TextChecker::toggleSpellingUIIsShowing): + Ditto. + * UIProcess/gtk/TextCheckerGtk.cpp: + (WebKit::TextChecker::spellingUIIsShowing): + Ditto. + (WebKit::TextChecker::toggleSpellingUIIsShowing): + Ditto. + + * UIProcess/win/WebTextCheckerClient.cpp: + (WebKit::WebTextCheckerClient::spellingUIIsShowing): + Call the client. + (WebKit::WebTextCheckerClient::toggleSpellingUIIsShowing): + Ditto. + * UIProcess/win/WebTextCheckerClient.h: + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::spellingUIIsShowing): + Send a sync message to the UI process to find out. + It needs to be sync because the Editor code relies on the value returned. + +2011-04-08 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Sandboxing doesn't work if a local file is dropped on the content area + https://bugs.webkit.org/show_bug.cgi?id=58177 + <rdar://problem/9019253> + + When performing a drag and the dragging pasteboard contains a local file, create a + sandbox extension and pass it along. If we end up loading the file, the sandbox extension + tracker will consume the extension. + + * UIProcess/API/mac/WKView.mm: + (maybeCreateSandboxExtensionFromPasteboard): + Add helper function. + + (-[WKView performDragOperation:]): + Create a sandbox extension handle and pass it to performDrag. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::dragEntered): + (WebKit::WebPageProxy::dragUpdated): + (WebKit::WebPageProxy::dragExited): + Pass an empty sandbox extension handle to performDragControllerAction. + + (WebKit::WebPageProxy::performDrag): + Pass the sandbox extension handle along to performDragControllerAction. + + (WebKit::WebPageProxy::performDragControllerAction): + Send along the sandbox extension handle. + + * WebProcess/WebCoreSupport/WebDragClient.cpp: + (WebKit::WebDragClient::willPerformDragDestinationAction): + If the destination action is a load action, call WebPage::willPerformLoadDragDestinationAction. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::performDragControllerAction): + Create a sandbox extension. + + (WebKit::WebPage::willPerformLoadDragDestinationAction): + If we have a sandbox extension, pass it along to the sandbox extension tracker. + + (WebKit::WebPage::SandboxExtensionTracker::willPerformLoadDragDestinationAction): + Call setPendingProvisionalSandboxExtension. + + (WebKit::WebPage::SandboxExtensionTracker::beginLoad): + Call setPendingProvisionalSandboxExtension. + + (WebKit::WebPage::SandboxExtensionTracker::setPendingProvisionalSandboxExtension): + Factor code from beginLoad out into a separate function. + + * WebProcess/WebPage/WebPage.messages.in: + PerformDragControllerAction now takes a sandbox extension handle. + +2011-04-08 Alice Liu <alice.liu@apple.com> + + Reviewed by Adam Roben. + + https://bugs.webkit.org/show_bug.cgi?id=58151 + Crash after closing a Webview, in WebKit!WebCore::WindowMessageBroadcaster::SubclassedWndProc + + * UIProcess/win/WebView.cpp: + (WebKit::WebView::close): + Resolve a difference between old WebKit WebView and WebKit2 WebView by destroying and clearing + out WebKit2 WebView's HWND when closing. Not doing so was causing the WebView to remain in the + list of WindowMessageBroadcaster listeners, and after closing the WebView, WindowMessageBroadcaster + would message a dead WebView and crash. + +2011-04-08 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Make the drag operations be different functions + https://bugs.webkit.org/show_bug.cgi?id=58169 + + Since we want performDrag to take a sandbox extension, separate the four + drag operations out into different functions. No functionality change. + + * UIProcess/API/mac/WKView.mm: + (-[WKView draggingEntered:]): + (-[WKView draggingUpdated:]): + (-[WKView draggingExited:]): + (-[WKView performDragOperation:]): + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::dragEntered): + (WebKit::WebPageProxy::dragUpdated): + (WebKit::WebPageProxy::dragExited): + (WebKit::WebPageProxy::performDrag): + * UIProcess/WebPageProxy.h: + * UIProcess/win/WebView.cpp: + (WebKit::WebView::DragEnter): + (WebKit::WebView::DragOver): + (WebKit::WebView::DragLeave): + (WebKit::WebView::Drop): + +2011-04-08 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Parse 'DispatchOnConnectionQueue' in messages.in files + https://bugs.webkit.org/show_bug.cgi?id=58168 + + Handle parsing multiple, space-separated attributes in .messages.in files. Keep track of + 'DispatchOnConnectionQueue' and rename 'delayed' to 'Delayed'. + + * Scripts/webkit2/messages.py: + * Scripts/webkit2/messages_unittest.py: + +2011-04-08 Alpha Lam <hclam@chromium.org> + + Unreviewed, rolling out r83335. + http://trac.webkit.org/changeset/83335 + https://bugs.webkit.org/show_bug.cgi?id=53556 + + GTK and QT bots are broken + + * Configurations/FeatureDefines.xcconfig: + +2011-04-07 Anna Cavender <annacc@chromium.org> + + Reviewed by Eric Carlson. + + Setup ENABLE(TRACK) feature define + https://bugs.webkit.org/show_bug.cgi?id=53556 + + * Configurations/FeatureDefines.xcconfig: + +2011-04-07 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Alder. + + REGRESSION (WebKit2): AppKit thinks that web views don't support DocumentAccess + https://bugs.webkit.org/show_bug.cgi?id=58102 + <rdar://problem/9223246> + + * UIProcess/API/mac/WKView.h: + * UIProcess/API/mac/WKView.mm: + (-[WKView doCommandBySelector:]): + (-[WKView insertText:replacementRange:]): + (-[WKView validAttributesForMarkedText]): + (-[WKView setMarkedText:selectedRange:replacementRange:]): + (-[WKView attributedSubstringForProposedRange:actualRange:]): + (-[WKView firstRectForCharacterRange:actualRange:]): + Switch to NSTextInputClient, opting out of optimizations and optional features for now. + +2011-04-08 Siddharth Mathur <siddharth.mathur@nokia.com> + + Reviewed by Martin Robinson. + + [Qt][WK2][Symbian] Remove use of stack arrays with variable size + https://bugs.webkit.org/show_bug.cgi?id=57877 + + For better compiler portability, use new/delete for arrays when size + isn't known at compile time. Also fix one compiler warning about bitshift + operations on signed integer + * Platform/CoreIPC/unix/ConnectionUnix.cpp: + (CoreIPC::Connection::readyReadHandler): + (CoreIPC::Connection::sendOutgoingMessage): + +2011-04-08 Martin Robinson <mrobinson@igalia.com> + + Reviewed by Xan Lopez. + + [GTK] Fix the WebKit2 build for older versions of GTK+ + https://bugs.webkit.org/show_bug.cgi?id=58095 + + * UIProcess/gtk/ChunkedUpdateDrawingAreaProxyGtk.cpp: Include the GtkVersioning.h header. + +2011-04-07 Balazs Kelemen <kbalazs@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + [WK2][Qt][GTK] Introduce common use flag for the shared UNIX domain socket IPC implementation + https://bugs.webkit.org/show_bug.cgi?id=58030 + + Replace "PLATFORM(QT) || PLATFORM(GTK)" conditions in IPC code with + USE(UNIX_DOMAIN_SOCKETS). + + * Platform/CoreIPC/Attachment.h: + * Platform/CoreIPC/Connection.h: + * Platform/SharedMemory.h: + +2011-04-07 Anders Carlsson <andersca@apple.com> + + Reviewed by Simon Fraser. + + Clicks not recognized on http://www.nibblestutorials.net/ which uses Silverlight + https://bugs.webkit.org/show_bug.cgi?id=58108 + <rdar://problem/9167611> + + Change platformHandleMouseEvent to return true, which means that the plug-in has handled the + event. Some plug-ins (like Silverlight) will return false from NPP_HandleEvent even though the + event has been handled. In this case it lead to a very subtle bug where the plug-in element would + lose focus right after a mouse down even had been sent. + + * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: + (WebKit::NetscapePlugin::platformHandleMouseEvent): + +2011-04-07 Adam Roben <aroben@apple.com> + + Pass NPP_SetWindow a null window handle during plugin destruction on non-Mac platforms + + This matches WebKit1. + + Fixes <http://webkit.org/b/47009> WebKit2 needs to call NPP_SetWindow when destroying a + plugin + + Reviewed by Anders Carlsson. + + * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: + (WebKit::NetscapePlugin::destroy): Null out our NPWindow's window handle and pass it to + NPP_SetWindow (unless we're on Mac). + +2011-04-08 Jamie Cooley <james.cooley@nokia.com> + + Reviewed by Benjamin Poulain. + + [Qt][WK2] Make sure qwkhistory.h is copied into includes/WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=57945 + + * UIProcess/API/qt/WKView.h: + * UIProcess/API/qt/qwkhistory.h: + +2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Do not destroy WorkQueue event sources unless they have been cancelled + https://bugs.webkit.org/show_bug.cgi?id=57611 + + * Platform/WorkQueue.h: + * Platform/gtk/WorkQueueGtk.cpp: + (WorkQueue::EventSource::EventSource): Remove unused member + m_dispatchSource. + (WorkQueue::EventSource::executeEventSource): Make it return void + instead of boolean since we are always ignoring the return value. + (WorkQueue::EventSource::performWork): Return FALSE from the + callback only when the source has been cancelled (condition = 0) + to make sure it's destroyed when the even source handler is + unregistered. + (WorkQueue::registerEventSourceHandler): Use GRefPtr for the + source, to avoid leaking it. + (WorkQueue::scheduleWorkOnSource): Receive the source callback as + parameter so that it can be used by scheduleWorkOnTermination() too. + (WorkQueue::scheduleWork): + (WorkQueue::scheduleWorkAfterDelay): + (WorkQueue::scheduleWorkOnTermination): Use + scheduleWorkOnSource(). + +2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Close connection when web process finishes + https://bugs.webkit.org/show_bug.cgi?id=57540 + + * Platform/CoreIPC/Connection.h: + * Platform/CoreIPC/unix/ConnectionUnix.cpp: + * Platform/PlatformProcessIdentifier.h: Use GPid as process + identifier. + * Platform/WorkQueue.h: + * Platform/gtk/WorkQueueGtk.cpp: + (WorkQueue::EventSource::EventSource): Add cancellable parameter. + (WorkQueue::EventSource::cancel): New method to cancel the source. + (WorkQueue::EventSource::performWorkOnTermination): New method to + execute a work item called when child process has finished. + (WorkQueue::registerEventSourceHandler): Create a GCancellable for + the socket source. + (WorkQueue::unregisterEventSourceHandler): Cancel the source + instead of destroying it, this will cause the source to trigger + with condition = 0, which makes the callback return FALSE and the + source is destroyed. + (WorkQueue::scheduleWorkOnSource): Pass NULL as cancellable for + idle and timeout sources. + (WorkQueue::scheduleWorkOnTermination): Create a child watch + source to monitor the child process. + * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp: + (WebKit::ProcessLauncher::launchProcess): Use GPid instead of int + as process identifier. + * UIProcess/WebProcessProxy.cpp: + (WebKit::WebProcessProxy::didFinishLaunching): Call + WorkQueue::scheduleWorkOnTermination() for GTK platform too when + web process has been launched. + +2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Implement scheduleWorkAfterDelay() in WorkQueueGtk + https://bugs.webkit.org/show_bug.cgi?id=57434 + + * Platform/WorkQueue.h: + * Platform/gtk/WorkQueueGtk.cpp: + (WorkQueue::EventSource::executeEventSource): This new method + contains the common code to execute a work item. + (WorkQueue::EventSource::performWorkOnce): Use + executeEventSource() to execute the work item. + (WorkQueue::EventSource::performWork): Use executeEventSource() to + execute the work item. + (WorkQueue::registerEventSourceHandler): Use a GSocket instead of + a GIOChannel since the API is newer and allows us to pass a + cancellable object to be able to cancel the source. + (WorkQueue::scheduleWorkOnSource): This new method contains the + common code to attach a source to a context. It doesn't use a lock + anymore, since g_source_attach() uses its own mutex internally. + (WorkQueue::scheduleWork): Use an idle source instead of a timeout + one, changing the priority to G_PRIORITY_DEFAULT. + (WorkQueue::scheduleWorkAfterDelay): Implement it using a timeout + source with the given delay. + +2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Use glib API instead of fork + execl in ProcessLauncherGtk + https://bugs.webkit.org/show_bug.cgi?id=57234 + + * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp: + (WebKit::childSetupFunction): close the socket and use prctl() + when platform is Linux to kill the child process when the parent + finishes. + (WebKit::ProcessLauncher::launchProcess): Use g_spawn_async() to + launch the web process. + +2011-04-07 Geoffrey Garen <ggaren@apple.com> + + Some Handle<T> cleanup + https://bugs.webkit.org/show_bug.cgi?id=58109 + + * WebProcess/Plugins/Netscape/NPJSObject.cpp: + (WebKit::NPJSObject::NPJSObject): Updated for new null constructor. + +2011-04-07 Jessie Berlin <jberlin@apple.com> + + Max build fix. + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::checkSpellingOfString): + Do not risk an overflow. + (WebKit::WebEditorClient::checkGrammarOfString): + Ditto. + +2011-04-07 Jessie Berlin <jberlin@apple.com> + + Reviewed by Brian Weinstein. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 4: Implement checkGrammarOfString. + + * Scripts/webkit2/messages.py: + The generated files should include TextCheckerClient.h for WebCore::GrammarDetail. + + * Shared/API/c/win/WKBaseWin.h: + * Shared/APIObject.h: + * UIProcess/API/C/win/WKAPICastWin.h: + + * UIProcess/API/C/win/WKGrammarDetail.cpp: Added. + (WKGrammarDetailGetTypeID): + (WKGrammarDetailCreate): + * UIProcess/API/C/win/WKGrammarDetail.h: Added. + + * UIProcess/API/C/win/WKTextChecker.h: + Add the checkGrammarOfString WKTextCheckerClient function. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::checkGrammarOfString): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + + * UIProcess/TextChecker.h: + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::checkGrammarOfString): + Call the TextCheckerClient. + * UIProcess/mac/TextCheckerMac.mm: + (WebKit::TextChecker::checkSpellingOfString): + Add a comment about this not being used on Mac. + (WebKit::TextChecker::checkGrammarOfString): + Ditto, and call notImplemented. + * UIProcess/gtk/TextCheckerGtk.cpp: + (WebKit::TextChecker::checkGrammarOfString): + Call notImplemented. + * UIProcess/qt/TextCheckerQt.cpp: + (WebKit::TextChecker::checkGrammarOfString): + Ditto. + + * UIProcess/win/WebGrammarDetail.cpp: Added. + (WebKit::WebGrammarDetail::create): + (WebKit::WebGrammarDetail::WebGrammarDetail): + Initialize the underlying WebCore::GrammarDetail. + * UIProcess/win/WebGrammarDetail.h: Added. + (WebKit::WebGrammarDetail::grammarDetail): + (WebKit::WebGrammarDetail::type): + + * UIProcess/win/WebTextCheckerClient.cpp: + (WebKit::WebTextCheckerClient::checkGrammarOfString): + Populate the Vector of WebCore::GrammarDetails with the WebGrammarDetails. + * UIProcess/win/WebTextCheckerClient.h: + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::checkSpellingOfString): + Use WTF::notFound as the initial value for resultLocation. + (WebKit::WebEditorClient::checkGrammarOfString): + Send a sync message to the UI Process (similar to checkSpellingOfString and checkTextOfParagraph). + + * win/WebKit2.vcproj: + Add WKGrammarDetail.h/.cpp and WebGrammarDetail.h/.cpp. + * win/WebKit2Generated.make: + Copy over WKGrammarDetail.h. + +2011-04-07 Enrica Casucci <enrica@apple.com> + + Reviewed by Oliver Hunt. + + REGRESSION(WebKit2): execCommand('undo') doesn't work (Windows). + https://bugs.webkit.org/show_bug.cgi?id=58056 + <rdar://problem/8862023> + + Adding support for execCommand('undo') and execCommand('redo') + in WebKit2 for Windows. + + * UIProcess/API/C/win/WKView.h: + * UIProcess/win/WebUndoClient.cpp: + (WebKit::WebUndoClient::canUndoRedo): + (WebKit::WebUndoClient::executeUndoRedo): + * UIProcess/win/WebUndoClient.h: + * UIProcess/win/WebView.cpp: + (WebKit::WebView::canUndoRedo): + (WebKit::WebView::executeUndoRedo): + +2011-04-07 Andrew Scherkus <scherkus@chromium.org> + + Revert ENABLE_TRACK patch due to compile failures. + + * Configurations/FeatureDefines.xcconfig: + +2011-04-07 Martin Robinson <mrobinson@igalia.com> + + Fix the WebKit2 GTK+ build for older versions of GTK+. + + * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp: Include the GtkVersioning.h header. + +2011-04-07 Amruth Raj <amruthraj@motorola.com> and Martin Robinson <mrobinson@igalia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [GTK] Implement SharedMemory for WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=49791 + + Share the SharedMemory, Attachment and Connection implementations with the Qt port. + Both implementation are, in fact, general Unix implementations using standard Unix + domain sockets and sendmsg / recvmsg. This should reduce the amount of duplicated code + greatly and lay the groundwork for GTK+/Qt implementations for other operating systems. + + * GNUmakefile.am: Replaced GTK+ versions of files with the Unix ones. + * Platform/CoreIPC/ArgumentDecoder.cpp: Extended Qt #ifdefs to include GTK. + (CoreIPC::ArgumentDecoder::~ArgumentDecoder): + * Platform/CoreIPC/ArgumentEncoder.cpp: Ditto. + (CoreIPC::ArgumentEncoder::~ArgumentEncoder): + * Platform/CoreIPC/Attachment.h: Ditto. + * Platform/CoreIPC/Connection.h: Combined the GTK+ and Qt sections. + * Platform/CoreIPC/unix/AttachmentUnix.cpp: Renamed from Source/WebKit2/Platform/CoreIPC/qt/AttachmentQt.cpp. + * Platform/CoreIPC/unix/ConnectionUnix.cpp: Renamed from Source/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp. + * Platform/unix/SharedMemoryUnix.cpp: Renamed from Source/WebKit2/Platform/qt/SharedMemoryQt.cpp. + * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp: + (WebKit::ProcessLauncher::launchProcess): Use SOCK_DGRAM instead of SOCK_STREAM to match Qt. + * WebKit2.pro: Updated source list to reflect file renaming. + +2011-04-07 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Brian Weinstein. + + REGRESSION (r83081): Use of deallocated memory in WebEditorClient::respondToChangedSelection() + https://bugs.webkit.org/show_bug.cgi?id=58082 + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: (WebKit::WebEditorClient::respondToChangedSelection): + Now that the Range is used outside the full expression where it's created, it needs to be + protected with RefPtr. + +2011-04-07 Mark Rowe <mrowe@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/9251566> WebBackForwardList::createCFDictionaryRepresentation's current item index + doesn't account for items removed by filter callback. + + * UIProcess/cf/WebBackForwardListCF.cpp: + (WebKit::WebBackForwardList::createCFDictionaryRepresentation): Update the current item index + when we omit an item due to the filter callback. + +2011-04-07 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Anders Carlsson. + + REGRESSION (WebKit2): Reverse conversion doesn't work in Kotoeri + https://bugs.webkit.org/show_bug.cgi?id=58066 + <rdar://problem/8965302> + + * Scripts/webkit2/messages.py: + * Shared/mac/AttributedString.h: Added. + * Shared/mac/AttributedString.mm: Added. + (WebKit::AttributedString::encode): + (WebKit::AttributedString::decode): + Added an class that wraps NSAttributedString. As far as I can tell, one can't pass a CF + or NS object to another process without wrapping it in a C++ one. + + * Shared/mac/ArgumentCodersMac.h: Added. + * Shared/mac/ArgumentCodersMac.mm: Added. + Added coders for Foundation objects, similar to ArgumentCodersCF. There are two reasons why + these are needed: + 1) Even though most Foundation objects are toll free bridged with CF, CFGetTypeID() doesn't + work properly for them (I've been just getting 1). + 2) NSColor isn't toll free bridged to CF. + This adds just the types necessary for editing NSAttributedString (and I don't yet know what + happens with attachments). + + * UIProcess/API/mac/WKView.mm: (-[WKView attributedSubstringFromRange:]): + * UIProcess/WebPageProxy.h: + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::getAttributedSubstringFromRange): + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: + Boilerplate code for making a sync call to web process. + + * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::getAttributedSubstringFromRange): + Ported from WebHTMLView. + +2011-04-07 Jeff Miller <jeffm@apple.com> + + Mac build fix. + + * Shared/WebString.h: + (WebKit::WebString::getCharacters): Add explict cast when using std::min(). + +2011-04-07 Jeff Miller <jeffm@apple.com> + + Reviewed by Adam Roben. + + Replace WKStringGetCharactersPtr() with WKStringGetCharacters() + https://bugs.webkit.org/show_bug.cgi?id=58058 + + WKStringGetCharactersPtr() exposes the internal implementation of WKString, so change this to WKStringGetCharacters(), which makes a UTF-16 copy. + + * Shared/API/c/WKString.cpp: + (WKStringGetCharacters): Added, replaces WKStringGetCharactersPtr(). + * Shared/API/c/WKString.h: Replaced WKStringGetCharactersPtr() with WKStringGetCharacters(). + * Shared/WebString.h: + (WebKit::WebString::getCharacters): Added. + +2011-04-07 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Support window bounce when panning. + https://bugs.webkit.org/show_bug.cgi?id=58065 + <rdar://problem/9244367> + + Make gestureDidScroll synchronous, as once we scroll, we need to know + whether or not we are at the beginning or end of the scrollable document. + + If we are at either end of the scrollable document, we call the Windows 7 + API to bounce the window to give an indication that you are past an end + of the document. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::gestureDidScroll): Pass a boolean for the reply, and return it. + * UIProcess/WebPageProxy.h: + * UIProcess/win/WebView.cpp: + (WebKit::WebView::WebView): Inititalize a new variable. + (WebKit::WebView::onGesture): Once we send the message to scroll, check if have gone to + an end of the document, and if we have, bounce the window. + * UIProcess/win/WebView.h: + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: GestureDidScroll is now sync. + * WebProcess/WebPage/win/WebPageWin.cpp: + (WebKit::WebPage::gestureDidScroll): When we are done scrolling, check if we have a vertical + scrollbar and if we are at the beginning or the end of the scrollable document. + +2011-04-07 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.isPageBoxVisible + https://bugs.webkit.org/show_bug.cgi?id=42695 + + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundleIsPageBoxVisible): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::isPageBoxVisible): + * WebProcess/InjectedBundle/InjectedBundle.h: + +2011-04-07 Enrica Casucci <enrica@apple.com> + + Reviewed by Oliver Hunt. + + REGRESSION(WebKit2): execCommand('undo') doesn't work (Mac). + https://bugs.webkit.org/show_bug.cgi?id=58055 + <rdar://problem/8862023> + + Adding support for execCommand('undo') and execCommand('redo') + in WebKit2 for Mac. + + * UIProcess/API/mac/PageClientImpl.h: + * UIProcess/API/mac/PageClientImpl.mm: + (WebKit::PageClientImpl::canUndoRedo): Added interaction with undomanager. + (WebKit::PageClientImpl::executeUndoRedo): Added interaction with undomanager. + + Added new empty PageClient methods for other platforms. + * UIProcess/API/qt/qwkpage.cpp: + (QWKPagePrivate::canUndoRedo): + (QWKPagePrivate::executeUndoRedo): + * UIProcess/API/qt/qwkpage_p.h: + * UIProcess/PageClient.h: + * UIProcess/gtk/WebView.cpp: + (WebKit::WebView::canUndoRedo): + (WebKit::WebView::executeUndoRedo): + * UIProcess/gtk/WebView.h: + * UIProcess/win/WebView.cpp: + (WebKit::WebView::canUndoRedo): + (WebKit::WebView::executeUndoRedo): + * UIProcess/win/WebView.h: + + * UIProcess/WebEditCommandProxy.cpp: + (WebKit::WebEditCommandProxy::unapply): Added flag to allow dispatching + of asychronous messages while waiting for a sync message reply. + (WebKit::WebEditCommandProxy::reapply): Same as above. + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::canUndoRedo): + (WebKit::WebPageProxy::executeUndoRedo): + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * WebProcess/WebCoreSupport/WebEditorClient.cpp: Added missing implementation. + (WebKit::WebEditorClient::canUndo): + (WebKit::WebEditorClient::canRedo): + (WebKit::WebEditorClient::undo): + (WebKit::WebEditorClient::redo): + +2011-04-07 Brady Eidson <beidson@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/9250368> and https://bugs.webkit.org/show_bug.cgi?id=58062 + + * UIProcess/API/C/WKIconDatabase.cpp: + (WKIconDatabaseClose): + * UIProcess/API/C/WKIconDatabase.h: + + * UIProcess/WebIconDatabase.cpp: + (WebKit::WebIconDatabase::close): + * UIProcess/WebIconDatabase.h: + +2011-04-07 Jessie Berlin <jberlin@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 3: Implement checkSpellingOfString + + In WebCore, checkTextOfParagraph is only defined and used on platforms where + WTF_USE_UNIFIED_TEXT_CHECKING is defined (which right now is only non-Leopard and non-Tiger + Mac builds). + + On other platforms, checkSpellingOfString and checkGrammarOfString (coming in a separate + patch in an attempt to keep things easier to review) are used. + + * UIProcess/API/C/win/WKTextChecker.h: + * UIProcess/TextChecker.h: + Surround checkTextOfParagraph by #if USE(UNIFIED_TEXT_CHECKING) and add + checkSpellingOfString. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::checkTextOfParagraph): + Surround this by #if USE(UNIFIED_TEXT_CHECKING). + (WebKit::WebPageProxy::checkSpellingOfString): + Call through to the client. + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + Surround checkTextOfParagraph by #if USE(UNIFIED_TEXT_CHECKING) and add + checkSpellingOfString. + + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::checkSpellingOfString): + Call through to the WebTextCheckerClient. + * UIProcess/mac/TextCheckerMac.mm: + (WebKit::TextChecker::checkTextOfParagraph): + Surround this by #if USE(UNIFIED_TEXT_CHECKING) for clarity. + (WebKit::TextChecker::checkSpellingOfString): + Add a call to notImplemented. + * UIProcess/qt/TextCheckerQt.cpp: + (WebKit::TextChecker::checkSpellingOfString): + Ditto, and remove the implementation for checkTextOfParagraph. + * UIProcess/gtk/TextCheckerGtk.cpp: + (WebKit::TextChecker::checkSpellingOfString): + Ditto. + + * UIProcess/win/WebTextCheckerClient.cpp: + (WebKit::WebTextCheckerClient::checkSpellingOfString): + * UIProcess/win/WebTextCheckerClient.h: + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::checkSpellingOfString): + Send a sync message to the UI Process (similar to the sync message used for + checkTextOfParagraph). + +2011-04-07 Siddharth Mathur <siddharth.mathur@nokia.com> + + Reviewed by Laszlo Gombos. + + [Qt][WK2][Symbian] Temporary build fix until native Symbian IPC is done. Implement fake socketpair() as it's not available. + https://bugs.webkit.org/show_bug.cgi?id=57877 + + * UIProcess/Launcher/qt/ProcessLauncherQt.cpp: + (WebKit::socketpair): socketpair() which returns -1 + +2011-04-07 Michael Saboff <msaboff@apple.com> + + Reviewed by Maciej Stachowiak. + + WebKit2: Memory leak in decodeResourceError + https://bugs.webkit.org/show_bug.cgi?id=58004 + + Release the local NSError after it is used to create a ResourceError + object assigned to the reference argument. + + * Shared/mac/WebCoreArgumentCodersMac.mm: + (CoreIPC::decodeResourceError): + +2011-04-07 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Adam Barth. + + Remove temporary WebProcess sandbox rules that are unnecessary now that plugins are in their own process + https://bugs.webkit.org/show_bug.cgi?id=58023 + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-07 Maciej Stachowiak <mjs@apple.com> + + Reviewed by Dan Bernstein. + + Remove some no longer needed WebProcess sandbox allowances + https://bugs.webkit.org/show_bug.cgi?id=58015 + <rdar://problem/9232592> + + * WebProcess/com.apple.WebProcess.sb: Remove no-longer needed extra network + and launching privileges, since the bugs that required them are fixed. + +2011-04-06 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.pageSizeAndMarginsInPixels + https://bugs.webkit.org/show_bug.cgi?id=57984 + + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundlePageSizeAndMarginsInPixels): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::pageSizeAndMarginsInPixels): + * WebProcess/InjectedBundle/InjectedBundle.h: + +2011-04-06 Siddharth Mathur <siddharth.mathur@nokia.com> + + Reviewed by Benjamin Poulain. + + [Qt][WK2][Symbian] Remove use of stack arrays with variable size + https://bugs.webkit.org/show_bug.cgi?id=57877 + + For better compiler portability, use new/delete for arrays when size + isn't known at compile time. Also fix one compiler warning about bitshift + operations on signed integers. + * Platform/CoreIPC/qt/ConnectionQt.cpp: + (CoreIPC::Connection::readyReadHandler): + (CoreIPC::Connection::sendOutgoingMessage): + +2011-04-06 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Adam Roben. + + WebKit2: Support Windows 7 Gestures + https://bugs.webkit.org/show_bug.cgi?id=49824 + <rdar://problem/8689728> + + Port code from WebKit1 -> WebKit2 to handle Windows 7 gestures. + + The UIProcess gets a WM_GESTURENOTIFY message, it sends a sync message to the WebProcess to ask + if we should allow panning. The WebProcess checks if we're in a scrollable area, and the mouse + isn't over a scrollbar. + + The UIProcess then gets a WM_GESTURE message, and if it is a pan gesture, it sends a message to + the WebProcess to scroll by the amount fingers have moved since the last WM_GESTURE messeage. The + X and Y are reversed because panning up -> moving the page down, and vice versa. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::gestureWillBegin): Send a sync message to the WebProcess + to initialize the gesture. The WebProcess returns whether or not we can start a pan + gesture from where we are. + (WebKit::WebPageProxy::gestureDidScroll): Send a message to the WebProcess to scroll by + pan gesture. + (WebKit::WebPageProxy::gestureDidEnd): Send a message to the WebProcess that the gesture has ended. + * UIProcess/WebPageProxy.h: + * UIProcess/win/WebView.cpp: + (WebKit::WebView::wndProc): Add WM_GESTURE and WM_GESTURENOTIFY handlers. + (WebKit::WebView::WebView): Initialize two new variables. + (WebKit::WebView::onGestureNotify): Figure out which gestures we should support based on where + the gesture is beginning. + (WebKit::WebView::onGesture): Support starting a gesture, ending a gesture, and panning. + * UIProcess/win/WebView.h: + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: Add messages needed for gestures. + * WebProcess/WebPage/win/WebPageWin.cpp: + (WebKit::WebPage::gestureWillBegin): Set the node that the gesture started on (so we + know which layer to scroll if the user pans), and determine whether or not we should allow + panning. If the page can't scroll, or the user is on a scrollbar, disallow panning. + (WebKit::WebPage::gestureDidScroll): Scroll the enclosing layer of the element the gesture + started on. + (WebKit::WebPage::gestureDidEnd): Clear the node the gesture started on. + +2011-04-06 Jeff Miller <jeffm@apple.com> + + Reviewed by Adam Roben. + + Add WKStringGetCharactersPtr() and WKStringGetLength() to WebKit2 C API + https://bugs.webkit.org/show_bug.cgi?id=57989 + + Note that WKChar, which is returned by WKStringGetCharactersPtr(), is defined the same way we define JSChar in JSStringRef.h. + + * Shared/API/c/WKString.cpp: + (WKStringGetLength): Added. + (WKStringGetCharactersPtr): Added. + * Shared/API/c/WKString.h: Define WKChar and added WKStringGetLength() and WKStringGetCharactersPtr(). + * Shared/WebString.h: + (WebKit::WebString::length): Added. + (WebKit::WebString::characters): Added. + +2011-04-06 Anders Carlsson <andersca@apple.com> + + Reviewed by Oliver Hunt. + + Dock stays in front of Hulu.com full screen video output + https://bugs.webkit.org/show_bug.cgi?id=57988 + <rdar://problem/9216260> + + Instead of using -[NSMenu setMenuBarVisible:] to toggle full screen, use + -[NSApp setPresentationOptions:]. Also, make the UI process the front most app before + setting the presentation options when exiting full screen, otherwise the dock won't + be restored correctly. + + * PluginProcess/mac/PluginProcessShim.mm: + Remove some shim functions that aren't needed. + + * UIProcess/Plugins/PluginProcessProxy.cpp: + (WebKit::PluginProcessProxy::PluginProcessProxy): + Initialize m_preFullscreenAppPresentationOptions. + + * UIProcess/Plugins/PluginProcessProxy.h: + Add m_preFullscreenAppPresentationOptions. + + * UIProcess/Plugins/mac/PluginProcessProxyMac.mm: + (WebKit::PluginProcessProxy::enterFullscreen): + Change the presentation options for the app. + + (WebKit::PluginProcessProxy::exitFullscreen): + Restore the presentation options. + +2011-04-06 Mark Rowe <mrowe@apple.com> + + Reviewed by Darin Adler. + + Expose the original URL of a WKBackForwardListItem. + + Needed for <rdar://problem/9074651>. + + * UIProcess/API/C/WKBackForwardListItem.cpp: + (WKBackForwardListItemCopyOriginalURL): + * UIProcess/API/C/WKBackForwardListItem.h: + +2011-04-06 Brady Eidson <beidson@apple.com> + + Reviewed by Anders Carlsson. + + https://bugs.webkit.org/show_bug.cgi?id=57973 and https://bugs.webkit.org/show_bug.cgi?id=57973 + WK2 icon database should be able to get a CGImage of a specific size + + * UIProcess/API/C/cg/WKIconDatabaseCG.cpp: + (WKIconDatabaseTryGetCGImageForURL): Change this API to take a requested size, and find the first matching + CGImage in the icon. + * UIProcess/API/C/cg/WKIconDatabaseCG.h: + +2011-04-06 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 2: Implement uniqueSpellDocumentTag and closeSpellDocumentWithTag. + + * UIProcess/API/C/win/WKTextChecker.h: + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::uniqueSpellDocumentTag): + (WebKit::TextChecker::closeSpellDocumentWithTag): + * UIProcess/win/WebTextCheckerClient.cpp: + (WebKit::WebTextCheckerClient::uniqueSpellDocumentTag): + (WebKit::WebTextCheckerClient::closeSpellDocumentWithTag): + * UIProcess/win/WebTextCheckerClient.h: + +2011-04-06 Robert Sesek <rsesek@chromium.org> + + Reviewed by Alexey Proskuryakov. + + Move code duplicated between the WebKit/mac and WebKit2 down to WebCore because Chromium will need it too + https://bugs.webkit.org/show_bug.cgi?id=54969 + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::respondToChangedSelection): Moved duplicated code to WebCore + * WebProcess/WebPage/mac/WebPageMac.mm: Moved duplicated code to WebCore + (WebKit::WebPage::getMarkedRange): + (WebKit::WebPage::getSelectedRange): + (WebKit::WebPage::characterIndexForPoint): + (WebKit::WebPage::performDictionaryLookupAtLocation): + +2011-04-06 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.pageNumberForElementById + https://bugs.webkit.org/show_bug.cgi?id=42329 + + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundlePageNumberForElementById): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::pageNumberForElementById): + * WebProcess/InjectedBundle/InjectedBundle.h: + +2011-04-05 Enrica Casucci <enrica@apple.com> + + Reviewed by Darin Adler. + + REGRESSION: Drag & Drop Gmail Attachments doesn't work. + https://bugs.webkit.org/show_bug.cgi?id=57909 + <rdar://problem/9103220> + + Added _hitTest method to support drag and drop when the drag types cannot be matched. + This is the case for elements that do not place content + in the drag pasteboard automatically when the drag start (i.e. dragging a DIV element). + + * UIProcess/API/mac/WKView.mm: + (-[WKView _hitTest:dragTypes:]): Added. + +2011-04-06 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Darin Adler. + + Fix using UNUSED_PARAM introduced in r82907 + https://bugs.webkit.org/show_bug.cgi?id=57940 + + * WebProcess/ResourceCache/WebResourceCacheManager.cpp: + (WebKit::WebResourceCacheManager::clearCacheForOrigin): + +2011-04-06 Jessie Berlin <jberlin@apple.com> + + Reviewed by Anders Carlsson. + + WebKit2: Implement TextChecker on Windows + https://bugs.webkit.org/show_bug.cgi?id=57862 + + Part 1: Get and set the state. + + * Shared/API/c/win/WKBaseWin.h: + * Shared/APIObject.h: + * UIProcess/API/C/win/WKAPICastWin.h: + + * UIProcess/API/C/win/WKTextChecker.cpp: Added. + (WKTextCheckerSetClient): + (WKTextCheckerContinuousSpellCheckingEnabledStateChanged): + (WKTextCheckerGrammarCheckingEnabledStateChanged): + * UIProcess/API/C/win/WKTextChecker.h: Added. + + * UIProcess/TextChecker.h: + * UIProcess/win/TextCheckerWin.cpp: + (WebKit::TextChecker::state): + Do the initalization for the state only once so that it is not necessary to call the client + every time the state is requested. + (WebKit::TextChecker::isContinuousSpellCheckingAllowed): + Call the client. + (WebKit::TextChecker::setContinuousSpellCheckingEnabled): + Update the state and tell the client. + (WebKit::TextChecker::setGrammarCheckingEnabled): + Ditto. + (WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged): + Update the state. + (WebKit::TextChecker::grammarCheckingEnabledStateChanged): + Update the state. + + * UIProcess/win/WebTextChecker.cpp: Added. + (WebKit::WebTextChecker::shared): + Make the WebTextChecker available globally. + (WebKit::WebTextChecker::WebTextChecker): + (WebKit::WebTextChecker::setClient): + (WebKit::updateStateForAllWebProcesses): + (WebKit::WebTextChecker::continuousSpellCheckingEnabledStateChanged): + Tell the TextChecker that the state has changed, and then tell the + WebProcessProxies to send the new state to the WebProcesses. + (WebKit::WebTextChecker::grammarCheckingEnabledStateChanged): + Ditto. + * UIProcess/win/WebTextChecker.h: Added. + (WebKit::WebTextChecker::client): + (WebKit::WebTextChecker::type): + + * UIProcess/win/WebTextCheckerClient.cpp: Added. + (WebKit::WebTextCheckerClient::continuousSpellCheckingAllowed): + (WebKit::WebTextCheckerClient::continuousSpellCheckingEnabled): + (WebKit::WebTextCheckerClient::setContinuousSpellCheckingEnabled): + (WebKit::WebTextCheckerClient::grammarCheckingEnabled): + (WebKit::WebTextCheckerClient::setGrammarCheckingEnabled): + * UIProcess/win/WebTextCheckerClient.h: Added. + + * win/WebKit2.vcproj: + Add WKTextChecker.h/.cpp, WebTextChecker.h/.cpp, and WebTextCheckerClient.h/.cpp. + * win/WebKit2Generated.make: + Copy over WKTextChecker.h. + +2011-04-05 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.numberOfPages + https://bugs.webkit.org/show_bug.cgi?id=42694 + + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundleNumberOfPages): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::numberOfPages): + * WebProcess/InjectedBundle/InjectedBundle.h: + +2011-04-05 Darin Adler <darin@apple.com> + + Reviewed by Alexey Proskuryakov. + + [Mac] WebKit2: Escape key does not stop page loads when focus is on the web page + https://bugs.webkit.org/show_bug.cgi?id=57893 + <rdar://problem/9130486> + + * UIProcess/API/mac/PageClientImpl.h: Added executeSavedCommandBySelector. + * UIProcess/API/mac/PageClientImpl.mm: Renamed internal Objective-C classes to use + the WebKit2 Objective-C class prefix, WK, rather than the WebKit1 Objective-C class + prefix, Web. Removed some unneeded explicit WebKit namespace prefixes. + (-[WKEditCommandObjC initWithWebEditCommandProxy:]): Removed unneeded WebKit + namespace prefix. + (-[WKEditCommandObjC command]): Ditto. + (-[WKEditorUndoTargetObjC undoEditing:]): Updated for new class name. + (-[WKEditorUndoTargetObjC redoEditing:]): Ditto. + (WebKit::PageClientImpl::PageClientImpl): Ditto. + (WebKit::PageClientImpl::registerEditCommand): Ditto. + (WebKit::PageClientImpl::executeSavedCommandBySelector): Added. + + * UIProcess/API/mac/WKView.mm: Renamed internal Objective-C categories to use the + WebKit2 Objective-C prefix, WK, rather than the WebKit1 Objective-C prefix, Web, + or no prefix at all. Tweaked use of extern "C" a little. + (-[WKView doCommandBySelector:]): Tweaked the comment. + (-[WKView _executeSavedCommandBySelector:]): Added. For use when command is not handled + by WebCore. + (-[WKResponderChainSink initWithResponderChain:]): Added. Based on the + WebResponderChainSink class in WebKit1. + (-[WKResponderChainSink detach]): Added. + (-[WKResponderChainSink didReceiveUnhandledCommand]): Added. + (-[WKResponderChainSink noResponderFor:]): Added. + (-[WKResponderChainSink doCommandBySelector:]): Added. + (-[WKResponderChainSink tryToPerform:with:]): Added. + + * UIProcess/API/mac/WKViewInternal.h: Added declaration of _executeSavedCommandBySelector: + method. Also removed unneeded includes. + + * UIProcess/PageClient.h: Added executeSavedCommandBySelector. + * UIProcess/WebPageProxy.h: Added executeSavedCommandBySelector. + * UIProcess/WebPageProxy.messages.in: Added ExecuteSavedCommandBySelector. + + * UIProcess/mac/WebFullScreenManagerProxyMac.mm: Updated includes. + + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::executeSavedCommandBySelector): Added. + + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::executeKeypressCommandsInternal): Send the synchronous + ExecuteSavedCommandBySelector message when a command is not handled by WebCore. + +2011-04-05 Anders Carlsson <andersca@apple.com> + + Reviewed by Alexey Proskuryakov. + + Some plug-in content is displayed upside down in Unity plug-in + https://bugs.webkit.org/show_bug.cgi?id=57895 + <rdar://problem/9212003> + + Create the flipped geometry layer in the web process instead of the plug-in process, + which matches what we do in WebKit1. + + * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: + (WebKit::NetscapePlugin::platformPostInitialize): + * WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm: + (WebKit::PluginProxy::pluginLayer): + +2011-04-05 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Assertion failure when navigating quickly between file URLs + https://bugs.webkit.org/show_bug.cgi?id=57884 + <rdar://problem/9080559> + + Remove bogus assertion. The pending provisional sandbox extension can be + non-null if the current provisional load fails because we're about to load a new + page that also has a sandbox extension. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::SandboxExtensionTracker::didFailProvisionalLoad): + +2011-04-05 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Grant the web process access to ~/Library/Preferences/com.apple.universalaccess.plist + https://bugs.webkit.org/show_bug.cgi?id=57879 + + The web process needs access to the unviersal access preferences to determine if full keyboard + access is enabled. I've filed <rdar://problem/9237619> which tracks reading this preference in the UI + process and sending it over to the web process whenever it changes. + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-05 Dean Jackson <dino@apple.com> + + Reviewed by Simon Fraser. + + Add parentheses around && within || to avoid clang warning. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): + +2011-04-05 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Add two more entries to the sandbox profile + https://bugs.webkit.org/show_bug.cgi?id=57875 + + Allow read-access to /Library/Dictionaries since WebCore::nextBreakablePosition + ends up calling into ICU which accesses the dictionary. + + Allow Mach access to com.apple.networkd since it's used by CFNetwork. + + * WebProcess/com.apple.WebProcess.sb: + +2011-04-05 Anders Carlsson <andersca@apple.com> + + Reviewed by Oliver Hunt. + + Invalidate callbacks if the WebPageProxy is no longer valid + https://bugs.webkit.org/show_bug.cgi?id=57873 + <rdar://problem/9059717> + + Audit all function calls that take callbacks and make sure to invalidate the callbacks + if the web page is no longer valid. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::runJavaScriptInMainFrame): + (WebKit::WebPageProxy::getRenderTreeExternalRepresentation): + (WebKit::WebPageProxy::getSourceForFrame): + (WebKit::WebPageProxy::getContentsAsString): + (WebKit::WebPageProxy::getSelectionOrContentsAsString): + (WebKit::WebPageProxy::getMainResourceDataOfFrame): + (WebKit::WebPageProxy::getResourceDataFromFrame): + (WebKit::WebPageProxy::getWebArchiveOfFrame): + (WebKit::WebPageProxy::forceRepaint): + (WebKit::WebPageProxy::computePagesForPrinting): + (WebKit::WebPageProxy::drawRectToPDF): + (WebKit::WebPageProxy::drawPagesToPDF): + +2011-04-05 Adam Roben <aroben@apple.com> + + Disable accelerated compositing on Windows machines that don't support it + + This includes machines without the necessary graphics hardware, and machines without + WebKitQuartzCoreAdditions (like the Windows 7 Release (WebKit2 Tests) bots). + + Fixes <http://webkit.org/b/57870> REGRESSION (r82960): Lots of tests crashing in + DrawingAreaImpl::enterAcceleratedCompositingMode on Windows 7 Release (WebKit2 Tests) + + Reviewed by Anders Carlsson. + + * WebProcess/WebPage/LayerTreeHost.h: + (WebKit::LayerTreeHost::supportsAcceleratedCompositing): Added. On platforms other than + Windows, this always returns true. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::updatePreferences): Only enable accelerated compositing-related + preferences if the machine supports accelerated compositing. + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp: + (WebKit::LayerTreeHostCAWin::supportsAcceleratedCompositing): Added. Creates a view, asks it + if it can draw, and returns the result. + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h: Added supportsAcceleratedCompositing. + + * WebProcess/WebPage/win/LayerTreeHostWin.cpp: Added. + (WebKit::LayerTreeHost::supportsAcceleratedCompositing): Added. Calls through to + LayerTreeHostCAWin in configurations that support that class. Otherwise just returns false. + + * win/WebKit2.vcproj: Added LayerTreeHostWin.cpp. Let VS reorder some other files. + +2011-04-05 Adam Roben <aroben@apple.com> + + Make accelerated compositing work in WebKit2 on Windows + + LayerTreeHostCAWin uses WKCACFView to render each frame to an image, then has + DrawingAreaImpl send that image over to the UI process (just like it does for + non-accelerated rendering). It's unfortunate that this requires reading every frame back + from the GPU into system memory. More efficient solutions can be explored in the future. + + Fixes <http://webkit.org/b/45567>. + + Reviewed by Anders Carlsson. + + * DerivedSources.make: Added $(WebKit2) to the VPATH so that DerivedSources.make can be + found when used as a target dependency. Added rules to generate a HeaderDetection.h file on + Windows. If we can find WebKitQuartzCoreAdditions headers, we define HAVE_WKQCA in + HeaderDetection.h. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::setLayerHostNeedsDisplay): + * WebProcess/WebPage/DrawingAreaImpl.h: + Added setLayerHostNeedsDisplay. Lets the layer host tell the DrawingAreaImpl that it has a + new frame to render. This should only be called by layer hosts that participate in + DrawingAreaImpl's display mechanism. + + * WebProcess/WebPage/LayerTreeHost.cpp: + (WebKit::LayerTreeHost::create): Only try to instantiate LayerTreeHostCAWin if we have + WebKitQuartzCoreAdditions, since it depends on that library. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::updatePreferences): Removed code that forced accelerated compositing to be + disabled on Windows. + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp: + (WebKit::registerDummyWindowClass): Registers the window class we use for the dummy window. + (WebKit::createDummyWindow): Creates the dummy window we pass to WKCACFView so that D3D can + determine the display mode, etc. (The window is never shown on screen.) + (WebKit::LayerTreeHostCAWin::LayerTreeHostCAWin): Initialize new members. + (WebKit::LayerTreeHostCAWin::platformInitialize): Create our dummy window and view and + associate the two. We set ourselves as the view's context's user data so that + PlatformCALayer can get our AbstractCACFLayerTreeHost pointer as needed. + (WebKit::LayerTreeHostCAWin::invalidate): Cancel any pending flushes, tear down our view, + and destroy the dummy window if no other layer host is using it. + (WebKit::LayerTreeHostCAWin::scheduleLayerFlush): Ask LayerChangesFlusher to call us back + soon to perform the flush. + (WebKit::LayerTreeHostCAWin::participatesInDisplay): Added. Returns true, since we render + each frame to an image. + (WebKit::LayerTreeHostCAWin::needsDisplay): Added. Returns true if it's now time to + displayReturns true if it's now time to display. + (WebKit::LayerTreeHostCAWin::timeUntilNextDisplay): Added. Returns how many seconds remain + before we need to display again. + (WebKit::size): Added. Helper function to get the size of a WKCACFImage. + (WebKit::toShareableBitmap): Added. Helper function to convert a WKCACFImage to a + ShareableBitmap. + (WebKit::LayerTreeHostCAWin::display): Added. Renders the next frame to an image and stuffs + the image into the UpdateInfo struct. + (WebKit::LayerTreeHostCAWin::sizeDidChange): Added. Tells the view about the new size. + (WebKit::LayerTreeHostCAWin::forceRepaint): Added. Flushes any pending changes to the view. + (WebKit::LayerTreeHostCAWin::contextDidChangeCallback): Added. WKCACFView calls this + whenever any changes made to the view or its layer tree have been flushed. Just calls + through to contextDidChange. + (WebKit::LayerTreeHostCAWin::contextDidChange): Added. Tells layers that they've started + animating, and tells the DrawingAreaImpl that we need to display again. + (WebKit::LayerTreeHostCAWin::rootLayer): Added. Gets the root layer's PlatformCALayer. + (WebKit::LayerTreeHostCAWin::addPendingAnimatedLayer): Added. Stores the layer so that we + can tell it animations have started the next time we get a contextDidChange callback. + (WebKit::LayerTreeHostCAWin::layerTreeDidChange): Added. Schedules a flush, unless we're + already in the process of flushing. This code came from WebCore::WKCACFViewLayerTreeHost. + (WebKit::LayerTreeHostCAWin::flushPendingLayerChangesNow): Added. Performs the flush. This + code was adapted from WebCore::WKCACFViewLayerTreeHost. + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h: Wrapped this whole header in HAVE(WKQCA), + since this class only works when WebKitQuartzCoreAdditions is available. Added a bunch of + new members. + +2011-04-04 Adam Roben <aroben@apple.com> + + Add a way for LayerTreeHost to participate in DrawingAreaImpl's normal display mechanism + + When LayerTreeHost participates in display, it renders each frame into a bitmap. + DrawingAreaImpl sends the bitmap to the UI process in an Update message, just like in + non-accelerated compositing mode. The UI process never knows that accelerated compositing is + going on. (When LayerTreeHost does not participate in display, as on Mac, it is responsible + for getting bits from the web process to the UI process.) + + No LayerTreeHost uses this mechanism (yet). This patch should cause no change in behavior. + + Fixes <http://webkit.org/b/57792> LayerTreeHost needs a way to render frames to a bitmap + + Reviewed by Anders Carlsson. + + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::forceRepaint): If the layer tree host participates in display, + perform a display (like in the non-accelerated case). + (WebKit::DrawingAreaImpl::layerHostDidFlushLayers): Don't send an + EnterAcceleratedCompositing message to the UI process if the layer tree host participates in + display. In that case, the UI process doesn't even need to know we're using accelerated + compositing in the web process. + (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Go through the normal display + mechanism if we have a layer tree host that participates in display. + (WebKit::DrawingAreaImpl::didUpdate): Don't ignore DidUpdate messages when we have a layer + tree host that participates in display. + (WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode): If the new layer tree host + participates in display, let the display timer continue to run and continue to expect + DidUpdate messages so that we don't interrupt the normal display mechanism. We still clear + out m_dirtyRegion, m_scrollRect, and m_scrollOffset, though, because the layer tree host is + still responsible for keeping track of those things even when it participates in display. + (WebKit::DrawingAreaImpl::exitAcceleratedCompositingMode): If the outgoing layer tree host + was participating in display, just send another Update message instead of an + ExitAcceleratedCompositing message, since the UI process never even knew we were using + accelerated compositing. + (WebKit::DrawingAreaImpl::displayTimerFired): If we have a layer tree host that's + participating in display, ask it when it next needs to display when scheduling our timer. + + (WebKit::DrawingAreaImpl::scheduleDisplay): + (WebKit::DrawingAreaImpl::display): + If we have a layer tree host that's participating in display, it will keep track of its own + dirty region, so ask it if it needs display rather than checking our own dirty region. + + (WebKit::DrawingAreaImpl::display): If we have a layer tree host that's participating in + display, don't bail out. Instead, tell it to display rather than asking the page to paint. + Moved the setting of updateInfo.viewSize earlier so that it will be set even when the layer + tree host is displaying. Other changes are just due to indentation. + + * WebProcess/WebPage/LayerTreeHost.h: + (WebKit::LayerTreeHost::participatesInDisplay): + (WebKit::LayerTreeHost::needsDisplay): + (WebKit::LayerTreeHost::timeUntilNextDisplay): + (WebKit::LayerTreeHost::display): + Stubbed out these functions. Derived classes can override them to participate in display. + +2011-04-04 MORITA Hajime <morrita@google.com> + + Reviewed by Ryosuke Niwa. + + [Refactoring] SpellCheckingResult should be replaced with TextCheckingResult + https://bugs.webkit.org/show_bug.cgi?id=56085 + + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + (WebKit::WebEditorClient::requestCheckingOfString): + * WebProcess/WebCoreSupport/WebEditorClient.h: + * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: + (WebKit::WebEditorClient::checkTextOfParagraph): + +2011-04-05 Alejandro G. Castro <alex@igalia.com> + + Another compilation fix after r82929 horrible patch merge. + + * UIProcess/WebPageProxy.messages.in: + +2011-04-05 Alejandro G. Castro <alex@igalia.com> + + Fix compilation error after r82929. + + * WebProcess/WebPage/WebPage.h: + +2011-04-05 Amruth Raj <amruthraj@motorola.com>, Ravi Phaneendra Kasibhatla <ravi.kasibhatla@motorola.com> and Alejandro G. Castro <alex@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Implement WebPage class for WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=54230 + + Added functions to handle the generation of commands from the + keycodes. + + * GNUmakefile.am: + * Scripts/webkit2/messages.py: + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * UIProcess/gtk/WebPageProxyGtk.cpp: + (WebKit::WebPageProxy::getEditorCommandsForKeyEvent): + * UIProcess/gtk/WebView.cpp: + (WebKit::backspaceCallback): + (WebKit::selectAllCallback): + (WebKit::cutClipboardCallback): + (WebKit::copyClipboardCallback): + (WebKit::pasteClipboardCallback): + (WebKit::toggleOverwriteCallback): + (WebKit::popupMenuCallback): + (WebKit::showHelpCallback): + (WebKit::deleteFromCursorCallback): + (WebKit::moveCursorCallback): + (WebKit::WebView::WebView): + (WebKit::WebView::getEditorCommandsForKeyEvent): + * UIProcess/gtk/WebView.h: + (WebKit::WebView::addPendingEditorCommand): + * WebProcess/WebCoreSupport/WebEditorClient.cpp: + * WebProcess/WebCoreSupport/WebEditorClient.h: + * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp: Added. + (WebKit::WebEditorClient::getEditorCommandsForKeyEvent): + (WebKit::WebEditorClient::executePendingEditorCommands): + (WebKit::WebEditorClient::handleKeyboardEvent): + (WebKit::WebEditorClient::handleInputMethodKeydown): + * WebProcess/WebPage/WebPage.cpp: + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/gtk/WebPageGtk.cpp: Added. + (WebKit::WebPage::platformInitialize): + (WebKit::WebPage::platformPreferencesDidChange): + (WebKit::scroll): + (WebKit::WebPage::performDefaultBehaviorForKeyEvent): + (WebKit::WebPage::platformHasLocalDataForURL): + (WebKit::WebPage::cachedResponseMIMETypeForURL): + (WebKit::WebPage::platformCanHandleRequest): + +2011-04-05 Csaba Osztrogonác <ossy@webkit.org> + + Remove duplicate API from WKContext + <rdar://problem/8727879> + https://bugs.webkit.org/show_bug.cgi?id=57815 + + Unreviewed buildfix after r82906. + + Add UNUSED_PARAM to resourceCachesToClear, because + it is only used within #if USE(CFURLCACHE) guard. + + * WebProcess/ResourceCache/WebResourceCacheManager.cpp: + (WebKit::WebResourceCacheManager::clearCacheForOrigin): + +2011-04-04 Sam Weinig <sam@webkit.org> + + Reviewed by Brian Weinstein. + + Remove duplicate API from WKContext + <rdar://problem/8727879> + https://bugs.webkit.org/show_bug.cgi?id=57815 + + - Remove WKContextClearResourceCaches and WKContextClearApplicationCache in favor + of their more modern counterparts WKResourceCacheManagerClearCacheForAllOrigins + and WKApplicationCacheManagerDeleteAllEntries. + + - Expand clearing functionality of WKResourceCacheManager by adding type of resources + to clear. + + * Shared/WebProcessCreationParameters.cpp: + (WebKit::WebProcessCreationParameters::WebProcessCreationParameters): + (WebKit::WebProcessCreationParameters::encode): + (WebKit::WebProcessCreationParameters::decode): + * Shared/WebProcessCreationParameters.h: + Remove clearing bools. + + * UIProcess/API/C/WKAPICast.h: + (WebKit::toResourceCachesToClear): + Update for new name of enum. + + * UIProcess/API/C/WKContext.cpp: + * UIProcess/API/C/WKContext.h: + Remove WKContextClearResourceCaches and WKContextClearApplicationCache. + + * UIProcess/API/C/WKResourceCacheManager.cpp: + (WKResourceCacheManagerClearCacheForOrigin): + (WKResourceCacheManagerClearCacheForAllOrigins): + * UIProcess/API/C/WKResourceCacheManager.h: + Add WKResourceCachesToClear enum and use it in the clearing functions. + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::WebContext): + (WebKit::WebContext::ensureWebProcess): + * UIProcess/WebContext.h: + * WebProcess/WebProcess.messages.in: + Remove clearing functions and setting of bools for clear on launch. + + * UIProcess/WebFullScreenManagerProxy.cpp: + Remove unnecessary #include. + + * UIProcess/WebResourceCacheManagerProxy.cpp: + (WebKit::WebResourceCacheManagerProxy::clearCacheForOrigin): + (WebKit::WebResourceCacheManagerProxy::clearCacheForAllOrigins): + * UIProcess/WebResourceCacheManagerProxy.h: + * WebProcess/ResourceCache/WebResourceCacheManager.cpp: + (WebKit::WebResourceCacheManager::clearCacheForOrigin): + (WebKit::WebResourceCacheManager::clearCacheForAllOrigins): + * WebProcess/ResourceCache/WebResourceCacheManager.h: + * WebProcess/ResourceCache/WebResourceCacheManager.messages.in: + Add enum parameter describing what type of caches to clear. + + * WebProcess/WebProcess.cpp: + (WebKit::WebProcess::initializeWebProcess): + (WebKit::WebProcess::clearResourceCaches): + * WebProcess/WebProcess.h: + No longer need to use opaque type now that it is not a message receiver. + +2011-04-04 David Kilzer <ddkilzer@apple.com> + + <http://webkit.org/b/57384> CFNetwork and WebCore load priorities should match + + Reviewed by Alexey Proskuryakov. + + * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: + (InitWebCoreSystemInterface): Added initialization for + wkSetHTTPPipeliningMaximumPriority(). + +2011-04-04 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Send NPCocoaEventFlagsChanged events + https://bugs.webkit.org/show_bug.cgi?id=57811 + <rdar://problem/9215600> + + * Shared/WebEvent.h: + (WebKit::WebEvent::capsLockKey): + Add CapsLock modifier and getter. + + * Shared/mac/WebEventFactory.mm: + (WebKit::modifiersForEvent): + Check for NSAlphaShiftKeyMask and set the CapsLockKey modifier. + + * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: + (WebKit::modifierFlags): + Check for CapsLockKey and set NSAlphaShiftKeyMask. + + (WebKit::isFlagsChangedEvent): + Return whether a given event is a Cocoa flags changed event. + + (WebKit::initializeKeyboardEvent): + If this is a flags changed event, set the event type to NPCocoaEventFlagsChanged. + +2011-04-04 Anders Carlsson <andersca@apple.com> + + Reviewed by Darin Adler. + + Don't discard the backing stores of WKViews in the key window + https://bugs.webkit.org/show_bug.cgi?id=57808 + <rdar://problem/9110793> + <rdar://problem/9194284> + <rdar://problem/9222216> + + * UIProcess/DrawingAreaProxy.h: + (WebKit::DrawingAreaProxy::setBackingStoreIsDiscardable): + Add empty stub. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::DrawingAreaProxyImpl): + Initialize m_isBackingStoreDiscardable to true. + + (WebKit::DrawingAreaProxyImpl::setBackingStoreIsDiscardable): + Set m_isBackingStoreDiscardable and schedule or stop the discard backing store timer. + + (WebKit::DrawingAreaProxyImpl::discardBackingStoreSoon): + Don't start the timer if m_isBackingStoreDiscardable is false. + + * UIProcess/DrawingAreaProxyImpl.h: + Add m_isBackingStoreDiscardable. + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::viewStateDidChange): + Mark the backing store as discardable if the view is hidden or if the containing window + is not active. + +2011-04-04 Jade Han <jade.han@nokia.com> + + Reviewed by Csaba Osztrogonác. + + Symbian build fix. + https://bugs.webkit.org/show_bug.cgi?id=54977 + + * config.h: + +2011-04-04 Brady Eidson <beidson@apple.com> + + Rubberstamped by Adam Roben. + + Add WKIconDatabase* headers to the WebKit2 export for Windows: + * win/WebKit2Generated.make: + +2011-04-04 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Get rid of WebContext::process() in more places + https://bugs.webkit.org/show_bug.cgi?id=57787 + + Migrate calls to WebContext::process() over to sendToAllProcesses and + sendToAllProcessesRelaunchingThemIfNecessary. + + Add FIXMEs for things that need to be fixed in order to support multiple web processes. + + * UIProcess/Downloads/DownloadProxy.cpp: + (WebKit::DownloadProxy::cancel): + * UIProcess/Plugins/WebPluginSiteDataManager.cpp: + (WebKit::WebPluginSiteDataManager::getSitesWithData): + (WebKit::WebPluginSiteDataManager::clearSiteData): + * UIProcess/VisitedLinkProvider.cpp: + (WebKit::VisitedLinkProvider::pendingVisitedLinksTimerFired): + * UIProcess/WebApplicationCacheManagerProxy.cpp: + (WebKit::WebApplicationCacheManagerProxy::getApplicationCacheOrigins): + (WebKit::WebApplicationCacheManagerProxy::deleteEntriesForOrigin): + (WebKit::WebApplicationCacheManagerProxy::deleteAllEntries): + * UIProcess/WebCookieManagerProxy.cpp: + (WebKit::WebCookieManagerProxy::getHostnamesWithCookies): + (WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy): + * UIProcess/WebDatabaseManagerProxy.cpp: + (WebKit::WebDatabaseManagerProxy::getDatabasesByOrigin): + (WebKit::WebDatabaseManagerProxy::getDatabaseOrigins): + (WebKit::WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin): + (WebKit::WebDatabaseManagerProxy::deleteDatabasesForOrigin): + (WebKit::WebDatabaseManagerProxy::deleteAllDatabases): + (WebKit::WebDatabaseManagerProxy::setQuotaForOrigin): + * UIProcess/WebGeolocationManagerProxy.cpp: + (WebKit::WebGeolocationManagerProxy::providerDidChangePosition): + (WebKit::WebGeolocationManagerProxy::providerDidFailToDeterminePosition): + * UIProcess/WebIconDatabase.cpp: + (WebKit::WebIconDatabase::getLoadDecisionForIconURL): + (WebKit::WebIconDatabase::didFinishURLImport): + * UIProcess/WebKeyValueStorageManagerProxy.cpp: + (WebKit::WebKeyValueStorageManagerProxy::getKeyValueStorageOrigins): + (WebKit::WebKeyValueStorageManagerProxy::deleteEntriesForOrigin): + (WebKit::WebKeyValueStorageManagerProxy::deleteAllEntries): + * UIProcess/WebMediaCacheManagerProxy.cpp: + (WebKit::WebMediaCacheManagerProxy::getHostnamesWithMediaCache): + (WebKit::WebMediaCacheManagerProxy::clearCacheForHostname): + (WebKit::WebMediaCacheManagerProxy::clearCacheForAllHostnames): + * UIProcess/WebResourceCacheManagerProxy.cpp: + (WebKit::WebResourceCacheManagerProxy::getCacheOrigins): + (WebKit::WebResourceCacheManagerProxy::clearCacheForOrigin): + (WebKit::WebResourceCacheManagerProxy::clearCacheForAllOrigins): + +2011-04-04 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Dan Bernstein. + + REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=51230 + <rdar://problem/8780989> + + <rdar://problem/9015250> REGRESSION (WebKit2): Key events not fired for modifier keys + + * UIProcess/API/mac/WKView.mm: + (-[WKView flagsChanged:]): Ported from WebHTMLView. + (-[WKView _interpretKeyEvent:withCachedTextInputState:savingCommandsTo:WebCore::]): + AppKit isn't happy about attempts to interpret NSFlagsChanged, but WK2 lacked the check. + +2011-04-04 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Adam Roben. + + Remove unused AnalyzeWithLargeStack code from Windows build files + https://bugs.webkit.org/show_bug.cgi?id=57771 + + This was used for us to build with prefast automatically, + but it is out-of-date and hasn't been used for some time. + Removing completely for now. + + * win/WebKitPreBuild.cmd: + +2011-04-04 Anders Carlsson <andersca@apple.com> + + Attempt to fix the Windows build. + + * UIProcess/win/WebContextWin.cpp: + (WebKit::WebContext::setShouldPaintNativeControls): + +2011-04-04 Anders Carlsson <andersca@apple.com> + + Reviewed by Adam Roben. + + Make it easier to send a message to all processes in a context + https://bugs.webkit.org/show_bug.cgi?id=57776 + + Add WebContext::sendToAllProcesses and WebContext::sendToAllProcessesRelaunchingThemIfNecessary + as a first step towards getting rid of WebContext::process() and getting rid of a class of crashers + where WebContext::process() is null. + + * UIProcess/WebContext.cpp: + (WebKit::WebContext::initializeHistoryClient): + (WebKit::WebContext::languageChanged): + (WebKit::WebContext::setAlwaysUsesComplexTextCodePath): + (WebKit::WebContext::registerURLSchemeAsEmptyDocument): + (WebKit::WebContext::registerURLSchemeAsSecure): + (WebKit::WebContext::setDomainRelaxationForbiddenForURLScheme): + (WebKit::WebContext::setCacheModel): + (WebKit::WebContext::setDefaultRequestTimeoutInterval): + (WebKit::WebContext::clearResourceCaches): + (WebKit::WebContext::clearApplicationCache): + (WebKit::WebContext::setEnhancedAccessibility): + (WebKit::WebContext::startMemorySampler): + Use sendToAllProcesses. + + (WebKit::WebContext::stopMemorySampler): + Use sendToAllProcesses. This is a slight policy change where we now create a sandbox extension even + if there's no process around. Since this is a debugging tool it seems OK to do this. + + * UIProcess/WebContext.h: + Get rid of hasValidProcess. + + (WebKit::WebContext::sendToAllProcesses): + If we have a process and we can send messages to it, then do so. + + (WebKit::WebContext::sendToAllProcessesRelaunchingThemIfNecessary): + Relaunch the web process and send the message. + + * UIProcess/WebCookieManagerProxy.cpp: + (WebKit::WebCookieManagerProxy::deleteCookiesForHostname): + (WebKit::WebCookieManagerProxy::deleteAllCookies): + (WebKit::WebCookieManagerProxy::startObservingCookieChanges): + (WebKit::WebCookieManagerProxy::stopObservingCookieChanges): + (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): + Use sendToAllProcesses and sendToAllProcessesRelaunchingThemIfNecessary. + +2011-04-04 Adam Roben <aroben@apple.com> + + Move a teensy bit of non-Mac-specific code up to LayerTreeHostCA + + Fixes <http://webkit.org/b/57774> LayerTreeHostCA should know how to flip the root layer + + Reviewed by Anders Carlsson. + + * WebProcess/WebPage/ca/LayerTreeHostCA.cpp: + (WebKit::LayerTreeHostCA::initialize): Cross-platformized and moved some code here... + + * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm: + (WebKit::LayerTreeHostCAMac::platformInitialize): ...from here. + +2011-04-01 Enrica Casucci <enrica@apple.com> + + Reviewed by Darin Adler. + + WK2: Reproducible crash when dragging out of or over Safari window. + https://bugs.webkit.org/show_bug.cgi?id=57654 + <rdar://problem/9139755> + + AppKit does not retain the owner given to the pasteboard, therefore we + need to give the ownership of the retained pointer to NSPasteboard. + Also, dragImage will release the NSFilePromiseDragSource object, therefore + we retain it before calling dragImage to be able to control its lifetime. + + * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: + (WebKit::WebDragClient::declareAndWriteDragImage): Passing ownership + of the pointer to AppKit when providing the owner pointer to the NSPasteboard + object. + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::platformDragEnded): Retaining the NSFilePromiseDragSource + since dragImage will release it. + +2011-03-30 Jer Noble <jer.noble@apple.com> + + Reviewed by Dan Bernstein. + + WebKit2: No "open in preview" contextual menu item for PDFs + https://bugs.webkit.org/show_bug.cgi?id=57527 + + Add support for opening a PDF in the associated application from the + context menu. + + * UIProcess/API/mac/PDFViewController.mm: + (_applicationInfoForMIMEType): Added, copied from WebKit/WebPDFView.mm + (-[WKPDFView _openWithFinder:]): Added. + (-[WKPDFView hitTest:]): Added, copied from WebKit/WebPDFView.mm. + (-[WKPDFView menuForEvent:]): Added, adapted from WebKit/WebPDFVie.mm. + (-[WKPDFView validateUserInterfaceItem:]): Added. + +2011-04-04 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.setAllowFileAccessFromFileURLs + https://bugs.webkit.org/show_bug.cgi?id=57572 + + * Shared/WebPreferencesStore.cpp: + (WebKit::WebPreferencesStore::decode): + (WebKit::WebPreferencesStore::overrideAllowFileAccessFromFileURLsForTestRunner): + * Shared/WebPreferencesStore.h: + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundleSetAllowFileAccessFromFileURLs): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::setAllowFileAccessFromFileURLs): + * WebProcess/InjectedBundle/InjectedBundle.h: + +2011-04-04 Brady Eidson <beidson@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=57683 + Flesh out WK2 Icon Database API + + For now the new API will add a client interface where the WK1 version used NSNotifications. + + If we decide we'd like the granularity of specific callback functions later, + they can easily be added on. + + Project file nonsense: + * GNUmakefile.am: + * WebKit2.pro: + * WebKit2.xcodeproj/project.pbxproj: + * win/WebKit2.vcproj: + + Add a WKIconDatabaseClient and some new API: + * UIProcess/API/C/WKIconDatabase.cpp: + (WKIconDatabaseSetIconDatabaseClient): + (WKIconDatabaseRemoveAllIcons): + (WKIconDatabaseCheckIntegrityBeforeOpening): + * UIProcess/API/C/WKIconDatabase.h: + * UIProcess/API/C/cg/WKIconDatabaseCG.cpp: + (WKIconDatabaseTryGetCGImageForURL): Renamed to "try" for subtle clarification. + * UIProcess/API/C/cg/WKIconDatabaseCG.h: + + Implementations for the new APIs: + * UIProcess/WebIconDatabase.cpp: + (WebKit::WebIconDatabase::retainIconForPageURL): Remove excessive logging. + (WebKit::WebIconDatabase::releaseIconForPageURL): Ditto. + (WebKit::WebIconDatabase::imageForPageURL): + (WebKit::WebIconDatabase::removeAllIcons): + (WebKit::WebIconDatabase::checkIntegrityBeforeOpening): + (WebKit::WebIconDatabase::initializeIconDatabaseClient): + (WebKit::WebIconDatabase::didImportIconURLForPageURL): Dispatch a client callback, + much like the WK1 API uses notifications. + (WebKit::WebIconDatabase::didImportIconDataForPageURL): Ditto. + (WebKit::WebIconDatabase::didChangeIconForPageURL): Ditto. + (WebKit::WebIconDatabase::didRemoveAllIcons): Ditto. + * UIProcess/WebIconDatabase.h: + * UIProcess/WebIconDatabaseClient.cpp: Added. + (WebKit::WebIconDatabaseClient::didChangeIconForPageURL): + (WebKit::WebIconDatabaseClient::didRemoveAllIcons): + * UIProcess/WebIconDatabaseClient.h: Added. + +2011-04-04 Carlos Garcia Campos <cgarcia@igalia.com> + + Reviewed by Martin Robinson. + + [GTK] Main loop sources are leaked in RunLoopGtk + https://bugs.webkit.org/show_bug.cgi?id=57618 + + * Platform/RunLoop.h: + (RunLoop::TimerBase::isRepeating): + * Platform/gtk/RunLoopGtk.cpp: + (RunLoop::~RunLoop): Make sure main loop is currently running + before calling g_main_loop_quit(), RunLoop::stop() might have been + called. + (RunLoop::wakeUp): Use an idle source with default priority + instead of a timeout one with a 0 interval. + (RunLoop::TimerBase::clearTimerSource): New method to clear the + timer. + (RunLoop::TimerBase::destroyNotifyCallback): Destroy notify + callback called when the source is destroyed to clear the timer. + (RunLoop::TimerBase::timerFiredCallback): Use the same callback for + repeating and no repeating timers. + (RunLoop::TimerBase::start): g_source_attach() increments the + source reference counter, so use GRefPtr to make sure the source + is freed. + (RunLoop::TimerBase::stop): Use clearTimerSource(). + +2011-04-03 Dan Bernstein <mitz@apple.com> + + Build fix. + + * Shared/DictionaryPopupInfo.cpp: + (WebKit::DictionaryPopupInfo::encode): + (WebKit::DictionaryPopupInfo::decode): + * Shared/DictionaryPopupInfo.h: + +2011-04-03 Dan Bernstein <mitz@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/9227839> REGRESSION: Reproducible crash in Snow Leopard when trying to show the Dictionary panel or application + https://bugs.webkit.org/show_bug.cgi?id=57739 + + * Shared/DictionaryPopupInfo.cpp: + (WebKit::DictionaryPopupInfo::encode): Do not encode the options dictionary on Snow Leopard. + (WebKit::DictionaryPopupInfo::decode): Do not decode the options dictionary on Snow Leopard. + * Shared/DictionaryPopupInfo.h: Removed the options member variable on Snow Leopard. + * Shared/Plugins/PluginQuirks.h: + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::WebPage::performDictionaryLookupForRange): Do not set the options member variable on + Snow Leopard. + +2011-04-02 Sam Weinig <sam@webkit.org> + + Reviewed by Beth Dakin. + + https://bugs.webkit.org/show_bug.cgi?id=57605 + Frame::pageScaleFactor() should not affect getBoundingClientRect() or + getClientRects() + -and corresponding- + <rdar://problem/9194541> + + Add DRT support for the scaleWebView SPI. + * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: + (WKBundlePageSetScaleAtOrigin): + * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h: + +2011-04-02 Sam Weinig <sam@webkit.org> + + Reviewed by Oliver Hunt. + + "Search in Spotlight" broken in WebKit2 + https://bugs.webkit.org/show_bug.cgi?id=57712 + + Proxy spotlight searching to the UIProcess. + + * UIProcess/WebPageProxy.messages.in: + Add new message. Re-organize messages to put all mac specific ones together. + + * UIProcess/WebPageProxy.h: + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::speak): + (WebKit::WebPageProxy::searchWithSpotlight): + Moved code to trigger spotlight here. Use WTF::String -> NSString conversion function + instead of relying on the built in conversion since it doesn't always work in the UIProcess. + + * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm: + (WebKit::WebContextMenuClient::searchWithSpotlight): + Post message to the UIProcess to do the searching. + +2011-04-02 Jeff Miller <jeffm@apple.com> + + Reviewed by Dan Bernstein. + + WebKit2: Specify the certificate store in WKBundleSetClientCertificate() + https://bugs.webkit.org/show_bug.cgi?id=57707 + + Include the name of the system certificate store that the client certificate came from in WKBundleSetClientCertificate(). + + The PCCERT_CONTEXT for the client certificate we create from the message from the UI process doesn't contain enough information to actually use it in a request, we need to get the real certificate from the certificate store (which is typically the "MY" store). + + * WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp: + (WKBundleSetClientCertificate): Add certificateSystemStoreName to parameters. + * WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h: Add certificateSystemStoreName to WKBundleSetClientCertificate() parameters. + * WebProcess/InjectedBundle/InjectedBundle.h: Add certificateSystemStoreName to setClientCertificate() parameters. + * WebProcess/InjectedBundle/win/InjectedBundleWin.cpp: + (WebKit::InjectedBundle::setClientCertificate): Read the real certificate from the certificate store. + +2011-04-02 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Implement WKBundleFrameHasHorizontalScrollbar/WKBundleFrameHasVerticalScrollbar + <rdar://problem/9225772> + https://bugs.webkit.org/show_bug.cgi?id=57709 + + * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: + (WKBundleFrameHasHorizontalScrollbar): + (WKBundleFrameHasVerticalScrollbar): + * WebProcess/InjectedBundle/API/c/WKBundleFrame.h: + * WebProcess/WebPage/WebFrame.cpp: + (WebKit::WebFrame::hasHorizontalScrollbar): + (WebKit::WebFrame::hasVerticalScrollbar): + * WebProcess/WebPage/WebFrame.h: + +2011-04-01 Jon Lee <jonlee@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Type-to-select doesn't work in open <select> menu (53023) + https://bugs.webkit.org/show_bug.cgi?id=53023 + <rdar://problem/8907678> + + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: adding new setPopupMenuSelectedIndex message for windows platform + * UIProcess/win/WebPageProxyWin.cpp: + (WebKit::WebPageProxy::setPopupMenuSelectedIndex): + * UIProcess/win/WebPopupMenuProxyWin.h: moving setFocusedIndex() into public method + * WebProcess/WebCoreSupport/WebPopupMenu.cpp: + (WebKit::WebPopupMenu::updateFromElement): send message back to UIProcess to update the selected element + +2011-04-01 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + REGRESSION: Assertion failure when executing a complex custom key binding + https://bugs.webkit.org/show_bug.cgi?id=57681 + + Also completes a fix for + <rdar://problem/9063782> WebKit2: Text fields in Safari don't honor custom key bindings + + * UIProcess/API/mac/WKView.mm: (-[WKView hasMarkedText]): There is no need to execute saved + commands when they can't possibly change the result. + +2011-04-01 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Anders Carlsson. + + Crash when calling WebPageProxy::setMemoryCacheClientCallsEnabled with an invalid Web Process + https://bugs.webkit.org/show_bug.cgi?id=57680 + <rdar://problem/9202909> + + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::setMemoryCacheClientCallsEnabled): Add an isValid check before sending + the message. + +2011-03-31 Jer Noble <jer.noble@apple.com> + + Reviewed by Dan Bernstein. + + WebKit2: Save as PDF in Safari provides Untitled as default file name + https://bugs.webkit.org/show_bug.cgi?id=57529 + + Set the NSPrintOperation's jobTitle to the printing frame's title. + + * UIProcess/API/mac/WKView.mm: + (-[WKView printOperationWithPrintInfo:forFrame:]): + +2011-04-01 Jer Noble <jer.noble@apple.com> + + Reviewed by Darin Adler. + + WebKit2: Link from PDF opens in a new tab instead of in the same tab + https://bugs.webkit.org/show_bug.cgi?id=57528 + + Notify the WebProcess that a link has been clicked so that the normal policy + lookup can occur. + + * Shared/WebEvent.cpp: + (WebKit::WebEvent::WebEvent): Initialize ivars in the default constructor. + * Shared/WebEvent.h: Add WebEvent::NoType to Type enum. + * Shared/WebMouseEvent.cpp: + (WebKit::WebMouseEvent::WebMouseEvent): Ditto. + * UIProcess/API/mac/PDFViewController.mm: + (-[WKPDFView PDFViewWillClickOnLink:withURL:]): Handle the delegate + function and override the PDFView default behavior. + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::didReceiveEvent): Handle the new WebEvent::NoType enum. + (WebKit::WebPageProxy::linkClicked): Added. Send event through to WebPage. + * UIProcess/WebPageProxy.h: + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::linkClicked): Added. Call loadFrameRequest(). + * WebProcess/WebPage/WebPage.h: + * WebProcess/WebPage/WebPage.messages.in: Added LinkClicked. + +2011-04-01 Sam Weinig <sam@webkit.org> + + Reviewed by Adam "Keyword Slasher" Roben. + + Remove unnecessary static keyword. + + * UIProcess/API/cpp/WKRetainPtr.h: + (WebKit::adoptWK): + +2011-04-01 Sam Weinig <sam@webkit.org> + + Reviewed by Adam Roben. + + Add adoptWK to WKRetainPtr.h + https://bugs.webkit.org/show_bug.cgi?id=57670 + + * UIProcess/API/cpp/WKRetainPtr.h: + (WebKit::adoptWK): + Add shared implementation of adoptWK. Previously both WebKitTestRunner + and TestWebKitAPI had separate versions of it. + +2011-04-01 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Shockwave plug-in doesn't accept mouse events + https://bugs.webkit.org/show_bug.cgi?id=57653 + <rdar://problem/8483273> + + Add a missing break. + + * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: + (WebKit::NetscapePlugin::convertPoint): + +2011-04-01 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + WebKitTestRunner needs layoutTestController.shadowRoot + https://bugs.webkit.org/show_bug.cgi?id=57661 + + * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: + (WKBundleNodeHandleGetRenderRect): + (WKBundleNodeHandleGetElementBounds): + (WKBundleNodeHandleCopyElementShadowRoot): + * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h: + * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp: + (WebKit::InjectedBundleNodeHandle::elementShadowRoot): + * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h: + Add accessor for the shadowRoot of an element in the bundle. + +2011-04-01 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + Make WebKit2 text input handling more like WebKit1 + https://bugs.webkit.org/show_bug.cgi?id=57649 + + We now send more sync messages from UI process to Web process for NSTextInput protocol + methods. Some of the exchanges are avoided by pre-calculating the responses before asking + UI process to interpret key events, and also with each sync message sent during + interpretation, and which could change the state. + + * Platform/CoreIPC/HandleMessage.h: (CoreIPC::callMemberFunction): Added a missing + specialization for a function with 6 arguments and 2 returned values. + + * Scripts/webkit2/messages.py: Added TextInputState to struct list. + + * Shared/WebCoreArgumentCoders.h: Fixed a bug in CompositionUnderline encoding, which only + encoded a part of Color field, and didn't match decoder. + + * Shared/mac/TextInputState.h: Added. This is state that's needed for IM machinery and that + we don't want to send sync messages for. This is similar to SelectionState, but the latter + is only updated asynchronously, and is thus less reliable. + + * UIProcess/API/mac/PageClientImpl.h: We don't "intercept", we "interpret". + + * UIProcess/API/mac/PageClientImpl.mm: (WebKit::PageClientImpl::interpretKeyEvent): Pass + current text input state, and don't expect anything input method related in return, as input + methods are now sync. + + * UIProcess/API/mac/WKView.mm: + (-[WKView doCommandBySelector:]): + (-[WKView insertText:]): + (-[WKView keyDown:]): + (-[WKView _executeSavedKeypressCommands]): + (-[WKView inputContext]): + (-[WKView selectedRange]): + (-[WKView hasMarkedText]): + (-[WKView unmarkText]): + (-[WKView setMarkedText:selectedRange:]): + (-[WKView markedRange]): + (-[WKView attributedSubstringFromRange:]): + (-[WKView characterIndexForPoint:]): + (-[WKView firstRectForCharacterRange:]): + (-[WKView _interpretKeyEvent:withCachedTextInputState:savingCommandsTo:WebCore::]): + * UIProcess/API/mac/WKViewInternal.h: + * UIProcess/PageClient.h: + * UIProcess/WebPageProxy.h: + * UIProcess/WebPageProxy.messages.in: + * UIProcess/mac/WebPageProxyMac.mm: + (WebKit::WebPageProxy::setComposition): + (WebKit::WebPageProxy::confirmComposition): + (WebKit::WebPageProxy::insertText): + (WebKit::WebPageProxy::getSelectedRange): + (WebKit::WebPageProxy::executeKeypressCommands): + (WebKit::WebPageProxy::interpretQueuedKeyEvent): + * WebKit2.xcodeproj/project.pbxproj: + * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm: + (WebKit::WebEditorClient::handleKeyboardEvent): + (WebKit::WebEditorClient::handleInputMethodKeydown): + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::WebPage): + * WebProcess/WebPage/WebPage.h: + (WebKit::WebPage::viewFrameInWindowCoordinates): + * WebProcess/WebPage/WebPage.messages.in: + * WebProcess/WebPage/mac/WebPageMac.mm: + (WebKit::createSelectorExceptionMap): + (WebKit::commandNameForSelectorName): + (WebKit::currentTextInputState): + (WebKit::frameForEvent): + (WebKit::WebPage::executeKeypressCommandsInternal): + (WebKit::WebPage::handleEditingKeyboardEvent): + (WebKit::WebPage::setComposition): + (WebKit::WebPage::confirmComposition): + (WebKit::WebPage::insertText): + (WebKit::WebPage::getSelectedRange): + (WebKit::convertToRange): + (WebKit::WebPage::executeKeypressCommands): + (WebKit::WebPage::performDefaultBehaviorForKeyEvent): + Rewrote to be more like WebKit1. + +2011-04-01 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.setDatabaseQuota + https://bugs.webkit.org/show_bug.cgi?id=57568 + + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundleSetDatabaseQuota): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::setDatabaseQuota): + * WebProcess/InjectedBundle/InjectedBundle.h: + * WebProcess/WebCoreSupport/WebDatabaseManager.h: + +2011-04-01 Timothy Hatcher <timothy@apple.com> + + Make momentum scroll event latching work in WebKit2 on Mac. + + <rdar://problem/8751861> + + Reviewed by Darin Adler. + + * Shared/mac/WebEventFactory.mm: + (WebKit::momentumPhaseForEvent): Return a phase on older Mac system by using WKGetNSEventMomentumPhase. + * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: + (InitWebCoreSystemInterface): Remove IsLatchingWheelEvent, add GetNSEventMomentumPhase. + +2011-04-01 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Anders Carlsson. + + Assertion failure (type == event.type()) after a web process crash + https://bugs.webkit.org/show_bug.cgi?id=56228 + <rdar://problem/8806106> + + This partially un-confuses the UI process about key processing state after a web process + crash. It may not be pefect yet - sending a KeyUp to a new process that never saw a KeyDown + seems weird. + + * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::processDidCrash): + +2011-04-01 Adam Roben <aroben@apple.com> + + Cairo build fix + + * WebProcess/WebPage/LayerTreeHost.cpp: Only pull in the LayerTreeHostCA derived classes for + PLATFORM(CA) ports. + +2011-03-31 Adam Roben <aroben@apple.com> + + Split LayerTreeHostCA into a base class and derived Mac and Win classes + + This will make it easier to customize the Mac and Windows implementations without adding too + many #ifdefs. + + Fixes <http://webkit.org/b/57606> Windows and Mac should use separate LayerTreeHost classes + + Reviewed by Anders Carlsson. + + * WebKit2.xcodeproj/project.pbxproj: Added LayerTreeHostCAMac.h. + + * WebProcess/WebPage/LayerTreeHost.cpp: + (WebKit::LayerTreeHost::create): Create a LayerTreeHostCAMac on Mac, and LayerTreeHostCAWin + on Windows. + + * WebProcess/WebPage/ca/LayerTreeHostCA.cpp: + (WebKit::LayerTreeHostCA::LayerTreeHostCA): Moved some code from here... + (WebKit::LayerTreeHostCA::initialize): ...to here. This function will be called after the + constructor returns, and thus can safely call functions that are pure virtual in this class + and its base class. We now pass our LayerTreeContext to platformInitialize so that our + derived classes can initialize it. + (WebKit::LayerTreeHostCA::~LayerTreeHostCA): Removed Mac-specific code. + + (WebKit::LayerTreeHostCA::invalidate): + (WebKit::LayerTreeHostCA::sizeDidChange): + (WebKit::LayerTreeHostCA::forceRepaint): + (WebKit::LayerTreeHostCA::didPerformScheduledLayerFlush): + Removed platform* calls. Derived classes can just override these functions to do what they + need. + + * WebProcess/WebPage/ca/LayerTreeHostCA.h: Removed Mac-specific pieces. Made some functions + virtual so that derived classes can override them. + + * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h: Added. + + * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm: + (WebKit::LayerTreeHostCAMac::create): Create and initialize a host. + (WebKit::LayerTreeHostCAMac::LayerTreeHostCAMac): Simple constructor. + (WebKit::LayerTreeHostCAMac::~LayerTreeHostCAMac): Moved code here from LayerTreeHostCA + destructor. + (WebKit::LayerTreeHostCAMac::platformInitialize): Removed direct uses of LayerTreeHostCA + data members. + + (WebKit::LayerTreeHostCAMac::invalidate): + (WebKit::LayerTreeHostCAMac::sizeDidChange): + (WebKit::LayerTreeHostCAMac::forceRepaint): + (WebKit::LayerTreeHostCAMac::didPerformScheduledLayerFlush): + Renamed from platform*. Now call up to the base class. + + (WebKit::LayerTreeHostCAMac::flushPendingLayerChangesRunLoopObserverCallback): Updated type. + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp: + (WebKit::LayerTreeHostCAWin::create): Create and initialize a host. + + (WebKit::LayerTreeHostCAWin::LayerTreeHostCAWin): + (WebKit::LayerTreeHostCAWin::~LayerTreeHostCAWin): + (WebKit::LayerTreeHostCAWin::platformInitialize): + (WebKit::LayerTreeHostCAWin::scheduleLayerFlush): + Stubbed out. + + * WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h: Added. + + * win/WebKit2.vcproj: Added LayerTreeHostCAWin.h + + * win/WebKit2Apple.vsprops: Added WebProcess/WebPage/ca/win to the include path. + +2011-03-31 Brent Fulgham <bfulgham@webkit.org> + + Unreviewed WinCairo build fix after r82632. + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::visibilityDidChange): + +2011-03-31 Adam Roben <aroben@apple.com> + + Add SharedMemory::adopt, which can take ownership of an existing file mapping object + + Fixes <http://webkit.org/b/57599> Need a way to wrap an existing file mapping object in a + SharedMemory + + Reviewed by Anders Carlsson. + + * Platform/SharedMemory.h: Added adopt. + + * Platform/win/SharedMemoryWin.cpp: + (WebKit::SharedMemory::create): Moved code to adopt the HANDLE from here... + (WebKit::SharedMemory::adopt): ...to here. + +2011-03-31 Chang Shu <cshu@webkit.org> + + Reviewed by Darin Adler. + + WebKitTestRunner needs layoutTestController.clearAllDatabases + https://bugs.webkit.org/show_bug.cgi?id=42540 + + * WebProcess/InjectedBundle/API/c/WKBundle.cpp: + (WKBundleClearAllDatabases): + * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: + * WebProcess/InjectedBundle/InjectedBundle.cpp: + (WebKit::InjectedBundle::clearAllDatabases): + * WebProcess/InjectedBundle/InjectedBundle.h: + * WebProcess/WebCoreSupport/WebDatabaseManager.h: + +2011-03-31 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Add some more media related things to the sandbox profile. + + * WebProcess/com.apple.WebProcess.sb: + +2011-03-31 Anders Carlsson <andersca@apple.com> + + Reviewed by Dan Bernstein. + + Tabbed pages redraw unnecessarily when activated + https://bugs.webkit.org/show_bug.cgi?id=57589 + <rdar://problem/9218258> + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::visibilityDidChange): + If we become visible and have no backing store, make sure to call backingStoreStateDidChange + so that the next time we're asked to paint we'll wait for something to paint. + + (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): + Remove now redundant call to backingStoreStateDidChange. + +2011-03-31 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Sandbox violations when playing back HTML5 video on YouTube + <rdar://problem/8950692> + + * WebProcess/com.apple.WebProcess.sb: + +2011-03-31 Darin Adler <darin@apple.com> + + Reviewed by Sam Weinig. + + Implement mouseDown, mouseUp, and mouseMoveTo in WebKitTestRunner + https://bugs.webkit.org/show_bug.cgi?id=57573 + + * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: + (WKBundlePageSimulateMouseDown): Added. + (WKBundlePageSimulateMouseUp): Added. + (WKBundlePageSimulateMouseMotion): Added. + * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h: Added above functions. + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::simulateMouseDown): Added. + (WebKit::WebPage::simulateMouseUp): Added. + (WebKit::WebPage::simulateMouseMotion): Added. + * WebProcess/WebPage/WebPage.h: Added above functions. + +2011-03-31 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Rename WebCore's UI_STRING to WEB_UI_STRING to not overlap with WebKit API + https://bugs.webkit.org/show_bug.cgi?id=57582 + + * PluginProcess/mac/PluginProcessMac.mm: + (WebKit::PluginProcess::platformInitialize): + * UIProcess/mac/WebInspectorProxyMac.mm: + (WebKit::WebInspectorProxy::platformInspectedURLChanged): + * WebProcess/WebCoreSupport/mac/WebErrorsMac.mm: + * WebProcess/mac/WebProcessMac.mm: + (WebKit::WebProcess::platformInitializeWebProcess): + +2011-03-31 Adam Roben <aroben@apple.com> + + Specify both FILE_MAP_READ and FILE_MAP_WRITE when creating a read-write SharedMemory object + + When passed to ::MapViewOfFile, FILE_MAP_WRITE implies FILE_MAP_READ, but other file mapping + APIs don't work that way. This bug wasn't causing any problems in practice, but it would + have prevented us from creating a DIB that wraps a SharedMemory object (which I noticed + while working on another bug). + + Fixes <http://webkit.org/b/57576> File mappings used by read-write SharedMemory objects + aren't correctly marked as read-write after being sent over a CoreIPC::Connection + + Reviewed by Brian Weinstein. + + * Platform/win/SharedMemoryWin.cpp: + (WebKit::accessRights): Specify FILE_MAP_READ in addition to FILE_MAP_WRITE for read-write + SharedMemory. + +2011-03-31 Adam Roben <aroben@apple.com> + + Quote the executable path we pass to ::CreateProcessW + + This will ensure that spaces in the path will be interpreted correctly. + + Fixes <http://webkit.org/b/57569> Web process sometimes fails to launch when there are + spaces in its path + + Reviewed by Steve Falkenburg. + + * UIProcess/Launcher/win/ProcessLauncherWin.cpp: + (WebKit::ProcessLauncher::launchProcess): Surround the executable path in quotes. + +2011-03-31 Alexey Proskuryakov <ap@apple.com> + + Patch by John Harvey, reviewed and tweaked by me. + + <rdar://problem/8644403> Should notify TSM that plug-ins would show a bottom input window for marked text. + + * UIProcess/API/mac/WKTextInputWindowController.mm: + (-[WKTextInputPanel _interpretKeyEvent:string:]): + +2011-03-31 Anders Carlsson <andersca@apple.com> + + Reviewed by John Sullivan, Darin Adler, Dan Bernstein and Sam Weinig. + + If a user doesn't have a Database/LocalStorage directory, it can't be created (sandbox violations) + https://bugs.webkit.org/show_bug.cgi?id=57561 + <rdar://problem/9127411> + + Ensure that any readwrite sandbox directories actually exist before entering the sandbox. + + * WebProcess/mac/WebProcessMac.mm: + (WebKit::appendReadwriteSandboxDirectory): + +2011-03-31 John Sullivan <sullivan@apple.com> + + Reviewed by Darin Adler and Adam Roben. + + <rdar://problem/9214824> Find client not told when WKPageCountStringMatches exceeds maximum + https://bugs.webkit.org/show_bug.cgi?id=57552 + + * WebProcess/WebPage/FindController.cpp: + (WebKit::FindController::countStringMatches): + Use the same technique as findString() to report kWKMoreThanMaximumMatchCount when appropriate. + (WebKit::FindController::findString): + Convert numeric_limits::max() to max() - 1 to avoid overflow case. + +2011-03-31 Evan Martin <evan@chromium.org> + + Reviewed by Eric Seidel. + + <title> should support dir attribute + https://bugs.webkit.org/show_bug.cgi?id=50961 + + Update to new FrameLoaderClient interface. + + * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: + (WebKit::WebFrameLoaderClient::dispatchDidReceiveTitle): + (WebKit::WebFrameLoaderClient::setTitle): + * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: + +2011-03-31 Balazs Kelemen <kbalazs@webkit.org> + + Reviewed by Csaba Osztrogonác. + + [WK2] Introduce an option for no NPAPI support + https://bugs.webkit.org/show_bug.cgi?id=55828 + + Stub out NPAPI support for platform and OS combinations that are + not supported yet. Ancestor patch was made by Laszlo Gombos. + + * GNUmakefile.am: Add NetscapePluginModuleNone.cpp and NetscapePluginNone.cpp + to the build system. + + * Shared/Plugins/Netscape/NetscapePluginModule.cpp: + Remove the sanity check because from now all combinations that + don't have an explicitly set plugin architecture fall into + the PLUGIN_ARCHITECTURE(UNSUPPORTED) category and has a stubbed + implementation. + + * Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp: Added. + Stubbed implementation. + (WebKit::NetscapePluginModule::getPluginInfo): + (WebKit::NetscapePluginModule::determineQuirks): + + * Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp: Guard with + PLUGIN_ARCHITECTURE(X11). + + * WebKit2.pro: Add NetscapePluginModuleNone.cpp and NetscapePluginNone.cpp + to the build system. + + * WebProcess/Plugins/Netscape/NetscapePluginNone.cpp: Added. + Stubbed implementation + (WebKit::NetscapePlugin::platformPostInitialize): + (WebKit::NetscapePlugin::platformDestroy): + (WebKit::NetscapePlugin::platformInvalidate): + (WebKit::NetscapePlugin::platformGeometryDidChange): + (WebKit::NetscapePlugin::platformPaint): + (WebKit::NetscapePlugin::platformHandleMouseEvent): + (WebKit::NetscapePlugin::platformHandleWheelEvent): + (WebKit::NetscapePlugin::platformSetFocus): + (WebKit::NetscapePlugin::platformHandleMouseEnterEvent): + (WebKit::NetscapePlugin::platformHandleMouseLeaveEvent): + (WebKit::NetscapePlugin::platformHandleKeyboardEvent): + + * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp: Guard with + PLUGIN_ARCHITECTURE(X11) + + * config.h: Introduce PLUGIN_ARCHITECTURE(UNSUPPORTED) as another + option. Make platform and OS combinations that are not supported + yet fall into this. Don't use Q_WS_X11 to test the window system + for Qt because it is not defined without including <QtGlobal>. + No clue about how could it work so far. + +2011-03-31 Vamshikrishna.Yellenki <vamshi@motorola.com> and Alejandro G. Castro <alex@igalia.com> + + Reviewed by Martin Robinson. + + Implement MiniBrowser for Gtk port. + https://bugs.webkit.org/show_bug.cgi?id=48512 + + * Shared/API/c/gtk/WKBaseGtk.h: Add the stdbool.h include. + +2011-03-30 Dan Bernstein <mitz@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/9005982> Flash of white when a WKView with composited content moves on-screen + https://bugs.webkit.org/show_bug.cgi?id=57522 + + * UIProcess/DrawingAreaProxyImpl.cpp: + (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode): Invalidate the current + backing store state, so that we get an update as soon as the page enters compositing mode + next. + * WebProcess/WebPage/DrawingAreaImpl.cpp: + (WebKit::DrawingAreaImpl::sendDidUpdateBackingStoreState): Added a call to + LayerTreeHost::forceRepaint() in order to flush and synchronize the layers + before sending the update message to the UI process. + +2011-03-30 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Sandbox violations if you navigate a file URL via something other than a click + <rdar://problem/9016086> + https://bugs.webkit.org/show_bug.cgi?id=57519 + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::shouldReuseCommittedSandboxExtension): + Remove unnecessary restriction on extension reuse. Any type of file to file navigation + should be allowed. + +2011-03-30 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Clean up the sandbox parameter code + https://bugs.webkit.org/show_bug.cgi?id=57518 + + * Shared/WebProcessCreationParameters.h: + Make nsURLCachePath and uiProcessBundleResourcePath Strings to match the other paths we send over. + + * UIProcess/mac/WebContextMac.mm: + (WebKit::WebContext::platformInitializeWebProcess): + nsURLCachePath and uiProcessBundleResourcePath are now Strings. + + * WebProcess/mac/WebProcessMac.mm: + (WebKit::appendSandboxParameterPathInternal): + (WebKit::appendReadwriteConfDirectory): + (WebKit::appendReadonlySandboxDirectory): + (WebKit::appendReadwriteSandboxDirectory): + (WebKit::initializeSandbox): + Make it more clear whether the directories we're adding are readonly or readwrite. No functionality change. + + (WebKit::WebProcess::platformInitializeWebProcess): + nsURLCachePath is now a string. + +2011-03-30 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Downloading a file fails due to a sandbox violation if the destination path is a symlink + https://bugs.webkit.org/show_bug.cgi?id=57517 + <rdar://problem/8943865> + + Make sure to resolve any symlinks in the given path when creating a sandbox extension handle. + Note that we can't use realpath or -[NSString stringByResolvingSymlinksInPath], because those calls + will fail if the pointed to file doesn't exist. + + * Shared/mac/SandboxExtensionMac.mm: + (WebKit::resolveSymlinksInPath): + New function that resolves all the symlinks in the given path. + + (WebKit::SandboxExtension::createHandle): + Call resolveSymlinksInPath on the resulting path. + +2011-03-30 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Adam Roben. + + Share most vsprops between Release and Production builds in releaseproduction.vsprops + https://bugs.webkit.org/show_bug.cgi?id=57508 + + * win/WebKit2Production.vsprops: + * win/WebKit2Release.vsprops: + * win/WebKit2ReleaseCairoCFLite.vsprops: + * win/WebKit2WebProcessProduction.vsprops: + * win/WebKit2WebProcessRelease.vsprops: + * win/WebKit2WebProcessReleaseCairoCFLite.vsprops: + 2011-03-30 Ivan Krstić <ike@apple.com> Reviewed by Oliver Hunt. @@ -1080,7 +6147,7 @@ 2011-03-26 Maciej Stachowiak <mjs@apple.com> - Revert inadvertently commited changes. + Revert inadvertently committed changes. * WebProcess/com.apple.WebProcess.sb: diff --git a/Source/WebKit2/Configurations/FeatureDefines.xcconfig b/Source/WebKit2/Configurations/FeatureDefines.xcconfig index 3971037..73d3a47 100644 --- a/Source/WebKit2/Configurations/FeatureDefines.xcconfig +++ b/Source/WebKit2/Configurations/FeatureDefines.xcconfig @@ -23,8 +23,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // The contents of this file must be kept in sync with FeatureDefines.xcconfig in JavaScriptCore, -// WebCore and WebKit. Also the default values of the ENABLE_FEATURE_NAME macros in build-webkit -// should match the values below, but they do not need to be in the same order. +// WebCore, WebKit and WebKit2. Also the default values of the ENABLE_FEATURE_NAME macros in +// build-webkit should match the values below, but they do not need to be in the same order. // Keep this list of features (not enabled/disabled state) in sync with FeatureDefines.vsprops // and FeatureDefinesCairo.vsprops in WebKitLibraries/win/tools/vsprops. @@ -66,6 +66,8 @@ ENABLE_DATAGRID = ; ENABLE_DATALIST = $(ENABLE_DATALIST_$(REAL_PLATFORM_NAME)); ENABLE_DATALIST_macosx = ENABLE_DATALIST; +ENABLE_DATA_TRANSFER_ITEMS = ; + ENABLE_DEVICE_ORIENTATION = ; ENABLE_DIRECTORY_UPLOAD = ; ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE; @@ -89,8 +91,11 @@ ENABLE_MATHML = ENABLE_MATHML; ENABLE_METER_TAG = ENABLE_METER_TAG; ENABLE_NOTIFICATIONS = ; ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS; +ENABLE_PAGE_VISIBILITY_API = ; ENABLE_PROGRESS_TAG = ENABLE_PROGRESS_TAG; +ENABLE_QUOTA = ; + ENABLE_REGISTER_PROTOCOL_HANDLER = ; ENABLE_SHARED_WORKERS = $(ENABLE_SHARED_WORKERS_$(REAL_PLATFORM_NAME)); @@ -107,6 +112,7 @@ ENABLE_SVG_FONTS = ENABLE_SVG_FONTS; ENABLE_SVG_FOREIGN_OBJECT = ENABLE_SVG_FOREIGN_OBJECT; ENABLE_SVG_USE = ENABLE_SVG_USE; ENABLE_VIDEO = ENABLE_VIDEO; +ENABLE_VIDEO_TRACK = ; ENABLE_MEDIA_STATISTICS = ; @@ -125,4 +131,4 @@ ENABLE_XHTMLMP = ; ENABLE_XPATH = ENABLE_XPATH; ENABLE_XSLT = ENABLE_XSLT; -FEATURE_DEFINES = $(ENABLE_LINK_PREFETCH) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_WEBGL) $(ENABLE_3D_RENDERING) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_FILE_SYSTEM) $(ENABLE_FULLSCREEN_API) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_IMAGE_RESIZER) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_METER_TAG) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_PROGRESS_TAG) $(ENABLE_REGISTER_PROTOCOL_HANDLER) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XHTMLMP) $(ENABLE_XPATH) $(ENABLE_XSLT); +FEATURE_DEFINES = $(ENABLE_LINK_PREFETCH) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_WEBGL) $(ENABLE_3D_RENDERING) $(ENABLE_BLOB) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_FILE_SYSTEM) $(ENABLE_FULLSCREEN_API) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_IMAGE_RESIZER) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_METER_TAG) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PROGRESS_TAG) $(ENABLE_REGISTER_PROTOCOL_HANDLER) $(ENABLE_QUOTA) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XHTMLMP) $(ENABLE_XPATH) $(ENABLE_XSLT); diff --git a/Source/WebKit2/Configurations/Version.xcconfig b/Source/WebKit2/Configurations/Version.xcconfig index e3bfad7..2b3ebe3 100644 --- a/Source/WebKit2/Configurations/Version.xcconfig +++ b/Source/WebKit2/Configurations/Version.xcconfig @@ -22,7 +22,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. MAJOR_VERSION = 534; -MINOR_VERSION = 27; +MINOR_VERSION = 30; TINY_VERSION = 0; FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION); diff --git a/Source/WebKit2/DerivedSources.make b/Source/WebKit2/DerivedSources.make index 6f30dd4..865050c 100644 --- a/Source/WebKit2/DerivedSources.make +++ b/Source/WebKit2/DerivedSources.make @@ -21,6 +21,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. VPATH = \ + $(WebKit2) \ $(WebKit2)/PluginProcess \ $(WebKit2)/Shared/Plugins \ $(WebKit2)/WebProcess/ApplicationCache \ @@ -100,3 +101,16 @@ all : \ %Messages.h : %.messages.in $(SCRIPTS) @echo Generating message receiver for $*... @python $(WebKit2)/Scripts/generate-messages-header.py $< > $@ + +# ------------------------ + +# Windows-specific rules + +ifeq ($(OS),Windows_NT) + +all : HeaderDetection.h + +HeaderDetection.h : DerivedSources.make + if [ -f "$(WEBKITLIBRARIESDIR)/include/WebKitQuartzCoreAdditions/WebKitQuartzCoreAdditionsBase.h" ]; then echo "#define HAVE_WKQCA 1" > $@; else echo > $@; fi + +endif # Windows_NT diff --git a/Source/WebKit2/GNUmakefile.am b/Source/WebKit2/GNUmakefile.am index 837165d..2d6ad7e 100644 --- a/Source/WebKit2/GNUmakefile.am +++ b/Source/WebKit2/GNUmakefile.am @@ -93,13 +93,13 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/Platform/CoreIPC/CoreIPCMessageKinds.h \ Source/WebKit2/Platform/CoreIPC/DataReference.cpp \ Source/WebKit2/Platform/CoreIPC/DataReference.h \ - Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp \ Source/WebKit2/Platform/CoreIPC/HandleMessage.h \ Source/WebKit2/Platform/CoreIPC/MessageID.h \ Source/WebKit2/Platform/CoreIPC/MessageSender.h \ + Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp \ + Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp \ Source/WebKit2/Platform/gtk/ModuleGtk.cpp \ Source/WebKit2/Platform/gtk/RunLoopGtk.cpp \ - Source/WebKit2/Platform/gtk/SharedMemoryGtk.cpp \ Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp \ Source/WebKit2/Platform/Logging.cpp \ Source/WebKit2/Platform/Logging.h \ @@ -109,6 +109,7 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/Platform/RunLoop.cpp \ Source/WebKit2/Platform/RunLoop.h \ Source/WebKit2/Platform/SharedMemory.h \ + Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp \ Source/WebKit2/Platform/WorkItem.h \ Source/WebKit2/Platform/WorkQueue.cpp \ Source/WebKit2/Platform/WorkQueue.h \ @@ -182,11 +183,12 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/Shared/CoreIPCSupport/InjectedBundleMessageKinds.h \ Source/WebKit2/Shared/CoreIPCSupport/WebContextMessageKinds.h \ Source/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h \ - Source/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h \ Source/WebKit2/Shared/DrawingAreaInfo.h \ + Source/WebKit2/Shared/EditorState.h \ Source/WebKit2/Shared/FontSmoothingLevel.h \ Source/WebKit2/Shared/gtk/ShareableBitmapGtk.cpp \ Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp \ + Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp \ Source/WebKit2/Shared/gtk/PlatformCertificateInfo.h \ Source/WebKit2/Shared/gtk/UpdateChunk.cpp \ Source/WebKit2/Shared/gtk/UpdateChunk.h \ @@ -204,6 +206,7 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/Shared/MutableDictionary.cpp \ Source/WebKit2/Shared/MutableDictionary.h \ Source/WebKit2/Shared/NativeWebKeyboardEvent.h \ + Source/WebKit2/Shared/NativeWebMouseEvent.h \ Source/WebKit2/Shared/OriginAndDatabases.cpp \ Source/WebKit2/Shared/OriginAndDatabases.h \ Source/WebKit2/Shared/PlatformPopupMenuData.cpp \ @@ -212,6 +215,7 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/Shared/PrintInfo.h \ Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp \ Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h \ + Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp \ Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp \ Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp \ Source/WebKit2/Shared/Plugins/NPIdentifierData.h \ @@ -230,7 +234,6 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/Shared/SandboxExtension.h \ Source/WebKit2/Shared/SecurityOriginData.h \ Source/WebKit2/Shared/SecurityOriginData.cpp \ - Source/WebKit2/Shared/SelectionState.h \ Source/WebKit2/Shared/SessionState.cpp \ Source/WebKit2/Shared/SessionState.h \ Source/WebKit2/Shared/StringPairVector.h \ @@ -454,6 +457,8 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/UIProcess/WebHistoryClient.h \ Source/WebKit2/UIProcess/WebIconDatabase.cpp \ Source/WebKit2/UIProcess/WebIconDatabase.h \ + Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp \ + Source/WebKit2/UIProcess/WebIconDatabaseClient.h \ Source/WebKit2/UIProcess/WebInspectorProxy.cpp \ Source/WebKit2/UIProcess/WebInspectorProxy.h \ Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp \ @@ -588,6 +593,7 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h \ Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp \ Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h \ + Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginNone.cpp \ Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp \ Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h \ Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp \ @@ -611,6 +617,7 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h \ Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp \ Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp \ + Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp \ Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp \ Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h \ Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebPopupMenuGtk.cpp \ @@ -651,6 +658,7 @@ libWebKit2_la_SOURCES = \ Source/WebKit2/WebProcess/WebPage/FindController.h \ Source/WebKit2/WebProcess/WebPage/gtk/ChunkedUpdateDrawingAreaGtk.cpp \ Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp \ + Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp \ Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp \ Source/WebKit2/WebProcess/WebPage/PageOverlay.h \ Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp \ diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp b/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp index 44f9a9f..b80a9bf 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp @@ -47,7 +47,7 @@ ArgumentDecoder::~ArgumentDecoder() { ASSERT(m_buffer); fastFree(m_buffer); -#if !PLATFORM(QT) +#if !PLATFORM(QT) && !PLATFORM(GTK) // FIXME: We need to dispose of the mach ports in cases of failure. #else Deque<Attachment>::iterator end = m_attachments.end(); diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp b/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp index fb0b68b..d20dc10 100644 --- a/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp +++ b/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp @@ -50,7 +50,7 @@ ArgumentEncoder::~ArgumentEncoder() { if (m_buffer) fastFree(m_buffer); -#if !PLATFORM(QT) +#if !PLATFORM(QT) && !PLATFORM(GTK) // FIXME: We need to dispose of the attachments in cases of failure. #else for (int i = 0; i < m_attachments.size(); ++i) diff --git a/Source/WebKit2/Platform/CoreIPC/Attachment.h b/Source/WebKit2/Platform/CoreIPC/Attachment.h index c057714..8060c64 100644 --- a/Source/WebKit2/Platform/CoreIPC/Attachment.h +++ b/Source/WebKit2/Platform/CoreIPC/Attachment.h @@ -39,8 +39,8 @@ public: Uninitialized, #if PLATFORM(MAC) MachPortType, - MachOOLMemoryType -#elif PLATFORM(QT) + MachOOLMemoryType, +#elif USE(UNIX_DOMAIN_SOCKETS) MappedMemory #endif }; @@ -48,7 +48,7 @@ public: #if PLATFORM(MAC) Attachment(mach_port_name_t port, mach_msg_type_name_t disposition); Attachment(void* address, mach_msg_size_t size, mach_msg_copy_options_t copyOptions, bool deallocate); -#elif PLATFORM(QT) +#elif USE(UNIX_DOMAIN_SOCKETS) Attachment(int fileDescriptor, size_t); #endif @@ -66,7 +66,7 @@ public: mach_msg_size_t size() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.size; } mach_msg_copy_options_t copyOptions() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.copyOptions; } bool deallocate() const { ASSERT(m_type == MachOOLMemoryType); return m_oolMemory.deallocate; } -#elif PLATFORM(QT) +#elif USE(UNIX_DOMAIN_SOCKETS) size_t size() const { return m_size; } int releaseFileDescriptor() { int temp = m_fileDescriptor; m_fileDescriptor = -1; return temp; } @@ -94,7 +94,7 @@ private: bool deallocate; } m_oolMemory; }; -#elif PLATFORM(QT) +#elif USE(UNIX_DOMAIN_SOCKETS) int m_fileDescriptor; size_t m_size; #endif diff --git a/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h b/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h index 32b5b02..e75ed75 100644 --- a/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h +++ b/Source/WebKit2/Platform/CoreIPC/BinarySemaphore.h @@ -41,6 +41,10 @@ public: void signal(); bool wait(double absoluteTime); +#if PLATFORM(WIN) + HANDLE event() const { return m_event; } +#endif + private: #if PLATFORM(WIN) HANDLE m_event; diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.cpp b/Source/WebKit2/Platform/CoreIPC/Connection.cpp index a65f065..0821ae8 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.cpp +++ b/Source/WebKit2/Platform/CoreIPC/Connection.cpp @@ -29,6 +29,7 @@ #include "BinarySemaphore.h" #include "CoreIPCMessageKinds.h" #include "RunLoop.h" +#include "WebProcess.h" #include "WorkItem.h" #include <wtf/CurrentTime.h> @@ -51,6 +52,13 @@ public: return m_waitForSyncReplySemaphore.wait(absoluteTime); } +#if PLATFORM(WIN) + bool waitWhileDispatchingSentWin32Messages(double absoluteTime, const Vector<HWND>& windowsToReceiveMessages) + { + return RunLoop::dispatchSentMessagesUntil(windowsToReceiveMessages, m_waitForSyncReplySemaphore, absoluteTime); + } +#endif + // Returns true if this message will be handled on a client thread that is currently // waiting for a reply to a synchronous message. bool processIncomingMessage(Connection*, IncomingMessage&); @@ -189,6 +197,7 @@ Connection::Connection(Identifier identifier, bool isServer, Client* client, Run , m_isServer(isServer) , m_syncRequestID(0) , m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(false) + , m_shouldExitOnSyncMessageSendFailure(false) , m_didCloseOnConnectionWorkQueueCallback(0) , m_isConnected(false) , m_connectionQueue("com.apple.CoreIPC.ReceiveQueue") @@ -196,6 +205,7 @@ Connection::Connection(Identifier identifier, bool isServer, Client* client, Run , m_inDispatchMessageCount(0) , m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount(0) , m_didReceiveInvalidMessage(false) + , m_defaultSyncMessageTimeout(NoTimeout) , m_syncMessageState(SyncMessageState::getOrCreate(clientRunLoop)) , m_shouldWaitForSyncReplies(true) { @@ -218,6 +228,13 @@ void Connection::setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcess m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage = flag; } +void Connection::setShouldExitOnSyncMessageSendFailure(bool shouldExitOnSyncMessageSendFailure) +{ + ASSERT(!m_isConnected); + + m_shouldExitOnSyncMessageSendFailure = shouldExitOnSyncMessageSendFailure; +} + void Connection::setDidCloseOnConnectionWorkQueueCallback(DidCloseOnConnectionWorkQueueCallback callback) { ASSERT(!m_isConnected); @@ -246,6 +263,13 @@ void Connection::markCurrentlyDispatchedMessageAsInvalid() m_didReceiveInvalidMessage = true; } +void Connection::setDefaultSyncMessageTimeout(double defaultSyncMessageTimeout) +{ + ASSERT(defaultSyncMessageTimeout != DefaultTimeout); + + m_defaultSyncMessageTimeout = defaultSyncMessageTimeout; +} + PassOwnPtr<ArgumentEncoder> Connection::createSyncMessageArgumentEncoder(uint64_t destinationID, uint64_t& syncRequestID) { OwnPtr<ArgumentEncoder> argumentEncoder = ArgumentEncoder::create(destinationID); @@ -342,14 +366,16 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin // We only allow sending sync messages from the client run loop. ASSERT(RunLoop::current() == m_clientRunLoop); - if (!isValid()) + if (!isValid()) { + didFailToSendSyncMessage(); return 0; - + } + // Push the pending sync reply information on our stack. { MutexLocker locker(m_syncReplyStateMutex); if (!m_shouldWaitForSyncReplies) { - m_client->didFailToSendSyncMessage(this); + didFailToSendSyncMessage(); return 0; } @@ -371,14 +397,21 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin m_pendingSyncReplies.removeLast(); } - if (!reply && m_client) - m_client->didFailToSendSyncMessage(this); + if (!reply) + didFailToSendSyncMessage(); return reply.release(); } PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, double timeout) { + if (timeout == DefaultTimeout) + timeout = m_defaultSyncMessageTimeout; + + // Use a really long timeout. + if (timeout == NoTimeout) + timeout = 1e10; + double absoluteTime = currentTime() + timeout; bool timedOut = false; @@ -401,10 +434,17 @@ PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, } // We didn't find a sync reply yet, keep waiting. +#if PLATFORM(WIN) + timedOut = !m_syncMessageState->waitWhileDispatchingSentWin32Messages(absoluteTime, m_client->windowsToReceiveSentMessagesWhileWaitingForSyncReply()); +#else timedOut = !m_syncMessageState->wait(absoluteTime); +#endif } // We timed out. + if (m_client) + m_client->syncMessageSendTimedOut(this); + return 0; } @@ -565,6 +605,14 @@ void Connection::dispatchSyncMessage(MessageID messageID, ArgumentDecoder* argum sendSyncReply(replyEncoder); } +void Connection::didFailToSendSyncMessage() +{ + if (!m_shouldExitOnSyncMessageSendFailure) + return; + + exit(0); +} + void Connection::enqueueIncomingMessage(IncomingMessage& incomingMessage) { MutexLocker locker(m_incomingMessagesLock); diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.h b/Source/WebKit2/Platform/CoreIPC/Connection.h index b6a2415..8754034 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.h +++ b/Source/WebKit2/Platform/CoreIPC/Connection.h @@ -44,6 +44,9 @@ #include <string> #elif PLATFORM(QT) class QSocketNotifier; +#endif + +#if PLATFORM(QT) || PLATFORM(GTK) #include "PlatformProcessIdentifier.h" #endif @@ -90,7 +93,11 @@ public: public: virtual void didClose(Connection*) = 0; virtual void didReceiveInvalidMessage(Connection*, MessageID) = 0; - virtual void didFailToSendSyncMessage(Connection*) { } + virtual void syncMessageSendTimedOut(Connection*) = 0; + +#if PLATFORM(WIN) + virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply() = 0; +#endif }; #if PLATFORM(MAC) @@ -98,9 +105,7 @@ public: #elif PLATFORM(WIN) typedef HANDLE Identifier; static bool createServerAndClientIdentifiers(Identifier& serverIdentifier, Identifier& clientIdentifier); -#elif PLATFORM(QT) - typedef int Identifier; -#elif PLATFORM(GTK) +#elif USE(UNIX_DOMAIN_SOCKETS) typedef int Identifier; #endif @@ -110,11 +115,12 @@ public: #if PLATFORM(MAC) void setShouldCloseConnectionOnMachExceptions(); -#elif PLATFORM(QT) +#elif PLATFORM(QT) || PLATFORM(GTK) void setShouldCloseConnectionOnProcessTermination(WebKit::PlatformProcessIdentifier); #endif void setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(bool); + void setShouldExitOnSyncMessageSendFailure(bool shouldExitOnSyncMessageSendFailure); // The set callback will be called on the connection work queue when the connection is closed, // before didCall is called on the client thread. Must be called before the connection is opened. @@ -128,10 +134,13 @@ public: void invalidate(); void markCurrentlyDispatchedMessageAsInvalid(); - static const unsigned long long NoTimeout = 10000000000ULL; + void setDefaultSyncMessageTimeout(double); + + static const int DefaultTimeout = 0; + static const int NoTimeout = -1; template<typename T> bool send(const T& message, uint64_t destinationID, unsigned messageSendFlags = 0); - template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = NoTimeout); + template<typename T> bool sendSync(const T& message, const typename T::Reply& reply, uint64_t destinationID, double timeout = DefaultTimeout); template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, double timeout); PassOwnPtr<ArgumentEncoder> createSyncMessageArgumentEncoder(uint64_t destinationID, uint64_t& syncRequestID); @@ -208,6 +217,7 @@ private: void dispatchMessage(IncomingMessage&); void dispatchMessages(); void dispatchSyncMessage(MessageID, ArgumentDecoder*); + void didFailToSendSyncMessage(); // Can be called on any thread. void enqueueIncomingMessage(IncomingMessage&); @@ -217,6 +227,7 @@ private: uint64_t m_syncRequestID; bool m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage; + bool m_shouldExitOnSyncMessageSendFailure; DidCloseOnConnectionWorkQueueCallback m_didCloseOnConnectionWorkQueueCallback; bool m_isConnected; @@ -227,6 +238,8 @@ private: unsigned m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount; bool m_didReceiveInvalidMessage; + double m_defaultSyncMessageTimeout; + // Incoming messages. Mutex m_incomingMessagesLock; Vector<IncomingMessage> m_incomingMessages; @@ -305,23 +318,17 @@ private: OwnPtr<ArgumentEncoder> m_pendingWriteArguments; OVERLAPPED m_writeState; HANDLE m_connectionPipe; -#elif PLATFORM(QT) +#elif USE(UNIX_DOMAIN_SOCKETS) // Called on the connection queue. void readyReadHandler(); Vector<uint8_t> m_readBuffer; size_t m_currentMessageSize; - QSocketNotifier* m_socketNotifier; int m_socketDescriptor; -#elif PLATFORM(GTK) - void readEventHandler(); - void processCompletedMessage(); - bool messageProcessingCompleted() { return !m_currentMessageSize; } - int m_socket; - Vector<uint8_t> m_readBuffer; - size_t m_currentMessageSize; - size_t m_pendingBytes; +#if PLATFORM(QT) + QSocketNotifier* m_socketNotifier; +#endif #endif }; diff --git a/Source/WebKit2/Platform/CoreIPC/HandleMessage.h b/Source/WebKit2/Platform/CoreIPC/HandleMessage.h index a99c76e..112503d 100644 --- a/Source/WebKit2/Platform/CoreIPC/HandleMessage.h +++ b/Source/WebKit2/Platform/CoreIPC/HandleMessage.h @@ -141,6 +141,12 @@ void callMemberFunction(const Arguments4<P1, P2, P3, P4>& args, Arguments1<R1>& (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, replyArgs.argument1); } +template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename R1> +void callMemberFunction(const Arguments6<P1, P2, P3, P4, P5, P6>& args, Arguments1<R1>& replyArgs, C* object, MF function) +{ + (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, args.argument5, args.argument6, replyArgs.argument1); +} + template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename R1> void callMemberFunction(const Arguments7<P1, P2, P3, P4, P5, P6, P7>& args, Arguments1<R1>& replyArgs, C* object, MF function) { @@ -171,6 +177,13 @@ void callMemberFunction(const Arguments4<P1, P2, P3, P4>& args, Arguments3<R1, R (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, replyArgs.argument1, replyArgs.argument2, replyArgs.argument3); } +// Dispatch functions with delayed reply arguments. +template<typename C, typename MF, typename P1, typename R> +void callMemberFunction(const Arguments1<P1>& args, PassRefPtr<R> delayedReply, C* object, MF function) +{ + (object->*function)(args.argument1, delayedReply); +} + // Variadic dispatch functions. template<typename C, typename MF> @@ -286,6 +299,17 @@ void handleMessageVariadic(ArgumentDecoder* argumentDecoder, ArgumentEncoder* re replyEncoder->encode(replyArguments); } +template<typename T, typename C, typename MF> +void handleMessageDelayed(Connection* connection, ArgumentDecoder* argumentDecoder, ArgumentEncoder* replyEncoder, C* object, MF function) +{ + typename T::DecodeType::ValueType arguments; + if (!argumentDecoder->decode(arguments)) + return; + + RefPtr<typename T::DelayedReply> delayedReply = adoptRef(new typename T::DelayedReply(connection, replyEncoder)); + callMemberFunction(arguments, delayedReply.release(), object, function); +} + } // namespace CoreIPC #endif // HandleMessage_h diff --git a/Source/WebKit2/Platform/CoreIPC/MessageID.h b/Source/WebKit2/Platform/CoreIPC/MessageID.h index 2afb168..0b52806 100644 --- a/Source/WebKit2/Platform/CoreIPC/MessageID.h +++ b/Source/WebKit2/Platform/CoreIPC/MessageID.h @@ -69,7 +69,6 @@ enum MessageClass { MessageClassWebMediaCacheManagerProxy, MessageClassWebPageProxy, MessageClassWebProcessProxy, - MessageClassWebProcessProxyLegacy, MessageClassWebResourceCacheManagerProxy, // Messages sent by the UI process to the plug-in process. diff --git a/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp b/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp deleted file mode 100644 index 4b140ee..0000000 --- a/Source/WebKit2/Platform/CoreIPC/gtk/ConnectionGtk.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "Connection.h" - -#include "ArgumentEncoder.h" -#include "WorkItem.h" -#include <errno.h> -#include <glib.h> -#include <sys/fcntl.h> - -using namespace std; - -namespace CoreIPC { - -static const size_t initialMessageBufferSize = 4096; - -static int readBytesFromSocket(int fileDescriptor, uint8_t* ptr, size_t length) -{ - ASSERT(fileDescriptor > 0); - ASSERT(ptr); - ASSERT(length > 0); - - ssize_t numberOfBytesRead = 0; - size_t pendingBytesToRead = length; - uint8_t* buffer = ptr; - - while (pendingBytesToRead > 0) { - if ((numberOfBytesRead = read(fileDescriptor, buffer, pendingBytesToRead)) < 0) { - if (errno == EINTR) - numberOfBytesRead = 0; - else if (errno == EAGAIN || errno == EWOULDBLOCK) - break; - else - return 0; - } else if (!numberOfBytesRead) - break; - - buffer += numberOfBytesRead; - pendingBytesToRead -= numberOfBytesRead; - } - - return (length - pendingBytesToRead); -} - -static bool writeBytesToSocket(int fileDescriptor, uint8_t* ptr, size_t length) -{ - ASSERT(fileDescriptor > 0); - ASSERT(ptr); - ASSERT(length > 0); - - ssize_t numberOfBytesWritten = 0; - size_t pendingBytesToWrite = length; - uint8_t* buffer = ptr; - - // Keep writing to the socket till the complete message has been written. - while (pendingBytesToWrite > 0) { - if ((numberOfBytesWritten = write(fileDescriptor, buffer, pendingBytesToWrite)) < 0) { - if (errno == EINTR) - numberOfBytesWritten = 0; - else - return false; - } - buffer += numberOfBytesWritten; - pendingBytesToWrite -= numberOfBytesWritten; - } - - // Write operation failed if complete message is not written. - return !pendingBytesToWrite; -} - -void Connection::platformInitialize(Identifier identifier) -{ - m_currentMessageSize = 0; - m_pendingBytes = 0; - m_readBuffer.resize(initialMessageBufferSize); - m_socket = identifier; -} - -void Connection::platformInvalidate() -{ - if (!m_isConnected) - return; - - m_connectionQueue.unregisterEventSourceHandler(m_socket); - if (m_socket > 0) { - close(m_socket); - m_socket = -1; - } - - m_isConnected = false; -} - -void Connection::processCompletedMessage() -{ - size_t realBufferSize = m_currentMessageSize - sizeof(MessageID); - unsigned messageID = *reinterpret_cast<unsigned*>(m_readBuffer.data() + realBufferSize); - - processIncomingMessage(MessageID::fromInt(messageID), adoptPtr(new ArgumentDecoder(m_readBuffer.data(), realBufferSize))); - - // Prepare for the next message. - m_currentMessageSize = 0; - m_pendingBytes = 0; -} - -void Connection::readEventHandler() -{ - if (m_socket < 0) - return; - - // Handle any previously unprocessed message. - if (!messageProcessingCompleted()) { - if ((m_pendingBytes -= readBytesFromSocket(m_socket, (m_readBuffer.data() + (m_currentMessageSize - m_pendingBytes)), m_pendingBytes)) > 0) - return; - - // Message received completely. Process the message now. - processCompletedMessage(); - } - - // Prepare to read the next message. - uint8_t sizeBuffer[sizeof(size_t)]; - memset(sizeBuffer, 0, sizeof(size_t)); - - while (messageProcessingCompleted()) { - if (readBytesFromSocket(m_socket, sizeBuffer, sizeof(size_t))) - m_currentMessageSize = *reinterpret_cast<size_t*>(sizeBuffer); - - if (!m_currentMessageSize) - break; - - if (m_readBuffer.size() < m_currentMessageSize) - m_readBuffer.grow(m_currentMessageSize); - - m_pendingBytes = m_currentMessageSize - readBytesFromSocket(m_socket, m_readBuffer.data(), m_currentMessageSize); - if (m_pendingBytes > 0) // Message partially received. - break; - - // Message received completely. Process the message now. - processCompletedMessage(); - - memset(sizeBuffer, 0, sizeof(size_t)); - } -} - -bool Connection::open() -{ - int flags = fcntl(m_socket, F_GETFL, 0); - fcntl(m_socket, F_SETFL, flags | O_NONBLOCK); - - m_isConnected = true; - - // Register callbacks for connection termination and input data on the WorkQueue. - m_connectionQueue.registerEventSourceHandler(m_socket, (G_IO_HUP | G_IO_ERR), WorkItem::create(this, &Connection::connectionDidClose)); - m_connectionQueue.registerEventSourceHandler(m_socket, G_IO_IN, WorkItem::create(this, &Connection::readEventHandler)); - return true; -} - -bool Connection::platformCanSendOutgoingMessages() const -{ - return (m_socket > 0); -} - -bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<ArgumentEncoder> arguments) -{ - if (m_socket < 0) - return false; - - // We put the message ID last. - arguments->encodeUInt32(messageID.toInt()); - - size_t bufferSize = arguments->bufferSize(); - - // Send the message size first. - if (!writeBytesToSocket(m_socket, reinterpret_cast<uint8_t*>(&bufferSize), sizeof(size_t))) - return false; - - if (!writeBytesToSocket(m_socket, arguments->buffer(), arguments->bufferSize())) - return false; - - return true; -} - -} // namespace CoreIPC diff --git a/Source/WebKit2/Platform/CoreIPC/qt/AttachmentQt.cpp b/Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp index 4c0ebc0..2d842da 100644 --- a/Source/WebKit2/Platform/CoreIPC/qt/AttachmentQt.cpp +++ b/Source/WebKit2/Platform/CoreIPC/unix/AttachmentUnix.cpp @@ -27,11 +27,8 @@ #include "config.h" #include "Attachment.h" -#if PLATFORM(QT) #include <unistd.h> #include <errno.h> -#endif - namespace CoreIPC { diff --git a/Source/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp b/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp index 225d7dc..92ffff3 100644 --- a/Source/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp +++ b/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp @@ -32,14 +32,19 @@ #include "WorkItem.h" #include "SharedMemory.h" #include "WebProcessProxy.h" -#include <QApplication> -#include <QSocketNotifier> #include <sys/socket.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <wtf/Assertions.h> +#if PLATFORM(QT) +#include <QApplication> +#include <QSocketNotifier> +#elif PLATFORM(GTK) +#include <glib.h> +#endif + using namespace std; namespace CoreIPC { @@ -48,7 +53,7 @@ static const size_t messageMaxSize = 4096; static const size_t attachmentMaxAmount = 255; enum { - MessageBodyIsOOL = 1 << 31 + MessageBodyIsOOL = 1U << 31 }; class MessageInfo { @@ -88,9 +93,12 @@ private: void Connection::platformInitialize(Identifier identifier) { m_socketDescriptor = identifier; - m_socketNotifier = 0; m_readBuffer.resize(messageMaxSize); m_currentMessageSize = 0; + +#if PLATFORM(QT) + m_socketNotifier = 0; +#endif } void Connection::platformInvalidate() @@ -101,12 +109,20 @@ void Connection::platformInvalidate() if (!m_isConnected) return; +#if PLATFORM(GTK) + m_connectionQueue.unregisterEventSourceHandler(m_socketDescriptor); +#endif + +#if PLATFORM(QT) delete m_socketNotifier; m_socketNotifier = 0; +#endif + m_socketDescriptor = -1; m_isConnected = false; } +#if PLATFORM(QT) class SocketNotifierResourceGuard { public: SocketNotifierResourceGuard(QSocketNotifier* socketNotifier) @@ -123,6 +139,7 @@ public: private: QSocketNotifier* const m_socketNotifier; }; +#endif template<class T, class iterator> class AttachmentResourceGuard { @@ -144,17 +161,19 @@ private: void Connection::readyReadHandler() { Deque<Attachment> attachments; +#if PLATFORM(QT) SocketNotifierResourceGuard socketNotifierEnabler(m_socketNotifier); +#endif AttachmentResourceGuard<Deque<Attachment>, Deque<Attachment>::iterator> attachementDisposer(attachments); - char attachmentDescriptorBuffer[CMSG_SPACE(sizeof(int) * (attachmentMaxAmount))]; + OwnArrayPtr<char> attachmentDescriptorBuffer = adoptArrayPtr(new char[CMSG_SPACE(sizeof(int) * (attachmentMaxAmount))]); struct msghdr message; memset(&message, 0, sizeof(message)); struct iovec iov[1]; memset(&iov, 0, sizeof(iov)); - message.msg_control = attachmentDescriptorBuffer; + message.msg_control = attachmentDescriptorBuffer.get(); message.msg_controllen = CMSG_SPACE(sizeof(int) * (attachmentMaxAmount)); iov[0].iov_base = m_readBuffer.data(); @@ -184,13 +203,13 @@ void Connection::readyReadHandler() if (messageInfo.attachmentCount()) { if (controlMessage && controlMessage->cmsg_level == SOL_SOCKET && controlMessage->cmsg_type == SCM_RIGHTS) { - size_t attachmentSizes[messageInfo.attachmentCount()]; - memcpy(attachmentSizes, messageData, sizeof(attachmentSizes)); + OwnArrayPtr<size_t> attachmentSizes = adoptArrayPtr(new size_t[messageInfo.attachmentCount()]); + memcpy(attachmentSizes.get(), messageData, sizeof(size_t) * messageInfo.attachmentCount()); messageData += sizeof(attachmentSizes); - int fileDescriptors[messageInfo.attachmentCount()]; - memcpy(fileDescriptors, CMSG_DATA(controlMessage), sizeof(fileDescriptors)); + OwnArrayPtr<int> fileDescriptors = adoptArrayPtr(new int[messageInfo.attachmentCount()]); + memcpy(fileDescriptors.get(), CMSG_DATA(controlMessage), sizeof(int) * messageInfo.attachmentCount()); int attachmentCount = messageInfo.attachmentCount(); @@ -253,7 +272,10 @@ void Connection::readyReadHandler() bool Connection::open() { +#if PLATFORM(QT) ASSERT(!m_socketNotifier); +#endif + int flags = fcntl(m_socketDescriptor, F_GETFL, 0); while (fcntl(m_socketDescriptor, F_SETFL, flags | O_NONBLOCK) == -1) { if (errno != EINTR) { @@ -263,7 +285,12 @@ bool Connection::open() } m_isConnected = true; +#if PLATFORM(QT) m_socketNotifier = m_connectionQueue.registerSocketEventHandler(m_socketDescriptor, QSocketNotifier::Read, WorkItem::create(this, &Connection::readyReadHandler)); +#elif PLATFORM(GTK) + m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, (G_IO_HUP | G_IO_ERR), WorkItem::create(this, &Connection::connectionDidClose)); + m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, G_IO_IN, WorkItem::create(this, &Connection::readyReadHandler)); +#endif // Schedule a call to readyReadHandler. Data may have arrived before installation of the signal // handler. @@ -274,12 +301,15 @@ bool Connection::open() bool Connection::platformCanSendOutgoingMessages() const { - return m_socketNotifier; + return m_isConnected; } bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<ArgumentEncoder> arguments) { +#if PLATFORM(QT) ASSERT(m_socketNotifier); +#endif + COMPILE_ASSERT(sizeof(MessageInfo) + attachmentMaxAmount * sizeof(size_t) <= messageMaxSize, AttachmentsFitToMessageInline); Vector<Attachment> attachments = arguments->releaseAttachments(); @@ -320,12 +350,12 @@ bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<ArgumentEnc iov[0].iov_base = reinterpret_cast<void*>(&messageInfo); iov[0].iov_len = sizeof(messageInfo); - char attachmentFDBuffer[CMSG_SPACE(sizeof(int) * (attachments.size()))]; - size_t attachmentSizes[attachments.size()]; + OwnArrayPtr<char> attachmentFDBuffer = adoptArrayPtr(new char[CMSG_SPACE(sizeof(int) * attachments.size())]); + OwnArrayPtr<size_t> attachmentSizes = adoptArrayPtr(new size_t[attachments.size()]); if (!attachments.isEmpty()) { - message.msg_control = attachmentFDBuffer; - message.msg_controllen = sizeof(attachmentFDBuffer); + message.msg_control = attachmentFDBuffer.get(); + message.msg_controllen = sizeof(char) * CMSG_SPACE(sizeof(int) * attachments.size()); struct cmsghdr* cmsg = CMSG_FIRSTHDR(&message); cmsg->cmsg_level = SOL_SOCKET; @@ -333,15 +363,15 @@ bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<ArgumentEnc cmsg->cmsg_len = CMSG_LEN(sizeof(int) * attachments.size()); int* fdptr = reinterpret_cast<int*>(CMSG_DATA(cmsg)); - for (int i = 0; i < attachments.size(); ++i) { + for (size_t i = 0; i < attachments.size(); ++i) { attachmentSizes[i] = attachments[i].size(); fdptr[i] = attachments[i].fileDescriptor(); } message.msg_controllen = cmsg->cmsg_len; - iov[iovLength].iov_base = attachmentSizes; - iov[iovLength].iov_len = sizeof(attachmentSizes); + iov[iovLength].iov_base = attachmentSizes.get(); + iov[iovLength].iov_len = sizeof(size_t) * attachments.size(); ++iovLength; } @@ -361,9 +391,11 @@ bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<ArgumentEnc return true; } +#if PLATFORM(QT) || PLATFORM(GTK) void Connection::setShouldCloseConnectionOnProcessTermination(WebKit::PlatformProcessIdentifier process) { m_connectionQueue.scheduleWorkOnTermination(process, WorkItem::create(this, &Connection::connectionDidClose)); } +#endif } // namespace CoreIPC diff --git a/Source/WebKit2/Platform/PlatformProcessIdentifier.h b/Source/WebKit2/Platform/PlatformProcessIdentifier.h index 0363692..5022da7 100644 --- a/Source/WebKit2/Platform/PlatformProcessIdentifier.h +++ b/Source/WebKit2/Platform/PlatformProcessIdentifier.h @@ -40,7 +40,12 @@ typedef HANDLE PlatformProcessIdentifier; #elif PLATFORM(QT) typedef QProcess* PlatformProcessIdentifier; #elif PLATFORM(GTK) -typedef pid_t PlatformProcessIdentifier; +#ifdef G_OS_WIN32 +typedef void* GPid; +#else +typedef int GPid; +#endif +typedef GPid PlatformProcessIdentifier; #endif } // namespace WebKit diff --git a/Source/WebKit2/Platform/RunLoop.h b/Source/WebKit2/Platform/RunLoop.h index aa87506..b2f1411 100644 --- a/Source/WebKit2/Platform/RunLoop.h +++ b/Source/WebKit2/Platform/RunLoop.h @@ -34,6 +34,7 @@ #include <wtf/Threading.h> #include <wtf/Vector.h> #if PLATFORM(GTK) +#include <wtf/gobject/GRefPtr.h> typedef struct _GSource GSource; typedef struct _GMainLoop GMainLoop; typedef struct _GMainContext GMainContext; @@ -42,6 +43,10 @@ typedef int gboolean; class WorkItem; +namespace CoreIPC { + class BinarySemaphore; +} + class RunLoop { public: // Must be called from the main thread. @@ -52,6 +57,14 @@ public: void scheduleWork(PassOwnPtr<WorkItem>); +#if PLATFORM(WIN) + // The absoluteTime is in seconds, starting on January 1, 1970. The time is assumed to use the + // same time zone as WTF::currentTime(). Dispatches sent (not posted) messages to the passed-in + // set of HWNDs until the semaphore is signaled or absoluteTime is reached. Returns true if the + // semaphore is signaled, false otherwise. + static bool dispatchSentMessagesUntil(const Vector<HWND>& windows, CoreIPC::BinarySemaphore&, double absoluteTime); +#endif + static void run(); void stop(); @@ -86,10 +99,12 @@ public: int m_ID; bool m_isRepeating; #elif PLATFORM(GTK) - static gboolean oneShotTimerFired(RunLoop::TimerBase*); - static gboolean repeatingTimerFired(RunLoop::TimerBase*); - void resetTimerSource(); - GSource* m_timerSource; + static gboolean timerFiredCallback(RunLoop::TimerBase*); + static void destroyNotifyCallback(RunLoop::TimerBase*); + gboolean isRepeating() const { return m_isRepeating; } + void clearTimerSource(); + GRefPtr<GSource> m_timerSource; + gboolean m_isRepeating; #endif }; diff --git a/Source/WebKit2/Platform/SharedMemory.h b/Source/WebKit2/Platform/SharedMemory.h index a4b95bf..b242b9b 100644 --- a/Source/WebKit2/Platform/SharedMemory.h +++ b/Source/WebKit2/Platform/SharedMemory.h @@ -30,7 +30,7 @@ #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> -#if PLATFORM(QT) +#if PLATFORM(QT) || PLATFORM(GTK) #include "Attachment.h" #include <wtf/text/WTFString.h> #endif @@ -60,7 +60,7 @@ public: void encode(CoreIPC::ArgumentEncoder*) const; static bool decode(CoreIPC::ArgumentDecoder*, Handle&); -#if PLATFORM(QT) +#if USE(UNIX_DOMAIN_SOCKETS) CoreIPC::Attachment releaseToAttachment() const; void adoptFromAttachment(int fileDescriptor, size_t); #endif @@ -70,7 +70,7 @@ public: mutable mach_port_t m_port; #elif PLATFORM(WIN) mutable HANDLE m_handle; -#elif PLATFORM(QT) +#elif USE(UNIX_DOMAIN_SOCKETS) mutable int m_fileDescriptor; #endif size_t m_size; @@ -82,6 +82,10 @@ public: // Create a shared memory object from the given handle and the requested protection. Will return 0 on failure. static PassRefPtr<SharedMemory> create(const Handle&, Protection); +#if PLATFORM(WIN) + static PassRefPtr<SharedMemory> adopt(HANDLE, size_t, Protection); +#endif + ~SharedMemory(); bool createHandle(Handle&, Protection); @@ -99,7 +103,7 @@ private: mach_port_t m_port; #elif PLATFORM(WIN) HANDLE m_handle; -#elif PLATFORM(QT) +#elif USE(UNIX_DOMAIN_SOCKETS) int m_fileDescriptor; #endif }; diff --git a/Source/WebKit2/Platform/WorkQueue.h b/Source/WebKit2/Platform/WorkQueue.h index 99f77ae..74d6055 100644 --- a/Source/WebKit2/Platform/WorkQueue.h +++ b/Source/WebKit2/Platform/WorkQueue.h @@ -46,8 +46,10 @@ class QObject; class QThread; #elif PLATFORM(GTK) +#include "PlatformProcessIdentifier.h" typedef struct _GMainContext GMainContext; typedef struct _GMainLoop GMainLoop; +typedef gboolean (*GSourceFunc) (gpointer data); #endif class WorkQueue { @@ -87,6 +89,7 @@ public: #elif PLATFORM(GTK) void registerEventSourceHandler(int, int, PassOwnPtr<WorkItem>); void unregisterEventSourceHandler(int); + void scheduleWorkOnTermination(WebKit::PlatformProcessIdentifier, PassOwnPtr<WorkItem>); #endif private: @@ -165,6 +168,7 @@ private: #elif PLATFORM(GTK) static void* startWorkQueueThread(WorkQueue*); void workQueueThreadBody(); + void scheduleWorkOnSource(GSource*, PassOwnPtr<WorkItem>, GSourceFunc); ThreadIdentifier m_workQueueThread; GMainContext* m_eventContext; diff --git a/Source/WebKit2/Platform/gtk/RunLoopGtk.cpp b/Source/WebKit2/Platform/gtk/RunLoopGtk.cpp index 70b0552..0f4ab68 100644 --- a/Source/WebKit2/Platform/gtk/RunLoopGtk.cpp +++ b/Source/WebKit2/Platform/gtk/RunLoopGtk.cpp @@ -41,7 +41,8 @@ RunLoop::RunLoop() RunLoop::~RunLoop() { if (m_runLoopMain) { - g_main_loop_quit(m_runLoopMain); + if (g_main_loop_is_running(m_runLoopMain)) + g_main_loop_quit(m_runLoopMain); g_main_loop_unref(m_runLoopMain); } @@ -72,9 +73,10 @@ gboolean RunLoop::queueWork(RunLoop* runLoop) void RunLoop::wakeUp() { - GSource* source = g_timeout_source_new(0); - g_source_set_callback(source, reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0); - g_source_attach(source, m_runLoopContext); + GRefPtr<GSource> source = adoptGRef(g_idle_source_new()); + g_source_set_priority(source.get(), G_PRIORITY_DEFAULT); + g_source_set_callback(source.get(), reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0); + g_source_attach(source.get(), m_runLoopContext); g_main_context_wakeup(m_runLoopContext); } @@ -90,22 +92,20 @@ RunLoop::TimerBase::~TimerBase() stop(); } -void RunLoop::TimerBase::resetTimerSource() +void RunLoop::TimerBase::clearTimerSource() { m_timerSource = 0; } -gboolean RunLoop::TimerBase::oneShotTimerFired(RunLoop::TimerBase* timer) +void RunLoop::TimerBase::destroyNotifyCallback(RunLoop::TimerBase* timer) { - timer->fired(); - timer->resetTimerSource(); - return FALSE; + timer->clearTimerSource(); } -gboolean RunLoop::TimerBase::repeatingTimerFired(RunLoop::TimerBase* timer) +gboolean RunLoop::TimerBase::timerFiredCallback(RunLoop::TimerBase* timer) { timer->fired(); - return TRUE; + return timer->isRepeating(); } void RunLoop::TimerBase::start(double fireInterval, bool repeat) @@ -113,12 +113,11 @@ void RunLoop::TimerBase::start(double fireInterval, bool repeat) if (m_timerSource) stop(); - m_timerSource = g_timeout_source_new(static_cast<guint>(fireInterval)); - if (repeat) - g_source_set_callback(m_timerSource, reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::repeatingTimerFired), this, 0); - else - g_source_set_callback(m_timerSource, reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::oneShotTimerFired), this, 0); - g_source_attach(m_timerSource, m_runLoop->m_runLoopContext); + m_timerSource = adoptGRef(g_timeout_source_new(static_cast<guint>(fireInterval * 1000))); + m_isRepeating = repeat; + g_source_set_callback(m_timerSource.get(), reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::timerFiredCallback), this, + reinterpret_cast<GDestroyNotify>(&RunLoop::TimerBase::destroyNotifyCallback)); + g_source_attach(m_timerSource.get(), m_runLoop->m_runLoopContext); } void RunLoop::TimerBase::stop() @@ -126,8 +125,8 @@ void RunLoop::TimerBase::stop() if (!m_timerSource) return; - g_source_destroy(m_timerSource); - m_timerSource = 0; + g_source_destroy(m_timerSource.get()); + clearTimerSource(); } bool RunLoop::TimerBase::isActive() const diff --git a/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp b/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp index dbe38bd..0cdb92f 100644 --- a/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp +++ b/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp @@ -1,4 +1,5 @@ /* + * Copyright (C) 2011 Igalia S.L. * Copyright (C) 2010 Apple Inc. All rights reserved. * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. * @@ -29,56 +30,63 @@ #include "WKBase.h" #include <WebCore/NotImplemented.h> +#include <gio/gio.h> #include <glib.h> +#include <wtf/gobject/GRefPtr.h> // WorkQueue::EventSource class WorkQueue::EventSource { public: - EventSource(GSource* dispatchSource, PassOwnPtr<WorkItem> workItem, WorkQueue* workQueue) - : m_dispatchSource(dispatchSource) - , m_workItem(workItem) + EventSource(PassOwnPtr<WorkItem> workItem, WorkQueue* workQueue, GCancellable* cancellable) + : m_workItem(workItem) , m_workQueue(workQueue) + , m_cancellable(cancellable) { } - GSource* dispatchSource() { return m_dispatchSource; } + void cancel() + { + if (!m_cancellable) + return; + g_cancellable_cancel(m_cancellable); + } - static gboolean performWorkOnce(EventSource* eventSource) + static void executeEventSource(EventSource* eventSource) { ASSERT(eventSource); WorkQueue* queue = eventSource->m_workQueue; { MutexLocker locker(queue->m_isValidMutex); if (!queue->m_isValid) - return FALSE; + return; } eventSource->m_workItem->execute(); - return FALSE; } - static gboolean performWork(GIOChannel* channel, GIOCondition condition, EventSource* eventSource) + static gboolean performWorkOnce(EventSource* eventSource) { - ASSERT(eventSource); + executeEventSource(eventSource); + return FALSE; + } - if (!(condition & G_IO_IN) && !(condition & G_IO_HUP) && !(condition & G_IO_ERR)) + static gboolean performWork(GSocket* socket, GIOCondition condition, EventSource* eventSource) + { + if (!(condition & G_IO_IN) && !(condition & G_IO_HUP) && !(condition & G_IO_ERR)) { + // EventSource has been cancelled, return FALSE to destroy the source. return FALSE; - - WorkQueue* queue = eventSource->m_workQueue; - { - MutexLocker locker(queue->m_isValidMutex); - if (!queue->m_isValid) - return FALSE; } - eventSource->m_workItem->execute(); - - if ((condition & G_IO_HUP) || (condition & G_IO_ERR)) - return FALSE; - + executeEventSource(eventSource); return TRUE; } - + + static gboolean performWorkOnTermination(GPid, gint, EventSource* eventSource) + { + executeEventSource(eventSource); + return FALSE; + } + static void deleteEventSource(EventSource* eventSource) { ASSERT(eventSource); @@ -86,9 +94,9 @@ public: } public: - GSource* m_dispatchSource; PassOwnPtr<WorkItem> m_workItem; WorkQueue* m_workQueue; + GCancellable* m_cancellable; }; // WorkQueue @@ -132,14 +140,15 @@ void WorkQueue::workQueueThreadBody() void WorkQueue::registerEventSourceHandler(int fileDescriptor, int condition, PassOwnPtr<WorkItem> item) { - GIOChannel* channel = g_io_channel_unix_new(fileDescriptor); - ASSERT(channel); - GSource* dispatchSource = g_io_create_watch(channel, static_cast<GIOCondition>(condition)); + GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0)); + ASSERT(socket); + GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new()); + GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get())); ASSERT(dispatchSource); - EventSource* eventSource = new EventSource(dispatchSource, item, this); + EventSource* eventSource = new EventSource(item, this, cancellable.get()); ASSERT(eventSource); - g_source_set_callback(dispatchSource, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWork), + g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWork), eventSource, reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); // Set up the event sources under the mutex since this is shared across multiple threads. @@ -154,11 +163,7 @@ void WorkQueue::registerEventSourceHandler(int fileDescriptor, int condition, Pa m_eventSources.set(fileDescriptor, sources); } - // Attach the event source to the GMainContext under the mutex since this is shared across multiple threads. - { - MutexLocker locker(m_eventLoopLock); - g_source_attach(dispatchSource, m_eventContext); - } + g_source_attach(dispatchSource.get(), m_eventContext); } void WorkQueue::unregisterEventSourceHandler(int fileDescriptor) @@ -174,29 +179,43 @@ void WorkQueue::unregisterEventSourceHandler(int fileDescriptor) if (it != m_eventSources.end()) { Vector<EventSource*> sources = it->second; for (unsigned i = 0; i < sources.size(); i++) - g_source_destroy(sources[i]->dispatchSource()); + sources[i]->cancel(); m_eventSources.remove(it); } } +void WorkQueue::scheduleWorkOnSource(GSource* dispatchSource, PassOwnPtr<WorkItem> item, GSourceFunc sourceCallback) +{ + EventSource* eventSource = new EventSource(item, this, 0); + + g_source_set_callback(dispatchSource, sourceCallback, eventSource, + reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); + + g_source_attach(dispatchSource, m_eventContext); +} + void WorkQueue::scheduleWork(PassOwnPtr<WorkItem> item) { - GSource* dispatchSource = g_timeout_source_new(0); + GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new()); ASSERT(dispatchSource); - EventSource* eventSource = new EventSource(dispatchSource, item, this); - - g_source_set_callback(dispatchSource, - reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce), - eventSource, - reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); - { - MutexLocker locker(m_eventLoopLock); - g_source_attach(dispatchSource, m_eventContext); - } + g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT); + + scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); } -void WorkQueue::scheduleWorkAfterDelay(PassOwnPtr<WorkItem>, double) +void WorkQueue::scheduleWorkAfterDelay(PassOwnPtr<WorkItem> item, double delay) { - notImplemented(); + GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(static_cast<guint>(delay * 1000))); + ASSERT(dispatchSource); + + scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); +} + +void WorkQueue::scheduleWorkOnTermination(WebKit::PlatformProcessIdentifier process, PassOwnPtr<WorkItem> item) +{ + GRefPtr<GSource> dispatchSource = adoptGRef(g_child_watch_source_new(process)); + ASSERT(dispatchSource); + + scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination)); } diff --git a/Source/WebKit2/Platform/qt/SharedMemoryQt.cpp b/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp index 8d5d70f..7acf132 100644 --- a/Source/WebKit2/Platform/qt/SharedMemoryQt.cpp +++ b/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp @@ -31,7 +31,6 @@ #include "ArgumentDecoder.h" #include "ArgumentEncoder.h" #include "WebCoreArgumentCoders.h" -#include <QDir> #include <errno.h> #include <fcntl.h> #include <stdlib.h> @@ -42,6 +41,12 @@ #include <wtf/Assertions.h> #include <wtf/CurrentTime.h> +#if PLATFORM(QT) +#include <QDir> +#elif PLATFORM(GTK) +#include <wtf/gobject/GOwnPtr.h> +#endif + namespace WebKit { SharedMemory::Handle::Handle() @@ -101,9 +106,14 @@ void SharedMemory::Handle::adoptFromAttachment(int fileDescriptor, size_t size) PassRefPtr<SharedMemory> SharedMemory::create(size_t size) { +#if PLATFORM(QT) QString tempName = QDir::temp().filePath(QLatin1String("qwkshm.XXXXXX")); QByteArray tempNameCSTR = tempName.toLocal8Bit(); char* tempNameC = tempNameCSTR.data(); +#elif PLATFORM(GTK) + GOwnPtr<gchar> tempName(g_build_filename(g_get_tmp_dir(), "WK2SharedMemoryXXXXXX", NULL)); + gchar* tempNameC = tempName.get(); +#endif int fileDescriptor; while ((fileDescriptor = mkstemp(tempNameC)) == -1) { diff --git a/Source/WebKit2/Platform/win/RunLoopWin.cpp b/Source/WebKit2/Platform/win/RunLoopWin.cpp index 0ca7d9b..21bc2e0 100644 --- a/Source/WebKit2/Platform/win/RunLoopWin.cpp +++ b/Source/WebKit2/Platform/win/RunLoopWin.cpp @@ -26,7 +26,12 @@ #include "config.h" #include "RunLoop.h" +#include "BinarySemaphore.h" #include "WorkItem.h" +#include <wtf/CurrentTime.h> + +using namespace CoreIPC; +using namespace std; static const UINT PerformWorkMessage = WM_USER + 1; static const LPWSTR kRunLoopMessageWindowClassName = L"RunLoopMessageWindow"; @@ -74,6 +79,47 @@ void RunLoop::run() } } +bool RunLoop::dispatchSentMessagesUntil(const Vector<HWND>& windows, CoreIPC::BinarySemaphore& semaphore, double absoluteTime) +{ + if (windows.isEmpty()) + return semaphore.wait(absoluteTime); + + HANDLE handle = semaphore.event(); + DWORD handleCount = 1; + + while (true) { + DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime); + if (!interval) { + // Consider the wait to have timed out, even if the semaphore is currently signaled. + // This matches the WTF::ThreadCondition implementation of BinarySemaphore::wait. + return false; + } + + DWORD result = ::MsgWaitForMultipleObjectsEx(handleCount, &handle, interval, QS_SENDMESSAGE, 0); + if (result == WAIT_OBJECT_0) { + // The semaphore was signaled. + return true; + } + if (result == WAIT_TIMEOUT) { + // absoluteTime was reached. + return false; + } + if (result == WAIT_OBJECT_0 + handleCount) { + // One or more sent messages are available. Process sent messages for all the windows + // we were given, since we don't have a way of knowing which window has available sent + // messages. + for (size_t i = 0; i < windows.size(); ++i) { + MSG message; + ::PeekMessageW(&message, windows[i], 0, 0, PM_NOREMOVE | PM_QS_SENDMESSAGE); + } + continue; + } + ASSERT_WITH_MESSAGE(result != WAIT_FAILED, "::MsgWaitForMultipleObjectsEx failed with error %lu", ::GetLastError()); + ASSERT_WITH_MESSAGE(false, "::MsgWaitForMultipleObjectsEx returned unexpected result %lu", result); + return false; + } +} + void RunLoop::stop() { ::PostQuitMessage(0); diff --git a/Source/WebKit2/Platform/win/SharedMemoryWin.cpp b/Source/WebKit2/Platform/win/SharedMemoryWin.cpp index ef83de7..50985e7 100644 --- a/Source/WebKit2/Platform/win/SharedMemoryWin.cpp +++ b/Source/WebKit2/Platform/win/SharedMemoryWin.cpp @@ -136,8 +136,7 @@ static DWORD accessRights(SharedMemory::Protection protection) case SharedMemory::ReadOnly: return FILE_MAP_READ; case SharedMemory::ReadWrite: - // FILE_MAP_WRITE implies read access, too. - return FILE_MAP_WRITE; + return FILE_MAP_READ | FILE_MAP_WRITE; } ASSERT_NOT_REACHED(); @@ -146,23 +145,32 @@ static DWORD accessRights(SharedMemory::Protection protection) PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection) { - if (handle.isNull()) + RefPtr<SharedMemory> memory = adopt(handle.m_handle, handle.m_size, protection); + if (!memory) + return 0; + + // The SharedMemory object now owns the HANDLE. + handle.m_handle = 0; + + return memory.release(); +} + +PassRefPtr<SharedMemory> SharedMemory::adopt(HANDLE handle, size_t size, Protection protection) +{ + if (!handle) return 0; DWORD desiredAccess = accessRights(protection); - void* baseAddress = ::MapViewOfFile(handle.m_handle, desiredAccess, 0, 0, handle.m_size); + void* baseAddress = ::MapViewOfFile(handle, desiredAccess, 0, 0, size); ASSERT_WITH_MESSAGE(baseAddress, "::MapViewOfFile failed with error %lu", ::GetLastError()); if (!baseAddress) return 0; RefPtr<SharedMemory> memory = adoptRef(new SharedMemory); - memory->m_size = handle.m_size; + memory->m_size = size; memory->m_data = baseAddress; - - // Adopt the HANDLE. - memory->m_handle = handle.m_handle; - handle.m_handle = 0; + memory->m_handle = handle; return memory.release(); } diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp index 03a8aec..30223b8 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp @@ -65,12 +65,20 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, u #if PLATFORM(MAC) , m_isComplexTextInputEnabled(false) #endif + , m_windowNPObject(0) + , m_pluginElementNPObject(0) { } PluginControllerProxy::~PluginControllerProxy() { ASSERT(!m_plugin); + + if (m_windowNPObject) + releaseNPObject(m_windowNPObject); + + if (m_pluginElementNPObject) + releaseNPObject(m_pluginElementNPObject); } bool PluginControllerProxy::initialize(const Plugin::Parameters& parameters) @@ -210,28 +218,40 @@ void PluginControllerProxy::cancelManualStreamLoad() NPObject* PluginControllerProxy::windowScriptNPObject() { - uint64_t windowScriptNPObjectID = 0; + if (!m_windowNPObject) { + uint64_t windowScriptNPObjectID = 0; - if (!m_connection->connection()->sendSync(Messages::PluginProxy::GetWindowScriptNPObject(), Messages::PluginProxy::GetWindowScriptNPObject::Reply(windowScriptNPObjectID), m_pluginInstanceID)) - return 0; + if (!m_connection->connection()->sendSync(Messages::PluginProxy::GetWindowScriptNPObject(), Messages::PluginProxy::GetWindowScriptNPObject::Reply(windowScriptNPObjectID), m_pluginInstanceID)) + return 0; - if (!windowScriptNPObjectID) - return 0; + if (!windowScriptNPObjectID) + return 0; + + m_windowNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(windowScriptNPObjectID, m_plugin.get()); + ASSERT(m_windowNPObject); + } - return m_connection->npRemoteObjectMap()->createNPObjectProxy(windowScriptNPObjectID, m_plugin.get()); + retainNPObject(m_windowNPObject); + return m_windowNPObject; } NPObject* PluginControllerProxy::pluginElementNPObject() { - uint64_t pluginElementNPObjectID = 0; + if (!m_pluginElementNPObject) { + uint64_t pluginElementNPObjectID = 0; - if (!m_connection->connection()->sendSync(Messages::PluginProxy::GetPluginElementNPObject(), Messages::PluginProxy::GetPluginElementNPObject::Reply(pluginElementNPObjectID), m_pluginInstanceID)) - return 0; + if (!m_connection->connection()->sendSync(Messages::PluginProxy::GetPluginElementNPObject(), Messages::PluginProxy::GetPluginElementNPObject::Reply(pluginElementNPObjectID), m_pluginInstanceID)) + return 0; - if (!pluginElementNPObjectID) - return 0; + if (!pluginElementNPObjectID) + return 0; - return m_connection->npRemoteObjectMap()->createNPObjectProxy(pluginElementNPObjectID, m_plugin.get()); + m_pluginElementNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(pluginElementNPObjectID, m_plugin.get()); + ASSERT(m_pluginElementNPObject); + } + + retainNPObject(m_pluginElementNPObject); + return m_pluginElementNPObject; } bool PluginControllerProxy::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups) @@ -273,6 +293,7 @@ void PluginControllerProxy::pluginProcessCrashed() ASSERT_NOT_REACHED(); } +#if PLATFORM(MAC) void PluginControllerProxy::setComplexTextInputEnabled(bool complexTextInputEnabled) { if (m_isComplexTextInputEnabled == complexTextInputEnabled) @@ -287,6 +308,7 @@ mach_port_t PluginControllerProxy::compositingRenderServerPort() { return PluginProcess::shared().compositingRenderServerPort(); } +#endif String PluginControllerProxy::proxiesForURL(const String& urlString) { @@ -347,14 +369,14 @@ void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const In ASSERT(m_plugin); + platformGeometryDidChange(); + if (!backingStoreHandle.isNull()) { // Create a new backing store. m_backingStore = ShareableBitmap::create(backingStoreHandle); } m_plugin->geometryDidChange(frameRect, clipRect); - - platformGeometryDidChange(frameRect, clipRect); } void PluginControllerProxy::didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result) @@ -414,9 +436,17 @@ void PluginControllerProxy::manualStreamDidFail(bool wasCancelled) m_plugin->manualStreamDidFail(wasCancelled); } -void PluginControllerProxy::handleMouseEvent(const WebMouseEvent& mouseEvent, bool& handled) +void PluginControllerProxy::handleMouseEvent(const WebMouseEvent& mouseEvent, PassRefPtr<Messages::PluginControllerProxy::HandleMouseEvent::DelayedReply> reply) { - handled = m_plugin->handleMouseEvent(mouseEvent); + // Always let the web process think that we've handled this mouse event, even before passing it along to the plug-in. + // This is a workaround for + // <rdar://problem/9299901> UI process thinks the page is unresponsive when a plug-in is showing a context menu. + // The web process sends a synchronous HandleMouseEvent message and the plug-in process spawns a nested + // run loop when showing the context menu, so eventually the unresponsiveness timer kicks in in the UI process. + // FIXME: We should come up with a better way to do this. + reply->send(true); + + m_plugin->handleMouseEvent(mouseEvent); } void PluginControllerProxy::handleWheelEvent(const WebWheelEvent& wheelEvent, bool& handled) @@ -481,29 +511,6 @@ void PluginControllerProxy::getPluginScriptableNPObject(uint64_t& pluginScriptab releaseNPObject(pluginScriptableNPObject); } -#if PLATFORM(MAC) -void PluginControllerProxy::windowFocusChanged(bool hasFocus) -{ - m_plugin->windowFocusChanged(hasFocus); -} - -void PluginControllerProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates) -{ - m_plugin->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates); -} - -void PluginControllerProxy::windowVisibilityChanged(bool isVisible) -{ - m_plugin->windowVisibilityChanged(isVisible); -} - -void PluginControllerProxy::sendComplexTextInput(const String& textInput) -{ - m_plugin->sendComplexTextInput(textInput); -} - -#endif - void PluginControllerProxy::privateBrowsingStateChanged(bool isPrivateBrowsingEnabled) { m_plugin->privateBrowsingStateChanged(isPrivateBrowsingEnabled); diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.h b/Source/WebKit2/PluginProcess/PluginControllerProxy.h index 65be39e..a6207df 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.h +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.h @@ -31,6 +31,7 @@ #include "Connection.h" #include "Plugin.h" #include "PluginController.h" +#include "PluginControllerProxyMessages.h" #include "RunLoop.h" #include "ShareableBitmap.h" #include <wtf/Noncopyable.h> @@ -115,7 +116,7 @@ private: void manualStreamDidReceiveData(const CoreIPC::DataReference& data); void manualStreamDidFinishLoading(); void manualStreamDidFail(bool wasCancelled); - void handleMouseEvent(const WebMouseEvent&, bool& handled); + void handleMouseEvent(const WebMouseEvent&, PassRefPtr<Messages::PluginControllerProxy::HandleMouseEvent::DelayedReply>); void handleWheelEvent(const WebWheelEvent&, bool& handled); void handleMouseEnterEvent(const WebMouseEvent&, bool& handled); void handleMouseLeaveEvent(const WebMouseEvent&, bool& handled); @@ -137,7 +138,7 @@ private: void platformInitialize(); void platformDestroy(); - void platformGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect); + void platformGeometryDidChange(); WebProcessConnection* m_connection; uint64_t m_pluginInstanceID; @@ -182,6 +183,12 @@ private: // The backing store that this plug-in draws into. RefPtr<ShareableBitmap> m_backingStore; + + // The window NPObject. + NPObject* m_windowNPObject; + + // The plug-in element NPObject. + NPObject* m_pluginElementNPObject; }; } // namespace WebKit diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in b/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in index 6e27b36..349172d 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in @@ -60,7 +60,7 @@ messages -> PluginControllerProxy { ManualStreamDidFail(bool wasCancelled) # Sent when a mouse event (that isn't a mouse enter/leave event or a wheel event) should be processed. - HandleMouseEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) + HandleMouseEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) Delayed # Sent when a mouse wheel event should be processed. HandleWheelEvent(WebKit::WebWheelEvent wheelEvent) -> (bool handled) @@ -86,10 +86,10 @@ messages -> PluginControllerProxy { # Get a reference to the plug-in's scriptable NPObject. GetPluginScriptableNPObject() -> (uint64_t pluginScriptableNPObjectID) +#if PLATFORM(MAC) # Send the complex text input to the plug-in. SendComplexTextInput(WTF::String textInput) -#if PLATFORM(MAC) # Sent when the containing NSWindow's focus changes WindowFocusChanged(bool hasFocus) diff --git a/Source/WebKit2/PluginProcess/PluginProcess.cpp b/Source/WebKit2/PluginProcess/PluginProcess.cpp index e35de9d..30504a2 100644 --- a/Source/WebKit2/PluginProcess/PluginProcess.cpp +++ b/Source/WebKit2/PluginProcess/PluginProcess.cpp @@ -29,12 +29,15 @@ #if ENABLE(PLUGIN_PROCESS) #include "ArgumentCoders.h" -#include "MachPort.h" #include "NetscapePluginModule.h" #include "PluginProcessProxyMessages.h" #include "PluginProcessCreationParameters.h" #include "WebProcessConnection.h" +#if PLATFORM(MAC) +#include "MachPort.h" +#endif + namespace WebKit { static const double shutdownTimeout = 15.0; @@ -46,8 +49,8 @@ PluginProcess& PluginProcess::shared() } PluginProcess::PluginProcess() - : m_shutdownTimer(RunLoop::main(), this, &PluginProcess::shutdownTimerFired) -#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) + : ChildProcess(shutdownTimeout) +#if PLATFORM(MAC) , m_compositingRenderServerPort(MACH_PORT_NULL) #endif { @@ -78,7 +81,7 @@ void PluginProcess::removeWebProcessConnection(WebProcessConnection* webProcessC m_pluginModule->decrementLoadCount(); } - startShutdownTimerIfNecessary(); + enableTermination(); } NetscapePluginModule* PluginProcess::netscapePluginModule() @@ -98,6 +101,13 @@ NetscapePluginModule* PluginProcess::netscapePluginModule() return m_pluginModule.get(); } +bool PluginProcess::shouldTerminate() +{ + ASSERT(m_webProcessConnections.isEmpty()); + + return true; +} + void PluginProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { didReceivePluginProcessMessage(connection, messageID, arguments); @@ -114,13 +124,10 @@ void PluginProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Mess { } -NO_RETURN void PluginProcess::didFailToSendSyncMessage(CoreIPC::Connection*) +void PluginProcess::syncMessageSendTimedOut(CoreIPC::Connection*) { - // We were making a synchronous call to a web process that doesn't exist any more. - // Callers are unlikely to be prepared for an error like this, so it's best to exit immediately. - exit(0); } - + void PluginProcess::initializePluginProcess(const PluginProcessCreationParameters& parameters) { ASSERT(!m_pluginModule); @@ -132,20 +139,23 @@ void PluginProcess::initializePluginProcess(const PluginProcessCreationParameter void PluginProcess::createWebProcessConnection() { - // FIXME: This is platform specific! + bool didHaveAnyWebProcessConnections = !m_webProcessConnections.isEmpty(); +#if PLATFORM(MAC) // Create the listening port. mach_port_t listeningPort; mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort); - bool didHaveAnyWebProcessConnections = !m_webProcessConnections.isEmpty(); - // Create a listening connection. RefPtr<WebProcessConnection> connection = WebProcessConnection::create(listeningPort); m_webProcessConnections.append(connection.release()); CoreIPC::MachPort clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND); m_connection->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientPort), 0); +#else + // FIXME: Implement. + ASSERT_NOT_REACHED(); +#endif if (NetscapePluginModule* module = netscapePluginModule()) { if (!didHaveAnyWebProcessConnections) { @@ -155,23 +165,24 @@ void PluginProcess::createWebProcessConnection() } } - // Stop the shutdown timer. - m_shutdownTimer.stop(); + disableTermination(); } void PluginProcess::getSitesWithData(uint64_t callbackID) { + LocalTerminationDisabler terminationDisabler(*this); + Vector<String> sites; if (NetscapePluginModule* module = netscapePluginModule()) sites = module->sitesWithData(); m_connection->send(Messages::PluginProcessProxy::DidGetSitesWithData(sites, callbackID), 0); - - startShutdownTimerIfNecessary(); } void PluginProcess::clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID) { + LocalTerminationDisabler terminationDisabler(*this); + if (NetscapePluginModule* module = netscapePluginModule()) { if (sites.isEmpty()) { // Clear everything. @@ -183,22 +194,6 @@ void PluginProcess::clearSiteData(const Vector<String>& sites, uint64_t flags, u } m_connection->send(Messages::PluginProcessProxy::DidClearSiteData(callbackID), 0); - - startShutdownTimerIfNecessary(); -} - -void PluginProcess::startShutdownTimerIfNecessary() -{ - if (!m_webProcessConnections.isEmpty()) - return; - - // Start the shutdown timer. - m_shutdownTimer.startOneShot(shutdownTimeout); -} - -void PluginProcess::shutdownTimerFired() -{ - RunLoop::current()->stop(); } } // namespace WebKit diff --git a/Source/WebKit2/PluginProcess/PluginProcess.h b/Source/WebKit2/PluginProcess/PluginProcess.h index 83c3b30..a610326 100644 --- a/Source/WebKit2/PluginProcess/PluginProcess.h +++ b/Source/WebKit2/PluginProcess/PluginProcess.h @@ -64,11 +64,14 @@ private: PluginProcess(); ~PluginProcess(); + // ChildProcess + virtual bool shouldTerminate(); + // CoreIPC::Connection::Client virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void didFailToSendSyncMessage(CoreIPC::Connection*); + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); // Message handlers. void didReceivePluginProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); @@ -77,9 +80,6 @@ private: void getSitesWithData(uint64_t callbackID); void clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); - void startShutdownTimerIfNecessary(); - void shutdownTimerFired(); - void platformInitialize(const PluginProcessCreationParameters&); // The connection to the UI process. @@ -94,9 +94,6 @@ private: // The plug-in module. RefPtr<NetscapePluginModule> m_pluginModule; - // A timer used for the shutdown timeout. - RunLoop::Timer<PluginProcess> m_shutdownTimer; - #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) // The Mach port used for accelerated compositing. mach_port_t m_compositingRenderServerPort; diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp index 56ffbb9..24e2027 100644 --- a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp +++ b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp @@ -157,6 +157,10 @@ void WebProcessConnection::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIP // FIXME: Implement. } +void WebProcessConnection::syncMessageSendTimedOut(CoreIPC::Connection*) +{ +} + void WebProcessConnection::createPlugin(uint64_t pluginInstanceID, const Plugin::Parameters& parameters, const String& userAgent, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled, bool& result, uint32_t& remoteLayerClientID) { OwnPtr<PluginControllerProxy> pluginControllerProxy = PluginControllerProxy::create(this, pluginInstanceID, userAgent, isPrivateBrowsingEnabled, isAcceleratedCompositingEnabled); @@ -173,7 +177,9 @@ void WebProcessConnection::createPlugin(uint64_t pluginInstanceID, const Plugin: if (!result) return; +#if PLATFORM(MAC) remoteLayerClientID = pluginControllerProxyPtr->remoteLayerClientID(); +#endif } } // namespace WebKit diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.h b/Source/WebKit2/PluginProcess/WebProcessConnection.h index 83fe0fe..57ad82b 100644 --- a/Source/WebKit2/PluginProcess/WebProcessConnection.h +++ b/Source/WebKit2/PluginProcess/WebProcessConnection.h @@ -61,6 +61,7 @@ private: virtual CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); // Message handlers. CoreIPC::SyncReplyMode didReceiveSyncWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); diff --git a/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm b/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm index 610ca32..347d026 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm @@ -67,17 +67,37 @@ uint32_t PluginControllerProxy::remoteLayerClientID() const return WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); } -void PluginControllerProxy::platformGeometryDidChange(const IntRect& frameRect, const IntRect&) +void PluginControllerProxy::platformGeometryDidChange() { CALayer * pluginLayer = m_plugin->pluginLayer(); // We don't want to animate to the new size so we disable actions for this transaction. [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions]; - [pluginLayer setFrame:CGRectMake(0, 0, frameRect.width(), frameRect.height())]; + [pluginLayer setFrame:CGRectMake(0, 0, m_frameRect.width(), m_frameRect.height())]; [CATransaction commit]; } +void PluginControllerProxy::windowFocusChanged(bool hasFocus) +{ + m_plugin->windowFocusChanged(hasFocus); +} + +void PluginControllerProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates) +{ + m_plugin->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates); +} + +void PluginControllerProxy::windowVisibilityChanged(bool isVisible) +{ + m_plugin->windowVisibilityChanged(isVisible); +} + +void PluginControllerProxy::sendComplexTextInput(const String& textInput) +{ + m_plugin->sendComplexTextInput(textInput); +} + } // namespace WebKit #endif // ENABLE(PLUGIN_PROCESS) diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm index 3a3586a..d509d49 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm @@ -219,7 +219,7 @@ void PluginProcess::platformInitialize(const PluginProcessCreationParameters& pa { m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port(); - NSString *applicationName = [NSString stringWithFormat:UI_STRING("%@ (%@ Internet plug-in)", + NSString *applicationName = [NSString stringWithFormat:WEB_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], diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm index 6a32727..d01a24f 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm @@ -121,32 +121,6 @@ static void shimHideWindow(WindowRef window) HideWindow(window); } -static bool isMenuBarVisible = true; - -static void shimShowMenuBar(void) -{ - isMenuBarVisible = true; - - ShowMenuBar(); -} - -static void shimHideMenuBar(void) -{ - isMenuBarVisible = false; - - // Make sure to make ourselves the front process - ProcessSerialNumber psn; - GetCurrentProcess(&psn); - SetFrontProcess(&psn); - - HideMenuBar(); -} - -static Boolean shimIsMenuBarVisible(void) -{ - return isMenuBarVisible; -} - DYLD_INTERPOSE(shimDebugger, Debugger); DYLD_INTERPOSE(shimGetCurrentEventButtonState, GetCurrentEventButtonState); DYLD_INTERPOSE(shimIsWindowActive, IsWindowActive); @@ -154,9 +128,6 @@ DYLD_INTERPOSE(shimModalDialog, ModalDialog); DYLD_INTERPOSE(shimAlert, Alert); DYLD_INTERPOSE(shimShowWindow, ShowWindow); DYLD_INTERPOSE(shimHideWindow, HideWindow); -DYLD_INTERPOSE(shimShowMenuBar, ShowMenuBar) -DYLD_INTERPOSE(shimHideMenuBar, HideMenuBar) -DYLD_INTERPOSE(shimIsMenuBarVisible, IsMenuBarVisible); #endif diff --git a/Source/WebKit2/Scripts/webkit2/messages.py b/Source/WebKit2/Scripts/webkit2/messages.py index 159ca32..433658d 100644 --- a/Source/WebKit2/Scripts/webkit2/messages.py +++ b/Source/WebKit2/Scripts/webkit2/messages.py @@ -81,9 +81,9 @@ class MessageReceiver(object): elif line.startswith('#endif'): condition = None continue - match = re.search(r'([A-Za-z_0-9]+)\((.*?)\)(?:(?:\s+->\s+)\((.*?)\)(?:\s+(delayed))?)?', line) + match = re.search(r'([A-Za-z_0-9]+)\((.*?)\)(?:(?:\s+->\s+)\((.*?)\)(?:\s+(.*))?)?', line) if match: - name, parameters_string, reply_parameters_string, delayed_string = match.groups() + name, parameters_string, reply_parameters_string, attributes_string = match.groups() if parameters_string: parameters = parse_parameter_string(parameters_string) else: @@ -92,7 +92,13 @@ class MessageReceiver(object): for parameter in parameters: parameter.condition = condition - delayed = delayed_string == 'delayed' + if attributes_string: + attributes = frozenset(attributes_string.split()) + is_delayed = "Delayed" in attributes + dispatch_on_connection_queue = "DispatchOnConnectionQueue" in attributes + else: + is_delayed = False + dispatch_on_connection_queue = False if reply_parameters_string: reply_parameters = parse_parameter_string(reply_parameters_string) @@ -101,17 +107,18 @@ class MessageReceiver(object): else: reply_parameters = None - messages.append(Message(name, parameters, reply_parameters, delayed, condition)) + messages.append(Message(name, parameters, reply_parameters, is_delayed, dispatch_on_connection_queue, condition)) return MessageReceiver(destination, messages, master_condition) class Message(object): - def __init__(self, name, parameters, reply_parameters, delayed, condition): + def __init__(self, name, parameters, reply_parameters, is_delayed, dispatch_on_connection_queue, condition): self.name = name self.parameters = parameters self.reply_parameters = reply_parameters if self.reply_parameters is not None: - self.delayed = delayed + self.is_delayed = is_delayed + self.dispatch_on_connection_queue = dispatch_on_connection_queue self.condition = condition if len(self.parameters) != 0: self.is_variadic = parameter_type_is_variadic(self.parameters[-1].type) @@ -217,30 +224,20 @@ def message_to_struct_declaration(message): result.append(' {\n') result.append(' static const Kind messageID = %s;\n' % message.id()) if message.reply_parameters != None: - if message.delayed: + if message.is_delayed: send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters] - result.append(' struct DelayedReply {\n') - result.append(' DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentDecoder> arguments)\n') - result.append(' : m_connection(connection)\n') - result.append(' , m_arguments(arguments)\n') - result.append(' {\n') - result.append(' }\n') + result.append(' struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {\n') + result.append(' DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>);\n') + result.append(' ~DelayedReply();\n') result.append('\n') - result.append(' bool send(%s)\n' % ', '.join([' '.join(x) for x in send_parameters])) - result.append(' {\n') - result.append(' ASSERT(m_arguments);\n') - result += [' m_arguments->encode(%s);\n' % x.name for x in message.reply_parameters] - result.append(' bool result = m_connection->sendSyncReply(m_arguments.release());\n') - result.append(' m_connection = nullptr;\n') - result.append(' return result;\n') - result.append(' }\n') + result.append(' bool send(%s);\n' % ', '.join([' '.join(x) for x in send_parameters])) result.append('\n') result.append(' private:\n') result.append(' RefPtr<CoreIPC::Connection> m_connection;\n') - result.append(' OwnPtr<CoreIPC::ArgumentDecoder> m_arguments;\n') + result.append(' OwnPtr<CoreIPC::ArgumentEncoder> m_arguments;\n') result.append(' };\n\n') - else: - result.append(' typedef %s Reply;\n' % reply_type(message)) + + result.append(' typedef %s Reply;\n' % reply_type(message)) result.append(' typedef %s DecodeType;\n' % decode_type(message)) if len(function_parameters): @@ -254,6 +251,7 @@ def message_to_struct_declaration(message): def struct_or_class(namespace, type): structs = frozenset([ + 'WebCore::EditorCommandsForKeyEvent', 'WebCore::CompositionUnderline', 'WebCore::GrammarDetail', 'WebCore::KeypressCommand', @@ -261,14 +259,15 @@ def struct_or_class(namespace, type): 'WebCore::PrintInfo', 'WebCore::ViewportArguments', 'WebCore::WindowFeatures', + 'WebKit::AttributedString', 'WebKit::ContextMenuState', 'WebKit::DictionaryPopupInfo', 'WebKit::DrawingAreaInfo', + 'WebKit::EditorState', 'WebKit::PlatformPopupMenuData', 'WebKit::PluginProcessCreationParameters', 'WebKit::PrintInfo', 'WebKit::SecurityOriginData', - 'WebKit::SelectionState', 'WebKit::TextCheckerState', 'WebKit::WebNavigationDataStore', 'WebKit::WebOpenPanelParameters::Data', @@ -299,6 +298,11 @@ def forward_declarations_and_headers(receiver): '"MessageID.h"', ]) + for message in receiver.messages: + if message.reply_parameters != None and message.is_delayed: + headers.add('<wtf/ThreadSafeRefCounted.h>') + types_by_namespace['CoreIPC'].update(['ArgumentEncoder', 'Connection']) + for parameter in receiver.iterparameters(): type = parameter.type @@ -385,14 +389,20 @@ def async_case_statement(receiver, message): def sync_case_statement(receiver, message): dispatch_function = 'handleMessage' + if message.is_delayed: + dispatch_function += 'Delayed' if message.is_variadic: dispatch_function += 'Variadic' result = [] result.append(' case Messages::%s::%s:\n' % (receiver.name, message.id())) - result.append(' CoreIPC::%s<Messages::%s::%s>(arguments, reply, this, &%s);\n' % (dispatch_function, receiver.name, message.name, handler_function(receiver, message))) - # FIXME: Handle delayed replies - result.append(' return CoreIPC::AutomaticReply;\n') + result.append(' CoreIPC::%s<Messages::%s::%s>(%sarguments, reply, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if message.is_delayed else '', handler_function(receiver, message))) + + if message.is_delayed: + result.append(' return CoreIPC::ManualReply;\n') + else: + result.append(' return CoreIPC::AutomaticReply;\n') + return surround_in_condition(''.join(result), message.condition) @@ -431,6 +441,7 @@ def headers_for_type(type): special_cases = { 'WTF::String': '<wtf/text/WTFString.h>', 'WebCore::CompositionUnderline': '<WebCore/Editor.h>', + 'WebCore::GrammarDetail': '<WebCore/TextCheckerClient.h>', 'WebCore::KeypressCommand': '<WebCore/KeyboardEvent.h>', 'WebCore::PluginInfo': '<WebCore/PluginData.h>', 'WebCore::TextCheckingResult': '<WebCore/TextCheckerClient.h>', @@ -518,6 +529,46 @@ def generate_message_handler(file): result += ['#include %s\n' % headercondition] result.append('\n') + sync_delayed_messages = [] + for message in receiver.messages: + if message.reply_parameters != None and message.is_delayed: + sync_delayed_messages.append(message) + + if sync_delayed_messages: + result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name) + + for message in sync_delayed_messages: + send_parameters = [(function_parameter_type(x.type), x.name) for x in message.reply_parameters] + + if message.condition: + result.append('#if %s\n\n' % message.condition) + + result.append('%s::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments)\n' % message.name) + result.append(' : m_connection(connection)\n') + result.append(' , m_arguments(arguments)\n') + result.append('{\n') + result.append('}\n') + result.append('\n') + result.append('%s::DelayedReply::~DelayedReply()\n' % message.name) + result.append('{\n') + result.append(' ASSERT(!m_connection);\n') + result.append('}\n') + result.append('\n') + result.append('bool %s::DelayedReply::send(%s)\n' % (message.name, ', '.join([' '.join(x) for x in send_parameters]))) + result.append('{\n') + result.append(' ASSERT(m_arguments);\n') + result += [' m_arguments->encode(%s);\n' % x.name for x in message.reply_parameters] + result.append(' bool result = m_connection->sendSyncReply(m_arguments.release());\n') + result.append(' m_connection = nullptr;\n') + result.append(' return result;\n') + result.append('}\n') + result.append('\n') + + if message.condition: + result.append('#endif\n\n') + + result.append('} // namespace %s\n\n} // namespace Messages\n\n' % receiver.name) + result.append('namespace WebKit {\n\n') async_messages = [] @@ -541,7 +592,7 @@ def generate_message_handler(file): if sync_messages: result.append('\n') - result.append('CoreIPC::SyncReplyMode %s::didReceiveSync%sMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)\n' % (receiver.name, receiver.name)) + result.append('CoreIPC::SyncReplyMode %s::didReceiveSync%sMessage(CoreIPC::Connection*%s, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)\n' % (receiver.name, receiver.name, ' connection' if sync_delayed_messages else '')) result.append('{\n') result.append(' switch (messageID.get<Messages::%s::Kind>()) {\n' % receiver.name) result += [sync_case_statement(receiver, message) for message in sync_messages] diff --git a/Source/WebKit2/Scripts/webkit2/messages_unittest.py b/Source/WebKit2/Scripts/webkit2/messages_unittest.py index 90d59ae..2fc5763 100644 --- a/Source/WebKit2/Scripts/webkit2/messages_unittest.py +++ b/Source/WebKit2/Scripts/webkit2/messages_unittest.py @@ -65,8 +65,10 @@ messages -> WebPage { CreatePlugin(uint64_t pluginInstanceID, WebKit::Plugin::Parameters parameters) -> (bool result) RunJavaScriptAlert(uint64_t frameID, WTF::String message) -> () - GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins) - GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::Connection::Handle connectionHandle) delayed + GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins) DispatchOnConnectionQueue + GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::Connection::Handle connectionHandle) Delayed + + TestMultipleAttributes() -> () DispatchOnConnectionQueue Delayed #if PLATFORM(MAC) DidCreateWebProcessConnection(CoreIPC::MachPort connectionIdentifier) @@ -177,6 +179,14 @@ _expected_results = { 'condition': None, }, { + 'name': 'TestMultipleAttributes', + 'parameters': ( + ), + 'reply_parameters': ( + ), + 'condition': None, + }, + { 'name': 'DidCreateWebProcessConnection', 'parameters': ( ('CoreIPC::MachPort', 'connectionIdentifier'), @@ -260,9 +270,12 @@ _expected_header = """/* #include "Plugin.h" #include <WebCore/KeyboardEvent.h> #include <WebCore/PluginData.h> +#include <wtf/ThreadSafeRefCounted.h> #include <wtf/Vector.h> namespace CoreIPC { + class ArgumentEncoder; + class Connection; class MachPort; } @@ -293,6 +306,7 @@ enum Kind { RunJavaScriptAlertID, GetPluginsID, GetPluginProcessConnectionID, + TestMultipleAttributesID, #if PLATFORM(MAC) DidCreateWebProcessConnectionID, #endif @@ -394,27 +408,18 @@ struct GetPlugins : CoreIPC::Arguments1<bool> { struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> { static const Kind messageID = GetPluginProcessConnectionID; - struct DelayedReply { - DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentDecoder> arguments) - : m_connection(connection) - , m_arguments(arguments) - { - } + struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { + DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>); + ~DelayedReply(); - bool send(const CoreIPC::Connection::Handle& connectionHandle) - { - ASSERT(m_arguments); - m_arguments->encode(connectionHandle); - bool result = m_connection->sendSyncReply(m_arguments.release()); - m_connection = nullptr; - return result; - } + bool send(const CoreIPC::Connection::Handle& connectionHandle); private: RefPtr<CoreIPC::Connection> m_connection; - OwnPtr<CoreIPC::ArgumentDecoder> m_arguments; + OwnPtr<CoreIPC::ArgumentEncoder> m_arguments; }; + typedef CoreIPC::Arguments1<CoreIPC::Connection::Handle&> Reply; typedef CoreIPC::Arguments1<const WTF::String&> DecodeType; explicit GetPluginProcessConnection(const WTF::String& pluginPath) : CoreIPC::Arguments1<const WTF::String&>(pluginPath) @@ -422,6 +427,23 @@ struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> { } }; +struct TestMultipleAttributes : CoreIPC::Arguments0 { + static const Kind messageID = TestMultipleAttributesID; + struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> { + DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>); + ~DelayedReply(); + + bool send(); + + private: + RefPtr<CoreIPC::Connection> m_connection; + OwnPtr<CoreIPC::ArgumentEncoder> m_arguments; + }; + + typedef CoreIPC::Arguments0 Reply; + typedef CoreIPC::Arguments0 DecodeType; +}; + #if PLATFORM(MAC) struct DidCreateWebProcessConnection : CoreIPC::Arguments1<const CoreIPC::MachPort&> { static const Kind messageID = DidCreateWebProcessConnectionID; @@ -511,6 +533,53 @@ _expected_receiver_implementation = """/* #include "WebPageMessages.h" #include "WebPreferencesStore.h" +namespace Messages { + +namespace WebPage { + +GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments) + : m_connection(connection) + , m_arguments(arguments) +{ +} + +GetPluginProcessConnection::DelayedReply::~DelayedReply() +{ + ASSERT(!m_connection); +} + +bool GetPluginProcessConnection::DelayedReply::send(const CoreIPC::Connection::Handle& connectionHandle) +{ + ASSERT(m_arguments); + m_arguments->encode(connectionHandle); + bool result = m_connection->sendSyncReply(m_arguments.release()); + m_connection = nullptr; + return result; +} + +TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments) + : m_connection(connection) + , m_arguments(arguments) +{ +} + +TestMultipleAttributes::DelayedReply::~DelayedReply() +{ + ASSERT(!m_connection); +} + +bool TestMultipleAttributes::DelayedReply::send() +{ + ASSERT(m_arguments); + bool result = m_connection->sendSyncReply(m_arguments.release()); + m_connection = nullptr; + return result; +} + +} // namespace WebPage + +} // namespace Messages + namespace WebKit { void WebPage::didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) @@ -551,7 +620,7 @@ void WebPage::didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID ASSERT_NOT_REACHED(); } -CoreIPC::SyncReplyMode WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply) +CoreIPC::SyncReplyMode WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply) { switch (messageID.get<Messages::WebPage::Kind>()) { case Messages::WebPage::CreatePluginID: @@ -564,8 +633,11 @@ CoreIPC::SyncReplyMode WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection CoreIPC::handleMessage<Messages::WebPage::GetPlugins>(arguments, reply, this, &WebPage::getPlugins); return CoreIPC::AutomaticReply; case Messages::WebPage::GetPluginProcessConnectionID: - CoreIPC::handleMessage<Messages::WebPage::GetPluginProcessConnection>(arguments, reply, this, &WebPage::getPluginProcessConnection); - return CoreIPC::AutomaticReply; + CoreIPC::handleMessageDelayed<Messages::WebPage::GetPluginProcessConnection>(connection, arguments, reply, this, &WebPage::getPluginProcessConnection); + return CoreIPC::ManualReply; + case Messages::WebPage::TestMultipleAttributesID: + CoreIPC::handleMessageDelayed<Messages::WebPage::TestMultipleAttributes>(connection, arguments, reply, this, &WebPage::testMultipleAttributes); + return CoreIPC::ManualReply; #if PLATFORM(MAC) case Messages::WebPage::InterpretKeyEventID: CoreIPC::handleMessage<Messages::WebPage::InterpretKeyEvent>(arguments, reply, this, &WebPage::interpretKeyEvent); diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h index 95fc048..3f73d7a 100644 --- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h @@ -36,7 +36,7 @@ extern "C" { WK_EXPORT WKTypeID WKSerializedScriptValueGetTypeID(); WK_EXPORT WKSerializedScriptValueRef WKSerializedScriptValueCreate(JSContextRef context, JSValueRef value, JSValueRef* exception); -WK_EXPORT JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValue, JSContextRef constext, JSValueRef* exception); +WK_EXPORT JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValue, JSContextRef context, JSValueRef* exception); #ifdef __cplusplus } diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp index 0c388c6..cbac67d 100644 --- a/Source/WebKit2/Shared/API/c/WKString.cpp +++ b/Source/WebKit2/Shared/API/c/WKString.cpp @@ -47,6 +47,17 @@ bool WKStringIsEmpty(WKStringRef stringRef) return toImpl(stringRef)->isEmpty(); } +size_t WKStringGetLength(WKStringRef stringRef) +{ + return toImpl(stringRef)->length(); +} + +size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t bufferLength) +{ + COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharacters_sizeof_WKChar_matches_UChar); + return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer), bufferLength)); +} + size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef) { return toImpl(stringRef)->maximumUTF8CStringSize(); diff --git a/Source/WebKit2/Shared/API/c/WKString.h b/Source/WebKit2/Shared/API/c/WKString.h index dffcab2..d1bc1ef 100644 --- a/Source/WebKit2/Shared/API/c/WKString.h +++ b/Source/WebKit2/Shared/API/c/WKString.h @@ -36,12 +36,22 @@ extern "C" { #endif +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WINSCW__) \ + && !((defined(__CC_ARM) || defined(__ARMCC__)) && !defined(__linux__)) /* RVCT */ + typedef unsigned short WKChar; +#else + typedef wchar_t WKChar; +#endif + WK_EXPORT WKTypeID WKStringGetTypeID(); WK_EXPORT WKStringRef WKStringCreateWithUTF8CString(const char* string); WK_EXPORT bool WKStringIsEmpty(WKStringRef string); +WK_EXPORT size_t WKStringGetLength(WKStringRef string); +WK_EXPORT size_t WKStringGetCharacters(WKStringRef string, WKChar* buffer, size_t bufferLength); + WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string); WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize); diff --git a/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h b/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h index 8f34ed3..eb88f70 100644 --- a/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h +++ b/Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h @@ -32,6 +32,8 @@ #error "Please #include \"WKBase.h\" instead of this file directly." #endif +#include <stdbool.h> + typedef const struct OpaqueWKView* WKViewRef; #endif /* WKBaseGtk_h */ diff --git a/Source/WebKit2/Shared/API/c/win/WKBaseWin.h b/Source/WebKit2/Shared/API/c/win/WKBaseWin.h index fdd4607..d9c13e3 100644 --- a/Source/WebKit2/Shared/API/c/win/WKBaseWin.h +++ b/Source/WebKit2/Shared/API/c/win/WKBaseWin.h @@ -32,5 +32,7 @@ typedef const struct OpaqueWKView* WKViewRef; typedef const struct OpaqueWKEditCommand* WKEditCommandRef; +typedef const struct OpaqueWKTextChecker* WKTextCheckerRef; +typedef const struct OpaqueWKGrammarDetail* WKGrammarDetailRef; #endif /* WKBaseWin_h */ diff --git a/Source/WebKit2/Shared/APIObject.h b/Source/WebKit2/Shared/APIObject.h index 7f50b51..e5a7eed 100644 --- a/Source/WebKit2/Shared/APIObject.h +++ b/Source/WebKit2/Shared/APIObject.h @@ -104,8 +104,10 @@ public: TypeBundleScriptWorld, // Platform specific - TypeView, - TypeEditCommandProxy + TypeEditCommandProxy, + TypeGrammarDetail, + TypeTextChecker, + TypeView }; virtual ~APIObject() diff --git a/Source/WebKit2/Shared/ChildProcess.cpp b/Source/WebKit2/Shared/ChildProcess.cpp index d45f4f2..e700caa 100644 --- a/Source/WebKit2/Shared/ChildProcess.cpp +++ b/Source/WebKit2/Shared/ChildProcess.cpp @@ -32,14 +32,54 @@ namespace WebKit { -ChildProcess::ChildProcess() +void ChildProcess::disableTermination() { + m_terminationCounter++; + m_terminationTimer.stop(); +} + +void ChildProcess::enableTermination() +{ + ASSERT(m_terminationCounter > 0); + m_terminationCounter--; + + if (m_terminationCounter) + return; + + if (!m_terminationTimeout) { + terminationTimerFired(); + return; + } + + m_terminationTimer.startOneShot(m_terminationTimeout); +} + +ChildProcess::ChildProcess(double terminationTimeout) + : m_terminationTimeout(terminationTimeout) + , m_terminationCounter(0) + , m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired) +{ + // FIXME: The termination timer should not be scheduled on the main run loop. + // It won't work with the threaded mode, but it's not really useful anyway as is. } ChildProcess::~ChildProcess() { } +void ChildProcess::terminationTimerFired() +{ + if (!shouldTerminate()) + return; + + terminate(); +} + +void ChildProcess::terminate() +{ + RunLoop::main()->stop(); +} + NO_RETURN static void watchdogCallback() { // We use _exit here since the watchdog callback is called from another thread and we don't want diff --git a/Source/WebKit2/Shared/ChildProcess.h b/Source/WebKit2/Shared/ChildProcess.h index 7286d52..0c66a9d 100644 --- a/Source/WebKit2/Shared/ChildProcess.h +++ b/Source/WebKit2/Shared/ChildProcess.h @@ -27,16 +27,57 @@ #define ChildProcess_h #include "Connection.h" +#include "RunLoop.h" namespace WebKit { class ChildProcess : protected CoreIPC::Connection::Client { WTF_MAKE_NONCOPYABLE(ChildProcess); + +public: + // disable and enable termination of the process. when disableTermination is called, the + // process won't terminate unless a corresponding disableTermination call is made. + void disableTermination(); + void enableTermination(); + + class LocalTerminationDisabler { + public: + explicit LocalTerminationDisabler(ChildProcess& childProcess) + : m_childProcess(childProcess) + { + m_childProcess.disableTermination(); + } + + ~LocalTerminationDisabler() + { + m_childProcess.enableTermination(); + } + + private: + ChildProcess& m_childProcess; + }; + protected: - ChildProcess(); + explicit ChildProcess(double terminationTimeout); ~ChildProcess(); static void didCloseOnConnectionWorkQueue(WorkQueue&, CoreIPC::Connection*); + +private: + void terminationTimerFired(); + + virtual bool shouldTerminate() = 0; + virtual void terminate(); + + // The timeout, in seconds, before this process will be terminated if termination + // has been enabled. If the timeout is 0 seconds, the process will be terminated immediately. + double m_terminationTimeout; + + // A termination counter; when the counter reaches zero, the process will be terminated + // after a given period of time. + unsigned m_terminationCounter; + + RunLoop::Timer<ChildProcess> m_terminationTimer; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/DictionaryPopupInfo.cpp b/Source/WebKit2/Shared/DictionaryPopupInfo.cpp index 45bf91d..e24a138 100644 --- a/Source/WebKit2/Shared/DictionaryPopupInfo.cpp +++ b/Source/WebKit2/Shared/DictionaryPopupInfo.cpp @@ -40,7 +40,7 @@ void DictionaryPopupInfo::encode(CoreIPC::ArgumentEncoder* encoder) const encoder->encode(fontInfo); encoder->encodeEnum(type); -#if PLATFORM(MAC) +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) CoreIPC::encode(encoder, options.get()); #endif } @@ -53,7 +53,7 @@ bool DictionaryPopupInfo::decode(CoreIPC::ArgumentDecoder* decoder, DictionaryPo return false; if (!decoder->decodeEnum(result.type)) return false; -#if PLATFORM(MAC) +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) if (!CoreIPC::decode(decoder, result.options)) return false; #endif diff --git a/Source/WebKit2/Shared/DictionaryPopupInfo.h b/Source/WebKit2/Shared/DictionaryPopupInfo.h index 68c81a7..3814ece 100644 --- a/Source/WebKit2/Shared/DictionaryPopupInfo.h +++ b/Source/WebKit2/Shared/DictionaryPopupInfo.h @@ -52,7 +52,7 @@ struct DictionaryPopupInfo { WebCore::FloatPoint origin; FontInfo fontInfo; Type type; -#if PLATFORM(MAC) +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) RetainPtr<CFDictionaryRef> options; #endif }; diff --git a/Source/WebKit2/Shared/SelectionState.h b/Source/WebKit2/Shared/EditorState.h index 9931a10..1e8bcb8 100644 --- a/Source/WebKit2/Shared/SelectionState.h +++ b/Source/WebKit2/Shared/EditorState.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 @@ -23,52 +23,37 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SelectionState_h -#define SelectionState_h +#ifndef EditorState_h +#define EditorState_h #include "ArgumentCoders.h" #include <wtf/NotFound.h> namespace WebKit { -struct SelectionState { - SelectionState() - : isNone(true) +struct EditorState { + EditorState() + : selectionIsNone(true) + , selectionIsRange(false) , isContentEditable(false) , isContentRichlyEditable(false) , isInPasswordField(false) , hasComposition(false) - , selectedRangeStart(notFound) - , selectedRangeLength(0) { } - // Whether there is a selection at all. This will be false when there is a caret selection. - bool isNone; - - // Whether the selection is in a content editable area. + bool selectionIsNone; // This will be false when there is a caret selection. + bool selectionIsRange; bool isContentEditable; - - // Whether the selection is in a rich content editable area. bool isContentRichlyEditable; - - // Whether the selection is in a password field. bool isInPasswordField; - - // Whether the selection has a composition. bool hasComposition; - - // The start of the selected range. - uint64_t selectedRangeStart; - - // The length of the selected range. - uint64_t selectedRangeLength; }; -} // namespace WebKit +} namespace CoreIPC { -template<> struct ArgumentCoder<WebKit::SelectionState> : SimpleArgumentCoder<WebKit::SelectionState> { }; +template<> struct ArgumentCoder<WebKit::EditorState> : SimpleArgumentCoder<WebKit::EditorState> { }; }; -#endif // SelectionState_h +#endif // EditorState_h diff --git a/Source/WebKit2/Shared/NativeWebMouseEvent.h b/Source/WebKit2/Shared/NativeWebMouseEvent.h new file mode 100644 index 0000000..01b8502 --- /dev/null +++ b/Source/WebKit2/Shared/NativeWebMouseEvent.h @@ -0,0 +1,78 @@ +/* + * 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 NativeWebMouseEvent_h +#define NativeWebMouseEvent_h + +#include "WebEvent.h" + +#if PLATFORM(MAC) +#include <wtf/RetainPtr.h> +OBJC_CLASS NSView; +#elif PLATFORM(QT) +#include <qgraphicssceneevent.h> +#elif PLATFORM(GTK) +typedef union _GdkEvent GdkEvent; +#endif + +namespace WebKit { + +class NativeWebMouseEvent : public WebMouseEvent { +public: +#if PLATFORM(MAC) + NativeWebMouseEvent(NSEvent *, NSView *); +#elif PLATFORM(WIN) + NativeWebMouseEvent(HWND, UINT message, WPARAM, LPARAM, bool); +#elif PLATFORM(QT) + explicit NativeWebMouseEvent(QGraphicsSceneMouseEvent*, int); +#elif PLATFORM(GTK) + NativeWebMouseEvent(GdkEvent*, int); +#endif + +#if PLATFORM(MAC) + NSEvent* nativeEvent() const { return m_nativeEvent.get(); } +#elif PLATFORM(WIN) + const MSG* nativeEvent() const { return &m_nativeEvent; } +#elif PLATFORM(QT) + const QGraphicsSceneMouseEvent* nativeEvent() const { return m_nativeEvent; } +#elif PLATFORM(GTK) + GdkEvent* nativeEvent() const { return m_nativeEvent; } +#endif + +private: +#if PLATFORM(MAC) + RetainPtr<NSEvent> m_nativeEvent; +#elif PLATFORM(WIN) + MSG m_nativeEvent; +#elif PLATFORM(QT) + QGraphicsSceneMouseEvent* m_nativeEvent; +#elif PLATFORM(GTK) + GdkEvent* m_nativeEvent; +#endif +}; + +} // namespace WebKit + +#endif // NativeWebMouseEvent_h diff --git a/Source/WebKit2/Shared/PlatformPopupMenuData.cpp b/Source/WebKit2/Shared/PlatformPopupMenuData.cpp index 1f56daf..6c4d20e 100644 --- a/Source/WebKit2/Shared/PlatformPopupMenuData.cpp +++ b/Source/WebKit2/Shared/PlatformPopupMenuData.cpp @@ -61,6 +61,7 @@ void PlatformPopupMenuData::encode(CoreIPC::ArgumentEncoder* encoder) const encoder->encode(selectedBackingStoreHandle); #elif PLATFORM(MAC) encoder->encode(fontInfo); + encoder->encode(shouldPopOver); #endif } @@ -92,6 +93,8 @@ bool PlatformPopupMenuData::decode(CoreIPC::ArgumentDecoder* decoder, PlatformPo #elif PLATFORM(MAC) if (!decoder->decode(data.fontInfo)) return false; + if (!decoder->decode(data.shouldPopOver)) + return false; #endif return true; diff --git a/Source/WebKit2/Shared/PlatformPopupMenuData.h b/Source/WebKit2/Shared/PlatformPopupMenuData.h index 5b3f58d..f85008a 100644 --- a/Source/WebKit2/Shared/PlatformPopupMenuData.h +++ b/Source/WebKit2/Shared/PlatformPopupMenuData.h @@ -54,6 +54,7 @@ struct PlatformPopupMenuData { RefPtr<ShareableBitmap> m_selectedBackingStore; #elif PLATFORM(MAC) FontInfo fontInfo; + bool shouldPopOver; #endif }; diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp index 54af967..c5c0a90 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp @@ -32,10 +32,6 @@ #include <wtf/PassOwnPtr.h> #include <wtf/text/CString.h> -#if !PLUGIN_ARCHITECTURE(MAC) && !PLUGIN_ARCHITECTURE(WIN) && !PLUGIN_ARCHITECTURE(X11) -#error Unknown plug-in architecture -#endif - namespace WebKit { static Vector<NetscapePluginModule*>& initializedNetscapePluginModules() @@ -88,6 +84,11 @@ bool NetscapePluginModule::tryGetSitesWithData(Vector<String>& sites) return false; char** siteArray = m_pluginFuncs.getsiteswithdata(); + + // There were no sites with data. + if (!siteArray) + return true; + for (int i = 0; siteArray[i]; ++i) { char* site = siteArray[i]; diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp new file mode 100644 index 0000000..dc4a37c --- /dev/null +++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#if PLUGIN_ARCHITECTURE(UNSUPPORTED) + +#include "NetscapePluginModule.h" + +using namespace WebCore; + +namespace WebKit { + +bool NetscapePluginModule::getPluginInfo(const String&, PluginInfoStore::Plugin&) +{ + return false; +} + +void NetscapePluginModule::determineQuirks() +{ +} + +} // namespace WebKit + +#endif diff --git a/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm b/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm index d290f5b..6a867a0 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm +++ b/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm @@ -273,22 +273,19 @@ static bool getPluginInfoFromCarbonResources(CFBundleRef bundle, PluginInfo& plu if (mimeTypesAndExtensions.size() % 2) return false; - size_t numMimeTypes = mimeTypesAndExtensions.size() / 2; - // Now get the MIME type descriptions string list. This string list needs to be the same length as the number of MIME types. Vector<String> mimeTypeDescriptions; if (!getStringListResource(MIMEDescriptionStringNumber, mimeTypeDescriptions)) return false; - if (mimeTypeDescriptions.size() != numMimeTypes) - return false; - // Add all MIME types. for (size_t i = 0; i < mimeTypesAndExtensions.size() / 2; ++i) { MimeClassInfo mimeClassInfo; const String& mimeType = mimeTypesAndExtensions[i * 2]; - const String& description = mimeTypeDescriptions[i]; + String description; + if (i < mimeTypeDescriptions.size()) + description = mimeTypeDescriptions[i]; mimeClassInfo.type = mimeType.lower(); mimeClassInfo.desc = description; diff --git a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp index 76ecda7..2c9b465 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp @@ -24,6 +24,8 @@ */ #include "config.h" +#if PLUGIN_ARCHITECTURE(X11) + #include "NetscapePluginModule.h" #include "PluginDatabase.h" @@ -98,3 +100,5 @@ void NetscapePluginModule::determineQuirks() } } // namespace WebKit + +#endif // PLUGIN_ARCHITECTURE(X11) diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp index 06014a9..c6c87a6 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp @@ -46,7 +46,7 @@ void PluginProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) #endif } -bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, PluginProcessCreationParameters::PluginProcessCreationParameters& result) +bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, PluginProcessCreationParameters& result) { if (!decoder->decode(result.pluginPath)) return false; diff --git a/Source/WebKit2/Shared/Plugins/PluginQuirks.h b/Source/WebKit2/Shared/Plugins/PluginQuirks.h index ea4643b..1ea38cd 100644 --- a/Source/WebKit2/Shared/Plugins/PluginQuirks.h +++ b/Source/WebKit2/Shared/Plugins/PluginQuirks.h @@ -49,7 +49,7 @@ public: MakeTransparentIfBackgroundAttributeExists, #ifndef NP_NO_QUICKDRAW - // Allow the plug-in to use the QuickDraw drawing model, since wek now that the plug-in + // Allow the plug-in to use the QuickDraw drawing model, since we know that the plug-in // will never paint or receive events. Used by the AppleConnect plug-in. AllowHalfBakedQuickDrawSupport, #endif diff --git a/Source/WebKit2/Shared/ShareableBitmap.h b/Source/WebKit2/Shared/ShareableBitmap.h index fe7fa0a..d647a12 100644 --- a/Source/WebKit2/Shared/ShareableBitmap.h +++ b/Source/WebKit2/Shared/ShareableBitmap.h @@ -33,7 +33,7 @@ #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> -#if PLATFORM(CG) +#if USE(CG) #include <wtf/RetainPtr.h> #endif @@ -98,7 +98,7 @@ public: bool isBackedBySharedMemory() const { return m_sharedMemory; } -#if PLATFORM(CG) +#if USE(CG) // This creates a copied CGImageRef (most likely a copy-on-write) of the shareable bitmap. RetainPtr<CGImageRef> makeCGImageCopy(); @@ -113,7 +113,7 @@ private: static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; } -#if PLATFORM(CG) +#if USE(CG) static void releaseBitmapContextData(void* typelessBitmap, void* typelessData); static void releaseDataProviderData(void* typelessBitmap, const void* typelessData, size_t); #endif diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp index 99b3c00..e015d64 100644 --- a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp +++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp @@ -33,7 +33,7 @@ namespace CoreIPC { // For now, these are CG-only. Once other platforms have createImage functions, // we can compile these for non-CG builds. -#if PLATFORM(CG) +#if USE(CG) void encodeImage(ArgumentEncoder* encoder, Image* image) { diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.h b/Source/WebKit2/Shared/WebCoreArgumentCoders.h index e12b9be..1b9b4f5 100644 --- a/Source/WebKit2/Shared/WebCoreArgumentCoders.h +++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.h @@ -194,7 +194,7 @@ template<> struct ArgumentCoder<WebCore::Cursor> { static void encode(ArgumentEncoder* encoder, const WebCore::Cursor& cursor) { WebCore::Cursor::Type type = cursor.type(); -#if !PLATFORM(CG) +#if !USE(CG) // FIXME: Currently we only have the createImage function implemented for CG. // Once we implement it for other platforms we can remove this conditional, // and the other conditionals below and in WebCoreArgumentCoders.cpp. @@ -202,7 +202,7 @@ template<> struct ArgumentCoder<WebCore::Cursor> { type = WebCore::Cursor::Pointer; #endif encoder->encode(static_cast<uint32_t>(type)); -#if PLATFORM(CG) +#if USE(CG) if (type != WebCore::Cursor::Custom) return; @@ -225,7 +225,7 @@ template<> struct ArgumentCoder<WebCore::Cursor> { return true; } -#if !PLATFORM(CG) +#if !USE(CG) return false; #else RefPtr<WebCore::Image> image; @@ -401,7 +401,7 @@ template<> struct ArgumentCoder<WebCore::KeypressCommand> { template<> struct ArgumentCoder<WebCore::CompositionUnderline> { static void encode(ArgumentEncoder* encoder, const WebCore::CompositionUnderline& underline) { - encoder->encode(CoreIPC::In(underline.startOffset, underline.endOffset, underline.thick, underline.color.rgb())); + encoder->encode(CoreIPC::In(underline.startOffset, underline.endOffset, underline.thick, underline.color)); } static bool decode(ArgumentDecoder* decoder, WebCore::CompositionUnderline& underline) diff --git a/Source/WebKit2/Shared/WebEvent.cpp b/Source/WebKit2/Shared/WebEvent.cpp index f6738fa..8edc3fd 100644 --- a/Source/WebKit2/Shared/WebEvent.cpp +++ b/Source/WebKit2/Shared/WebEvent.cpp @@ -32,6 +32,13 @@ namespace WebKit { +WebEvent::WebEvent() + : m_type(static_cast<uint32_t>(NoType)) + , m_modifiers(0) + , m_timestamp(0) +{ +} + WebEvent::WebEvent(Type type, Modifiers modifiers, double timestamp) : m_type(type) , m_modifiers(modifiers) diff --git a/Source/WebKit2/Shared/WebEvent.h b/Source/WebKit2/Shared/WebEvent.h index 6d2e60b..169c1a9 100644 --- a/Source/WebKit2/Shared/WebEvent.h +++ b/Source/WebKit2/Shared/WebEvent.h @@ -43,6 +43,8 @@ namespace WebKit { class WebEvent { public: enum Type { + NoType = -1, + // WebMouseEvent MouseDown, MouseUp, @@ -77,6 +79,7 @@ public: ControlKey = 1 << 1, AltKey = 1 << 2, MetaKey = 1 << 3, + CapsLockKey = 1 << 4, }; Type type() const { return static_cast<Type>(m_type); } @@ -85,13 +88,14 @@ public: bool controlKey() const { return m_modifiers & ControlKey; } bool altKey() const { return m_modifiers & AltKey; } bool metaKey() const { return m_modifiers & MetaKey; } + bool capsLockKey() const { return m_modifiers & CapsLockKey; } Modifiers modifiers() const { return static_cast<Modifiers>(m_modifiers); } double timestamp() const { return m_timestamp; } protected: - WebEvent() { } + WebEvent(); WebEvent(Type, Modifiers, double timestamp); @@ -114,7 +118,7 @@ public: RightButton }; - WebMouseEvent() { } + WebMouseEvent(); WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp); #if PLATFORM(WIN) diff --git a/Source/WebKit2/Shared/WebGraphicsContext.cpp b/Source/WebKit2/Shared/WebGraphicsContext.cpp index 3d319e4..72220b3 100644 --- a/Source/WebKit2/Shared/WebGraphicsContext.cpp +++ b/Source/WebKit2/Shared/WebGraphicsContext.cpp @@ -26,15 +26,19 @@ #include "config.h" #include "WebGraphicsContext.h" +#if PLATFORM(GTK) +#include <WebCore/PlatformContextCairo.h> +#endif + using namespace WebCore; namespace WebKit { WebGraphicsContext::WebGraphicsContext(GraphicsContext* graphicsContext) -#if PLATFORM(CG) +#if USE(CG) : m_platformContext(graphicsContext->platformContext()) #elif PLATFORM(GTK) - : m_platformContext(graphicsContext->platformContext()) + : m_platformContext(graphicsContext->platformContext()->cr()) #endif { } diff --git a/Source/WebKit2/Shared/WebGraphicsContext.h b/Source/WebKit2/Shared/WebGraphicsContext.h index ddb2e34..5f72aae 100644 --- a/Source/WebKit2/Shared/WebGraphicsContext.h +++ b/Source/WebKit2/Shared/WebGraphicsContext.h @@ -30,7 +30,7 @@ #include <WebCore/GraphicsContext.h> #include <wtf/PassRefPtr.h> -#if PLATFORM(CG) +#if USE(CG) #include <wtf/RetainPtr.h> #elif PLATFORM(GTK) #include "RefPtrCairo.h" @@ -47,7 +47,7 @@ public: return adoptRef(new WebGraphicsContext(graphicsContext)); } -#if PLATFORM(CG) +#if USE(CG) CGContextRef platformContext() { return m_platformContext.get(); } #elif PLATFORM(GTK) cairo_t* platformContext() { return m_platformContext.get(); } @@ -59,7 +59,7 @@ private: virtual Type type() const { return APIType; } -#if PLATFORM(CG) +#if USE(CG) RetainPtr<CGContextRef> m_platformContext; #elif PLATFORM(GTK) RefPtr<cairo_t> m_platformContext; diff --git a/Source/WebKit2/Shared/WebMouseEvent.cpp b/Source/WebKit2/Shared/WebMouseEvent.cpp index 16e5057..7aa7dff 100644 --- a/Source/WebKit2/Shared/WebMouseEvent.cpp +++ b/Source/WebKit2/Shared/WebMouseEvent.cpp @@ -33,6 +33,19 @@ using namespace WebCore; namespace WebKit { +WebMouseEvent::WebMouseEvent() + : WebEvent() + , m_button(static_cast<uint32_t>(NoButton)) + , m_deltaX(0) + , m_deltaY(0) + , m_deltaZ(0) + , m_clickCount(0) +#if PLATFORM(WIN) + , m_didActivateWebView(false) +#endif +{ +} + WebMouseEvent::WebMouseEvent(Type type, Button button, const IntPoint& position, const IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp) : WebEvent(type, modifiers, timestamp) , m_button(button) diff --git a/Source/WebKit2/Shared/WebPageGroupData.cpp b/Source/WebKit2/Shared/WebPageGroupData.cpp index e8df62f..107df1d 100644 --- a/Source/WebKit2/Shared/WebPageGroupData.cpp +++ b/Source/WebKit2/Shared/WebPageGroupData.cpp @@ -33,12 +33,12 @@ namespace WebKit { void WebPageGroupData::encode(CoreIPC::ArgumentEncoder* encoder) const { - return encoder->encode(CoreIPC::In(identifer, pageGroupID, visibleToInjectedBundle)); + return encoder->encode(CoreIPC::In(identifer, pageGroupID, visibleToInjectedBundle, visibleToHistoryClient)); } bool WebPageGroupData::decode(CoreIPC::ArgumentDecoder* decoder, WebPageGroupData& data) { - return decoder->decode(CoreIPC::Out(data.identifer, data.pageGroupID, data.visibleToInjectedBundle)); + return decoder->decode(CoreIPC::Out(data.identifer, data.pageGroupID, data.visibleToInjectedBundle, data.visibleToHistoryClient)); } } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebPageGroupData.h b/Source/WebKit2/Shared/WebPageGroupData.h index fedb5de..36f6fe1 100644 --- a/Source/WebKit2/Shared/WebPageGroupData.h +++ b/Source/WebKit2/Shared/WebPageGroupData.h @@ -42,6 +42,7 @@ struct WebPageGroupData { String identifer; uint64_t pageGroupID; bool visibleToInjectedBundle; + bool visibleToHistoryClient; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebPopupItem.h b/Source/WebKit2/Shared/WebPopupItem.h index 85495a3..3dc61d7 100644 --- a/Source/WebKit2/Shared/WebPopupItem.h +++ b/Source/WebKit2/Shared/WebPopupItem.h @@ -38,13 +38,13 @@ namespace WebKit { struct WebPopupItem { enum Type { - Seperator, + Separator, Item }; WebPopupItem(); WebPopupItem(Type); - WebPopupItem(Type, const String& text, WebCore::TextDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool m_isLabel); + WebPopupItem(Type, const String& text, WebCore::TextDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel); void encode(CoreIPC::ArgumentEncoder*) const; static bool decode(CoreIPC::ArgumentDecoder*, WebPopupItem&); diff --git a/Source/WebKit2/Shared/WebPreferencesStore.cpp b/Source/WebKit2/Shared/WebPreferencesStore.cpp index c072740..e0bbd4e 100644 --- a/Source/WebKit2/Shared/WebPreferencesStore.cpp +++ b/Source/WebKit2/Shared/WebPreferencesStore.cpp @@ -28,6 +28,7 @@ #include "FontSmoothingLevel.h" #include "WebCoreArgumentCoders.h" +#include <WebCore/Settings.h> namespace WebKit { @@ -51,6 +52,8 @@ static bool hasXSSAuditorEnabledTestRunnerOverride; static bool xssAuditorEnabledTestRunnerOverride; static bool hasAllowUniversalAccessFromFileURLsTestRunnerOverride; static bool allowUniversalAccessFromFileURLsTestRunnerOverride; +static bool hasAllowFileAccessFromFileURLsTestRunnerOverride; +static bool allowFileAccessFromFileURLsTestRunnerOverride; WebPreferencesStore::WebPreferencesStore() { @@ -72,6 +75,9 @@ bool WebPreferencesStore::decode(CoreIPC::ArgumentDecoder* decoder, WebPreferenc if (hasAllowUniversalAccessFromFileURLsTestRunnerOverride) s.m_boolValues.set(WebPreferencesKey::allowUniversalAccessFromFileURLsKey(), allowUniversalAccessFromFileURLsTestRunnerOverride); + if (hasAllowFileAccessFromFileURLsTestRunnerOverride) + s.m_boolValues.set(WebPreferencesKey::allowFileAccessFromFileURLsKey(), allowFileAccessFromFileURLsTestRunnerOverride); + return true; } @@ -87,6 +93,12 @@ void WebPreferencesStore::overrideAllowUniversalAccessFromFileURLsForTestRunner( allowUniversalAccessFromFileURLsTestRunnerOverride = enabled; } +void WebPreferencesStore::overrideAllowFileAccessFromFileURLsForTestRunner(bool enabled) +{ + hasAllowFileAccessFromFileURLsTestRunnerOverride = true; + allowFileAccessFromFileURLsTestRunnerOverride = enabled; +} + void WebPreferencesStore::removeTestRunnerOverrides() { hasXSSAuditorEnabledTestRunnerOverride = false; diff --git a/Source/WebKit2/Shared/WebPreferencesStore.h b/Source/WebKit2/Shared/WebPreferencesStore.h index 43ef487..8bef2b4 100644 --- a/Source/WebKit2/Shared/WebPreferencesStore.h +++ b/Source/WebKit2/Shared/WebPreferencesStore.h @@ -39,6 +39,7 @@ namespace WebKit { #define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \ macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true) \ macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true) \ + macro(LoadsSiteIconsIgnoringImageLoadingPreference, loadsSiteIconsIgnoringImageLoadingPreference, Bool, bool, false) \ macro(PluginsEnabled, pluginsEnabled, Bool, bool, true) \ macro(JavaEnabled, javaEnabled, Bool, bool, true) \ macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, false) \ @@ -86,6 +87,7 @@ namespace WebKit { macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \ macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \ macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \ + macro(EditableLinkBehavior, editableLinkBehavior, UInt32, uint32_t, WebCore::EditableLinkNeverLive) \ \ #if PLATFORM(WIN) @@ -169,6 +171,7 @@ struct WebPreferencesStore { static void overrideXSSAuditorEnabledForTestRunner(bool); static void overrideAllowUniversalAccessFromFileURLsForTestRunner(bool); + static void overrideAllowFileAccessFromFileURLsForTestRunner(bool); static void removeTestRunnerOverrides(); HashMap<String, String> m_stringValues; diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp index db3cd4c..651aaf1 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp @@ -32,8 +32,6 @@ namespace WebKit { WebProcessCreationParameters::WebProcessCreationParameters() : shouldTrackVisitedLinks(false) - , clearResourceCaches(false) - , clearApplicationCache(false) , shouldAlwaysUseComplexTextCodePath(false) , defaultRequestTimeoutInterval(INT_MAX) #if PLATFORM(MAC) @@ -58,8 +56,6 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con encoder->encode(mimeTypesWithCustomRepresentation); encoder->encodeEnum(cacheModel); encoder->encode(shouldTrackVisitedLinks); - encoder->encode(clearResourceCaches); - encoder->encode(clearApplicationCache); encoder->encode(shouldAlwaysUseComplexTextCodePath); encoder->encode(iconDatabaseEnabled); encoder->encode(languageCode); @@ -109,10 +105,6 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web return false; if (!decoder->decode(parameters.shouldTrackVisitedLinks)) return false; - if (!decoder->decode(parameters.clearResourceCaches)) - return false; - if (!decoder->decode(parameters.clearApplicationCache)) - return false; if (!decoder->decode(parameters.shouldAlwaysUseComplexTextCodePath)) return false; if (!decoder->decode(parameters.iconDatabaseEnabled)) diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.h b/Source/WebKit2/Shared/WebProcessCreationParameters.h index 112d6eb..faac556 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.h +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.h @@ -64,9 +64,6 @@ struct WebProcessCreationParameters { CacheModel cacheModel; bool shouldTrackVisitedLinks; - - bool clearResourceCaches; - bool clearApplicationCache; bool shouldAlwaysUseComplexTextCodePath; @@ -88,13 +85,14 @@ struct WebProcessCreationParameters { pid_t presenterApplicationPid; // FIXME: These should be merged with CFURLCache counterparts below. - CString nsURLCachePath; + String nsURLCachePath; uint64_t nsURLCacheMemoryCapacity; uint64_t nsURLCacheDiskCapacity; CoreIPC::MachPort acceleratedCompositingPort; - CString uiProcessBundleResourcePath; + String uiProcessBundleResourcePath; + #elif PLATFORM(WIN) String cfURLCachePath; uint64_t cfURLCacheDiskCapacity; diff --git a/Source/WebKit2/Shared/WebString.h b/Source/WebKit2/Shared/WebString.h index 6827276..5935b4a 100644 --- a/Source/WebKit2/Shared/WebString.h +++ b/Source/WebKit2/Shared/WebString.h @@ -57,6 +57,16 @@ public: bool isNull() const { return m_string.isNull(); } bool isEmpty() const { return m_string.isEmpty(); } + + size_t length() const { return m_string.length(); } + size_t getCharacters(UChar* buffer, size_t bufferLength) const + { + if (!bufferLength) + return 0; + bufferLength = std::min(bufferLength, static_cast<size_t>(m_string.length())); + memcpy(buffer, m_string.characters(), bufferLength * sizeof(UChar)); + return bufferLength; + } size_t maximumUTF8CStringSize() const { return m_string.length() * 3 + 1; } size_t getUTF8CString(char* buffer, size_t bufferSize) diff --git a/Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp b/Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp new file mode 100644 index 0000000..c0bbbd6 --- /dev/null +++ b/Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "NativeWebMouseEvent.h" + +#include "WebEventFactory.h" + +namespace WebKit { + +NativeWebMouseEvent::NativeWebMouseEvent(GdkEvent* event, int eventClickCount) + : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, eventClickCount)) + , m_nativeEvent(event) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/mac/ArgumentCodersMac.h b/Source/WebKit2/Shared/mac/ArgumentCodersMac.h new file mode 100644 index 0000000..e83a50f --- /dev/null +++ b/Source/WebKit2/Shared/mac/ArgumentCodersMac.h @@ -0,0 +1,62 @@ +/* + * 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 ArgumentCodersMac_h +#define ArgumentCodersMac_h + +#include <wtf/RetainPtr.h> + +namespace CoreIPC { + +class ArgumentEncoder; +class ArgumentDecoder; + +// NSAttributedString +void encode(ArgumentEncoder*, NSAttributedString *); +bool decode(ArgumentDecoder*, RetainPtr<NSAttributedString>&); + +// NSColor +void encode(ArgumentEncoder*, NSColor *); +bool decode(ArgumentDecoder*, RetainPtr<NSColor>&); + +// NSDictionary +void encode(ArgumentEncoder*, NSDictionary *); +bool decode(ArgumentDecoder*, RetainPtr<NSDictionary>&); + +// NSFont +void encode(ArgumentEncoder*, NSFont *); +bool decode(ArgumentDecoder*, RetainPtr<NSFont>&); + +// NSNumber +void encode(ArgumentEncoder*, NSNumber *); +bool decode(ArgumentDecoder*, RetainPtr<NSNumber>&); + +// NSString +void encode(ArgumentEncoder*, NSString *); +bool decode(ArgumentDecoder*, RetainPtr<NSString>&); + +} + +#endif // ArgumentCodersMac_h diff --git a/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm b/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm new file mode 100644 index 0000000..394f56c --- /dev/null +++ b/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm @@ -0,0 +1,343 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "ArgumentCodersMac.h" + +#import "ArgumentCodersCF.h" +#import "ArgumentDecoder.h" +#import "ArgumentEncoder.h" +#import "WebCoreArgumentCoders.h" +#import <WebCore/ColorMac.h> + +using namespace WebCore; +using namespace std; + +namespace CoreIPC { + +enum NSType { + NSAttributedStringType, + NSColorType, + NSDictionaryType, + NSFontType, + NSNumberType, + NSStringType, + Unknown, +}; + +static NSType typeFromObject(id object) +{ + ASSERT(object); + + if ([object isKindOfClass:[NSAttributedString class]]) + return NSAttributedStringType; + if ([object isKindOfClass:[NSColor class]]) + return NSColorType; + if ([object isKindOfClass:[NSDictionary class]]) + return NSDictionaryType; + if ([object isKindOfClass:[NSFont class]]) + return NSFontType; + if ([object isKindOfClass:[NSNumber class]]) + return NSNumberType; + if ([object isKindOfClass:[NSString class]]) + return NSStringType; + + ASSERT_NOT_REACHED(); + return Unknown; +} + +static void encode(ArgumentEncoder* encoder, id object) +{ + NSType type = typeFromObject(object); + encoder->encodeEnum(type); + + switch (type) { + case NSAttributedStringType: + encode(encoder, static_cast<NSAttributedString *>(object)); + return; + case NSColorType: + encode(encoder, static_cast<NSColor *>(object)); + return; + case NSDictionaryType: + encode(encoder, static_cast<NSDictionary *>(object)); + return; + case NSFontType: + encode(encoder, static_cast<NSFont *>(object)); + return; + case NSNumberType: + encode(encoder, static_cast<NSNumber *>(object)); + return; + case NSStringType: + encode(encoder, static_cast<NSString *>(object)); + return; + case Unknown: + break; + } + + ASSERT_NOT_REACHED(); +} + +static bool decode(ArgumentDecoder* decoder, RetainPtr<id>& result) +{ + NSType type; + if (!decoder->decodeEnum(type)) + return false; + + switch (type) { + case NSAttributedStringType: { + RetainPtr<NSAttributedString> string; + if (!decode(decoder, string)) + return false; + result = string; + return true; + } + case NSColorType: { + RetainPtr<NSColor> color; + if (!decode(decoder, color)) + return false; + result = color; + return true; + } + case NSDictionaryType: { + RetainPtr<NSDictionary> dictionary; + if (!decode(decoder, dictionary)) + return false; + result = dictionary; + return true; + } + case NSFontType: { + RetainPtr<NSFont> font; + if (!decode(decoder, font)) + return false; + result = font; + return true; + } + case NSNumberType: { + RetainPtr<NSNumber> number; + if (!decode(decoder, number)) + return false; + result = number; + return true; + } + case NSStringType: { + RetainPtr<NSString> string; + if (!decode(decoder, string)) + return false; + result = string; + return true; + } + case Unknown: + ASSERT_NOT_REACHED(); + return false; + } + + return false; +} + +void encode(ArgumentEncoder* encoder, NSAttributedString *string) +{ + // Even though NSAttributedString is toll free bridged with CFAttributedStringRef, attributes' values may be not, so we should stay within this file's code. + + NSString *plainString = [string string]; + NSUInteger length = [plainString length]; + CoreIPC::encode(encoder, plainString); + + Vector<pair<NSRange, RetainPtr<NSDictionary> > > ranges; + + NSUInteger position = 0; + while (position < length) { + // Collect ranges in a vector, becasue the total count should be encoded first. + NSRange effectiveRange; + RetainPtr<NSDictionary> attributesAtIndex = [string attributesAtIndex:position effectiveRange:&effectiveRange]; + ASSERT(effectiveRange.location == position); + ASSERT(effectiveRange.length); + ASSERT(NSMaxRange(effectiveRange) <= length); + + ranges.append(make_pair(effectiveRange, attributesAtIndex)); + + position = NSMaxRange(effectiveRange); + } + + encoder->encodeUInt64(ranges.size()); + + for (size_t i = 0; i < ranges.size(); ++i) { + encoder->encodeUInt64(ranges[i].first.location); + encoder->encodeUInt64(ranges[i].first.length); + CoreIPC::encode(encoder, ranges[i].second.get()); + } +} + +bool decode(ArgumentDecoder* decoder, RetainPtr<NSAttributedString>& result) +{ + RetainPtr<NSString> plainString; + if (!CoreIPC::decode(decoder, plainString)) + return false; + + NSUInteger stringLength = [plainString.get() length]; + + RetainPtr<NSMutableAttributedString> resultString(AdoptNS, [[NSMutableAttributedString alloc] initWithString:plainString.get()]); + + uint64_t rangeCount; + if (!decoder->decode(rangeCount)) + return false; + + while (rangeCount--) { + uint64_t rangeLocation; + uint64_t rangeLength; + RetainPtr<NSDictionary> attributes; + if (!decoder->decode(rangeLocation)) + return false; + if (!decoder->decode(rangeLength)) + return false; + + ASSERT(rangeLocation + rangeLength > rangeLocation); + ASSERT(rangeLocation + rangeLength <= stringLength); + if (rangeLocation + rangeLength <= rangeLocation || rangeLocation + rangeLength > stringLength) + return false; + + if (!CoreIPC::decode(decoder, attributes)) + return false; + [resultString.get() addAttributes:attributes.get() range:NSMakeRange(rangeLocation, rangeLength)]; + } + + result.adoptCF(resultString.leakRef()); + return true; +} + +void encode(ArgumentEncoder* encoder, NSColor *color) +{ + encoder->encode(colorFromNSColor(color)); +} + +bool decode(ArgumentDecoder* decoder, RetainPtr<NSColor>& result) +{ + Color color; + if (!decoder->decode(color)) + return false; + + result = nsColor(color); + return true; +} + +void encode(ArgumentEncoder* encoder, NSDictionary *dictionary) +{ + // Even though NSDictionary is toll free bridged with CFDictionaryRef, values may be not, so we should stay within this file's code. + + NSUInteger size = [dictionary count]; + NSArray *keys = [dictionary allKeys]; + NSArray *values = [dictionary allValues]; + + encoder->encodeUInt64(size); + + for (NSUInteger i = 0; i < size; ++i) { + id key = [keys objectAtIndex:i]; + id value = [values objectAtIndex:i]; + ASSERT(key); + ASSERT([key isKindOfClass:[NSString class]]); + ASSERT(value); + + // Ignore values we don't recognize. + if (typeFromObject(value) == Unknown) + continue; + + encode(encoder, (NSString *)key); + encode(encoder, value); + } +} + +bool decode(ArgumentDecoder* decoder, RetainPtr<NSDictionary>& result) +{ + uint64_t size; + if (!decoder->decodeUInt64(size)) + return false; + + RetainPtr<NSMutableDictionary> dictionary(AdoptNS, [[NSMutableDictionary alloc] initWithCapacity:size]); + for (uint64_t i = 0; i < size; ++i) { + // Try to decode the key name. + RetainPtr<NSString> key; + if (!decode(decoder, key)) + return false; + + RetainPtr<id> value; + if (!decode(decoder, value)) + return false; + + [dictionary.get() setObject:value.get() forKey:key.get()]; + } + + result.adoptCF(dictionary.leakRef()); + return true; +} + + +void encode(ArgumentEncoder* encoder, NSFont *font) +{ + // NSFont could use CTFontRef code if we had it in ArgumentCodersCF. + encode(encoder, [[font fontDescriptor] fontAttributes]); +} + +bool decode(ArgumentDecoder* decoder, RetainPtr<NSFont>& result) +{ + RetainPtr<NSDictionary> fontAttributes; + if (!decode(decoder, fontAttributes)) + return false; + + NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:fontAttributes.get()]; + result = [NSFont fontWithDescriptor:fontDescriptor size:0]; + + return true; +} + +void encode(ArgumentEncoder* encoder, NSNumber *number) +{ + encode(encoder, (CFNumberRef)number); +} + +bool decode(ArgumentDecoder* decoder, RetainPtr<NSNumber>& result) +{ + RetainPtr<CFNumberRef> number; + if (!decode(decoder, number)) + return false; + + result.adoptCF((NSNumber *)number.leakRef()); + return true; +} + +void encode(ArgumentEncoder* encoder, NSString *string) +{ + encode(encoder, (CFStringRef)string); +} + +bool decode(ArgumentDecoder* decoder, RetainPtr<NSString>& result) +{ + RetainPtr<CFStringRef> string; + if (!decode(decoder, string)) + return false; + + result.adoptCF((NSString *)string.leakRef()); + return true; +} + +} diff --git a/Source/WebKit2/Shared/mac/AttributedString.h b/Source/WebKit2/Shared/mac/AttributedString.h new file mode 100644 index 0000000..6c8a8ae --- /dev/null +++ b/Source/WebKit2/Shared/mac/AttributedString.h @@ -0,0 +1,49 @@ +/* + * 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 AttributedString_h +#define AttributedString_h + +#include <wtf/RetainPtr.h> + +OBJC_CLASS NSAttributedString; + +namespace CoreIPC { + class ArgumentDecoder; + class ArgumentEncoder; +} + +namespace WebKit { + +struct AttributedString { + void encode(CoreIPC::ArgumentEncoder*) const; + static bool decode(CoreIPC::ArgumentDecoder*, AttributedString&); + + RetainPtr<NSAttributedString> string; +}; + +} + +#endif // AttributedString_h diff --git a/Source/WebKit2/Shared/mac/AttributedString.mm b/Source/WebKit2/Shared/mac/AttributedString.mm new file mode 100644 index 0000000..bc7cfd0 --- /dev/null +++ b/Source/WebKit2/Shared/mac/AttributedString.mm @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "AttributedString.h" + +#import "ArgumentCodersMac.h" +#import "ArgumentDecoder.h" +#import "ArgumentEncoder.h" + +namespace WebKit { + +void AttributedString::encode(CoreIPC::ArgumentEncoder* encoder) const +{ + encoder->encode(!string); + if (!string) + return; + CoreIPC::encode(encoder, string.get()); +} + +bool AttributedString::decode(CoreIPC::ArgumentDecoder* decoder, AttributedString& attributedString) +{ + bool isNull; + if (!decoder->decode(isNull)) + return false; + if (isNull) + return true; + return CoreIPC::decode(decoder, attributedString.string); +} + +} diff --git a/Source/WebKit2/Shared/mac/NativeWebMouseEventMac.mm b/Source/WebKit2/Shared/mac/NativeWebMouseEventMac.mm new file mode 100644 index 0000000..b7064a3 --- /dev/null +++ b/Source/WebKit2/Shared/mac/NativeWebMouseEventMac.mm @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "NativeWebMouseEvent.h" + +#import "WebEventFactory.h" + +namespace WebKit { + +NativeWebMouseEvent::NativeWebMouseEvent(NSEvent* event, NSView* view) + : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, view)) + , m_nativeEvent(event) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm b/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm index 54cf5d3..60626d1 100644 --- a/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm +++ b/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm @@ -33,6 +33,7 @@ #import "DataReference.h" #import "WebKitSystemInterface.h" #import <WebCore/FileSystem.h> +#import <sys/stat.h> #import <wtf/text/CString.h> using namespace WebCore; @@ -108,12 +109,55 @@ static WKSandboxExtensionType wkSandboxExtensionType(SandboxExtension::Type type return WKSandboxExtensionTypeReadOnly; } +static CString resolveSymlinksInPath(const CString& path) +{ + struct stat statBuf; + + // Check if this file exists. + if (!stat(path.data(), &statBuf)) { + char resolvedName[PATH_MAX]; + + return realpath(path.data(), resolvedName); + } + + char* slashPtr = strrchr(path.data(), '/'); + if (slashPtr == path.data()) + return path; + + size_t parentDirectoryLength = slashPtr - path.data(); + if (parentDirectoryLength >= PATH_MAX) + return CString(); + + // Get the parent directory. + char parentDirectory[PATH_MAX]; + memcpy(parentDirectory, path.data(), parentDirectoryLength); + parentDirectory[parentDirectoryLength] = '\0'; + + // Resolve it. + CString resolvedParentDirectory = resolveSymlinksInPath(CString(parentDirectory)); + if (resolvedParentDirectory.isNull()) + return CString(); + + size_t lastPathComponentLength = path.length() - parentDirectoryLength; + size_t resolvedPathLength = resolvedParentDirectory.length() + lastPathComponentLength; + if (resolvedPathLength >= PATH_MAX) + return CString(); + + // Combine the resolved parent directory with the last path component. + char* resolvedPathBuffer; + CString resolvedPath = CString::newUninitialized(resolvedPathLength, resolvedPathBuffer); + memcpy(resolvedPathBuffer, resolvedParentDirectory.data(), resolvedParentDirectory.length()); + memcpy(resolvedPathBuffer + resolvedParentDirectory.length(), slashPtr, lastPathComponentLength); + + return resolvedPath; +} + void SandboxExtension::createHandle(const String& path, Type type, Handle& handle) { ASSERT(!handle.m_sandboxExtension); - NSString *standardizedPath = [(NSString *)path stringByStandardizingPath]; - handle.m_sandboxExtension = WKSandboxExtensionCreate([standardizedPath fileSystemRepresentation], wkSandboxExtensionType(type)); + CString standardizedPath = resolveSymlinksInPath([[(NSString *)path stringByStandardizingPath] fileSystemRepresentation]); + handle.m_sandboxExtension = WKSandboxExtensionCreate(standardizedPath.data(), wkSandboxExtensionType(type)); } String SandboxExtension::createHandleForTemporaryFile(const String& prefix, Type type, Handle& handle) diff --git a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm b/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm index 321cb40..174daf9 100644 --- a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm +++ b/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm @@ -188,6 +188,7 @@ bool decodeResourceError(ArgumentDecoder* decoder, ResourceError& resourceError) NSError *nsError = [[NSError alloc] initWithDomain:nsString(domain) code:code userInfo:userInfo]; resourceError = ResourceError(nsError); + [nsError release]; return true; } diff --git a/Source/WebKit2/Shared/mac/WebEventFactory.mm b/Source/WebKit2/Shared/mac/WebEventFactory.mm index 67ab1ba..4622080 100644 --- a/Source/WebKit2/Shared/mac/WebEventFactory.mm +++ b/Source/WebKit2/Shared/mac/WebEventFactory.mm @@ -207,8 +207,9 @@ static WebWheelEvent::Phase phaseForEvent(NSEvent *event) static WebWheelEvent::Phase momentumPhaseForEvent(NSEvent *event) { -#if !defined(BUILDING_ON_SNOW_LEOPARD) uint32_t phase = WebWheelEvent::PhaseNone; + +#if !defined(BUILDING_ON_SNOW_LEOPARD) if ([event momentumPhase] & NSEventPhaseBegan) phase |= WebWheelEvent::PhaseBegan; if ([event momentumPhase] & NSEventPhaseStationary) @@ -219,10 +220,24 @@ static WebWheelEvent::Phase momentumPhaseForEvent(NSEvent *event) phase |= WebWheelEvent::PhaseEnded; if ([event momentumPhase] & NSEventPhaseCancelled) phase |= WebWheelEvent::PhaseCancelled; - return static_cast<WebWheelEvent::Phase>(phase); #else - return WebWheelEvent::PhaseNone; + switch (WKGetNSEventMomentumPhase(event)) { + case WKEventPhaseNone: + phase = WebWheelEvent::PhaseNone; + break; + case WKEventPhaseBegan: + phase = WebWheelEvent::PhaseBegan; + break; + case WKEventPhaseChanged: + phase = WebWheelEvent::PhaseChanged; + break; + case WKEventPhaseEnded: + phase = WebWheelEvent::PhaseEnded; + break; + } #endif + + return static_cast<WebWheelEvent::Phase>(phase); } #if ENABLE(GESTURE_EVENTS) @@ -1015,6 +1030,8 @@ static inline bool isKeyUpEvent(NSEvent *event) static inline WebEvent::Modifiers modifiersForEvent(NSEvent *event) { unsigned modifiers = 0; + if ([event modifierFlags] & NSAlphaShiftKeyMask) + modifiers |= WebEvent::CapsLockKey; if ([event modifierFlags] & NSShiftKeyMask) modifiers |= WebEvent::ShiftKey; if ([event modifierFlags] & NSControlKeyMask) diff --git a/Source/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h b/Source/WebKit2/Shared/qt/NativeWebMouseEventQt.cpp index 1f5a6be..a6f6e34 100644 --- a/Source/WebKit2/Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h +++ b/Source/WebKit2/Shared/qt/NativeWebMouseEventQt.cpp @@ -23,29 +23,17 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebProcessProxyMessageKinds_h -#define WebProcessProxyMessageKinds_h +#include "config.h" +#include "NativeWebMouseEvent.h" -// Messages sent from the web process to the WebProcessProxy. +#include "WebEventFactoryQt.h" -#include "MessageID.h" - -namespace WebProcessProxyLegacyMessage { - -enum Kind { -#if ENABLE(PLUGIN_PROCESS) - GetPluginProcessConnection, -#endif -}; - -} - -namespace CoreIPC { - -template<> struct MessageKindTraits<WebProcessProxyLegacyMessage::Kind> { - static const MessageClass messageClass = MessageClassWebProcessProxyLegacy; -}; +namespace WebKit { +NativeWebMouseEvent::NativeWebMouseEvent(QGraphicsSceneMouseEvent* event, int eventClickCount) + : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, eventClickCount)) + , m_nativeEvent(event) +{ } -#endif // WebProcessProxyMessageKinds_h +} // namespace WebKit diff --git a/Source/WebKit2/Shared/win/NativeWebMouseEventWin.cpp b/Source/WebKit2/Shared/win/NativeWebMouseEventWin.cpp new file mode 100644 index 0000000..5b83dc6 --- /dev/null +++ b/Source/WebKit2/Shared/win/NativeWebMouseEventWin.cpp @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#include "config.h" +#include "NativeWebMouseEvent.h" + +#include "WebEventFactory.h" + +namespace WebKit { + +NativeWebMouseEvent::NativeWebMouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, bool didActivateWebView) + : WebMouseEvent(WebEventFactory::createWebMouseEvent(hwnd, message, wParam, lParam, didActivateWebView)) + , m_nativeEvent() +{ + m_nativeEvent.hwnd = hwnd; + m_nativeEvent.message = message; + m_nativeEvent.wParam = wParam; + m_nativeEvent.lParam = lParam; +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp b/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp index 0d1ca36..6770f21 100644 --- a/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp +++ b/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp @@ -30,7 +30,7 @@ #include "ArgumentEncoder.h" #include <WebCore/ResourceResponse.h> -#if PLATFORM(CG) +#if USE(CG) #include <WebKitSystemInterface/WebKitSystemInterface.h> #endif @@ -48,7 +48,7 @@ PlatformCertificateInfo::PlatformCertificateInfo(const ResourceResponse& respons if (!cfResponse) return; -#if PLATFORM(CG) +#if USE(CG) CFDictionaryRef certificateInfo = wkGetSSLCertificateInfo(cfResponse); if (!certificateInfo) return; diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h index a440c6f..81c2f5f 100644 --- a/Source/WebKit2/UIProcess/API/C/WKAPICast.h +++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h @@ -37,11 +37,13 @@ #include "WKPage.h" #include "WKPreferencesPrivate.h" #include "WKProtectionSpaceTypes.h" +#include "WKResourceCacheManager.h" #include "WKSharedAPICast.h" #include <WebCore/CookieJar.h> #include <WebCore/Credential.h> #include <WebCore/FrameLoaderTypes.h> #include <WebCore/ProtectionSpace.h> +#include <WebCore/Settings.h> namespace WebKit { @@ -182,6 +184,44 @@ inline WKFontSmoothingLevel toAPI(FontSmoothingLevel level) return kWKFontSmoothingLevelMedium; } +inline WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior) +{ + switch (behavior) { + case WebCore::EditableLinkDefaultBehavior: + return kWKEditableLinkBehaviorDefault; + case WebCore::EditableLinkAlwaysLive: + return kWKEditableLinkBehaviorAlwaysLive; + case WebCore::EditableLinkOnlyLiveWithShiftKey: + return kWKEditableLinkBehaviorOnlyLiveWithShiftKey; + case WebCore::EditableLinkLiveWhenNotFocused: + return kWKEditableLinkBehaviorLiveWhenNotFocused; + case WebCore::EditableLinkNeverLive: + return kWKEditableLinkBehaviorNeverLive; + } + + ASSERT_NOT_REACHED(); + return kWKEditableLinkBehaviorNeverLive; +} + +inline WebCore::EditableLinkBehavior toEditableLinkBehavior(WKEditableLinkBehavior wkBehavior) +{ + switch (wkBehavior) { + case kWKEditableLinkBehaviorDefault: + return WebCore::EditableLinkDefaultBehavior; + case kWKEditableLinkBehaviorAlwaysLive: + return WebCore::EditableLinkAlwaysLive; + case kWKEditableLinkBehaviorOnlyLiveWithShiftKey: + return WebCore::EditableLinkOnlyLiveWithShiftKey; + case kWKEditableLinkBehaviorLiveWhenNotFocused: + return WebCore::EditableLinkLiveWhenNotFocused; + case kWKEditableLinkBehaviorNeverLive: + return WebCore::EditableLinkNeverLive; + } + + ASSERT_NOT_REACHED(); + return WebCore::EditableLinkNeverLive; +} + inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type) { switch (type) { @@ -246,9 +286,9 @@ inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersis inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear) { switch (wkResourceCachesToClear) { - case kWKAllResourceCaches: + case WKResourceCachesToClearAll: return AllResourceCaches; - case kWKInMemoryResourceCachesOnly: + case WKResourceCachesToClearInMemoryOnly: return InMemoryResourceCachesOnly; } diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp index 5f6a222..00dc6da 100644 --- a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp @@ -45,3 +45,8 @@ WKStringRef WKBackForwardListItemCopyTitle(WKBackForwardListItemRef itemRef) { return toCopiedAPI(toImpl(itemRef)->title()); } + +WKURLRef WKBackForwardListItemCopyOriginalURL(WKBackForwardListItemRef itemRef) +{ + return toCopiedURLAPI(toImpl(itemRef)->originalURL()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h index b0bf1de..3810d15 100644 --- a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h +++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h @@ -36,6 +36,7 @@ WK_EXPORT WKTypeID WKBackForwardListItemGetTypeID(); WK_EXPORT WKURLRef WKBackForwardListItemCopyURL(WKBackForwardListItemRef item); WK_EXPORT WKStringRef WKBackForwardListItemCopyTitle(WKBackForwardListItemRef item); +WK_EXPORT WKURLRef WKBackForwardListItemCopyOriginalURL(WKBackForwardListItemRef item); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp index bf196b7..063f3ea 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp @@ -84,9 +84,9 @@ void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownload toImpl(contextRef)->initializeDownloadClient(wkClient); } -void WKContextDownloadURLRequest(WKContextRef contextRef, const WKURLRequestRef requestRef) +WKDownloadRef WKContextDownloadURLRequest(WKContextRef contextRef, const WKURLRequestRef requestRef) { - toImpl(contextRef)->download(0, toImpl(requestRef)->resourceRequest()); + return toAPI(toImpl(contextRef)->download(0, toImpl(requestRef)->resourceRequest())); } void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef contextRef, WKTypeRef userDataRef) @@ -148,16 +148,6 @@ void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string()); } -void WKContextClearResourceCaches(WKContextRef contextRef, WKResourceCachesToClear cachesToClear) -{ - toImpl(contextRef)->clearResourceCaches(toResourceCachesToClear(cachesToClear)); -} - -void WKContextClearApplicationCache(WKContextRef contextRef) -{ - toImpl(contextRef)->clearApplicationCache(); -} - WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef) { return toAPI(toImpl(contextRef)->cookieManagerProxy()); @@ -227,3 +217,18 @@ void WKContextSetLocalStorageDirectory(WKContextRef contextRef, WKStringRef loca { toImpl(contextRef)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string()); } + +void WKContextDisableProcessTermination(WKContextRef contextRef) +{ + toImpl(contextRef)->disableProcessTermination(); +} + +void WKContextEnableProcessTermination(WKContextRef contextRef) +{ + toImpl(contextRef)->enableProcessTermination(); +} + +void _WKContextSetHTTPPipeliningEnabled(WKContextRef contextRef, bool enabled) +{ + toImpl(contextRef)->setHTTPPipeliningEnabled(enabled); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h index 606574f..6e8e4c0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.h +++ b/Source/WebKit2/UIProcess/API/C/WKContext.h @@ -39,12 +39,6 @@ enum { }; typedef uint32_t WKCacheModel; -enum { - kWKAllResourceCaches = 0, - kWKInMemoryResourceCachesOnly = 1 -}; -typedef uint32_t WKResourceCachesToClear; - // Injected Bundle Client typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo); typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo); @@ -115,7 +109,7 @@ WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKCo WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client); WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClient* client); -WK_EXPORT void WKContextDownloadURLRequest(WKContextRef context, const WKURLRequestRef request); +WK_EXPORT WKDownloadRef WKContextDownloadURLRequest(WKContextRef context, const WKURLRequestRef request); WK_EXPORT void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef context, WKTypeRef userData); WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody); @@ -125,9 +119,6 @@ WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visited WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel); WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context); -WK_EXPORT void WKContextClearResourceCaches(WKContextRef context, WKResourceCachesToClear cachesToClear); -WK_EXPORT void WKContextClearApplicationCache(WKContextRef context); - WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval); WK_EXPORT void WKContextStopMemorySampler(WKContextRef context); diff --git a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h index 5fd7dd3..153ef3e 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h @@ -61,6 +61,13 @@ WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef ic WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory); WK_EXPORT void WKContextSetLocalStorageDirectory(WKContextRef context, WKStringRef localStorageDirectory); +// FIXME: This is a workaround for testing purposes only and should be removed once a better +// solution has been found for testing. +WK_EXPORT void WKContextDisableProcessTermination(WKContextRef context); +WK_EXPORT void WKContextEnableProcessTermination(WKContextRef context); + +WK_EXPORT void _WKContextSetHTTPPipeliningEnabled(WKContextRef context, bool enabled); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.h b/Source/WebKit2/UIProcess/API/C/WKFrame.h index 334a27b..eec939e 100644 --- a/Source/WebKit2/UIProcess/API/C/WKFrame.h +++ b/Source/WebKit2/UIProcess/API/C/WKFrame.h @@ -36,12 +36,12 @@ extern "C" { #endif -enum WKFrameLoadState { +enum { kWKFrameLoadStateProvisional = 0, kWKFrameLoadStateCommitted = 1, kWKFrameLoadStateFinished = 2 }; -typedef enum WKFrameLoadState WKFrameLoadState; +typedef uint32_t WKFrameLoadState; WK_EXPORT WKTypeID WKFrameGetTypeID(); diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp index c8e87a0..8e9327f 100644 --- a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp @@ -36,6 +36,13 @@ WKTypeID WKIconDatabaseGetTypeID() return toAPI(WebIconDatabase::APIType); } +void WKIconDatabaseSetIconDatabaseClient(WKIconDatabaseRef iconDatabaseRef, const WKIconDatabaseClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(iconDatabaseRef)->initializeIconDatabaseClient(wkClient); +} + void WKIconDatabaseRetainIconForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef pageURLRef) { toImpl(iconDatabaseRef)->retainIconForPageURL(toWTFString(pageURLRef)); @@ -50,3 +57,18 @@ void WKIconDatabaseEnableDatabaseCleanup(WKIconDatabaseRef iconDatabaseRef) { toImpl(iconDatabaseRef)->enableDatabaseCleanup(); } + +void WKIconDatabaseRemoveAllIcons(WKIconDatabaseRef iconDatabaseRef) +{ + toImpl(iconDatabaseRef)->removeAllIcons(); +} + +void WKIconDatabaseCheckIntegrityBeforeOpening(WKIconDatabaseRef iconDatabaseRef) +{ + toImpl(iconDatabaseRef)->checkIntegrityBeforeOpening(); +} + +void WKIconDatabaseClose(WKIconDatabaseRef iconDatabaseRef) +{ + toImpl(iconDatabaseRef)->close(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h index 1ea1860..ece3399 100644 --- a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h +++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h @@ -32,12 +32,31 @@ extern "C" { #endif +// IconDatabase Client. +typedef void (*WKIconDatabaseDidChangeIconForPageURLCallback)(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); +typedef void (*WKIconDatabaseDidRemoveAllIconsCallback)(WKIconDatabaseRef iconDatabase, const void* clientInfo); + +struct WKIconDatabaseClient { + int version; + const void * clientInfo; + WKIconDatabaseDidChangeIconForPageURLCallback didChangeIconForPageURL; + WKIconDatabaseDidRemoveAllIconsCallback didRemoveAllIcons; +}; +typedef struct WKIconDatabaseClient WKIconDatabaseClient; + WK_EXPORT WKTypeID WKIconDatabaseGetTypeID(); +WK_EXPORT void WKIconDatabaseSetIconDatabaseClient(WKIconDatabaseRef iconDatabase, const WKIconDatabaseClient* client); + WK_EXPORT void WKIconDatabaseRetainIconForURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL); WK_EXPORT void WKIconDatabaseReleaseIconForURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL); WK_EXPORT void WKIconDatabaseEnableDatabaseCleanup(WKIconDatabaseRef iconDatabase); +WK_EXPORT void WKIconDatabaseRemoveAllIcons(WKIconDatabaseRef iconDatabase); +WK_EXPORT void WKIconDatabaseCheckIntegrityBeforeOpening(WKIconDatabaseRef iconDatabase); + +WK_EXPORT void WKIconDatabaseClose(WKIconDatabaseRef iconDatabase); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp index 7061e39..18bc5a7 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp @@ -32,6 +32,7 @@ #include "WebBackForwardList.h" #include "WebData.h" #include "WebPageProxy.h" +#include "WebProcessProxy.h" #ifdef __BLOCKS__ #include <Block.h> @@ -46,7 +47,7 @@ WKTypeID WKPageGetTypeID() WKContextRef WKPageGetContext(WKPageRef pageRef) { - return toAPI(toImpl(pageRef)->context()); + return toAPI(toImpl(pageRef)->process()->context()); } WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef) diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index 03f49f7..72405a3 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -41,6 +41,12 @@ extern "C" { #endif +enum { + kWKFocusDirectionBackward = 0, + kWKFocusDirectionForward = 1 +}; +typedef uint32_t WKFocusDirection; + typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo); // FrameLoad Client @@ -149,6 +155,9 @@ typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef 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); +typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo); +typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo); typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo); typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo); typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo); @@ -181,6 +190,9 @@ struct WKPageUIClient { WKPageCreateNewPageCallback createNewPage; WKPageCallback showPage; WKPageCallback close; + WKPageTakeFocusCallback takeFocus; + WKPageFocusCallback focus; + WKPageUnfocusCallback unfocus; WKPageRunJavaScriptAlertCallback runJavaScriptAlert; WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm; WKPageRunJavaScriptPromptCallback runJavaScriptPrompt; diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 0122531..449a1e8 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -29,6 +29,7 @@ #include "WKAPICast.h" #include "WebPreferences.h" +#include <WebCore/Settings.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -71,6 +72,16 @@ bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferencesRef) return toImpl(preferencesRef)->loadsImagesAutomatically(); } +void WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferencesRef, bool loadsSiteIconsIgnoringImageLoadingPreference) +{ + toImpl(preferencesRef)->setLoadsSiteIconsIgnoringImageLoadingPreference(loadsSiteIconsIgnoringImageLoadingPreference); +} + +bool WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->loadsSiteIconsIgnoringImageLoadingPreference(); +} + void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef, bool offlineWebApplicationCacheEnabled) { toImpl(preferencesRef)->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled); @@ -251,6 +262,16 @@ uint32_t WKPreferencesGetMinimumFontSize(WKPreferencesRef preferencesRef) return toImpl(preferencesRef)->minimumFontSize(); } +void WKPreferencesSetEditableLinkBehavior(WKPreferencesRef preferencesRef, WKEditableLinkBehavior wkBehavior) +{ + toImpl(preferencesRef)->setEditableLinkBehavior(toEditableLinkBehavior(wkBehavior)); +} + +WKEditableLinkBehavior WKPreferencesGetEditableLinkBehavior(WKPreferencesRef preferencesRef) +{ + return toAPI(static_cast<WebCore::EditableLinkBehavior>(toImpl(preferencesRef)->editableLinkBehavior())); +} + void WKPreferencesSetDefaultTextEncodingName(WKPreferencesRef preferencesRef, WKStringRef name) { toImpl(preferencesRef)->setDefaultTextEncodingName(toWTFString(name)); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h index f2486bf..930f23d 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h @@ -50,6 +50,10 @@ WK_EXPORT void WKPreferencesSetLoadsImagesAutomatically(WKPreferencesRef prefere WK_EXPORT bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferences); // Defaults to false. +WK_EXPORT void WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferences, bool loadsSiteIconsIgnoringImageLoadingPreference); +WK_EXPORT bool WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferences); + +// Defaults to false. WK_EXPORT void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferences, bool offlineWebApplicationCacheEnabled); WK_EXPORT bool WKPreferencesGetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferences); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h index ddf1b9a..d67db14 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -43,10 +43,23 @@ enum WKFontSmoothingLevel { }; typedef enum WKFontSmoothingLevel WKFontSmoothingLevel; +enum WKEditableLinkBehavior { + kWKEditableLinkBehaviorDefault, + kWKEditableLinkBehaviorAlwaysLive, + kWKEditableLinkBehaviorOnlyLiveWithShiftKey, + kWKEditableLinkBehaviorLiveWhenNotFocused, + kWKEditableLinkBehaviorNeverLive +}; +typedef enum WKEditableLinkBehavior WKEditableLinkBehavior; + // Defaults to kWKFontSmoothingLevelMedium. WK_EXPORT void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef, WKFontSmoothingLevel); WK_EXPORT WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef); +// Defaults to EditableLinkNeverLive. +WK_EXPORT void WKPreferencesSetEditableLinkBehavior(WKPreferencesRef preferencesRef, WKEditableLinkBehavior); +WK_EXPORT WKEditableLinkBehavior WKPreferencesGetEditableLinkBehavior(WKPreferencesRef preferencesRef); + // Defaults to false. WK_EXPORT void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef, bool); WK_EXPORT bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef); diff --git a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp index 483beeb..a5711e0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp @@ -41,12 +41,12 @@ void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef cacheManage toImpl(cacheManagerRef)->getCacheOrigins(ArrayCallback::create(context, callback)); } -void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManagerRef, WKSecurityOriginRef originRef) +void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManagerRef, WKSecurityOriginRef originRef, WKResourceCachesToClear cachesToClear) { - toImpl(cacheManagerRef)->clearCacheForOrigin(toImpl(originRef)); + toImpl(cacheManagerRef)->clearCacheForOrigin(toImpl(originRef), toResourceCachesToClear(cachesToClear)); } -void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManagerRef) +void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManagerRef, WKResourceCachesToClear cachesToClear) { - toImpl(cacheManagerRef)->clearCacheForAllOrigins(); + toImpl(cacheManagerRef)->clearCacheForAllOrigins(toResourceCachesToClear(cachesToClear)); } diff --git a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h index 479169d..80c4531 100644 --- a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h +++ b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h @@ -32,13 +32,19 @@ extern "C" { #endif +enum { + WKResourceCachesToClearAll = 0, + WKResourceCachesToClearInMemoryOnly = 1 +}; +typedef uint32_t WKResourceCachesToClear; + WK_EXPORT WKTypeID WKResourceCacheManagerGetTypeID(); typedef void (*WKResourceCacheManagerGetCacheOriginsFunction)(WKArrayRef, WKErrorRef, void*); WK_EXPORT void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef contextRef, void* context, WKResourceCacheManagerGetCacheOriginsFunction function); -WK_EXPORT void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManger, WKSecurityOriginRef origin); -WK_EXPORT void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManager); +WK_EXPORT void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManger, WKSecurityOriginRef origin, WKResourceCachesToClear cachesToClear); +WK_EXPORT void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManager, WKResourceCachesToClear cachesToClear); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp index 5e50dd8..40e4a0e 100644 --- a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp +++ b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp @@ -34,8 +34,8 @@ using namespace WebKit; using namespace WebCore; -CGImageRef WKIconDatabaseGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef) +CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size) { Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef)); - return image ? image->getCGImageRef() : 0; + return image ? image->getFirstCGImageRefOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))) : 0; } diff --git a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h index 48cf5bf..62ae82e 100644 --- a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h +++ b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h @@ -28,12 +28,13 @@ #include <CoreGraphics/CGImage.h> #include <WebKit2/WKBase.h> +#include <WebKit2/WKGeometry.h> #ifdef __cplusplus extern "C" { #endif -WK_EXPORT CGImageRef WKIconDatabaseGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString); +WK_EXPORT CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString, WKSize size); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h index 09cf06f..24891f5 100644 --- a/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h +++ b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h @@ -30,14 +30,25 @@ #error "Please #include \"WKAPICast.h\" instead of this file directly." #endif +#include "WebGrammarDetail.h" +#include <WebCore/TextCheckerClient.h> + namespace WebKit { class WebView; class WebEditCommandProxy; +class WebTextChecker; WK_ADD_API_MAPPING(WKViewRef, WebView) WK_ADD_API_MAPPING(WKEditCommandRef, WebEditCommandProxy) +WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker) +WK_ADD_API_MAPPING(WKGrammarDetailRef, WebGrammarDetail) +inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail) +{ + return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail)); } +} // namespace WebKit + #endif // WKAPICastWin_h diff --git a/Source/WebKit2/UIProcess/API/C/win/WKGrammarDetail.cpp b/Source/WebKit2/UIProcess/API/C/win/WKGrammarDetail.cpp new file mode 100644 index 0000000..5ab0fc4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKGrammarDetail.cpp @@ -0,0 +1,65 @@ +/* + * 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. + */ + +#include "config.h" +#include "WKGrammarDetail.h" + +#include "APIObject.h" +#include "ImmutableArray.h" +#include "WKAPICast.h" +#include "WebGrammarDetail.h" + +using namespace WebKit; + +WKTypeID WKGrammarDetailGetTypeID() +{ + return toAPI(APIObject::TypeGrammarDetail); +} + +WKGrammarDetailRef WKGrammarDetailCreate(int location, int length, WKArrayRef guesses, WKStringRef userDescription) +{ + RefPtr<WebGrammarDetail> detail = WebGrammarDetail::create(location, length, toImpl(guesses), toWTFString(userDescription)); + return toAPI(detail.release().releaseRef()); +} + +int WKGrammarDetailGetLocation(WKGrammarDetailRef grammarDetailRef) +{ + return toImpl(grammarDetailRef)->location(); +} + +int WKGrammarDetailGetLength(WKGrammarDetailRef grammarDetailRef) +{ + return toImpl(grammarDetailRef)->length(); +} + +WKArrayRef WKGrammarDetailCopyGuesses(WKGrammarDetailRef grammarDetailRef) +{ + return toAPI(toImpl(grammarDetailRef)->guesses().leakRef()); +} + +WKStringRef WKGrammarDetailCopyUserDescription(WKGrammarDetailRef grammarDetailRef) +{ + return toCopiedAPI(toImpl(grammarDetailRef)->userDescription()); +} diff --git a/Source/WebKit2/UIProcess/API/C/win/WKGrammarDetail.h b/Source/WebKit2/UIProcess/API/C/win/WKGrammarDetail.h new file mode 100644 index 0000000..c187ce6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKGrammarDetail.h @@ -0,0 +1,47 @@ +/* + * 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 WKGrammarDetail_h +#define WKGrammarDetail_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKGrammarDetailGetTypeID(); +WK_EXPORT WKGrammarDetailRef WKGrammarDetailCreate(int location, int length, WKArrayRef guesses, WKStringRef userDescription); + +WK_EXPORT int WKGrammarDetailGetLocation(WKGrammarDetailRef grammarDetailRef); +WK_EXPORT int WKGrammarDetailGetLength(WKGrammarDetailRef grammarDetailRef); +WK_EXPORT WKArrayRef WKGrammarDetailCopyGuesses(WKGrammarDetailRef grammarDetailRef); +WK_EXPORT WKStringRef WKGrammarDetailCopyUserDescription(WKGrammarDetailRef grammarDetailRef); + +#ifdef __cplusplus +} +#endif + +#endif /* WKGrammarDetail_h */ diff --git a/Source/WebKit2/UIProcess/API/C/win/WKTextChecker.cpp b/Source/WebKit2/UIProcess/API/C/win/WKTextChecker.cpp new file mode 100644 index 0000000..3329da2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKTextChecker.cpp @@ -0,0 +1,60 @@ +/* + * 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. + */ + +#include "config.h" +#include "WKTextChecker.h" + +#include "WKAPICast.h" +#include "WebPageProxy.h" +#include "WebTextChecker.h" + +using namespace WebKit; + +void WKTextCheckerSetClient(const WKTextCheckerClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + WebTextChecker::shared()->setClient(wkClient); +} + +void WKTextCheckerContinuousSpellCheckingEnabledStateChanged(bool enabled) +{ + WebTextChecker::shared()->continuousSpellCheckingEnabledStateChanged(enabled); +} + +void WKTextCheckerGrammarCheckingEnabledStateChanged(bool enabled) +{ + WebTextChecker::shared()->grammarCheckingEnabledStateChanged(enabled); +} + +void WKTextCheckerCheckSpelling(WKPageRef page, bool startBeforeSelection) +{ + WebTextChecker::shared()->checkSpelling(toImpl(page), startBeforeSelection); +} + +void WKTextCheckerChangeSpellingToWord(WKPageRef page, WKStringRef word) +{ + WebTextChecker::shared()->changeSpellingToWord(toImpl(page), toWTFString(word)); +} diff --git a/Source/WebKit2/UIProcess/API/C/win/WKTextChecker.h b/Source/WebKit2/UIProcess/API/C/win/WKTextChecker.h new file mode 100644 index 0000000..31a855d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKTextChecker.h @@ -0,0 +1,87 @@ +/* + * 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 WKTextChecker_h +#define WKTextChecker_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// TextChecker Client +typedef bool (*WKTextCheckerContinousSpellCheckingAllowed)(const void *clientInfo); +typedef bool (*WKTextCheckerContinousSpellCheckingEnabled)(const void *clientInfo); +typedef void (*WKTextCheckerSetContinousSpellCheckingEnabled)(bool enabled, const void *clientInfo); +typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo); +typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo); +typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(WKPageRef page, const void *clientInfo); +typedef void (*WKTextCheckerCloseSpellDocumentWithTag)(uint64_t tag, const void *clientInfo); +typedef void (*WKTextCheckerCheckSpellingOfString)(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void *clientInfo); +typedef void (*WKTextCheckerCheckGrammarOfString)(uint64_t tag, WKStringRef text, WKArrayRef* grammarDetails, int32_t* badGrammarLocation, int32_t* badGrammarLength, const void *clientInfo); +typedef bool (*WKTextCheckerSpellingUIIsShowing)(const void *clientInfo); +typedef void (*WKTextCheckerToggleSpellingUIIsShowing)(const void *clientInfo); +typedef void (*WKTextCheckerUpdateSpellingUIWithMisspelledWord)(uint64_t tag, WKStringRef misspelledWord, const void *clientInfo); +typedef void (*WKTextCheckerUpdateSpellingUIWithGrammarString)(uint64_t tag, WKStringRef badGrammarPhrase, WKGrammarDetailRef grammarDetail, const void *clientInfo); +typedef WKArrayRef (*WKTextCheckerGuessesForWord)(uint64_t tag, WKStringRef word, const void *clientInfo); +typedef void (*WKTextCheckerLearnWord)(uint64_t tag, WKStringRef word, const void *clientInfo); +typedef void (*WKTextCheckerIgnoreWord)(uint64_t tag, WKStringRef word, const void *clientInfo); + +struct WKTextCheckerClient { + int version; + const void * clientInfo; + WKTextCheckerContinousSpellCheckingAllowed continuousSpellCheckingAllowed; + WKTextCheckerContinousSpellCheckingEnabled continuousSpellCheckingEnabled; + WKTextCheckerSetContinousSpellCheckingEnabled setContinuousSpellCheckingEnabled; + WKTextCheckerGrammarCheckingEnabled grammarCheckingEnabled; + WKTextCheckerSetGrammarCheckingEnabled setGrammarCheckingEnabled; + WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag; + WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag; + WKTextCheckerCheckSpellingOfString checkSpellingOfString; + WKTextCheckerCheckGrammarOfString checkGrammarOfString; + WKTextCheckerSpellingUIIsShowing spellingUIIsShowing; + WKTextCheckerToggleSpellingUIIsShowing toggleSpellingUIIsShowing; + WKTextCheckerUpdateSpellingUIWithMisspelledWord updateSpellingUIWithMisspelledWord; + WKTextCheckerUpdateSpellingUIWithGrammarString updateSpellingUIWithGrammarString; + WKTextCheckerGuessesForWord guessesForWord; + WKTextCheckerLearnWord learnWord; + WKTextCheckerIgnoreWord ignoreWord; +}; +typedef struct WKTextCheckerClient WKTextCheckerClient; + +WK_EXPORT void WKTextCheckerSetClient(const WKTextCheckerClient* client); + +WK_EXPORT void WKTextCheckerContinuousSpellCheckingEnabledStateChanged(bool); +WK_EXPORT void WKTextCheckerGrammarCheckingEnabledStateChanged(bool); + +WK_EXPORT void WKTextCheckerCheckSpelling(WKPageRef page, bool startBeforeSelection); +WK_EXPORT void WKTextCheckerChangeSpellingToWord(WKPageRef page, WKStringRef word); + +#ifdef __cplusplus +} +#endif + +#endif /* WKTextChecker_h */ diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.h b/Source/WebKit2/UIProcess/API/C/win/WKView.h index c8ac44c..8b5e5b2 100644 --- a/Source/WebKit2/UIProcess/API/C/win/WKView.h +++ b/Source/WebKit2/UIProcess/API/C/win/WKView.h @@ -43,12 +43,16 @@ typedef uint32_t WKViewUndoType; typedef void (*WKViewRegisterEditCommandCallback)(WKViewRef, WKEditCommandRef, WKViewUndoType undoOrRedo, const void *clientInfo); typedef void (*WKViewClearAllEditCommandsCallback)(WKViewRef, const void *clientInfo); +typedef bool (*WKViewCanUndoRedoCallback)(WKViewRef, WKViewUndoType undoOrRedo, const void *clientInfo); +typedef void (*WKViewExecuteUndoRedoCallback)(WKViewRef, WKViewUndoType undoOrRedo, const void *clientInfo); struct WKViewUndoClient { int version; const void * clientInfo; WKViewRegisterEditCommandCallback registerEditCommand; WKViewClearAllEditCommandsCallback clearAllEditCommands; + WKViewCanUndoRedoCallback canUndoRedo; + WKViewExecuteUndoRedoCallback executeUndoRedo; }; typedef struct WKViewUndoClient WKViewUndoClient; diff --git a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h index cb2a63e..ae5ba65 100644 --- a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h +++ b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h @@ -204,9 +204,15 @@ template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr< return a != b.get(); } +template<typename T> inline WKRetainPtr<T> adoptWK(T o) +{ + return WKRetainPtr<T>(AdoptWK, o); +} + } // namespace WebKit using WebKit::WKRetainPtr; using WebKit::AdoptWK; +using WebKit::adoptWK; #endif // WKRetainPtr_h diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h index dc30f56..041aa7b 100644 --- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h @@ -26,6 +26,7 @@ #ifndef PDFViewController_h #define PDFViewController_h +#include "WebFindOptions.h" #include <wtf/Forward.h> #include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> @@ -64,6 +65,10 @@ public: NSPrintOperation *makePrintOperation(NSPrintInfo *); void openPDFInFinder(); void savePDFToDownloadsFolder(); + void linkClicked(const String& url); + + void findString(const String&, FindOptions, unsigned maxMatchCount); + void countStringMatches(const String&, FindOptions, unsigned maxMatchCount); private: explicit PDFViewController(WKView *wkView); diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm index 5c64000..436a08a 100644 --- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm @@ -30,10 +30,12 @@ #import "WKAPICast.h" #import "WKView.h" #import "WebData.h" +#import "WebEventFactory.h" #import "WebPageGroup.h" #import "WebPageProxy.h" #import "WebPreferences.h" #import <PDFKit/PDFKit.h> +#import <WebCore/LocalizedStrings.h> #import <wtf/text/WTFString.h> // Redeclarations of PDFKit notifications. We can't use the API since we use a weak link to the framework. @@ -51,7 +53,51 @@ using namespace WebKit; @end extern "C" NSString *_NSPathForSystemFramework(NSString *framework); + +// MARK: C UTILITY FUNCTIONS + +static void _applicationInfoForMIMEType(NSString *type, NSString **name, NSImage **image) +{ + ASSERT(name); + ASSERT(image); + CFURLRef appURL = 0; + + OSStatus error = LSCopyApplicationForMIMEType((CFStringRef)type, kLSRolesAll, &appURL); + if (error != noErr) + return; + + NSString *appPath = [(NSURL *)appURL path]; + if (appURL) + CFRelease(appURL); + + *image = [[NSWorkspace sharedWorkspace] iconForFile:appPath]; + [*image setSize:NSMakeSize(16, 16)]; + + *name = [[NSFileManager defaultManager] displayNameAtPath:appPath]; +} + +// FIXME 4182876: We can eliminate this function in favor if -isEqual: if [PDFSelection isEqual:] is overridden +// to compare contents. +static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selectionB) +{ + NSArray *aPages = [selectionA pages]; + NSArray *bPages = [selectionB pages]; + + if (![aPages isEqual:bPages]) + return NO; + + NSUInteger count = [aPages count]; + for (NSUInteger i = 0; i < count; ++i) { + NSRect aBounds = [selectionA boundsForPage:[aPages objectAtIndex:i]]; + NSRect bBounds = [selectionB boundsForPage:[bPages objectAtIndex:i]]; + if (!NSEqualRects(aBounds, bBounds)) + return NO; + } + + return YES; +} + @interface WKPDFView : NSView { PDFViewController* _pdfViewController; @@ -68,7 +114,7 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework); - (void)setDocument:(PDFDocument *)pdfDocument; - (void)_applyPDFPreferences; - +- (PDFSelection *)_nextMatchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag fromSelection:(PDFSelection *)initialSelection startInSelection:(BOOL)startInSelection; @end @implementation WKPDFView @@ -159,6 +205,64 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework); [self _updatePreferencesSoon]; } +- (void)_openWithFinder:(id)sender +{ + _pdfViewController->openPDFInFinder(); +} + +- (PDFSelection *)_nextMatchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag fromSelection:(PDFSelection *)initialSelection startInSelection:(BOOL)startInSelection +{ + if (![string length]) + return nil; + + int options = 0; + if (!forward) + options |= NSBackwardsSearch; + + if (!caseFlag) + options |= NSCaseInsensitiveSearch; + + PDFDocument *document = [_pdfView document]; + + PDFSelection *selectionForInitialSearch = [initialSelection copy]; + if (startInSelection) { + // Initially we want to include the selected text in the search. So we must modify the starting search + // selection to fit PDFDocument's search requirements: selection must have a length >= 1, begin before + // the current selection (if searching forwards) or after (if searching backwards). + int initialSelectionLength = [[initialSelection string] length]; + if (forward) { + [selectionForInitialSearch extendSelectionAtStart:1]; + [selectionForInitialSearch extendSelectionAtEnd:-initialSelectionLength]; + } else { + [selectionForInitialSearch extendSelectionAtEnd:1]; + [selectionForInitialSearch extendSelectionAtStart:-initialSelectionLength]; + } + } + PDFSelection *foundSelection = [document findString:string fromSelection:selectionForInitialSearch withOptions:options]; + [selectionForInitialSearch release]; + + // If we first searched in the selection, and we found the selection, search again from just past the selection + if (startInSelection && _PDFSelectionsAreEqual(foundSelection, initialSelection)) + foundSelection = [document findString:string fromSelection:initialSelection withOptions:options]; + + if (!foundSelection && wrapFlag) + foundSelection = [document findString:string fromSelection:nil withOptions:options]; + + return foundSelection; +} + +- (NSUInteger)_countMatches:(NSString *)string caseSensitive:(BOOL)caseFlag +{ + if (![string length]) + return 0; + + int options = caseFlag ? 0 : NSCaseInsensitiveSearch; + + return [[[_pdfView document] findString:string withOptions:options] count]; +} + +// MARK: NSView overrides + - (void)viewDidMoveToWindow { if (![self window]) @@ -181,7 +285,69 @@ extern "C" NSString *_NSPathForSystemFramework(NSString *framework); [notificationCenter removeObserver:self name:_webkit_PDFViewPageChangedNotification object:_pdfView]; } -// PDFView delegate methods +- (NSView *)hitTest:(NSPoint)point +{ + // Override hitTest so we can override menuForEvent. + NSEvent *event = [NSApp currentEvent]; + NSEventType type = [event type]; + if (type == NSRightMouseDown || (type == NSLeftMouseDown && ([event modifierFlags] & NSControlKeyMask))) + return self; + + return [super hitTest:point]; +} + +- (NSMenu *)menuForEvent:(NSEvent *)theEvent +{ + NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; + + NSEnumerator *menuItemEnumerator = [[[_pdfView menuForEvent:theEvent] itemArray] objectEnumerator]; + while (NSMenuItem *item = [menuItemEnumerator nextObject]) { + NSMenuItem *itemCopy = [item copy]; + [menu addItem:itemCopy]; + [itemCopy release]; + + if ([item action] != @selector(copy:)) + continue; + + // Add in an "Open with <default PDF viewer>" item + NSString *appName = nil; + NSImage *appIcon = nil; + + _applicationInfoForMIMEType(@"application/pdf", &appName, &appIcon); + if (!appName) + appName = WEB_UI_STRING("Finder", "Default application name for Open With context menu"); + + // To match the PDFKit style, we'll add Open with Preview even when there's no document yet to view, and + // disable it using validateUserInterfaceItem. + NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Open with %@", "context menu item for PDF"), appName]; + + item = [[NSMenuItem alloc] initWithTitle:title action:@selector(_openWithFinder:) keyEquivalent:@""]; + if (appIcon) + [item setImage:appIcon]; + [menu addItem:[NSMenuItem separatorItem]]; + [menu addItem:item]; + [item release]; + } + + return [menu autorelease]; +} + +// MARK: NSUserInterfaceValidations PROTOCOL IMPLEMENTATION + +- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item +{ + SEL action = [item action]; + if (action == @selector(_openWithFinder:)) + return [_pdfView document] != nil; + return YES; +} + +// MARK: PDFView delegate methods + +- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)URL +{ + _pdfViewController->linkClicked([URL absoluteString]); +} - (void)PDFViewOpenPDFInNativeApplication:(PDFView *)sender { @@ -416,4 +582,55 @@ NSString *PDFViewController::pathToPDFOnDisk() return path; } +void PDFViewController::linkClicked(const String& url) +{ + NSEvent* nsEvent = [NSApp currentEvent]; + WebMouseEvent event; + switch ([nsEvent type]) { + case NSLeftMouseUp: + case NSRightMouseUp: + case NSOtherMouseUp: + event = WebEventFactory::createWebMouseEvent(nsEvent, m_pdfView); + default: + // For non mouse-clicks or for keyboard events, pass an empty WebMouseEvent + // through. The event is only used by the WebFrameLoaderClient to determine + // the modifier keys and which mouse button is down. These queries will be + // valid with an empty event. + break; + } + + page()->linkClicked(url, event); +} + +void PDFViewController::findString(const String& string, FindOptions options, unsigned maxMatchCount) +{ + BOOL forward = !(options & FindOptionsBackwards); + BOOL caseFlag = !(options & FindOptionsCaseInsensitive); + BOOL wrapFlag = options & FindOptionsWrapAround; + + PDFSelection *selection = [m_wkPDFView.get() _nextMatchFor:string direction:forward caseSensitive:caseFlag wrap:wrapFlag fromSelection:[m_pdfView currentSelection] startInSelection:NO]; + NSUInteger matchCount = [m_wkPDFView.get() _countMatches:string caseSensitive:caseFlag]; + if (matchCount > maxMatchCount) + matchCount = maxMatchCount; + + if (!selection) { + page()->didFailToFindString(string); + return; + } + + [m_pdfView setCurrentSelection:selection]; + [m_pdfView scrollSelectionToVisible:nil]; + page()->didFindString(string, matchCount); +} + +void PDFViewController::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount) +{ + BOOL caseFlag = !(options & FindOptionsCaseInsensitive); + + NSUInteger matchCount = [m_wkPDFView.get() _countMatches:string caseSensitive:caseFlag]; + if (matchCount > maxMatchCount) + matchCount = maxMatchCount; + page()->didCountStringMatches(string, matchCount); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h index e217fc5..9e08a28 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.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 @@ -30,8 +30,8 @@ #include "PageClient.h" #include <wtf/RetainPtr.h> +@class WKEditorUndoTargetObjC; @class WKView; -@class WebEditorUndoTargetObjC; namespace WebKit { @@ -63,16 +63,18 @@ private: virtual void processDidCrash(); virtual void pageClosed(); virtual void didRelaunchProcess(); - virtual void setFocus(bool focused); - virtual void takeFocus(bool direction); virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip); virtual void setCursor(const WebCore::Cursor&); virtual void setViewportArguments(const WebCore::ViewportArguments&); virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); virtual void clearAllEditCommands(); - virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines); + virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); + virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); + virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&); + virtual bool executeSavedCommandBySelector(const String& selector); virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag); + virtual void updateSecureInputState(); virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); @@ -100,10 +102,13 @@ private: virtual double customRepresentationZoomFactor(); virtual void setCustomRepresentationZoomFactor(double); + virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount); + virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount); virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&); + virtual void dismissDictionaryLookupPanel(); virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); @@ -113,7 +118,7 @@ private: virtual float userSpaceScaleFactor() const; WKView* m_wkView; - RetainPtr<WebEditorUndoTargetObjC> m_undoTarget; + RetainPtr<WKEditorUndoTargetObjC> m_undoTarget; #if !defined(BUILDING_ON_SNOW_LEOPARD) CorrectionPanel m_correctionPanel; #endif diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm index 7a0d62d..e1888de 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -52,20 +52,24 @@ @end using namespace WebCore; +using namespace WebKit; -@interface WebEditCommandObjC : NSObject +@interface WKEditCommandObjC : NSObject { - RefPtr<WebKit::WebEditCommandProxy> m_command; + RefPtr<WebEditCommandProxy> m_command; } +- (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command; +- (WebEditCommandProxy*)command; +@end -- (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command; -- (WebKit::WebEditCommandProxy*)command; - +@interface WKEditorUndoTargetObjC : NSObject +- (void)undoEditing:(id)sender; +- (void)redoEditing:(id)sender; @end -@implementation WebEditCommandObjC +@implementation WKEditCommandObjC -- (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command +- (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command { self = [super init]; if (!self) @@ -75,31 +79,24 @@ using namespace WebCore; return self; } -- (WebKit::WebEditCommandProxy*)command +- (WebEditCommandProxy*)command { return m_command.get(); } @end -@interface WebEditorUndoTargetObjC : NSObject - -- (void)undoEditing:(id)sender; -- (void)redoEditing:(id)sender; - -@end - -@implementation WebEditorUndoTargetObjC +@implementation WKEditorUndoTargetObjC - (void)undoEditing:(id)sender { - ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]); + ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]); [sender command]->unapply(); } - (void)redoEditing:(id)sender { - ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]); + ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]); [sender command]->reapply(); } @@ -119,7 +116,7 @@ PassOwnPtr<PageClientImpl> PageClientImpl::create(WKView* wkView) PageClientImpl::PageClientImpl(WKView* wkView) : m_wkView(wkView) - , m_undoTarget(AdoptNS, [[WebEditorUndoTargetObjC alloc] init]) + , m_undoTarget(AdoptNS, [[WKEditorUndoTargetObjC alloc] init]) { } @@ -157,7 +154,7 @@ IntSize PageClientImpl::viewSize() bool PageClientImpl::isViewWindowActive() { - return [[m_wkView window] isKeyWindow]; + return [[m_wkView window] isKeyWindow] || [NSApp keyWindow] == [m_wkView window]; } bool PageClientImpl::isViewFocused() @@ -170,6 +167,9 @@ bool PageClientImpl::isViewVisible() if (![m_wkView window]) return false; + if (![[m_wkView window] isVisible]) + return false; + if ([m_wkView isHiddenOrHasHiddenAncestor]) return false; @@ -196,20 +196,6 @@ void PageClientImpl::didRelaunchProcess() [m_wkView _didRelaunchProcess]; } -void PageClientImpl::setFocus(bool focused) -{ - if (focused) - [[m_wkView window] makeFirstResponder:m_wkView]; - else - // takeFocus in this context means take focus away from the WKView. - takeFocus(true); -} - -void PageClientImpl::takeFocus(bool direction) -{ - [m_wkView _takeFocus:direction]; -} - void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip) { [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)]; @@ -223,67 +209,19 @@ void PageClientImpl::setCursor(const WebCore::Cursor& cursor) void PageClientImpl::setViewportArguments(const WebCore::ViewportArguments&) { - -} - -static NSString* nameForEditAction(EditAction editAction) -{ - // FIXME: Use localized strings. - // FIXME: Move this to a platform independent location. - - switch (editAction) { - case EditActionUnspecified: return nil; - case EditActionSetColor: return @"Set Color"; - case EditActionSetBackgroundColor: return @"Set Background Color"; - case EditActionTurnOffKerning: return @"Turn Off Kerning"; - case EditActionTightenKerning: return @"Tighten Kerning"; - case EditActionLoosenKerning: return @"Loosen Kerning"; - case EditActionUseStandardKerning: return @"Use Standard Kerning"; - case EditActionTurnOffLigatures: return @"Turn Off Ligatures"; - case EditActionUseStandardLigatures: return @"Use Standard Ligatures"; - case EditActionUseAllLigatures: return @"Use All Ligatures"; - case EditActionRaiseBaseline: return @"Raise Baseline"; - case EditActionLowerBaseline: return @"Lower Baseline"; - case EditActionSetTraditionalCharacterShape: return @"Set Traditional Character Shape"; - case EditActionSetFont: return @"Set Font"; - case EditActionChangeAttributes: return @"Change Attributes"; - case EditActionAlignLeft: return @"Align Left"; - case EditActionAlignRight: return @"Align Right"; - case EditActionCenter: return @"Center"; - case EditActionJustify: return @"Justify"; - case EditActionSetWritingDirection: return @"Set Writing Direction"; - case EditActionSubscript: return @"Subscript"; - case EditActionSuperscript: return @"Superscript"; - case EditActionUnderline: return @"Underline"; - case EditActionOutline: return @"Outline"; - case EditActionUnscript: return @"Unscript"; - case EditActionDrag: return @"Drag"; - case EditActionCut: return @"Cut"; - case EditActionPaste: return @"Paste"; - case EditActionPasteFont: return @"Paste Font"; - case EditActionPasteRuler: return @"Paste Ruler"; - case EditActionTyping: return @"Typing"; - case EditActionCreateLink: return @"Create Link"; - case EditActionUnlink: return @"Unlink"; - case EditActionInsertList: return @"Insert List"; - case EditActionFormatBlock: return @"Formatting"; - case EditActionIndent: return @"Indent"; - case EditActionOutdent: return @"Outdent"; - } - return nil; } void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo) { RefPtr<WebEditCommandProxy> command = prpCommand; - RetainPtr<WebEditCommandObjC> commandObjC(AdoptNS, [[WebEditCommandObjC alloc] initWithWebEditCommandProxy:command]); - NSString *actionName = nameForEditAction(command->editAction()); + RetainPtr<WKEditCommandObjC> commandObjC(AdoptNS, [[WKEditCommandObjC alloc] initWithWebEditCommandProxy:command]); + String actionName = WebEditCommandProxy::nameForEditAction(command->editAction()); NSUndoManager *undoManager = [m_wkView undoManager]; [undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()]; - if (actionName) - [undoManager setActionName:actionName]; + if (!actionName.isEmpty()) + [undoManager setActionName:(NSString *)actionName]; } void PageClientImpl::clearAllEditCommands() @@ -291,10 +229,19 @@ void PageClientImpl::clearAllEditCommands() [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()]; } -void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) +bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) { - commandsList = [m_wkView _interceptKeyEvent:event.nativeEvent()]; - [m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines]; + return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] canUndo] : [[m_wkView undoManager] canRedo]; +} + +void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) +{ + return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo]; +} + +bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commands) +{ + return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands]; } void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) @@ -304,7 +251,12 @@ void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<Sha [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag]; } - + +void PageClientImpl::updateSecureInputState() +{ + [m_wkView _updateSecureInputState]; +} + FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect) { return [m_wkView _convertToDeviceSpace:rect]; @@ -408,6 +360,16 @@ void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor) [m_wkView _setCustomRepresentationZoomFactor:zoomFactor]; } +void PageClientImpl::findStringInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount) +{ + [m_wkView _findStringInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount]; +} + +void PageClientImpl::countStringMatchesInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount) +{ + [m_wkView _countStringMatchesInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount]; +} + void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&) { notImplemented(); @@ -437,6 +399,13 @@ void PageClientImpl::didPerformDictionaryLookup(const String& text, double scale #endif } +void PageClientImpl::dismissDictionaryLookupPanel() +{ +#if !defined(BUILDING_ON_SNOW_LEOPARD) + WKHideWordDefinitionWindow(); +#endif +} + void PageClientImpl::showCorrectionPanel(CorrectionPanelInfo::PanelType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) { #if !defined(BUILDING_ON_SNOW_LEOPARD) @@ -484,4 +453,9 @@ float PageClientImpl::userSpaceScaleFactor() const #endif } +bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString) +{ + return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)]; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm index 3b69a1d..2c9ceaa 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm @@ -86,7 +86,14 @@ BOOL hadMarkedText = [_inputTextView hasMarkedText]; *string = nil; - + + // Let TSM know that a bottom input window would be created for marked text. + EventRef carbonEvent = static_cast<EventRef>(const_cast<void*>([event eventRef])); + if (carbonEvent) { + Boolean ignorePAH = true; + SetEventParameter(carbonEvent, 'iPAH', typeBoolean, sizeof(ignorePAH), &ignorePAH); + } + if (![[_inputTextView inputContext] handleEvent:event]) return NO; diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.h b/Source/WebKit2/UIProcess/API/mac/WKView.h index 8c1826c..098b3ca 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.h +++ b/Source/WebKit2/UIProcess/API/mac/WKView.h @@ -29,7 +29,7 @@ @class WKViewData; WK_EXPORT -@interface WKView : NSView <NSTextInput> { +@interface WKView : NSView <NSTextInputClient> { WKViewData *_data; unsigned _frameSizeUpdatesDisabledCount; } diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index 05693ef..80345f7 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -26,14 +26,17 @@ #import "config.h" #import "WKView.h" +#import "AttributedString.h" #import "ChunkedUpdateDrawingAreaProxy.h" #import "DataReference.h" #import "DrawingAreaProxyImpl.h" +#import "EditorState.h" #import "FindIndicator.h" #import "FindIndicatorWindow.h" #import "LayerTreeContext.h" #import "Logging.h" #import "NativeWebKeyboardEvent.h" +#import "NativeWebMouseEvent.h" #import "PDFViewController.h" #import "PageClientImpl.h" #import "PasteboardTypes.h" @@ -69,24 +72,23 @@ #import <wtf/RefPtr.h> #import <wtf/RetainPtr.h> -@interface NSApplication (WebNSApplicationDetails) +@interface NSApplication (WKNSApplicationDetails) - (void)speakString:(NSString *)string; - (void)_setCurrentEvent:(NSEvent *)event; @end -@interface NSWindow (WebNSWindowDetails) +@interface NSObject (WKNSTextInputContextDetails) +- (BOOL)wantsToHandleMouseEvents; +- (BOOL)handleMouseEvent:(NSEvent *)event; +@end + +@interface NSWindow (WKNSWindowDetails) - (NSRect)_growBoxRect; - (id)_growBoxOwner; - (void)_setShowOpaqueGrowBoxForOwner:(id)owner; - (BOOL)_updateGrowBoxForWindowFrameChange; @end -extern "C" { - // Need to declare this attribute name because AppKit exports it but does not make it available in API or SPI headers. - // <rdar://problem/8631468> tracks the request to make it available. This code should be removed when the bug is closed. - extern NSString *NSTextInputReplacementRangeAttributeName; -} - using namespace WebKit; using namespace WebCore; @@ -98,6 +100,13 @@ typedef HashMap<String, ValidationVector> ValidationMap; } +struct WKViewInterpretKeyEventsParameters { + bool eventInterpretationHadSideEffects; + bool consumedByIM; + bool executingSavedKeypressCommands; + Vector<KeypressCommand>* commands; +}; + @interface WKViewData : NSObject { @public OwnPtr<PageClientImpl> _pageClient; @@ -122,18 +131,13 @@ typedef HashMap<String, ValidationVector> ValidationMap; // the application to distinguish the case of a new event from one // that has been already sent to WebCore. RetainPtr<NSEvent> _keyDownEventBeingResent; - bool _isInInterpretKeyEvents; - Vector<KeypressCommand> _commandsList; + WKViewInterpretKeyEventsParameters* _interpretKeyEventsParameters; NSSize _resizeScrollOffset; // The identifier of the plug-in we want to send complex text input to, or 0 if there is none. uint64_t _pluginComplexTextInputIdentifier; - Vector<CompositionUnderline> _underlines; - unsigned _selectionStart; - unsigned _selectionEnd; - bool _inBecomeFirstResponder; bool _inResignFirstResponder; NSEvent *_mouseDownEvent; @@ -150,15 +154,21 @@ typedef HashMap<String, ValidationVector> ValidationMap; BOOL _hasSpellCheckerDocumentTag; NSInteger _spellCheckerDocumentTag; + + BOOL _inSecureInputState; } @end -@implementation WKViewData +@interface WKResponderChainSink : NSResponder { + NSResponder *_lastResponderInChain; + bool _didReceiveUnhandledCommand; +} +- (id)initWithResponderChain:(NSResponder *)chain; +- (void)detach; +- (bool)didReceiveUnhandledCommand; @end -@interface NSObject (NSTextInputContextDetails) -- (BOOL)wantsToHandleMouseEvents; -- (BOOL)handleMouseEvent:(NSEvent *)event; +@implementation WKViewData @end @implementation WKView @@ -239,6 +249,8 @@ typedef HashMap<String, ValidationVector> ValidationMap; { _data->_page->close(); + ASSERT(!_data->_inSecureInputState); + [_data release]; _data = nil; @@ -282,7 +294,10 @@ typedef HashMap<String, ValidationVector> ValidationMap; NSSelectionDirection direction = [[self window] keyViewSelectionDirection]; _data->_inBecomeFirstResponder = true; + + [self _updateSecureInputState]; _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused); + _data->_inBecomeFirstResponder = false; if (direction != NSDirectSelection) @@ -294,7 +309,13 @@ typedef HashMap<String, ValidationVector> ValidationMap; - (BOOL)resignFirstResponder { _data->_inResignFirstResponder = true; + + if (_data->_inSecureInputState) { + DisableSecureEventInput(); + _data->_inSecureInputState = NO; + } _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused); + _data->_inResignFirstResponder = false; return YES; @@ -514,13 +535,13 @@ WEBCORE_COMMAND(yankAndSelect) - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { - BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->selectionState().isNone); + BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->editorState().selectionIsNone); BOOL isValidReturnType = NO; if (!returnType) isValidReturnType = YES; - else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->selectionState().isContentEditable) { + else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->editorState().isContentEditable) { // We can insert strings in any editable context. We can insert other types, like images, only in rich edit contexts. - isValidReturnType = _data->_page->selectionState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType]; + isValidReturnType = _data->_page->editorState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType]; } if (isValidSendType && isValidReturnType) return self; @@ -604,12 +625,12 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int if (action == @selector(showGuessPanel:)) { if (NSMenuItem *menuItem = ::menuItem(item)) - [menuItem setTitle:contextMenuItemTagShowSpellingPanel([[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])]; - return _data->_page->selectionState().isContentEditable; + [menuItem setTitle:contextMenuItemTagShowSpellingPanel(![[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])]; + return _data->_page->editorState().isContentEditable; } if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:)) - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; if (action == @selector(toggleContinuousSpellChecking:)) { bool enabled = TextChecker::isContinuousSpellCheckingAllowed(); @@ -627,47 +648,47 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int if (action == @selector(toggleAutomaticSpellingCorrection:)) { bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled; [menuItem(item) setState:checked ? NSOnState : NSOffState]; - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; } if (action == @selector(orderFrontSubstitutionsPanel:)) { if (NSMenuItem *menuItem = ::menuItem(item)) - [menuItem setTitle:contextMenuItemTagShowSubstitutions([[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])]; - return _data->_page->selectionState().isContentEditable; + [menuItem setTitle:contextMenuItemTagShowSubstitutions(![[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])]; + return _data->_page->editorState().isContentEditable; } if (action == @selector(toggleSmartInsertDelete:)) { bool checked = _data->_page->isSmartInsertDeleteEnabled(); [menuItem(item) setState:checked ? NSOnState : NSOffState]; - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; } if (action == @selector(toggleAutomaticQuoteSubstitution:)) { bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled; [menuItem(item) setState:checked ? NSOnState : NSOffState]; - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; } if (action == @selector(toggleAutomaticDashSubstitution:)) { bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled; [menuItem(item) setState:checked ? NSOnState : NSOffState]; - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; } if (action == @selector(toggleAutomaticLinkDetection:)) { bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled; [menuItem(item) setState:checked ? NSOnState : NSOffState]; - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; } if (action == @selector(toggleAutomaticTextReplacement:)) { bool checked = TextChecker::state().isAutomaticTextReplacementEnabled; [menuItem(item) setState:checked ? NSOnState : NSOffState]; - return _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().isContentEditable; } if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:)) - return _data->_page->selectionState().selectedRangeLength && _data->_page->selectionState().isContentEditable; + return _data->_page->editorState().selectionIsRange && _data->_page->editorState().isContentEditable; if (action == @selector(stopSpeaking:)) return [NSApp isSpeaking]; @@ -751,9 +772,6 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) TextChecker::setContinuousSpellCheckingEnabled(spellCheckingEnabled); _data->_page->process()->updateTextCheckerState(); - - if (!spellCheckingEnabled) - _data->_page->unmarkAllMisspellings(); } - (BOOL)isGrammarCheckingEnabled @@ -768,9 +786,6 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) TextChecker::setGrammarCheckingEnabled(flag); _data->_page->process()->updateTextCheckerState(); - - if (!flag) - _data->_page->unmarkAllBadGrammar(); } - (IBAction)toggleGrammarChecking:(id)sender @@ -779,9 +794,6 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled); _data->_page->process()->updateTextCheckerState(); - - if (!grammarCheckingEnabled) - _data->_page->unmarkAllBadGrammar(); } - (IBAction)toggleAutomaticSpellingCorrection:(id)sender @@ -927,6 +939,33 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) _data->_mouseDownEvent = [event retain]; } +#define NATIVE_MOUSE_EVENT_HANDLER(Selector) \ + - (void)Selector:(NSEvent *)theEvent \ + { \ + if ([[self inputContext] handleEvent:theEvent]) { \ + LOG(TextInput, "%s was handled by text input context", String(#Selector).substring(0, String(#Selector).find("Internal")).ascii().data()); \ + return; \ + } \ + NativeWebMouseEvent webEvent(theEvent, self); \ + _data->_page->handleMouseEvent(webEvent); \ + } + +NATIVE_MOUSE_EVENT_HANDLER(mouseEntered) +NATIVE_MOUSE_EVENT_HANDLER(mouseExited) +NATIVE_MOUSE_EVENT_HANDLER(mouseMovedInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseDownInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseUpInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseDraggedInternal) +NATIVE_MOUSE_EVENT_HANDLER(otherMouseDown) +NATIVE_MOUSE_EVENT_HANDLER(otherMouseDragged) +NATIVE_MOUSE_EVENT_HANDLER(otherMouseMoved) +NATIVE_MOUSE_EVENT_HANDLER(otherMouseUp) +NATIVE_MOUSE_EVENT_HANDLER(rightMouseDown) +NATIVE_MOUSE_EVENT_HANDLER(rightMouseDragged) +NATIVE_MOUSE_EVENT_HANDLER(rightMouseUp) + +#undef NATIVE_MOUSE_EVENT_HANDLER + #define EVENT_HANDLER(Selector, Type) \ - (void)Selector:(NSEvent *)theEvent \ { \ @@ -934,28 +973,17 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) _data->_page->handle##Type##Event(webEvent); \ } -EVENT_HANDLER(mouseEntered, Mouse) -EVENT_HANDLER(mouseExited, Mouse) -EVENT_HANDLER(mouseMoved, Mouse) -EVENT_HANDLER(otherMouseDown, Mouse) -EVENT_HANDLER(otherMouseDragged, Mouse) -EVENT_HANDLER(otherMouseMoved, Mouse) -EVENT_HANDLER(otherMouseUp, Mouse) -EVENT_HANDLER(rightMouseDown, Mouse) -EVENT_HANDLER(rightMouseDragged, Mouse) -EVENT_HANDLER(rightMouseMoved, Mouse) -EVENT_HANDLER(rightMouseUp, Mouse) EVENT_HANDLER(scrollWheel, Wheel) #undef EVENT_HANDLER -- (void)_mouseHandler:(NSEvent *)event +- (void)mouseMoved:(NSEvent *)event { - NSInputManager *currentInputManager = [NSInputManager currentInputManager]; - if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event]) + // When a view is first responder, it gets mouse moved events even when the mouse is outside its visible rect. + if (self == [[self window] firstResponder] && !NSPointInRect([self convertPoint:[event locationInWindow] fromView:nil], [self visibleRect])) return; - WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(event, self); - _data->_page->handleMouseEvent(webEvent); + + [self mouseMovedInternal:event]; } - (void)mouseDown:(NSEvent *)event @@ -963,20 +991,57 @@ EVENT_HANDLER(scrollWheel, Wheel) [self _setMouseDownEvent:event]; _data->_ignoringMouseDraggedEvents = NO; _data->_dragHasStarted = NO; - [self _mouseHandler:event]; + [self mouseDownInternal:event]; } - (void)mouseUp:(NSEvent *)event { [self _setMouseDownEvent:nil]; - [self _mouseHandler:event]; + [self mouseUpInternal:event]; } - (void)mouseDragged:(NSEvent *)event { if (_data->_ignoringMouseDraggedEvents) return; - [self _mouseHandler:event]; + [self mouseDraggedInternal:event]; +} + +- (BOOL)acceptsFirstMouse:(NSEvent *)event +{ + // There's a chance that responding to this event will run a nested event loop, and + // fetching a new event might release the old one. Retaining and then autoreleasing + // the current event prevents that from causing a problem inside WebKit or AppKit code. + [[event retain] autorelease]; + + if (![self hitTest:[event locationInWindow]]) + return NO; + + [self _setMouseDownEvent:event]; + bool result = _data->_page->acceptsFirstMouse([event eventNumber], WebEventFactory::createWebMouseEvent(event, self)); + [self _setMouseDownEvent:nil]; + return result; +} + +- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)event +{ + // If this is the active window or we don't have a range selection, there is no need to perform additional checks + // and we can avoid making a synchronous call to the WebProcess. + if ([[self window] isKeyWindow] || _data->_page->editorState().selectionIsNone || !_data->_page->editorState().selectionIsRange) + return NO; + + // There's a chance that responding to this event will run a nested event loop, and + // fetching a new event might release the old one. Retaining and then autoreleasing + // the current event prevents that from causing a problem inside WebKit or AppKit code. + [[event retain] autorelease]; + + if (![self hitTest:[event locationInWindow]]) + return NO; + + [self _setMouseDownEvent:event]; + bool result = _data->_page->shouldDelayWindowOrderingForEvent(WebEventFactory::createWebMouseEvent(event, self)); + [self _setMouseDownEvent:nil]; + return result; } #if ENABLE(GESTURE_EVENTS) @@ -1018,52 +1083,75 @@ static const short kIOHIDEventTypeScroll = 6; { LOG(TextInput, "doCommandBySelector:\"%s\"", sel_getName(selector)); - if (!_data->_isInInterpretKeyEvents) { + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + if (parameters) + parameters->consumedByIM = false; + + // As in insertText:replacementRange:, we assume that the call comes from an input method if there is marked text. + bool isFromInputMethod = _data->_page->editorState().hasComposition; + + if (parameters && !isFromInputMethod) + parameters->commands->append(KeypressCommand(NSStringFromSelector(selector))); + else { + // FIXME: Send the command to Editor synchronously and only send it along the + // responder chain if it's a selector that does not correspond to an editing command. [super doCommandBySelector:selector]; - return; } - if (selector != @selector(noop:)) - _data->_commandsList.append(KeypressCommand(commandNameForSelector(selector))); } - (void)insertText:(id)string { - BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString - - LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string); + // Unlike and NSTextInputClient variant with replacementRange, this NSResponder method is called when there is no input context, + // so text input processing isn't performed. We are not going to actually insert any text in that case, but saving an insertText + // command ensures that a keypress event is dispatched as appropriate. + [self insertText:string replacementRange:NSMakeRange(NSNotFound, 0)]; +} + +- (void)insertText:(id)string replacementRange:(NSRange)replacementRange +{ + BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; + ASSERT(isAttributedString || [string isKindOfClass:[NSString class]]); + + if (replacementRange.location != NSNotFound) + LOG(TextInput, "insertText:\"%@\" replacementRange:(%u, %u)", isAttributedString ? [string string] : string, replacementRange.location, replacementRange.length); + else + LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string); + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + if (parameters) + parameters->consumedByIM = false; + NSString *text; - bool isFromInputMethod = _data->_page->selectionState().hasComposition; + bool isFromInputMethod = _data->_page->editorState().hasComposition; if (isAttributedString) { + // FIXME: We ignore most attributes from the string, so for example inserting from Character Palette loses font and glyph variation data. text = [string string]; - // We deal with the NSTextInputReplacementRangeAttributeName attribute from NSAttributedString here - // simply because it is used by at least one Input Method -- it corresonds to the kEventParamTextInputSendReplaceRange - // event in TSM. This behaviour matches that of -[WebHTMLView setMarkedText:selectedRange:] when it receives an - // NSAttributedString - NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, [text length])]; - LOG(TextInput, "ReplacementRange: %@", rangeString); - if (rangeString) - isFromInputMethod = YES; } else text = string; + // insertText can be called for several reasons: + // - If it's from normal key event processing (including key bindings), we may need to save the action to perform it later. + // - If it's from an input method, then we should go ahead and insert the text now. We assume it's from the input method if we have marked text. + // FIXME: In theory, this could be wrong for some input methods, so we should try to find another way to determine if the call is from the input method. + // - If it's sent outside of keyboard event processing (e.g. from Character Viewer, or when confirming an inline input area with a mouse), + // then we also execute it immediately, as there will be no other chance. + if (parameters && !isFromInputMethod) { + ASSERT(replacementRange.location == NSNotFound); + parameters->commands->append(KeypressCommand("insertText:", text)); + return; + } + String eventText = text; - - // We'd need a different code path here if we wanted to be able to handle this - // outside of interpretKeyEvents. - ASSERT(_data->_isInInterpretKeyEvents); + eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore + bool eventHandled = _data->_page->insertText(eventText, replacementRange.location, NSMaxRange(replacementRange)); - if (!isFromInputMethod) - _data->_commandsList.append(KeypressCommand("insertText", text)); - else { - eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore - _data->_commandsList.append(KeypressCommand("insertText", eventText)); - } + if (parameters) + parameters->eventInterpretationHadSideEffects |= eventHandled; } - (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event { - if (!_data->_page->selectionState().isContentEditable) + if (!_data->_page->editorState().isContentEditable) return NO; if (([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) != NSCommandKeyMask) @@ -1130,9 +1218,6 @@ static const short kIOHIDEventTypeScroll = 6; } } - _data->_underlines.clear(); - _data->_selectionStart = 0; - _data->_selectionEnd = 0; // We could be receiving a key down from AppKit if we have re-sent an event // that maps to an action that is currently unavailable (for example a copy when // there is no range selection). @@ -1144,37 +1229,108 @@ static const short kIOHIDEventTypeScroll = 6; _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); } -- (NSTextInputContext *)inputContext { - if (_data->_pluginComplexTextInputIdentifier && !_data->_isInInterpretKeyEvents) +- (void)flagsChanged:(NSEvent *)theEvent +{ + // There's a chance that responding to this event will run a nested event loop, and + // fetching a new event might release the old one. Retaining and then autoreleasing + // the current event prevents that from causing a problem inside WebKit or AppKit code. + [[theEvent retain] autorelease]; + + unsigned short keyCode = [theEvent keyCode]; + + // Don't make an event from the num lock and function keys + if (!keyCode || keyCode == 10 || keyCode == 63) + return; + + _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); +} + +- (void)_executeSavedKeypressCommands +{ + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + if (!parameters || parameters->commands->isEmpty()) + return; + + // We could be called again if the execution of one command triggers a call to selectedRange. + // In this case, the state is up to date, and we don't need to execute any more saved commands to return a result. + if (parameters->executingSavedKeypressCommands) + return; + + parameters->executingSavedKeypressCommands = true; + parameters->eventInterpretationHadSideEffects |= _data->_page->executeKeypressCommands(*parameters->commands); + parameters->commands->clear(); + parameters->executingSavedKeypressCommands = false; +} + +- (NSTextInputContext *)inputContext +{ + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + + if (_data->_pluginComplexTextInputIdentifier && !parameters) return [[WKTextInputWindowController sharedTextInputWindowController] inputContext]; + // Disable text input machinery when in non-editable content. An invisible inline input area affects performance, and can prevent Expose from working. + if (!_data->_page->editorState().isContentEditable) + return nil; + return [super inputContext]; } - (NSRange)selectedRange { - if (_data->_page->selectionState().isNone || !_data->_page->selectionState().isContentEditable) - return NSMakeRange(NSNotFound, 0); - - LOG(TextInput, "selectedRange -> (%u, %u)", _data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength); - return NSMakeRange(_data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength); + [self _executeSavedKeypressCommands]; + + uint64_t selectionStart; + uint64_t selectionLength; + _data->_page->getSelectedRange(selectionStart, selectionLength); + + NSRange result = NSMakeRange(selectionStart, selectionLength); + if (result.location == NSNotFound) + LOG(TextInput, "selectedRange -> (NSNotFound, %u)", result.length); + else + LOG(TextInput, "selectedRange -> (%u, %u)", result.location, result.length); + + return result; } - (BOOL)hasMarkedText { - LOG(TextInput, "hasMarkedText -> %u", _data->_page->selectionState().hasComposition); - return _data->_page->selectionState().hasComposition; + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + + BOOL result; + if (parameters) { + result = _data->_page->editorState().hasComposition; + if (result) { + // A saved command can confirm a composition, but it cannot start a new one. + [self _executeSavedKeypressCommands]; + result = _data->_page->editorState().hasComposition; + } + } else { + uint64_t location; + uint64_t length; + _data->_page->getMarkedRange(location, length); + result = location != NSNotFound; + } + + LOG(TextInput, "hasMarkedText -> %u", result); + return result; } - (void)unmarkText { + [self _executeSavedKeypressCommands]; + LOG(TextInput, "unmarkText"); - // We'd need a different code path here if we wanted to be able to handle this - // outside of interpretKeyEvents. - ASSERT(_data->_isInInterpretKeyEvents); + // Use pointer to get parameters passed to us by the caller of interpretKeyEvents. + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + + if (parameters) { + parameters->eventInterpretationHadSideEffects = true; + parameters->consumedByIM = false; + } - _data->_commandsList.append(KeypressCommand("unmarkText")); + _data->_page->confirmComposition(); } - (NSArray *)validAttributesForMarkedText @@ -1183,7 +1339,7 @@ static const short kIOHIDEventTypeScroll = 6; if (!validAttributes) { validAttributes = [[NSArray alloc] initWithObjects: NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName, - NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName, nil]; + NSMarkedClauseSegmentAttributeName, nil]; // NSText also supports the following attributes, but it's // hard to tell which are really required for text input to // work well; I have not seen any input method make use of them yet. @@ -1215,47 +1371,86 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde } } -- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange +- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange replacementRange:(NSRange)replacementRange { - BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString - + [self _executeSavedKeypressCommands]; + + BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; + ASSERT(isAttributedString || [string isKindOfClass:[NSString class]]); + LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelRange.location, newSelRange.length); + + // Use pointer to get parameters passed to us by the caller of interpretKeyEvents. + WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; + + if (parameters) { + parameters->eventInterpretationHadSideEffects = true; + parameters->consumedByIM = false; + } - NSString *text = string; - + Vector<CompositionUnderline> underlines; + NSString *text; + if (isAttributedString) { + // FIXME: We ignore most attributes from the string, so an input method cannot specify e.g. a font or a glyph variation. text = [string string]; - extractUnderlines(string, _data->_underlines); + extractUnderlines(string, underlines); + } else + text = string; + + if (_data->_page->editorState().isInPasswordField) { + // In password fields, we only allow ASCII dead keys, and don't allow inline input, matching NSSecureTextInputField. + // Allowing ASCII dead keys is necessary to enable full Roman input when using a Vietnamese keyboard. + ASSERT(!_data->_page->editorState().hasComposition); + [[super inputContext] discardMarkedText]; // Inform the input method that we won't have an inline input area despite having been asked to. + if ([text length] == 1 && [[text decomposedStringWithCanonicalMapping] characterAtIndex:0] < 0x80) { + _data->_page->insertText(text, replacementRange.location, NSMaxRange(replacementRange)); + } else + NSBeep(); + return; } - - // We'd need a different code path here if we wanted to be able to handle this - // outside of interpretKeyEvents. - ASSERT(_data->_isInInterpretKeyEvents); - _data->_commandsList.append(KeypressCommand("setMarkedText", text)); - _data->_selectionStart = newSelRange.location; - _data->_selectionEnd = NSMaxRange(newSelRange); + _data->_page->setComposition(text, underlines, newSelRange.location, NSMaxRange(newSelRange), replacementRange.location, NSMaxRange(replacementRange)); } - (NSRange)markedRange { + [self _executeSavedKeypressCommands]; + uint64_t location; uint64_t length; - _data->_page->getMarkedRange(location, length); + LOG(TextInput, "markedRange -> (%u, %u)", location, length); return NSMakeRange(location, length); } -- (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange +- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)nsRange actualRange:(NSRangePointer)actualRange { - // This is not implemented for now. Need to figure out how to serialize the attributed string across processes. - LOG(TextInput, "attributedSubstringFromRange"); - return nil; + [self _executeSavedKeypressCommands]; + + if (!_data->_page->editorState().isContentEditable) { + LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length); + return nil; + } + + if (_data->_page->editorState().isInPasswordField) + return nil; + + AttributedString result; + _data->_page->getAttributedSubstringFromRange(nsRange.location, NSMaxRange(nsRange), result); + + if (actualRange) + *actualRange = nsRange; + + LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> \"%@\"", nsRange.location, nsRange.length, [result.string.get() string]); + return [[result.string.get() retain] autorelease]; } - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { + [self _executeSavedKeypressCommands]; + NSWindow *window = [self window]; if (window) @@ -1267,8 +1462,10 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde return result; } -- (NSRect)firstRectForCharacterRange:(NSRange)theRange +- (NSRect)firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange { + [self _executeSavedKeypressCommands]; + // Just to match NSTextView's behavior. Regression tests cannot detect this; // to reproduce, use a test application from http://bugs.webkit.org/show_bug.cgi?id=4682 // (type something; try ranges (1, -1) and (2, -1). @@ -1281,7 +1478,10 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde NSWindow *window = [self window]; if (window) resultRect.origin = [window convertBaseToScreen:resultRect.origin]; - + + if (actualRange) + *actualRange = theRange; + LOG(TextInput, "firstRectForCharacterRange:(%u, %u) -> (%f, %f, %f, %f)", theRange.location, theRange.length, resultRect.origin.x, resultRect.origin.y, resultRect.size.width, resultRect.size.height); return resultRect; } @@ -1318,7 +1518,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); _data->_page->resetDragOperation(); - _data->_page->performDragControllerAction(DragControllerActionEntered, &dragData, [[draggingInfo draggingPasteboard] name]); + _data->_page->dragEntered(&dragData, [[draggingInfo draggingPasteboard] name]); return NSDragOperationCopy; } @@ -1327,7 +1527,7 @@ 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->performDragControllerAction(DragControllerActionUpdated, &dragData, [[draggingInfo draggingPasteboard] name]); + _data->_page->dragUpdated(&dragData, [[draggingInfo draggingPasteboard] name]); return _data->_page->dragOperation(); } @@ -1336,7 +1536,7 @@ 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->performDragControllerAction(DragControllerActionExited, &dragData, [[draggingInfo draggingPasteboard] name]); + _data->_page->dragExited(&dragData, [[draggingInfo draggingPasteboard] name]); _data->_page->resetDragOperation(); } @@ -1345,15 +1545,53 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde return YES; } +// FIXME: This code is more or less copied from Pasteboard::getBestURL. +// It would be nice to be able to share the code somehow. +static void maybeCreateSandboxExtensionFromPasteboard(NSPasteboard *pasteboard, SandboxExtension::Handle& sandboxExtensionHandle) +{ + NSArray *types = [pasteboard types]; + if (![types containsObject:NSFilenamesPboardType]) + return; + + NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType]; + if ([files count] != 1) + return; + + NSString *file = [files objectAtIndex:0]; + BOOL isDirectory; + if (![[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory]) + return; + + if (isDirectory) + return; + + SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle); +} + - (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo { 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->performDragControllerAction(DragControllerActionPerformDrag, &dragData, [[draggingInfo draggingPasteboard] name]); + + SandboxExtension::Handle sandboxExtensionHandle; + maybeCreateSandboxExtensionFromPasteboard([draggingInfo draggingPasteboard], sandboxExtensionHandle); + + _data->_page->performDrag(&dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle); + return YES; } +// This code is needed to support drag and drop when the drag types cannot be matched. +// This is the case for elements that do not place content +// in the drag pasteboard automatically when the drag start (i.e. dragging a DIV element). +- (NSView *)_hitTest:(NSPoint *)point dragTypes:(NSSet *)types +{ + if ([[self superview] mouse:*point inRect:[self frame]]) + return self; + return nil; +} + - (void)_updateWindowVisibility { _data->_page->updateWindowIsVisible(![[self window] isMiniaturized]); @@ -1423,6 +1661,10 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde name:NSWindowDidMoveNotification object:window]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowFrameDidChange:) name:NSWindowDidResizeNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOffScreen:) + name:@"NSWindowDidOrderOffScreenNotification" object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOnScreen:) + name:@"_NSWindowDidBecomeVisible" object:window]; } } @@ -1438,6 +1680,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMoveNotification object:window]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window]; } - (void)viewWillMoveToWindow:(NSWindow *)window @@ -1492,15 +1736,19 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (void)_windowDidBecomeKey:(NSNotification *)notification { NSWindow *keyWindow = [notification object]; - if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet]) + if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet]) { + [self _updateSecureInputState]; _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); + } } - (void)_windowDidResignKey:(NSNotification *)notification { NSWindow *formerKeyWindow = [notification object]; - if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) + if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) { + [self _updateSecureInputState]; _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); + } } - (void)_windowDidMiniaturize:(NSNotification *)notification @@ -1518,6 +1766,16 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde [self _updateWindowAndViewFrames]; } +- (void)_windowDidOrderOffScreen:(NSNotification *)notification +{ + _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + +- (void)_windowDidOrderOnScreen:(NSNotification *)notification +{ + _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + static void drawPageBackground(CGContextRef context, WebPageProxy* page, const IntRect& rect) { if (!page->drawsBackground()) @@ -1667,6 +1925,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I // NSPrintOperation takes ownership of the view. NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printingView.get()]; [printOperation setCanSpawnSeparateThread:YES]; + [printOperation setJobTitle:toImpl(frameRef)->title()]; printingView->_printOperation = printOperation; return printOperation; } @@ -1706,14 +1965,6 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [self setNeedsDisplay:YES]; } -- (void)_takeFocus:(BOOL)forward -{ - if (forward) - [[self window] selectKeyViewFollowingView:self]; - else - [[self window] selectKeyViewPrecedingView:self]; -} - - (void)_setCursor:(NSCursor *)cursor { if ([NSCursor currentCursor] == cursor) @@ -1744,27 +1995,34 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_keyDownEventBeingResent = nullptr; } -- (Vector<KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent +- (BOOL)_interpretKeyEvent:(NSEvent *)event savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands { - ASSERT(!_data->_isInInterpretKeyEvents); + ASSERT(!_data->_interpretKeyEventsParameters); + ASSERT(commands.isEmpty()); - _data->_isInInterpretKeyEvents = true; - _data->_commandsList.clear(); + if ([event type] == NSFlagsChanged) + return NO; - // Calling interpretKeyEvents will trigger one or more calls to doCommandBySelector and insertText - // that will populate the commandsList vector. - [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; + WKViewInterpretKeyEventsParameters parameters; + parameters.eventInterpretationHadSideEffects = false; + parameters.executingSavedKeypressCommands = false; + // We assume that an input method has consumed the event, and only change this assumption if one of the NSTextInput methods is called. + // We assume the IM will *not* consume hotkey sequences. + parameters.consumedByIM = !([event modifierFlags] & NSCommandKeyMask); + parameters.commands = &commands; + _data->_interpretKeyEventsParameters = ¶meters; - _data->_isInInterpretKeyEvents = false; + [self interpretKeyEvents:[NSArray arrayWithObject:event]]; - return _data->_commandsList; -} + _data->_interpretKeyEventsParameters = 0; -- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<CompositionUnderline>&)lines -{ - start = _data->_selectionStart; - end = _data->_selectionEnd; - lines = _data->_underlines; + // An input method may consume an event and not tell us (e.g. when displaying a candidate window), + // in which case we should not bubble the event up the DOM. + if (parameters.consumedByIM) + return YES; + + // If we have already executed all or some of the commands, the event is "handled". Note that there are additional checks on web process side. + return parameters.eventInterpretationHadSideEffects; } - (NSRect)_convertToDeviceSpace:(NSRect)rect @@ -2010,6 +2268,22 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_pdfViewController->setZoomFactor(zoomFactor); } +- (void)_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count +{ + if (!_data->_pdfViewController) + return; + + _data->_pdfViewController->findString(string, options, count); +} + +- (void)_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count +{ + if (!_data->_pdfViewController) + return; + + _data->_pdfViewController->countStringMatches(string, options, count); +} + - (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag { // We need to prevent re-entering this call to avoid crashing in AppKit. @@ -2028,6 +2302,32 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_dragHasStarted = NO; } +- (void)_updateSecureInputState +{ + if (![[self window] isKeyWindow] || ([[self window] firstResponder] != self && !_data->_inBecomeFirstResponder)) { + if (_data->_inSecureInputState) { + DisableSecureEventInput(); + _data->_inSecureInputState = NO; + } + return; + } + // WKView has a single input context for all editable areas (except for plug-ins). + NSTextInputContext *context = [super inputContext]; + bool isInPasswordField = _data->_page->editorState().isInPasswordField; + + if (isInPasswordField) { + if (!_data->_inSecureInputState) + EnableSecureEventInput(); + static NSArray *romanInputSources = [[NSArray alloc] initWithObjects:&NSAllRomanInputSourcesLocaleIdentifier count:1]; + [context setAllowedInputSourceLocales:romanInputSources]; + } else { + if (_data->_inSecureInputState) + DisableSecureEventInput(); + [context setAllowedInputSourceLocales:nil]; + } + _data->_inSecureInputState = isInPasswordField; +} + - (void)_setDrawingAreaSize:(NSSize)size { if (!_data->_page->drawingArea()) @@ -2053,6 +2353,16 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I } #endif +- (bool)_executeSavedCommandBySelector:(SEL)selector +{ + // The sink does two things: 1) Tells us if the responder went unhandled, and + // 2) prevents any NSBeep; we don't ever want to beep here. + RetainPtr<WKResponderChainSink> sink(AdoptNS, [[WKResponderChainSink alloc] initWithResponderChain:self]); + [super doCommandBySelector:selector]; + [sink.get() detach]; + return ![sink.get() didReceiveUnhandledCommand]; +} + @end @implementation WKView (Private) @@ -2101,3 +2411,45 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I @end +@implementation WKResponderChainSink + +- (id)initWithResponderChain:(NSResponder *)chain +{ + self = [super init]; + if (!self) + return nil; + _lastResponderInChain = chain; + while (NSResponder *next = [_lastResponderInChain nextResponder]) + _lastResponderInChain = next; + [_lastResponderInChain setNextResponder:self]; + return self; +} + +- (void)detach +{ + [_lastResponderInChain setNextResponder:nil]; + _lastResponderInChain = nil; +} + +- (bool)didReceiveUnhandledCommand +{ + return _didReceiveUnhandledCommand; +} + +- (void)noResponderFor:(SEL)selector +{ + _didReceiveUnhandledCommand = true; +} + +- (void)doCommandBySelector:(SEL)selector +{ + _didReceiveUnhandledCommand = true; +} + +- (BOOL)tryToPerform:(SEL)action with:(id)object +{ + _didReceiveUnhandledCommand = true; + return YES; +} + +@end diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h index e4a40f7..82acdcf 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h @@ -24,22 +24,25 @@ */ #import "WKView.h" -#import <WebCore/Editor.h> -#import <WebCore/KeyboardEvent.h> +#import "WebFindOptions.h" +#import <wtf/Forward.h> +#import <wtf/Vector.h> namespace CoreIPC { class DataReference; } +namespace WebCore { + struct KeypressCommand; +} + namespace WebKit { class DrawingAreaProxy; class FindIndicator; class LayerTreeContext; } -#if ENABLE(FULLSCREEN_API) @class WKFullScreenWindowController; -#endif @interface WKView (Internal) - (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy; @@ -47,13 +50,12 @@ namespace WebKit { - (void)_processDidCrash; - (void)_pageClosed; - (void)_didRelaunchProcess; -- (void)_takeFocus:(BOOL)direction; - (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip; - (void)_setCursor:(NSCursor *)cursor; - (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState; -- (Vector<WebCore::KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent; -- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines; +- (BOOL)_interpretKeyEvent:(NSEvent *)theEvent savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands; - (void)_resendKeyDownEvent:(NSEvent *)event; +- (bool)_executeSavedCommandBySelector:(SEL)selector; - (NSRect)_convertToDeviceSpace:(NSRect)rect; - (NSRect)_convertToUserSpace:(NSRect)rect; - (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut; @@ -68,7 +70,10 @@ namespace WebKit { - (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference; - (double)_customRepresentationZoomFactor; - (void)_setCustomRepresentationZoomFactor:(double)zoomFactor; +- (void)_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count; +- (void)_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count; - (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag; +- (void)_updateSecureInputState; - (void)_setDrawingAreaSize:(NSSize)size; diff --git a/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp b/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp index 8197236..b427058 100644 --- a/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp @@ -165,6 +165,17 @@ void qt_wk_close(WKPageRef page, const void* clientInfo) emit toQWKPage(clientInfo)->windowCloseRequested(); } +void qt_wk_takeFocus(WKPageRef page, WKFocusDirection direction, const void *clientInfo) +{ + emit toQWKPage(clientInfo)->focusNextPrevChild(direction == kWKFocusDirectionForward); +} + void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo) { } + +void qt_wk_setStatusText(WKPageRef page, WKStringRef text, const void *clientInfo) +{ + QString qText = WKStringCopyQString(text); + emit toQWKPage(clientInfo)->statusBarMessage(qText); +} diff --git a/Source/WebKit2/UIProcess/API/qt/ClientImpl.h b/Source/WebKit2/UIProcess/API/qt/ClientImpl.h index 5d8c062..7955144 100644 --- a/Source/WebKit2/UIProcess/API/qt/ClientImpl.h +++ b/Source/WebKit2/UIProcess/API/qt/ClientImpl.h @@ -48,7 +48,9 @@ void qt_wk_didBecomeResponsive(WKPageRef, const void* clientInfo); WKPageRef qt_wk_createNewPage(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo); void qt_wk_showPage(WKPageRef page, const void *clientInfo); void qt_wk_close(WKPageRef page, const void *clientInfo); +void qt_wk_takeFocus(WKPageRef page, WKFocusDirection direction, const void *clientInfo); void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo); +void qt_wk_setStatusText(WKPageRef page, WKStringRef text, const void *clientInfo); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/qt/WKView.h b/Source/WebKit2/UIProcess/API/qt/WKView.h index 5bb95e8..57a5458 100644 --- a/Source/WebKit2/UIProcess/API/qt/WKView.h +++ b/Source/WebKit2/UIProcess/API/qt/WKView.h @@ -22,6 +22,7 @@ #include <WebKit2/qgraphicswkview.h> #include <WebKit2/qwkcontext.h> +#include <WebKit2/qwkhistory.h> #include <WebKit2/qwkpage.h> #include <WebKit2/qwkpreferences.h> diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp index 0381d73..d85ade3 100644 --- a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp @@ -50,6 +50,7 @@ struct QGraphicsWKViewPrivate { QGraphicsWKViewPrivate(QGraphicsWKView* view); WKPageRef pageRef() const { return page->pageRef(); } + void onToolTipChanged(const QString&); void onScaleChanged(); void commitScale(); @@ -84,6 +85,7 @@ QGraphicsWKView::QGraphicsWKView(QWKContext* context, BackingStoreType backingSt connect(d->page, SIGNAL(cursorChanged(const QCursor&)), this, SLOT(updateCursor(const QCursor&))); connect(d->page, SIGNAL(focusNextPrevChild(bool)), this, SLOT(focusNextPrevChildCallback(bool))); connect(d->page, SIGNAL(showContextMenu(QSharedPointer<QMenu>)), this, SLOT(showContextMenu(QSharedPointer<QMenu>))); + connect(d->page, SIGNAL(toolTipChanged(QString)), this, SLOT(onToolTipChanged(QString))); } QGraphicsWKView::~QGraphicsWKView() @@ -424,6 +426,11 @@ void QGraphicsWKViewPrivate::onScaleChanged() #endif } +void QGraphicsWKViewPrivate::onToolTipChanged(const QString& toolTip) +{ + q->setToolTip(toolTip); +} + void QGraphicsWKViewPrivate::commitScale() { #if ENABLE(TILED_BACKING_STORE) diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h index 03fc722..e4aecdd 100644 --- a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h @@ -90,7 +90,8 @@ protected: virtual void focusOutEvent(QFocusEvent*); private: - Q_PRIVATE_SLOT(d, void onScaleChanged()); + Q_PRIVATE_SLOT(d, void onScaleChanged()) + Q_PRIVATE_SLOT(d, void onToolTipChanged(const QString&)) QGraphicsWKViewPrivate* d; friend class QGraphicsWKViewPrivate; diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory.h b/Source/WebKit2/UIProcess/API/qt/qwkhistory.h index 81081c9..cf1c842 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkhistory.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory.h @@ -25,10 +25,10 @@ #ifndef qwkhistory_h #define qwkhistory_h +#include "WebKit2/WKBackForwardListItem.h" #include "qwebkitglobal.h" #include <QObject> #include <QSharedData> -#include "WKBackForwardListItem.h" class QWKHistoryPrivate; class QWKHistoryItemPrivate; @@ -49,7 +49,7 @@ public: QUrl url() const; private: - QWKHistoryItem(WKBackForwardListItemRef item); + QWKHistoryItem(WKBackForwardListItemRef); QExplicitlySharedDataPointer<QWKHistoryItemPrivate> d; diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp index a162918..7eb78da 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp @@ -34,6 +34,7 @@ #include "FindIndicator.h" #include "LocalizedStrings.h" #include "NativeWebKeyboardEvent.h" +#include "NativeWebMouseEvent.h" #include "NotImplemented.h" #include "TiledDrawingAreaProxy.h" #include "WebContext.h" @@ -125,11 +126,6 @@ void QWKPagePrivate::setViewportArguments(const ViewportArguments& args) emit q->viewportChangeRequested(); } -void QWKPagePrivate::takeFocus(bool direction) -{ - emit q->focusNextPrevChild(direction); -} - PassOwnPtr<DrawingAreaProxy> QWKPagePrivate::createDrawingAreaProxy() { // FIXME: We should avoid this cast by decoupling the view from the page. @@ -206,7 +202,7 @@ void QWKPagePrivate::didChangeContentsSize(const IntSize& newSize) void QWKPagePrivate::toolTipChanged(const String&, const String& newTooltip) { - emit q->statusBarMessage(QString(newTooltip)); + emit q->toolTipChanged(QString(newTooltip)); } void QWKPagePrivate::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) @@ -217,6 +213,15 @@ void QWKPagePrivate::clearAllEditCommands() { } +bool QWKPagePrivate::canUndoRedo(WebPageProxy::UndoOrRedo) +{ + return false; +} + +void QWKPagePrivate::executeUndoRedo(WebPageProxy::UndoOrRedo) +{ +} + FloatRect QWKPagePrivate::convertToDeviceSpace(const FloatRect& rect) { return rect; @@ -297,32 +302,27 @@ void QWKPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) return; lastPos = ev->pos(); - WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0); - page->handleMouseEvent(mouseEvent); + page->handleMouseEvent(NativeWebMouseEvent(ev, 0)); } void QWKPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev) { if (tripleClickTimer.isActive() && (ev->pos() - tripleClick).manhattanLength() < QApplication::startDragDistance()) { - WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 3); - page->handleMouseEvent(mouseEvent); + page->handleMouseEvent(NativeWebMouseEvent(ev, 3)); return; } - WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 1); - page->handleMouseEvent(mouseEvent); + page->handleMouseEvent(NativeWebMouseEvent(ev, 1)); } void QWKPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) { - WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0); - page->handleMouseEvent(mouseEvent); + page->handleMouseEvent(NativeWebMouseEvent(ev, 0)); } void QWKPagePrivate::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) { - WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 2); - page->handleMouseEvent(mouseEvent); + page->handleMouseEvent(NativeWebMouseEvent(ev, 2)); tripleClickTimer.start(QApplication::doubleClickInterval(), q); tripleClick = ev->pos().toPoint(); @@ -458,10 +458,13 @@ QWKPage::QWKPage(QWKContext* context) qt_wk_createNewPage, qt_wk_showPage, qt_wk_close, + qt_wk_takeFocus, + 0, /* focus */ + 0, /* unfocus */ qt_wk_runJavaScriptAlert, 0, /* runJavaScriptConfirm */ 0, /* runJavaScriptPrompt */ - 0, /* setStatusText */ + qt_wk_setStatusText, 0, /* mouseDidMoveOverElement */ 0, /* missingPluginButtonClicked */ 0, /* didNotHandleKeyEvent */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.h b/Source/WebKit2/UIProcess/API/qt/qwkpage.h index 48fdd9f..5dcfad2 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.h @@ -48,7 +48,7 @@ public: WebActionCount }; - class ViewportAttributes { + class QWEBKIT_EXPORT ViewportAttributes { public: ViewportAttributes(); ViewportAttributes(const QWKPage::ViewportAttributes& other); @@ -122,6 +122,7 @@ public: public: Q_SIGNAL void statusBarMessage(const QString&); + Q_SIGNAL void toolTipChanged(const QString&); Q_SIGNAL void titleChanged(const QString&); Q_SIGNAL void loadStarted(); Q_SIGNAL void loadFinished(bool ok); diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h index ee1fb0e..d2fd26b 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h @@ -71,11 +71,11 @@ public: virtual void didFindZoomableArea(const WebCore::IntRect&); virtual void setCursor(const WebCore::Cursor&); virtual void setViewportArguments(const WebCore::ViewportArguments&); - virtual void takeFocus(bool direction); - virtual void setFocus(bool focused) { } virtual void toolTipChanged(const WTF::String&, const WTF::String&); virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo); virtual void clearAllEditCommands(); + virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); + virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); @@ -94,7 +94,8 @@ public: virtual void didChangeScrollbarsForMainFrame() const { } virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); - + virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { } + virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { } virtual float userSpaceScaleFactor() const { return 1; } void paint(QPainter* painter, QRect); diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp index ad61d33..c93a6df 100644 --- a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp +++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp @@ -65,7 +65,8 @@ void DownloadProxy::cancel() if (!m_webContext) return; - m_webContext->process()->send(Messages::WebProcess::CancelDownload(m_downloadID), 0); + // FIXME (Multi-WebProcess): Downloads shouldn't be handled in the web process. + m_webContext->sendToAllProcesses(Messages::WebProcess::CancelDownload(m_downloadID)); } void DownloadProxy::invalidate() diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h index c72cf03..5ccb2fb 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h @@ -83,9 +83,10 @@ public: virtual void sizeDidChange() = 0; - // FIXME: visibilityDidChange() should be pure virtual. + // FIXME: These should be pure virtual. virtual void visibilityDidChange() { } - + virtual void setBackingStoreIsDiscardable(bool) { } + virtual void setPageIsVisible(bool isVisible) = 0; const WebCore::IntSize& size() const { return m_size; } diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp index 0ee42f4..0c5359a 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp @@ -52,6 +52,7 @@ DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy) , m_currentBackingStoreStateID(0) , m_nextBackingStoreStateID(0) , m_isWaitingForDidUpdateBackingStoreState(false) + , m_isBackingStoreDiscardable(true) , m_discardBackingStoreTimer(RunLoop::current(), this, &DrawingAreaProxyImpl::discardBackingStore) { } @@ -135,12 +136,31 @@ void DrawingAreaProxyImpl::visibilityDidChange() // Resume painting. m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID()); + +#if USE(ACCELERATED_COMPOSITING) + // If we don't have a backing store, go ahead and mark the backing store as being changed so + // that when paint we'll actually wait for something to paint and not flash white. + if (!m_backingStore && m_layerTreeContext.isEmpty()) + backingStoreStateDidChange(DoNotRespondImmediately); +#endif } void DrawingAreaProxyImpl::setPageIsVisible(bool) { } +void DrawingAreaProxyImpl::setBackingStoreIsDiscardable(bool isBackingStoreDiscardable) +{ + if (m_isBackingStoreDiscardable == isBackingStoreDiscardable) + return; + + m_isBackingStoreDiscardable = isBackingStoreDiscardable; + if (m_isBackingStoreDiscardable) + discardBackingStoreSoon(); + else + m_discardBackingStoreTimer.stop(); +} + void DrawingAreaProxyImpl::update(uint64_t backingStoreStateID, const UpdateInfo& updateInfo) { ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID); @@ -277,7 +297,7 @@ void DrawingAreaProxyImpl::waitForAndDispatchDidUpdateBackingStoreState() return; if (m_webPageProxy->process()->isLaunching()) return; - + #if USE(ACCELERATED_COMPOSITING) // FIXME: waitForAndDispatchImmediately will always return the oldest DidUpdateBackingStoreState message that // hasn't yet been processed. But it might be better to skip ahead to some other DidUpdateBackingStoreState @@ -311,6 +331,9 @@ void DrawingAreaProxyImpl::exitAcceleratedCompositingMode() void DrawingAreaProxyImpl::discardBackingStoreSoon() { + if (!m_isBackingStoreDiscardable) + return; + // We'll wait this many seconds after the last paint before throwing away our backing store to save memory. // FIXME: It would be smarter to make this delay based on how expensive painting is. See <http://webkit.org/b/55733>. static const double discardBackingStoreDelay = 5; diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h index 11e430c..5762264 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h @@ -54,6 +54,7 @@ private: virtual void sizeDidChange(); virtual void visibilityDidChange(); virtual void setPageIsVisible(bool); + virtual void setBackingStoreIsDiscardable(bool); // CoreIPC message handlers virtual void update(uint64_t backingStoreStateID, const UpdateInfo&); @@ -98,6 +99,7 @@ private: // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle. bool m_isWaitingForDidUpdateBackingStoreState; + bool m_isBackingStoreDiscardable; OwnPtr<BackingStore> m_backingStore; RunLoop::Timer<DrawingAreaProxyImpl> m_discardBackingStoreTimer; diff --git a/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp b/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp index 04d8a03..f877209 100644 --- a/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp +++ b/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp @@ -32,8 +32,9 @@ #include <WebCore/FileSystem.h> #include <WebCore/ResourceHandle.h> #include <errno.h> -#include <stdio.h> -#include <unistd.h> +#if OS(LINUX) +#include <sys/prctl.h> +#endif #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> #include <wtf/gobject/GOwnPtr.h> @@ -44,32 +45,46 @@ namespace WebKit { const char* gWebKitWebProcessName = "WebKitWebProcess"; +static void childSetupFunction(gpointer userData) +{ + int socket = GPOINTER_TO_INT(userData); + close(socket); + +#if OS(LINUX) + // Kill child process when parent dies. + prctl(PR_SET_PDEATHSIG, SIGKILL); +#endif +} + void ProcessLauncher::launchProcess() { - pid_t pid = 0; + GPid pid = 0; int sockets[2]; - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) { - fprintf(stderr, "Creation of socket failed with errno %d.\n", errno); + if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sockets) < 0) { + g_printerr("Creation of socket failed: %s.\n", g_strerror(errno)); ASSERT_NOT_REACHED(); return; } - pid = fork(); - if (!pid) { // child process - close(sockets[1]); - String socket = String::format("%d", sockets[0]); - GOwnPtr<gchar> binaryPath(g_build_filename(applicationDirectoryPath().data(), gWebKitWebProcessName, NULL)); - execl(binaryPath.get(), gWebKitWebProcessName, socket.utf8().data(), NULL); - } else if (pid > 0) { // parent process - close(sockets[0]); - m_processIdentifier = pid; - // We've finished launching the process, message back to the main run loop. - RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, pid, sockets[1])); - } else { - fprintf(stderr, "Unable to fork a new WebProcess with errno: %d.\n", errno); + GOwnPtr<gchar> binaryPath(g_build_filename(applicationDirectoryPath().data(), gWebKitWebProcessName, NULL)); + GOwnPtr<gchar> socket(g_strdup_printf("%d", sockets[0])); + char* argv[3]; + argv[0] = binaryPath.get(); + argv[1] = socket.get(); + argv[2] = 0; + + GOwnPtr<GError> error; + int spawnFlags = G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_DO_NOT_REAP_CHILD; + if (!g_spawn_async(0, argv, 0, static_cast<GSpawnFlags>(spawnFlags), childSetupFunction, GINT_TO_POINTER(sockets[1]), &pid, &error.outPtr())) { + g_printerr("Unable to fork a new WebProcess: %s.\n", error->message); ASSERT_NOT_REACHED(); } + + close(sockets[0]); + m_processIdentifier = pid; + // We've finished launching the process, message back to the main run loop. + RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, m_processIdentifier, sockets[1])); } void ProcessLauncher::terminateProcess() diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp index cae5bdf..5f3c99f 100644 --- a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp +++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp @@ -83,6 +83,16 @@ void QtWebProcess::setupChildProcess() #endif } +#if OS(SYMBIAN) +// FIXME: Symbian's POSIX layer doesn't have a socketpair(), so +// the following is just to fix the build until a pure Symbian +// IPC implementation lands on trunk +static int socketpair(int, int, int , int[2]) +{ + return -1; +} +#endif + void ProcessLauncher::launchProcess() { QString applicationPath = QLatin1String("%1 %2"); diff --git a/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp b/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp index 8981e80..03175b5 100644 --- a/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp +++ b/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp @@ -76,7 +76,9 @@ void ProcessLauncher::launchProcess() // FIXME: It would be nice if we could just create a CommandLine object and output a command line vector from it. Vector<UChar> commandLineVector; + append(commandLineVector, "\""); append(commandLineVector, commandLine); + append(commandLineVector, "\""); append(commandLineVector, " -type webprocess"); append(commandLineVector, " -clientIdentifier "); append(commandLineVector, String::number(reinterpret_cast<uintptr_t>(clientIdentifier))); diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h index 83ce502..7582152 100644 --- a/Source/WebKit2/UIProcess/PageClient.h +++ b/Source/WebKit2/UIProcess/PageClient.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 @@ -81,8 +81,6 @@ public: virtual void didRelaunchProcess() = 0; virtual void pageClosed() = 0; - virtual void setFocus(bool focused) = 0; - virtual void takeFocus(bool direction) = 0; virtual void toolTipChanged(const String&, const String&) = 0; #if ENABLE(TILED_BACKING_STORE) @@ -98,14 +96,21 @@ public: virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) = 0; virtual void clearAllEditCommands() = 0; + virtual bool canUndoRedo(WebPageProxy::UndoOrRedo) = 0; + virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) = 0; #if PLATFORM(MAC) virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0; - virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) = 0; + virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&) = 0; + virtual bool executeSavedCommandBySelector(const String& selector) = 0; virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0; + virtual void updateSecureInputState() = 0; #endif #if PLATFORM(WIN) virtual void compositionSelectionChanged(bool) = 0; #endif +#if PLATFORM(GTK) + virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, Vector<WTF::String>&) = 0; +#endif virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0; virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) = 0; @@ -124,12 +129,14 @@ public: #if PLATFORM(WIN) virtual HWND nativeWindow() = 0; + virtual void setGestureReachedScrollingLimit(bool) = 0; #endif #if PLATFORM(MAC) virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) = 0; virtual CGContextRef containingWindowGraphicsContext() = 0; virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&) = 0; + virtual void dismissDictionaryLookupPanel() = 0; virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) = 0; virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) = 0; virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel) = 0; @@ -145,6 +152,8 @@ public: virtual void setCustomRepresentationZoomFactor(double) = 0; virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects) = 0; + virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0; + virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0; virtual float userSpaceScaleFactor() const = 0; }; diff --git a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h index fc49d96..bcef7d6 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h @@ -35,6 +35,8 @@ namespace WebCore { namespace WebKit { class PluginInfoStore { + WTF_MAKE_NONCOPYABLE(PluginInfoStore); + public: PluginInfoStore(); diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp index c0aa8b3..fd81da5 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp @@ -45,14 +45,13 @@ PluginProcessManager::PluginProcessManager() { } -void PluginProcessManager::getPluginProcessConnection(const String& pluginPath, WebProcessProxy* webProcessProxy, CoreIPC::ArgumentEncoder* reply) +void PluginProcessManager::getPluginProcessConnection(PluginInfoStore* pluginInfoStore, const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply) { ASSERT(!pluginPath.isNull()); - PluginInfoStore::Plugin plugin = webProcessProxy->context()->pluginInfoStore()->infoForPluginWithPath(pluginPath); + PluginInfoStore::Plugin plugin = pluginInfoStore->infoForPluginWithPath(pluginPath); PluginProcessProxy* pluginProcess = getOrCreatePluginProcess(plugin); - - pluginProcess->createWebProcessConnection(webProcessProxy, reply); + pluginProcess->getPluginProcessConnection(reply); } void PluginProcessManager::removePluginProcessProxy(PluginProcessProxy* pluginProcessProxy) @@ -75,12 +74,28 @@ void PluginProcessManager::clearSiteData(const PluginInfoStore::Plugin& plugin, pluginProcess->clearSiteData(webPluginSiteDataManager, sites, flags, maxAgeInSeconds, callbackID); } -PluginProcessProxy* PluginProcessManager::getOrCreatePluginProcess(const PluginInfoStore::Plugin& plugin) +void PluginProcessManager::pluginSyncMessageSendTimedOut(const String& pluginPath) +{ + PluginProcessProxy* pluginProcess = pluginProcessWithPath(pluginPath); + if (!pluginProcess) + return; + + pluginProcess->terminate(); +} + +PluginProcessProxy* PluginProcessManager::pluginProcessWithPath(const String& pluginPath) { for (size_t i = 0; i < m_pluginProcesses.size(); ++i) { - if (m_pluginProcesses[i]->pluginInfo().path == plugin.path) + if (m_pluginProcesses[i]->pluginInfo().path == pluginPath) return m_pluginProcesses[i]; } + return 0; +} + +PluginProcessProxy* PluginProcessManager::getOrCreatePluginProcess(const PluginInfoStore::Plugin& plugin) +{ + if (PluginProcessProxy* pluginProcess = pluginProcessWithPath(plugin.path)) + return pluginProcess; PluginProcessProxy* pluginProcess = PluginProcessProxy::create(this, plugin).leakPtr(); m_pluginProcesses.append(pluginProcess); diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h index 79e5952..eaa7536 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h @@ -29,6 +29,7 @@ #if ENABLE(PLUGIN_PROCESS) #include "PluginInfoStore.h" +#include "WebProcessProxyMessages.h" #include <wtf/Forward.h> #include <wtf/Noncopyable.h> #include <wtf/Vector.h> @@ -39,6 +40,7 @@ namespace CoreIPC { namespace WebKit { +class PluginInfoStore; class PluginProcessProxy; class WebProcessProxy; class WebPluginSiteDataManager; @@ -48,16 +50,19 @@ class PluginProcessManager { public: static PluginProcessManager& shared(); - void getPluginProcessConnection(const String& pluginPath, WebProcessProxy*, CoreIPC::ArgumentEncoder* reply); + void getPluginProcessConnection(PluginInfoStore*, const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>); void removePluginProcessProxy(PluginProcessProxy*); void getSitesWithData(const PluginInfoStore::Plugin&, WebPluginSiteDataManager*, uint64_t callbackID); void clearSiteData(const PluginInfoStore::Plugin&, WebPluginSiteDataManager*, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); + void pluginSyncMessageSendTimedOut(const String& pluginPath); + private: PluginProcessManager(); PluginProcessProxy* getOrCreatePluginProcess(const PluginInfoStore::Plugin&); + PluginProcessProxy* pluginProcessWithPath(const String& pluginPath); Vector<PluginProcessProxy*> m_pluginProcesses; }; diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp index f167747..561c02b 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp @@ -28,7 +28,6 @@ #if ENABLE(PLUGIN_PROCESS) -#include "MachPort.h" #include "PluginProcessCreationParameters.h" #include "PluginProcessManager.h" #include "PluginProcessMessages.h" @@ -37,6 +36,10 @@ #include "WebPluginSiteDataManager.h" #include "WebProcessProxy.h" +#if PLATFORM(MAC) +#include "MachPort.h" +#endif + namespace WebKit { PassOwnPtr<PluginProcessProxy> PluginProcessProxy::create(PluginProcessManager* PluginProcessManager, const PluginInfoStore::Plugin& pluginInfo) @@ -51,6 +54,7 @@ PluginProcessProxy::PluginProcessProxy(PluginProcessManager* PluginProcessManage #if PLATFORM(MAC) , m_modalWindowIsShowing(false) , m_fullscreenWindowIsShowing(false) + , m_preFullscreenAppPresentationOptions(0) #endif { ProcessLauncher::LaunchOptions launchOptions; @@ -69,15 +73,15 @@ PluginProcessProxy::~PluginProcessProxy() // Asks the plug-in process to create a new connection to a web process. The connection identifier will be // encoded in the given argument encoder and sent back to the connection of the given web process. -void PluginProcessProxy::createWebProcessConnection(WebProcessProxy* webProcessProxy, CoreIPC::ArgumentEncoder* reply) +void PluginProcessProxy::getPluginProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply) { - m_pendingConnectionReplies.append(make_pair(webProcessProxy, reply)); + m_pendingConnectionReplies.append(reply); if (m_processLauncher->isLaunching()) { m_numPendingConnectionRequests++; return; } - + // Ask the plug-in process to create a connection. Since the plug-in can be waiting for a synchronous reply // we need to make sure that this message is always processed, even when the plug-in is waiting for a synchronus reply. m_connection->send(Messages::PluginProcess::CreateWebProcessConnection(), 0, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); @@ -116,17 +120,23 @@ void PluginProcessProxy::clearSiteData(WebPluginSiteDataManager* webPluginSiteDa m_connection->send(Messages::PluginProcess::ClearSiteData(sites, flags, maxAgeInSeconds, callbackID), 0); } +void PluginProcessProxy::terminate() +{ + m_processLauncher->terminateProcess(); +} + void PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch() { // The plug-in process must have crashed or exited, send any pending sync replies we might have. while (!m_pendingConnectionReplies.isEmpty()) { - RefPtr<WebProcessProxy> replyWebProcessProxy = m_pendingConnectionReplies.first().first.release(); - CoreIPC::ArgumentEncoder* reply = m_pendingConnectionReplies.first().second; - m_pendingConnectionReplies.removeFirst(); + RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst(); - // FIXME: This is Mac specific. - reply->encode(CoreIPC::MachPort(0, MACH_MSG_TYPE_MOVE_SEND)); - replyWebProcessProxy->connection()->sendSyncReply(reply); +#if PLATFORM(MAC) + reply->send(CoreIPC::MachPort(0, MACH_MSG_TYPE_MOVE_SEND)); +#else + // FIXME: Implement. + ASSERT_NOT_REACHED(); +#endif } while (!m_pendingGetSitesReplies.isEmpty()) @@ -162,6 +172,10 @@ void PluginProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC: { } +void PluginProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*) +{ +} + void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier) { ASSERT(!m_connection); @@ -200,19 +214,17 @@ void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connectio m_numPendingConnectionRequests = 0; } +#if PLATFORM(MAC) void PluginProcessProxy::didCreateWebProcessConnection(const CoreIPC::MachPort& machPort) { ASSERT(!m_pendingConnectionReplies.isEmpty()); // Grab the first pending connection reply. - RefPtr<WebProcessProxy> replyWebProcessProxy = m_pendingConnectionReplies.first().first.release(); - CoreIPC::ArgumentEncoder* reply = m_pendingConnectionReplies.first().second; - m_pendingConnectionReplies.removeFirst(); + RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst(); - // FIXME: This is Mac specific. - reply->encode(CoreIPC::MachPort(machPort.port(), MACH_MSG_TYPE_MOVE_SEND)); - replyWebProcessProxy->connection()->sendSyncReply(reply); + reply->send(CoreIPC::MachPort(machPort.port(), MACH_MSG_TYPE_MOVE_SEND)); } +#endif void PluginProcessProxy::didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID) { diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h index e285d64..59bfd90 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h @@ -31,6 +31,7 @@ #include "Connection.h" #include "PluginInfoStore.h" #include "ProcessLauncher.h" +#include "WebProcessProxyMessages.h" #include <wtf/Deque.h> #if PLATFORM(MAC) @@ -63,14 +64,17 @@ public: // Asks the plug-in process to create a new connection to a web process. The connection identifier will be // encoded in the given argument encoder and sent back to the connection of the given web process. - void createWebProcessConnection(WebProcessProxy*, CoreIPC::ArgumentEncoder* reply); - + void getPluginProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>); + // Asks the plug-in process to get a list of domains for which the plug-in has data stored. void getSitesWithData(WebPluginSiteDataManager*, uint64_t callbackID); // Asks the plug-in process to clear the data for the given sites. void clearSiteData(WebPluginSiteDataManager*, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); + // Terminates the plug-in process. + void terminate(); + private: PluginProcessProxy(PluginProcessManager*, const PluginInfoStore::Plugin&); @@ -80,13 +84,16 @@ private: virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); // ProcessLauncher::Client virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier); // Message handlers void didReceivePluginProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); +#if PLATFORM(MAC) void didCreateWebProcessConnection(const CoreIPC::MachPort&); +#endif void didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID); void didClearSiteData(uint64_t callbackID); @@ -120,7 +127,7 @@ private: // The process launcher for the plug-in host process. RefPtr<ProcessLauncher> m_processLauncher; - Deque<std::pair<RefPtr<WebProcessProxy>, CoreIPC::ArgumentEncoder*> > m_pendingConnectionReplies; + Deque<RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> > m_pendingConnectionReplies; Vector<uint64_t> m_pendingGetSitesRequests; HashMap<uint64_t, RefPtr<WebPluginSiteDataManager> > m_pendingGetSitesReplies; @@ -143,6 +150,7 @@ private: RetainPtr<WKPlaceholderModalWindow *> m_placeholderWindow; bool m_modalWindowIsShowing; bool m_fullscreenWindowIsShowing; + unsigned m_preFullscreenAppPresentationOptions; #endif }; diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in index 5fcbe71..7caac11 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in @@ -23,8 +23,9 @@ #if ENABLE(PLUGIN_PROCESS) messages -> PluginProcessProxy { - # FIXME: This is platform specific +#if PLATFORM(MAC) DidCreateWebProcessConnection(CoreIPC::MachPort connectionIdentifier) +#endif DidGetSitesWithData(Vector<WTF::String> sites, uint64_t callbackID) DidClearSiteData(uint64_t callbackID) diff --git a/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp index 5f56d0b..89620a1 100644 --- a/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp +++ b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp @@ -167,8 +167,10 @@ void WebPluginSiteDataManager::getSitesWithData(PassRefPtr<ArrayCallback> prpCal Vector<String> pluginPaths; m_webContext->pluginInfoStore()->getPluginPaths(pluginPaths); - m_webContext->ensureWebProcess(); - m_webContext->process()->send(Messages::WebProcess::GetSitesWithPluginData(pluginPaths, callbackID), 0); + + // FIXME (Multi-WebProcess): When multi-process is enabled, we must always use a plug-in process for this, + // so this code should just be removed. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebProcess::GetSitesWithPluginData(pluginPaths, callbackID)); #endif } @@ -226,8 +228,10 @@ void WebPluginSiteDataManager::clearSiteData(ImmutableArray* sites, uint64_t fla m_webContext->relaunchProcessIfNecessary(); Vector<String> pluginPaths; m_webContext->pluginInfoStore()->getPluginPaths(pluginPaths); - m_webContext->ensureWebProcess(); - m_webContext->process()->send(Messages::WebProcess::ClearPluginSiteData(pluginPaths, sitesVector, flags, maxAgeInSeconds, callbackID), 0); + + // FIXME (Multi-WebProcess): When multi-process is enabled, we must always use a plug-in process for this, + // so this code should just be removed. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebProcess::ClearPluginSiteData(pluginPaths, sitesVector, flags, maxAgeInSeconds, callbackID)); #endif } diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm index 8375fd2..c845a49 100644 --- a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm +++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm @@ -105,30 +105,37 @@ void PluginProcessProxy::setFullscreenWindowIsShowing(bool fullscreenWindowIsSho void PluginProcessProxy::enterFullscreen() { - [NSMenu setMenuBarVisible:NO]; + // Get the current presentation options. + m_preFullscreenAppPresentationOptions = [NSApp presentationOptions]; + // Figure out which presentation options to use. + unsigned presentationOptions = m_preFullscreenAppPresentationOptions & ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); + presentationOptions |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + + [NSApp setPresentationOptions:presentationOptions]; makePluginProcessTheFrontProcess(); } void PluginProcessProxy::exitFullscreen() { - [NSMenu setMenuBarVisible:YES]; - // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode. - ProcessSerialNumber frontProcessSerialNumber; GetFrontProcess(&frontProcessSerialNumber); - Boolean isSameProcess = 0; + + // The UI process must be the front process in order to change the presentation mode. + makeUIProcessTheFrontProcess(); + [NSApp setPresentationOptions:m_preFullscreenAppPresentationOptions]; ProcessSerialNumber pluginProcessSerialNumber; if (!getPluginProcessSerialNumber(pluginProcessSerialNumber)) return; - SameProcess(&frontProcessSerialNumber, &pluginProcessSerialNumber, &isSameProcess); - if (!isSameProcess) - return; - - makeUIProcessTheFrontProcess(); + // If the plug-in process was not the front process, switch back to the previous front process. + // (Otherwise we'll keep the UI process as the front process). + Boolean isPluginProcessFrontProcess; + SameProcess(&frontProcessSerialNumber, &pluginProcessSerialNumber, &isPluginProcessFrontProcess); + if (!isPluginProcessFrontProcess) + SetFrontProcess(&frontProcessSerialNumber); } void PluginProcessProxy::setModalWindowIsShowing(bool modalWindowIsShowing) diff --git a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp index f695969..f29fa4f 100644 --- a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp +++ b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp @@ -27,6 +27,7 @@ #include "PluginInfoStore.h" #include "NetscapePluginModule.h" +#include <WebCore/FileSystem.h> #include <WebCore/PathWalker.h> #include <shlwapi.h> @@ -339,9 +340,6 @@ static bool isNewWindowsMediaPlayerPlugin(const PluginInfoStore::Plugin& plugin) bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin) { - // FIXME: We should prefer a newer version of a plugin to an older version, rather than loading - // both. <http://webkit.org/b/49075> - if (plugin.info.name == "Citrix ICA Client") { // The Citrix ICA Client plug-in requires a Mozilla-based browser; see <rdar://6418681>. return false; @@ -393,6 +391,17 @@ bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin) return true; } + // FIXME: We should prefer a newer version of a plugin to an older version, rather than loading + // only the first. <http://webkit.org/b/58469> + String pluginFileName = pathGetFileName(plugin.path); + for (size_t i = 0; i < m_plugins.size(); ++i) { + Plugin& loadedPlugin = m_plugins[i]; + + // If a plug-in with the same filename already exists, we don't want to load it. + if (equalIgnoringCase(pluginFileName, pathGetFileName(loadedPlugin.path))) + return false; + } + return true; } diff --git a/Source/WebKit2/UIProcess/TextChecker.h b/Source/WebKit2/UIProcess/TextChecker.h index 7a5d535..69e2837 100644 --- a/Source/WebKit2/UIProcess/TextChecker.h +++ b/Source/WebKit2/UIProcess/TextChecker.h @@ -31,6 +31,7 @@ namespace WebKit { +class WebPageProxy; struct TextCheckerState; class TextChecker { @@ -50,16 +51,27 @@ public: static bool isSmartInsertDeleteEnabled(); static void setSmartInsertDeleteEnabled(bool); + + static bool substitutionsPanelIsShowing(); + static void toggleSubstitutionsPanelIsShowing(); +#elif PLATFORM(WIN) + static void continuousSpellCheckingEnabledStateChanged(bool); + static void grammarCheckingEnabledStateChanged(bool); #endif - static int64_t uniqueSpellDocumentTag(); + static int64_t uniqueSpellDocumentTag(WebPageProxy*); static void closeSpellDocumentWithTag(int64_t); - +#if USE(UNIFIED_TEXT_CHECKING) static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes); - static void updateSpellingUIWithMisspelledWord(const String& misspelledWord); - static void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&); +#endif + static void checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength); + static void checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength); + static bool spellingUIIsShowing(); + static void toggleSpellingUIIsShowing(); + static void updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord); + static void updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const WebCore::GrammarDetail&); static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses); - static void learnWord(const String& word); + static void learnWord(int64_t spellDocumentTag, const String& word); static void ignoreWord(int64_t spellDocumentTag, const String& word); }; diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp b/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp index 94b595a..912d05f 100644 --- a/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp +++ b/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp @@ -163,17 +163,19 @@ void VisitedLinkProvider::pendingVisitedLinksTimerFired() if (!m_table.sharedMemory()->createHandle(handle, SharedMemory::ReadOnly)) return; - m_context->process()->send(Messages::WebProcess::SetVisitedLinkTable(handle), 0); + // FIXME (Multi-WebProcess): Encoding a handle will null it out so we need to create a new + // handle for every process. Maybe the ArgumentEncoder should handle this. + m_context->sendToAllProcesses(Messages::WebProcess::SetVisitedLinkTable(handle)); } // We now need to let the web process know that we've added links. if (m_webProcessHasVisitedLinkState && addedVisitedLinks.size() <= 20) { - m_context->process()->send(Messages::WebProcess::VisitedLinkStateChanged(addedVisitedLinks), 0); + m_context->sendToAllProcesses(Messages::WebProcess::VisitedLinkStateChanged(addedVisitedLinks)); return; } // Just recalculate all the visited links. - m_context->process()->send(Messages::WebProcess::AllVisitedLinkStateChanged(), 0); + m_context->sendToAllProcesses(Messages::WebProcess::AllVisitedLinkStateChanged()); m_webProcessHasVisitedLinkState = true; } diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp index 6b24940..5ea62cd 100644 --- a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp @@ -65,11 +65,12 @@ void WebApplicationCacheManagerProxy::didReceiveMessage(CoreIPC::Connection* con void WebApplicationCacheManagerProxy::getApplicationCacheOrigins(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebApplicationCacheManager::GetApplicationCacheOrigins(callbackID), 0); + + // FIXME (Multi-WebProcess): The application cache shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebApplicationCacheManager::GetApplicationCacheOrigins(callbackID)); } void WebApplicationCacheManagerProxy::didGetApplicationCacheOrigins(const Vector<SecurityOriginData>& originDatas, uint64_t callbackID) @@ -80,20 +81,19 @@ void WebApplicationCacheManagerProxy::didGetApplicationCacheOrigins(const Vector void WebApplicationCacheManagerProxy::deleteEntriesForOrigin(WebSecurityOrigin* origin) { - m_webContext->relaunchProcessIfNecessary(); - SecurityOriginData securityOriginData; securityOriginData.protocol = origin->protocol(); securityOriginData.host = origin->host(); securityOriginData.port = origin->port(); - m_webContext->process()->send(Messages::WebApplicationCacheManager::DeleteEntriesForOrigin(securityOriginData), 0); + // FIXME (Multi-WebProcess): The application cache shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebApplicationCacheManager::DeleteEntriesForOrigin(securityOriginData)); } void WebApplicationCacheManagerProxy::deleteAllEntries() { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebApplicationCacheManager::DeleteAllEntries(), 0); + // FIXME (Multi-WebProcess): The application cache shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebApplicationCacheManager::DeleteAllEntries()); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp index 0609d68..c5d4abc 100644 --- a/Source/WebKit2/UIProcess/WebContext.cpp +++ b/Source/WebKit2/UIProcess/WebContext.cpp @@ -54,6 +54,7 @@ #include <WebCore/Language.h> #include <WebCore/LinkHash.h> #include <WebCore/Logging.h> +#include <WebCore/ResourceRequest.h> #include <wtf/CurrentTime.h> #ifndef NDEBUG @@ -111,8 +112,6 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa , m_visitedLinkProvider(this) , m_alwaysUsesComplexTextCodePath(false) , m_cacheModel(CacheModelDocumentViewer) - , m_clearResourceCachesForNewWebProcess(false) - , m_clearApplicationCacheForNewWebProcess(false) , m_memorySamplerEnabled(false) , m_memorySamplerInterval(1400.0) , m_applicationCacheManagerProxy(WebApplicationCacheManagerProxy::create(this)) @@ -128,6 +127,7 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa , m_shouldPaintNativeControls(true) , m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAlways) #endif + , m_processTerminationEnabled(true) { #ifndef NDEBUG WebKit::initializeLogChannelsIfNecessary(); @@ -193,11 +193,8 @@ void WebContext::initializeInjectedBundleClient(const WKContextInjectedBundleCli void WebContext::initializeHistoryClient(const WKContextHistoryClient* client) { m_historyClient.initialize(client); - - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()), 0); + + sendToAllProcesses(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks())); } void WebContext::initializeDownloadClient(const WKContextDownloadClient* client) @@ -212,10 +209,7 @@ void WebContext::languageChanged(void* context) void WebContext::languageChanged() { - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::LanguageChanged(defaultLanguage()), 0); + sendToAllProcesses(Messages::WebProcess::LanguageChanged(defaultLanguage())); } void WebContext::ensureWebProcess() @@ -241,14 +235,9 @@ void WebContext::ensureWebProcess() parameters.applicationCacheDirectory = applicationCacheDirectory(); parameters.databaseDirectory = databaseDirectory(); parameters.localStorageDirectory = localStorageDirectory(); - parameters.clearResourceCaches = m_clearResourceCachesForNewWebProcess; - parameters.clearApplicationCache = m_clearApplicationCacheForNewWebProcess; #if PLATFORM(MAC) parameters.presenterApplicationPid = getpid(); #endif - - m_clearResourceCachesForNewWebProcess = false; - m_clearApplicationCacheForNewWebProcess = false; copyToVector(m_schemesToRegisterAsEmptyDocument, parameters.urlSchemesRegistererdAsEmptyDocument); copyToVector(m_schemesToRegisterAsSecure, parameters.urlSchemesRegisteredAsSecure); @@ -274,11 +263,21 @@ void WebContext::ensureWebProcess() m_pendingMessagesToPostToInjectedBundle.clear(); } +void WebContext::enableProcessTermination() +{ + m_processTerminationEnabled = true; + if (shouldTerminate(m_process.get())) + m_process->terminate(); +} + bool WebContext::shouldTerminate(WebProcessProxy* process) { // FIXME: Once we support multiple processes per context, this assertion won't hold. ASSERT(process == m_process); + if (!m_processTerminationEnabled) + return false; + if (!m_downloads.isEmpty()) return false; @@ -348,10 +347,11 @@ void WebContext::disconnectProcess(WebProcessProxy* process) m_pluginSiteDataManager->invalidate(); #endif + // This can cause the web context to be destroyed. m_process = 0; } -WebPageProxy* WebContext::createWebPage(PageClient* pageClient, WebPageGroup* pageGroup) +PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient* pageClient, WebPageGroup* pageGroup) { ensureWebProcess(); @@ -361,17 +361,21 @@ WebPageProxy* WebContext::createWebPage(PageClient* pageClient, WebPageGroup* pa return m_process->createWebPage(pageClient, this, pageGroup); } -void WebContext::relaunchProcessIfNecessary() +WebProcessProxy* WebContext::relaunchProcessIfNecessary() { ensureWebProcess(); + + ASSERT(m_process); + return m_process.get(); } -void WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request) +DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request) { - uint64_t downloadID = createDownloadProxy(); + DownloadProxy* download = createDownloadProxy(); uint64_t initiatingPageID = initiatingPage ? initiatingPage->pageID() : 0; - process()->send(Messages::WebProcess::DownloadRequest(downloadID, initiatingPageID, request), 0); + process()->send(Messages::WebProcess::DownloadRequest(download->downloadID(), initiatingPageID, request), 0); + return download; } void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody) @@ -463,58 +467,36 @@ void WebContext::setAdditionalPluginsDirectory(const String& directory) void WebContext::setAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText) { m_alwaysUsesComplexTextCodePath = alwaysUseComplexText; - - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::SetAlwaysUsesComplexTextCodePath(alwaysUseComplexText), 0); + sendToAllProcesses(Messages::WebProcess::SetAlwaysUsesComplexTextCodePath(alwaysUseComplexText)); } void WebContext::registerURLSchemeAsEmptyDocument(const String& urlScheme) { m_schemesToRegisterAsEmptyDocument.add(urlScheme); - - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::RegisterURLSchemeAsEmptyDocument(urlScheme), 0); + sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsEmptyDocument(urlScheme)); } void WebContext::registerURLSchemeAsSecure(const String& urlScheme) { m_schemesToRegisterAsSecure.add(urlScheme); - - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme), 0); + sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme)); } void WebContext::setDomainRelaxationForbiddenForURLScheme(const String& urlScheme) { m_schemesToSetDomainRelaxationForbiddenFor.add(urlScheme); - - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme), 0); + sendToAllProcesses(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme)); } void WebContext::setCacheModel(CacheModel cacheModel) { m_cacheModel = cacheModel; - - if (!hasValidProcess()) - return; - m_process->send(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel)), 0); + sendToAllProcesses(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel))); } void WebContext::setDefaultRequestTimeoutInterval(double timeoutInterval) { - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::SetDefaultRequestTimeoutInterval(timeoutInterval), 0); + sendToAllProcesses(Messages::WebProcess::SetDefaultRequestTimeoutInterval(timeoutInterval)); } void WebContext::addVisitedLink(const String& visitedURL) @@ -561,14 +543,11 @@ void WebContext::didClearPluginSiteData(uint64_t callbackID) } #endif -uint64_t WebContext::createDownloadProxy() +DownloadProxy* WebContext::createDownloadProxy() { RefPtr<DownloadProxy> downloadProxy = DownloadProxy::create(this); - uint64_t downloadID = downloadProxy->downloadID(); - - m_downloads.set(downloadID, downloadProxy.release()); - - return downloadID; + m_downloads.set(downloadProxy->downloadID(), downloadProxy); + return downloadProxy.get(); } void WebContext::downloadFinished(DownloadProxy* downloadProxy) @@ -700,41 +679,9 @@ CoreIPC::SyncReplyMode WebContext::didReceiveSyncMessage(CoreIPC::Connection* co return CoreIPC::AutomaticReply; } -void WebContext::clearResourceCaches(ResourceCachesToClear cachesToClear) -{ - if (hasValidProcess()) { - m_process->send(Messages::WebProcess::ClearResourceCaches(cachesToClear), 0); - return; - } - - if (cachesToClear == InMemoryResourceCachesOnly) - return; - - // FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to - // clear the resource cache will be respected. But if the user quits the application before another WebProcess is created, - // their request will be ignored. - m_clearResourceCachesForNewWebProcess = true; -} - -void WebContext::clearApplicationCache() -{ - if (!hasValidProcess()) { - // FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to - // clear the application cache will be respected. But if the user quits the application before another WebProcess is created, - // their request will be ignored. - m_clearApplicationCacheForNewWebProcess = true; - return; - } - - m_process->send(Messages::WebProcess::ClearApplicationCache(), 0); -} - void WebContext::setEnhancedAccessibility(bool flag) { - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::SetEnhancedAccessibility(flag), 0); + sendToAllProcesses(Messages::WebProcess::SetEnhancedAccessibility(flag)); } void WebContext::startMemorySampler(const double interval) @@ -748,16 +695,13 @@ void WebContext::startMemorySampler(const double interval) WebMemorySampler::shared()->start(interval); #endif - if (!hasValidProcess()) - return; - // For WebProcess SandboxExtension::Handle sampleLogSandboxHandle; double now = WTF::currentTime(); String sampleLogFilePath = String::format("WebProcess%llu", static_cast<uint64_t>(now)); sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle); - m_process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, interval), 0); + sendToAllProcesses(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, interval)); } void WebContext::stopMemorySampler() @@ -769,11 +713,8 @@ void WebContext::stopMemorySampler() #if ENABLE(MEMORY_SAMPLER) WebMemorySampler::shared()->stop(); #endif - - if (!hasValidProcess()) - return; - - m_process->send(Messages::WebProcess::StopMemorySampler(), 0); + + sendToAllProcesses(Messages::WebProcess::StopMemorySampler()); } String WebContext::databaseDirectory() const @@ -806,4 +747,20 @@ String WebContext::localStorageDirectory() const return platformDefaultLocalStorageDirectory(); } +void WebContext::setHTTPPipeliningEnabled(bool enabled) +{ +#if PLATFORM(MAC) + ResourceRequest::setHTTPPipeliningEnabled(enabled); +#endif +} + +bool WebContext::httpPipeliningEnabled() +{ +#if PLATFORM(MAC) + return ResourceRequest::httpPipeliningEnabled(); +#else + return false; +#endif +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h index a9ba22f..676f1aa 100644 --- a/Source/WebKit2/UIProcess/WebContext.h +++ b/Source/WebKit2/UIProcess/WebContext.h @@ -75,20 +75,22 @@ public: ProcessModel processModel() const { return m_processModel; } WebProcessProxy* process() const { return m_process.get(); } - bool hasValidProcess() const { return m_process && m_process->isValid(); } + template<typename U> bool sendToAllProcesses(const U& message); + template<typename U> bool sendToAllProcessesRelaunchingThemIfNecessary(const U& message); + void processDidFinishLaunching(WebProcessProxy*); // Disconnect the process from the context. void disconnectProcess(WebProcessProxy*); - WebPageProxy* createWebPage(PageClient*, WebPageGroup*); + PassRefPtr<WebPageProxy> createWebPage(PageClient*, WebPageGroup*); - void relaunchProcessIfNecessary(); + WebProcessProxy* relaunchProcessIfNecessary(); const String& injectedBundlePath() const { return m_injectedBundlePath; } - void download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&); + DownloadProxy* download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&); void setInjectedBundleInitializationUserData(PassRefPtr<APIObject> userData) { m_injectedBundleInitializationUserData = userData; } APIObject* injectedBundleInitializationUserData() const { return m_injectedBundleInitializationUserData.get(); } @@ -120,8 +122,6 @@ public: void setCacheModel(CacheModel); CacheModel cacheModel() const { return m_cacheModel; } - void clearResourceCaches(ResourceCachesToClear); - void clearApplicationCache(); void setDefaultRequestTimeoutInterval(double); @@ -137,7 +137,7 @@ public: void setEnhancedAccessibility(bool); // Downloads. - uint64_t createDownloadProxy(); + DownloadProxy* createDownloadProxy(); WebDownloadClient& downloadClient() { return m_downloadClient; } void downloadFinished(DownloadProxy*); @@ -168,6 +168,13 @@ public: bool shouldTerminate(WebProcessProxy*); + void disableProcessTermination() { m_processTerminationEnabled = false; } + void enableProcessTermination(); + + // Defaults to false. + void setHTTPPipeliningEnabled(bool); + bool httpPipeliningEnabled(); + private: WebContext(ProcessModel, const String& injectedBundlePath); @@ -205,7 +212,7 @@ private: String localStorageDirectory() const; String platformDefaultLocalStorageDirectory() const; - + ProcessModel m_processModel; // FIXME: In the future, this should be one or more WebProcessProxies. @@ -234,9 +241,6 @@ private: WebDownloadClient m_downloadClient; HashMap<uint64_t, RefPtr<DownloadProxy> > m_downloads; - - bool m_clearResourceCachesForNewWebProcess; - bool m_clearApplicationCacheForNewWebProcess; bool m_memorySamplerEnabled; double m_memorySamplerInterval; @@ -263,8 +267,25 @@ private: String m_overrideDatabaseDirectory; String m_overrideIconDatabasePath; String m_overrideLocalStorageDirectory; + + bool m_processTerminationEnabled; }; +template<typename U> inline bool WebContext::sendToAllProcesses(const U& message) +{ + if (!m_process || !m_process->canSendMessage()) + return false; + + return m_process->send(message, 0); +} + +template<typename U> bool WebContext::sendToAllProcessesRelaunchingThemIfNecessary(const U& message) +{ + relaunchProcessIfNecessary(); + + return m_process->send(message, 0); +} + } // namespace WebKit #endif // WebContext_h diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp index a30ab41..e7b4a6a 100644 --- a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp @@ -73,11 +73,11 @@ void WebCookieManagerProxy::getHostnamesWithCookies(PassRefPtr<ArrayCallback> pr ASSERT(m_webContext); RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); - uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebCookieManager::GetHostnamesWithCookies(callbackID), 0); + + // FIXME (Multi-WebProcess): Cookies shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::GetHostnamesWithCookies(callbackID)); } void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hostnameList, uint64_t callbackID) @@ -100,30 +100,25 @@ void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hos void WebCookieManagerProxy::deleteCookiesForHostname(const String& hostname) { ASSERT(m_webContext); - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebCookieManager::DeleteCookiesForHostname(hostname), 0); + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::DeleteCookiesForHostname(hostname)); } void WebCookieManagerProxy::deleteAllCookies() { ASSERT(m_webContext); - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebCookieManager::DeleteAllCookies(), 0); + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::DeleteAllCookies()); } void WebCookieManagerProxy::startObservingCookieChanges() { ASSERT(m_webContext); - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebCookieManager::StartObservingCookieChanges(), 0); + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::StartObservingCookieChanges()); } void WebCookieManagerProxy::stopObservingCookieChanges() { ASSERT(m_webContext); - if (!m_webContext->hasValidProcess()) - return; - m_webContext->process()->send(Messages::WebCookieManager::StopObservingCookieChanges(), 0); + m_webContext->sendToAllProcesses(Messages::WebCookieManager::StopObservingCookieChanges()); } void WebCookieManagerProxy::cookiesDidChange() @@ -134,11 +129,11 @@ void WebCookieManagerProxy::cookiesDidChange() void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { ASSERT(m_webContext); - m_webContext->relaunchProcessIfNecessary(); #if PLATFORM(MAC) persistHTTPCookieAcceptPolicy(policy); #endif - m_webContext->process()->send(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy), 0); + + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy)); } void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(PassRefPtr<HTTPCookieAcceptPolicyCallback> prpCallback) @@ -146,11 +141,12 @@ void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(PassRefPtr<HTTPCookieAccep ASSERT(m_webContext); RefPtr<HTTPCookieAcceptPolicyCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); uint64_t callbackID = callback->callbackID(); m_httpCookieAcceptPolicyCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebCookieManager::GetHTTPCookieAcceptPolicy(callbackID), 0); + + // FIXME (Multi-WebProcess): Cookies shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::GetHTTPCookieAcceptPolicy(callbackID)); } void WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID) diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp index 67323cd..26c518f 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp @@ -116,12 +116,12 @@ void WebDatabaseManagerProxy::initializeClient(const WKDatabaseManagerClient* cl void WebDatabaseManagerProxy::getDatabasesByOrigin(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabasesByOrigin(callbackID), 0); -} + // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::GetDatabasesByOrigin(callbackID)); +} void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndDatabases>& originAndDatabasesVector, uint64_t callbackID) { @@ -169,10 +169,11 @@ void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndData void WebDatabaseManagerProxy::getDatabaseOrigins(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabaseOrigins(callbackID), 0); + + // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::GetDatabaseOrigins(callbackID)); } void WebDatabaseManagerProxy::didGetDatabaseOrigins(const Vector<String>& originIdentifiers, uint64_t callbackID) @@ -194,26 +195,26 @@ void WebDatabaseManagerProxy::didGetDatabaseOrigins(const Vector<String>& origin void WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, WebSecurityOrigin* origin) { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabaseWithNameForOrigin(databaseIdentifier, origin->databaseIdentifier()), 0); + // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::DeleteDatabaseWithNameForOrigin(databaseIdentifier, origin->databaseIdentifier())); } void WebDatabaseManagerProxy::deleteDatabasesForOrigin(WebSecurityOrigin* origin) { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabasesForOrigin(origin->databaseIdentifier()), 0); + // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::DeleteDatabasesForOrigin(origin->databaseIdentifier())); } void WebDatabaseManagerProxy::deleteAllDatabases() { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebDatabaseManager::DeleteAllDatabases(), 0); + // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::DeleteAllDatabases()); } void WebDatabaseManagerProxy::setQuotaForOrigin(WebSecurityOrigin* origin, uint64_t quota) { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebDatabaseManager::SetQuotaForOrigin(origin->databaseIdentifier(), quota), 0); + // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::SetQuotaForOrigin(origin->databaseIdentifier(), quota)); } void WebDatabaseManagerProxy::didModifyOrigin(const String& originIdentifier) diff --git a/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp b/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp index b9599f3..25ffe23 100644 --- a/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp +++ b/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp @@ -29,6 +29,8 @@ #include "WebPageMessages.h" #include "WebPageProxy.h" #include "WebProcessProxy.h" +#include <WebCore/LocalizedStrings.h> +#include <wtf/text/WTFString.h> using namespace WebCore; @@ -53,7 +55,7 @@ void WebEditCommandProxy::unapply() if (!m_page || !m_page->isValid()) return; - m_page->process()->send(Messages::WebPage::UnapplyEditCommand(m_commandID), m_page->pageID()); + m_page->process()->send(Messages::WebPage::UnapplyEditCommand(m_commandID), m_page->pageID(), CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); m_page->registerEditCommand(this, WebPageProxy::Redo); } @@ -62,8 +64,89 @@ void WebEditCommandProxy::reapply() if (!m_page || !m_page->isValid()) return; - m_page->process()->send(Messages::WebPage::ReapplyEditCommand(m_commandID), m_page->pageID()); + m_page->process()->send(Messages::WebPage::ReapplyEditCommand(m_commandID), m_page->pageID(), CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); m_page->registerEditCommand(this, WebPageProxy::Undo); } +String WebEditCommandProxy::nameForEditAction(EditAction editAction) +{ + switch (editAction) { + case EditActionUnspecified: + return String(); + case EditActionSetColor: + return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name"); + case EditActionSetBackgroundColor: + return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name"); + case EditActionTurnOffKerning: + return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name"); + case EditActionTightenKerning: + return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name"); + case EditActionLoosenKerning: + return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name"); + case EditActionUseStandardKerning: + return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name"); + case EditActionTurnOffLigatures: + return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name"); + case EditActionUseStandardLigatures: + return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name"); + case EditActionUseAllLigatures: + return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name"); + case EditActionRaiseBaseline: + return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name"); + case EditActionLowerBaseline: + return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name"); + case EditActionSetTraditionalCharacterShape: + return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name"); + case EditActionSetFont: + return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name"); + case EditActionChangeAttributes: + return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name"); + case EditActionAlignLeft: + return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name"); + case EditActionAlignRight: + return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name"); + case EditActionCenter: + return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name"); + case EditActionJustify: + return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name"); + case EditActionSetWritingDirection: + return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name"); + case EditActionSubscript: + return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name"); + case EditActionSuperscript: + return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name"); + case EditActionUnderline: + return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name"); + case EditActionOutline: + return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name"); + case EditActionUnscript: + return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name"); + case EditActionDrag: + return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name"); + case EditActionCut: + return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name"); + case EditActionPaste: + return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name"); + case EditActionPasteFont: + return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name"); + case EditActionPasteRuler: + return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name"); + case EditActionTyping: + return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name"); + case EditActionCreateLink: + return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name"); + case EditActionUnlink: + return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name"); + case EditActionInsertList: + return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name"); + case EditActionFormatBlock: + return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name"); + case EditActionIndent: + return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name"); + case EditActionOutdent: + return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name"); + } + return String(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebEditCommandProxy.h b/Source/WebKit2/UIProcess/WebEditCommandProxy.h index 4c08877..67d1430 100644 --- a/Source/WebKit2/UIProcess/WebEditCommandProxy.h +++ b/Source/WebKit2/UIProcess/WebEditCommandProxy.h @@ -28,6 +28,7 @@ #include "APIObject.h" #include <WebCore/EditAction.h> +#include <wtf/Forward.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -51,6 +52,8 @@ public: void unapply(); void reapply(); + static String nameForEditAction(WebCore::EditAction); + private: WebEditCommandProxy(uint64_t commandID, WebCore::EditAction, WebPageProxy*); diff --git a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp index 91daf10..f25bb41 100644 --- a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp @@ -31,7 +31,6 @@ #include "WebContext.h" #include "WebFullScreenManagerMessages.h" #include "WebFullScreenManagerProxyMessages.h" -#include "WebProcess.h" namespace WebKit { diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp index eae4935..14ab88a 100644 --- a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp @@ -61,8 +61,7 @@ void WebGeolocationManagerProxy::providerDidChangePosition(WebGeolocationPositio if (!m_context) return; - // FIXME: Should this check for a valid process? - m_context->process()->send(Messages::WebGeolocationManager::DidChangePosition(position->data()), 0); + m_context->sendToAllProcesses(Messages::WebGeolocationManager::DidChangePosition(position->data())); } void WebGeolocationManagerProxy::providerDidFailToDeterminePosition() @@ -70,8 +69,7 @@ void WebGeolocationManagerProxy::providerDidFailToDeterminePosition() if (!m_context) return; - // FIXME: Should this check for a valid process? - m_context->process()->send(Messages::WebGeolocationManager::DidFailToDeterminePosition(), 0); + m_context->sendToAllProcesses(Messages::WebGeolocationManager::DidFailToDeterminePosition()); } void WebGeolocationManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.cpp b/Source/WebKit2/UIProcess/WebIconDatabase.cpp index c397a1d..aecc34d 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabase.cpp +++ b/Source/WebKit2/UIProcess/WebIconDatabase.cpp @@ -100,14 +100,12 @@ void WebIconDatabase::enableDatabaseCleanup() void WebIconDatabase::retainIconForPageURL(const String& pageURL) { - LOG(IconDatabase, "WK2 UIProcess retaining icon for page URL %s", pageURL.ascii().data()); if (m_iconDatabaseImpl) m_iconDatabaseImpl->retainIconForPageURL(pageURL); } void WebIconDatabase::releaseIconForPageURL(const String& pageURL) { - LOG(IconDatabase, "WK2 UIProcess releasing icon for page URL %s", pageURL.ascii().data()); if (m_iconDatabaseImpl) m_iconDatabaseImpl->releaseIconForPageURL(pageURL); } @@ -157,7 +155,8 @@ void WebIconDatabase::getLoadDecisionForIconURL(const String& iconURL, uint64_t return; if (!m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || iconURL.isEmpty()) { - m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(IconLoadNo), callbackID), 0); + // FIXME (Multi-WebProcess): We need to know which connection to send this message to. + m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(IconLoadNo), callbackID)); return; } @@ -170,23 +169,40 @@ void WebIconDatabase::getLoadDecisionForIconURL(const String& iconURL, uint64_t m_pendingLoadDecisionURLMap.set(callbackID, iconURL); return; } - - m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision((int)decision, callbackID), 0); + + // FIXME (Multi-WebProcess): We need to know which connection to send this message to. + m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision((int)decision, callbackID)); } Image* WebIconDatabase::imageForPageURL(const String& pageURL) { - if (!m_webContext) - return 0; - - if (!m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || pageURL.isEmpty()) - return 0; + if (!m_webContext || !m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || pageURL.isEmpty()) + return 0; // The WebCore IconDatabase ignores the passed in size parameter. // If that changes we'll need to rethink how this API is exposed. return m_iconDatabaseImpl->synchronousIconForPageURL(pageURL, WebCore::IntSize(32, 32)); } +void WebIconDatabase::removeAllIcons() +{ + m_iconDatabaseImpl->removeAllIcons(); +} + +void WebIconDatabase::checkIntegrityBeforeOpening() +{ + IconDatabase::checkIntegrityBeforeOpening(); +} + +void WebIconDatabase::close() +{ + m_iconDatabaseImpl->close(); +} + +void WebIconDatabase::initializeIconDatabaseClient(const WKIconDatabaseClient* client) +{ + m_iconDatabaseClient.initialize(client); +} // WebCore::IconDatabaseClient bool WebIconDatabase::performImport() @@ -195,24 +211,24 @@ bool WebIconDatabase::performImport() return true; } -void WebIconDatabase::didImportIconURLForPageURL(const String&) +void WebIconDatabase::didImportIconURLForPageURL(const String& pageURL) { - // Send a WK2 client notification out here. + didChangeIconForPageURL(pageURL); } -void WebIconDatabase::didImportIconDataForPageURL(const String&) +void WebIconDatabase::didImportIconDataForPageURL(const String& pageURL) { - // Send a WK2 client notification out here. + didChangeIconForPageURL(pageURL); } -void WebIconDatabase::didChangeIconForPageURL(const String&) +void WebIconDatabase::didChangeIconForPageURL(const String& pageURL) { - // Send a WK2 client notification out here. + m_iconDatabaseClient.didChangeIconForPageURL(this, WebURL::create(pageURL).get()); } void WebIconDatabase::didRemoveAllIcons() { - // Send a WK2 client notification out here. + m_iconDatabaseClient.didRemoveAllIcons(this); } void WebIconDatabase::didFinishURLImport() @@ -234,7 +250,8 @@ void WebIconDatabase::didFinishURLImport() // Decisions should never be unknown after the inital import is complete ASSERT(decision != IconLoadUnknown); - m_webContext->process()->send(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(decision), i->first), 0); + // FIXME (Multi-WebProcess): We need to know which connection to send this message to. + m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(decision), i->first)); } m_pendingLoadDecisionURLMap.clear(); diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.h b/Source/WebKit2/UIProcess/WebIconDatabase.h index 802f2aa..91372d6 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabase.h +++ b/Source/WebKit2/UIProcess/WebIconDatabase.h @@ -29,6 +29,7 @@ #include "APIObject.h" #include "Connection.h" +#include "WebIconDatabaseClient.h" #include <WebCore/IconDatabaseClient.h> #include <wtf/Forward.h> #include <wtf/PassRefPtr.h> @@ -77,6 +78,12 @@ public: WebCore::Image* imageForPageURL(const String&); + void removeAllIcons(); + void checkIntegrityBeforeOpening(); + void close(); + + void initializeIconDatabaseClient(const WKIconDatabaseClient*); + // WebCore::IconDatabaseClient virtual bool performImport(); virtual void didImportIconURLForPageURL(const String&); @@ -103,6 +110,7 @@ private: bool m_databaseCleanupDisabled; HashMap<uint64_t, String> m_pendingLoadDecisionURLMap; + WebIconDatabaseClient m_iconDatabaseClient; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp new file mode 100644 index 0000000..e0de366 --- /dev/null +++ b/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebIconDatabaseClient.h" + +#include "WKAPICast.h" +#include "WKSharedAPICast.h" + +namespace WebKit { + +void WebIconDatabaseClient::didChangeIconForPageURL(WebIconDatabase* iconDatabase, WebURL* url) +{ + if (!m_client.didChangeIconForPageURL) + return; + + m_client.didChangeIconForPageURL(toAPI(iconDatabase), toAPI(url), m_client.clientInfo); +} + +void WebIconDatabaseClient::didRemoveAllIcons(WebIconDatabase* iconDatabase) +{ + if (!m_client.didRemoveAllIcons) + return; + + m_client.didRemoveAllIcons(toAPI(iconDatabase), m_client.clientInfo); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebIconDatabaseClient.h b/Source/WebKit2/UIProcess/WebIconDatabaseClient.h new file mode 100644 index 0000000..2311493 --- /dev/null +++ b/Source/WebKit2/UIProcess/WebIconDatabaseClient.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 WebIconDatabaseClient_h +#define WebIconDatabaseClient_h + +#include "APIClient.h" +#include "WKIconDatabase.h" + +namespace WebKit { + +class APIObject; +class WebIconDatabase; +class WebURL; + +class WebIconDatabaseClient : public APIClient<WKIconDatabaseClient> { +public: + void didChangeIconForPageURL(WebIconDatabase*, WebURL*); + void didRemoveAllIcons(WebIconDatabase*); +}; + +} // namespace WebKit + +#endif // WebIconDatabaseClient_h diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp index b971315..694e76a 100644 --- a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp +++ b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp @@ -46,7 +46,7 @@ namespace WebKit { WebPageGroup* WebInspectorProxy::inspectorPageGroup() { - static WebPageGroup* pageGroup = WebPageGroup::create("__WebInspectorPageGroup__", false).leakRef(); + static WebPageGroup* pageGroup = WebPageGroup::create("__WebInspectorPageGroup__", false, false).leakRef(); return pageGroup; } diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp index 1de1532..93b6fb9 100644 --- a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp @@ -65,11 +65,11 @@ void WebKeyValueStorageManagerProxy::didReceiveMessage(CoreIPC::Connection* conn void WebKeyValueStorageManagerProxy::getKeyValueStorageOrigins(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); - uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebKeyValueStorageManager::GetKeyValueStorageOrigins(callbackID), 0); + + // FIXME (Multi-WebProcess): Should key-value storage be handled in the web process? + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::GetKeyValueStorageOrigins(callbackID)); } void WebKeyValueStorageManagerProxy::didGetKeyValueStorageOrigins(const Vector<SecurityOriginData>& originDatas, uint64_t callbackID) @@ -80,20 +80,19 @@ void WebKeyValueStorageManagerProxy::didGetKeyValueStorageOrigins(const Vector<S void WebKeyValueStorageManagerProxy::deleteEntriesForOrigin(WebSecurityOrigin* origin) { - m_webContext->relaunchProcessIfNecessary(); - SecurityOriginData securityOriginData; securityOriginData.protocol = origin->protocol(); securityOriginData.host = origin->host(); securityOriginData.port = origin->port(); - m_webContext->process()->send(Messages::WebKeyValueStorageManager::DeleteEntriesForOrigin(securityOriginData), 0); + // FIXME (Multi-WebProcess): Should key-value storage be handled in the web process? + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::DeleteEntriesForOrigin(securityOriginData)); } void WebKeyValueStorageManagerProxy::deleteAllEntries() { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebKeyValueStorageManager::DeleteAllEntries(), 0); + // FIXME (Multi-WebProcess): Should key-value storage be handled in the web process? + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::DeleteAllEntries()); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp index c8a7f51..3b034d8 100644 --- a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp @@ -64,11 +64,12 @@ void WebMediaCacheManagerProxy::didReceiveMessage(CoreIPC::Connection* connectio void WebMediaCacheManagerProxy::getHostnamesWithMediaCache(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); - uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebMediaCacheManager::GetHostnamesWithMediaCache(callbackID), 0); + + // FIXME (Multi-WebProcess): When we're sending this to multiple processes, we need to aggregate the + // callback data when it comes back. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::GetHostnamesWithMediaCache(callbackID)); } void WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache(const Vector<String>& hostnameList, uint64_t callbackID) @@ -90,14 +91,12 @@ void WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache(const Vector<Strin void WebMediaCacheManagerProxy::clearCacheForHostname(const String& hostname) { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebMediaCacheManager::ClearCacheForHostname(hostname), 0); + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::ClearCacheForHostname(hostname)); } void WebMediaCacheManagerProxy::clearCacheForAllHostnames() { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebMediaCacheManager::ClearCacheForAllHostnames(), 0); + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::ClearCacheForAllHostnames()); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageGroup.cpp b/Source/WebKit2/UIProcess/WebPageGroup.cpp index f64dd2c..72588d4 100644 --- a/Source/WebKit2/UIProcess/WebPageGroup.cpp +++ b/Source/WebKit2/UIProcess/WebPageGroup.cpp @@ -47,9 +47,9 @@ static WebPageGroupMap& webPageGroupMap() return map; } -PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool visibleToInjectedBundle) +PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient) { - RefPtr<WebPageGroup> pageGroup = adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle)); + RefPtr<WebPageGroup> pageGroup = adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle, visibleToHistoryClient)); webPageGroupMap().set(pageGroup->pageGroupID(), pageGroup.get()); @@ -61,25 +61,23 @@ WebPageGroup* WebPageGroup::get(uint64_t pageGroupID) return webPageGroupMap().get(pageGroupID); } -WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle) +WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient) { m_data.pageGroupID = generatePageGroupID(); - if (!identifier.isNull()) { + if (!identifier.isNull()) m_data.identifer = identifier; - m_preferences = WebPreferences::create(identifier); - } else { + else m_data.identifer = m_data.identifer = makeString("__uniquePageGroupID-", String::number(m_data.pageGroupID)); - m_preferences = WebPreferences::create(); - } - m_preferences->addPageGroup(this); - m_data.visibleToInjectedBundle = visibleToInjectedBundle; + m_data.visibleToInjectedBundle = visibleToInjectedBundle; + m_data.visibleToHistoryClient = visibleToHistoryClient; } WebPageGroup::~WebPageGroup() { - m_preferences->removePageGroup(this); + if (m_preferences) + m_preferences->removePageGroup(this); webPageGroupMap().remove(pageGroupID()); } @@ -98,15 +96,27 @@ void WebPageGroup::setPreferences(WebPreferences* preferences) if (preferences == m_preferences) return; - m_preferences->removePageGroup(this); - m_preferences = preferences; - m_preferences->addPageGroup(this); + if (!m_preferences) { + m_preferences = preferences; + m_preferences->addPageGroup(this); + } else { + m_preferences->removePageGroup(this); + m_preferences = preferences; + m_preferences->addPageGroup(this); - preferencesDidChange(); + preferencesDidChange(); + } } WebPreferences* WebPageGroup::preferences() const { + if (!m_preferences) { + if (!m_data.identifer.isNull()) + m_preferences = WebPreferences::create(m_data.identifer); + else + m_preferences = WebPreferences::create(); + m_preferences->addPageGroup(const_cast<WebPageGroup*>(this)); + } return m_preferences.get(); } diff --git a/Source/WebKit2/UIProcess/WebPageGroup.h b/Source/WebKit2/UIProcess/WebPageGroup.h index 7859dfc..ccc14bd 100644 --- a/Source/WebKit2/UIProcess/WebPageGroup.h +++ b/Source/WebKit2/UIProcess/WebPageGroup.h @@ -40,7 +40,7 @@ class WebPageGroup : public APIObject { public: static const Type APIType = TypePageGroup; - static PassRefPtr<WebPageGroup> create(const String& identifier = String(), bool visibleToInjectedBundle = true); + static PassRefPtr<WebPageGroup> create(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true); static WebPageGroup* get(uint64_t pageGroupID); virtual ~WebPageGroup(); @@ -58,12 +58,12 @@ public: void preferencesDidChange(); private: - WebPageGroup(const String& identifier, bool visibleToInjectedBundle); + WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient); virtual Type type() const { return APIType; } WebPageGroupData m_data; - RefPtr<WebPreferences> m_preferences; + mutable RefPtr<WebPreferences> m_preferences; HashSet<WebPageProxy*> m_pages; }; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index ce3af46..aabb304 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -29,10 +29,12 @@ #include "AuthenticationChallengeProxy.h" #include "AuthenticationDecisionListener.h" #include "DataReference.h" +#include "DownloadProxy.h" #include "DrawingAreaProxy.h" #include "FindIndicator.h" #include "MessageID.h" #include "NativeWebKeyboardEvent.h" +#include "NativeWebMouseEvent.h" #include "PageClient.h" #include "PrintInfo.h" #include "SessionState.h" @@ -69,6 +71,7 @@ #include "WebURLRequest.h" #include <WebCore/DragData.h> #include <WebCore/FloatRect.h> +#include <WebCore/FocusDirection.h> #include <WebCore/MIMETypeRegistry.h> #include <WebCore/WindowFeatures.h> #include <stdio.h> @@ -100,14 +103,14 @@ WKPageDebugPaintFlags WebPageProxy::s_debugPaintFlags = 0; static WTF::RefCountedLeakCounter webPageProxyCounter("WebPageProxy"); #endif -PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup, uint64_t pageID) +PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID) { - return adoptRef(new WebPageProxy(pageClient, context, pageGroup, pageID)); + return adoptRef(new WebPageProxy(pageClient, process, pageGroup, pageID)); } -WebPageProxy::WebPageProxy(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup, uint64_t pageID) +WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID) : m_pageClient(pageClient) - , m_context(context) + , m_process(process) , m_pageGroup(pageGroup) , m_mainFrame(0) , m_userAgent(standardUserAgent()) @@ -162,6 +165,9 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, WebContext* context, WebPageG WebPageProxy::~WebPageProxy() { + if (!m_isClosed) + close(); + WebContext::statistics().wkPageCount--; if (m_hasSpellDocumentTag) @@ -176,7 +182,7 @@ WebPageProxy::~WebPageProxy() WebProcessProxy* WebPageProxy::process() const { - return m_context->process(); + return m_process.get(); } bool WebPageProxy::isValid() @@ -239,9 +245,11 @@ void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* cl void WebPageProxy::reattachToWebProcess() { + ASSERT(!isValid()); + m_isValid = true; - context()->relaunchProcessIfNecessary(); + m_process = m_process->context()->relaunchProcessIfNecessary(); process()->addExistingWebPage(this, m_pageID); initializeWebPage(); @@ -524,7 +532,7 @@ bool WebPageProxy::canShowMIMEType(const String& mimeType) const return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType); String newMimeType = mimeType; - PluginInfoStore::Plugin plugin = context()->pluginInfoStore()->findPlugin(newMimeType, KURL()); + PluginInfoStore::Plugin plugin = m_process->context()->pluginInfoStore()->findPlugin(newMimeType, KURL()); if (!plugin.path.isNull()) return true; @@ -609,6 +617,9 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags) process()->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID); } } + + if (flags & (ViewWindowIsActive | ViewIsVisible)) + m_drawingArea->setBackingStoreIsDiscardable(!m_pageClient->isViewWindowActive() || !isViewVisible()); } IntSize WebPageProxy::viewSize() const @@ -664,6 +675,28 @@ String WebPageProxy::getSelectedText() process()->sendSync(Messages::WebPage::GetSelectedText(), Messages::WebPage::GetSelectedText::Reply(text), m_pageID); return text; } + +bool WebPageProxy::gestureWillBegin(const IntPoint& point) +{ + bool canBeginPanning = false; + process()->sendSync(Messages::WebPage::GestureWillBegin(point), Messages::WebPage::GestureWillBegin::Reply(canBeginPanning), m_pageID); + return canBeginPanning; +} + +void WebPageProxy::gestureDidScroll(const IntSize& size) +{ + process()->send(Messages::WebPage::GestureDidScroll(size), m_pageID); +} + +void WebPageProxy::gestureDidEnd() +{ + process()->send(Messages::WebPage::GestureDidEnd(), m_pageID); +} + +void WebPageProxy::setGestureReachedScrollingLimit(bool limitReached) +{ + m_pageClient->setGestureReachedScrollingLimit(limitReached); +} #endif #if ENABLE(TILED_BACKING_STORE) @@ -676,7 +709,30 @@ void WebPageProxy::setActualVisibleContentRect(const IntRect& rect) } #endif -void WebPageProxy::performDragControllerAction(DragControllerAction action, WebCore::DragData* dragData, const String& dragStorageName) +void WebPageProxy::dragEntered(WebCore::DragData* dragData, const String& dragStorageName) +{ + SandboxExtension::Handle sandboxExtensionHandle; + performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle); +} + +void WebPageProxy::dragUpdated(WebCore::DragData* dragData, const String& dragStorageName) +{ + SandboxExtension::Handle sandboxExtensionHandle; + performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle); +} + +void WebPageProxy::dragExited(WebCore::DragData* dragData, const String& dragStorageName) +{ + SandboxExtension::Handle sandboxExtensionHandle; + performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle); +} + +void WebPageProxy::performDrag(WebCore::DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle) +{ + performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle); +} + +void WebPageProxy::performDragControllerAction(DragControllerAction action, WebCore::DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle) { if (!isValid()) return; @@ -685,7 +741,7 @@ void WebPageProxy::performDragControllerAction(DragControllerAction action, WebC process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragData->dragDataMap(), dragData->flags()), m_pageID); #else - process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags()), m_pageID); + process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle), m_pageID); #endif } @@ -758,7 +814,7 @@ void WebPageProxy::dragEnded(const WebCore::IntPoint& clientPosition, const WebC process()->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID); } -void WebPageProxy::handleMouseEvent(const WebMouseEvent& event) +void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event) { if (!isValid()) return; @@ -768,13 +824,20 @@ void WebPageProxy::handleMouseEvent(const WebMouseEvent& event) process()->responsivenessTimer()->start(); else { if (m_processingMouseMoveEvent) { - m_nextMouseMoveEvent = adoptPtr(new WebMouseEvent(event)); + m_nextMouseMoveEvent = adoptPtr(new NativeWebMouseEvent(event)); return; } m_processingMouseMoveEvent = true; } + // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we + // display a popup menu for select elements. When the user changes the selected item, + // we fake a mouse up event by using this stored down event. This event gets cleared + // when the mouse up message is received from WebProcess. + if (event.type() == WebEvent::MouseDown) + m_currentlyProcessedMouseDownEvent = adoptPtr(new NativeWebMouseEvent(event)); + process()->send(Messages::WebPage::MouseEvent(event), m_pageID); } @@ -860,7 +923,7 @@ void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* fr uint64_t downloadID = 0; if (action == PolicyDownload) { // Create a download proxy. - downloadID = context()->createDownloadProxy(); + downloadID = m_process->context()->createDownloadProxy()->downloadID(); } // If we received a policy decision while in decidePolicyForMIMEType the decision will @@ -1077,6 +1140,9 @@ void WebPageProxy::viewScaleFactorDidChange(double scaleFactor) void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsEnabled) { + if (!isValid()) + return; + if (m_areMemoryCacheClientCallsEnabled == memoryCacheClientCallsEnabled) return; @@ -1086,7 +1152,10 @@ void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsE void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount) { - process()->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID); + if (m_mainFrameHasCustomRepresentation) + m_pageClient->findStringInCustomRepresentation(string, options, maxMatchCount); + else + process()->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID); } void WebPageProxy::hideFindUI() @@ -1096,12 +1165,25 @@ void WebPageProxy::hideFindUI() void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount) { + if (m_mainFrameHasCustomRepresentation) { + m_pageClient->countStringMatchesInCustomRepresentation(string, options, maxMatchCount); + return; + } + + if (!isValid()) + return; + process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID); } void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback) { RefPtr<ScriptValueCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_scriptValueCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID); @@ -1110,6 +1192,11 @@ void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<Scr void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback) { RefPtr<StringCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_stringCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID); @@ -1118,6 +1205,11 @@ void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback) { RefPtr<StringCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_loadDependentStringCallbackIDs.add(callbackID); m_stringCallbacks.set(callbackID, callback.get()); @@ -1127,6 +1219,11 @@ void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCall void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback) { RefPtr<StringCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_loadDependentStringCallbackIDs.add(callbackID); m_stringCallbacks.set(callbackID, callback.get()); @@ -1136,6 +1233,11 @@ void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback) void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback) { RefPtr<StringCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_stringCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID); @@ -1144,6 +1246,11 @@ void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prp void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback) { RefPtr<DataCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_dataCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID); @@ -1152,6 +1259,11 @@ void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<D void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback) { RefPtr<DataCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_dataCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID); @@ -1160,6 +1272,11 @@ void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resour void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback) { RefPtr<DataCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_dataCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID); @@ -1168,7 +1285,6 @@ void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCal void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback) { RefPtr<VoidCallback> callback = prpCallback; - if (!isValid()) { callback->invalidate(); return; @@ -1358,7 +1474,7 @@ void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const Strin clearPendingAPIRequestURL(); RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1374,7 +1490,7 @@ void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const Strin void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String& url, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1389,7 +1505,7 @@ void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t f void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1417,12 +1533,13 @@ void WebPageProxy::clearLoadDependentCallbacks() void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo& certificateInfo, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored); + m_pageClient->dismissDictionaryLookupPanel(); #endif WebFrameProxy* frame = process()->webFrame(frameID); @@ -1443,7 +1560,7 @@ void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeTyp void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1456,7 +1573,7 @@ void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::Argu void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1471,7 +1588,7 @@ void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDeco void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1488,7 +1605,7 @@ void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& er void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1503,7 +1620,7 @@ void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1518,7 +1635,7 @@ void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1531,7 +1648,7 @@ void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDec void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1544,7 +1661,7 @@ void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, Core void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1559,7 +1676,7 @@ void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::Argume void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1572,7 +1689,7 @@ void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC:: void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1596,7 +1713,7 @@ void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value) void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1633,7 +1750,7 @@ void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t op void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1652,7 +1769,7 @@ void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opa void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1682,7 +1799,7 @@ void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceRespo void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError& error, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1697,7 +1814,7 @@ void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const WebCore::Reso void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -1825,7 +1942,7 @@ void WebPageProxy::setStatusText(const String& text) void WebPageProxy::mouseDidMoveOverElement(uint32_t opaqueModifiers, CoreIPC::ArgumentDecoder* arguments) { RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -2025,9 +2142,22 @@ void WebPageProxy::backForwardForwardListCount(int32_t& count) count = m_backForwardList->forwardListCount(); } -void WebPageProxy::selectionStateChanged(const SelectionState& selectionState) +void WebPageProxy::editorStateChanged(const EditorState& editorState) { - m_selectionState = selectionState; +#if PLATFORM(MAC) + bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone; +#endif + + m_editorState = editorState; + +#if PLATFORM(MAC) + // This is a temporary state. Flipping secure input state too quickly can expose race conditions. + if (editorState.selectionIsNone) + return; + + if (couldChangeSecureInputState) + m_pageClient->updateSecureInputState(); +#endif } #if PLATFORM(WIN) @@ -2054,6 +2184,17 @@ void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editA registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo); } +void WebPageProxy::canUndoRedo(uint32_t action, bool& result) +{ + result = m_pageClient->canUndoRedo(static_cast<UndoOrRedo>(action)); +} + +void WebPageProxy::executeUndoRedo(uint32_t action, bool& result) +{ + m_pageClient->executeUndoRedo(static_cast<UndoOrRedo>(action)); + result = true; +} + void WebPageProxy::clearAllEditCommands() { m_pageClient->clearAllEditCommands(); @@ -2090,6 +2231,11 @@ void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index process()->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID); } +NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent() +{ + return m_currentlyProcessedMouseDownEvent.get(); +} + void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data) { if (m_activePopupMenu) { @@ -2122,8 +2268,16 @@ void WebPageProxy::hidePopupMenu() void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const ContextMenuState& contextMenuState, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments) { + internalShowContextMenu(menuLocation, contextMenuState, proposedItems, arguments); + + // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again. + process()->send(Messages::WebPage::ContextMenuHidden(), m_pageID); +} + +void WebPageProxy::internalShowContextMenu(const IntPoint& menuLocation, const ContextMenuState& contextMenuState, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments) +{ RefPtr<APIObject> userData; - WebContextUserMessageDecoder messageDecoder(userData, context()); + WebContextUserMessageDecoder messageDecoder(userData, m_process->context()); if (!arguments->decode(messageDecoder)) return; @@ -2185,13 +2339,17 @@ void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item) process()->updateTextCheckerState(); return; } + if (item.action() == ContextMenuItemTagShowSubstitutions) { + TextChecker::toggleSubstitutionsPanelIsShowing(); + return; + } #endif if (item.action() == ContextMenuItemTagDownloadImageToDisk) { - m_context->download(this, KURL(KURL(), m_activeContextMenuState.absoluteImageURLString)); + m_process->context()->download(this, KURL(KURL(), m_activeContextMenuState.absoluteImageURLString)); return; } if (item.action() == ContextMenuItemTagDownloadLinkToDisk) { - m_context->download(this, KURL(KURL(), m_activeContextMenuState.absoluteLinkURLString)); + m_process->context()->download(this, KURL(KURL(), m_activeContextMenuState.absoluteLinkURLString)); return; } if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) { @@ -2204,6 +2362,12 @@ void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item) process()->updateTextCheckerState(); return; } + if (item.action() == ContextMenuItemTagShowSpellingPanel) { + if (!TextChecker::spellingUIIsShowing()) + advanceToNextMisspelling(true); + TextChecker::toggleSpellingUIIsShowing(); + return; + } if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling) ++m_pendingLearnOrIgnoreWordMessageCount; @@ -2242,12 +2406,12 @@ void WebPageProxy::didCancelForOpenPanel() m_openPanelResultListener = 0; } -void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection) +void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection) const { process()->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID); } -void WebPageProxy::changeSpellingToWord(const String& word) +void WebPageProxy::changeSpellingToWord(const String& word) const { if (word.isEmpty()) return; @@ -2255,16 +2419,6 @@ void WebPageProxy::changeSpellingToWord(const String& word) process()->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID); } -void WebPageProxy::unmarkAllMisspellings() -{ - process()->send(Messages::WebPage::UnmarkAllMisspellings(), m_pageID); -} - -void WebPageProxy::unmarkAllBadGrammar() -{ - process()->send(Messages::WebPage::UnmarkAllBadGrammar(), m_pageID); -} - void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo) { m_pageClient->registerEditCommand(commandProxy, undoOrRedo); @@ -2292,26 +2446,45 @@ bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command) int64_t WebPageProxy::spellDocumentTag() { if (!m_hasSpellDocumentTag) { - m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(); + m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(this); m_hasSpellDocumentTag = true; } return m_spellDocumentTag; } +#if USE(UNIFIED_TEXT_CHECKING) + void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results) { results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes); } +#endif + +void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength) +{ + TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength); +} + +void WebPageProxy::checkGrammarOfString(const String& text, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength) +{ + TextChecker::checkGrammarOfString(spellDocumentTag(), text.characters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength); +} + +void WebPageProxy::spellingUIIsShowing(bool& isShowing) +{ + isShowing = TextChecker::spellingUIIsShowing(); +} + void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord) { - TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord); + TextChecker::updateSpellingUIWithMisspelledWord(spellDocumentTag(), misspelledWord); } void WebPageProxy::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail) { - TextChecker::updateSpellingUIWithGrammarString(badGrammarPhrase, grammarDetail); + TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail); } void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) @@ -2324,7 +2497,7 @@ void WebPageProxy::learnWord(const String& word) MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount); --m_pendingLearnOrIgnoreWordMessageCount; - TextChecker::learnWord(word); + TextChecker::learnWord(spellDocumentTag(), word); } void WebPageProxy::ignoreWord(const String& word) @@ -2339,12 +2512,15 @@ void WebPageProxy::ignoreWord(const String& word) void WebPageProxy::setFocus(bool focused) { - m_pageClient->setFocus(focused); + if (focused) + m_uiClient.focus(this); + else + m_uiClient.unfocus(this); } -void WebPageProxy::takeFocus(bool direction) +void WebPageProxy::takeFocus(uint32_t direction) { - m_pageClient->takeFocus(direction); + m_uiClient.takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward); } void WebPageProxy::setToolTip(const String& toolTip) @@ -2364,6 +2540,7 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled) WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType); switch (type) { + case WebEvent::NoType: case WebEvent::MouseMove: break; @@ -2383,6 +2560,8 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled) } switch (type) { + case WebEvent::NoType: + break; case WebEvent::MouseMove: m_processingMouseMoveEvent = false; if (m_nextMouseMoveEvent) { @@ -2391,12 +2570,14 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled) } break; case WebEvent::MouseDown: - case WebEvent::MouseUp: #if ENABLE(GESTURE_EVENTS) case WebEvent::GestureScrollBegin: case WebEvent::GestureScrollEnd: #endif break; + case WebEvent::MouseUp: + m_currentlyProcessedMouseDownEvent = nullptr; + break; case WebEvent::Wheel: { m_processingWheelEvent = false; @@ -2421,7 +2602,12 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled) if (handled) break; - m_uiClient.didNotHandleKeyEvent(this, event); + if (m_uiClient.implementsDidNotHandleKeyEvent()) + m_uiClient.didNotHandleKeyEvent(this, event); +#if PLATFORM(WIN) + else + ::TranslateMessage(event.nativeEvent()); +#endif break; } } @@ -2542,30 +2728,26 @@ void WebPageProxy::processDidCrash() m_isValid = false; - if (m_mainFrame) - m_urlAtProcessExit = m_mainFrame->url(); - - m_mainFrame = 0; - + m_mainFrame = nullptr; m_drawingArea = nullptr; #if ENABLE(INSPECTOR) if (m_inspector) { m_inspector->invalidate(); - m_inspector = 0; + m_inspector = nullptr; } #endif #if ENABLE(FULLSCREEN_API) if (m_fullScreenManager) { m_fullScreenManager->invalidate(); - m_fullScreenManager = 0; + m_fullScreenManager = nullptr; } #endif if (m_openPanelResultListener) { m_openPanelResultListener->invalidate(); - m_openPanelResultListener = 0; + m_openPanelResultListener = nullptr; } m_geolocationPermissionRequestManager.invalidateRequests(); @@ -2601,6 +2783,17 @@ void WebPageProxy::processDidCrash() m_pageClient->processDidCrash(); m_loaderClient.processDidCrash(this); + + // Can't expect DidReceiveEvent notifications from a crashed web process. + m_keyEventQueue.clear(); + m_nextWheelEvent = nullptr; + m_nextMouseMoveEvent = nullptr; + m_currentlyProcessedMouseDownEvent = nullptr; + +#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) + dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored); + m_pageClient->dismissDictionaryLookupPanel(); +#endif } WebPageCreationParameters WebPageProxy::creationParameters() const @@ -2764,8 +2957,14 @@ void WebPageProxy::endPrinting() process()->send(Messages::WebPage::EndPrinting(), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0); } -void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<ComputedPagesCallback> callback) +void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<ComputedPagesCallback> prpCallback) { + RefPtr<ComputedPagesCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_computedPagesCallbacks.set(callbackID, callback.get()); m_isInPrintingMode = true; @@ -2773,15 +2972,27 @@ void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo } #if PLATFORM(MAC) || PLATFORM(WIN) -void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const IntRect& rect, PassRefPtr<DataCallback> callback) +void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const IntRect& rect, PassRefPtr<DataCallback> prpCallback) { + RefPtr<DataCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_dataCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::DrawRectToPDF(frame->frameID(), rect, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0); } -void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, uint32_t first, uint32_t count, PassRefPtr<DataCallback> callback) +void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback) { + RefPtr<DataCallback> callback = prpCallback; + if (!isValid()) { + callback->invalidate(); + return; + } + uint64_t callbackID = callback->callbackID(); m_dataCallbacks.set(callbackID, callback.get()); process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0); @@ -2808,7 +3019,19 @@ void WebPageProxy::saveDataToFileInDownloadsFolder(const String& suggestedFilena m_uiClient.saveDataToFileInDownloadsFolder(this, suggestedFilename, mimeType, originatingURLString, data); } -#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) +void WebPageProxy::linkClicked(const String& url, const WebMouseEvent& event) +{ + process()->send(Messages::WebPage::LinkClicked(url, event), m_pageID, 0); +} + +#if PLATFORM(MAC) + +void WebPageProxy::substitutionsPanelIsShowing(bool& isShowing) +{ + isShowing = TextChecker::substitutionsPanelIsShowing(); +} + +#if !defined(BUILDING_ON_SNOW_LEOPARD) void WebPageProxy::showCorrectionPanel(int32_t panelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) { m_pageClient->showCorrectionPanel((WebCore::CorrectionPanelInfo::PanelType)panelType, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings); @@ -2828,9 +3051,8 @@ void WebPageProxy::recordAutocorrectionResponse(int32_t responseType, const Stri { m_pageClient->recordAutocorrectionResponse((WebCore::EditorClient::AutocorrectionResponseType)responseType, replacedString, replacementString); } -#endif +#endif // !defined(BUILDING_ON_SNOW_LEOPARD) -#if PLATFORM(MAC) void WebPageProxy::handleCorrectionPanelResult(const String& result) { #if !defined(BUILDING_ON_SNOW_LEOPARD) @@ -2838,6 +3060,6 @@ void WebPageProxy::handleCorrectionPanelResult(const String& result) process()->send(Messages::WebPage::HandleCorrectionPanelResult(result), m_pageID, 0); #endif } -#endif +#endif // PLATFORM(MAC) } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index e3e62d4..bea43b5 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -31,9 +31,9 @@ #include "ContextMenuState.h" #include "DragControllerAction.h" #include "DrawingAreaProxy.h" +#include "EditorState.h" #include "GeolocationPermissionRequestManagerProxy.h" #include "SandboxExtension.h" -#include "SelectionState.h" #include "SharedMemory.h" #include "WKBase.h" #include "WKPagePrivate.h" @@ -78,6 +78,7 @@ namespace WebCore { namespace WebKit { class NativeWebKeyboardEvent; +class NativeWebMouseEvent; class PageClient; class PlatformCertificateInfo; class StringPairVector; @@ -94,7 +95,9 @@ class WebPageGroup; class WebProcessProxy; class WebURLRequest; class WebWheelEvent; +struct AttributedString; struct DictionaryPopupInfo; +struct EditorState; struct PlatformPopupMenuData; struct PrintInfo; struct WebPageCreationParameters; @@ -156,7 +159,7 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client { public: static const Type APIType = TypePage; - static PassRefPtr<WebPageProxy> create(PageClient*, WebContext*, WebPageGroup*, uint64_t pageID); + static PassRefPtr<WebPageProxy> create(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID); virtual ~WebPageProxy(); uint64_t pageID() const { return m_pageID; } @@ -239,23 +242,34 @@ public: WebCore::IntSize viewSize() const; bool isViewVisible() const { return m_isVisible; } + bool isViewWindowActive() const; void executeEditCommand(const String& commandName); void validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback>); - const SelectionState& selectionState() const { return m_selectionState; } + const EditorState& editorState() const { return m_editorState; } bool canDelete() const { return hasSelectedRange() && isContentEditable(); } - bool hasSelectedRange() const { return m_selectionState.selectedRangeLength; } - bool isContentEditable() const { return m_selectionState.isContentEditable; } + bool hasSelectedRange() const { return m_editorState.selectionIsRange; } + bool isContentEditable() const { return m_editorState.isContentEditable; } #if PLATFORM(MAC) void updateWindowIsVisible(bool windowIsVisible); void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates); + + void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd); + void confirmComposition(); + bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd); void getMarkedRange(uint64_t& location, uint64_t& length); + void getSelectedRange(uint64_t& location, uint64_t& length); + void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&); uint64_t characterIndexForPoint(const WebCore::IntPoint); WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t); + bool executeKeypressCommands(const Vector<WebCore::KeypressCommand>&); + void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput); CGContextRef containingWindowGraphicsContext(); + bool shouldDelayWindowOrderingForEvent(const WebMouseEvent&); + bool acceptsFirstMouse(int eventNumber, const WebMouseEvent&); #endif #if PLATFORM(WIN) void didChangeCompositionSelection(bool); @@ -263,12 +277,18 @@ public: void setComposition(const String&, Vector<WebCore::CompositionUnderline>&, int); WebCore::IntRect firstRectForCharacterInSelectedRange(int); String getSelectedText(); + + bool gestureWillBegin(const WebCore::IntPoint&); + void gestureDidScroll(const WebCore::IntSize&); + void gestureDidEnd(); + + void setGestureReachedScrollingLimit(bool); #endif #if ENABLE(TILED_BACKING_STORE) void setActualVisibleContentRect(const WebCore::IntRect& rect); #endif - void handleMouseEvent(const WebMouseEvent&); + void handleMouseEvent(const NativeWebMouseEvent&); void handleWheelEvent(const WebWheelEvent&); void handleKeyboardEvent(const NativeWebKeyboardEvent&); #if ENABLE(GESTURE_EVENTS) @@ -340,6 +360,10 @@ public: void findString(const String&, FindOptions, unsigned maxMatchCount); void hideFindUI(); void countStringMatches(const String&, FindOptions, unsigned maxMatchCount); + void didCountStringMatches(const String&, uint32_t matchCount); + void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut); + void didFindString(const String&, uint32_t matchCount); + void didFailToFindString(const String&); void getContentsAsString(PassRefPtr<StringCallback>); void getMainResourceDataOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>); @@ -366,7 +390,11 @@ public: void backForwardRemovedItem(uint64_t itemID); // Drag and drop support. - void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& = String()); + void dragEntered(WebCore::DragData*, const String& dragStorageName = String()); + void dragUpdated(WebCore::DragData*, const String& dragStorageName = String()); + void dragExited(WebCore::DragData*, const String& dragStorageName = String()); + void performDrag(WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&); + void didPerformDragControllerAction(uint64_t resultOperation); void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation); #if PLATFORM(MAC) @@ -396,7 +424,6 @@ public: void registerEditCommand(PassRefPtr<WebEditCommandProxy>, UndoOrRedo); WebProcessProxy* process() const; - WebContext* context() const { return m_context.get(); } WebPageGroup* pageGroup() const { return m_pageGroup.get(); } @@ -405,9 +432,6 @@ public: WebCore::DragOperation dragOperation() { return m_currentDragOperation; } void resetDragOperation() { m_currentDragOperation = WebCore::DragOperationNone; } - // REMOVE: For demo purposes only. - const String& urlAtProcessExit() const { return m_urlAtProcessExit; } - void preferencesDidChange(); #if ENABLE(TILED_BACKING_STORE) @@ -427,10 +451,8 @@ public: void findZoomableAreaForPoint(const WebCore::IntPoint&); #endif - void advanceToNextMisspelling(bool startBeforeSelection); - void changeSpellingToWord(const String& word); - void unmarkAllMisspellings(); - void unmarkAllBadGrammar(); + void advanceToNextMisspelling(bool startBeforeSelection) const; + void changeSpellingToWord(const String& word) const; #if PLATFORM(MAC) void uppercaseWord(); void lowercaseWord(); @@ -467,14 +489,17 @@ public: void saveDataToFileInDownloadsFolder(const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData*); + void linkClicked(const String&, const WebMouseEvent&); + private: - WebPageProxy(PageClient*, WebContext*, WebPageGroup*, uint64_t pageID); + WebPageProxy(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID); virtual Type type() const { return APIType; } // WebPopupMenuProxy::Client virtual void valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex); virtual void setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index); + virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent(); // Implemented in generated WebPageProxyMessageReceiver.cpp void didReceiveWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); @@ -564,8 +589,7 @@ private: void didFindZoomableArea(const WebCore::IntRect&); #endif - // Selection - void selectionStateChanged(const SelectionState&); + void editorStateChanged(const EditorState&); // Back/Forward list management void backForwardAddItem(uint64_t itemID); @@ -578,24 +602,33 @@ private: // Undo management void registerEditCommandForUndo(uint64_t commandID, uint32_t editAction); void clearAllEditCommands(); + void canUndoRedo(uint32_t action, bool& result); + void executeUndoRedo(uint32_t action, bool& result); // Keyboard handling #if PLATFORM(MAC) - void interpretKeyEvent(uint32_t eventType, Vector<WebCore::KeypressCommand>&, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines); + void interpretQueuedKeyEvent(const EditorState&, bool& handled, Vector<WebCore::KeypressCommand>&); + void executeSavedCommandBySelector(const String& selector, bool& handled); +#endif + +#if PLATFORM(GTK) + void getEditorCommandsForKeyEvent(Vector<String>&); #endif - - // Find. - void didCountStringMatches(const String&, uint32_t matchCount); - void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut); - void didFindString(const String&, uint32_t matchCount); - void didFailToFindString(const String&); // Popup Menu. void showPopupMenu(const WebCore::IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData&); void hidePopupMenu(); +#if PLATFORM(WIN) + void setPopupMenuSelectedIndex(int32_t); +#endif // Context Menu. void showContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*); + void internalShowContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*); + + // Search popup results + void saveRecentSearches(const String&, const Vector<String>&); + void loadRecentSearches(const String&, Vector<String>&); #if PLATFORM(MAC) // Speech. @@ -603,13 +636,21 @@ private: void speak(const String&); void stopSpeaking(); + // Spotlight. + void searchWithSpotlight(const String&); + // Dictionary. void didPerformDictionaryLookup(const String&, const DictionaryPopupInfo&); #endif // Spelling and grammar. int64_t spellDocumentTag(); +#if USE(UNIFIED_TEXT_CHECKING) void checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results); +#endif + void checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength); + void checkGrammarOfString(const String& text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength); + void spellingUIIsShowing(bool&); void updateSpellingUIWithMisspelledWord(const String& misspelledWord); void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&); void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses); @@ -617,7 +658,7 @@ private: void ignoreWord(const String& word); void setFocus(bool focused); - void takeFocus(bool direction); + void takeFocus(uint32_t direction); void setToolTip(const String&); void setCursor(const WebCore::Cursor&); @@ -649,15 +690,20 @@ private: void initializeSandboxExtensionHandle(const WebCore::KURL&, SandboxExtension::Handle&); -#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(MAC) + void substitutionsPanelIsShowing(bool&); +#if !defined(BUILDING_ON_SNOW_LEOPARD) void showCorrectionPanel(int32_t panelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); void dismissCorrectionPanel(int32_t reason); void dismissCorrectionPanelSoon(int32_t reason, String& result); void recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString); -#endif +#endif // !defined(BUILDING_ON_SNOW_LEOPARD) +#endif // PLATFORM(MAC) void clearLoadDependentCallbacks(); + void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&); + PageClient* m_pageClient; WebLoaderClient m_loaderClient; WebPolicyClient m_policyClient; @@ -668,7 +714,7 @@ private: WebPageContextMenuClient m_contextMenuClient; OwnPtr<DrawingAreaProxy> m_drawingArea; - RefPtr<WebContext> m_context; + RefPtr<WebProcessProxy> m_process; RefPtr<WebPageGroup> m_pageGroup; RefPtr<WebFrameProxy> m_mainFrame; RefPtr<WebFrameProxy> m_focusedFrame; @@ -717,10 +763,7 @@ private: String m_toolTip; - SelectionState m_selectionState; - - // REMOVE: For demo purposes only. - String m_urlAtProcessExit; + EditorState m_editorState; double m_textZoomFactor; double m_pageZoomFactor; @@ -758,7 +801,8 @@ private: OwnPtr<WebWheelEvent> m_nextWheelEvent; bool m_processingMouseMoveEvent; - OwnPtr<WebMouseEvent> m_nextMouseMoveEvent; + OwnPtr<NativeWebMouseEvent> m_nextMouseMoveEvent; + OwnPtr<NativeWebMouseEvent> m_currentlyProcessedMouseDownEvent; uint64_t m_pageID; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index e145d82..f5f4238 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -36,7 +36,7 @@ messages -> WebPageProxy { SetStatusText(WTF::String statusText) SetToolTip(WTF::String toolTip) SetFocus(bool focused) - TakeFocus(bool direction) + TakeFocus(uint32_t direction) FocusedFrameChanged(uint64_t frameID) FrameSetLargestFrameChanged(uint64_t frameID) SetToolbarsAreVisible(bool toolbarsAreVisible) @@ -126,17 +126,11 @@ messages -> WebPageProxy { ViewScaleFactorDidChange(double scaleFactor) -#if PLATFORM(MAC) - # Dictionary support. - DidPerformDictionaryLookup(WTF::String text, WebKit::DictionaryPopupInfo dictionaryPopupInfo) - - # Keyboard support messages - InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline> underlines) - - # Remote accessibility messages - RegisterWebProcessAccessibilityToken(CoreIPC::DataReference data) +#if PLATFORM(GTK) + # Support for GTK+ platform keybindings + GetEditorCommandsForKeyEvent() -> (Vector<WTF::String> commandsList) #endif - + # BackForward messages BackForwardAddItem(uint64_t itemID) BackForwardGoToItem(uint64_t itemID) @@ -149,10 +143,11 @@ messages -> WebPageProxy { # Undo/Redo messages RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction) ClearAllEditCommands() - - # Selection messages - SelectionStateChanged(WebKit::SelectionState selectionState) + CanUndoRedo(uint32_t action) -> (bool result) + ExecuteUndoRedo(uint32_t action) -> (bool result) + # Editor notifications + EditorStateChanged(WebKit::EditorState editorState) #if PLATFORM(WIN) DidChangeCompositionSelection(bool hasChanged) #endif @@ -166,7 +161,10 @@ messages -> WebPageProxy { # PopupMenu messages ShowPopupMenu(WebCore::IntRect rect, uint64_t textDirection, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data) HidePopupMenu() - +#if PLATFORM(WIN) + SetPopupMenuSelectedIndex(int32_t selectedIndex) +#endif + # ContextMenu messages ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::ContextMenuState state, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData) @@ -180,20 +178,13 @@ messages -> WebPageProxy { # Geolocation messages RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier) -#if PLATFORM(MAC) - # Plug-in complex text input support messages - SetComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) -#endif - -#if PLATFORM(MAC) - # Speech messages - GetIsSpeaking() -> (bool isSpeaking) - Speak(WTF::String string) - StopSpeaking() -#endif - # Spelling and grammar messages +#if USE(UNIFIED_TEXT_CHECKING) CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results) +#endif + CheckSpellingOfString(WTF::String text) -> (int32_t misspellingLocation, int32_t misspellingLength) + CheckGrammarOfString(WTF::String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength) + SpellingUIIsShowing() -> (bool isShowing) UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord) UpdateSpellingUIWithGrammarString(WTF::String badGrammarPhrase, WebCore::GrammarDetail grammarDetail) GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses) @@ -209,6 +200,32 @@ messages -> WebPageProxy { StartDragDrop(WebCore::IntPoint imagePoint, WebCore::IntPoint dragPoint, uint64_t okEffect, HashMap<UINT,Vector<String> > dataMap, WebCore::IntSize dragImageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag) #endif +#if PLATFORM(MAC) + # Dictionary support. + DidPerformDictionaryLookup(WTF::String text, WebKit::DictionaryPopupInfo dictionaryPopupInfo) + + # Keyboard input support messages + InterpretQueuedKeyEvent(WebKit::EditorState state) -> (bool handled, Vector<WebCore::KeypressCommand> savedCommands) + ExecuteSavedCommandBySelector(WTF::String selector) -> (bool handled) + + # Remote accessibility messages + RegisterWebProcessAccessibilityToken(CoreIPC::DataReference data) + + # Plug-in complex text input support messages + SetComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) + + # Speech messages + GetIsSpeaking() -> (bool isSpeaking) + Speak(WTF::String string) + StopSpeaking() + + # Spotlight + SearchWithSpotlight(WTF::String string) +#endif + +#if PLATFORM(MAC) + SubstitutionsPanelIsShowing() -> (bool isShowing) +#endif #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) # Autocorrection messages ShowCorrectionPanel(int32_t panelType, WebCore::FloatRect boundingBoxOfReplacedString, String replacedString, String replacementString, Vector<String> alternativeReplacementStrings) @@ -216,4 +233,13 @@ messages -> WebPageProxy { DismissCorrectionPanelSoon(int32_t reason) -> (String result) RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString); #endif + +#if PLATFORM(WIN) + # Windows 7 Gesture Messages + SetGestureReachedScrollingLimit(bool limitReached) +#endif + + # Search popup menus + SaveRecentSearches(WTF::String name, Vector<String> searchItems) + LoadRecentSearches(WTF::String name) -> (Vector<String> result) } diff --git a/Source/WebKit2/UIProcess/WebPopupMenuProxy.h b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h index 96901fb..0af8880 100644 --- a/Source/WebKit2/UIProcess/WebPopupMenuProxy.h +++ b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h @@ -39,6 +39,7 @@ namespace WebKit { struct PlatformPopupMenuData; struct WebPopupItem; +class NativeWebMouseEvent; class WebPopupMenuProxy : public RefCounted<WebPopupMenuProxy> { public: @@ -51,6 +52,7 @@ public: public: virtual void valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex) = 0; virtual void setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index) = 0; + virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent() = 0; }; virtual ~WebPopupMenuProxy() diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.cpp b/Source/WebKit2/UIProcess/WebProcessProxy.cpp index 8a48724..a8ae574 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.cpp +++ b/Source/WebKit2/UIProcess/WebProcessProxy.cpp @@ -37,7 +37,6 @@ #include "WebPageProxy.h" #include "WebProcessMessages.h" #include "WebProcessProxyMessages.h" -#include "WebProcessProxyMessageKinds.h" #include <WebCore/KURL.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> @@ -59,12 +58,12 @@ static uint64_t generatePageID() return uniquePageID++; } -PassRefPtr<WebProcessProxy> WebProcessProxy::create(WebContext* context) +PassRefPtr<WebProcessProxy> WebProcessProxy::create(PassRefPtr<WebContext> context) { return adoptRef(new WebProcessProxy(context)); } -WebProcessProxy::WebProcessProxy(WebContext* context) +WebProcessProxy::WebProcessProxy(PassRefPtr<WebContext> context) : m_responsivenessTimer(this) , m_context(context) { @@ -163,17 +162,17 @@ void WebProcessProxy::terminate() WebPageProxy* WebProcessProxy::webPage(uint64_t pageID) const { - return m_pageMap.get(pageID).get(); + return m_pageMap.get(pageID); } -WebPageProxy* WebProcessProxy::createWebPage(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup) +PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup) { ASSERT(context->process() == this); unsigned pageID = generatePageID(); - RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, context, pageGroup, pageID); - m_pageMap.set(pageID, webPage); - return webPage.get(); + RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, this, pageGroup, pageID); + m_pageMap.set(pageID, webPage.get()); + return webPage.release(); } void WebProcessProxy::addExistingWebPage(WebPageProxy* webPage, uint64_t pageID) @@ -186,21 +185,6 @@ void WebProcessProxy::removeWebPage(uint64_t pageID) m_pageMap.remove(pageID); } -WebProcessProxy::pages_const_iterator WebProcessProxy::pages_begin() -{ - return m_pageMap.begin().values(); -} - -WebProcessProxy::pages_const_iterator WebProcessProxy::pages_end() -{ - return m_pageMap.end().values(); -} - -size_t WebProcessProxy::numberOfPages() -{ - return m_pageMap.size(); -} - WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) const { return m_backForwardListItemMap.get(itemID).get(); @@ -232,9 +216,14 @@ void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& original } #if ENABLE(PLUGIN_PROCESS) -void WebProcessProxy::getPluginProcessConnection(const String& pluginPath, CoreIPC::ArgumentEncoder* reply) +void WebProcessProxy::getPluginProcessConnection(const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply) { - PluginProcessManager::shared().getPluginProcessConnection(pluginPath, this, reply); + PluginProcessManager::shared().getPluginProcessConnection(context()->pluginInfoStore(), pluginPath, reply); +} + +void WebProcessProxy::pluginSyncMessageSendTimedOut(const String& pluginPath) +{ + PluginProcessManager::shared().pluginSyncMessageSendTimedOut(pluginPath); } #endif @@ -276,22 +265,6 @@ CoreIPC::SyncReplyMode WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connectio if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) return didReceiveSyncWebProcessProxyMessage(connection, messageID, arguments, reply); -#if ENABLE(PLUGIN_PROCESS) - if (messageID.is<CoreIPC::MessageClassWebProcessProxyLegacy>()) { - switch (messageID.get<WebProcessProxyLegacyMessage::Kind>()) { - case WebProcessProxyLegacyMessage::GetPluginProcessConnection: { - String pluginPath; - - if (!arguments->decode(CoreIPC::Out(pluginPath))) - return CoreIPC::AutomaticReply; - - getPluginProcessConnection(pluginPath, reply); - return CoreIPC::ManualReply; - } - } - } -#endif - if (messageID.is<CoreIPC::MessageClassWebContext>() || messageID.is<CoreIPC::MessageClassWebContextLegacy>() || messageID.is<CoreIPC::MessageClassDownloadProxy>() || messageID.is<CoreIPC::MessageClassWebIconDatabase>()) return m_context->didReceiveSyncMessage(connection, messageID, arguments, reply); @@ -331,6 +304,10 @@ void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Me terminate(); } +void WebProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*) +{ +} + void WebProcessProxy::didBecomeUnresponsive(ResponsivenessTimer*) { Vector<RefPtr<WebPageProxy> > pages; @@ -364,7 +341,7 @@ void WebProcessProxy::didFinishLaunching(CoreIPC::Connection::Identifier connect m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main()); #if PLATFORM(MAC) m_connection->setShouldCloseConnectionOnMachExceptions(); -#elif PLATFORM(QT) +#elif PLATFORM(QT) || PLATFORM(GTK) m_connection->setShouldCloseConnectionOnProcessTermination(processIdentifier()); #endif diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.h b/Source/WebKit2/UIProcess/WebProcessProxy.h index 04dbd98..761aad4 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.h +++ b/Source/WebKit2/UIProcess/WebProcessProxy.h @@ -34,6 +34,7 @@ #include "ResponsivenessTimer.h" #include "ThreadLauncher.h" #include "WebPageProxy.h" +#include "WebProcessProxyMessages.h" #include <WebCore/LinkHash.h> #include <wtf/Forward.h> #include <wtf/HashMap.h> @@ -53,12 +54,10 @@ struct WebNavigationDataStore; class WebProcessProxy : public RefCounted<WebProcessProxy>, CoreIPC::Connection::Client, ResponsivenessTimer::Client, ProcessLauncher::Client, ThreadLauncher::Client { public: - typedef HashMap<uint64_t, RefPtr<WebPageProxy> > WebPageProxyMap; - typedef WebPageProxyMap::const_iterator::Values pages_const_iterator; typedef HashMap<uint64_t, RefPtr<WebFrameProxy> > WebFrameProxyMap; typedef HashMap<uint64_t, RefPtr<WebBackForwardListItem> > WebBackForwardListItemMap; - static PassRefPtr<WebProcessProxy> create(WebContext*); + static PassRefPtr<WebProcessProxy> create(PassRefPtr<WebContext>); ~WebProcessProxy(); void terminate(); @@ -73,19 +72,15 @@ public: return m_connection.get(); } - WebContext* context() const { return m_context; } + WebContext* context() const { return m_context.get(); } PlatformProcessIdentifier processIdentifier() const { return m_processLauncher->processIdentifier(); } WebPageProxy* webPage(uint64_t pageID) const; - WebPageProxy* createWebPage(PageClient*, WebContext*, WebPageGroup*); + PassRefPtr<WebPageProxy> createWebPage(PageClient*, WebContext*, WebPageGroup*); void addExistingWebPage(WebPageProxy*, uint64_t pageID); void removeWebPage(uint64_t pageID); - pages_const_iterator pages_begin(); - pages_const_iterator pages_end(); - size_t numberOfPages(); - WebBackForwardListItem* webBackForwardItem(uint64_t itemID) const; ResponsivenessTimer* responsivenessTimer() { return &m_responsivenessTimer; } @@ -108,7 +103,7 @@ public: template<typename E, typename T> bool deprecatedSend(E messageID, uint64_t destinationID, const T& arguments); private: - explicit WebProcessProxy(WebContext*); + explicit WebProcessProxy(PassRefPtr<WebContext>); // Initializes the process or thread launcher which will begin launching the process. void connect(); @@ -126,14 +121,20 @@ private: void shouldTerminate(bool& shouldTerminate); #if ENABLE(PLUGIN_PROCESS) - void getPluginProcessConnection(const String& pluginPath, CoreIPC::ArgumentEncoder* reply); + void getPluginProcessConnection(const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>); + void pluginSyncMessageSendTimedOut(const String& pluginPath); #endif // CoreIPC::Connection::Client - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); - void didClose(CoreIPC::Connection*); - void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + virtual CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); + virtual void didClose(CoreIPC::Connection*); + virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); + +#if PLATFORM(WIN) + Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply(); +#endif // ResponsivenessTimer::Client void didBecomeUnresponsive(ResponsivenessTimer*); @@ -158,9 +159,9 @@ private: RefPtr<ProcessLauncher> m_processLauncher; RefPtr<ThreadLauncher> m_threadLauncher; - WebContext* m_context; + RefPtr<WebContext> m_context; - WebPageProxyMap m_pageMap; + HashMap<uint64_t, WebPageProxy*> m_pageMap; WebFrameProxyMap m_frameMap; WebBackForwardListItemMap m_backForwardListItemMap; }; diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.messages.in b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in index 99014d4..e80bdd0 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in @@ -26,4 +26,9 @@ messages -> WebProcessProxy { DidDestroyFrame(uint64_t frameID) ShouldTerminate() -> (bool shouldTerminate) + +#if ENABLE(PLUGIN_PROCESS) + GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::MachPort connectionHandle) Delayed + PluginSyncMessageSendTimedOut(WTF::String pluginPath) +#endif } diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp index 403a8dc..8c06bdc 100644 --- a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp @@ -67,7 +67,9 @@ void WebResourceCacheManagerProxy::getCacheOrigins(PassRefPtr<ArrayCallback> prp m_webContext->relaunchProcessIfNecessary(); uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); - m_webContext->process()->send(Messages::WebResourceCacheManager::GetCacheOrigins(callbackID), 0); + + // FIXME (Multi-WebProcess): When multi-process is enabled, we need to aggregate the callback data from all processes. + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::GetCacheOrigins(callbackID)); } void WebResourceCacheManagerProxy::didGetCacheOrigins(const Vector<SecurityOriginData>& origins, uint64_t callbackID) @@ -76,21 +78,19 @@ void WebResourceCacheManagerProxy::didGetCacheOrigins(const Vector<SecurityOrigi performAPICallbackWithSecurityOriginDataVector(origins, callback.get()); } -void WebResourceCacheManagerProxy::clearCacheForOrigin(WebSecurityOrigin* origin) +void WebResourceCacheManagerProxy::clearCacheForOrigin(WebSecurityOrigin* origin, ResourceCachesToClear cachesToClear) { - m_webContext->relaunchProcessIfNecessary(); - SecurityOriginData securityOrigin; securityOrigin.protocol = origin->protocol(); securityOrigin.host = origin->host(); securityOrigin.port = origin->port(); - m_webContext->process()->send(Messages::WebResourceCacheManager::ClearCacheForOrigin(securityOrigin), 0); + + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::ClearCacheForOrigin(securityOrigin, cachesToClear)); } -void WebResourceCacheManagerProxy::clearCacheForAllOrigins() +void WebResourceCacheManagerProxy::clearCacheForAllOrigins(ResourceCachesToClear cachesToClear) { - m_webContext->relaunchProcessIfNecessary(); - m_webContext->process()->send(Messages::WebResourceCacheManager::ClearCacheForAllOrigins(), 0); + m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::ClearCacheForAllOrigins(cachesToClear)); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h index 1a360b4..f0c7bb5 100644 --- a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h @@ -29,6 +29,7 @@ #include "APIObject.h" #include "Arguments.h" #include "GenericCallback.h" +#include "ResourceCachesToClear.h" #include <wtf/HashMap.h> #include <wtf/PassRefPtr.h> @@ -58,8 +59,8 @@ public: void clearContext() { m_webContext = 0; } void getCacheOrigins(PassRefPtr<ArrayCallback>); - void clearCacheForOrigin(WebSecurityOrigin*); - void clearCacheForAllOrigins(); + void clearCacheForOrigin(WebSecurityOrigin*, ResourceCachesToClear); + void clearCacheForAllOrigins(ResourceCachesToClear); void didReceiveWebResourceCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); diff --git a/Source/WebKit2/UIProcess/WebUIClient.cpp b/Source/WebKit2/UIProcess/WebUIClient.cpp index 9bb8efc..ec13a41 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.cpp +++ b/Source/WebKit2/UIProcess/WebUIClient.cpp @@ -84,6 +84,30 @@ void WebUIClient::close(WebPageProxy* page) m_client.close(toAPI(page), m_client.clientInfo); } +void WebUIClient::takeFocus(WebPageProxy* page, WKFocusDirection direction) +{ + if (!m_client.takeFocus) + return; + + m_client.takeFocus(toAPI(page), direction, m_client.clientInfo); +} + +void WebUIClient::focus(WebPageProxy* page) +{ + if (!m_client.focus) + return; + + m_client.focus(toAPI(page), m_client.clientInfo); +} + +void WebUIClient::unfocus(WebPageProxy* page) +{ + if (!m_client.unfocus) + return; + + m_client.unfocus(toAPI(page), m_client.clientInfo); +} + void WebUIClient::runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame) { if (!m_client.runJavaScriptAlert) @@ -139,6 +163,11 @@ void WebUIClient::missingPluginButtonClicked(WebPageProxy* page, const String& m m_client.missingPluginButtonClicked(toAPI(page), toAPI(mimeType.impl()), toAPI(url.impl()), toAPI(pluginsPageURL.impl()), m_client.clientInfo); } +bool WebUIClient::implementsDidNotHandleKeyEvent() const +{ + return m_client.didNotHandleKeyEvent; +} + void WebUIClient::didNotHandleKeyEvent(WebPageProxy* page, const NativeWebKeyboardEvent& event) { if (!m_client.didNotHandleKeyEvent) diff --git a/Source/WebKit2/UIProcess/WebUIClient.h b/Source/WebKit2/UIProcess/WebUIClient.h index 8fcf7b6..196574a 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.h +++ b/Source/WebKit2/UIProcess/WebUIClient.h @@ -56,6 +56,10 @@ public: void showPage(WebPageProxy*); void close(WebPageProxy*); + void takeFocus(WebPageProxy*, WKFocusDirection); + void focus(WebPageProxy*); + void unfocus(WebPageProxy*); + void runJavaScriptAlert(WebPageProxy*, const String&, WebFrameProxy*); bool runJavaScriptConfirm(WebPageProxy*, const String&, WebFrameProxy*); String runJavaScriptPrompt(WebPageProxy*, const String&, const String&, WebFrameProxy*); @@ -63,6 +67,8 @@ public: void setStatusText(WebPageProxy*, const String&); void mouseDidMoveOverElement(WebPageProxy*, WebEvent::Modifiers, APIObject*); void missingPluginButtonClicked(WebPageProxy*, const String& mimeType, const String& url, const String& pluginsPageURL); + + bool implementsDidNotHandleKeyEvent() const; void didNotHandleKeyEvent(WebPageProxy*, const NativeWebKeyboardEvent&); bool toolbarsAreVisible(WebPageProxy*); diff --git a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp index 718e3b8..73245dd 100644 --- a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp +++ b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp @@ -54,18 +54,18 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx { ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); - RetainPtr<CFNumberRef> currentIndex(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &m_current)); RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks)); - - const void* keys[2] = { SessionHistoryCurrentIndexKey(), SessionHistoryEntriesKey() }; - const void* values[2] = { currentIndex.get(), entries.get() }; - RetainPtr<CFDictionaryRef> dictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + // We may need to update the current index to account for entries that are filtered by the callback. + int currentIndex = m_current; for (size_t i = 0; i < m_entries.size(); ++i) { RefPtr<WebURL> webURL = WebURL::create(m_entries[i]->url()); - if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) + if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) { + if (i <= static_cast<size_t>(currentIndex)) + currentIndex--; continue; + } RetainPtr<CFStringRef> url(AdoptCF, m_entries[i]->url().createCFString()); RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString()); @@ -78,8 +78,12 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx RetainPtr<CFDictionaryRef> entryDictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); CFArrayAppendValue(entries.get(), entryDictionary.get()); } - - return dictionary.leakRef(); + RetainPtr<CFNumberRef> currentIndexNumber(AdoptCF, CFNumberCreate(0, kCFNumberIntType, ¤tIndex)); + + const void* keys[2] = { SessionHistoryCurrentIndexKey(), SessionHistoryEntriesKey() }; + const void* values[2] = { currentIndexNumber.get(), entries.get() }; + + return CFDictionaryCreate(0, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef dictionary) diff --git a/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp b/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp index 45e77df..02b864b 100644 --- a/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp +++ b/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp @@ -180,4 +180,48 @@ void WebPageProxy::restoreFromSessionStateData(WebData* webData) loadURL(provisionalURL); } +static RetainPtr<CFStringRef> autosaveKey(const String& name) +{ + String key = "com.apple.WebKit.searchField:" + name; + return RetainPtr<CFStringRef>(AdoptCF, key.createCFString()); +} + +void WebPageProxy::saveRecentSearches(const String& name, const Vector<String>& searchItems) +{ + // The WebProcess shouldn't have bothered to send this message if the name was empty. + ASSERT(!name.isEmpty()); + + RetainPtr<CFMutableArrayRef> items; + + if (size_t size = searchItems.size()) { + items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks)); + for (size_t i = 0; i < size; ++i) { + RetainPtr<CFStringRef> item(AdoptCF, searchItems[i].createCFString()); + CFArrayAppendValue(items.get(), item.get()); + } + } + + CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication); + CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); +} + +void WebPageProxy::loadRecentSearches(const String& name, Vector<String>& searchItems) +{ + // The WebProcess shouldn't have bothered to send this message if the name was empty. + ASSERT(!name.isEmpty()); + + searchItems.clear(); + RetainPtr<CFArrayRef> items(AdoptCF, reinterpret_cast<CFArrayRef>(CFPreferencesCopyAppValue(autosaveKey(name).get(), kCFPreferencesCurrentApplication))); + + if (!items || CFGetTypeID(items.get()) != CFArrayGetTypeID()) + return; + + size_t size = CFArrayGetCount(items.get()); + for (size_t i = 0; i < size; ++i) { + CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(items.get(), i); + if (CFGetTypeID(item) == CFStringGetTypeID()) + searchItems.append(item); + } +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp b/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp index 1b7c2dc..5f6ca9d 100644 --- a/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp +++ b/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp @@ -26,28 +26,119 @@ #include "config.h" #include "WebPreferences.h" +#include <wtf/RetainPtr.h> +#include <wtf/text/StringConcatenate.h> + #if !PLATFORM(MAC) namespace WebKit { +static RetainPtr<CFStringRef> cfStringFromWebCoreString(const String& string) +{ + return RetainPtr<CFStringRef>(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length())); +} + +static inline RetainPtr<CFStringRef> makeKey(const String& identifier, const String& baseKey) +{ + return cfStringFromWebCoreString(makeString(identifier, ".WebKit2", baseKey)); +} + +static void setStringValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store) +{ + RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication)); + if (!value) + return; + if (CFGetTypeID(value.get()) != CFStringGetTypeID()) + return; + + store.setStringValueForKey(baseKey, (CFStringRef)value.get()); +} + +static void setBoolValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store) +{ + RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication)); + if (!value) + return; + if (CFGetTypeID(value.get()) != CFBooleanGetTypeID()) + return; + + store.setBoolValueForKey(baseKey, CFBooleanGetValue((CFBooleanRef)value.get()) ? true : false); +} + +static void setUInt32ValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store) +{ + RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication)); + if (!value) + return; + if (CFGetTypeID(value.get()) != CFNumberGetTypeID()) + return; + int32_t intValue = 0; + if (!CFNumberGetValue((CFNumberRef)value.get(), kCFNumberSInt32Type, &intValue)) + return; + + store.setUInt32ValueForKey(baseKey, intValue); +} + +static void setDoubleValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store) +{ + RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication)); + if (!value) + return; + if (CFGetTypeID(value.get()) != CFNumberGetTypeID()) + return; + double doubleValue = 0; + if (!CFNumberGetValue((CFNumberRef)value.get(), kCFNumberDoubleType, &doubleValue)) + return; + + store.setDoubleValueForKey(baseKey, doubleValue); +} + void WebPreferences::platformInitializeStore() { + if (!m_identifier) + return; + +#define INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \ + set##TypeName##ValueIfInUserDefaults(m_identifier, WebPreferencesKey::KeyLower##Key(), m_store); + + FOR_EACH_WEBKIT_PREFERENCE(INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS) + +#undef INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS + } -void WebPreferences::platformUpdateStringValueForKey(const String&, const String&) +void WebPreferences::platformUpdateStringValueForKey(const String& key, const String& value) { + if (!m_identifier) + return; + + CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), cfStringFromWebCoreString(value).get(), kCFPreferencesCurrentApplication); } -void WebPreferences::platformUpdateBoolValueForKey(const String&, bool) +void WebPreferences::platformUpdateBoolValueForKey(const String& key, bool value) { + if (!m_identifier) + return; + + CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), value ? kCFBooleanTrue : kCFBooleanFalse, kCFPreferencesCurrentApplication); } -void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t) +void WebPreferences::platformUpdateUInt32ValueForKey(const String& key, uint32_t value) { + if (!m_identifier) + return; + + RetainPtr<CFNumberRef> number(AdoptCF, CFNumberCreate(0, kCFNumberSInt32Type, &value)); + CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), number.get(), kCFPreferencesCurrentApplication); } -void WebPreferences::platformUpdateDoubleValueForKey(const String&, double) +void WebPreferences::platformUpdateDoubleValueForKey(const String& key, double value) { + if (!m_identifier) + return; + + RetainPtr<CFNumberRef> number(AdoptCF, CFNumberCreate(0, kCFNumberDoubleType, &value)); + CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), number.get(), kCFPreferencesCurrentApplication); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/gtk/ChunkedUpdateDrawingAreaProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/ChunkedUpdateDrawingAreaProxyGtk.cpp index a5c708f..89a9ef7 100644 --- a/Source/WebKit2/UIProcess/gtk/ChunkedUpdateDrawingAreaProxyGtk.cpp +++ b/Source/WebKit2/UIProcess/gtk/ChunkedUpdateDrawingAreaProxyGtk.cpp @@ -32,7 +32,7 @@ #include "UpdateChunk.h" #include "WebProcessProxy.h" #include "WebView.h" - +#include <WebCore/GtkVersioning.h> #include <gdk/gdk.h> using namespace WebCore; diff --git a/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp b/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp index 6a6715a..118bee1 100644 --- a/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp +++ b/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp @@ -58,7 +58,7 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled) notImplemented(); } -int64_t TextChecker::uniqueSpellDocumentTag() +int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*) { notImplemented(); return 0; @@ -69,18 +69,33 @@ void TextChecker::closeSpellDocumentWithTag(int64_t) notImplemented(); } -Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes) +void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&) { notImplemented(); - return Vector<WebCore::TextCheckingResult>(); } -void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) +void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) { notImplemented(); } -void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail) +bool TextChecker::spellingUIIsShowing() +{ + notImplemented(); + return false; +} + +void TextChecker::toggleSpellingUIIsShowing() +{ + notImplemented(); +} + +void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&) +{ + notImplemented(); +} + +void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&) { notImplemented(); } @@ -90,7 +105,7 @@ void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word notImplemented(); } -void TextChecker::learnWord(const String& word) +void TextChecker::learnWord(int64_t, const String&) { notImplemented(); } diff --git a/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp index 838de97..8945d13 100644 --- a/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp +++ b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp @@ -27,6 +27,10 @@ #include "config.h" #include "WebPageProxy.h" +#include "NativeWebKeyboardEvent.h" +#include "NotImplemented.h" +#include "PageClient.h" + namespace WebKit { String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent) @@ -35,4 +39,19 @@ String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent return "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.7 (KHTML, like Gecko) Version/5.0 Safari/534.7"; } +void WebPageProxy::getEditorCommandsForKeyEvent(Vector<WTF::String>& commandsList) +{ + m_pageClient->getEditorCommandsForKeyEvent(m_keyEventQueue.first(), commandsList); +} + +void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&) +{ + notImplemented(); +} + +void WebPageProxy::loadRecentSearches(const String&, Vector<String>&) +{ + notImplemented(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/gtk/WebView.cpp b/Source/WebKit2/UIProcess/gtk/WebView.cpp index 2ff67cd..aa45c62 100644 --- a/Source/WebKit2/UIProcess/gtk/WebView.cpp +++ b/Source/WebKit2/UIProcess/gtk/WebView.cpp @@ -30,6 +30,7 @@ #include "ChunkedUpdateDrawingAreaProxy.h" #include "NativeWebKeyboardEvent.h" +#include "NativeWebMouseEvent.h" #include "NotImplemented.h" #include "WebContext.h" #include "WebContextMenuProxy.h" @@ -38,11 +39,12 @@ #include "WebPageProxy.h" #include <wtf/text/WTFString.h> +typedef HashMap<int, const char*> IntConstCharHashMap; + using namespace WebCore; namespace WebKit { - void WebView::handleFocusInEvent(GtkWidget* widget) { if (!(m_isPageActive)) { @@ -59,8 +61,185 @@ void WebView::handleFocusOutEvent(GtkWidget* widget) m_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); } + +static void backspaceCallback(GtkWidget* widget, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "backspace"); + client->addPendingEditorCommand("DeleteBackward"); +} + +static void selectAllCallback(GtkWidget* widget, gboolean select, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "select-all"); + client->addPendingEditorCommand(select ? "SelectAll" : "Unselect"); +} + +static void cutClipboardCallback(GtkWidget* widget, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "cut-clipboard"); + client->addPendingEditorCommand("Cut"); +} + +static void copyClipboardCallback(GtkWidget* widget, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "copy-clipboard"); + client->addPendingEditorCommand("Copy"); +} + +static void pasteClipboardCallback(GtkWidget* widget, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "paste-clipboard"); + client->addPendingEditorCommand("Paste"); +} + +static void toggleOverwriteCallback(GtkWidget* widget, EditorClient*) +{ + // We don't support toggling the overwrite mode, but the default callback expects + // the GtkTextView to have a layout, so we handle this signal just to stop it. + g_signal_stop_emission_by_name(widget, "toggle-overwrite"); +} + +// GTK+ will still send these signals to the web view. So we can safely stop signal +// emission without breaking accessibility. +static void popupMenuCallback(GtkWidget* widget, EditorClient*) +{ + g_signal_stop_emission_by_name(widget, "popup-menu"); +} + +static void showHelpCallback(GtkWidget* widget, EditorClient*) +{ + g_signal_stop_emission_by_name(widget, "show-help"); +} + +static const char* const gtkDeleteCommands[][2] = { + { "DeleteBackward", "DeleteForward" }, // Characters + { "DeleteWordBackward", "DeleteWordForward" }, // Word ends + { "DeleteWordBackward", "DeleteWordForward" }, // Words + { "DeleteToBeginningOfLine", "DeleteToEndOfLine" }, // Lines + { "DeleteToBeginningOfLine", "DeleteToEndOfLine" }, // Line ends + { "DeleteToBeginningOfParagraph", "DeleteToEndOfParagraph" }, // Paragraph ends + { "DeleteToBeginningOfParagraph", "DeleteToEndOfParagraph" }, // Paragraphs + { 0, 0 } // Whitespace (M-\ in Emacs) +}; + +static void deleteFromCursorCallback(GtkWidget* widget, GtkDeleteType deleteType, gint count, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "delete-from-cursor"); + int direction = count > 0 ? 1 : 0; + + // Ensuring that deleteType <= G_N_ELEMENTS here results in a compiler warning + // that the condition is always true. + + if (deleteType == GTK_DELETE_WORDS) { + if (!direction) { + client->addPendingEditorCommand("MoveWordForward"); + client->addPendingEditorCommand("MoveWordBackward"); + } else { + client->addPendingEditorCommand("MoveWordBackward"); + client->addPendingEditorCommand("MoveWordForward"); + } + } else if (deleteType == GTK_DELETE_DISPLAY_LINES) { + if (!direction) + client->addPendingEditorCommand("MoveToBeginningOfLine"); + else + client->addPendingEditorCommand("MoveToEndOfLine"); + } else if (deleteType == GTK_DELETE_PARAGRAPHS) { + if (!direction) + client->addPendingEditorCommand("MoveToBeginningOfParagraph"); + else + client->addPendingEditorCommand("MoveToEndOfParagraph"); + } + + const char* rawCommand = gtkDeleteCommands[deleteType][direction]; + if (!rawCommand) + return; + + for (int i = 0; i < abs(count); i++) + client->addPendingEditorCommand(rawCommand); +} + +static const char* const gtkMoveCommands[][4] = { + { "MoveBackward", "MoveForward", + "MoveBackwardAndModifySelection", "MoveForwardAndModifySelection" }, // Forward/backward grapheme + { "MoveLeft", "MoveRight", + "MoveBackwardAndModifySelection", "MoveForwardAndModifySelection" }, // Left/right grapheme + { "MoveWordBackward", "MoveWordForward", + "MoveWordBackwardAndModifySelection", "MoveWordForwardAndModifySelection" }, // Forward/backward word + { "MoveUp", "MoveDown", + "MoveUpAndModifySelection", "MoveDownAndModifySelection" }, // Up/down line + { "MoveToBeginningOfLine", "MoveToEndOfLine", + "MoveToBeginningOfLineAndModifySelection", "MoveToEndOfLineAndModifySelection" }, // Up/down line ends + { "MoveParagraphForward", "MoveParagraphBackward", + "MoveParagraphForwardAndModifySelection", "MoveParagraphBackwardAndModifySelection" }, // Up/down paragraphs + { "MoveToBeginningOfParagraph", "MoveToEndOfParagraph", + "MoveToBeginningOfParagraphAndModifySelection", "MoveToEndOfParagraphAndModifySelection" }, // Up/down paragraph ends. + { "MovePageUp", "MovePageDown", + "MovePageUpAndModifySelection", "MovePageDownAndModifySelection" }, // Up/down page + { "MoveToBeginningOfDocument", "MoveToEndOfDocument", + "MoveToBeginningOfDocumentAndModifySelection", "MoveToEndOfDocumentAndModifySelection" }, // Begin/end of buffer + { 0, 0, + 0, 0 } // Horizontal page movement +}; + +static void moveCursorCallback(GtkWidget* widget, GtkMovementStep step, gint count, gboolean extendSelection, WebView* client) +{ + g_signal_stop_emission_by_name(widget, "move-cursor"); + int direction = count > 0 ? 1 : 0; + if (extendSelection) + direction += 2; + + if (static_cast<unsigned>(step) >= G_N_ELEMENTS(gtkMoveCommands)) + return; + + const char* rawCommand = gtkMoveCommands[step][direction]; + if (!rawCommand) + return; + + for (int i = 0; i < abs(count); i++) + client->addPendingEditorCommand(rawCommand); +} + +static const unsigned CtrlKey = 1 << 0; +static const unsigned AltKey = 1 << 1; +static const unsigned ShiftKey = 1 << 2; + +struct KeyDownEntry { + unsigned virtualKey; + unsigned modifiers; + const char* name; +}; + +struct KeyPressEntry { + unsigned charCode; + unsigned modifiers; + const char* name; +}; + +static const KeyDownEntry keyDownEntries[] = { + { 'B', CtrlKey, "ToggleBold" }, + { 'I', CtrlKey, "ToggleItalic" }, + { VK_ESCAPE, 0, "Cancel" }, + { VK_OEM_PERIOD, CtrlKey, "Cancel" }, + { VK_TAB, 0, "InsertTab" }, + { VK_TAB, ShiftKey, "InsertBacktab" }, + { VK_RETURN, 0, "InsertNewline" }, + { VK_RETURN, CtrlKey, "InsertNewline" }, + { VK_RETURN, AltKey, "InsertNewline" }, + { VK_RETURN, AltKey | ShiftKey, "InsertNewline" }, +}; + +static const KeyPressEntry keyPressEntries[] = { + { '\t', 0, "InsertTab" }, + { '\t', ShiftKey, "InsertBacktab" }, + { '\r', 0, "InsertNewline" }, + { '\r', CtrlKey, "InsertNewline" }, + { '\r', AltKey, "InsertNewline" }, + { '\r', AltKey | ShiftKey, "InsertNewline" }, +}; + WebView::WebView(WebContext* context, WebPageGroup* pageGroup) : m_isPageActive(true) + , m_nativeWidget(gtk_text_view_new()) { m_page = context->createWebPage(this, pageGroup); @@ -71,6 +250,17 @@ WebView::WebView(WebContext* context, WebPageGroup* pageGroup) WebViewWidget* webViewWidget = WEB_VIEW_WIDGET(m_viewWidget); webViewWidgetSetWebViewInstance(webViewWidget, this); + + g_signal_connect(m_nativeWidget.get(), "backspace", G_CALLBACK(backspaceCallback), this); + g_signal_connect(m_nativeWidget.get(), "cut-clipboard", G_CALLBACK(cutClipboardCallback), this); + g_signal_connect(m_nativeWidget.get(), "copy-clipboard", G_CALLBACK(copyClipboardCallback), this); + g_signal_connect(m_nativeWidget.get(), "paste-clipboard", G_CALLBACK(pasteClipboardCallback), this); + g_signal_connect(m_nativeWidget.get(), "select-all", G_CALLBACK(selectAllCallback), this); + g_signal_connect(m_nativeWidget.get(), "move-cursor", G_CALLBACK(moveCursorCallback), this); + g_signal_connect(m_nativeWidget.get(), "delete-from-cursor", G_CALLBACK(deleteFromCursorCallback), this); + g_signal_connect(m_nativeWidget.get(), "toggle-overwrite", G_CALLBACK(toggleOverwriteCallback), this); + g_signal_connect(m_nativeWidget.get(), "popup-menu", G_CALLBACK(popupMenuCallback), this); + g_signal_connect(m_nativeWidget.get(), "show-help", G_CALLBACK(showHelpCallback), this); } WebView::~WebView() @@ -99,7 +289,7 @@ void WebView::handleKeyboardEvent(GdkEventKey* event) void WebView::handleMouseEvent(GdkEvent* event, int currentClickCount) { - m_page->handleMouseEvent(WebEventFactory::createWebMouseEvent(event, currentClickCount)); + m_page->handleMouseEvent(NativeWebMouseEvent(event, currentClickCount)); } void WebView::handleWheelEvent(GdkEventScroll* event) @@ -107,6 +297,52 @@ void WebView::handleWheelEvent(GdkEventScroll* event) m_page->handleWheelEvent(WebEventFactory::createWebWheelEvent(event)); } +void WebView::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent& event, Vector<WTF::String>& commandList) +{ + m_pendingEditorCommands.clear(); + +#ifdef GTK_API_VERSION_2 + gtk_bindings_activate_event(GTK_OBJECT(m_nativeWidget.get()), const_cast<GdkEventKey*>(&event.nativeEvent()->key)); +#else + gtk_bindings_activate_event(G_OBJECT(m_nativeWidget.get()), const_cast<GdkEventKey*>(&event.nativeEvent()->key)); +#endif + + if (m_pendingEditorCommands.isEmpty()) { + commandList.append(m_pendingEditorCommands); + return; + } + + DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyDownCommandsMap, ()); + DEFINE_STATIC_LOCAL(IntConstCharHashMap, keyPressCommandsMap, ()); + + if (keyDownCommandsMap.isEmpty()) { + for (unsigned i = 0; i < G_N_ELEMENTS(keyDownEntries); i++) + keyDownCommandsMap.set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, keyDownEntries[i].name); + + for (unsigned i = 0; i < G_N_ELEMENTS(keyPressEntries); i++) + keyPressCommandsMap.set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].charCode, keyPressEntries[i].name); + } + + unsigned modifiers = 0; + if (event.shiftKey()) + modifiers |= ShiftKey; + if (event.altKey()) + modifiers |= AltKey; + if (event.controlKey()) + modifiers |= CtrlKey; + + // For keypress events, we want charCode(), but keyCode() does that. + int mapKey = modifiers << 16 | event.nativeVirtualKeyCode(); + if (mapKey) { + HashMap<int, const char*>* commandMap = event.type() == WebEvent::KeyDown ? + &keyDownCommandsMap : &keyPressCommandsMap; + if (const char* commandString = commandMap->get(mapKey)) + m_pendingEditorCommands.append(commandString); + } + + commandList.append(m_pendingEditorCommands); +} + bool WebView::isActive() { return m_isPageActive; @@ -179,11 +415,6 @@ void WebView::didRelaunchProcess() notImplemented(); } -void WebView::setFocus(bool) -{ - notImplemented(); -} - void WebView::takeFocus(bool) { notImplemented(); @@ -222,6 +453,17 @@ void WebView::clearAllEditCommands() notImplemented(); } +bool WebView::canUndoRedo(WebPageProxy::UndoOrRedo) +{ + notImplemented(); + return false; +} + +void WebView::executeUndoRedo(WebPageProxy::UndoOrRedo) +{ + notImplemented(); +} + FloatRect WebView::convertToDeviceSpace(const FloatRect& viewRect) { notImplemented(); @@ -312,5 +554,14 @@ void WebView::flashBackingStoreUpdates(const Vector<IntRect>&) notImplemented(); } +void WebView::findStringInCustomRepresentation(const String&, FindOptions, unsigned) +{ + notImplemented(); +} + +void WebView::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned) +{ + notImplemented(); +} } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/gtk/WebView.h b/Source/WebKit2/UIProcess/gtk/WebView.h index 6c281ed..6cef14c 100644 --- a/Source/WebKit2/UIProcess/gtk/WebView.h +++ b/Source/WebKit2/UIProcess/gtk/WebView.h @@ -30,6 +30,7 @@ #include "PageClient.h" #include "WebPageProxy.h" +#include "WindowsKeyboardCodes.h" #include <WebCore/IntSize.h> #include <gdk/gdk.h> #include <glib.h> @@ -64,6 +65,8 @@ public: void handleWheelEvent(GdkEventScroll*); void handleMouseEvent(GdkEvent*, int); + void addPendingEditorCommand(const char* command) { m_pendingEditorCommands.append(WTF::String(command)); } + private: WebView(WebContext*, WebPageGroup*); @@ -85,13 +88,14 @@ private: virtual void processDidCrash(); virtual void didRelaunchProcess(); virtual void pageClosed(); - virtual void setFocus(bool focused); virtual void takeFocus(bool direction); virtual void toolTipChanged(const WTF::String&, const WTF::String&); virtual void setCursor(const WebCore::Cursor&); virtual void setViewportArguments(const WebCore::ViewportArguments&); virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); virtual void clearAllEditCommands(); + virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); + virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); @@ -103,6 +107,9 @@ private: virtual void didChangeScrollbarsForMainFrame() const; virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); virtual float userSpaceScaleFactor() const { return 1; } + virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, Vector<WTF::String>&); + virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned); + virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned); #if USE(ACCELERATED_COMPOSITING) virtual void pageDidEnterAcceleratedCompositing(); @@ -118,6 +125,8 @@ private: GtkWidget* m_viewWidget; bool m_isPageActive; RefPtr<WebPageProxy> m_page; + Vector<WTF::String> m_pendingEditorCommands; + GRefPtr<GtkWidget> m_nativeWidget; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/CorrectionPanel.h b/Source/WebKit2/UIProcess/mac/CorrectionPanel.h index d4bc353..85a98ef 100644 --- a/Source/WebKit2/UIProcess/mac/CorrectionPanel.h +++ b/Source/WebKit2/UIProcess/mac/CorrectionPanel.h @@ -27,8 +27,8 @@ #define CorrectionPanel_h #if !defined(BUILDING_ON_SNOW_LEOPARD) -#import <AppKit/NSTextChecker.h> -#import <WebCore/CorrectionPanelInfo.h> +#import <AppKit/NSSpellChecker.h> +#import <WebCore/SpellingCorrectionController.h> #import <wtf/RetainPtr.h> @class WKView; @@ -47,7 +47,7 @@ public: private: bool isShowing() const { return m_view; } void dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally); - void handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionBubbleType); + void handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType); bool m_wasDismissedExternally; WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissing; diff --git a/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm b/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm index ab6818f..0fc520b 100644 --- a/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm +++ b/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm @@ -33,18 +33,18 @@ using namespace WebCore; -static inline NSCorrectionBubbleType correctionBubbleType(CorrectionPanelInfo::PanelType panelType) +static inline NSCorrectionIndicatorType correctionIndicatorType(CorrectionPanelInfo::PanelType panelType) { switch (panelType) { case CorrectionPanelInfo::PanelTypeCorrection: - return NSCorrectionBubbleTypeCorrection; + return NSCorrectionIndicatorTypeDefault; case CorrectionPanelInfo::PanelTypeReversion: - return NSCorrectionBubbleTypeReversion; + return NSCorrectionIndicatorTypeReversion; case CorrectionPanelInfo::PanelTypeSpellingSuggestions: - return NSCorrectionBubbleTypeGuesses; + return NSCorrectionIndicatorTypeGuesses; } ASSERT_NOT_REACHED(); - return NSCorrectionBubbleTypeCorrection; + return NSCorrectionIndicatorTypeDefault; } namespace WebKit { @@ -71,7 +71,7 @@ void CorrectionPanel::show(WKView* view, CorrectionPanelInfo::PanelType type, co NSString* replacedStringAsNSString = replacedString; NSString* replacementStringAsNSString = replacementString; m_view = view; - NSCorrectionBubbleType bubbleType = correctionBubbleType(type); + NSCorrectionIndicatorType indicatorType = correctionIndicatorType(type); NSMutableArray* alternativeStrings = 0; if (!alternativeReplacementStrings.isEmpty()) { @@ -82,8 +82,8 @@ void CorrectionPanel::show(WKView* view, CorrectionPanelInfo::PanelType type, co } NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker]; - [spellChecker showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) { - handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, bubbleType); + [spellChecker showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) { + handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, indicatorType); }]; } @@ -113,7 +113,7 @@ void CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, m_reasonForDismissing = reason; m_resultForSynchronousDismissal.clear(); - [[NSSpellChecker sharedSpellChecker] dismissCorrectionBubbleForView:m_view.get()]; + [[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:m_view.get()]; m_view.clear(); } @@ -122,13 +122,13 @@ void CorrectionPanel::recordAutocorrectionResponse(WKView* view, NSCorrectionRes [[NSSpellChecker sharedSpellChecker] recordResponse:response toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:[view spellCheckerDocumentTag]]; } -void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionBubbleType correctionBubbleType) +void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType correctionIndicatorType) { NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker]; NSInteger documentTag = [m_view.get() spellCheckerDocumentTag]; - switch (correctionBubbleType) { - case NSCorrectionBubbleTypeCorrection: + switch (correctionIndicatorType) { + case NSCorrectionIndicatorTypeDefault: if (acceptedReplacement) [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; else { @@ -138,11 +138,11 @@ void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, N [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; } break; - case NSCorrectionBubbleTypeReversion: + case NSCorrectionIndicatorTypeReversion: if (acceptedReplacement) [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replaced forWord:acceptedReplacement language:nil inSpellDocumentWithTag:documentTag]; break; - case NSCorrectionBubbleTypeGuesses: + case NSCorrectionIndicatorTypeGuesses: if (acceptedReplacement) [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag]; break; diff --git a/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm index cef3a55..29493f9 100644 --- a/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm +++ b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm @@ -27,10 +27,13 @@ #import "TextChecker.h" #import "TextCheckerState.h" +#import <WebCore/NotImplemented.h> #import <wtf/RetainPtr.h> #ifndef BUILDING_ON_SNOW_LEOPARD -#import <AppKit/NSTextChecker.h> +@interface NSSpellChecker (WebNSSpellCheckerDetails) +- (NSString *)languageForWordRange:(NSRange)range inString:(NSString *)string orthography:(NSOrthography *)orthography; +@end #endif static NSString* const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled"; @@ -195,7 +198,22 @@ void TextChecker::setSmartInsertDeleteEnabled(bool flag) [[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled]; } -int64_t TextChecker::uniqueSpellDocumentTag() +bool TextChecker::substitutionsPanelIsShowing() +{ + return [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible]; +} + +void TextChecker::toggleSubstitutionsPanelIsShowing() +{ + NSPanel *substitutionsPanel = [[NSSpellChecker sharedSpellChecker] substitutionsPanel]; + if ([substitutionsPanel isVisible]) { + [substitutionsPanel orderOut:nil]; + return; + } + [substitutionsPanel orderFront:nil]; +} + +int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*) { return [NSSpellChecker uniqueSpellDocumentTag]; } @@ -205,6 +223,8 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag) [[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:tag]; } +#if USE(UNIFIED_TEXT_CHECKING) + Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes) { Vector<TextCheckingResult> results; @@ -292,12 +312,40 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume return results; } -void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) +#endif + +void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&) +{ + // Mac uses checkTextOfParagraph instead. + notImplemented(); +} + +void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) +{ + // Mac uses checkTextOfParagraph instead. + notImplemented(); +} + +bool TextChecker::spellingUIIsShowing() +{ + return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible]; +} + +void TextChecker::toggleSpellingUIIsShowing() +{ + NSPanel *spellingPanel = [[NSSpellChecker sharedSpellChecker] spellingPanel]; + if ([spellingPanel isVisible]) + [spellingPanel orderOut:nil]; + else + [spellingPanel orderFront:nil]; +} + +void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String& misspelledWord) { [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord]; } -void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail) +void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String& badGrammarPhrase, const GrammarDetail& grammarDetail) { RetainPtr<NSMutableArray> corrections(AdoptNS, [[NSMutableArray alloc] init]); for (size_t i = 0; i < grammarDetail.guesses.size(); ++i) { @@ -307,7 +355,7 @@ void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhra NSRange grammarRange = NSMakeRange(grammarDetail.location, grammarDetail.length); NSString *grammarUserDescription = grammarDetail.userDescription; - RetainPtr<NSMutableDictionary> grammarDetailDict(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:[NSValue valueWithRange:grammarRange], NSGrammarRange, grammarUserDescription, NSGrammarUserDescription, corrections.get(), NSGrammarCorrections, nil]); + RetainPtr<NSDictionary> grammarDetailDict(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:[NSValue valueWithRange:grammarRange], NSGrammarRange, grammarUserDescription, NSGrammarUserDescription, corrections.get(), NSGrammarCorrections, nil]); [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithGrammarString:badGrammarPhrase detail:grammarDetailDict.get()]; } @@ -331,7 +379,7 @@ void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word guesses.append(guess); } -void TextChecker::learnWord(const String& word) +void TextChecker::learnWord(int64_t, const String& word) { [[NSSpellChecker sharedSpellChecker] learnWord:word]; } diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm index f7c186d..e770d5b 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm @@ -84,12 +84,11 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para NSURLCache *urlCache = [NSURLCache sharedURLCache]; parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; - parameters.nsURLCachePath = fileSystemRepresentation([(NSString *)cachePath.get() stringByStandardizingPath]); + parameters.nsURLCachePath = [(NSString *)cachePath.get() stringByStandardizingPath]; parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity]; parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity]; - ASSERT(strlen(parameters.nsURLCachePath.data())); - ASSERT(parameters.nsURLCachePath.data()[strlen(parameters.nsURLCachePath.data()) - 1] != '/'); // Necessary for NSURLCache to find the cache file. + ASSERT(!parameters.nsURLCachePath.isEmpty()); #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION) mach_port_t renderServerPort = WKInitializeRenderServer(); @@ -98,7 +97,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para #endif // FIXME: This should really be configurable; we shouldn't just blindly allow read access to the UI process bundle. - parameters.uiProcessBundleResourcePath = fileSystemRepresentation([[NSBundle mainBundle] resourcePath]); + parameters.uiProcessBundleResourcePath = [[NSBundle mainBundle] resourcePath]; #if USE(CFURLSTORAGESESSIONS) parameters.uiProcessBundleIdentifier = String([[NSBundle mainBundle] bundleIdentifier]); diff --git a/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm index d533573..33238b0 100644 --- a/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm @@ -23,11 +23,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "WebFullScreenManagerProxy.h" -#include "LayerTreeContext.h" -#include "WKFullScreenWindowController.h" -#include "WKViewInternal.h" +#import "config.h" +#import "WebFullScreenManagerProxy.h" + +#import "LayerTreeContext.h" +#import "WKFullScreenWindowController.h" +#import "WKViewInternal.h" +#import <WebCore/IntRect.h> #if ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm index 9657764..e406166 100644 --- a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm @@ -31,6 +31,7 @@ #import "WKAPICast.h" #import "WKView.h" #import "WebPageProxy.h" +#import "WebProcessProxy.h" #import <WebKitSystemInterface.h> #import <WebCore/LocalizedStrings.h> #import <wtf/text/WTFString.h> @@ -80,7 +81,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() ASSERT(m_page); ASSERT(!m_inspectorView); - m_inspectorView.adoptNS([[WKView alloc] initWithFrame:NSZeroRect contextRef:toAPI(page()->context()) pageGroupRef:toAPI(inspectorPageGroup())]); + m_inspectorView.adoptNS([[WKView alloc] initWithFrame:NSZeroRect contextRef:toAPI(page()->process()->context()) pageGroupRef:toAPI(inspectorPageGroup())]); ASSERT(m_inspectorView); [m_inspectorView.get() setDrawsBackground:NO]; @@ -135,7 +136,7 @@ void WebInspectorProxy::platformClose() void WebInspectorProxy::platformInspectedURLChanged(const String& urlString) { - NSString *title = [NSString stringWithFormat:UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)urlString]; + NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)urlString]; [m_inspectorWindow.get() setTitle:title]; } diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm index 90df81e..9dacae5 100644 --- a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm @@ -26,10 +26,13 @@ #import "config.h" #import "WebPageProxy.h" +#import "AttributedString.h" #import "DataReference.h" #import "DictionaryPopupInfo.h" +#import "EditorState.h" #import "NativeWebKeyboardEvent.h" #import "PageClient.h" +#import "PageClientImpl.h" #import "TextChecker.h" #import "WebPageMessages.h" #import "WebProcessProxy.h" @@ -105,8 +108,7 @@ void WebPageProxy::getIsSpeaking(bool& isSpeaking) void WebPageProxy::speak(const String& string) { - NSString *convertedString = string; - [NSApp speakString:convertedString]; + [NSApp speakString:nsStringFromWebCoreString(string)]; } void WebPageProxy::stopSpeaking() @@ -114,6 +116,11 @@ void WebPageProxy::stopSpeaking() [NSApp stopSpeaking:nil]; } +void WebPageProxy::searchWithSpotlight(const String& string) +{ + [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:nsStringFromWebCoreString(string)]; +} + CGContextRef WebPageProxy::containingWindowGraphicsContext() { return m_pageClient->containingWindowGraphicsContext(); @@ -134,11 +141,38 @@ void WebPageProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreen process()->send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID); } +void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) +{ + process()->sendSync(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID); +} + +void WebPageProxy::confirmComposition() +{ + process()->sendSync(Messages::WebPage::ConfirmComposition(), Messages::WebPage::ConfirmComposition::Reply(m_editorState), m_pageID); +} + +bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) +{ + bool handled; + process()->sendSync(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRangeEnd), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID); + return handled; +} + void WebPageProxy::getMarkedRange(uint64_t& location, uint64_t& length) { process()->sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(location, length), m_pageID); } - + +void WebPageProxy::getSelectedRange(uint64_t& location, uint64_t& length) +{ + process()->sendSync(Messages::WebPage::GetSelectedRange(), Messages::WebPage::GetSelectedRange::Reply(location, length), m_pageID); +} + +void WebPageProxy::getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString& result) +{ + process()->sendSync(Messages::WebPage::GetAttributedSubstringFromRange(location, length), Messages::WebPage::GetAttributedSubstringFromRange::Reply(result), m_pageID); +} + uint64_t WebPageProxy::characterIndexForPoint(const IntPoint point) { uint64_t result; @@ -152,20 +186,27 @@ WebCore::IntRect WebPageProxy::firstRectForCharacterRange(uint64_t location, uin process()->sendSync(Messages::WebPage::FirstRectForCharacterRange(location, length), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID); return resultRect; } - + +bool WebPageProxy::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands) +{ + bool result; + process()->sendSync(Messages::WebPage::ExecuteKeypressCommands(commands), Messages::WebPage::ExecuteKeypressCommands::Reply(result, m_editorState), m_pageID); + return result; +} + bool WebPageProxy::writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes) { bool result; - const double MessageTimeout = 20; - process()->sendSync(Messages::WebPage::WriteSelectionToPasteboard(pasteboardName, pasteboardTypes), Messages::WebPage::WriteSelectionToPasteboard::Reply(result), m_pageID, MessageTimeout); + const double messageTimeout = 20; + process()->sendSync(Messages::WebPage::WriteSelectionToPasteboard(pasteboardName, pasteboardTypes), Messages::WebPage::WriteSelectionToPasteboard::Reply(result), m_pageID, messageTimeout); return result; } bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName) { bool result; - const double MessageTimeout = 20; - process()->sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, MessageTimeout); + const double messageTimeout = 20; + process()->sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, messageTimeout); return result; } @@ -186,9 +227,10 @@ void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& process()->send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID); } -void WebPageProxy::interpretKeyEvent(uint32_t type, Vector<KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<CompositionUnderline>& underlines) +void WebPageProxy::interpretQueuedKeyEvent(const EditorState& state, bool& handled, Vector<WebCore::KeypressCommand>& commands) { - m_pageClient->interceptKeyEvent(m_keyEventQueue.first(), commandsList, selectionStart, selectionEnd, underlines); + m_editorState = state; + handled = m_pageClient->interpretKeyEvent(m_keyEventQueue.first(), commands); } // Complex text input support for plug-ins. @@ -248,4 +290,25 @@ void WebPageProxy::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIde m_pageClient->setComplexTextInputEnabled(pluginComplexTextInputIdentifier, complexTextInputEnabled); } +void WebPageProxy::executeSavedCommandBySelector(const String& selector, bool& handled) +{ + handled = m_pageClient->executeSavedCommandBySelector(selector); +} + +bool WebPageProxy::shouldDelayWindowOrderingForEvent(const WebKit::WebMouseEvent& event) +{ + bool result = false; + const double messageTimeout = 3; + process()->sendSync(Messages::WebPage::ShouldDelayWindowOrderingEvent(event), Messages::WebPage::ShouldDelayWindowOrderingEvent::Reply(result), m_pageID, messageTimeout); + return result; +} + +bool WebPageProxy::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& event) +{ + bool result = false; + const double messageTimeout = 3; + process()->sendSync(Messages::WebPage::AcceptsFirstMouse(eventNumber, event), Messages::WebPage::AcceptsFirstMouse::Reply(result), m_pageID, messageTimeout); + return result; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm index 7ce8764..d13a2a7 100644 --- a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm @@ -26,6 +26,7 @@ #import "config.h" #import "WebPopupMenuProxyMac.h" +#import "NativeWebMouseEvent.h" #import "PageClientImpl.h" #import "PlatformPopupMenuData.h" #import "WKView.h" @@ -61,7 +62,7 @@ void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items, NSFont *f int size = items.size(); for (int i = 0; i < size; i++) { - if (items[i].m_type == WebPopupItem::Seperator) + if (items[i].m_type == WebPopupItem::Separator) [[m_popup.get() menu] addItem:[NSMenuItem separatorItem]]; else { [m_popup.get() addItemWithTitle:@""]; @@ -108,11 +109,20 @@ void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection text // These values were borrowed from AppKit to match their placement of the menu. const int popOverHorizontalAdjust = -10; - NSRect titleFrame = [m_popup.get() titleRectForBounds:rect]; - if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0) - titleFrame = rect; - float vertOffset = roundf((NSMaxY(rect) - NSMaxY(titleFrame)) + NSHeight(titleFrame)); - NSPoint location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset); + const int popUnderHorizontalAdjust = 6; + const int popUnderVerticalAdjust = 6; + + // Menus that pop-over directly obscure the node that generated the popup menu. + // Menus that pop-under are offset underneath it. + NSPoint location; + if (data.shouldPopOver) { + NSRect titleFrame = [m_popup.get() titleRectForBounds:rect]; + if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0) + titleFrame = rect; + float vertOffset = roundf((NSMaxY(rect) - NSMaxY(titleFrame)) + NSHeight(titleFrame)); + location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset); + } else + location = NSMakePoint(NSMinX(rect) + popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust); RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:rect]); [m_webView addSubview:dummyView.get()]; @@ -122,9 +132,41 @@ void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection text [m_popup.get() dismissPopUp]; [dummyView.get() removeFromSuperview]; - - if (m_client) - m_client->valueChangedForPopupMenu(this, [m_popup.get() indexOfSelectedItem]); + + if (!m_client) + return; + + m_client->valueChangedForPopupMenu(this, [m_popup.get() indexOfSelectedItem]); + + // <https://bugs.webkit.org/show_bug.cgi?id=57904> This code is adopted from EventHandler::sendFakeEventsAfterWidgetTracking(). + if (!m_client->currentlyProcessedMouseDownEvent()) + return; + + NSEvent* initiatingNSEvent = m_client->currentlyProcessedMouseDownEvent()->nativeEvent(); + if ([initiatingNSEvent type] != NSLeftMouseDown) + return; + + NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSLeftMouseUp + location:[initiatingNSEvent locationInWindow] + modifierFlags:[initiatingNSEvent modifierFlags] + timestamp:[initiatingNSEvent timestamp] + windowNumber:[initiatingNSEvent windowNumber] + context:[initiatingNSEvent context] + eventNumber:[initiatingNSEvent eventNumber] + clickCount:[initiatingNSEvent clickCount] + pressure:[initiatingNSEvent pressure]]; + + [NSApp postEvent:fakeEvent atStart:YES]; + fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved + location:[[m_webView window] convertScreenToBase:[NSEvent mouseLocation]] + modifierFlags:[initiatingNSEvent modifierFlags] + timestamp:[initiatingNSEvent timestamp] + windowNumber:[initiatingNSEvent windowNumber] + context:[initiatingNSEvent context] + eventNumber:0 + clickCount:0 + pressure:0]; + [NSApp postEvent:fakeEvent atStart:YES]; } void WebPopupMenuProxyMac::hidePopupMenu() diff --git a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp index a28b867..2582cc2 100644 --- a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp +++ b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp @@ -59,7 +59,7 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled) notImplemented(); } -int64_t TextChecker::uniqueSpellDocumentTag() +int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*) { notImplemented(); return 0; @@ -70,18 +70,33 @@ void TextChecker::closeSpellDocumentWithTag(int64_t) notImplemented(); } -Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes) +void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&) { notImplemented(); - return Vector<WebCore::TextCheckingResult>(); } -void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) +void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) { notImplemented(); } -void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail) +bool TextChecker::spellingUIIsShowing() +{ + notImplemented(); + return false; +} + +void TextChecker::toggleSpellingUIIsShowing() +{ + notImplemented(); +} + +void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&) +{ + notImplemented(); +} + +void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&) { notImplemented(); } @@ -91,7 +106,7 @@ void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word notImplemented(); } -void TextChecker::learnWord(const String& word) +void TextChecker::learnWord(int64_t, const String&) { notImplemented(); } diff --git a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp index d6e8639..615cd8d 100644 --- a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "WebPageProxy.h" +#include <WebCore/NotImplemented.h> + namespace WebKit { String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent) @@ -34,4 +36,14 @@ String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4"; } +void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&) +{ + notImplemented(); +} + +void WebPageProxy::loadRecentSearches(const String&, Vector<String>&) +{ + notImplemented(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp index dbc6fdc..9f7c766 100644 --- a/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp +++ b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp @@ -27,6 +27,7 @@ #include "TextChecker.h" #include "TextCheckerState.h" +#include "WebTextChecker.h" #include <WebCore/NotImplemented.h> using namespace WebCore; @@ -37,68 +38,103 @@ static TextCheckerState textCheckerState; const TextCheckerState& TextChecker::state() { - notImplemented(); + static bool didInitializeState; + if (didInitializeState) + return textCheckerState; + + WebTextCheckerClient& client = WebTextChecker::shared()->client(); + textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled(); + textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled(); + + didInitializeState = true; return textCheckerState; } bool TextChecker::isContinuousSpellCheckingAllowed() { - notImplemented(); - - return false; + return WebTextChecker::shared()->client().continuousSpellCheckingAllowed(); } void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled) { - notImplemented(); + if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled) + return; + textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled; + WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled); } void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled) { - notImplemented(); + if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled) + return; + textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled; + WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled); +} + +void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled) +{ + textCheckerState.isContinuousSpellCheckingEnabled = enabled; +} + +void TextChecker::grammarCheckingEnabledStateChanged(bool enabled) +{ + textCheckerState.isGrammarCheckingEnabled = enabled; +} + +int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page) +{ + return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page); +} + +void TextChecker::closeSpellDocumentWithTag(int64_t tag) +{ + WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag); +} + +void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength) +{ + WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength); } -int64_t TextChecker::uniqueSpellDocumentTag() +void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength) { - notImplemented(); - return 0; + WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength); } -void TextChecker::closeSpellDocumentWithTag(int64_t) +bool TextChecker::spellingUIIsShowing() { - notImplemented(); + return WebTextChecker::shared()->client().spellingUIIsShowing(); } -Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes) +void TextChecker::toggleSpellingUIIsShowing() { - notImplemented(); - return Vector<WebCore::TextCheckingResult>(); + WebTextChecker::shared()->client().toggleSpellingUIIsShowing(); } -void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) +void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord) { - notImplemented(); + WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord); } -void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail) +void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail) { - notImplemented(); + WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail); } void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses) { - notImplemented(); + WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses); } -void TextChecker::learnWord(const String& word) +void TextChecker::learnWord(int64_t spellDocumentTag, const String& word) { - notImplemented(); + WebTextChecker::shared()->client().learnWord(spellDocumentTag, word); } void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word) { - notImplemented(); + WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebContextWin.cpp b/Source/WebKit2/UIProcess/win/WebContextWin.cpp index d5fd859..c1c2a00 100644 --- a/Source/WebKit2/UIProcess/win/WebContextWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebContextWin.cpp @@ -48,9 +48,7 @@ void WebContext::setShouldPaintNativeControls(bool b) { m_shouldPaintNativeControls = b; - if (!hasValidProcess()) - return; - m_process->send(Messages::WebProcess::SetShouldPaintNativeControls(m_shouldPaintNativeControls), 0); + sendToAllProcesses(Messages::WebProcess::SetShouldPaintNativeControls(m_shouldPaintNativeControls)); } void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters) diff --git a/Source/WebKit2/UIProcess/win/WebGrammarDetail.cpp b/Source/WebKit2/UIProcess/win/WebGrammarDetail.cpp new file mode 100644 index 0000000..8df528c --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebGrammarDetail.cpp @@ -0,0 +1,72 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebGrammarDetail.h" + +#include "ImmutableArray.h" +#include "WKGrammarDetail.h" +#include "WebString.h" + +namespace WebKit { + +PassRefPtr<WebGrammarDetail> WebGrammarDetail::create(int location, int length, ImmutableArray* guesses, const String& userDescription) +{ + return adoptRef(new WebGrammarDetail(location, length, guesses, userDescription)); +} + +PassRefPtr<WebGrammarDetail> WebGrammarDetail::create(const WebCore::GrammarDetail& grammarDetail) +{ + return adoptRef(new WebGrammarDetail(grammarDetail)); +} + +WebGrammarDetail::WebGrammarDetail(int location, int length, ImmutableArray* guesses, const String& userDescription) +{ + m_grammarDetail.location = location; + m_grammarDetail.length = length; + + size_t numGuesses = guesses->size(); + m_grammarDetail.guesses.reserveCapacity(numGuesses); + for (size_t i = 0; i < numGuesses; ++i) + m_grammarDetail.guesses.uncheckedAppend(guesses->at<WebString>(i)->string()); + + m_grammarDetail.userDescription = userDescription; +} + +PassRefPtr<ImmutableArray> WebGrammarDetail::guesses() const +{ + size_t numGuesses = m_grammarDetail.guesses.size(); + Vector<RefPtr<APIObject> > wkGuesses(numGuesses); + for (unsigned i = 0; i < numGuesses; ++i) + wkGuesses[i] = WebString::create(m_grammarDetail.guesses[i]); + return ImmutableArray::adopt(wkGuesses); +} + +WebGrammarDetail::WebGrammarDetail(const WebCore::GrammarDetail& grammarDetail) + : m_grammarDetail(grammarDetail) +{ +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebGrammarDetail.h b/Source/WebKit2/UIProcess/win/WebGrammarDetail.h new file mode 100644 index 0000000..ff79b5c --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebGrammarDetail.h @@ -0,0 +1,62 @@ +/* + * 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 WebGrammarDetail_h +#define WebGrammarDetail_h + +#include "APIObject.h" +#include <WebCore/TextCheckerClient.h> +#include <wtf/Forward.h> +#include <wtf/PassRefPtr.h> + +namespace WebKit { + +class ImmutableArray; + +class WebGrammarDetail : public APIObject { +public: + static const Type APIType = TypeGrammarDetail; + static PassRefPtr<WebGrammarDetail> create(int location, int length, ImmutableArray* guesses, const String& userDescription); + static PassRefPtr<WebGrammarDetail> create(const WebCore::GrammarDetail&); + + int location() const { return m_grammarDetail.location; } + int length() const { return m_grammarDetail.length; } + PassRefPtr<ImmutableArray> guesses() const; + const String& userDescription() const { return m_grammarDetail.userDescription; } + + const WebCore::GrammarDetail& grammarDetail() { return m_grammarDetail; } + +private: + WebGrammarDetail(int location, int length, ImmutableArray* guesses, const String& userDescription); + WebGrammarDetail(const WebCore::GrammarDetail&); + + virtual Type type() const { return APIType; } + + WebCore::GrammarDetail m_grammarDetail; +}; + +} // namespace WebKit + +#endif // WebGrammarDetail_h diff --git a/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp index 30b012e..ec5e91c 100644 --- a/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp @@ -30,6 +30,7 @@ #include "WebKitBundle.h" #include "WebPageProxy.h" +#include "WebProcessProxy.h" #include "WebView.h" #include <WebCore/WebCoreInstanceHandle.h> #include <wtf/PassRefPtr.h> @@ -155,7 +156,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() ASSERT(!m_inspectorWindow); RECT emptyRect = { 0 }; - m_inspectorView = WebView::create(emptyRect, m_page->context(), inspectorPageGroup(), 0); + m_inspectorView = WebView::create(emptyRect, m_page->process()->context(), inspectorPageGroup(), 0); return m_inspectorView->page(); } diff --git a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp index 1745a06..40a4cbb 100644 --- a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "WebPageProxy.h" +#include "WebPopupMenuProxyWin.h" #include "resource.h" #include <tchar.h> @@ -54,4 +55,12 @@ String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent return makeString("Mozilla/5.0 (", osVersion, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)", applicationNameForUserAgent.isEmpty() ? "" : " ", applicationNameForUserAgent); } +void WebPageProxy::setPopupMenuSelectedIndex(int32_t selectedIndex) +{ + if (!m_activePopupMenu) + return; + + static_cast<WebPopupMenuProxyWin*>(m_activePopupMenu.get())->setFocusedIndex(selectedIndex); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp index eebde75..a8d8063 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp @@ -29,6 +29,7 @@ #include "config.h" #include "WebPopupMenuProxyWin.h" +#include "NativeWebMouseEvent.h" #include "WebView.h" #include <WebCore/WebCoreInstanceHandle.h> #include <WebCore/ScrollbarTheme.h> @@ -324,8 +325,26 @@ void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, TextDirection, dou m_showPopup = false; ::ShowWindow(m_popup, SW_HIDE); - if (m_client) - m_client->valueChangedForPopupMenu(this, m_newSelectedIndex); + if (!m_client) + return; + + m_client->valueChangedForPopupMenu(this, m_newSelectedIndex); + + // <https://bugs.webkit.org/show_bug.cgi?id=57904> In order to properly call the onClick() + // handler on a <select> element, we need to fake a mouse up event in the main window. + // The main window already received the mouse down, which showed this popup, but upon + // selection of an item the mouse up gets eaten by the popup menu. So we take the mouse down + // event, change the message type to a mouse up event, and post that in the message queue. + // Thus, we are virtually clicking at the + // same location where the mouse down event occurred. This allows the hit test to select + // the correct element, and thereby call the onClick() JS handler. + if (!m_client->currentlyProcessedMouseDownEvent()) + return; + + const MSG* initiatingWinEvent = m_client->currentlyProcessedMouseDownEvent()->nativeEvent(); + MSG fakeEvent = *initiatingWinEvent; + fakeEvent.message = WM_LBUTTONUP; + ::PostMessage(fakeEvent.hwnd, fakeEvent.message, fakeEvent.wParam, fakeEvent.lParam); } void WebPopupMenuProxyWin::hidePopupMenu() diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h index 5a20edf..9d6d5b2 100644 --- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h +++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h @@ -51,6 +51,8 @@ public: virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double scaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex); virtual void hidePopupMenu(); + bool setFocusedIndex(int index, bool hotTracking = false); + void hide() { hidePopupMenu(); } private: @@ -63,8 +65,10 @@ private: virtual int scrollPosition(WebCore::Scrollbar*) const; virtual void setScrollOffset(const WebCore::IntPoint&); virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&); + virtual void invalidateScrollCornerRect(const WebCore::IntRect&) { } virtual bool isActive() const { return true; } - virtual bool scrollbarCornerPresent() const { return false; } + virtual bool isScrollCornerVisible() const { return false; } + virtual WebCore::IntRect scrollCornerRect() const { return WebCore::IntRect(); } virtual WebCore::Scrollbar* verticalScrollbar() const { return m_scrollbar.get(); } // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. @@ -107,7 +111,6 @@ private: void paint(const WebCore::IntRect& damageRect, HDC = 0); int visibleItems() const; int listIndexAtPoint(const WebCore::IntPoint&) const; - bool setFocusedIndex(int index, bool hotTracking = false); int focusedIndex() const; void focusFirst(); void focusLast(); diff --git a/Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp new file mode 100644 index 0000000..1856b3b --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebProcessProxy.h" + +namespace WebKit { + +Vector<HWND> WebProcessProxy::windowsToReceiveSentMessagesWhileWaitingForSyncReply() +{ + return Vector<HWND>(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebTextChecker.cpp b/Source/WebKit2/UIProcess/win/WebTextChecker.cpp new file mode 100644 index 0000000..2761844 --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebTextChecker.cpp @@ -0,0 +1,84 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebTextChecker.h" + +#include "TextChecker.h" +#include "WKAPICast.h" +#include "WebContext.h" +#include <wtf/RefPtr.h> + +namespace WebKit { + +WebTextChecker* WebTextChecker::shared() +{ + static WebTextChecker* textChecker = adoptRef(new WebTextChecker).leakRef(); + return textChecker; +} + +WebTextChecker::WebTextChecker() +{ +} + +void WebTextChecker::setClient(const WKTextCheckerClient* client) +{ + m_client.initialize(client); +} + +static void updateStateForAllWebProcesses() +{ + const Vector<WebContext*>& contexts = WebContext::allContexts(); + for (size_t i = 0; i < contexts.size(); ++i) { + WebProcessProxy* webProcess = contexts[i]->process(); + if (!webProcess) + continue; + webProcess->updateTextCheckerState(); + } +} + +void WebTextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled) +{ + TextChecker::continuousSpellCheckingEnabledStateChanged(enabled); + updateStateForAllWebProcesses(); +} + +void WebTextChecker::grammarCheckingEnabledStateChanged(bool enabled) +{ + TextChecker::grammarCheckingEnabledStateChanged(enabled); + updateStateForAllWebProcesses(); +} + +void WebTextChecker::checkSpelling(const WebPageProxy* page, bool startBeforeSelection) +{ + page->advanceToNextMisspelling(startBeforeSelection); +} + +void WebTextChecker::changeSpellingToWord(const WebPageProxy* page, const String& text) +{ + page->changeSpellingToWord(text); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebTextChecker.h b/Source/WebKit2/UIProcess/win/WebTextChecker.h new file mode 100644 index 0000000..a1c574c --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebTextChecker.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebTextChecker_h +#define WebTextChecker_h + +#include "APIObject.h" +#include "WKTextChecker.h" +#include "WebTextCheckerClient.h" +#include <wtf/Forward.h> + +namespace WebKit { + +class WebPageProxy; + +class WebTextChecker : public APIObject { +public: + static const Type APIType = TypeTextChecker; + + static WebTextChecker* shared(); + + void setClient(const WKTextCheckerClient*); + WebTextCheckerClient& client() { return m_client; } + + void continuousSpellCheckingEnabledStateChanged(bool); + void grammarCheckingEnabledStateChanged(bool); + + void checkSpelling(const WebPageProxy*, bool startBeforeSelection); + void changeSpellingToWord(const WebPageProxy*, const String&); + +private: + WebTextChecker(); + + virtual Type type() const { return APIType; } + + WebTextCheckerClient m_client; +}; + +} // namespace WebKit + +#endif // WebTextChecker_h diff --git a/Source/WebKit2/UIProcess/win/WebTextCheckerClient.cpp b/Source/WebKit2/UIProcess/win/WebTextCheckerClient.cpp new file mode 100644 index 0000000..86e52c6 --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebTextCheckerClient.cpp @@ -0,0 +1,175 @@ +/* + * 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. + */ + +#include "config.h" +#include "WebTextCheckerClient.h" + +#include "ImmutableArray.h" +#include "WKAPICast.h" +#include "WKSharedAPICast.h" +#include "WebGrammarDetail.h" +#include "WebPageProxy.h" +#include <wtf/text/WTFString.h> + +namespace WebKit { + +bool WebTextCheckerClient::continuousSpellCheckingAllowed() +{ + if (!m_client.continuousSpellCheckingAllowed) + return false; + + return m_client.continuousSpellCheckingAllowed(m_client.clientInfo); +} + +bool WebTextCheckerClient::continuousSpellCheckingEnabled() +{ + if (!m_client.continuousSpellCheckingEnabled) + return false; + + return m_client.continuousSpellCheckingEnabled(m_client.clientInfo); +} + +void WebTextCheckerClient::setContinuousSpellCheckingEnabled(bool enabled) +{ + if (!m_client.setContinuousSpellCheckingEnabled) + return; + + m_client.setContinuousSpellCheckingEnabled(enabled, m_client.clientInfo); +} + +bool WebTextCheckerClient::grammarCheckingEnabled() +{ + if (!m_client.grammarCheckingEnabled) + return false; + + return m_client.grammarCheckingEnabled(m_client.clientInfo); +} + +void WebTextCheckerClient::setGrammarCheckingEnabled(bool enabled) +{ + if (!m_client.setGrammarCheckingEnabled) + return; + + m_client.setGrammarCheckingEnabled(enabled, m_client.clientInfo); +} + +uint64_t WebTextCheckerClient::uniqueSpellDocumentTag(WebPageProxy* page) +{ + if (!m_client.uniqueSpellDocumentTag) + return 0; + + return m_client.uniqueSpellDocumentTag(toAPI(page), m_client.clientInfo); +} + +void WebTextCheckerClient::closeSpellDocumentWithTag(uint64_t tag) +{ + if (!m_client.closeSpellDocumentWithTag) + return; + + m_client.closeSpellDocumentWithTag(tag, m_client.clientInfo); +} + +void WebTextCheckerClient::checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength) +{ + if (!m_client.checkSpellingOfString) + return; + + m_client.checkSpellingOfString(tag, toAPI(text.impl()), &misspellingLocation, &misspellingLength, m_client.clientInfo); +} + +void WebTextCheckerClient::checkGrammarOfString(uint64_t tag, const String& text, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength) +{ + if (!m_client.checkGrammarOfString) + return; + + WKArrayRef wkGrammarDetailsRef = 0; + m_client.checkGrammarOfString(tag, toAPI(text.impl()), &wkGrammarDetailsRef, &badGrammarLocation, &badGrammarLength, m_client.clientInfo); + + RefPtr<ImmutableArray> wkGrammarDetails = adoptRef(toImpl(wkGrammarDetailsRef)); + size_t numGrammarDetails = wkGrammarDetails->size(); + for (size_t i = 0; i < numGrammarDetails; ++i) + grammarDetails.append(wkGrammarDetails->at<WebGrammarDetail>(i)->grammarDetail()); +} + +bool WebTextCheckerClient::spellingUIIsShowing() +{ + if (!m_client.spellingUIIsShowing) + return false; + + return m_client.spellingUIIsShowing(m_client.clientInfo); +} + +void WebTextCheckerClient::toggleSpellingUIIsShowing() +{ + if (!m_client.toggleSpellingUIIsShowing) + return; + + return m_client.toggleSpellingUIIsShowing(m_client.clientInfo); +} + +void WebTextCheckerClient::updateSpellingUIWithMisspelledWord(uint64_t tag, const String& misspelledWord) +{ + if (!m_client.updateSpellingUIWithMisspelledWord) + return; + + m_client.updateSpellingUIWithMisspelledWord(tag, toAPI(misspelledWord.impl()), m_client.clientInfo); +} + +void WebTextCheckerClient::updateSpellingUIWithGrammarString(uint64_t tag, const String& badGrammarPhrase, const WebCore::GrammarDetail& grammarDetail) +{ + if (!m_client.updateSpellingUIWithGrammarString) + return; + + m_client.updateSpellingUIWithGrammarString(tag, toAPI(badGrammarPhrase.impl()), toAPI(grammarDetail), m_client.clientInfo); +} + +void WebTextCheckerClient::guessesForWord(uint64_t tag, const String& word, Vector<String>& guesses) +{ + if (!m_client.guessesForWord) + return; + + RefPtr<ImmutableArray> wkGuesses = adoptRef(toImpl(m_client.guessesForWord(tag, toAPI(word.impl()), m_client.clientInfo))); + size_t numGuesses = wkGuesses->size(); + for (size_t i = 0; i < numGuesses; ++i) + guesses.append(wkGuesses->at<WebString>(i)->string()); +} + +void WebTextCheckerClient::learnWord(uint64_t tag, const String& word) +{ + if (!m_client.learnWord) + return; + + m_client.learnWord(tag, toAPI(word.impl()), m_client.clientInfo); +} + +void WebTextCheckerClient::ignoreWord(uint64_t tag, const String& word) +{ + if (!m_client.ignoreWord) + return; + + m_client.ignoreWord(tag, toAPI(word.impl()), m_client.clientInfo); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebTextCheckerClient.h b/Source/WebKit2/UIProcess/win/WebTextCheckerClient.h new file mode 100644 index 0000000..50fb42d --- /dev/null +++ b/Source/WebKit2/UIProcess/win/WebTextCheckerClient.h @@ -0,0 +1,61 @@ +/* + * 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 WebTextCheckerClient_h +#define WebTextCheckerClient_h + +#include "APIClient.h" +#include "WKTextChecker.h" +#include <WebCore/TextCheckerClient.h> +#include <wtf/Forward.h> +#include <wtf/Vector.h> + +namespace WebKit { + +class WebPageProxy; + +class WebTextCheckerClient : public APIClient<WKTextCheckerClient> { +public: + bool continuousSpellCheckingAllowed(); + bool continuousSpellCheckingEnabled(); + void setContinuousSpellCheckingEnabled(bool); + bool grammarCheckingEnabled(); + void setGrammarCheckingEnabled(bool); + uint64_t uniqueSpellDocumentTag(WebPageProxy*); + void closeSpellDocumentWithTag(uint64_t); + void checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength); + void checkGrammarOfString(uint64_t tag, const String& text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength); + bool spellingUIIsShowing(); + void toggleSpellingUIIsShowing(); + void updateSpellingUIWithMisspelledWord(uint64_t tag, const String& misspelledWord); + void updateSpellingUIWithGrammarString(uint64_t tag, const String& badGrammarPhrase, const WebCore::GrammarDetail&); + void guessesForWord(uint64_t tag, const String& word, Vector<String>& guesses); + void learnWord(uint64_t tag, const String& word); + void ignoreWord(uint64_t tag, const String& word); +}; + +} // namespace WebKit + +#endif // WebTextCheckerClient_h diff --git a/Source/WebKit2/UIProcess/win/WebUndoClient.cpp b/Source/WebKit2/UIProcess/win/WebUndoClient.cpp index 9bc96f5..9b86540 100644 --- a/Source/WebKit2/UIProcess/win/WebUndoClient.cpp +++ b/Source/WebKit2/UIProcess/win/WebUndoClient.cpp @@ -49,5 +49,21 @@ void WebUndoClient::clearAllEditCommands(WebView* view) m_client.clearAllEditCommands(toAPI(view), m_client.clientInfo); } +bool WebUndoClient::canUndoRedo(WebView* view, WebPageProxy::UndoOrRedo undoOrRedo) +{ + if (!m_client.canUndoRedo) + return false; + + return m_client.canUndoRedo(toAPI(view), undoOrRedo, m_client.clientInfo); +} + +void WebUndoClient::executeUndoRedo(WebView* view, WebPageProxy::UndoOrRedo undoOrRedo) +{ + if (!m_client.executeUndoRedo) + return; + + m_client.executeUndoRedo(toAPI(view), undoOrRedo, m_client.clientInfo); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebUndoClient.h b/Source/WebKit2/UIProcess/win/WebUndoClient.h index 12582c0..b7fdc15 100755 --- a/Source/WebKit2/UIProcess/win/WebUndoClient.h +++ b/Source/WebKit2/UIProcess/win/WebUndoClient.h @@ -39,6 +39,8 @@ class WebUndoClient : public APIClient<WKViewUndoClient> { public: void registerEditCommand(WebView*, PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); void clearAllEditCommands(WebView*); + bool canUndoRedo(WebView*, WebPageProxy::UndoOrRedo); + void executeUndoRedo(WebView*, WebPageProxy::UndoOrRedo); }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/win/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp index 1447864..8cecb02 100644 --- a/Source/WebKit2/UIProcess/win/WebView.cpp +++ b/Source/WebKit2/UIProcess/win/WebView.cpp @@ -31,6 +31,7 @@ #include "FindIndicator.h" #include "Logging.h" #include "NativeWebKeyboardEvent.h" +#include "NativeWebMouseEvent.h" #include "Region.h" #include "RunLoop.h" #include "WKAPICast.h" @@ -44,13 +45,14 @@ #include <WebCore/BitmapInfo.h> #include <WebCore/Cursor.h> #include <WebCore/FloatRect.h> -#if PLATFORM(CG) +#if USE(CG) #include <WebCore/GraphicsContextCG.h> #endif #include <WebCore/IntRect.h> #include <WebCore/SoftLinking.h> #include <WebCore/WebCoreInstanceHandle.h> #include <WebCore/WindowMessageBroadcaster.h> +#include <WebCore/WindowsTouch.h> #include <wtf/text/WTFString.h> namespace Ime { @@ -67,6 +69,17 @@ SOFT_LINK(IMM32, ImmNotifyIME, BOOL, WINAPI, (HIMC hIMC, DWORD dwAction, DWORD d SOFT_LINK(IMM32, ImmAssociateContextEx, BOOL, WINAPI, (HWND hWnd, HIMC hIMC, DWORD dwFlags), (hWnd, hIMC, dwFlags)) }; +// Soft link functions for gestures and panning. +SOFT_LINK_LIBRARY(USER32); +SOFT_LINK_OPTIONAL(USER32, GetGestureInfo, BOOL, WINAPI, (HGESTUREINFO, PGESTUREINFO)); +SOFT_LINK_OPTIONAL(USER32, SetGestureConfig, BOOL, WINAPI, (HWND, DWORD, UINT, PGESTURECONFIG, UINT)); +SOFT_LINK_OPTIONAL(USER32, CloseGestureInfoHandle, BOOL, WINAPI, (HGESTUREINFO)); + +SOFT_LINK_LIBRARY(Uxtheme); +SOFT_LINK_OPTIONAL(Uxtheme, BeginPanningFeedback, BOOL, WINAPI, (HWND)); +SOFT_LINK_OPTIONAL(Uxtheme, EndPanningFeedback, BOOL, WINAPI, (HWND, BOOL)); +SOFT_LINK_OPTIONAL(Uxtheme, UpdatePanningFeedback, BOOL, WINAPI, (HWND, LONG, LONG, BOOL)); + using namespace WebCore; namespace WebKit { @@ -157,6 +170,12 @@ LRESULT WebView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_VSCROLL: lResult = onVerticalScroll(hWnd, message, wParam, lParam, handled); break; + case WM_GESTURENOTIFY: + lResult = onGestureNotify(hWnd, message, wParam, lParam, handled); + break; + case WM_GESTURE: + lResult = onGesture(hWnd, message, wParam, lParam, handled); + break; case WM_SYSKEYDOWN: case WM_KEYDOWN: case WM_SYSCHAR: @@ -254,6 +273,10 @@ WebView::WebView(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND p , m_inIMEComposition(0) , m_findIndicatorCallback(0) , m_findIndicatorCallbackContext(0) + , m_lastPanX(0) + , m_lastPanY(0) + , m_overPanY(0) + , m_gestureReachedScrollingLimit(false) { registerWebViewWindowClass(); @@ -365,7 +388,7 @@ void WebView::windowAncestryDidChange() LRESULT WebView::onMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) { - WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(hWnd, message, wParam, lParam, m_wasActivatedByMouseEvent); + NativeWebMouseEvent mouseEvent = NativeWebMouseEvent(hWnd, message, wParam, lParam, m_wasActivatedByMouseEvent); setWasActivatedByMouseEvent(false); switch (message) { @@ -480,6 +503,109 @@ LRESULT WebView::onVerticalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM return 0; } +LRESULT WebView::onGestureNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) +{ + // We shouldn't be getting any gesture messages without SetGestureConfig soft-linking correctly. + ASSERT(SetGestureConfigPtr()); + + GESTURENOTIFYSTRUCT* gn = reinterpret_cast<GESTURENOTIFYSTRUCT*>(lParam); + + POINT localPoint = { gn->ptsLocation.x, gn->ptsLocation.y }; + ::ScreenToClient(m_window, &localPoint); + + bool canPan = m_page->gestureWillBegin(localPoint); + + DWORD dwPanWant = GC_PAN | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER; + DWORD dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; + if (canPan) + dwPanWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; + else + dwPanBlock |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; + + GESTURECONFIG gc = { GID_PAN, dwPanWant, dwPanBlock }; + return SetGestureConfigPtr()(m_window, 0, 1, &gc, sizeof(gc)); +} + +LRESULT WebView::onGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) +{ + ASSERT(GetGestureInfoPtr()); + ASSERT(CloseGestureInfoHandlePtr()); + ASSERT(UpdatePanningFeedbackPtr()); + ASSERT(BeginPanningFeedbackPtr()); + ASSERT(EndPanningFeedbackPtr()); + + if (!GetGestureInfoPtr() || !CloseGestureInfoHandlePtr() || !UpdatePanningFeedbackPtr() || !BeginPanningFeedbackPtr() || !EndPanningFeedbackPtr()) { + handled = false; + return 0; + } + + HGESTUREINFO gestureHandle = reinterpret_cast<HGESTUREINFO>(lParam); + GESTUREINFO gi = {0}; + gi.cbSize = sizeof(GESTUREINFO); + + if (!GetGestureInfoPtr()(gestureHandle, &gi)) { + handled = false; + return 0; + } + + switch (gi.dwID) { + case GID_BEGIN: + m_lastPanX = gi.ptsLocation.x; + m_lastPanY = gi.ptsLocation.y; + break; + case GID_END: + m_page->gestureDidEnd(); + break; + case GID_PAN: { + int currentX = gi.ptsLocation.x; + int currentY = gi.ptsLocation.y; + + // Reverse the calculations because moving your fingers up should move the screen down, and + // vice-versa. + int deltaX = m_lastPanX - currentX; + int deltaY = m_lastPanY - currentY; + + m_lastPanX = currentX; + m_lastPanY = currentY; + + // Calculate the overpan for window bounce. + m_overPanY -= deltaY; + + if (deltaX || deltaY) + m_page->gestureDidScroll(IntSize(deltaX, deltaY)); + + if (gi.dwFlags & GF_BEGIN) { + BeginPanningFeedbackPtr()(m_window); + m_gestureReachedScrollingLimit = false; + m_overPanY = 0; + } else if (gi.dwFlags & GF_END) { + EndPanningFeedbackPtr()(m_window, true); + m_overPanY = 0; + } + + // FIXME: Support horizontal window bounce - <http://webkit.org/b/58068>. + // FIXME: Window Bounce doesn't undo until user releases their finger - <http://webkit.org/b/58069>. + + if (m_gestureReachedScrollingLimit) + UpdatePanningFeedbackPtr()(m_window, 0, m_overPanY, gi.dwFlags & GF_INERTIA); + + CloseGestureInfoHandlePtr()(gestureHandle); + + handled = true; + return 0; + } + default: + break; + } + + // If we get to this point, the gesture has not been handled. We forward + // the call to DefWindowProc by returning false, and we don't need to + // to call CloseGestureInfoHandle. + // http://msdn.microsoft.com/en-us/library/dd353228(VS.85).aspx + handled = false; + return 0; +} + LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled) { m_page->handleKeyboardEvent(NativeWebKeyboardEvent(hWnd, message, wParam, lParam)); @@ -565,8 +691,22 @@ LRESULT WebView::onPrintClientEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool RECT winRect; ::GetClientRect(hWnd, &winRect); + // Twidding the visibility flags tells the DrawingArea to resume painting. Right now, the + // the visible state of the view only affects whether or not painting happens, but in the + // future it could affect more, which we wouldn't want to touch here. + + // FIXME: We should have a better way of telling the WebProcess to draw even if we're + // invisible than twiddling the visibility flag. + + bool wasVisible = isViewVisible(); + if (!wasVisible) + setIsVisible(true); + paint(hdc, winRect); + if (!wasVisible) + setIsVisible(false); + handled = true; return 0; } @@ -626,11 +766,8 @@ LRESULT WebView::onShowWindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARA // lParam is 0 when the message is sent because of a ShowWindow call. // FIXME: Since we don't get notified when an ancestor window is hidden or shown, we will keep // painting even when we have a hidden ancestor. <http://webkit.org/b/54104> - if (!lParam) { - m_isVisible = wParam; - if (m_page) - m_page->viewStateDidChange(WebPageProxy::ViewIsVisible); - } + if (!lParam) + setIsVisible(wParam); handled = false; return 0; @@ -760,6 +897,15 @@ void WebView::close() { m_undoClient.initialize(0); ::RevokeDragDrop(m_window); + if (m_window) { + // We can't check IsWindow(m_window) here, because that will return true even while + // we're already handling WM_DESTROY. So we check !m_isBeingDestroyed instead. + if (!m_isBeingDestroyed) + DestroyWindow(m_window); + // Either we just destroyed m_window, or it's in the process of being destroyed. Either + // way, we clear it out to make sure we don't try to use it later. + m_window = 0; + } setParentWindow(0); m_page->close(); } @@ -844,10 +990,6 @@ void WebView::didRelaunchProcess() ::InvalidateRect(m_window, 0, TRUE); } -void WebView::takeFocus(bool) -{ -} - void WebView::toolTipChanged(const String&, const String& newToolTip) { if (!m_toolTipWindow) @@ -929,6 +1071,16 @@ void WebView::clearAllEditCommands() m_undoClient.clearAllEditCommands(this); } +bool WebView::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) +{ + return m_undoClient.canUndoRedo(this, undoOrRedo); +} + +void WebView::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) +{ + m_undoClient.executeUndoRedo(this, undoOrRedo); +} + void WebView::reapplyEditCommand(WebEditCommandProxy* command) { if (!m_page->isValid() || !m_page->isValidEditCommand(command)) @@ -996,7 +1148,7 @@ void WebView::setInputMethodState(bool enabled) void WebView::compositionSelectionChanged(bool hasChanged) { - if (m_page->selectionState().hasComposition && !hasChanged) + if (m_page->editorState().hasComposition && !hasChanged) resetIME(); } @@ -1104,7 +1256,7 @@ bool WebView::onIMEComposition(LPARAM lparam) if (!hInputContext) return true; - if (!m_page->selectionState().isContentEditable) + if (!m_page->editorState().isContentEditable) return true; prepareCandidateWindow(hInputContext); @@ -1147,7 +1299,7 @@ bool WebView::onIMEEndComposition() LOG(TextInput, "onIMEEndComposition"); // If the composition hasn't been confirmed yet, it needs to be cancelled. // This happens after deleting the last character from inline input hole. - if (m_page->selectionState().hasComposition) + if (m_page->editorState().hasComposition) m_page->confirmComposition(String()); if (m_inIMEComposition) @@ -1158,7 +1310,7 @@ bool WebView::onIMEEndComposition() LRESULT WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos) { - if (charPos->dwCharPos && !m_page->selectionState().hasComposition) + if (charPos->dwCharPos && !m_page->editorState().hasComposition) return 0; IntRect caret = m_page->firstRectForCharacterInSelectedRange(charPos->dwCharPos); charPos->pt.x = caret.x(); @@ -1190,7 +1342,7 @@ LRESULT WebView::onIMERequestReconvertString(RECONVERTSTRING* reconvertString) LRESULT WebView::onIMERequest(WPARAM request, LPARAM data) { LOG(TextInput, "onIMERequest %s", imeRequestName(request).latin1().data()); - if (!m_page->selectionState().isContentEditable) + if (!m_page->editorState().isContentEditable) return 0; switch (request) { @@ -1254,7 +1406,7 @@ void WebView::setFindIndicator(PassRefPtr<FindIndicator> prpFindIndicator, bool hbmp = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0); HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc, hbmp)); -#if PLATFORM(CG) +#if USE(CG) RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(bits, width, height, 8, width * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst)); @@ -1310,12 +1462,28 @@ void WebView::didChangeScrollbarsForMainFrame() const { } +void WebView::findStringInCustomRepresentation(const String&, FindOptions, unsigned) +{ +} + +void WebView::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned) +{ +} + void WebView::setIsInWindow(bool isInWindow) { m_isInWindow = isInWindow; m_page->viewStateDidChange(WebPageProxy::ViewIsInWindow); } +void WebView::setIsVisible(bool isVisible) +{ + m_isVisible = isVisible; + + if (m_page) + m_page->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + #if USE(ACCELERATED_COMPOSITING) void WebView::enterAcceleratedCompositingMode(const LayerTreeContext&) @@ -1425,7 +1593,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragEnter(IDataObject* pDataObject, DWORD grf POINTL localpt = pt; ::ScreenToClient(m_window, (LPPOINT)&localpt); DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); - m_page->performDragControllerAction(DragControllerActionEntered, &data); + m_page->dragEntered(&data); *pdwEffect = dragOperationToDragCursor(m_page->dragOperation()); m_lastDropEffect = *pdwEffect; @@ -1443,7 +1611,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragOver(DWORD grfKeyState, POINTL pt, DWORD* POINTL localpt = pt; ::ScreenToClient(m_window, (LPPOINT)&localpt); DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); - m_page->performDragControllerAction(DragControllerActionUpdated, &data); + m_page->dragUpdated(&data); *pdwEffect = dragOperationToDragCursor(m_page->dragOperation()); } else *pdwEffect = DROPEFFECT_NONE; @@ -1459,7 +1627,7 @@ HRESULT STDMETHODCALLTYPE WebView::DragLeave() if (m_dragData) { DragData data(m_dragData.get(), IntPoint(), IntPoint(), DragOperationNone); - m_page->performDragControllerAction(DragControllerActionExited, &data); + m_page->dragExited(&data); m_dragData = 0; m_page->resetDragOperation(); } @@ -1476,7 +1644,9 @@ HRESULT STDMETHODCALLTYPE WebView::Drop(IDataObject* pDataObject, DWORD grfKeySt POINTL localpt = pt; ::ScreenToClient(m_window, (LPPOINT)&localpt); DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); - m_page->performDragControllerAction(DragControllerActionPerformDrag, &data); + + SandboxExtension::Handle sandboxExtensionHandle; + m_page->performDrag(&data, String(), sandboxExtensionHandle); return S_OK; } diff --git a/Source/WebKit2/UIProcess/win/WebView.h b/Source/WebKit2/UIProcess/win/WebView.h index 1d65179..d62311c 100644 --- a/Source/WebKit2/UIProcess/win/WebView.h +++ b/Source/WebKit2/UIProcess/win/WebView.h @@ -60,6 +60,7 @@ public: void setParentWindow(HWND); void windowAncestryDidChange(); void setIsInWindow(bool); + void setIsVisible(bool); void setOverrideCursor(HCURSOR); void setInitialFocus(bool forward); void setScrollOffsetOnNextResize(const WebCore::IntSize&); @@ -97,6 +98,8 @@ private: LRESULT onWheelEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onHorizontalScroll(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onVerticalScroll(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); + LRESULT onGestureNotify(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); + LRESULT onGesture(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onKeyEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); LRESULT onPrintClientEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); @@ -154,13 +157,13 @@ private: virtual void processDidCrash(); virtual void didRelaunchProcess(); virtual void pageClosed(); - virtual void takeFocus(bool direction); - virtual void setFocus(bool focused) { } virtual void toolTipChanged(const WTF::String&, const WTF::String&); virtual void setCursor(const WebCore::Cursor&); virtual void setViewportArguments(const WebCore::ViewportArguments&); virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); virtual void clearAllEditCommands(); + virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); + virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); @@ -182,8 +185,13 @@ private: WebCore::DragOperation keyStateToDragOperation(DWORD grfKeyState) const; virtual void didChangeScrollbarsForMainFrame() const; + virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount); + virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount); + virtual HWND nativeWindow(); + virtual void setGestureReachedScrollingLimit(bool limitReached) { m_gestureReachedScrollingLimit = limitReached; } + // WebCore::WindowMessageListener virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM); @@ -219,6 +227,13 @@ private: // Thus, on return from DoDragDrop we have the correct pdwEffect for the drag-and-drop operation. // (see https://bugs.webkit.org/show_bug.cgi?id=29264) DWORD m_lastDropEffect; + + int m_lastPanX; + int m_lastPanY; + + int m_overPanY; + + bool m_gestureReachedScrollingLimit; }; } // namespace WebKit diff --git a/Source/WebKit2/WebKit2.pro b/Source/WebKit2/WebKit2.pro index d3b0814..47a1ebc 100644 --- a/Source/WebKit2/WebKit2.pro +++ b/Source/WebKit2/WebKit2.pro @@ -107,6 +107,9 @@ HEADERS += \ Platform/SharedMemory.h \ Platform/WorkItem.h \ Platform/WorkQueue.h \ + PluginProcess/PluginControllerProxy.h \ + PluginProcess/PluginProcess.h \ + PluginProcess/WebProcessConnection.h \ Shared/ShareableBitmap.h \ Shared/CacheModel.h \ Shared/ChildProcess.h \ @@ -120,6 +123,7 @@ HEADERS += \ Shared/MutableArray.h \ Shared/MutableDictionary.h \ Shared/NativeWebKeyboardEvent.h \ + Shared/NativeWebMouseEvent.h \ Shared/OriginAndDatabases.h \ Shared/PlatformPopupMenuData.h \ Shared/PrintInfo.h \ @@ -207,6 +211,7 @@ HEADERS += \ UIProcess/WebGeolocationProvider.h \ UIProcess/WebHistoryClient.h \ UIProcess/WebIconDatabase.h \ + UIProcess/WebIconDatabaseClient.h \ UIProcess/WebInspectorProxy.h \ UIProcess/WebKeyValueStorageManagerProxy.h \ UIProcess/WebLoaderClient.h \ @@ -297,17 +302,23 @@ SOURCES += \ Platform/CoreIPC/BinarySemaphore.cpp \ Platform/CoreIPC/Connection.cpp \ Platform/CoreIPC/DataReference.cpp \ - Platform/CoreIPC/qt/AttachmentQt.cpp \ - Platform/CoreIPC/qt/ConnectionQt.cpp \ + Platform/CoreIPC/unix/AttachmentUnix.cpp \ + Platform/CoreIPC/unix/ConnectionUnix.cpp \ Platform/Logging.cpp \ Platform/Module.cpp \ Platform/RunLoop.cpp \ Platform/WorkQueue.cpp \ Platform/qt/ModuleQt.cpp \ Platform/qt/RunLoopQt.cpp \ - Platform/qt/SharedMemoryQt.cpp \ Platform/qt/WorkQueueQt.cpp \ + Platform/unix/SharedMemoryUnix.cpp \ + PluginProcess/PluginControllerProxy.cpp \ + PluginProcess/PluginProcess.cpp \ + PluginProcess/WebProcessConnection.cpp \ + PluginProcess/qt/PluginControllerProxyQt.cpp \ + PluginProcess/qt/PluginProcessQt.cpp \ Shared/Plugins/Netscape/NetscapePluginModule.cpp \ + Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp \ Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp \ Shared/ShareableBitmap.cpp \ Shared/Plugins/NPRemoteObjectMap.cpp \ @@ -353,6 +364,7 @@ SOURCES += \ Shared/WebWheelEvent.cpp \ Shared/qt/ShareableBitmapQt.cpp \ Shared/qt/NativeWebKeyboardEventQt.cpp \ + Shared/qt/NativeWebMouseEventQt.cpp \ Shared/qt/UpdateChunk.cpp \ Shared/qt/WebCoreArgumentCodersQt.cpp \ Shared/qt/WebEventFactoryQt.cpp \ @@ -403,6 +415,7 @@ SOURCES += \ UIProcess/WebGeolocationProvider.cpp \ UIProcess/WebHistoryClient.cpp \ UIProcess/WebIconDatabase.cpp \ + UIProcess/WebIconDatabaseClient.cpp \ UIProcess/WebInspectorProxy.cpp \ UIProcess/WebKeyValueStorageManagerProxy.cpp \ UIProcess/WebLoaderClient.cpp \ @@ -466,6 +479,7 @@ SOURCES += \ WebProcess/Plugins/Netscape/NPRuntimeUtilities.cpp \ WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp \ WebProcess/Plugins/Netscape/NetscapePlugin.cpp \ + WebProcess/Plugins/Netscape/NetscapePluginNone.cpp \ WebProcess/Plugins/Netscape/NetscapePluginStream.cpp \ WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp \ WebProcess/Plugins/Netscape/qt/PluginProxyQt.cpp \ diff --git a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj index d54f8f2..d899e1d 100644 --- a/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj +++ b/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj @@ -179,7 +179,7 @@ 1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */; }; 1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA417C912C00CCA002BE67B /* TextChecker.h */; }; 1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */; }; - 1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA41AB412C02EC4002BE67B /* SelectionState.h */; }; + 1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA41AB412C02EC4002BE67B /* EditorState.h */; }; 1AA4792312A59FD9008236C3 /* PluginProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */; }; 1AA479B012A5A436008236C3 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; }; 1AA56F2911E92BC80061B882 /* PluginController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA56F2811E92BC80061B882 /* PluginController.h */; }; @@ -236,6 +236,7 @@ 1CA8B954127C891500576C2B /* WebInspectorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */; }; 29CD55AA128E294F00133C85 /* AccessibilityWebPageObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CD55A8128E294F00133C85 /* AccessibilityWebPageObject.h */; }; 29CD55AB128E294F00133C85 /* AccessibilityWebPageObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29CD55A9128E294F00133C85 /* AccessibilityWebPageObject.mm */; }; + 31EA25D2134F78C0005B1452 /* NativeWebMouseEventMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */; }; 330934471315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 330934431315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp */; }; 330934481315B9220097A7BC /* WebCookieManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 330934441315B9220097A7BC /* WebCookieManagerMessages.h */; }; 330934491315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */; }; @@ -323,6 +324,8 @@ 51578B831209ECEF00A37C4A /* WebData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51578B821209ECEF00A37C4A /* WebData.h */; }; 5160BFE113381DF900918999 /* Logging.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160BFE013381DF900918999 /* Logging.mac.mm */; }; 516A4A5D120A2CCD00C05B7F /* WebError.h in Headers */ = {isa = PBXBuildFile; fileRef = 516A4A5B120A2CCD00C05B7F /* WebError.h */; }; + 51834592134532E90092B696 /* WebIconDatabaseClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51834590134532E80092B696 /* WebIconDatabaseClient.cpp */; }; + 51834593134532E90092B696 /* WebIconDatabaseClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51834591134532E80092B696 /* WebIconDatabaseClient.h */; }; 51871B5B127CB89D00F76232 /* WebContextMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51871B59127CB89D00F76232 /* WebContextMenu.cpp */; }; 51871B5C127CB89D00F76232 /* WebContextMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 51871B5A127CB89D00F76232 /* WebContextMenu.h */; }; 518ACAEA12AEE6BB00B04B83 /* WKProtectionSpaceTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 518ACAE912AEE6BB00B04B83 /* WKProtectionSpaceTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -643,7 +646,6 @@ BCB0B0E012305AB100B1341E /* UserMessageCoders.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB0B0DF12305AB100B1341E /* UserMessageCoders.h */; }; BCB28CC0120233D9007D99BC /* InjectedBundleMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */; }; BCB63478116BF10600603215 /* WebKit2.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB63477116BF10600603215 /* WebKit2.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BCB7346E11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */; }; BCB9E2431120DACA00A137E0 /* WebContext.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB9E2411120DACA00A137E0 /* WebContext.h */; }; BCB9E2441120DACA00A137E0 /* WebContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB9E2421120DACA00A137E0 /* WebContext.cpp */; }; BCB9E24B1120E15C00A137E0 /* WKContext.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB9E2491120E15C00A137E0 /* WKContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -762,11 +764,14 @@ C0E3AA7A1209E83000A49D01 /* ModuleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0E3AA481209E45000A49D01 /* ModuleMac.mm */; }; C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0E3AA451209E2BA00A49D01 /* Module.cpp */; }; C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */ = {isa = PBXBuildFile; fileRef = C0E3AA441209E2BA00A49D01 /* Module.h */; }; + C0FA52431345694A0028E8C2 /* LayerTreeHostCAMac.h in Headers */ = {isa = PBXBuildFile; fileRef = C0FA52421345694A0028E8C2 /* LayerTreeHostCAMac.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 */; }; + CD5C66A0134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */; }; + CD5C66A1134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */; }; CD6F75F4131B66D000D6B21E /* WebFullScreenManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA3E131A2E8A00EEDED2 /* WebFullScreenManagerProxy.cpp */; }; CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */; }; CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */; }; @@ -782,7 +787,11 @@ D3B9484911FF4B6500032B39 /* WebSearchPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */; }; E134F01712EA5D33004EC58D /* WKPrintingView.h in Headers */ = {isa = PBXBuildFile; fileRef = E134F01512EA5D11004EC58D /* WKPrintingView.h */; }; E134F01A12EA5D99004EC58D /* WKPrintingView.mm in Sources */ = {isa = PBXBuildFile; fileRef = E134F01912EA5D99004EC58D /* WKPrintingView.mm */; }; + E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */ = {isa = PBXBuildFile; fileRef = E179FD9B134D38060015B883 /* ArgumentCodersMac.h */; }; + E179FD9F134D38250015B883 /* ArgumentCodersMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */; }; E18C92F412DB9E7100CF2AEB /* PrintInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */; }; + E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; }; + E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1A31734134CEA80007C9A4F /* AttributedString.mm */; }; E1BB16A413201B9B00F49431 /* FullKeyboardAccessWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BB1688132018BA00F49431 /* FullKeyboardAccessWatcher.h */; }; E1BB16A513201B9B00F49431 /* FullKeyboardAccessWatcher.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1BB1689132018BA00F49431 /* FullKeyboardAccessWatcher.mm */; }; E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CC1B8E12D7EADF00625838 /* PrintInfo.h */; }; @@ -1046,7 +1055,7 @@ 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUtilities.cpp; sourceTree = "<group>"; }; 1AA417C912C00CCA002BE67B /* TextChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecker.h; sourceTree = "<group>"; }; 1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckerMac.mm; sourceTree = "<group>"; }; - 1AA41AB412C02EC4002BE67B /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = "<group>"; }; + 1AA41AB412C02EC4002BE67B /* EditorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorState.h; sourceTree = "<group>"; }; 1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessMac.mm; sourceTree = "<group>"; }; 1AA56F2811E92BC80061B882 /* PluginController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginController.h; sourceTree = "<group>"; }; 1AA5889011EE70400061B882 /* NetscapePluginStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginStream.h; sourceTree = "<group>"; }; @@ -1108,6 +1117,8 @@ 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorProxyMessages.h; sourceTree = "<group>"; }; 29CD55A8128E294F00133C85 /* AccessibilityWebPageObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityWebPageObject.h; sourceTree = "<group>"; }; 29CD55A9128E294F00133C85 /* AccessibilityWebPageObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityWebPageObject.mm; sourceTree = "<group>"; }; + 31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebMouseEventMac.mm; sourceTree = "<group>"; }; + 31EA25D3134F78D6005B1452 /* NativeWebMouseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebMouseEvent.h; sourceTree = "<group>"; }; 32DBCF5E0370ADEE00C91783 /* WebKit2Prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2Prefix.h; sourceTree = "<group>"; }; 330934431315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCookieManagerMessageReceiver.cpp; sourceTree = "<group>"; }; 330934441315B9220097A7BC /* WebCookieManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCookieManagerMessages.h; sourceTree = "<group>"; }; @@ -1204,6 +1215,8 @@ 516A4A5B120A2CCD00C05B7F /* WebError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebError.h; sourceTree = "<group>"; }; 517A33B3130B308C00F80CB5 /* WKApplicationCacheManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKApplicationCacheManager.cpp; sourceTree = "<group>"; }; 517A33B4130B308C00F80CB5 /* WKApplicationCacheManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKApplicationCacheManager.h; sourceTree = "<group>"; }; + 51834590134532E80092B696 /* WebIconDatabaseClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebIconDatabaseClient.cpp; sourceTree = "<group>"; }; + 51834591134532E80092B696 /* WebIconDatabaseClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseClient.h; sourceTree = "<group>"; }; 5184BC4A132E907A006B9E28 /* WebIconDatabase.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebIconDatabase.messages.in; sourceTree = "<group>"; }; 51871B59127CB89D00F76232 /* WebContextMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenu.cpp; sourceTree = "<group>"; }; 51871B5A127CB89D00F76232 /* WebContextMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMenu.h; sourceTree = "<group>"; }; @@ -1537,7 +1550,6 @@ BCB0B0DF12305AB100B1341E /* UserMessageCoders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageCoders.h; sourceTree = "<group>"; }; BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleMessageKinds.h; sourceTree = "<group>"; }; BCB63477116BF10600603215 /* WebKit2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2.h; sourceTree = "<group>"; }; - BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessProxyMessageKinds.h; sourceTree = "<group>"; }; BCB86F4B116AAACD00CE20B7 /* WebKit2.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKit2.xcconfig; sourceTree = "<group>"; }; BCB9E2411120DACA00A137E0 /* WebContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContext.h; sourceTree = "<group>"; }; BCB9E2421120DACA00A137E0 /* WebContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContext.cpp; sourceTree = "<group>"; }; @@ -1671,11 +1683,14 @@ C0E3AA441209E2BA00A49D01 /* Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Module.h; sourceTree = "<group>"; }; C0E3AA451209E2BA00A49D01 /* Module.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Module.cpp; sourceTree = "<group>"; }; C0E3AA481209E45000A49D01 /* ModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModuleMac.mm; sourceTree = "<group>"; }; + C0FA52421345694A0028E8C2 /* LayerTreeHostCAMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerTreeHostCAMac.h; 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>"; }; + CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageFullScreenClient.cpp; sourceTree = "<group>"; }; + CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageFullScreenClient.h; sourceTree = "<group>"; }; CD73BA37131A29FE00EEDED2 /* WebFullScreenManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebFullScreenManager.cpp; path = FullScreen/WebFullScreenManager.cpp; sourceTree = "<group>"; }; CD73BA38131A29FE00EEDED2 /* WebFullScreenManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFullScreenManager.h; path = FullScreen/WebFullScreenManager.h; sourceTree = "<group>"; }; CD73BA39131A29FE00EEDED2 /* WebFullScreenManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebFullScreenManager.messages.in; path = FullScreen/WebFullScreenManager.messages.in; sourceTree = "<group>"; }; @@ -1698,7 +1713,11 @@ D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSearchPopupMenu.h; sourceTree = "<group>"; }; E134F01512EA5D11004EC58D /* WKPrintingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPrintingView.h; sourceTree = "<group>"; }; E134F01912EA5D99004EC58D /* WKPrintingView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPrintingView.mm; sourceTree = "<group>"; }; + E179FD9B134D38060015B883 /* ArgumentCodersMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgumentCodersMac.h; sourceTree = "<group>"; }; + E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ArgumentCodersMac.mm; sourceTree = "<group>"; }; E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintInfo.cpp; sourceTree = "<group>"; }; + E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; }; + E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; }; E1BB1688132018BA00F49431 /* FullKeyboardAccessWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullKeyboardAccessWatcher.h; sourceTree = "<group>"; }; E1BB1689132018BA00F49431 /* FullKeyboardAccessWatcher.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = FullKeyboardAccessWatcher.mm; sourceTree = "<group>"; }; E1CC1B8E12D7EADF00625838 /* PrintInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintInfo.h; sourceTree = "<group>"; }; @@ -2053,6 +2072,7 @@ BCB0AEE8122F53E300B1341E /* MutableDictionary.cpp */, BCB0AEE7122F53E300B1341E /* MutableDictionary.h */, C02BFF1512514FD8009CCBEA /* NativeWebKeyboardEvent.h */, + 31EA25D3134F78D6005B1452 /* NativeWebMouseEvent.h */, BCCF673212C7F15C008F9C35 /* OriginAndDatabases.cpp */, BCCF672C12C7EDF7008F9C35 /* OriginAndDatabases.h */, BCC43AB8127B95DC00317F16 /* PlatformPopupMenuData.cpp */, @@ -2066,7 +2086,7 @@ 1AAB4A8C1296F0A20023952F /* SandboxExtension.h */, 33152973130D0CB200ED2483 /* SecurityOriginData.cpp */, 33152974130D0CB200ED2483 /* SecurityOriginData.h */, - 1AA41AB412C02EC4002BE67B /* SelectionState.h */, + 1AA41AB412C02EC4002BE67B /* EditorState.h */, 518D2CC812D51DFB003BB93B /* SessionState.cpp */, 518D2CC912D51DFB003BB93B /* SessionState.h */, 1A6420E212DCE2FF00CAAE2C /* ShareableBitmap.cpp */, @@ -2549,6 +2569,8 @@ 511B24A8132E097200065A0C /* WebIconDatabase.cpp */, 511B24A9132E097200065A0C /* WebIconDatabase.h */, 5184BC4A132E907A006B9E28 /* WebIconDatabase.messages.in */, + 51834590134532E80092B696 /* WebIconDatabaseClient.cpp */, + 51834591134532E80092B696 /* WebIconDatabaseClient.h */, 1C8E28331275D73800BC7BD0 /* WebInspectorProxy.cpp */, 1C8E28321275D73800BC7BD0 /* WebInspectorProxy.h */, 1C77C1951288A872006A742F /* WebInspectorProxy.messages.in */, @@ -2749,10 +2771,15 @@ BC111B5A112F628200337BAB /* mac */ = { isa = PBXGroup; children = ( + E179FD9B134D38060015B883 /* ArgumentCodersMac.h */, + E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */, + E1A31731134CEA6C007C9A4F /* AttributedString.h */, + E1A31734134CEA80007C9A4F /* AttributedString.mm */, 1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */, 1A9639F512F38ECD0078A062 /* CoreAnimationRenderer.h */, 1A9639F612F38ECD0078A062 /* CoreAnimationRenderer.mm */, 1A92DC1212F8BAB90017AF65 /* LayerTreeContextMac.mm */, + 31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */, C02BFF1D1251502E009CCBEA /* NativeWebKeyboardEventMac.mm */, C574A57F12E66681002DFE98 /* PasteboardTypes.h */, C574A58012E66681002DFE98 /* PasteboardTypes.mm */, @@ -2781,7 +2808,6 @@ BC9E969911457EDE00870E71 /* DrawingAreaProxyMessageKinds.h */, BCB28CBF120233D9007D99BC /* InjectedBundleMessageKinds.h */, BCCB75C51203A1CE00222D1B /* WebContextMessageKinds.h */, - BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */, ); path = CoreIPCSupport; sourceTree = "<group>"; @@ -2829,6 +2855,8 @@ BC14DF76120B5B7900826C0C /* InjectedBundleScriptWorld.cpp */, BC14DF75120B5B7900826C0C /* InjectedBundleScriptWorld.h */, BCB0B0DD12305A8C00B1341E /* InjectedBundleUserMessageCoders.h */, + CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */, + CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */, ); path = InjectedBundle; sourceTree = "<group>"; @@ -3108,6 +3136,7 @@ C03A136A133BEBF900D767D1 /* mac */ = { isa = PBXGroup; children = ( + C0FA52421345694A0028E8C2 /* LayerTreeHostCAMac.h */, C03A136B133BEBF900D767D1 /* LayerTreeHostCAMac.mm */, ); path = mac; @@ -3339,7 +3368,6 @@ BC032D9710F437AF0058C15A /* WebProcess.h in Headers */, 1A6FA02011E1528700DB1371 /* WebProcessMain.h in Headers */, BC032DD510F4389F0058C15A /* WebProcessProxy.h in Headers */, - BCB7346E11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h in Headers */, BCC5715B115ADAEF001CCAF9 /* WebSystemInterface.h in Headers */, 1A594ABB112A1FB6009DE7C7 /* WebUIClient.h in Headers */, BC646C1B11DD399F006455B0 /* WKBackForwardList.h in Headers */, @@ -3559,7 +3587,7 @@ BC858A2012C0357B00EDEB2E /* WebResourceLoadClient.h in Headers */, 1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */, 909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */, - 1AA41AB512C02EC4002BE67B /* SelectionState.h in Headers */, + 1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */, BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */, BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */, BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */, @@ -3651,6 +3679,11 @@ C064504A133BE709003470E2 /* LayerTreeHostCA.h in Headers */, 5110AE0D133C16CB0072717A /* WKIconDatabase.h in Headers */, 5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */, + 51834593134532E90092B696 /* WebIconDatabaseClient.h in Headers */, + C0FA52431345694A0028E8C2 /* LayerTreeHostCAMac.h in Headers */, + E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */, + E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */, + CD5C66A1134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4275,6 +4308,11 @@ 5123CF1B133D260A0056F800 /* WKIconDatabaseCG.cpp in Sources */, F6A90813133C20510082C3F4 /* WebCookieManagerMac.mm in Sources */, F6D632BC133D198200743D77 /* WebCookieManagerProxyMac.mm in Sources */, + 51834592134532E90092B696 /* WebIconDatabaseClient.cpp in Sources */, + E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */, + E179FD9F134D38250015B883 /* ArgumentCodersMac.mm in Sources */, + 31EA25D2134F78C0005B1452 /* NativeWebMouseEventMac.mm in Sources */, + CD5C66A0134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/WebKit2/WebKit2API.pri b/Source/WebKit2/WebKit2API.pri index 7b182a9..3dfc7bf 100644 --- a/Source/WebKit2/WebKit2API.pri +++ b/Source/WebKit2/WebKit2API.pri @@ -40,6 +40,7 @@ WEBKIT2_API_SOURCES = \ $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp \ $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKPreferences.cpp \ $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp \ + $$SOURCE_DIR/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp \ $$SOURCE_DIR/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp \ $$SOURCE_DIR/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp \ $$SOURCE_DIR/WebKit2/UIProcess/API/qt/ClientImpl.cpp \ @@ -60,12 +61,7 @@ WEBKIT2_API_SOURCES = \ $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.cpp \ $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp \ $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp \ - $$SOURCE_DIR/WebKit2/PluginProcess/PluginControllerProxy.cpp \ - $$SOURCE_DIR/WebKit2/PluginProcess/PluginProcess.cpp \ - $$SOURCE_DIR/WebKit2/PluginProcess/WebProcessConnection.cpp \ - $$SOURCE_DIR/WebKit2/PluginProcess/qt/PluginControllerProxyQt.cpp \ $$SOURCE_DIR/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp \ - $$SOURCE_DIR/WebKit2/PluginProcess/qt/PluginProcessQt.cpp \ $$SOURCE_DIR/WebKit2/WebProcess/qt/WebProcessMainQt.cpp diff --git a/Source/WebKit2/WebProcess.pro b/Source/WebKit2/WebProcess.pro index 08521de..cd28c26 100644 --- a/Source/WebKit2/WebProcess.pro +++ b/Source/WebKit2/WebProcess.pro @@ -27,7 +27,7 @@ linux-* { QMAKE_RPATHDIR = \$\$ORIGIN/../lib $$QMAKE_RPATHDIR MY_RPATH = $$join(QMAKE_RPATHDIR, ":") - QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' + QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${MY_RPATH}\' -Wl,--no-undefined QMAKE_RPATHDIR = } else { QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp b/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp index 4f91e3d..5f9a724 100644 --- a/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp +++ b/Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.cpp @@ -56,6 +56,8 @@ void WebApplicationCacheManager::didReceiveMessage(CoreIPC::Connection* connecti void WebApplicationCacheManager::getApplicationCacheOrigins(uint64_t callbackID) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash> origins; #if ENABLE(OFFLINE_WEB_APPLICATIONS) @@ -79,11 +81,12 @@ void WebApplicationCacheManager::getApplicationCacheOrigins(uint64_t callbackID) } WebProcess::shared().connection()->send(Messages::WebApplicationCacheManagerProxy::DidGetApplicationCacheOrigins(identifiers, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } void WebApplicationCacheManager::deleteEntriesForOrigin(const SecurityOriginData& originData) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + #if ENABLE(OFFLINE_WEB_APPLICATIONS) RefPtr<SecurityOrigin> origin = SecurityOrigin::create(originData.protocol, originData.host, originData.port); if (!origin) @@ -91,15 +94,15 @@ void WebApplicationCacheManager::deleteEntriesForOrigin(const SecurityOriginData ApplicationCache::deleteCacheForOrigin(origin.get()); #endif - WebProcess::shared().terminateIfPossible(); } void WebApplicationCacheManager::deleteAllEntries() { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + #if ENABLE(OFFLINE_WEB_APPLICATIONS) cacheStorage().deleteAllEntries(); #endif - WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp index 4181e14..e8254cc 100644 --- a/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp +++ b/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp @@ -54,6 +54,8 @@ void WebCookieManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIP void WebCookieManager::getHostnamesWithCookies(uint64_t callbackID) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + HashSet<String> hostnames; WebCore::getHostnamesWithCookies(hostnames); @@ -62,25 +64,27 @@ void WebCookieManager::getHostnamesWithCookies(uint64_t callbackID) copyToVector(hostnames, hostnameList); WebProcess::shared().connection()->send(Messages::WebCookieManagerProxy::DidGetHostnamesWithCookies(hostnameList, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } void WebCookieManager::deleteCookiesForHostname(const String& hostname) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + WebCore::deleteCookiesForHostname(hostname); - WebProcess::shared().terminateIfPossible(); } void WebCookieManager::deleteAllCookies() { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + WebCore::deleteAllCookies(); - WebProcess::shared().terminateIfPossible(); } void WebCookieManager::startObservingCookieChanges() { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + WebCore::startObservingCookieChanges(); - WebProcess::shared().terminateIfPossible(); } void WebCookieManager::stopObservingCookieChanges() @@ -95,14 +99,14 @@ void WebCookieManager::dispatchCookiesDidChange() void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); platformSetHTTPCookieAcceptPolicy(policy); - WebProcess::shared().terminateIfPossible(); } void WebCookieManager::getHTTPCookieAcceptPolicy(uint64_t callbackID) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); WebProcess::shared().connection()->send(Messages::WebCookieManagerProxy::DidGetHTTPCookieAcceptPolicy(platformGetHTTPCookieAcceptPolicy(), callbackID), 0); - WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Downloads/Download.cpp b/Source/WebKit2/WebProcess/Downloads/Download.cpp index 3fc87d9..ff0482b 100644 --- a/Source/WebKit2/WebProcess/Downloads/Download.cpp +++ b/Source/WebKit2/WebProcess/Downloads/Download.cpp @@ -52,11 +52,15 @@ Download::Download(uint64_t downloadID, const ResourceRequest& request) #endif { ASSERT(m_downloadID); + + WebProcess::shared().disableTermination(); } Download::~Download() { platformInvalidate(); + + WebProcess::shared().enableTermination(); } CoreIPC::Connection* Download::connection() const diff --git a/Source/WebKit2/WebProcess/Downloads/DownloadManager.cpp b/Source/WebKit2/WebProcess/Downloads/DownloadManager.cpp index 4a96b11..a624891 100644 --- a/Source/WebKit2/WebProcess/Downloads/DownloadManager.cpp +++ b/Source/WebKit2/WebProcess/Downloads/DownloadManager.cpp @@ -77,8 +77,6 @@ void DownloadManager::downloadFinished(Download* download) m_downloads.remove(download->downloadID()); delete download; - - WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm b/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm index 2d09612..aacdf0b 100644 --- a/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm +++ b/Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm @@ -45,7 +45,7 @@ - (void)_setOriginatingURL:(NSURL *)originatingURL; @end -@interface WKDownloadAsDelegate : NSObject <NSURLConnectionDelegate> { +@interface WKDownloadAsDelegate : NSObject <NSURLDownloadDelegate> { WebKit::Download* _download; } - (id)initWithDownload:(WebKit::Download*)download; diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp index e856876..47f1d42 100644 --- a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp +++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp @@ -66,9 +66,8 @@ bool WebFullScreenManager::supportsFullScreen(bool withKeyboard) if (!m_page->corePage()->settings()->fullScreenEnabled()) return false; - bool supports = true; - m_page->sendSync(Messages::WebFullScreenManagerProxy::SupportsFullScreen(withKeyboard), supports); - return supports; + return m_page->injectedBundleFullScreenClient().supportsFullScreen(m_page.get(), withKeyboard); + } void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element) @@ -76,14 +75,14 @@ void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element) ASSERT(element); m_element = element; m_initialFrame = m_element->screenRect(); - m_page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen()); + m_page->injectedBundleFullScreenClient().enterFullScreenForElement(m_page.get(), element); } void WebFullScreenManager::exitFullScreenForElement(WebCore::Element* element) { ASSERT(element); ASSERT(m_element == element); - m_page->send(Messages::WebFullScreenManagerProxy::ExitFullScreen()); + m_page->injectedBundleFullScreenClient().exitFullScreenForElement(m_page.get(), element); } void WebFullScreenManager::beganEnterFullScreenAnimation() diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h index d4ec15d..d6ccb15 100644 --- a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h +++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h @@ -63,15 +63,16 @@ public: void finishedExitFullScreenAnimation(bool completed); virtual void setRootFullScreenLayer(WebCore::GraphicsLayer*) = 0; + void willEnterFullScreen(); + void didEnterFullScreen(); + void willExitFullScreen(); + void didExitFullScreen(); + WebCore::Element* element(); protected: WebFullScreenManager(WebPage*); - void willEnterFullScreen(); - void didEnterFullScreen(); - void willExitFullScreen(); - void didExitFullScreen(); virtual void beginEnterFullScreenAnimation(float duration) = 0; virtual void beginExitFullScreenAnimation(float duration) = 0; WebCore::IntRect getFullScreenRect(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index 587968c..d73070d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -133,7 +133,42 @@ void WKBundleOverrideAllowUniversalAccessFromFileURLsForTestRunner(WKBundleRef b toImpl(bundleRef)->overrideAllowUniversalAccessFromFileURLsForTestRunner(toImpl(pageGroupRef), enabled); } +void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) +{ + toImpl(bundleRef)->setAllowFileAccessFromFileURLs(toImpl(pageGroupRef), enabled); +} + void WKBundleReportException(JSContextRef context, JSValueRef exception) { InjectedBundle::reportException(context, exception); } + +void WKBundleClearAllDatabases(WKBundleRef bundleRef) +{ + toImpl(bundleRef)->clearAllDatabases(); +} + +void WKBundleSetDatabaseQuota(WKBundleRef bundleRef, uint64_t quota) +{ + toImpl(bundleRef)->setDatabaseQuota(quota); +} + +int WKBundleNumberOfPages(WKBundleRef bundleRef, WKBundleFrameRef frameRef, double pageWidthInPixels, double pageHeightInPixels) +{ + return toImpl(bundleRef)->numberOfPages(toImpl(frameRef), pageWidthInPixels, pageHeightInPixels); +} + +int WKBundlePageNumberForElementById(WKBundleRef bundleRef, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels) +{ + return toImpl(bundleRef)->pageNumberForElementById(toImpl(frameRef), toImpl(idRef)->string(), pageWidthInPixels, pageHeightInPixels); +} + +WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundleRef, WKBundleFrameRef frameRef, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) +{ + return toCopiedAPI(toImpl(bundleRef)->pageSizeAndMarginsInPixels(toImpl(frameRef), pageIndex, width, height, marginTop, marginRight, marginBottom, marginLeft)); +} + +WK_EXPORT bool WKBundleIsPageBoxVisible(WKBundleRef bundleRef, WKBundleFrameRef frameRef, int pageIndex) +{ + return toImpl(bundleRef)->isPageBoxVisible(toImpl(frameRef), pageIndex); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index dd44e93..5528dfe 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -201,6 +201,16 @@ WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frameRef) return toAPI(toImpl(frameRef)->scrollOffset()); } +bool WKBundleFrameHasHorizontalScrollbar(WKBundleFrameRef frameRef) +{ + return toImpl(frameRef)->hasHorizontalScrollbar(); +} + +bool WKBundleFrameHasVerticalScrollbar(WKBundleFrameRef frameRef) +{ + return toImpl(frameRef)->hasVerticalScrollbar(); +} + bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frameRef, double* red, double* green, double* blue, double* alpha) { return toImpl(frameRef)->getDocumentBackgroundColor(red, green, blue, alpha); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index 3c7c52d..727ea53 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -63,6 +63,9 @@ WK_EXPORT WKRect WKBundleFrameGetVisibleContentBounds(WKBundleFrameRef frame); WK_EXPORT WKRect WKBundleFrameGetVisibleContentBoundsExcludingScrollbars(WKBundleFrameRef frame); WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frame); +WK_EXPORT bool WKBundleFrameHasHorizontalScrollbar(WKBundleFrameRef frame); +WK_EXPORT bool WKBundleFrameHasVerticalScrollbar(WKBundleFrameRef frame); + WK_EXPORT bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frame, double* red, double* green, double* blue, double* alpha); WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index 6bed7a4..292b022 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -51,14 +51,20 @@ WKBundleNodeHandleRef WKBundleNodeHandleCopyDocument(WKBundleNodeHandleRef nodeH return toAPI(nodeHandle.release().releaseRef()); } -WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef nodeHandleRef) +WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandleRef, bool* isReplaced) { - return toAPI(toImpl(nodeHandleRef)->elementBounds()); + return toAPI(toImpl(nodeHandleRef)->renderRect(isReplaced)); } -WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandleRef, bool* isReplaced) +WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandleRef) { - return toAPI(toImpl(nodeHandleRef)->renderRect(isReplaced)); + return toAPI(toImpl(elementHandleRef)->elementBounds()); +} + +WKBundleNodeHandleRef WKBundleNodeHandleCopyElementShadowRoot(WKBundleNodeHandleRef elementHandleRef) +{ + RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(elementHandleRef)->elementShadowRoot(); + return toAPI(nodeHandle.release().releaseRef()); } void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandleRef, WKStringRef valueRef) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h index 6006596..3655194 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h @@ -42,9 +42,11 @@ WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyDocument(WKBundleNodeHandl /* Additional DOM Operations */ -WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef nodeHandle); WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandle, bool* isReplaced); +/* Element Specific Operations */ +WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandle); +WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyElementShadowRoot(WKBundleNodeHandleRef elementHandle); /* HTMLInputElement Specific Operations */ WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 58052c5..e57b420 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.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 @@ -28,8 +28,10 @@ #include "WKBundlePagePrivate.h" #include "InjectedBundleBackForwardList.h" +#include "InjectedBundleNodeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" +#include "WebFullScreenManager.h" #include "WebImage.h" #include "WebPage.h" #include "WebURL.h" @@ -93,6 +95,43 @@ void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkCl toImpl(pageRef)->initializeInjectedBundleUIClient(wkClient); } +void WKBundlePageSetFullScreenClient(WKBundlePageRef pageRef, WKBundlePageFullScreenClient* wkClient) +{ +#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeInjectedBundleFullScreenClient(wkClient); +#endif +} + +void WKBundlePageWillEnterFullScreen(WKBundlePageRef pageRef) +{ +#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API + toImpl(pageRef)->fullScreenManager()->willEnterFullScreen(); +#endif +} + +void WKBundlePageDidEnterFullScreen(WKBundlePageRef pageRef) +{ +#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API + toImpl(pageRef)->fullScreenManager()->didEnterFullScreen(); +#endif +} + +void WKBundlePageWillExitFullScreen(WKBundlePageRef pageRef) +{ +#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API + toImpl(pageRef)->fullScreenManager()->willExitFullScreen(); +#endif +} + +void WKBundlePageDidExitFullScreen(WKBundlePageRef pageRef) +{ +#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API + toImpl(pageRef)->fullScreenManager()->didExitFullScreen(); +#endif +} + WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef pageRef) { return toAPI(toImpl(pageRef)->pageGroup()); @@ -158,6 +197,11 @@ void WKBundlePageSetPageZoomFactor(WKBundlePageRef pageRef, double zoomFactor) toImpl(pageRef)->setPageZoomFactor(zoomFactor); } +void WKBundlePageSetScaleAtOrigin(WKBundlePageRef pageRef, double scale, WKPoint origin) +{ + toImpl(pageRef)->scaleWebView(scale, toIntPoint(origin)); +} + WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef pageRef) { return toAPI(toImpl(pageRef)->backForwardList()); @@ -170,7 +214,7 @@ void WKBundlePageInstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlay void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef)); + toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), false); } bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef) @@ -217,3 +261,18 @@ void WKBundlePageForceRepaint(WKBundlePageRef page) { toImpl(page)->forceRepaintWithoutCallback(); } + +void WKBundlePageSimulateMouseDown(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time) +{ + toImpl(page)->simulateMouseDown(button, toIntPoint(position), clickCount, modifiers, time); +} + +void WKBundlePageSimulateMouseUp(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time) +{ + toImpl(page)->simulateMouseUp(button, toIntPoint(position), clickCount, modifiers, time); +} + +void WKBundlePageSimulateMouseMotion(WKBundlePageRef page, WKPoint position, double time) +{ + toImpl(page)->simulateMouseMotion(toIntPoint(position), time); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index e01f51f..74d899e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -66,6 +66,12 @@ enum { }; typedef uint32_t WKInputFieldActionType; +enum { + WKFullScreenNoKeyboard, + WKFullScreenKeyboard, +}; +typedef uint32_t WKFullScreenKeyboardRequestType; + // Loader Client typedef void (*WKBundlePageDidStartProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); typedef void (*WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); @@ -243,8 +249,27 @@ struct WKBundlePageContextMenuClient { }; typedef struct WKBundlePageContextMenuClient WKBundlePageContextMenuClient; +// Full Screen client +typedef bool (*WKBundlePageSupportsFullScreen)(WKBundlePageRef page, WKFullScreenKeyboardRequestType requestType); +typedef void (*WKBundlePageEnterFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); +typedef void (*WKBundlePageExitFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); + +struct WKBundlePageFullScreenClient { + int version; + const void * clientInfo; + WKBundlePageSupportsFullScreen supportsFullScreen; + WKBundlePageEnterFullScreenForElement enterFullScreenForElement; + WKBundlePageExitFullScreenForElement exitFullScreenForElement; +}; +typedef struct WKBundlePageFullScreenClient WKBundlePageFullScreenClient; + +WK_EXPORT void WKBundlePageWillEnterFullScreen(WKBundlePageRef page); +WK_EXPORT void WKBundlePageDidEnterFullScreen(WKBundlePageRef page); +WK_EXPORT void WKBundlePageWillExitFullScreen(WKBundlePageRef page); +WK_EXPORT void WKBundlePageDidExitFullScreen(WKBundlePageRef page); + WK_EXPORT WKTypeID WKBundlePageGetTypeID(); - + WK_EXPORT void WKBundlePageSetContextMenuClient(WKBundlePageRef page, WKBundlePageContextMenuClient* client); WK_EXPORT void WKBundlePageSetEditorClient(WKBundlePageRef page, WKBundlePageEditorClient* client); WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClient* client); @@ -252,6 +277,8 @@ WK_EXPORT void WKBundlePageSetPageLoaderClient(WKBundlePageRef page, WKBundlePag WK_EXPORT void WKBundlePageSetResourceLoadClient(WKBundlePageRef page, WKBundlePageResourceLoadClient* client); WK_EXPORT void WKBundlePageSetPolicyClient(WKBundlePageRef page, WKBundlePagePolicyClient* client); WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client); + +WK_EXPORT void WKBundlePageSetFullScreenClient(WKBundlePageRef page, WKBundlePageFullScreenClient* client); WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page); WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp index d86c2e0..4364ce9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp @@ -137,3 +137,8 @@ void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlay { toImpl(bundlePageOverlayRef)->setNeedsDisplay(enclosingIntRect(toFloatRect(rect))); } + +float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef bundlePageOverlayRef) +{ + return toImpl(bundlePageOverlayRef)->fractionFadedIn(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h index 3b4f950..e78b350 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h @@ -66,6 +66,7 @@ WK_EXPORT WKTypeID WKBundlePageOverlayGetTypeID(); WK_EXPORT WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClient* client); WK_EXPORT void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlay, WKRect rect); +WK_EXPORT float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef bundlePageOverlay); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h index b9dce68..5e902d9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.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 @@ -45,8 +45,14 @@ WK_EXPORT void WKBundlePageSetTextZoomFactor(WKBundlePageRef page, double zoomFa WK_EXPORT double WKBundlePageGetPageZoomFactor(WKBundlePageRef page); WK_EXPORT void WKBundlePageSetPageZoomFactor(WKBundlePageRef page, double zoomFactor); +WK_EXPORT void WKBundlePageSetScaleAtOrigin(WKBundlePageRef page, double scale, WKPoint origin); + WK_EXPORT void WKBundlePageForceRepaint(WKBundlePageRef page); +WK_EXPORT void WKBundlePageSimulateMouseDown(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time); +WK_EXPORT void WKBundlePageSimulateMouseUp(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time); +WK_EXPORT void WKBundlePageSimulateMouseMotion(WKBundlePageRef page, WKPoint position, double time); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index 79c796a..03e17a2 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -66,6 +66,13 @@ WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGrou // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use. WK_EXPORT void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleOverrideAllowUniversalAccessFromFileURLsForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); +WK_EXPORT void WKBundleSetAllowFileAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); +WK_EXPORT void WKBundleClearAllDatabases(WKBundleRef bundle); +WK_EXPORT void WKBundleSetDatabaseQuota(WKBundleRef bundle, uint64_t); +WK_EXPORT int WKBundleNumberOfPages(WKBundleRef bundle, WKBundleFrameRef frameRef, double pageWidthInPixels, double pageHeightInPixels); +WK_EXPORT int WKBundlePageNumberForElementById(WKBundleRef bundle, WKBundleFrameRef frameRef, WKStringRef idRef, double pageWidthInPixels, double pageHeightInPixels); +WK_EXPORT WKStringRef WKBundlePageSizeAndMarginsInPixels(WKBundleRef bundle, WKBundleFrameRef frameRef, int, int, int, int, int, int, int); +WK_EXPORT bool WKBundleIsPageBoxVisible(WKBundleRef bundle, WKBundleFrameRef frameRef, int); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp index d97784e..463a211 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp @@ -37,7 +37,7 @@ void WKBundleSetHostAllowsAnyHTTPSCertificate(WKBundleRef bundleRef, WKStringRef toImpl(bundleRef)->setHostAllowsAnyHTTPSCertificate(toWTFString(host)); } -void WKBundleSetClientCertificate(WKBundleRef bundleRef, WKStringRef host, WKCertificateInfoRef certificateInfoRef) +void WKBundleSetClientCertificate(WKBundleRef bundleRef, WKStringRef host, WKStringRef certificateSystemStoreName, WKCertificateInfoRef certificateInfoRef) { - toImpl(bundleRef)->setClientCertificate(toWTFString(host), toImpl(certificateInfoRef)); + toImpl(bundleRef)->setClientCertificate(toWTFString(host), toWTFString(certificateSystemStoreName), toImpl(certificateInfoRef)); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h index e404ec8..03006dc 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h @@ -33,7 +33,7 @@ extern "C" { #endif WK_EXPORT void WKBundleSetHostAllowsAnyHTTPSCertificate(WKBundleRef bundle, WKStringRef host); -WK_EXPORT void WKBundleSetClientCertificate(WKBundleRef bundle, WKStringRef host, WKCertificateInfoRef certificateInfo); +WK_EXPORT void WKBundleSetClientCertificate(WKBundleRef bundle, WKStringRef host, WKStringRef certificateSystemStoreName, WKCertificateInfoRef certificateInfo); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index 5e15872..bef3f90 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -165,6 +165,14 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElem return getOrCreate(static_cast<HTMLTableCellElement*>(m_node.get())->cellAbove()); } +PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::elementShadowRoot() +{ + if (!m_node->isElementNode()) + return 0; + + return getOrCreate(static_cast<Element*>(m_node.get())->shadowRoot()); +} + PassRefPtr<WebFrame> InjectedBundleNodeHandle::documentFrame() { if (!m_node->isDocumentNode()) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h index e4a5ab9..e1003e8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h @@ -68,6 +68,8 @@ public: PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove(); + PassRefPtr<InjectedBundleNodeHandle> elementShadowRoot(); + PassRefPtr<WebFrame> documentFrame(); PassRefPtr<WebFrame> htmlFrameElementContentFrame(); PassRefPtr<WebFrame> htmlIFrameElementContentFrame(); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index 24dc7f9..baee7c9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -35,15 +35,20 @@ #include "WKBundleAPICast.h" #include "WebContextMessageKinds.h" #include "WebCoreArgumentCoders.h" +#include "WebDatabaseManager.h" +#include "WebFrame.h" #include "WebPage.h" #include "WebPreferencesStore.h" #include "WebProcess.h" #include <JavaScriptCore/APICast.h> #include <JavaScriptCore/JSLock.h> +#include <WebCore/Frame.h> +#include <WebCore/FrameView.h> #include <WebCore/GCController.h> #include <WebCore/JSDOMWindow.h> #include <WebCore/Page.h> #include <WebCore/PageGroup.h> +#include <WebCore/PrintContext.h> #include <WebCore/Settings.h> #include <wtf/OwnArrayPtr.h> #include <wtf/PassOwnArrayPtr.h> @@ -119,6 +124,76 @@ void InjectedBundle::overrideAllowUniversalAccessFromFileURLsForTestRunner(WebPa (*iter)->settings()->setAllowUniversalAccessFromFileURLs(enabled); } +void InjectedBundle::setAllowFileAccessFromFileURLs(WebPageGroupProxy* pageGroup, bool enabled) +{ + // Override the preference for all future pages. + WebPreferencesStore::overrideAllowFileAccessFromFileURLsForTestRunner(enabled); + + // Change the setting for existing ones. + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); + for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) + (*iter)->settings()->setAllowFileAccessFromFileURLs(enabled); +} + +void InjectedBundle::clearAllDatabases() +{ + WebDatabaseManager::shared().deleteAllDatabases(); +} + +void InjectedBundle::setDatabaseQuota(uint64_t quota) +{ + WebDatabaseManager::shared().setQuotaForOrigin("file:///", quota); +} + +int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels) +{ + Frame* coreFrame = frame ? frame->coreFrame() : 0; + if (!coreFrame) + return -1; + if (!pageWidthInPixels) + pageWidthInPixels = coreFrame->view()->width(); + if (!pageHeightInPixels) + pageHeightInPixels = coreFrame->view()->height(); + + return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels)); +} + +int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String& id, double pageWidthInPixels, double pageHeightInPixels) +{ + Frame* coreFrame = frame ? frame->coreFrame() : 0; + if (!coreFrame) + return -1; + + Element* element = coreFrame->document()->getElementById(AtomicString(id)); + if (!element) + return -1; + + if (!pageWidthInPixels) + pageWidthInPixels = coreFrame->view()->width(); + if (!pageHeightInPixels) + pageHeightInPixels = coreFrame->view()->height(); + + return PrintContext::pageNumberForElement(element, FloatSize(pageWidthInPixels, pageHeightInPixels)); +} + +String InjectedBundle::pageSizeAndMarginsInPixels(WebFrame* frame, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) +{ + Frame* coreFrame = frame ? frame->coreFrame() : 0; + if (!coreFrame) + return String(); + + return PrintContext::pageSizeAndMarginsInPixels(coreFrame, pageIndex, width, height, marginTop, marginRight, marginBottom, marginLeft); +} + +bool InjectedBundle::isPageBoxVisible(WebFrame* frame, int pageIndex) +{ + Frame* coreFrame = frame ? frame->coreFrame() : 0; + if (!coreFrame) + return false; + + return PrintContext::isPageBoxVisible(coreFrame, pageIndex); +} + static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* patterns) { if (!patterns) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h index 6896669..6755a39 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h @@ -60,6 +60,7 @@ typedef void* PlatformBundle; class ImmutableArray; class InjectedBundleScriptWorld; class WebCertificateInfo; +class WebFrame; class WebPage; class WebPageGroupProxy; @@ -82,7 +83,7 @@ public: void postSynchronousMessage(const String&, APIObject*, RefPtr<APIObject>& returnData); #if PLATFORM(WIN) void setHostAllowsAnyHTTPSCertificate(const String&); - void setClientCertificate(const String&, const WebCertificateInfo*); + void setClientCertificate(const String& host, const String& certificateSystemStoreName, const WebCertificateInfo*); #endif // TestRunner only SPI @@ -91,6 +92,11 @@ public: void activateMacFontAscentHack(); void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled); void overrideAllowUniversalAccessFromFileURLsForTestRunner(WebPageGroupProxy*, bool); + void setAllowFileAccessFromFileURLs(WebPageGroupProxy*, bool); + int numberOfPages(WebFrame*, double, double); + int pageNumberForElementById(WebFrame*, const String&, double, double); + String pageSizeAndMarginsInPixels(WebFrame*, int, int, int, int, int, int, int); + bool isPageBoxVisible(WebFrame*, int); // UserContent API void addUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames); @@ -101,6 +107,10 @@ public: void removeUserStyleSheets(WebPageGroupProxy*, InjectedBundleScriptWorld*); void removeAllUserContent(WebPageGroupProxy*); + // Local storage API + void clearAllDatabases(); + void setDatabaseQuota(uint64_t); + // Garbage collection API void garbageCollectJavaScriptObjects(); void garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp new file mode 100644 index 0000000..0f81a1c --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(FULLSCREEN_API) + +#include "InjectedBundlePageFullScreenClient.h" + +#include "InjectedBundleNodeHandle.h" +#include "WKAPICast.h" +#include "WKBundleAPICast.h" +#include "WebFullScreenManagerProxyMessages.h" +#include "WebPage.h" +#include <WebCore/Element.h> + +using namespace WebCore; + +namespace WebKit { + +bool InjectedBundlePageFullScreenClient::supportsFullScreen(WebPage *page, bool withKeyboard) +{ + if (m_client.supportsFullScreen) + return m_client.supportsFullScreen(toAPI(page), withKeyboard); + + bool supports = true; + page->sendSync(Messages::WebFullScreenManagerProxy::SupportsFullScreen(withKeyboard), supports); + return supports; +} + +void InjectedBundlePageFullScreenClient::enterFullScreenForElement(WebPage *page, WebCore::Element *element) +{ + if (m_client.enterFullScreenForElement) { + RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element); + m_client.enterFullScreenForElement(toAPI(page), toAPI(nodeHandle.get())); + } else + page->send(Messages::WebFullScreenManagerProxy::EnterFullScreen()); +} + +void InjectedBundlePageFullScreenClient::exitFullScreenForElement(WebPage *page, WebCore::Element *element) +{ + if (m_client.enterFullScreenForElement) { + RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(element); + m_client.enterFullScreenForElement(toAPI(page), toAPI(nodeHandle.get())); + } else + page->send(Messages::WebFullScreenManagerProxy::ExitFullScreen()); +} + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h new file mode 100644 index 0000000..eebc4b4 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h @@ -0,0 +1,55 @@ +/* + * 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 InjectedBundlePageFullScreenClient_h +#define InjectedBundlePageFullScreenClient_h + +#if ENABLE(FULLSCREEN_API) + +#include "APIClient.h" +#include "WKBundlePage.h" +#include "WebEvent.h" +#include <wtf/Forward.h> + +namespace WebCore { +class Element; +} + +namespace WebKit { + +class WebPage; + +class InjectedBundlePageFullScreenClient : public APIClient<WKBundlePageFullScreenClient> { +public: + bool supportsFullScreen(WebPage*, bool withKeyboard); + void enterFullScreenForElement(WebPage*, WebCore::Element*); + void exitFullScreenForElement(WebPage*, WebCore::Element*); +}; + +} // namespace WebKit + +#endif // ENABLE(FULLSCREEN_API) + +#endif // InjectedBundlePageFullScreenClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp b/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp index 4b415a4..08c9a93 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp @@ -31,6 +31,7 @@ #include "WebCertificateInfo.h" #include <WebCore/ResourceHandle.h> #include <WebCore/SimpleFontData.h> +#include <wtf/text/CString.h> #include <windows.h> #include <winbase.h> @@ -99,10 +100,10 @@ void InjectedBundle::setHostAllowsAnyHTTPSCertificate(const String& host) #endif } -void InjectedBundle::setClientCertificate(const String& host, const WebCertificateInfo* certificateInfo) +void InjectedBundle::setClientCertificate(const String& host, const String& certificateSystemStoreName, const WebCertificateInfo* certificateInfo) { #if USE(CFNETWORK) - ASSERT(certificateInfo); + ASSERT_ARG(certificateInfo, certificateInfo); if (!certificateInfo) return; @@ -111,7 +112,29 @@ void InjectedBundle::setClientCertificate(const String& host, const WebCertifica if (certificateChain.size() != 1) return; - ResourceHandle::setClientCertificate(host, WebCore::copyCertificateToData(certificateChain.first()).get()); + ASSERT_ARG(certificateSystemStoreName, !certificateSystemStoreName.isEmpty()); + if (certificateSystemStoreName.isEmpty()) + return; + + // The PCCERT_CONTEXT in the WebCertificateInfo we created using the message from the UI process doesn't contain enough information + // to actually use it in a request, we need to get the real certificate from the certificate store (which is typically the "MY" store). + String mutableCertificateSystemStoreName = certificateSystemStoreName; + HCERTSTORE certStore = ::CertOpenSystemStore(0, mutableCertificateSystemStoreName.charactersWithNullTermination()); + if (!certStore) { + LOG_ERROR("Could not open system certificate store %s", certificateSystemStoreName.ascii().data()); + return; + } + + PCCERT_CONTEXT realCert = ::CertFindCertificateInStore(certStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_EXISTING, certificateChain.first(), 0); + if (!realCert) { + LOG_ERROR("Could not find certificate in system certificate store"); + return; + } + + ResourceHandle::setClientCertificate(host, WebCore::copyCertificateToData(realCert).get()); + CertFreeCertificateContext(realCert); + + // We can't close certStore here, since the certificate is still in use. #endif } diff --git a/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp b/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp index 45431c3..6b41204 100644 --- a/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp +++ b/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp @@ -57,6 +57,8 @@ void WebKeyValueStorageManager::didReceiveMessage(CoreIPC::Connection* connectio void WebKeyValueStorageManager::getKeyValueStorageOrigins(uint64_t callbackID) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + Vector<RefPtr<SecurityOrigin> > coreOrigins; StorageTracker::tracker().origins(coreOrigins); @@ -76,23 +78,23 @@ void WebKeyValueStorageManager::getKeyValueStorageOrigins(uint64_t callbackID) } WebProcess::shared().connection()->send(Messages::WebKeyValueStorageManagerProxy::DidGetKeyValueStorageOrigins(identifiers, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } void WebKeyValueStorageManager::deleteEntriesForOrigin(const SecurityOriginData& originData) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + RefPtr<SecurityOrigin> origin = SecurityOrigin::create(originData.protocol, originData.host, originData.port); if (!origin) return; StorageTracker::tracker().deleteOrigin(origin.get()); - WebProcess::shared().terminateIfPossible(); } void WebKeyValueStorageManager::deleteAllEntries() { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); StorageTracker::tracker().deleteAllOrigins(); - WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp index 6baf6d9..4a5d7f9 100644 --- a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp +++ b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp @@ -53,6 +53,8 @@ void WebMediaCacheManager::didReceiveMessage(CoreIPC::Connection* connection, Co void WebMediaCacheManager::getHostnamesWithMediaCache(uint64_t callbackID) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + Vector<String> mediaCacheHostnames; #if ENABLE(VIDEO) @@ -60,23 +62,24 @@ void WebMediaCacheManager::getHostnamesWithMediaCache(uint64_t callbackID) #endif WebProcess::shared().connection()->send(Messages::WebMediaCacheManagerProxy::DidGetHostnamesWithMediaCache(mediaCacheHostnames, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } void WebMediaCacheManager::clearCacheForHostname(const String& hostname) { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + #if ENABLE(VIDEO) HTMLMediaElement::clearMediaCacheForSite(hostname); #endif - WebProcess::shared().terminateIfPossible(); } void WebMediaCacheManager::clearCacheForAllHostnames() { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + #if ENABLE(VIDEO) HTMLMediaElement::clearMediaCache(); #endif - WebProcess::shared().terminateIfPossible(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h index f0c2424..0fd01ea 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h @@ -42,7 +42,7 @@ public: NPIdentifier npIdentifier() const { return m_npIdentifier; } private: - static PassRefPtr<JSC::Structure> createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype) + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype) { return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h index e8a08da..ed124b9 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h @@ -55,7 +55,7 @@ public: private: static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSObject::StructureFlags; - static PassRefPtr<JSC::Structure> createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype) + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype) { return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp index 4c687f4..7720e88 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp @@ -55,7 +55,6 @@ NPJSObject* NPJSObject::create(JSGlobalData& globalData, NPRuntimeObjectMap* obj NPJSObject::NPJSObject() : m_objectMap(0) - , m_jsObject(Global<JSObject>::EmptyValue) { } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h index 796f1c3..f0ee07a 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.h @@ -26,7 +26,7 @@ #ifndef NPJSObject_h #define NPJSObject_h -#include <JavaScriptCore/Global.h> +#include <JavaScriptCore/Strong.h> #include <WebCore/npruntime_internal.h> #include <wtf/Noncopyable.h> @@ -90,7 +90,7 @@ private: static bool NP_Construct(NPObject*, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result); NPRuntimeObjectMap* m_objectMap; - JSC::Global<JSC::JSObject> m_jsObject; + JSC::Strong<JSC::JSObject> m_jsObject; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp index f6c0057..1cf60d2 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp @@ -33,6 +33,7 @@ #include <JavaScriptCore/Error.h> #include <JavaScriptCore/JSLock.h> #include <JavaScriptCore/SourceCode.h> +#include <JavaScriptCore/Strong.h> #include <WebCore/Frame.h> #include <WebCore/NotImplemented.h> @@ -182,7 +183,7 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String&scriptString, NPVariant* result) { - Global<JSGlobalObject> globalObject(this->globalObject()->globalData(), this->globalObject()); + Strong<JSGlobalObject> globalObject(this->globalObject()->globalData(), this->globalObject()); if (!globalObject) return false; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index 7d00219..574df0d 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -491,6 +491,11 @@ void NetscapePlugin::destroy() // Stop all streams. stopAllStreams(); +#if !PLUGIN_ARCHITECTURE(MAC) + m_npWindow.window = 0; + callSetWindow(); +#endif + NPP_Destroy(0); m_isStarted = false; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginNone.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginNone.cpp new file mode 100644 index 0000000..d4b2043 --- /dev/null +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginNone.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#if PLUGIN_ARCHITECTURE(UNSUPPORTED) + +#include "NetscapePlugin.h" + +using namespace WebCore; + +namespace WebKit { + +bool NetscapePlugin::platformPostInitialize() +{ + return false; +} + +void NetscapePlugin::platformDestroy() +{ +} + +bool NetscapePlugin::platformInvalidate(const IntRect&) +{ + return false; +} + +void NetscapePlugin::platformGeometryDidChange() +{ +} + +void NetscapePlugin::platformPaint(GraphicsContext*, const IntRect&, bool) +{ +} + +bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent&) +{ + return false; +} + +bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent&) +{ + return false; +} + +void NetscapePlugin::platformSetFocus(bool) +{ +} + +bool NetscapePlugin::platformHandleMouseEnterEvent(const WebMouseEvent&) +{ + return false; +} + +bool NetscapePlugin::platformHandleMouseLeaveEvent(const WebMouseEvent&) +{ + return false; +} + +bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& event) +{ + return false; +} + +} // namespace WebKit + +#endif // PLUGIN_ARCHITECTURE(UNSUPPORTED) diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp index cf5affc..c5beb5f 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp @@ -221,6 +221,7 @@ void NetscapePluginStream::deliverDataToPlugin() int32_t numBytesWritten = m_plugin->NPP_Write(&m_npStream, m_offset, dataLength, data); if (numBytesWritten < 0) { + cancel(); stop(NPRES_NETWORK_ERR); return; } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm index 14ac070..e1c193f 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm @@ -124,6 +124,7 @@ NPBool NetscapePlugin::convertPoint(double sourceX, double sourceY, NPCoordinate case NPCoordinateSpaceFlippedScreen: sourceXInScreenSpace = sourceX; sourceYInScreenSpace = flipScreenYCoordinate(sourceY); + break; default: return false; } @@ -231,17 +232,7 @@ bool NetscapePlugin::platformPostInitialize() // Get the Core Animation layer. if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) { ASSERT(!m_pluginLayer); - - CALayer *realPluginLayer = reinterpret_cast<CALayer *>(value); - - // Create a layer with flipped geometry and add the real plug-in layer as a sublayer - // so the coordinate system will match the event coordinate system. - m_pluginLayer.adoptNS([[CALayer alloc] init]); - [m_pluginLayer.get() setBounds:[realPluginLayer bounds]]; - [m_pluginLayer.get() setGeometryFlipped:YES]; - - [realPluginLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; - [m_pluginLayer.get() addSublayer:realPluginLayer]; + m_pluginLayer = reinterpret_cast<CALayer *>(value); } } @@ -517,11 +508,14 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent) // access m_currentMouseEvent afterwards. RefPtr<NetscapePlugin> protect(this); - bool returnValue = NPP_HandleEvent(&event); + NPP_HandleEvent(&event); m_currentMouseEvent = previousMouseEvent; - return returnValue; + // Some plug-ins return false even if the mouse event has been handled. + // This leads to bugs such as <rdar://problem/9167611>. Work around this + // by always returning true. + return true; } #ifndef NP_NO_CARBON @@ -549,7 +543,12 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent) event.where.h = mouseEvent.globalPosition().x(); event.where.v = mouseEvent.globalPosition().y(); - return NPP_HandleEvent(&event); + NPP_HandleEvent(&event); + + // Some plug-ins return false even if the mouse event has been handled. + // This leads to bugs such as <rdar://problem/9167611>. Work around this + // by always returning true. + return true; } #endif @@ -646,6 +645,8 @@ static unsigned modifierFlags(const WebKeyboardEvent& keyboardEvent) { unsigned modifierFlags = 0; + if (keyboardEvent.capsLockKey()) + modifierFlags |= NSAlphaShiftKeyMask; if (keyboardEvent.shiftKey()) modifierFlags |= NSShiftKeyMask; if (keyboardEvent.controlKey()) @@ -658,20 +659,46 @@ static unsigned modifierFlags(const WebKeyboardEvent& keyboardEvent) return modifierFlags; } +static bool isFlagsChangedEvent(const WebKeyboardEvent& keyboardEvent) +{ + switch (keyboardEvent.nativeVirtualKeyCode()) { + case 54: // Right Command + case 55: // Left Command + + case 57: // Capslock + + case 56: // Left Shift + case 60: // Right Shift + + case 58: // Left Alt + case 61: // Right Alt + + case 59: // Left Ctrl + case 62: // Right Ctrl + return true; + } + + return false; +} + static NPCocoaEvent initializeKeyboardEvent(const WebKeyboardEvent& keyboardEvent) { NPCocoaEventType eventType; - - switch (keyboardEvent.type()) { - case WebEvent::KeyDown: - eventType = NPCocoaEventKeyDown; - break; - case WebEvent::KeyUp: - eventType = NPCocoaEventKeyUp; - break; - default: - ASSERT_NOT_REACHED(); - return NPCocoaEvent(); + + if (isFlagsChangedEvent(keyboardEvent)) + eventType = NPCocoaEventFlagsChanged; + else { + switch (keyboardEvent.type()) { + case WebEvent::KeyDown: + eventType = NPCocoaEventKeyDown; + break; + case WebEvent::KeyUp: + eventType = NPCocoaEventKeyUp; + break; + default: + ASSERT_NOT_REACHED(); + return NPCocoaEvent(); + } } NPCocoaEvent event = initializeEvent(eventType); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm index d331506..0b2917f 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm @@ -34,8 +34,17 @@ namespace WebKit { PlatformLayer* PluginProxy::pluginLayer() { - if (!m_pluginLayer && m_remoteLayerClientID) - m_pluginLayer = WKMakeRenderLayer(m_remoteLayerClientID); + if (!m_pluginLayer && m_remoteLayerClientID) { + CALayer *renderLayer = WKMakeRenderLayer(m_remoteLayerClientID); + + // Create a layer with flipped geometry and add the real plug-in layer as a sublayer + // so the coordinate system will match the event coordinate system. + m_pluginLayer.adoptNS([[CALayer alloc] init]); + [m_pluginLayer.get() setGeometryFlipped:YES]; + + [renderLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; + [m_pluginLayer.get() addSublayer:renderLayer]; + } return m_pluginLayer.get(); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp index 27e694b..b8c8f2a 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp @@ -25,6 +25,8 @@ */ #include "config.h" +#if PLUGIN_ARCHITECTURE(X11) + #include "NetscapePlugin.h" #include "WebEvent.h" @@ -38,6 +40,7 @@ #include <QX11Info> #elif PLATFORM(GTK) #include <gdk/gdkx.h> +#include <WebCore/GtkVersioning.h> #endif using namespace WebCore; @@ -423,3 +426,5 @@ bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& event) } } // namespace WebKit + +#endif // PLUGIN_ARCHITECTURE(X11) diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp index 3d007a6..31e377f 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp @@ -32,14 +32,33 @@ #include "PluginProcessConnectionManager.h" #include "PluginProxy.h" #include "WebProcess.h" +#include "WebProcessProxyMessages.h" +#include <WebCore/FileSystem.h> + +using namespace WebCore; namespace WebKit { +// The timeout, in seconds, when sending sync messages to the plug-in. +static const double syncMessageTimeout = 45; + +static double defaultSyncMessageTimeout(const String& pluginPath) +{ + // We don't want a message timeout for the AppleConnect plug-in. + // FIXME: We should key this off something other than the path. + if (pathGetFileName(pluginPath) == "AppleConnect.plugin") + return CoreIPC::Connection::NoTimeout; + + return syncMessageTimeout; +} + PluginProcessConnection::PluginProcessConnection(PluginProcessConnectionManager* pluginProcessConnectionManager, const String& pluginPath, CoreIPC::Connection::Identifier connectionIdentifier) : m_pluginProcessConnectionManager(pluginProcessConnectionManager) , m_pluginPath(pluginPath) { m_connection = CoreIPC::Connection::createClientConnection(connectionIdentifier, this, WebProcess::shared().runLoop()); + + m_connection->setDefaultSyncMessageTimeout(defaultSyncMessageTimeout(m_pluginPath)); m_npRemoteObjectMap = NPRemoteObjectMap::create(m_connection.get()); m_connection->open(); @@ -116,6 +135,11 @@ void PluginProcessConnection::didReceiveInvalidMessage(CoreIPC::Connection*, Cor { } +void PluginProcessConnection::syncMessageSendTimedOut(CoreIPC::Connection*) +{ + WebProcess::shared().connection()->send(Messages::WebProcessProxy::PluginSyncMessageSendTimedOut(m_pluginPath), 0); +} + } // namespace WebKit #endif // ENABLE(PLUGIN_PROCESS) diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h index 76e2315..589baf4 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.h @@ -66,7 +66,8 @@ private: virtual CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); + PluginProcessConnectionManager* m_pluginProcessConnectionManager; String m_pluginPath; diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp index 1290391..d2f3686 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp @@ -30,13 +30,16 @@ #include "ArgumentDecoder.h" #include "ArgumentEncoder.h" -#include "MachPort.h" #include "PluginProcessConnection.h" #include "WebCoreArgumentCoders.h" #include "WebProcess.h" -#include "WebProcessProxyMessageKinds.h" +#include "WebProcessProxyMessages.h" #include <wtf/StdLibExtras.h> +#if PLATFORM(MAC) +#include "MachPort.h" +#endif + namespace WebKit { PluginProcessConnectionManager& PluginProcessConnectionManager::shared() @@ -61,11 +64,18 @@ PluginProcessConnection* PluginProcessConnectionManager::getPluginProcessConnect } CoreIPC::Connection::Identifier connectionIdentifier; +#if PLATFORM(MAC) CoreIPC::MachPort connectionMachPort; - if (!WebProcess::shared().connection()->deprecatedSendSync(WebProcessProxyLegacyMessage::GetPluginProcessConnection, 0, CoreIPC::In(pluginPath), CoreIPC::Out(connectionMachPort))) + + if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginProcessConnection(pluginPath), Messages::WebProcessProxy::GetPluginProcessConnection::Reply(connectionMachPort), 0)) return 0; connectionIdentifier = connectionMachPort.port(); +#else + // FIXME: Implement. + connectionIdentifier = 0; + ASSERT_NOT_REACHED(); +#endif if (!connectionIdentifier) return 0; diff --git a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp index 1596319..febf61b 100644 --- a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp +++ b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp @@ -28,6 +28,7 @@ #include "Connection.h" #include "MessageID.h" +#include "ResourceCachesToClear.h" #include "SecurityOriginData.h" #include "WebCoreArgumentCoders.h" #include "WebResourceCacheManagerProxyMessages.h" @@ -62,6 +63,8 @@ void WebResourceCacheManager::didReceiveMessage(CoreIPC::Connection* connection, void WebResourceCacheManager::getCacheOrigins(uint64_t callbackID) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + MemoryCache::SecurityOriginSet origins; memoryCache()->getOriginsWithCache(origins); @@ -93,11 +96,18 @@ void WebResourceCacheManager::getCacheOrigins(uint64_t callbackID) const } WebProcess::shared().connection()->send(Messages::WebResourceCacheManagerProxy::DidGetCacheOrigins(identifiers, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } -void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData) const +void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData, uint32_t cachesToClear) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + +#if USE(CFURLCACHE) + ResourceCachesToClear resourceCachesToClear = static_cast<ResourceCachesToClear>(cachesToClear); +#else + UNUSED_PARAM(cachesToClear); +#endif + RefPtr<SecurityOrigin> origin = SecurityOrigin::create(originData.protocol, originData.host, originData.port); if (!origin) return; @@ -105,19 +115,23 @@ void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData) memoryCache()->removeResourcesWithOrigin(origin.get()); #if USE(CFURLCACHE) - RetainPtr<CFMutableArrayRef> hostArray(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks)); - RetainPtr<CFStringRef> host(AdoptCF, origin->host().createCFString()); - CFArrayAppendValue(hostArray.get(), host.get()); + if (resourceCachesToClear != InMemoryResourceCachesOnly) { + RetainPtr<CFMutableArrayRef> hostArray(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks)); + RetainPtr<CFStringRef> host(AdoptCF, origin->host().createCFString()); + CFArrayAppendValue(hostArray.get(), host.get()); - clearCFURLCacheForHostNames(hostArray.get()); + clearCFURLCacheForHostNames(hostArray.get()); + } #endif - WebProcess::shared().terminateIfPossible(); } -void WebResourceCacheManager::clearCacheForAllOrigins() const +void WebResourceCacheManager::clearCacheForAllOrigins(uint32_t cachesToClear) const { - WebProcess::shared().clearResourceCaches(); - WebProcess::shared().terminateIfPossible(); + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + + ResourceCachesToClear resourceCachesToClear = static_cast<ResourceCachesToClear>(cachesToClear); + + WebProcess::shared().clearResourceCaches(resourceCachesToClear); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h index 3a29a4b..0172389 100644 --- a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h +++ b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h @@ -27,6 +27,7 @@ #define WebResourceCacheManager_h #include "Arguments.h" +#include "ResourceCachesToClear.h" #include <wtf/Noncopyable.h> #include <wtf/RetainPtr.h> #include <wtf/text/WTFString.h> @@ -56,8 +57,8 @@ private: void didReceiveWebResourceCacheManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void getCacheOrigins(uint64_t callbackID) const; - void clearCacheForOrigin(SecurityOriginData origin) const; - void clearCacheForAllOrigins() const; + void clearCacheForOrigin(SecurityOriginData, uint32_t cachesToClear) const; + void clearCacheForAllOrigins(uint32_t cachesToClear) const; #if USE(CFURLCACHE) static RetainPtr<CFArrayRef> cfURLCacheHostNames(); diff --git a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.messages.in b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.messages.in index b6d5900..336b253 100644 --- a/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.messages.in +++ b/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.messages.in @@ -22,6 +22,6 @@ messages -> WebResourceCacheManager { void GetCacheOrigins(uint64_t callbackID) - void ClearCacheForOrigin(WebKit::SecurityOriginData originIdentifier) - void ClearCacheForAllOrigins() + void ClearCacheForOrigin(WebKit::SecurityOriginData originIdentifier, uint32_t cachesToClear) + void ClearCacheForAllOrigins(uint32_t cachesToClear) } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index becf48f..2a81851 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -43,7 +43,6 @@ #include "WebPopupMenu.h" #include "WebPreferencesStore.h" #include "WebProcess.h" -#include "WebProcessProxyMessageKinds.h" #include "WebSearchPopupMenu.h" #include <WebCore/DatabaseTracker.h> #include <WebCore/FileChooser.h> @@ -138,7 +137,7 @@ bool WebChromeClient::canTakeFocus(FocusDirection) void WebChromeClient::takeFocus(FocusDirection direction) { - m_page->send(Messages::WebPageProxy::TakeFocus(direction == FocusDirectionForward ? true : false)); + m_page->send(Messages::WebPageProxy::TakeFocus(direction)); } void WebChromeClient::focusedNodeChanged(Node*) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp index 825a448..6104a50 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp @@ -67,6 +67,8 @@ void WebDatabaseManager::didReceiveMessage(CoreIPC::Connection* connection, Core void WebDatabaseManager::getDatabasesByOrigin(uint64_t callbackID) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + // FIXME: This could be made more efficient by adding a function to DatabaseTracker // to get both the origins and the Vector of DatabaseDetails for each origin in one // shot. That would avoid taking the numerous locks this requires. @@ -105,11 +107,12 @@ void WebDatabaseManager::getDatabasesByOrigin(uint64_t callbackID) const } WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabasesByOrigin(originAndDatabasesVector, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + Vector<RefPtr<SecurityOrigin> > origins; DatabaseTracker::tracker().origins(origins); @@ -119,37 +122,41 @@ void WebDatabaseManager::getDatabaseOrigins(uint64_t callbackID) const for (size_t i = 0; i < numOrigins; ++i) identifiers[i] = origins[i]->databaseIdentifier(); WebProcess::shared().connection()->send(Messages::WebDatabaseManagerProxy::DidGetDatabaseOrigins(identifiers, callbackID), 0); - WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, const String& originIdentifier) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier); if (!origin) return; DatabaseTracker::tracker().deleteDatabase(origin.get(), databaseIdentifier); - WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteDatabasesForOrigin(const String& originIdentifier) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier); if (!origin) return; DatabaseTracker::tracker().deleteOrigin(origin.get()); - WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::deleteAllDatabases() const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + DatabaseTracker::tracker().deleteAllDatabases(); - WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const { + WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); + // If the quota is set to a value lower than the current usage, that quota will // "stick" but no data will be purged to meet the new quota. This will simply // prevent new data from being added to databases in that origin. @@ -159,7 +166,6 @@ void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsig return; DatabaseTracker::tracker().setQuota(origin.get(), quota); - WebProcess::shared().terminateIfPossible(); } void WebDatabaseManager::dispatchDidModifyOrigin(SecurityOrigin* origin) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h index 96ed83e..ad91493 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h @@ -46,6 +46,10 @@ public: static void initialize(const String& databaseDirectory); void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + void setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const; + +public: + void deleteAllDatabases() const; private: WebDatabaseManager(); @@ -58,8 +62,6 @@ private: void getDatabaseOrigins(uint64_t callbackID) const; void deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, const String& originIdentifier) const; void deleteDatabasesForOrigin(const String& originIdentifier) const; - void deleteAllDatabases() const; - void setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const; // WebCore::DatabaseTrackerClient virtual void dispatchDidModifyOrigin(WebCore::SecurityOrigin*); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp index dfb1542..204810e 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp @@ -26,14 +26,16 @@ #include "config.h" #include "WebDragClient.h" -#include <WebCore/NotImplemented.h> +#include "WebPage.h" using namespace WebCore; namespace WebKit { -void WebDragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*) +void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData*) { + if (action == DragDestinationActionLoad) + m_page->willPerformLoadDragDestinationAction(); } void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp index b954283..197a0ab 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp @@ -26,10 +26,11 @@ #include "config.h" #include "WebEditorClient.h" -#include "SelectionState.h" +#include "EditorState.h" #include "WebCoreArgumentCoders.h" #include "WebFrameLoaderClient.h" #include "WebPage.h" +#include "WebPageProxy.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" #include <WebCore/ArchiveResource.h> @@ -189,16 +190,7 @@ void WebEditorClient::respondToChangedSelection() if (!frame) return; - SelectionState selectionState; - selectionState.isNone = frame->selection()->isNone(); - selectionState.isContentEditable = frame->selection()->isContentEditable(); - selectionState.isContentRichlyEditable = frame->selection()->isContentRichlyEditable(); - selectionState.isInPasswordField = frame->selection()->isInPasswordField(); - selectionState.hasComposition = frame->editor()->hasComposition(); - - WebPage::getLocationAndLengthFromRange(frame->selection()->toNormalizedRange().get(), selectionState.selectedRangeStart, selectionState.selectedRangeLength); - - m_page->send(Messages::WebPageProxy::SelectionStateChanged(selectionState)); + m_page->send(Messages::WebPageProxy::EditorStateChanged(m_page->editorState())); #if PLATFORM(WIN) // FIXME: This should also go into the selection state. @@ -263,27 +255,31 @@ bool WebEditorClient::canPaste(bool defaultValue) const bool WebEditorClient::canUndo() const { - notImplemented(); - return false; + bool result = false; + m_page->sendSync(Messages::WebPageProxy::CanUndoRedo(static_cast<uint32_t>(WebPageProxy::Undo)), Messages::WebPageProxy::CanUndoRedo::Reply(result)); + return result; } bool WebEditorClient::canRedo() const { - notImplemented(); - return false; + bool result = false; + m_page->sendSync(Messages::WebPageProxy::CanUndoRedo(static_cast<uint32_t>(WebPageProxy::Redo)), Messages::WebPageProxy::CanUndoRedo::Reply(result)); + return result; } void WebEditorClient::undo() { - notImplemented(); + bool result = false; + m_page->sendSync(Messages::WebPageProxy::ExecuteUndoRedo(static_cast<uint32_t>(WebPageProxy::Undo)), Messages::WebPageProxy::ExecuteUndoRedo::Reply(result)); } void WebEditorClient::redo() { - notImplemented(); + bool result = false; + m_page->sendSync(Messages::WebPageProxy::ExecuteUndoRedo(static_cast<uint32_t>(WebPageProxy::Redo)), Messages::WebPageProxy::ExecuteUndoRedo::Reply(result)); } -#if !PLATFORM(MAC) +#if !PLATFORM(GTK) && !PLATFORM(MAC) void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) { if (m_page->handleEditingKeyboardEvent(event)) @@ -389,9 +385,15 @@ void WebEditorClient::learnWord(const String& word) m_page->send(Messages::WebPageProxy::LearnWord(word)); } -void WebEditorClient::checkSpellingOfString(const UChar*, int, int*, int*) +void WebEditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength) { - notImplemented(); + int32_t resultLocation = -1; + int32_t resultLength = 0; + // FIXME: It would be nice if we wouldn't have to copy the text here. + m_page->sendSync(Messages::WebPageProxy::CheckSpellingOfString(String(text, length)), + Messages::WebPageProxy::CheckSpellingOfString::Reply(resultLocation, resultLength)); + *misspellingLocation = resultLocation; + *misspellingLength = resultLength; } String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&) @@ -400,9 +402,15 @@ String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&) return String(); } -void WebEditorClient::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*) +void WebEditorClient::checkGrammarOfString(const UChar* text, int length, Vector<WebCore::GrammarDetail>& grammarDetails, int* badGrammarLocation, int* badGrammarLength) { - notImplemented(); + int32_t resultLocation = -1; + int32_t resultLength = 0; + // FIXME: It would be nice if we wouldn't have to copy the text here. + m_page->sendSync(Messages::WebPageProxy::CheckGrammarOfString(String(text, length)), + Messages::WebPageProxy::CheckGrammarOfString::Reply(grammarDetails, resultLocation, resultLength)); + *badGrammarLocation = resultLocation; + *badGrammarLength = resultLength; } void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail) @@ -422,8 +430,9 @@ void WebEditorClient::showSpellingUI(bool) bool WebEditorClient::spellingUIIsShowing() { - notImplemented(); - return false; + bool isShowing = false; + m_page->sendSync(Messages::WebPageProxy::SpellingUIIsShowing(), Messages::WebPageProxy::SpellingUIIsShowing::Reply(isShowing)); + return isShowing; } void WebEditorClient::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) @@ -441,7 +450,7 @@ void WebEditorClient::setInputMethodState(bool) notImplemented(); } -void WebEditorClient::requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&) +void WebEditorClient::requestCheckingOfString(WebCore::SpellChecker*, int, WebCore::TextCheckingTypeMask, const WTF::String&) { notImplemented(); } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h index 9200af0..633090f 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h @@ -123,6 +123,11 @@ private: virtual void toggleAutomaticSpellingCorrection(); #endif +#if PLATFORM(GTK) + bool executePendingEditorCommands(WebCore::Frame*, Vector<WTF::String>, bool); + void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&); +#endif + TextCheckerClient* textChecker() { return this; } virtual void ignoreWordInSpellDocument(const String&); @@ -131,7 +136,7 @@ private: virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord); virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength); #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - virtual void checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results); + virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector<WebCore::TextCheckingResult>& results); #endif virtual void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail& detail); virtual void updateSpellingUIWithMisspelledWord(const String&); @@ -140,7 +145,7 @@ private: virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses); virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); - virtual void requestCheckingOfString(WebCore::SpellChecker*, int, const WTF::String&); + virtual void requestCheckingOfString(WebCore::SpellChecker*, int, WebCore::TextCheckingTypeMask, const WTF::String&); #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings); virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index fa3cdce..c3f72b0 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -44,7 +44,6 @@ #include "WebPage.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" -#include "WebProcessProxyMessageKinds.h" #include "WebProcessProxyMessages.h" #include <JavaScriptCore/APICast.h> #include <JavaScriptCore/JSObject.h> @@ -223,14 +222,14 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned webPage->send(Messages::WebPageProxy::DidReceiveResponseForResource(m_frame->frameID(), identifier, response)); } -void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) +void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int dataLength) { WebPage* webPage = m_frame->page(); if (!webPage) return; - webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(webPage, m_frame, identifier, lengthReceived); - webPage->send(Messages::WebPageProxy::DidReceiveContentLengthForResource(m_frame->frameID(), identifier, lengthReceived)); + webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(webPage, m_frame, identifier, dataLength); + webPage->send(Messages::WebPageProxy::DidReceiveContentLengthForResource(m_frame->frameID(), identifier, dataLength)); } void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) @@ -403,7 +402,7 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); } -void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) +void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title) { WebPage* webPage = m_frame->page(); if (!webPage) @@ -412,10 +411,11 @@ void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) RefPtr<APIObject> userData; // Notify the bundle client. - webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title, m_frame, userData); + // FIXME: use direction of title. + webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title.string(), m_frame, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title.string(), InjectedBundleUserMessageEncoder(userData.get()))); } void WebFrameLoaderClient::dispatchDidChangeIcons() @@ -839,14 +839,15 @@ void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader) void WebFrameLoaderClient::updateGlobalHistory() { WebPage* webPage = m_frame->page(); - if (!webPage) + if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient()) return; DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader(); WebNavigationDataStore data; data.url = loader->urlForHistory().string(); - data.title = loader->title(); + // FIXME: use direction of title. + data.title = loader->title().string(); WebProcess::shared().connection()->send(Messages::WebContext::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0); } @@ -854,7 +855,7 @@ void WebFrameLoaderClient::updateGlobalHistory() void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks() { WebPage* webPage = m_frame->page(); - if (!webPage) + if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient()) return; DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader(); @@ -1061,14 +1062,15 @@ PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const Reso return DocumentLoader::create(request, data); } -void WebFrameLoaderClient::setTitle(const String& title, const KURL& url) +void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url) { WebPage* webPage = m_frame->page(); - if (!webPage) + if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient()) return; + // FIXME: use direction of title. WebProcess::shared().connection()->send(Messages::WebContext::DidUpdateHistoryTitle(webPage->pageID(), - title, url.string(), m_frame->frameID()), 0); + title.string(), url.string(), m_frame->frameID()), 0); } String WebFrameLoaderClient::userAgent(const KURL&) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h index 1948541..6ab6691 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h @@ -67,7 +67,7 @@ private: virtual bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&); #endif virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); - virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); + virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength); virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); @@ -84,7 +84,7 @@ private: virtual void dispatchWillClose(); virtual void dispatchDidReceiveIcon(); virtual void dispatchDidStartProvisionalLoad(); - virtual void dispatchDidReceiveTitle(const String& title); + virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&); virtual void dispatchDidChangeIcons(); virtual void dispatchDidCommitLoad(); virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); @@ -165,7 +165,7 @@ private: virtual void prepareForDataSourceReplacement(); virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); - virtual void setTitle(const String& title, const WebCore::KURL&); + virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::KURL&); virtual String userAgent(const WebCore::KURL&); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp index 7242d4f..940cb95 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp @@ -81,7 +81,7 @@ Vector<WebPopupItem> WebPopupMenu::populateItems() for (size_t i = 0; i < size; ++i) { if (m_popupClient->itemIsSeparator(i)) - items.append(WebPopupItem(WebPopupItem::Seperator)); + items.append(WebPopupItem(WebPopupItem::Separator)); else { // FIXME: Add support for styling the font. // FIXME: Add support for styling the foreground and background colors. @@ -126,6 +126,13 @@ void WebPopupMenu::hide() void WebPopupMenu::updateFromElement() { +#if PLATFORM(WIN) + if (!m_page || !m_popupClient) + return; + + int selectedIndex = m_popupClient->selectedIndex(); + WebProcess::shared().connection()->send(Messages::WebPageProxy::SetPopupMenuSelectedIndex(selectedIndex), m_page->pageID()); +#endif } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h index 3083c94..1e6e09a 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h @@ -43,6 +43,8 @@ public: static PassRefPtr<WebPopupMenu> create(WebPage*, WebCore::PopupMenuClient*); ~WebPopupMenu(); + WebPage* page() { return m_page; } + void disconnectFromPage() { m_page = 0; } void didChangeSelectedIndex(int newIndex); void setTextForIndex(int newIndex); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp index b875f32..39a7f32 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,6 +23,11 @@ #include "config.h" #include "WebSearchPopupMenu.h" +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <wtf/text/AtomicString.h> + using namespace WebCore; namespace WebKit { @@ -42,17 +47,33 @@ PopupMenu* WebSearchPopupMenu::popupMenu() return m_popup.get(); } -void WebSearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&) +void WebSearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) { + if (name.isEmpty()) + return; + + WebPage* page = m_popup->page(); + if (!page) + return; + + WebProcess::shared().connection()->send(Messages::WebPageProxy::SaveRecentSearches(name, searchItems), page->pageID()); } -void WebSearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&) +void WebSearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& resultItems) { + if (name.isEmpty()) + return; + + WebPage* page = m_popup->page(); + if (!page) + return; + + WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::LoadRecentSearches(name), Messages::WebPageProxy::LoadRecentSearches::Reply(resultItems), page->pageID()); } bool WebSearchPopupMenu::enabled() { - return false; + return true; } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp new file mode 100644 index 0000000..c05589b --- /dev/null +++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2011 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "WebEditorClient.h" + +#include "Frame.h" +#include "PlatformKeyboardEvent.h" +#include "WebPage.h" +#include "WebPageProxyMessages.h" +#include "WebProcess.h" +#include <WebCore/KeyboardEvent.h> +#include <WebCore/NotImplemented.h> + +using namespace WebCore; + +namespace WebKit { + +void WebEditorClient::getEditorCommandsForKeyEvent(const KeyboardEvent* event, Vector<WTF::String>& pendingEditorCommands) +{ + ASSERT(event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent); + + // First try to interpret the command in the UI and get the commands. + WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::GetEditorCommandsForKeyEvent(), + Messages::WebPageProxy::GetEditorCommandsForKeyEvent::Reply(pendingEditorCommands), + m_page->pageID(), CoreIPC::Connection::NoTimeout); +} + +bool WebEditorClient::executePendingEditorCommands(Frame* frame, Vector<WTF::String> pendingEditorCommands, bool allowTextInsertion) +{ + Vector<Editor::Command> commands; + for (size_t i = 0; i < pendingEditorCommands.size(); i++) { + Editor::Command command = frame->editor()->command(pendingEditorCommands.at(i).utf8().data()); + if (command.isTextInsertion() && !allowTextInsertion) + return false; + + commands.append(command); + } + + for (size_t i = 0; i < commands.size(); i++) { + if (!commands.at(i).execute()) + return false; + } + + return true; +} + +void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) +{ + Node* node = event->target()->toNode(); + ASSERT(node); + Frame* frame = node->document()->frame(); + ASSERT(frame); + + const PlatformKeyboardEvent* platformEvent = event->keyEvent(); + if (!platformEvent) + return; + + Vector<WTF::String> pendingEditorCommands; + getEditorCommandsForKeyEvent(event, pendingEditorCommands); + if (!pendingEditorCommands.isEmpty()) { + + // During RawKeyDown events if an editor command will insert text, defer + // the insertion until the keypress event. We want keydown to bubble up + // through the DOM first. + if (platformEvent->type() == PlatformKeyboardEvent::RawKeyDown) { + if (executePendingEditorCommands(frame, pendingEditorCommands, false)) + event->setDefaultHandled(); + + return; + } + + // Only allow text insertion commands if the current node is editable. + if (executePendingEditorCommands(frame, pendingEditorCommands, frame->editor()->canEdit())) { + event->setDefaultHandled(); + return; + } + } + + // Don't allow text insertion for nodes that cannot edit. + if (!frame->editor()->canEdit()) + return; + + // This is just a normal text insertion, so wait to execute the insertion + // until a keypress event happens. This will ensure that the insertion will not + // be reflected in the contents of the field until the keyup DOM event. + if (event->type() == eventNames().keypressEvent) { + + // FIXME: Add IM support + // https://bugs.webkit.org/show_bug.cgi?id=55946 + frame->editor()->insertText(platformEvent->text(), event); + event->setDefaultHandled(); + + } else { + // Don't insert null or control characters as they can result in unexpected behaviour + if (event->charCode() < ' ') + return; + + // Don't insert anything if a modifier is pressed + if (platformEvent->ctrlKey() || platformEvent->altKey()) + return; + + if (frame->editor()->insertText(platformEvent->text(), event)) + event->setDefaultHandled(); + } +} + +void WebEditorClient::handleInputMethodKeydown(KeyboardEvent*) +{ + notImplemented(); +} + +} diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm index 6aa83f8..84b7d50 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm @@ -80,9 +80,7 @@ void WebContextMenuClient::searchWithSpotlight() if (selectedString.isEmpty()) return; - NSString *convertedSelectedString = selectedString; - - [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:convertedSelectedString]; + m_page->send(Messages::WebPageProxy::SearchWithSpotlight(selectedString)); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm index 75d92e2..b9806f4 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm @@ -152,7 +152,7 @@ void WebDragClient::declareAndWriteDragImage(NSPasteboard *pasteboard, DOMElemen RetainPtr<WKPasteboardFilePromiseOwner> filePromiseOwner(AdoptNS, [(WKPasteboardFilePromiseOwner *)[WKPasteboardFilePromiseOwner alloc] initWithSource:pasteboardOwner.get()]); m_page->setDragSource(filePromiseOwner.get()); - [pasteboard declareTypes:types.get() owner:pasteboardOwner.get()]; + [pasteboard declareTypes:types.get() owner:pasteboardOwner.leakRef()]; [pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType]; @@ -252,6 +252,7 @@ static CachedResourceClient* promisedDataClient() - (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard { [self clearImage]; + CFRelease(self); // Balanced by the leakRef that WebDragClient::declareAndWriteDragImage does when making this pasteboard owner. } static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm index 7a95a72..17fd5fe 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm @@ -46,9 +46,6 @@ #import <WebCore/Page.h> #import <WebKit/WebResource.h> #import <WebKit/WebNSURLExtras.h> -#if !defined(BUILDING_ON_SNOW_LEOPARD) -#import <AppKit/NSTextChecker.h> -#endif using namespace WebCore; @@ -64,13 +61,13 @@ namespace WebKit { void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) { - if (m_page->interceptEditingKeyboardEvent(event, false)) + if (m_page->handleEditingKeyboardEvent(event, false)) event->setDefaultHandled(); } void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event) { - if (m_page->interceptEditingKeyboardEvent(event, true)) + if (m_page->handleEditingKeyboardEvent(event, true)) event->setDefaultHandled(); } @@ -176,8 +173,9 @@ void WebEditorClient::showSubstitutionsPanel(bool) bool WebEditorClient::substitutionsPanelIsShowing() { - notImplemented(); - return false; + bool isShowing; + m_page->sendSync(Messages::WebPageProxy::SubstitutionsPanelIsShowing(), Messages::WebPageProxy::SubstitutionsPanelIsShowing::Reply(isShowing)); + return isShowing; } void WebEditorClient::toggleSmartInsertDelete() @@ -240,7 +238,7 @@ void WebEditorClient::toggleAutomaticSpellingCorrection() notImplemented(); } -void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64_t checkingTypes, Vector<TextCheckingResult>& results) +void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results) { // FIXME: It would be nice if we wouldn't have to copy the text here. m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results)); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm index 70e7607..3ae02a9 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm @@ -43,17 +43,17 @@ static NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlug static NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey"; // Policy errors -#define WebKitErrorDescriptionCannotShowMIMEType UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description") -#define WebKitErrorDescriptionCannotShowURL UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description") -#define WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description") -#define WebKitErrorDescriptionCannotUseRestrictedPort UI_STRING("Not allowed to use restricted network port", "WebKitErrorCannotUseRestrictedPort description") +#define WebKitErrorDescriptionCannotShowMIMEType WEB_UI_STRING("Content with specified MIME type can’t be shown", "WebKitErrorCannotShowMIMEType description") +#define WebKitErrorDescriptionCannotShowURL WEB_UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description") +#define WebKitErrorDescriptionFrameLoadInterruptedByPolicyChange WEB_UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description") +#define WebKitErrorDescriptionCannotUseRestrictedPort WEB_UI_STRING("Not allowed to use restricted network port", "WebKitErrorCannotUseRestrictedPort description") // Plug-in and java errors -#define WebKitErrorDescriptionCannotFindPlugin UI_STRING("The plug-in can’t be found", "WebKitErrorCannotFindPlugin description") -#define WebKitErrorDescriptionCannotLoadPlugin UI_STRING("The plug-in can’t be loaded", "WebKitErrorCannotLoadPlugin description") -#define WebKitErrorDescriptionJavaUnavailable UI_STRING("Java is unavailable", "WebKitErrorJavaUnavailable description") -#define WebKitErrorDescriptionPlugInCancelledConnection UI_STRING("Plug-in cancelled", "WebKitErrorPlugInCancelledConnection description") -#define WebKitErrorDescriptionPlugInWillHandleLoad UI_STRING("Plug-in handled load", "WebKitErrorPlugInWillHandleLoad description") +#define WebKitErrorDescriptionCannotFindPlugin WEB_UI_STRING("The plug-in can’t be found", "WebKitErrorCannotFindPlugin description") +#define WebKitErrorDescriptionCannotLoadPlugin WEB_UI_STRING("The plug-in can’t be loaded", "WebKitErrorCannotLoadPlugin description") +#define WebKitErrorDescriptionJavaUnavailable WEB_UI_STRING("Java is unavailable", "WebKitErrorJavaUnavailable description") +#define WebKitErrorDescriptionPlugInCancelledConnection WEB_UI_STRING("Plug-in cancelled", "WebKitErrorPlugInCancelledConnection description") +#define WebKitErrorDescriptionPlugInWillHandleLoad WEB_UI_STRING("Plug-in handled load", "WebKitErrorPlugInWillHandleLoad description") static pthread_once_t registerErrorsControl = PTHREAD_ONCE_INIT; static void registerErrors(void); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm index e36f438..b9bc48f 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -46,6 +46,7 @@ void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData& data return; data.fontInfo.fontAttributeDictionary = fontDescriptorAttributes; + data.shouldPopOver = m_popupClient->shouldPopOver(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm index 06faa2f..a4fbc09 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm +++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm @@ -65,7 +65,6 @@ void InitWebCoreSystemInterface(void) INIT(GetWheelEventDeltas); INIT(HitTestMediaUIPart); INIT(InitializeMaximumHTTPConnectionCountPerHost); - INIT(IsLatchingWheelEvent); INIT(MeasureMediaUIPart); INIT(MediaControllerThemeAvailable); INIT(PopupMenu); @@ -85,7 +84,9 @@ void InitWebCoreSystemInterface(void) INIT(SetCONNECTProxyForStream); INIT(SetCookieStoragePrivateBrowsingEnabled); INIT(SetDragImage); + INIT(SetHTTPPipeliningMaximumPriority); INIT(SetHTTPPipeliningPriority); + INIT(SetHTTPPipeliningMinimumFastLanePriority); INIT(SetNSURLConnectionDefersCallbacks); INIT(SetNSURLRequestShouldContentSniff); INIT(SetPatternBaseCTM); @@ -135,9 +136,12 @@ void InitWebCoreSystemInterface(void) INIT(WillEndLiveResize); INIT(ContentAreaDidShow); INIT(ContentAreaDidHide); + INIT(DidBeginScrollGesture); + INIT(DidEndScrollGesture); INIT(ScrollbarPainterUsesOverlayScrollers); #else INIT(GetHyphenationLocationBeforeIndex); + INIT(GetNSEventMomentumPhase); #endif INIT(GetAXTextMarkerTypeID); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp index 5fcaa84..0248f70 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp @@ -29,6 +29,7 @@ namespace WebCore { WebFrameNetworkingContext::WebFrameNetworkingContext(Frame* frame) : FrameNetworkingContext(frame) , m_originatingObject(0) + , m_mimeSniffingEnabled(true) { } @@ -47,4 +48,9 @@ QNetworkAccessManager* WebFrameNetworkingContext::networkAccessManager() const return WebKit::WebProcess::shared().networkAccessManager(); } +bool WebFrameNetworkingContext::mimeSniffingEnabled() const +{ + return m_mimeSniffingEnabled; +} + } diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h index 9c87785..f2cf248 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.h @@ -33,8 +33,10 @@ private: virtual QObject* originatingObject() const; virtual QNetworkAccessManager* networkAccessManager() const; + virtual bool mimeSniffingEnabled() const; QObject* m_originatingObject; + bool m_mimeSniffingEnabled; }; } diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index 47acc7a..6272fb5 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -42,6 +42,7 @@ #endif using namespace WebCore; +using namespace std; namespace WebKit { @@ -159,7 +160,8 @@ void DrawingAreaImpl::forceRepaint() if (m_layerTreeHost) { m_layerTreeHost->forceRepaint(); - return; + if (!m_layerTreeHost->participatesInDisplay()) + return; } m_isWaitingForDidUpdate = false; @@ -190,6 +192,13 @@ void DrawingAreaImpl::setPageOverlayNeedsDisplay(const IntRect& rect) setNeedsDisplay(rect); } +void DrawingAreaImpl::setLayerHostNeedsDisplay() +{ + ASSERT(m_layerTreeHost); + ASSERT(m_layerTreeHost->participatesInDisplay()); + scheduleDisplay(); +} + void DrawingAreaImpl::layerHostDidFlushLayers() { ASSERT(m_layerTreeHost); @@ -201,8 +210,12 @@ void DrawingAreaImpl::layerHostDidFlushLayers() return; } - if (!m_layerTreeHost) + if (!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()) { + // When the layer tree host participates in display, we never tell the UI process about + // accelerated compositing. From the UI process's point of view, we're still just sending + // it a series of bitmaps in Update messages. return; + } #if USE(ACCELERATED_COMPOSITING) m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext())); @@ -301,13 +314,13 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState() UpdateInfo updateInfo; - if (!m_isPaintingSuspended && !m_layerTreeHost) + if (!m_isPaintingSuspended && (!m_layerTreeHost || m_layerTreeHost->participatesInDisplay())) display(updateInfo); #if USE(ACCELERATED_COMPOSITING) LayerTreeContext layerTreeContext; - if (m_isPaintingSuspended || m_layerTreeHost) { + if (m_isPaintingSuspended || (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay())) { updateInfo.viewSize = m_webPage->size(); if (m_layerTreeHost) { @@ -318,6 +331,7 @@ void DrawingAreaImpl::sendDidUpdateBackingStoreState() // message back to the UI process, but the updated layer tree context // will be sent back in the DidUpdateBackingStoreState message. m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false); + m_layerTreeHost->forceRepaint(); } } @@ -329,7 +343,7 @@ void DrawingAreaImpl::didUpdate() { // We might get didUpdate messages from the UI process even after we've // entered accelerated compositing mode. Ignore them. - if (m_layerTreeHost) + if (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) return; m_isWaitingForDidUpdate = false; @@ -342,14 +356,24 @@ void DrawingAreaImpl::suspendPainting() { ASSERT(!m_isPaintingSuspended); + if (m_layerTreeHost) + m_layerTreeHost->pauseRendering(); + m_isPaintingSuspended = true; m_displayTimer.stop(); } void DrawingAreaImpl::resumePainting() { - ASSERT(m_isPaintingSuspended); - + if (!m_isPaintingSuspended) { + // FIXME: We can get a call to resumePainting when painting is not suspended. + // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>. + return; + } + + if (m_layerTreeHost) + m_layerTreeHost->resumeRendering(); + m_isPaintingSuspended = false; // FIXME: We shouldn't always repaint everything here. @@ -372,8 +396,11 @@ void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLay m_dirtyRegion = Region(); m_scrollRect = IntRect(); m_scrollOffset = IntSize(); - m_displayTimer.stop(); - m_isWaitingForDidUpdate = false; + + if (!m_layerTreeHost->participatesInDisplay()) { + m_displayTimer.stop(); + m_isWaitingForDidUpdate = false; + } } void DrawingAreaImpl::exitAcceleratedCompositingMode() @@ -385,6 +412,8 @@ void DrawingAreaImpl::exitAcceleratedCompositingMode() ASSERT(m_layerTreeHost); + bool wasParticipatingInDisplay = m_layerTreeHost->participatesInDisplay(); + m_layerTreeHost->invalidate(); m_layerTreeHost = nullptr; m_dirtyRegion = m_webPage->bounds(); @@ -404,9 +433,16 @@ void DrawingAreaImpl::exitAcceleratedCompositingMode() display(updateInfo); #if USE(ACCELERATED_COMPOSITING) - // Send along a complete update of the page so we can paint the contents right after we exit the - // accelerated compositing mode, eliminiating flicker. - m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo)); + if (wasParticipatingInDisplay) { + // When the layer tree host participates in display, we never tell the UI process about + // accelerated compositing. From the UI process's point of view, we're still just sending + // it a series of bitmaps in Update messages. + m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo)); + } else { + // Send along a complete update of the page so we can paint the contents right after we exit the + // accelerated compositing mode, eliminiating flicker. + m_webPage->send(Messages::DrawingAreaProxy::ExitAcceleratedCompositingMode(m_backingStoreStateID, updateInfo)); + } #endif } @@ -420,14 +456,19 @@ void DrawingAreaImpl::exitAcceleratedCompositingModeSoon() void DrawingAreaImpl::scheduleDisplay() { + ASSERT(!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()); + if (m_isWaitingForDidUpdate) return; if (m_isPaintingSuspended) return; - if (m_dirtyRegion.isEmpty()) - return; + if (m_layerTreeHost) { + if (!m_layerTreeHost->needsDisplay()) + return; + } else if (m_dirtyRegion.isEmpty()) + return; if (m_displayTimer.isActive()) return; @@ -440,7 +481,8 @@ void DrawingAreaImpl::displayTimerFired() static const double minimumFrameInterval = 1.0 / 60.0; double timeSinceLastDisplay = currentTime() - m_lastDisplayTime; - double timeUntilNextDisplay = minimumFrameInterval - timeSinceLastDisplay; + double timeUntilLayerTreeHostNeedsDisplay = m_layerTreeHost && m_layerTreeHost->participatesInDisplay() ? m_layerTreeHost->timeUntilNextDisplay() : 0; + double timeUntilNextDisplay = max(minimumFrameInterval - timeSinceLastDisplay, timeUntilLayerTreeHostNeedsDisplay); if (timeUntilNextDisplay > 0) { m_displayTimer.startOneShot(timeUntilNextDisplay); @@ -452,14 +494,17 @@ void DrawingAreaImpl::displayTimerFired() void DrawingAreaImpl::display() { - ASSERT(!m_layerTreeHost); + ASSERT(!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()); ASSERT(!m_isWaitingForDidUpdate); ASSERT(!m_inUpdateBackingStoreState); if (m_isPaintingSuspended) return; - if (m_dirtyRegion.isEmpty()) + if (m_layerTreeHost) { + if (!m_layerTreeHost->needsDisplay()) + return; + } else if (m_dirtyRegion.isEmpty()) return; if (m_shouldSendDidUpdateBackingStoreState) { @@ -470,7 +515,7 @@ void DrawingAreaImpl::display() UpdateInfo updateInfo; display(updateInfo); - if (m_layerTreeHost) { + if (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) { // The call to update caused layout which turned on accelerated compositing. // Don't send an Update message in this case. return; @@ -504,7 +549,7 @@ static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>& void DrawingAreaImpl::display(UpdateInfo& updateInfo) { ASSERT(!m_isPaintingSuspended); - ASSERT(!m_layerTreeHost); + ASSERT(!m_layerTreeHost || m_layerTreeHost->participatesInDisplay()); ASSERT(!m_webPage->size().isEmpty()); // FIXME: It would be better if we could avoid painting altogether when there is a custom representation. @@ -516,44 +561,49 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo) m_webPage->layoutIfNeeded(); - // The layout may have put the page into accelerated compositing mode, in which case the - // LayerTreeHost is now in charge of displaying. - if (m_layerTreeHost) + // The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is + // in charge of displaying, we have nothing more to do. + if (m_layerTreeHost && !m_layerTreeHost->participatesInDisplay()) return; - IntRect bounds = m_dirtyRegion.bounds(); - ASSERT(m_webPage->bounds().contains(bounds)); + updateInfo.viewSize = m_webPage->size(); + + if (m_layerTreeHost) + m_layerTreeHost->display(updateInfo); + else { + IntRect bounds = m_dirtyRegion.bounds(); + ASSERT(m_webPage->bounds().contains(bounds)); - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha); - if (!bitmap->createHandle(updateInfo.bitmapHandle)) - return; + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bounds.size(), ShareableBitmap::SupportsAlpha); + if (!bitmap->createHandle(updateInfo.bitmapHandle)) + return; - Vector<IntRect> rects = m_dirtyRegion.rects(); + Vector<IntRect> rects = m_dirtyRegion.rects(); - if (shouldPaintBoundsRect(bounds, rects)) { - rects.clear(); - rects.append(bounds); - } + if (shouldPaintBoundsRect(bounds, rects)) { + rects.clear(); + rects.append(bounds); + } - updateInfo.scrollRect = m_scrollRect; - updateInfo.scrollOffset = m_scrollOffset; + updateInfo.scrollRect = m_scrollRect; + updateInfo.scrollOffset = m_scrollOffset; - m_dirtyRegion = Region(); - m_scrollRect = IntRect(); - m_scrollOffset = IntSize(); + m_dirtyRegion = Region(); + m_scrollRect = IntRect(); + m_scrollOffset = IntSize(); - OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); - - updateInfo.viewSize = m_webPage->size(); - updateInfo.updateRectBounds = bounds; + OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); + + updateInfo.updateRectBounds = bounds; - graphicsContext->translate(-bounds.x(), -bounds.y()); + graphicsContext->translate(-bounds.x(), -bounds.y()); - for (size_t i = 0; i < rects.size(); ++i) { - m_webPage->drawRect(*graphicsContext, rects[i]); - if (m_webPage->hasPageOverlay()) - m_webPage->drawPageOverlay(*graphicsContext, rects[i]); - updateInfo.updateRects.append(rects[i]); + for (size_t i = 0; i < rects.size(); ++i) { + m_webPage->drawRect(*graphicsContext, rects[i]); + if (m_webPage->hasPageOverlay()) + m_webPage->drawPageOverlay(*graphicsContext, rects[i]); + updateInfo.updateRects.append(rects[i]); + } } // Layout can trigger more calls to setNeedsDisplay and we don't want to process them diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index 9e93869..471ba56 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -40,6 +40,7 @@ public: static PassOwnPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&); virtual ~DrawingAreaImpl(); + void setLayerHostNeedsDisplay(); void layerHostDidFlushLayers(); private: diff --git a/Source/WebKit2/WebProcess/WebPage/FindController.cpp b/Source/WebKit2/WebProcess/WebPage/FindController.cpp index 3e7b268..49f5786 100644 --- a/Source/WebKit2/WebProcess/WebPage/FindController.cpp +++ b/Source/WebKit2/WebProcess/WebPage/FindController.cpp @@ -38,6 +38,7 @@ #include <WebCore/GraphicsContext.h> #include <WebCore/Page.h> +using namespace std; using namespace WebCore; namespace WebKit { @@ -64,9 +65,16 @@ FindController::~FindController() void FindController::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount) { - unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount); + if (maxMatchCount == numeric_limits<unsigned>::max()) + --maxMatchCount; + + unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1); m_webPage->corePage()->unmarkAllTextMatches(); + // Check if we have more matches than allowed. + if (matchCount > maxMatchCount) + matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount); + m_webPage->send(Messages::WebPageProxy::DidCountStringMatches(string, matchCount)); } @@ -102,6 +110,9 @@ void FindController::findString(const String& string, FindOptions options, unsig shouldShowOverlay = options & FindOptionsShowOverlay; if (shouldShowOverlay) { + if (maxMatchCount == numeric_limits<unsigned>::max()) + --maxMatchCount; + unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1); // Check if we have more matches than allowed. @@ -122,7 +133,7 @@ void FindController::findString(const String& string, FindOptions options, unsig if (!shouldShowOverlay) { if (m_findPageOverlay) { // Get rid of the overlay. - m_webPage->uninstallPageOverlay(m_findPageOverlay); + m_webPage->uninstallPageOverlay(m_findPageOverlay, false); } ASSERT(!m_findPageOverlay); @@ -142,7 +153,7 @@ void FindController::findString(const String& string, FindOptions options, unsig void FindController::hideFindUI() { if (m_findPageOverlay) - m_webPage->uninstallPageOverlay(m_findPageOverlay); + m_webPage->uninstallPageOverlay(m_findPageOverlay, true); hideFindIndicator(); } @@ -259,27 +270,39 @@ static const float shadowOffsetY = 1.0; static const float shadowBlurRadius = 2.0; static const float whiteFrameThickness = 1.0; -static const int overlayBackgroundRed = 25; -static const int overlayBackgroundGreen = 25; -static const int overlayBackgroundBlue = 25; -static const int overlayBackgroundAlpha = 63; +static const float overlayBackgroundRed = 0.1; +static const float overlayBackgroundGreen = 0.1; +static const float overlayBackgroundBlue = 0.1; +static const float overlayBackgroundAlpha = 0.25; + +static Color overlayBackgroundColor(float fractionFadedIn) +{ + return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha * fractionFadedIn); +} -static Color overlayBackgroundColor() +static Color holeShadowColor(float fractionFadedIn) { - return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha); + return Color(0.0f, 0.0f, 0.0f, fractionFadedIn); } -void FindController::drawRect(PageOverlay*, GraphicsContext& graphicsContext, const IntRect& dirtyRect) +static Color holeFillColor(float fractionFadedIn) { + return Color(1.0f, 1.0f, 1.0f, fractionFadedIn); +} + +void FindController::drawRect(PageOverlay* pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect) +{ + float fractionFadedIn = pageOverlay->fractionFadedIn(); + Vector<IntRect> rects = rectsForTextMatches(); // Draw the background. - graphicsContext.fillRect(dirtyRect, overlayBackgroundColor(), ColorSpaceSRGB); + graphicsContext.fillRect(dirtyRect, overlayBackgroundColor(fractionFadedIn), ColorSpaceSRGB); graphicsContext.save(); - graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, Color::black, ColorSpaceSRGB); + graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, holeShadowColor(fractionFadedIn), ColorSpaceSRGB); - graphicsContext.setFillColor(Color::white, ColorSpaceSRGB); + graphicsContext.setFillColor(holeFillColor(fractionFadedIn), ColorSpaceSRGB); // Draw white frames around the holes. for (size_t i = 0; i < rects.size(); ++i) { diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp index 737e195..24cbcc6 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp @@ -26,8 +26,12 @@ #include "config.h" #include "LayerTreeHost.h" +#if USE(CA) #if PLATFORM(MAC) -#include "LayerTreeHostCA.h" +#include "LayerTreeHostCAMac.h" +#elif PLATFORM(WIN) +#include "LayerTreeHostCAWin.h" +#endif #endif #if !PLATFORM(MAC) && !PLATFORM(WIN) @@ -41,10 +45,12 @@ namespace WebKit { PassRefPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage) { #if PLATFORM(MAC) - return LayerTreeHostCA::create(webPage); -#endif - + return LayerTreeHostCAMac::create(webPage); +#elif PLATFORM(WIN) && HAVE(WKQCA) + return LayerTreeHostCAWin::create(webPage); +#else return 0; +#endif } LayerTreeHost::LayerTreeHost(WebPage* webPage) diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h index bbb94e8..004bdb7 100644 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h @@ -38,6 +38,7 @@ namespace WebCore { namespace WebKit { class LayerTreeContext; +class UpdateInfo; class WebPage; class LayerTreeHost : public RefCounted<LayerTreeHost> { @@ -45,6 +46,8 @@ public: static PassRefPtr<LayerTreeHost> create(WebPage*); virtual ~LayerTreeHost(); + static bool supportsAcceleratedCompositing(); + virtual const LayerTreeContext& layerTreeContext() = 0; virtual void scheduleLayerFlush() = 0; virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool) = 0; @@ -60,12 +63,29 @@ public: virtual void didUninstallPageOverlay() = 0; virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) = 0; + virtual void pauseRendering() { } + virtual void resumeRendering() { } + + // If a derived class overrides this function to return true, the derived class must also + // override the functions beneath it. + virtual bool participatesInDisplay() { return false; } + virtual bool needsDisplay() { ASSERT_NOT_REACHED(); return false; } + virtual double timeUntilNextDisplay() { ASSERT_NOT_REACHED(); return 0; } + virtual void display(UpdateInfo&) { ASSERT_NOT_REACHED(); } + protected: explicit LayerTreeHost(WebPage*); WebPage* m_webPage; }; +#if !PLATFORM(WIN) +inline bool LayerTreeHost::supportsAcceleratedCompositing() +{ + return true; +} +#endif + } // namespace WebKit #endif // LayerTreeHost_h diff --git a/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp b/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp index 67c1165..d4b1b41 100644 --- a/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp +++ b/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp @@ -27,6 +27,7 @@ #include "PageOverlay.h" #include "WebPage.h" +#include "WebProcess.h" #include <WebCore/Frame.h> #include <WebCore/FrameView.h> #include <WebCore/GraphicsContext.h> @@ -37,6 +38,9 @@ using namespace WebCore; namespace WebKit { +static const double fadeAnimationDuration = 0.2; +static const double fadeAnimationFrameRate = 30; + PassRefPtr<PageOverlay> PageOverlay::create(Client* client) { return adoptRef(new PageOverlay(client)); @@ -45,6 +49,11 @@ PassRefPtr<PageOverlay> PageOverlay::create(Client* client) PageOverlay::PageOverlay(Client* client) : m_client(client) , m_webPage(0) + , m_fadeAnimationTimer(WebProcess::shared().runLoop(), this, &PageOverlay::fadeAnimationTimerFired) + , m_fadeAnimationStartTime(0.0) + , m_fadeAnimationDuration(fadeAnimationDuration) + , m_fadeAnimationType(NoAnimation) + , m_fractionFadedIn(1.0) { } @@ -54,7 +63,7 @@ PageOverlay::~PageOverlay() IntRect PageOverlay::bounds() const { - FrameView* frameView = webPage()->corePage()->mainFrame()->view(); + FrameView* frameView = m_webPage->corePage()->mainFrame()->view(); int width = frameView->width(); int height = frameView->height(); @@ -73,6 +82,8 @@ void PageOverlay::setPage(WebPage* webPage) m_client->willMoveToWebPage(this, webPage); m_webPage = webPage; m_client->didMoveToWebPage(this, webPage); + + m_fadeAnimationTimer.stop(); } void PageOverlay::setNeedsDisplay(const IntRect& dirtyRect) @@ -112,4 +123,54 @@ bool PageOverlay::mouseEvent(const WebMouseEvent& mouseEvent) return m_client->mouseEvent(this, mouseEvent); } +void PageOverlay::startFadeInAnimation() +{ + m_fractionFadedIn = 0.0; + m_fadeAnimationType = FadeInAnimation; + + startFadeAnimation(); +} + +void PageOverlay::startFadeOutAnimation() +{ + m_fractionFadedIn = 1.0; + m_fadeAnimationType = FadeOutAnimation; + + startFadeAnimation(); +} + +void PageOverlay::startFadeAnimation() +{ + m_fadeAnimationStartTime = currentTime(); + + // Start the timer + m_fadeAnimationTimer.startRepeating(1 / fadeAnimationFrameRate); +} + +void PageOverlay::fadeAnimationTimerFired() +{ + float animationProgress = (currentTime() - m_fadeAnimationStartTime) / m_fadeAnimationDuration; + + if (animationProgress >= 1.0) + animationProgress = 1.0; + + double sine = sin(piOverTwoFloat * animationProgress); + float fadeAnimationValue = sine * sine; + + m_fractionFadedIn = (m_fadeAnimationType == FadeInAnimation) ? fadeAnimationValue : 1 - fadeAnimationValue; + setNeedsDisplay(); + + if (animationProgress == 1.0) { + m_fadeAnimationTimer.stop(); + + bool wasFadingOut = m_fadeAnimationType == FadeOutAnimation; + m_fadeAnimationType = NoAnimation; + + if (wasFadingOut) { + // If this was a fade out, go ahead and uninstall the page overlay. + m_webPage->uninstallPageOverlay(this, false); + } + } +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/PageOverlay.h b/Source/WebKit2/WebProcess/WebPage/PageOverlay.h index 6f1f70f..1f61ceb 100644 --- a/Source/WebKit2/WebProcess/WebPage/PageOverlay.h +++ b/Source/WebKit2/WebProcess/WebPage/PageOverlay.h @@ -27,6 +27,7 @@ #define PageOverlay_h #include "APIObject.h" +#include "RunLoop.h" #include <wtf/PassRefPtr.h> namespace WebCore { @@ -65,20 +66,38 @@ public: void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect); bool mouseEvent(const WebMouseEvent&); + void startFadeInAnimation(); + void startFadeOutAnimation(); + + float fractionFadedIn() const { return m_fractionFadedIn; } + protected: explicit PageOverlay(Client*); - WebPage* webPage() const { return m_webPage; } - private: // APIObject virtual Type type() const { return APIType; } WebCore::IntRect bounds() const; - Client* m_client; + void startFadeAnimation(); + void fadeAnimationTimerFired(); + Client* m_client; WebPage* m_webPage; + + RunLoop::Timer<PageOverlay> m_fadeAnimationTimer; + double m_fadeAnimationStartTime; + double m_fadeAnimationDuration; + + enum FadeAnimationType { + NoAnimation, + FadeInAnimation, + FadeOutAnimation, + }; + + FadeAnimationType m_fadeAnimationType; + float m_fractionFadedIn; }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp index 35058de..cbed180 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp @@ -82,7 +82,8 @@ void WebContextMenu::show() contextMenuState.absoluteImageURLString = controller->hitTestResult().absoluteImageURL().string(); contextMenuState.absoluteLinkURLString = controller->hitTestResult().absoluteLinkURL().string(); - // Notify the UIProcess. + // Mark the WebPage has having a shown context menu then notify the UIProcess. + m_page->contextMenuShowing(); m_page->send(Messages::WebPageProxy::ShowContextMenu(view->contentsToWindow(controller->hitTestResult().point()), contextMenuState, proposedMenu, InjectedBundleUserMessageEncoder(userData.get()))); } diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp index 574634f..0d550c9 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp @@ -512,6 +512,30 @@ IntSize WebFrame::scrollOffset() const return view->scrollOffset(); } +bool WebFrame::hasHorizontalScrollbar() const +{ + if (!m_coreFrame) + return false; + + FrameView* view = m_coreFrame->view(); + if (!view) + return false; + + return view->horizontalScrollbar(); +} + +bool WebFrame::hasVerticalScrollbar() const +{ + if (!m_coreFrame) + return false; + + FrameView* view = m_coreFrame->view(); + if (!view) + return false; + + return view->verticalScrollbar(); +} + bool WebFrame::getDocumentBackgroundColor(double* red, double* green, double* blue, double* alpha) { if (!m_coreFrame) @@ -550,6 +574,9 @@ WebFrame* WebFrame::frameForContext(JSContextRef context) JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, InjectedBundleScriptWorld* world) { + if (!m_coreFrame) + return 0; + JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld()); ExecState* exec = globalObject->globalExec(); @@ -559,6 +586,9 @@ JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, Inj JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleRangeHandle* rangeHandle, InjectedBundleScriptWorld* world) { + if (!m_coreFrame) + return 0; + JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld()); ExecState* exec = globalObject->globalExec(); diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.h b/Source/WebKit2/WebProcess/WebPage/WebFrame.h index 3c63cf3..b6e1e13 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebFrame.h +++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.h @@ -93,6 +93,8 @@ public: WebCore::IntRect visibleContentBounds() const; WebCore::IntRect visibleContentBoundsExcludingScrollbars() const; WebCore::IntSize scrollOffset() const; + bool hasHorizontalScrollbar() const; + bool hasVerticalScrollbar() const; bool getDocumentBackgroundColor(double* red, double* green, double* blue, double* alpha); static WebFrame* frameForContext(JSContextRef); diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index d5f3724..7707965 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -32,6 +32,7 @@ #include "DrawingArea.h" #include "InjectedBundle.h" #include "InjectedBundleBackForwardList.h" +#include "LayerTreeHost.h" #include "MessageID.h" #include "NetscapePlugin.h" #include "PageOverlay.h" @@ -66,8 +67,8 @@ #include "WebPopupMenu.h" #include "WebPreferencesStore.h" #include "WebProcess.h" -#include "WebProcessProxyMessageKinds.h" #include "WebProcessProxyMessages.h" +#include <JavaScriptCore/APICast.h> #include <WebCore/AbstractDatabase.h> #include <WebCore/ArchiveResource.h> #include <WebCore/Chrome.h> @@ -77,18 +78,23 @@ #include <WebCore/DocumentMarkerController.h> #include <WebCore/DragController.h> #include <WebCore/DragData.h> +#include <WebCore/EditingBehavior.h> #include <WebCore/EventHandler.h> #include <WebCore/FocusController.h> +#include <WebCore/FormState.h> #include <WebCore/Frame.h> +#include <WebCore/FrameLoadRequest.h> #include <WebCore/FrameLoaderTypes.h> #include <WebCore/FrameView.h> +#include <WebCore/HTMLFormElement.h> #include <WebCore/HistoryItem.h> #include <WebCore/KeyboardEvent.h> +#include <WebCore/MouseEvent.h> #include <WebCore/Page.h> #include <WebCore/PlatformKeyboardEvent.h> #include <WebCore/PrintContext.h> -#include <WebCore/RenderTreeAsText.h> #include <WebCore/RenderLayer.h> +#include <WebCore/RenderTreeAsText.h> #include <WebCore/RenderView.h> #include <WebCore/ReplaceSelectionCommand.h> #include <WebCore/ResourceRequest.h> @@ -110,9 +116,10 @@ #endif #if ENABLE(PLUGIN_PROCESS) -// FIXME: This is currently Mac-specific! +#if PLATFORM(MAC) #include "MachPort.h" #endif +#endif #if PLATFORM(QT) #include "HitTestResult.h" @@ -151,6 +158,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) #if PLATFORM(MAC) , m_windowIsVisible(false) , m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled) + , m_keyboardEventBeingInterpreted(0) #elif PLATFORM(WIN) , m_nativeWindow(parameters.nativeWindow) #endif @@ -163,6 +171,10 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) , m_userSpaceScaleFactor(parameters.userSpaceScaleFactor) , m_cachedMainFrameIsPinnedToLeftSide(false) , m_cachedMainFrameIsPinnedToRightSide(false) + , m_isShowingContextMenu(false) +#if PLATFORM(WIN) + , m_gestureReachedScrollingLimit(false) +#endif { ASSERT(m_pageID); @@ -282,6 +294,13 @@ void WebPage::initializeInjectedBundleUIClient(WKBundlePageUIClient* client) m_uiClient.initialize(client); } +#if ENABLE(FULLSCREEN_API) +void WebPage::initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient* client) +{ + m_fullScreenClient.initialize(client); +} +#endif + PassRefPtr<Plugin> WebPage::createPlugin(const Plugin::Parameters& parameters) { String pluginPath; @@ -302,6 +321,22 @@ PassRefPtr<Plugin> WebPage::createPlugin(const Plugin::Parameters& parameters) #endif } +EditorState WebPage::editorState() const +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + ASSERT(frame); + + EditorState result; + result.selectionIsNone = frame->selection()->isNone(); + result.selectionIsRange = frame->selection()->isRange(); + result.isContentEditable = frame->selection()->isContentEditable(); + result.isContentRichlyEditable = frame->selection()->isContentRichlyEditable(); + result.isInPasswordField = frame->selection()->isInPasswordField(); + result.hasComposition = frame->editor()->hasComposition(); + + return result; +} + String WebPage::renderTreeExternalRepresentation() const { return externalRepresentation(m_mainFrame->coreFrame(), RenderAsTextBehaviorNormal); @@ -440,6 +475,20 @@ void WebPage::loadPlainTextString(const String& string) loadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL()); } +void WebPage::linkClicked(const String& url, const WebMouseEvent& event) +{ + Frame* frame = m_page->mainFrame(); + if (!frame) + return; + + RefPtr<Event> coreEvent; + if (event.type() != WebEvent::NoType) + coreEvent = MouseEvent::create(eventNames().clickEvent, frame->document()->defaultView(), platform(event), 0, 0); + + frame->loader()->loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(url)), + false, false, coreEvent.get(), 0, SendReferrer); +} + void WebPage::stopLoadingFrame(uint64_t frameID) { WebFrame* frame = WebProcess::shared().webFrame(frameID); @@ -697,22 +746,38 @@ void WebPage::setFixedLayoutSize(const IntSize& size) void WebPage::installPageOverlay(PassRefPtr<PageOverlay> pageOverlay) { - if (m_pageOverlay) - pageOverlay->setPage(0); + bool shouldFadeIn = true; + + if (m_pageOverlay) { + m_pageOverlay->setPage(0); + + if (pageOverlay) { + // We're installing a page overlay when a page overlay is already active. + // In this case we don't want to fade in the new overlay. + shouldFadeIn = false; + } + } m_pageOverlay = pageOverlay; m_pageOverlay->setPage(this); - m_drawingArea->didInstallPageOverlay(); + if (shouldFadeIn) + m_pageOverlay->startFadeInAnimation(); + m_drawingArea->didInstallPageOverlay(); m_pageOverlay->setNeedsDisplay(); } -void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay) +void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay, bool fadeOut) { if (pageOverlay != m_pageOverlay) return; + if (fadeOut) { + m_pageOverlay->startFadeOutAnimation(); + return; + } + m_pageOverlay->setPage(0); m_pageOverlay = nullptr; @@ -804,35 +869,6 @@ WebContextMenu* WebPage::contextMenu() return m_contextMenu.get(); } -void WebPage::getLocationAndLengthFromRange(Range* range, uint64_t& location, uint64_t& length) -{ - location = notFound; - length = 0; - - if (!range || !range->startContainer()) - return; - - Element* selectionRoot = range->ownerDocument()->frame()->selection()->rootEditableElement(); - Element* scope = selectionRoot ? selectionRoot : range->ownerDocument()->documentElement(); - - // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view - // that is not inside the current editable region. These checks ensure we don't produce - // potentially invalid data when responding to such requests. - if (range->startContainer() != scope && !range->startContainer()->isDescendantOf(scope)) - return; - if (range->endContainer() != scope && !range->endContainer()->isDescendantOf(scope)) - return; - - RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); - ASSERT(testRange->startContainer() == scope); - location = TextIterator::rangeLength(testRange.get()); - - ExceptionCode ec; - testRange->setEnd(range->endContainer(), range->endOffset(), ec); - ASSERT(testRange->startContainer() == scope); - length = TextIterator::rangeLength(testRange.get()) - location; -} - // Events static const WebEvent* g_currentEvent = 0; @@ -913,6 +949,12 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, Page* page) void WebPage::mouseEvent(const WebMouseEvent& mouseEvent) { + // Don't try to handle any pending mouse events if a context menu is showing. + if (m_isShowingContextMenu) { + send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(mouseEvent.type()), false)); + return; + } + bool handled = false; if (m_pageOverlay) { @@ -962,6 +1004,7 @@ void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent) CurrentEvent currentEvent(keyboardEvent); bool handled = handleKeyEvent(keyboardEvent, m_page.get()); + // FIXME: Platform default behaviors should be performed during normal DOM event dispatch (in most cases, in default keydown event handler). if (!handled) handled = performDefaultBehaviorForKeyEvent(keyboardEvent); @@ -1142,8 +1185,9 @@ void WebPage::viewWillEndLiveResize() void WebPage::setFocused(bool isFocused) { - if (!isFocused) + if (!isFocused && m_page->focusController()->focusedOrMainFrame()->editor()->behavior().shouldClearSelectionWhenLosingWebPageFocus()) m_page->focusController()->focusedOrMainFrame()->selection()->clear(); + m_page->focusController()->setFocused(isFocused); } @@ -1240,7 +1284,8 @@ void WebPage::runJavaScriptInMainFrame(const String& script, uint64_t callbackID JSLock lock(SilenceAssertionsOnly); if (JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue()) { - if ((serializedResultValue = SerializedScriptValue::create(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec(), resultValue))) + if ((serializedResultValue = SerializedScriptValue::create(m_mainFrame->jsContext(), + toRef(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec(), resultValue), 0))) dataReference = CoreIPC::DataReference(serializedResultValue->data().data(), serializedResultValue->data().size()); } @@ -1360,6 +1405,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setJavaScriptEnabled(store.getBoolValueForKey(WebPreferencesKey::javaScriptEnabledKey())); settings->setLoadsImagesAutomatically(store.getBoolValueForKey(WebPreferencesKey::loadsImagesAutomaticallyKey())); + settings->setLoadsSiteIconsIgnoringImageLoadingSetting(store.getBoolValueForKey(WebPreferencesKey::loadsSiteIconsIgnoringImageLoadingPreferenceKey())); settings->setPluginsEnabled(store.getBoolValueForKey(WebPreferencesKey::pluginsEnabledKey())); settings->setJavaEnabled(store.getBoolValueForKey(WebPreferencesKey::javaEnabledKey())); settings->setOfflineWebApplicationCacheEnabled(store.getBoolValueForKey(WebPreferencesKey::offlineWebApplicationCacheEnabledKey())); @@ -1391,17 +1437,11 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) settings->setMinimumLogicalFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumLogicalFontSizeKey())); settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey())); settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey())); + settings->setEditableLinkBehavior(static_cast<WebCore::EditableLinkBehavior>(store.getUInt32ValueForKey(WebPreferencesKey::editableLinkBehaviorKey()))); -#if PLATFORM(WIN) - // Temporarily turn off accelerated compositing until we have a good solution for rendering it. - settings->setAcceleratedCompositingEnabled(false); - settings->setAcceleratedDrawingEnabled(false); - settings->setCanvasUsesAcceleratedDrawing(false); -#else - settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey())); - settings->setAcceleratedDrawingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedDrawingEnabledKey())); - settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey())); -#endif + settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey()) && LayerTreeHost::supportsAcceleratedCompositing()); + settings->setAcceleratedDrawingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedDrawingEnabledKey()) && LayerTreeHost::supportsAcceleratedCompositing()); + settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey()) && LayerTreeHost::supportsAcceleratedCompositing()); settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey())); settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey())); settings->setWebGLEnabled(store.getBoolValueForKey(WebPreferencesKey::webGLEnabledKey())); @@ -1441,7 +1481,7 @@ WebFullScreenManager* WebPage::fullScreenManager() } #endif -#if !PLATFORM(MAC) +#if !PLATFORM(GTK) && !PLATFORM(MAC) bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt) { Node* node = evt->target()->toNode(); @@ -1504,7 +1544,7 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli } } #else -void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags) +void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle) { if (!m_page) { send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone)); @@ -1525,10 +1565,23 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli m_page->dragController()->dragExited(&dragData); break; - case DragControllerActionPerformDrag: + case DragControllerActionPerformDrag: { + ASSERT(!m_pendingDropSandboxExtension); + + m_pendingDropSandboxExtension = SandboxExtension::create(sandboxExtensionHandle); + m_page->dragController()->performDrag(&dragData); + + // If we started loading a local file, the sandbox extension tracker would have adopted this + // pending drop sandbox extension. If not, we'll play it safe and invalidate it. + if (m_pendingDropSandboxExtension) { + m_pendingDropSandboxExtension->invalidate(); + m_pendingDropSandboxExtension = nullptr; + } + break; - + } + default: ASSERT_NOT_REACHED(); } @@ -1550,6 +1603,11 @@ void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint glob m_page->mainFrame()->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation); } +void WebPage::willPerformLoadDragDestinationAction() +{ + m_sandboxExtensionTracker.willPerformLoadDragDestinationAction(m_pendingDropSandboxExtension.release()); +} + WebEditCommand* WebPage::webEditCommand(uint64_t commandID) { return m_editCommandMap.get(commandID).get(); @@ -1734,8 +1792,9 @@ void WebPage::didChangeScrollOffsetForMainFrame() Frame* frame = m_page->mainFrame(); IntPoint scrollPosition = frame->view()->scrollPosition(); IntPoint maximumScrollPosition = frame->view()->maximumScrollPosition(); + IntPoint minimumScrollPosition = frame->view()->minimumScrollPosition(); - bool isPinnedToLeftSide = (scrollPosition.x() <= 0); + bool isPinnedToLeftSide = (scrollPosition.x() <= minimumScrollPosition.x()); bool isPinnedToRightSide = (scrollPosition.x() >= maximumScrollPosition.x()); if (isPinnedToLeftSide != m_cachedMainFrameIsPinnedToLeftSide || isPinnedToRightSide != m_cachedMainFrameIsPinnedToRightSide) { @@ -1877,18 +1936,28 @@ void WebPage::SandboxExtensionTracker::invalidate() } } +void WebPage::SandboxExtensionTracker::willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension) +{ + setPendingProvisionalSandboxExtension(pendingDropSandboxExtension); +} + void WebPage::SandboxExtensionTracker::beginLoad(WebFrame* frame, const SandboxExtension::Handle& handle) { ASSERT(frame->isMainFrame()); + setPendingProvisionalSandboxExtension(SandboxExtension::create(handle)); +} + +void WebPage::SandboxExtensionTracker::setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension> 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); + + m_pendingProvisionalSandboxExtension = pendingProvisionalSandboxExtension; } static bool shouldReuseCommittedSandboxExtension(WebFrame* frame) @@ -1907,8 +1976,7 @@ static bool shouldReuseCommittedSandboxExtension(WebFrame* frame) if (!documentLoader || !provisionalDocumentLoader) return false; - if (documentLoader->url().isLocalFile() && provisionalDocumentLoader->url().isLocalFile() - && provisionalDocumentLoader->triggeringAction().type() == NavigationTypeLinkClicked) + if (documentLoader->url().isLocalFile() && provisionalDocumentLoader->url().isLocalFile()) return true; return false; @@ -1953,7 +2021,6 @@ void WebPage::SandboxExtensionTracker::didFailProvisionalLoad(WebFrame* frame) if (!frame->isMainFrame()) return; - ASSERT(!m_pendingProvisionalSandboxExtension); if (!m_provisionalSandboxExtension) return; @@ -2058,7 +2125,7 @@ void WebPage::drawRectToPDF(uint64_t frameID, const WebCore::IntRect& rect, uint if (coreFrame) { ASSERT(coreFrame->document()->printing()); -#if PLATFORM(CG) +#if USE(CG) // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data. RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get())); @@ -2090,7 +2157,7 @@ void WebPage::drawPagesToPDF(uint64_t frameID, uint32_t first, uint32_t count, u if (coreFrame) { ASSERT(coreFrame->document()->printing()); -#if PLATFORM(CG) +#if USE(CG) // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data. RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get())); @@ -2159,4 +2226,19 @@ void WebPage::handleCorrectionPanelResult(const String& result) } #endif +void WebPage::simulateMouseDown(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, double time) +{ + mouseEvent(WebMouseEvent(WebMouseEvent::MouseDown, static_cast<WebMouseEvent::Button>(button), position, position, 0, 0, 0, clickCount, static_cast<WebMouseEvent::Modifiers>(modifiers), time)); +} + +void WebPage::simulateMouseUp(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, double time) +{ + mouseEvent(WebMouseEvent(WebMouseEvent::MouseUp, static_cast<WebMouseEvent::Button>(button), position, position, 0, 0, 0, clickCount, static_cast<WebMouseEvent::Modifiers>(modifiers), time)); +} + +void WebPage::simulateMouseMotion(WebCore::IntPoint position, double time) +{ + mouseEvent(WebMouseEvent(WebMouseEvent::MouseMove, WebMouseEvent::NoButton, position, position, 0, 0, 0, 0, WebMouseEvent::Modifiers(), time)); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 8e4e71c..7828b45 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -34,6 +34,7 @@ #include "InjectedBundlePageContextMenuClient.h" #include "InjectedBundlePageEditorClient.h" #include "InjectedBundlePageFormClient.h" +#include "InjectedBundlePageFullScreenClient.h" #include "InjectedBundlePageLoaderClient.h" #include "InjectedBundlePagePolicyClient.h" #include "InjectedBundlePageResourceLoadClient.h" @@ -81,6 +82,7 @@ namespace WebCore { class ResourceRequest; class SharedBuffer; class VisibleSelection; + struct KeypressCommand; } namespace WebKit { @@ -103,6 +105,8 @@ class WebOpenPanelResultListener; class WebPageGroupProxy; class WebPopupMenu; class WebWheelEvent; +struct AttributedString; +struct EditorState; struct PrintInfo; struct WebPageCreationParameters; struct WebPreferencesStore; @@ -159,9 +163,12 @@ public: void layoutIfNeeded(); // -- Called from WebCore clients. -#if !PLATFORM(MAC) +#if PLATFORM(MAC) + bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*, bool saveCommands); +#elif !PLATFORM(GTK) bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*); #endif + void show(); String userAgent() const { return m_userAgent; } WebCore::IntRect windowResizerRect() const; @@ -189,6 +196,9 @@ public: void initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient*); void initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient*); void initializeInjectedBundleUIClient(WKBundlePageUIClient*); +#if ENABLE(FULLSCREEN_API) + void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient*); +#endif InjectedBundlePageContextMenuClient& injectedBundleContextMenuClient() { return m_contextMenuClient; } InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; } @@ -197,12 +207,17 @@ public: InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; } InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; } InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; } +#if ENABLE(FULLSCREEN_API) + InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; } +#endif bool findStringFromInjectedBundle(const String&, FindOptions); WebFrame* mainFrame() const { return m_mainFrame.get(); } PassRefPtr<Plugin> createPlugin(const Plugin::Parameters&); + EditorState editorState() const; + String renderTreeExternalRepresentation() const; void executeEditingCommand(const String& commandName, const String& argument); bool isEditingCommandEnabled(const String& commandName); @@ -240,14 +255,13 @@ public: bool windowIsVisible() const { return m_windowIsVisible; } const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; } const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; } - bool interceptEditingKeyboardEvent(WebCore::KeyboardEvent*, bool); #elif PLATFORM(WIN) HWND nativeWindow() const { return m_nativeWindow; } #endif bool windowIsFocused() const; void installPageOverlay(PassRefPtr<PageOverlay>); - void uninstallPageOverlay(PageOverlay*); + void uninstallPageOverlay(PageOverlay*, bool fadeOut); bool hasPageOverlay() const { return m_pageOverlay; } WebCore::IntRect windowToScreen(const WebCore::IntRect&); @@ -285,10 +299,14 @@ public: void invalidate(); void beginLoad(WebFrame*, const SandboxExtension::Handle& handle); + void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension); void didStartProvisionalLoad(WebFrame*); void didCommitProvisionalLoad(WebFrame*); void didFailProvisionalLoad(WebFrame*); + private: + void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>); + RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension; RefPtr<SandboxExtension> m_provisionalSandboxExtension; RefPtr<SandboxExtension> m_committedSandboxExtension; @@ -296,8 +314,6 @@ public: SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; } - static void getLocationAndLengthFromRange(WebCore::Range*, uint64_t& location, uint64_t& length); - #if PLATFORM(MAC) void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken); AccessibilityWebPageObject* accessibilityRemoteObject(); @@ -305,16 +321,29 @@ public: void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput); + void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState); + void confirmComposition(EditorState& newState); + void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState); void getMarkedRange(uint64_t& location, uint64_t& length); + void getSelectedRange(uint64_t& location, uint64_t& length); + void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&); void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result); void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect); + void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState); void writeSelectionToPasteboard(const WTF::String& pasteboardName, const WTF::Vector<WTF::String>& pasteboardTypes, bool& result); void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result); + void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result); + void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result); + bool performNonEditingBehaviorForSelector(const String&); #elif PLATFORM(WIN) void confirmComposition(const String& compositionString); void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition); void firstRectForCharacterInSelectedRange(const uint64_t characterPosition, WebCore::IntRect& resultRect); void getSelectedText(WTF::String&); + + void gestureWillBegin(const WebCore::IntPoint&, bool& canBeginPanning); + void gestureDidScroll(const WebCore::IntSize&); + void gestureDidEnd(); #endif // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require @@ -335,10 +364,12 @@ public: #if PLATFORM(WIN) void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WebCore::DragDataMap&, uint32_t flags); #else - void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags); + void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&); #endif void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation); + void willPerformLoadDragDestinationAction(); + void beginPrinting(uint64_t frameID, const PrintInfo&); void endPrinting(); void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID); @@ -365,6 +396,9 @@ public: void forceRepaintWithoutCallback(); + void unmarkAllMisspellings(); + void unmarkAllBadGrammar(); + #if PLATFORM(MAC) void setDragSource(NSObject *); #endif @@ -373,6 +407,12 @@ public: void handleCorrectionPanelResult(const String&); #endif + void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time); + void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time); + void simulateMouseMotion(WebCore::IntPoint, double time); + + void contextMenuShowing() { m_isShowingContextMenu = true; } + private: WebPage(uint64_t pageID, const WebPageCreationParameters&); @@ -383,9 +423,15 @@ private: void didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); CoreIPC::SyncReplyMode didReceiveSyncWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); +#if !PLATFORM(MAC) static const char* interpretKeyEvent(const WebCore::KeyboardEvent*); +#endif bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&); +#if PLATFORM(MAC) + bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*); +#endif + String sourceForFrame(WebFrame*); void loadData(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::KURL& baseURL, const WebCore::KURL& failingURL); @@ -399,6 +445,7 @@ private: void loadHTMLString(const String& htmlString, const String& baseURL); void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL); void loadPlainTextString(const String&); + void linkClicked(const String& url, const WebMouseEvent&); void reload(bool reloadFromOrigin); void goForward(uint64_t, const SandboxExtension::Handle&); void goBack(uint64_t, const SandboxExtension::Handle&); @@ -420,6 +467,7 @@ private: #if ENABLE(TOUCH_EVENTS) void touchEvent(const WebTouchEvent&); #endif + void contextMenuHidden() { m_isShowingContextMenu = false; } static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity); static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity); @@ -486,8 +534,6 @@ private: void advanceToNextMisspelling(bool startBeforeSelection); void changeSpellingToWord(const String& word); - void unmarkAllMisspellings(); - void unmarkAllBadGrammar(); #if PLATFORM(MAC) void uppercaseWord(); void lowercaseWord(); @@ -545,9 +591,14 @@ private: RetainPtr<AccessibilityWebPageObject> m_mockAccessibilityElement; RetainPtr<NSObject> m_dragSource; + + WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted; + #elif PLATFORM(WIN) // Our view's window (in the UI process). HWND m_nativeWindow; + + RefPtr<WebCore::Node> m_gestureTargetNode; #endif HashMap<uint64_t, RefPtr<WebEditCommand> > m_editCommandMap; @@ -561,6 +612,9 @@ private: InjectedBundlePagePolicyClient m_policyClient; InjectedBundlePageResourceLoadClient m_resourceLoadClient; InjectedBundlePageUIClient m_uiClient; +#if ENABLE(FULLSCREEN_API) + InjectedBundlePageFullScreenClient m_fullScreenClient; +#endif #if ENABLE(TILED_BACKING_STORE) WebCore::IntSize m_resizesToContentsLayoutSize; @@ -585,6 +639,8 @@ private: SandboxExtensionTracker m_sandboxExtensionTracker; uint64_t m_pageID; + RefPtr<SandboxExtension> m_pendingDropSandboxExtension; + bool m_canRunBeforeUnloadConfirmPanel; bool m_canRunModal; @@ -594,6 +650,12 @@ private: bool m_cachedMainFrameIsPinnedToLeftSide; bool m_cachedMainFrameIsPinnedToRightSide; + + bool m_isShowingContextMenu; + +#if PLATFORM(WIN) + bool m_gestureReachedScrollingLimit; +#endif }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in index 69bd54d..673e8d6 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in @@ -42,6 +42,8 @@ messages -> WebPage { TouchEvent(WebKit::WebTouchEvent event) #endif + ContextMenuHidden() + ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity) GoBack(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle) @@ -52,6 +54,7 @@ messages -> WebPage { LoadPlainTextString(WTF::String string) LoadURL(WTF::String url, WebKit::SandboxExtension::Handle sandboxExtensionHandle) LoadURLRequest(WebCore::ResourceRequest request, WebKit::SandboxExtension::Handle sandboxExtensionHandle) + LinkClicked(WTF::String url, WebKit::WebMouseEvent event) Reload(bool reloadFromOrigin) StopLoading() @@ -119,7 +122,7 @@ messages -> WebPage { PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, HashMap<UINT,Vector<String>> dataMap, uint32_t flags) #endif #if !PLATFORM(WIN) - PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags) + PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags, WebKit::SandboxExtension::Handle sandboxExtensionHandle) #endif DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation) @@ -140,8 +143,6 @@ messages -> WebPage { # Spelling and grammar. AdvanceToNextMisspelling(bool startBeforeSelection) ChangeSpellingToWord(WTF::String word) - UnmarkAllMisspellings() - UnmarkAllBadGrammar() #if PLATFORM(MAC) UppercaseWord(); LowercaseWord(); @@ -179,18 +180,33 @@ messages -> WebPage { SetWindowIsVisible(bool windowIsVisible) WindowAndViewFramesChanged(WebCore::IntRect windowFrameInScreenCoordinates, WebCore::IntRect viewFrameInWindowCoordinates, WebCore::IntPoint accessibilityViewCoordinates) - GetMarkedRange() -> (uint64_t location, uint64_t length) - CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result) - FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect) RegisterUIProcessAccessibilityTokens(CoreIPC::DataReference elemenToken, CoreIPC::DataReference windowToken) WriteSelectionToPasteboard(WTF::String pasteboardName, WTF::Vector<WTF::String> pasteboardTypes) -> (bool result) ReadSelectionFromPasteboard(WTF::String pasteboardName) -> (bool result) + + # Text input. + SetComposition(WTF::String text, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (WebKit::EditorState newState) + ConfirmComposition() -> (WebKit::EditorState newState) + InsertText(WTF::String text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (bool handled, WebKit::EditorState newState) + GetMarkedRange() -> (uint64_t location, uint64_t length) + GetSelectedRange() -> (uint64_t location, uint64_t length) + GetAttributedSubstringFromRange(uint64_t location, uint64_t length) -> (WebKit::AttributedString result) + CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result) + FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect) + ExecuteKeypressCommands(Vector<WebCore::KeypressCommand> savedCommands) -> (bool handled, WebKit::EditorState newState) + ShouldDelayWindowOrderingEvent(WebKit::WebMouseEvent event) -> (bool result) + AcceptsFirstMouse(int eventNumber, WebKit::WebMouseEvent event) -> (bool result) #endif #if PLATFORM(WIN) + // FIXME: Unify with Mac counterparts. ConfirmComposition(WTF::String compositionString) SetComposition(WTF::String compositionString, WTF::Vector<WebCore::CompositionUnderline> underlines, uint64_t cursorPosition) FirstRectForCharacterInSelectedRange(uint64_t characterPosition) -> (WebCore::IntRect resultRect) GetSelectedText() -> (WTF::String text) + + GestureWillBegin(WebCore::IntPoint point) -> (bool canBeginPanning) + GestureDidScroll(WebCore::IntSize size) + GestureDidEnd() #endif #if PLATFORM(QT) FindZoomableAreaForPoint(WebCore::IntPoint point) diff --git a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h index 55cf629..91e6c5c 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h @@ -42,6 +42,7 @@ public: const String& identifier() const { return m_data.identifer; } uint64_t pageGroupID() const { return m_data.pageGroupID; } bool isVisibleToInjectedBundle() const { return m_data.visibleToInjectedBundle; } + bool isVisibleToHistoryClient() const { return m_data.visibleToHistoryClient; } private: WebPageGroupProxy(const WebPageGroupData& data) diff --git a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp index 2460607..42a2dc9 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp @@ -31,39 +31,41 @@ #include "WebProcess.h" #include <WebCore/Frame.h> #include <WebCore/FrameView.h> +#include <WebCore/GraphicsLayerCA.h> #include <WebCore/Page.h> +#include <WebCore/PlatformCALayer.h> #include <WebCore/Settings.h> using namespace WebCore; namespace WebKit { -PassRefPtr<LayerTreeHostCA> LayerTreeHostCA::create(WebPage* webPage) -{ - return adoptRef(new LayerTreeHostCA(webPage)); -} - LayerTreeHostCA::LayerTreeHostCA(WebPage* webPage) : LayerTreeHost(webPage) , m_isValid(true) , m_notifyAfterScheduledLayerFlush(false) { +} +void LayerTreeHostCA::initialize() +{ // Create a root layer. m_rootLayer = GraphicsLayer::create(this); #ifndef NDEBUG m_rootLayer->setName("LayerTreeHost root layer"); #endif m_rootLayer->setDrawsContent(false); - m_rootLayer->setSize(webPage->size()); + m_rootLayer->setSize(m_webPage->size()); + static_cast<GraphicsLayerCA*>(m_rootLayer.get())->platformCALayer()->setGeometryFlipped(true); m_nonCompositedContentLayer = GraphicsLayer::create(this); + static_cast<GraphicsLayerCA*>(m_nonCompositedContentLayer.get())->setAllowTiledLayer(false); #ifndef NDEBUG m_nonCompositedContentLayer->setName("LayerTreeHost non-composited content"); #endif m_nonCompositedContentLayer->setDrawsContent(true); m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground()); - m_nonCompositedContentLayer->setSize(webPage->size()); + m_nonCompositedContentLayer->setSize(m_webPage->size()); if (m_webPage->corePage()->settings()->acceleratedDrawingEnabled()) m_nonCompositedContentLayer->setAcceleratesDrawing(true); @@ -72,7 +74,7 @@ LayerTreeHostCA::LayerTreeHostCA(WebPage* webPage) if (m_webPage->hasPageOverlay()) createPageOverlayLayer(); - platformInitialize(); + platformInitialize(m_layerTreeContext); scheduleLayerFlush(); } @@ -81,10 +83,6 @@ LayerTreeHostCA::~LayerTreeHostCA() { ASSERT(!m_isValid); ASSERT(!m_rootLayer); -#if PLATFORM(MAC) - ASSERT(!m_flushPendingLayerChangesRunLoopObserver); - ASSERT(!m_remoteLayerClient); -#endif } const LayerTreeContext& LayerTreeHostCA::layerTreeContext() @@ -109,7 +107,6 @@ void LayerTreeHostCA::setRootCompositingLayer(GraphicsLayer* graphicsLayer) void LayerTreeHostCA::invalidate() { ASSERT(m_isValid); - platformInvalidate(); m_rootLayer = nullptr; m_isValid = false; } @@ -138,16 +135,12 @@ void LayerTreeHostCA::sizeDidChange(const IntSize& newSize) scheduleLayerFlush(); flushPendingLayerChanges(); - - platformSizeDidChange(); } void LayerTreeHostCA::forceRepaint() { scheduleLayerFlush(); flushPendingLayerChanges(); - - platformForceRepaint(); } void LayerTreeHostCA::didInstallPageOverlay() @@ -218,8 +211,6 @@ void LayerTreeHostCA::performScheduledLayerFlush() void LayerTreeHostCA::didPerformScheduledLayerFlush() { - platformDidPerformScheduledLayerFlush(); - if (m_notifyAfterScheduledLayerFlush) { // Let the drawing area know that we've done a flush of the layer changes. static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers(); diff --git a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h index ba4e33a..3a62d15 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h +++ b/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h @@ -31,35 +31,36 @@ #include <WebCore/GraphicsLayerClient.h> #include <wtf/OwnPtr.h> -#if PLATFORM(MAC) -#include <wtf/RetainPtr.h> -#endif - -#if PLATFORM(MAC) -typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef; -#endif - namespace WebKit { class LayerTreeHostCA : public LayerTreeHost, WebCore::GraphicsLayerClient { public: - static PassRefPtr<LayerTreeHostCA> create(WebPage*); - ~LayerTreeHostCA(); + virtual ~LayerTreeHostCA(); -private: +protected: explicit LayerTreeHostCA(WebPage*); + WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); } + + void initialize(); + void performScheduledLayerFlush(); + + // LayerTreeHost. + virtual void invalidate(); + virtual void sizeDidChange(const WebCore::IntSize& newSize); + virtual void forceRepaint(); + + // LayerTreeHostCA + virtual void didPerformScheduledLayerFlush(); + +private: // LayerTreeHost. virtual const LayerTreeContext& layerTreeContext(); - virtual void scheduleLayerFlush(); virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool); virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); - virtual void invalidate(); virtual void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&); virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); - virtual void sizeDidChange(const WebCore::IntSize& newSize); - virtual void forceRepaint(); virtual void didInstallPageOverlay(); virtual void didUninstallPageOverlay(); @@ -72,23 +73,14 @@ private: virtual bool showDebugBorders() const; virtual bool showRepaintCounter() const; - void platformInitialize(); - void platformInvalidate(); - void platformSizeDidChange(); - void platformForceRepaint(); + // LayerTreeHostCA + virtual void platformInitialize(LayerTreeContext&) = 0; - void performScheduledLayerFlush(); - void didPerformScheduledLayerFlush(); - void platformDidPerformScheduledLayerFlush(); bool flushPendingLayerChanges(); void createPageOverlayLayer(); void destroyPageOverlayLayer(); -#if PLATFORM(MAC) - static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*); -#endif - // The context for this layer tree. LayerTreeContext m_layerTreeContext; @@ -107,11 +99,6 @@ private: // The page overlay layer. Will be null if there's no page overlay. OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer; - -#if PLATFORM(MAC) - RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; - RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver; -#endif }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h new file mode 100644 index 0000000..e3a0160 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h @@ -0,0 +1,64 @@ +/* + * 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 LayerTreeHostCAMac_h +#define LayerTreeHostCAMac_h + +#include "LayerTreeHostCA.h" +#include <wtf/RetainPtr.h> + +typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef; + +namespace WebKit { + +class LayerTreeHostCAMac : public LayerTreeHostCA { +public: + static PassRefPtr<LayerTreeHostCAMac> create(WebPage*); + virtual ~LayerTreeHostCAMac(); + +private: + explicit LayerTreeHostCAMac(WebPage*); + + // LayerTreeHost. + virtual void scheduleLayerFlush(); + virtual void invalidate(); + virtual void sizeDidChange(const WebCore::IntSize& newSize); + virtual void forceRepaint(); + virtual void pauseRendering(); + virtual void resumeRendering(); + + // LayerTreeHostCA + virtual void platformInitialize(LayerTreeContext&); + virtual void didPerformScheduledLayerFlush(); + + static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*); + + RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient; + RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver; +}; + +} // namespace WebKit + +#endif // LayerTreeHostCAMac_h diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm index 50776d7..69cfa44 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm @@ -24,32 +24,50 @@ */ #import "config.h" -#import "LayerTreeHostCA.h" +#import "LayerTreeHostCAMac.h" #import "WebProcess.h" #import <QuartzCore/CATransaction.h> #import <WebCore/GraphicsLayer.h> #import <WebKitSystemInterface.h> +using namespace WebCore; + @interface CATransaction (Details) + (void)synchronize; @end namespace WebKit { -void LayerTreeHostCA::platformInitialize() +PassRefPtr<LayerTreeHostCAMac> LayerTreeHostCAMac::create(WebPage* webPage) +{ + RefPtr<LayerTreeHostCAMac> host = adoptRef(new LayerTreeHostCAMac(webPage)); + host->initialize(); + return host.release(); +} + +LayerTreeHostCAMac::LayerTreeHostCAMac(WebPage* webPage) + : LayerTreeHostCA(webPage) +{ +} + +LayerTreeHostCAMac::~LayerTreeHostCAMac() +{ + ASSERT(!m_flushPendingLayerChangesRunLoopObserver); + ASSERT(!m_remoteLayerClient); +} + +void LayerTreeHostCAMac::platformInitialize(LayerTreeContext& layerTreeContext) { mach_port_t serverPort = WebProcess::shared().compositingRenderServerPort(); m_remoteLayerClient = WKCARemoteLayerClientMakeWithServerPort(serverPort); - [m_rootLayer->platformLayer() setGeometryFlipped:YES]; + WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), rootLayer()->platformLayer()); - WKCARemoteLayerClientSetLayer(m_remoteLayerClient.get(), m_rootLayer->platformLayer()); - - m_layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); + layerTreeContext.contextID = WKCARemoteLayerClientGetClientId(m_remoteLayerClient.get()); } -void LayerTreeHostCA::scheduleLayerFlush() +void LayerTreeHostCAMac::scheduleLayerFlush() { CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent(); @@ -67,7 +85,7 @@ void LayerTreeHostCA::scheduleLayerFlush() CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes); } -void LayerTreeHostCA::platformInvalidate() +void LayerTreeHostCAMac::invalidate() { if (m_flushPendingLayerChangesRunLoopObserver) { CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get()); @@ -76,34 +94,54 @@ void LayerTreeHostCA::platformInvalidate() WKCARemoteLayerClientInvalidate(m_remoteLayerClient.get()); m_remoteLayerClient = nullptr; + + LayerTreeHostCA::invalidate(); } -void LayerTreeHostCA::platformSizeDidChange() +void LayerTreeHostCAMac::sizeDidChange(const IntSize& newSize) { + LayerTreeHostCA::sizeDidChange(newSize); [CATransaction flush]; [CATransaction synchronize]; } -void LayerTreeHostCA::platformForceRepaint() +void LayerTreeHostCAMac::forceRepaint() { + LayerTreeHostCA::forceRepaint(); [CATransaction flush]; [CATransaction synchronize]; -} +} + +void LayerTreeHostCAMac::pauseRendering() +{ + CALayer* root = rootLayer()->platformLayer(); + [root setValue:(id)kCFBooleanTrue forKey:@"NSCAViewRenderPaused"]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidPauseNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]]; +} -void LayerTreeHostCA::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context) +void LayerTreeHostCAMac::resumeRendering() +{ + CALayer* root = rootLayer()->platformLayer(); + [root setValue:(id)kCFBooleanFalse forKey:@"NSCAViewRenderPaused"]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]]; +} + +void LayerTreeHostCAMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context) { // This gets called outside of the normal event loop so wrap in an autorelease pool NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - static_cast<LayerTreeHostCA*>(context)->performScheduledLayerFlush(); + static_cast<LayerTreeHostCAMac*>(context)->performScheduledLayerFlush(); [pool drain]; } -void LayerTreeHostCA::platformDidPerformScheduledLayerFlush() +void LayerTreeHostCAMac::didPerformScheduledLayerFlush() { // We successfully flushed the pending layer changes, remove the run loop observer. ASSERT(m_flushPendingLayerChangesRunLoopObserver); CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get()); m_flushPendingLayerChangesRunLoopObserver = 0; + + LayerTreeHostCA::didPerformScheduledLayerFlush(); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp b/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp index 81db03e..699a1fe 100644 --- a/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp +++ b/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.cpp @@ -24,46 +24,276 @@ */ #include "config.h" -#include "LayerTreeHostCA.h" +#include "LayerTreeHostCAWin.h" -#include <WebCore/NotImplemented.h> +#if HAVE(WKQCA) + +#include "DrawingAreaImpl.h" +#include "ShareableBitmap.h" +#include "UpdateInfo.h" +#include "WebPage.h" +#include <WebCore/GraphicsLayerCA.h> +#include <WebCore/LayerChangesFlusher.h> +#include <WebCore/PlatformCALayer.h> +#include <WebCore/WebCoreInstanceHandle.h> +#include <WebKitQuartzCoreAdditions/WKCACFImage.h> +#include <WebKitQuartzCoreAdditions/WKCACFView.h> +#include <wtf/CurrentTime.h> +#include <wtf/Threading.h> + +#ifdef DEBUG_ALL +#pragma comment(lib, "WebKitQuartzCoreAdditions_debug") +#else +#pragma comment(lib, "WebKitQuartzCoreAdditions") +#endif + +using namespace WebCore; namespace WebKit { -void LayerTreeHostCA::platformInitialize() +static HWND dummyWindow; +static LPCWSTR dummyWindowClass = L"LayerTreeHostCAWindowClass"; +static size_t validLayerTreeHostCount; + +static void registerDummyWindowClass() +{ + static bool didRegister; + if (didRegister) + return; + didRegister = true; + + WNDCLASSW wndClass = {0}; + wndClass.lpszClassName = dummyWindowClass; + wndClass.lpfnWndProc = ::DefWindowProcW; + wndClass.hInstance = instanceHandle(); + + ::RegisterClassW(&wndClass); +} + +// This window is never shown. It is only needed so that D3D can determine the display mode, etc. +static HWND createDummyWindow() { - // FIXME: <http://webkit.org/b/45567> Implement this! - notImplemented(); + registerDummyWindowClass(); + return ::CreateWindowW(dummyWindowClass, 0, WS_POPUP, 0, 0, 10, 10, 0, 0, instanceHandle(), 0); } -void LayerTreeHostCA::scheduleLayerFlush() +bool LayerTreeHostCAWin::supportsAcceleratedCompositing() { - // FIXME: <http://webkit.org/b/45567> Implement this! - notImplemented(); + static bool initialized; + static bool supportsAcceleratedCompositing; + if (initialized) + return supportsAcceleratedCompositing; + initialized = true; + + ASSERT(!dummyWindow); + dummyWindow = createDummyWindow(); + RetainPtr<WKCACFViewRef> view(AdoptCF, WKCACFViewCreate(kWKCACFViewDrawingDestinationImage)); + CGRect fakeBounds = CGRectMake(0, 0, 10, 10); + WKCACFViewUpdate(view.get(), dummyWindow, &fakeBounds); + + supportsAcceleratedCompositing = WKCACFViewCanDraw(view.get()); + + WKCACFViewUpdate(view.get(), 0, 0); + ::DestroyWindow(dummyWindow); + dummyWindow = 0; + + return supportsAcceleratedCompositing; } -void LayerTreeHostCA::platformInvalidate() +PassRefPtr<LayerTreeHostCAWin> LayerTreeHostCAWin::create(WebPage* webPage) { - // FIXME: <http://webkit.org/b/45567> Implement this! - notImplemented(); + RefPtr<LayerTreeHostCAWin> host = adoptRef(new LayerTreeHostCAWin(webPage)); + host->initialize(); + return host.release(); } -void LayerTreeHostCA::platformSizeDidChange() +LayerTreeHostCAWin::LayerTreeHostCAWin(WebPage* webPage) + : LayerTreeHostCA(webPage) + , m_isFlushingLayerChanges(false) + , m_nextDisplayTime(0) { - // FIXME: <http://webkit.org/b/45567> Implement this! - notImplemented(); } -void LayerTreeHostCA::platformForceRepaint() +LayerTreeHostCAWin::~LayerTreeHostCAWin() { - // FIXME: <http://webkit.org/b/45567> Implement this! - notImplemented(); } -void LayerTreeHostCA::platformDidPerformScheduledLayerFlush() +void LayerTreeHostCAWin::platformInitialize(LayerTreeContext&) { - // FIXME: <http://webkit.org/b/45567> Implement this! - notImplemented(); + ++validLayerTreeHostCount; + if (!dummyWindow) + dummyWindow = createDummyWindow(); + + m_view.adoptCF(WKCACFViewCreate(kWKCACFViewDrawingDestinationImage)); + WKCACFViewSetContextUserData(m_view.get(), static_cast<AbstractCACFLayerTreeHost*>(this)); + WKCACFViewSetLayer(m_view.get(), rootLayer()->platformLayer()); + WKCACFViewSetContextDidChangeCallback(m_view.get(), contextDidChangeCallback, this); + + CGRect bounds = m_webPage->bounds(); + WKCACFViewUpdate(m_view.get(), dummyWindow, &bounds); +} + +void LayerTreeHostCAWin::invalidate() +{ + LayerChangesFlusher::shared().cancelPendingFlush(this); + + WKCACFViewUpdate(m_view.get(), 0, 0); + WKCACFViewSetContextUserData(m_view.get(), 0); + WKCACFViewSetLayer(m_view.get(), 0); + WKCACFViewSetContextDidChangeCallback(m_view.get(), 0, 0); + + LayerTreeHostCA::invalidate(); + + if (--validLayerTreeHostCount) + return; + ::DestroyWindow(dummyWindow); + dummyWindow = 0; +} + +void LayerTreeHostCAWin::scheduleLayerFlush() +{ + LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this); +} + +bool LayerTreeHostCAWin::participatesInDisplay() +{ + return true; +} + +bool LayerTreeHostCAWin::needsDisplay() +{ + return timeUntilNextDisplay() <= 0; +} + +double LayerTreeHostCAWin::timeUntilNextDisplay() +{ + return m_nextDisplayTime - currentTime(); +} + +static IntSize size(WKCACFImageRef image) +{ + return IntSize(WKCACFImageGetWidth(image), WKCACFImageGetHeight(image)); +} + +static PassRefPtr<ShareableBitmap> toShareableBitmap(WKCACFImageRef image) +{ + size_t fileMappingSize; + HANDLE mapping = WKCACFImageCopyFileMapping(image, &fileMappingSize); + if (!mapping) + return 0; + + RefPtr<SharedMemory> sharedMemory = SharedMemory::adopt(mapping, fileMappingSize, SharedMemory::ReadWrite); + if (!sharedMemory) { + ::CloseHandle(mapping); + return 0; + } + + // WKCACFImage never has an alpha channel. + return ShareableBitmap::create(size(image), 0, sharedMemory.release()); +} + +void LayerTreeHostCAWin::display(UpdateInfo& updateInfo) +{ + CGPoint imageOrigin; + CFTimeInterval nextDrawTime; + RetainPtr<WKCACFImageRef> image(AdoptCF, WKCACFViewCopyDrawnImage(m_view.get(), &imageOrigin, &nextDrawTime)); + m_nextDisplayTime = nextDrawTime - CACurrentMediaTime() + currentTime(); + if (!image) + return; + RefPtr<ShareableBitmap> bitmap = toShareableBitmap(image.get()); + if (!bitmap) + return; + if (!bitmap->createHandle(updateInfo.bitmapHandle)) + return; + updateInfo.updateRectBounds = IntRect(IntPoint(imageOrigin.x, m_webPage->size().height() - imageOrigin.y - bitmap->size().height()), bitmap->size()); + updateInfo.updateRects.append(updateInfo.updateRectBounds); +} + +void LayerTreeHostCAWin::sizeDidChange(const IntSize& newSize) +{ + LayerTreeHostCA::sizeDidChange(newSize); + CGRect bounds = CGRectMake(0, 0, newSize.width(), newSize.height()); + WKCACFViewUpdate(m_view.get(), dummyWindow, &bounds); + WKCACFViewFlushContext(m_view.get()); +} + +void LayerTreeHostCAWin::forceRepaint() +{ + LayerTreeHostCA::forceRepaint(); + WKCACFViewFlushContext(m_view.get()); +} + +void LayerTreeHostCAWin::contextDidChangeCallback(WKCACFViewRef view, void* info) +{ + // This should only be called on a background thread when no changes have actually + // been committed to the context, eg. when a video frame has been added to an image + // queue, so return without triggering animations etc. + if (!isMainThread()) + return; + + LayerTreeHostCAWin* host = static_cast<LayerTreeHostCAWin*>(info); + ASSERT_ARG(view, view == host->m_view); + host->contextDidChange(); +} + +void LayerTreeHostCAWin::contextDidChange() +{ + // Send currentTime to the pending animations. This function is called by CACF in a callback + // which occurs after the drawInContext calls. So currentTime is very close to the time + // the animations actually start + double currentTime = WTF::currentTime(); + + HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end(); + for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it) + (*it)->animationStarted(currentTime); + + m_pendingAnimatedLayers.clear(); + + m_nextDisplayTime = 0; + static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->setLayerHostNeedsDisplay(); +} + +PlatformCALayer* LayerTreeHostCAWin::rootLayer() const +{ + return static_cast<GraphicsLayerCA*>(LayerTreeHostCA::rootLayer())->platformCALayer(); +} + +void LayerTreeHostCAWin::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer) +{ + m_pendingAnimatedLayers.add(layer); +} + +void LayerTreeHostCAWin::layerTreeDidChange() +{ + if (m_isFlushingLayerChanges) { + // The layer tree is changing as a result of flushing GraphicsLayer changes to their + // underlying PlatformCALayers. We'll flush those changes to the context as part of that + // process, so there's no need to schedule another flush here. + return; + } + + // The layer tree is changing as a result of someone modifying a PlatformCALayer that doesn't + // have a corresponding GraphicsLayer. Schedule a flush since we won't schedule one through the + // normal GraphicsLayer mechanisms. + LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this); +} + +void LayerTreeHostCAWin::flushPendingLayerChangesNow() +{ + RefPtr<LayerTreeHostCA> protector(this); + + m_isFlushingLayerChanges = true; + + // Flush changes stored up in GraphicsLayers to their underlying PlatformCALayers, if + // requested. + performScheduledLayerFlush(); + + // Flush changes stored up in PlatformCALayers to the context so they will be rendered. + WKCACFViewFlushContext(m_view.get()); + + m_isFlushingLayerChanges = false; } } // namespace WebKit + +#endif // HAVE(WKQCA) diff --git a/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h b/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h new file mode 100644 index 0000000..2232b08 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/ca/win/LayerTreeHostCAWin.h @@ -0,0 +1,84 @@ +/* + * 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 LayerTreeHostCAWin_h +#define LayerTreeHostCAWin_h + +#include "HeaderDetection.h" + +#if HAVE(WKQCA) + +#include "LayerTreeHostCA.h" +#include <WebCore/AbstractCACFLayerTreeHost.h> +#include <wtf/HashSet.h> +#include <wtf/RetainPtr.h> + +typedef struct _WKCACFView* WKCACFViewRef; + +namespace WebKit { + +class LayerTreeHostCAWin : public LayerTreeHostCA, private WebCore::AbstractCACFLayerTreeHost { +public: + static bool supportsAcceleratedCompositing(); + + static PassRefPtr<LayerTreeHostCAWin> create(WebPage*); + virtual ~LayerTreeHostCAWin(); + +private: + explicit LayerTreeHostCAWin(WebPage*); + + static void contextDidChangeCallback(WKCACFViewRef, void* info); + void contextDidChange(); + + // LayerTreeHost + virtual void invalidate(); + virtual void forceRepaint(); + virtual void sizeDidChange(const WebCore::IntSize& newSize); + virtual void scheduleLayerFlush(); + virtual bool participatesInDisplay(); + virtual bool needsDisplay(); + virtual double timeUntilNextDisplay(); + virtual void display(UpdateInfo&); + + // LayerTreeHostCA + virtual void platformInitialize(LayerTreeContext&); + + // AbstractCACFLayerTreeHost + virtual WebCore::PlatformCALayer* rootLayer() const; + virtual void addPendingAnimatedLayer(PassRefPtr<WebCore::PlatformCALayer>); + virtual void layerTreeDidChange(); + virtual void flushPendingLayerChangesNow(); + + RetainPtr<WKCACFViewRef> m_view; + HashSet<RefPtr<WebCore::PlatformCALayer> > m_pendingAnimatedLayers; + bool m_isFlushingLayerChanges; + double m_nextDisplayTime; +}; + +} // namespace WebKit + +#endif // HAVE(WKQCA) + +#endif // LayerTreeHostCAWin_h diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp new file mode 100644 index 0000000..57c9977 --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * Copyright (C) 2011 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebPage.h" + +#include "NotImplemented.h" +#include "WebEvent.h" +#include "WindowsKeyboardCodes.h" +#include <WebCore/FocusController.h> +#include <WebCore/Frame.h> +#include <WebCore/KeyboardEvent.h> +#include <WebCore/Page.h> +#include <WebCore/PlatformKeyboardEvent.h> +#include <WebCore/Settings.h> + +using namespace WebCore; + +namespace WebKit { + +void WebPage::platformInitialize() +{ + notImplemented(); +} + +void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) +{ + notImplemented(); +} + +static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity) +{ + page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity); +} + +bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) +{ + if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown) + return false; + + switch (keyboardEvent.windowsVirtualKeyCode()) { + case VK_BACK: + if (keyboardEvent.shiftKey()) + m_page->goForward(); + else + m_page->goBack(); + break; + case VK_SPACE: + scroll(m_page.get(), keyboardEvent.shiftKey() ? ScrollUp : ScrollDown, ScrollByPage); + break; + case VK_LEFT: + scroll(m_page.get(), ScrollLeft, ScrollByLine); + break; + case VK_RIGHT: + scroll(m_page.get(), ScrollRight, ScrollByLine); + break; + case VK_UP: + scroll(m_page.get(), ScrollUp, ScrollByLine); + break; + case VK_DOWN: + scroll(m_page.get(), ScrollDown, ScrollByLine); + break; + case VK_HOME: + scroll(m_page.get(), ScrollUp, ScrollByDocument); + break; + case VK_END: + scroll(m_page.get(), ScrollDown, ScrollByDocument); + break; + case VK_PRIOR: + scroll(m_page.get(), ScrollUp, ScrollByPage); + break; + case VK_NEXT: + scroll(m_page.get(), ScrollDown, ScrollByPage); + break; + default: + return false; + } + + return true; +} + +bool WebPage::platformHasLocalDataForURL(const WebCore::KURL&) +{ + // FIXME: Implement + notImplemented(); + return false; +} + +String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL&) +{ + // FIXME: Implement + return String(); +} + +bool WebPage::platformCanHandleRequest(const WebCore::ResourceRequest&) +{ + // FIXME: Implement + return true; +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm index 8d81889..d7b352c 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm @@ -27,10 +27,13 @@ #import "WebPage.h" #import "AccessibilityWebPageObject.h" +#import "AttributedString.h" #import "DataReference.h" +#import "EditorState.h" #import "PluginView.h" #import "WebCoreArgumentCoders.h" #import "WebEvent.h" +#import "WebEventConversion.h" #import "WebFrame.h" #import "WebPageProxyMessages.h" #import "WebProcess.h" @@ -39,6 +42,7 @@ #import <WebCore/Frame.h> #import <WebCore/FrameView.h> #import <WebCore/HitTestResult.h> +#import <WebCore/HTMLConverter.h> #import <WebCore/KeyboardEvent.h> #import <WebCore/Page.h> #import <WebCore/PlatformKeyboardEvent.h> @@ -53,6 +57,8 @@ using namespace WebCore; namespace WebKit { +static PassRefPtr<Range> convertToRange(Frame*, NSRange); + void WebPage::platformInitialize() { m_page->addSchedulePair(SchedulePair::create([NSRunLoop currentRunLoop], kCFRunLoopCommonModes)); @@ -77,68 +83,131 @@ void WebPage::platformPreferencesDidChange(const WebPreferencesStore&) { } -bool WebPage::interceptEditingKeyboardEvent(KeyboardEvent* evt, bool shouldSaveCommand) +typedef HashMap<String, String> SelectorNameMap; + +// Map selectors into Editor command names. +// This is not needed for any selectors that have the same name as the Editor command. +static const SelectorNameMap* createSelectorExceptionMap() +{ + SelectorNameMap* map = new HashMap<String, String>; + + map->add("insertNewlineIgnoringFieldEditor:", "InsertNewline"); + map->add("insertParagraphSeparator:", "InsertNewline"); + map->add("insertTabIgnoringFieldEditor:", "InsertTab"); + map->add("pageDown:", "MovePageDown"); + map->add("pageDownAndModifySelection:", "MovePageDownAndModifySelection"); + map->add("pageUp:", "MovePageUp"); + map->add("pageUpAndModifySelection:", "MovePageUpAndModifySelection"); + + return map; +} + +static String commandNameForSelectorName(const String& selectorName) +{ + // Check the exception map first. + static const SelectorNameMap* exceptionMap = createSelectorExceptionMap(); + SelectorNameMap::const_iterator it = exceptionMap->find(selectorName); + if (it != exceptionMap->end()) + return it->second; + + // Remove the trailing colon. + // No need to capitalize the command name since Editor command names are not case sensitive. + size_t selectorNameLength = selectorName.length(); + if (selectorNameLength < 2 || selectorName[selectorNameLength - 1] != ':') + return String(); + return selectorName.left(selectorNameLength - 1); +} + +static Frame* frameForEvent(KeyboardEvent* event) { - Node* node = evt->target()->toNode(); + Node* node = event->target()->toNode(); ASSERT(node); Frame* frame = node->document()->frame(); ASSERT(frame); + return frame; +} + +bool WebPage::executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>& commands, KeyboardEvent* event) +{ + Frame* frame = frameForEvent(event); + ASSERT(frame->page() == corePage()); + + bool eventWasHandled = false; + for (size_t i = 0; i < commands.size(); ++i) { + if (commands[i].commandName == "insertText:") { + ASSERT(!frame->editor()->hasComposition()); + + if (!frame->editor()->canEdit()) + continue; + + // An insertText: might be handled by other responders in the chain if we don't handle it. + // One example is space bar that results in scrolling down the page. + eventWasHandled |= frame->editor()->insertText(commands[i].text, event); + } else { + Editor::Command command = frame->editor()->command(commandNameForSelectorName(commands[i].commandName)); + if (command.isSupported()) { + bool commandExecutedByEditor = command.execute(event); + eventWasHandled |= commandExecutedByEditor; + if (!commandExecutedByEditor) { + bool performedNonEditingBehavior = event->keyEvent()->type() == PlatformKeyboardEvent::RawKeyDown && performNonEditingBehaviorForSelector(commands[i].commandName); + eventWasHandled |= performedNonEditingBehavior; + } + } else { + bool commandWasHandledByUIProcess = false; + WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::ExecuteSavedCommandBySelector(commands[i].commandName), + Messages::WebPageProxy::ExecuteSavedCommandBySelector::Reply(commandWasHandledByUIProcess), m_pageID); + eventWasHandled |= commandWasHandledByUIProcess; + } + } + } + return eventWasHandled; +} + +bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* event, bool saveCommands) +{ + ASSERT(!saveCommands || event->keypressCommands().isEmpty()); // Save commands once for each event. + + Frame* frame = frameForEvent(event); - const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); - if (!keyEvent) + const PlatformKeyboardEvent* platformEvent = event->keyEvent(); + if (!platformEvent) return false; - const Vector<KeypressCommand>& commands = evt->keypressCommands(); - bool hasKeypressCommand = !commands.isEmpty(); - + Vector<KeypressCommand>& commands = event->keypressCommands(); + + if ([platformEvent->macEvent() type] == NSFlagsChanged) + return false; + bool eventWasHandled = false; - if (shouldSaveCommand || !hasKeypressCommand) { - Vector<KeypressCommand> commandsList; - Vector<CompositionUnderline> underlines; - unsigned start; - unsigned end; - if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::InterpretKeyEvent(keyEvent->type()), - Messages::WebPageProxy::InterpretKeyEvent::Reply(commandsList, start, end, underlines), - m_pageID, CoreIPC::Connection::NoTimeout)) + if (saveCommands) { + KeyboardEvent* oldEvent = m_keyboardEventBeingInterpreted; + m_keyboardEventBeingInterpreted = event; + bool sendResult = WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::InterpretQueuedKeyEvent(editorState()), + Messages::WebPageProxy::InterpretQueuedKeyEvent::Reply(eventWasHandled, commands), m_pageID); + m_keyboardEventBeingInterpreted = oldEvent; + if (!sendResult) + return false; + + // An input method may make several actions per keypress. For example, pressing Return with Korean IM both confirms it and sends a newline. + // IM-like actions are handled immediately (so the return value from UI process is true), but there are saved commands that + // should be handled like normal text input after DOM event dispatch. + if (!event->keypressCommands().isEmpty()) return false; - if (commandsList.isEmpty()) - return eventWasHandled; - - if (commandsList[0].commandName == "setMarkedText") { - frame->editor()->setComposition(commandsList[0].text, underlines, start, end); - eventWasHandled = true; - } else if (commandsList[0].commandName == "insertText" && frame->editor()->hasComposition()) { - frame->editor()->confirmComposition(commandsList[0].text); - eventWasHandled = true; - } else if (commandsList[0].commandName == "unmarkText") { - frame->editor()->confirmComposition(); - eventWasHandled = true; - } else { - for (size_t i = 0; i < commandsList.size(); i++) - evt->keypressCommands().append(commandsList[i]); - } } else { - size_t size = commands.size(); - // Are there commands that would just cause text insertion if executed via Editor? + // Are there commands that could just cause text insertion if executed via Editor? // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated // (e.g. Tab that inserts a Tab character, or Enter). bool haveTextInsertionCommands = false; - for (size_t i = 0; i < size; ++i) { - if (frame->editor()->command(commands[i].commandName).isTextInsertion()) + for (size_t i = 0; i < commands.size(); ++i) { + if (frame->editor()->command(commandNameForSelectorName(commands[i].commandName)).isTextInsertion()) haveTextInsertionCommands = true; } - if (!haveTextInsertionCommands || keyEvent->type() == PlatformKeyboardEvent::Char) { - for (size_t i = 0; i < size; ++i) { - if (commands[i].commandName == "insertText") { - // Don't insert null or control characters as they can result in unexpected behaviour - if (evt->charCode() < ' ') - return false; - eventWasHandled = frame->editor()->insertText(commands[i].text, evt); - } else - if (frame->editor()->command(commands[i].commandName).isSupported()) - eventWasHandled = frame->editor()->command(commands[i].commandName).execute(evt); - } + // If there are no text insertion commands, default keydown handler is the right time to execute the commands. + // Keypress (Char event) handler is the latest opportunity to execute. + if (!haveTextInsertionCommands || platformEvent->type() == PlatformKeyboardEvent::Char) { + eventWasHandled = executeKeypressCommandsInternal(event->keypressCommands(), event); + event->keypressCommands().clear(); } } return eventWasHandled; @@ -152,6 +221,54 @@ void WebPage::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdenti } } +void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + + if (frame->selection()->isContentEditable()) { + RefPtr<Range> replacementRange; + if (replacementRangeStart != NSNotFound) { + replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart)); + frame->selection()->setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); + } + + frame->editor()->setComposition(text, underlines, selectionStart, selectionEnd); + } + + newState = editorState(); +} + +void WebPage::confirmComposition(EditorState& newState) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + + frame->editor()->confirmComposition(); + + newState = editorState(); +} + +void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + + RefPtr<Range> replacementRange; + if (replacementRangeStart != NSNotFound) { + replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart)); + frame->selection()->setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); + } + + if (!frame->editor()->hasComposition()) { + // An insertText: might be handled by other responders in the chain if we don't handle it. + // One example is space bar that results in scrolling down the page. + handled = frame->editor()->insertText(text, m_keyboardEventBeingInterpreted); + } else { + handled = true; + frame->editor()->confirmComposition(text); + } + + newState = editorState(); +} + void WebPage::getMarkedRange(uint64_t& location, uint64_t& length) { location = NSNotFound; @@ -159,38 +276,59 @@ void WebPage::getMarkedRange(uint64_t& location, uint64_t& length) Frame* frame = m_page->focusController()->focusedOrMainFrame(); if (!frame) return; - - getLocationAndLengthFromRange(frame->editor()->compositionRange().get(), location, length); -} + RefPtr<Range> range = frame->editor()->compositionRange(); + size_t locationSize; + size_t lengthSize; + if (range && TextIterator::locationAndLengthFromRange(range.get(), locationSize, lengthSize)) { + location = static_cast<uint64_t>(locationSize); + length = static_cast<uint64_t>(lengthSize); + } +} -static PassRefPtr<Range> characterRangeAtPositionForPoint(Frame* frame, const VisiblePosition& position, const IntPoint& point) +void WebPage::getSelectedRange(uint64_t& location, uint64_t& length) { - if (position.isNull()) - return 0; + location = NSNotFound; + length = 0; + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return; - VisiblePosition previous = position.previous(); - if (previous.isNotNull()) { - RefPtr<Range> previousCharacterRange = makeRange(previous, position); - IntRect rect = frame->editor()->firstRectForRange(previousCharacterRange.get()); - if (rect.contains(point)) - return previousCharacterRange.release(); - } - - VisiblePosition next = position.next(); - if (next.isNotNull()) { - RefPtr<Range> nextCharacterRange = makeRange(position, next); - IntRect rect = frame->editor()->firstRectForRange(nextCharacterRange.get()); - if (rect.contains(point)) - return nextCharacterRange.release(); + size_t locationSize; + size_t lengthSize; + RefPtr<Range> range = frame->selection()->toNormalizedRange(); + if (range && TextIterator::locationAndLengthFromRange(range.get(), locationSize, lengthSize)) { + location = static_cast<uint64_t>(locationSize); + length = static_cast<uint64_t>(lengthSize); } - - return 0; } -static PassRefPtr<Range> characterRangeAtPoint(Frame* frame, const IntPoint& point) +void WebPage::getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString& result) { - return characterRangeAtPositionForPoint(frame, frame->visiblePositionForPoint(point), point); + NSRange nsRange = NSMakeRange(location, length - location); + + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return; + + if (frame->selection()->isNone() || !frame->selection()->isContentEditable() || frame->selection()->isInPasswordField()) + return; + + RefPtr<Range> range = convertToRange(frame, nsRange); + if (!range) + return; + + result.string = [WebHTMLConverter editingAttributedStringFromRange:range.get()]; + NSAttributedString* attributedString = result.string.get(); + + // [WebHTMLConverter editingAttributedStringFromRange:] insists on inserting a trailing + // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551> + // To work around this we truncate the resultant string to the correct length. + if ([attributedString length] > nsRange.length) { + ASSERT([attributedString length] == nsRange.length + 1); + ASSERT([[attributedString string] characterAtIndex:nsRange.length] == '\n' || [[attributedString string] characterAtIndex:nsRange.length] == ' '); + result.string = [attributedString attributedSubstringFromRange:NSMakeRange(0, nsRange.length)]; + } } void WebPage::characterIndexForPoint(IntPoint point, uint64_t& index) @@ -203,15 +341,17 @@ void WebPage::characterIndexForPoint(IntPoint point, uint64_t& index) HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(point, false); frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController()->focusedOrMainFrame(); - RefPtr<Range> range = characterRangeAtPoint(frame, result.point()); + RefPtr<Range> range = frame->rangeForPoint(result.point()); if (!range) return; - uint64_t length; - getLocationAndLengthFromRange(range.get(), index, length); + size_t location; + size_t length; + if (TextIterator::locationAndLengthFromRange(range.get(), location, length)) + index = static_cast<uint64_t>(location); } -static PassRefPtr<Range> convertToRange(Frame* frame, NSRange nsrange) +PassRefPtr<Range> convertToRange(Frame* frame, NSRange nsrange) { if (nsrange.location > INT_MAX) return 0; @@ -246,6 +386,12 @@ void WebPage::firstRectForCharacterRange(uint64_t location, uint64_t length, Web resultRect = frame->view()->contentsToWindow(rect); } +void WebPage::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands, bool& handled, EditorState& newState) +{ + handled = executeKeypressCommandsInternal(commands, m_keyboardEventBeingInterpreted); + newState = editorState(); +} + static bool isPositionInRange(const VisiblePosition& position, Range* range) { RefPtr<Range> positionRange = makeRange(position, position); @@ -284,12 +430,12 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint) frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController()->focusedOrMainFrame(); IntPoint translatedPoint = frame->view()->windowToContents(point); - VisiblePosition position = frame->visiblePositionForPoint(translatedPoint); // Don't do anything if there is no character at the point. - if (!characterRangeAtPositionForPoint(frame, position, translatedPoint)) + if (!frame->rangeForPoint(translatedPoint)) return; + VisiblePosition position = frame->visiblePositionForPoint(translatedPoint); VisibleSelection selection = m_page->focusController()->focusedOrMainFrame()->selection()->selection(); if (shouldUseSelection(position, selection)) { performDictionaryLookupForSelection(DictionaryPopupInfo::HotKey, frame, selection); @@ -378,96 +524,54 @@ void WebPage::performDictionaryLookupForRange(DictionaryPopupInfo::Type type, Fr dictionaryPopupInfo.type = type; dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y()); dictionaryPopupInfo.fontInfo.fontAttributeDictionary = fontDescriptorAttributes; +#if !defined(BUILDING_ON_SNOW_LEOPARD) dictionaryPopupInfo.options = (CFDictionaryRef)options; +#endif send(Messages::WebPageProxy::DidPerformDictionaryLookup(rangeText, dictionaryPopupInfo)); } -bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) +bool WebPage::performNonEditingBehaviorForSelector(const String& selector) { - if (keyboardEvent.type() != WebEvent::KeyDown) - return false; - - // FIXME: This should be in WebCore. - - switch (keyboardEvent.windowsVirtualKeyCode()) { - case VK_BACK: - if (keyboardEvent.shiftKey()) - m_page->goForward(); - else - m_page->goBack(); - break; - case VK_SPACE: - if (keyboardEvent.shiftKey()) - logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage); - else - logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage); - break; - case VK_PRIOR: - logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage); - break; - case VK_NEXT: - logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage); - break; - case VK_HOME: - logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByDocument); - break; - case VK_END: - logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByDocument); - break; - case VK_UP: - if (keyboardEvent.shiftKey()) - return false; - if (keyboardEvent.metaKey()) { - scroll(m_page.get(), ScrollUp, ScrollByDocument); - scroll(m_page.get(), ScrollLeft, ScrollByDocument); - } else if (keyboardEvent.altKey() || keyboardEvent.controlKey()) - scroll(m_page.get(), ScrollUp, ScrollByPage); - else - scroll(m_page.get(), ScrollUp, ScrollByLine); - break; - case VK_DOWN: - if (keyboardEvent.shiftKey()) - return false; - if (keyboardEvent.metaKey()) { - scroll(m_page.get(), ScrollDown, ScrollByDocument); - scroll(m_page.get(), ScrollLeft, ScrollByDocument); - } else if (keyboardEvent.altKey() || keyboardEvent.controlKey()) - scroll(m_page.get(), ScrollDown, ScrollByPage); - else - scroll(m_page.get(), ScrollDown, ScrollByLine); - break; - case VK_LEFT: - if (keyboardEvent.shiftKey()) - return false; - if (keyboardEvent.metaKey()) - m_page->goBack(); - else { - if (keyboardEvent.altKey() || keyboardEvent.controlKey()) - scroll(m_page.get(), ScrollLeft, ScrollByPage); - else - scroll(m_page.get(), ScrollLeft, ScrollByLine); - } - break; - case VK_RIGHT: - if (keyboardEvent.shiftKey()) - return false; - if (keyboardEvent.metaKey()) - m_page->goForward(); - else { - if (keyboardEvent.altKey() || keyboardEvent.controlKey()) - scroll(m_page.get(), ScrollRight, ScrollByPage); - else - scroll(m_page.get(), ScrollRight, ScrollByLine); - } - break; - default: + // FIXME: All these selectors have corresponding Editor commands, but the commands only work in editable content. + // Should such non-editing behaviors be implemented in Editor or EventHandler::defaultArrowEventHandler() perhaps? + if (selector == "moveUp:") + scroll(m_page.get(), ScrollUp, ScrollByLine); + else if (selector == "moveToBeginningOfParagraph:") + scroll(m_page.get(), ScrollUp, ScrollByPage); + else if (selector == "moveToBeginningOfDocument:") { + scroll(m_page.get(), ScrollUp, ScrollByDocument); + scroll(m_page.get(), ScrollLeft, ScrollByDocument); + } else if (selector == "moveDown:") + scroll(m_page.get(), ScrollDown, ScrollByLine); + else if (selector == "moveToEndOfParagraph:") + scroll(m_page.get(), ScrollDown, ScrollByPage); + else if (selector == "moveToEndOfDocument:") { + scroll(m_page.get(), ScrollDown, ScrollByDocument); + scroll(m_page.get(), ScrollLeft, ScrollByDocument); + } else if (selector == "moveLeft:") + scroll(m_page.get(), ScrollLeft, ScrollByLine); + else if (selector == "moveWordLeft:") + scroll(m_page.get(), ScrollLeft, ScrollByPage); + else if (selector == "moveToLeftEndOfLine:") + m_page->goBack(); + else if (selector == "moveRight:") + scroll(m_page.get(), ScrollRight, ScrollByLine); + else if (selector == "moveWordRight:") + scroll(m_page.get(), ScrollRight, ScrollByPage); + else if (selector == "moveToRightEndOfLine:") + m_page->goForward(); + else return false; - } return true; } +bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&) +{ + return false; +} + void WebPage::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elementToken, const CoreIPC::DataReference& windowToken) { #if !defined(BUILDING_ON_SNOW_LEOPARD) @@ -484,6 +588,10 @@ void WebPage::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& void WebPage::writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes, bool& result) { Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame || frame->selection()->isNone()) { + result = false; + return; + } frame->editor()->writeSelectionToPasteboard(pasteboardName, pasteboardTypes); result = true; } @@ -491,6 +599,10 @@ void WebPage::writeSelectionToPasteboard(const String& pasteboardName, const Vec void WebPage::readSelectionFromPasteboard(const String& pasteboardName, bool& result) { Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame || frame->selection()->isNone()) { + result = false; + return; + } frame->editor()->readSelectionFromPasteboard(pasteboardName); result = true; } @@ -548,10 +660,39 @@ void WebPage::setDragSource(NSObject *dragSource) void WebPage::platformDragEnded() { + // The draggedImage method releases its responder; we retain here to balance that. + [m_dragSource.get() retain]; // The drag source we care about here is NSFilePromiseDragSource, which doesn't look at // the arguments. It's OK to just pass arbitrary constant values, so we just pass all zeroes. [m_dragSource.get() draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationNone]; m_dragSource = nullptr; } +void WebPage::shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent& event, bool& result) +{ + result = false; + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return; + + HitTestResult hitResult = frame->eventHandler()->hitTestResultAtPoint(event.position(), true); + if (hitResult.isSelected()) + result = frame->eventHandler()->eventMayStartDrag(platform(event)); +} + +void WebPage::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& event, bool& result) +{ + result = false; + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame) + return; + + HitTestResult hitResult = frame->eventHandler()->hitTestResultAtPoint(event.position(), true); + frame->eventHandler()->setActivationEventNumber(eventNumber); + if (hitResult.isSelected()) + result = frame->eventHandler()->eventMayStartDrag(platform(event)); + else + result = !!hitResult.scrollbar(); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/win/LayerTreeHostWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/LayerTreeHostWin.cpp new file mode 100644 index 0000000..57c04bb --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/win/LayerTreeHostWin.cpp @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#include "config.h" +#include "LayerTreeHost.h" + +#if USE(CA) +#include "LayerTreeHostCAWin.h" +#endif + +namespace WebKit { + +bool LayerTreeHost::supportsAcceleratedCompositing() +{ +#if USE(CA) && HAVE(WKQCA) + return LayerTreeHostCAWin::supportsAcceleratedCompositing(); +#else + return false; +#endif +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp index 41bb219..9c7206a 100644 --- a/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp +++ b/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp @@ -28,17 +28,22 @@ #include "FontSmoothingLevel.h" #include "WebEvent.h" +#include "WebPageProxyMessages.h" #include "WebPreferencesStore.h" #include <WebCore/FocusController.h> #include <WebCore/FontRenderingMode.h> #include <WebCore/Frame.h> #include <WebCore/FrameView.h> +#include <WebCore/HitTestRequest.h> +#include <WebCore/HitTestResult.h> #include <WebCore/KeyboardEvent.h> #include <WebCore/Page.h> #include <WebCore/PlatformKeyboardEvent.h> +#include <WebCore/RenderLayer.h> +#include <WebCore/RenderView.h> #include <WebCore/ResourceHandle.h> #include <WebCore/Settings.h> -#if PLATFORM(CG) +#if USE(CG) #include <WebKitSystemInterface/WebKitSystemInterface.h> #endif #include <WinUser.h> @@ -62,7 +67,7 @@ void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store) { FontSmoothingLevel fontSmoothingLevel = static_cast<FontSmoothingLevel>(store.getUInt32ValueForKey(WebPreferencesKey::fontSmoothingLevelKey())); -#if PLATFORM(CG) +#if USE(CG) FontSmoothingLevel adjustedLevel = fontSmoothingLevel; if (adjustedLevel == FontSmoothingLevelWindows) adjustedLevel = FontSmoothingLevelMedium; @@ -351,4 +356,89 @@ void WebPage::getSelectedText(String& text) text = selectedRange->text(); } +void WebPage::gestureWillBegin(const WebCore::IntPoint& point, bool& canBeginPanning) +{ + m_gestureReachedScrollingLimit = false; + + bool hitScrollbar = false; + + HitTestRequest request(HitTestRequest::ReadOnly); + for (Frame* childFrame = m_page->mainFrame(); childFrame; childFrame = EventHandler::subframeForTargetNode(m_gestureTargetNode.get())) { + ScrollView* scollView = childFrame->view(); + if (!scollView) + break; + + RenderView* renderView = childFrame->document()->renderView(); + if (!renderView) + break; + + RenderLayer* layer = renderView->layer(); + if (!layer) + break; + + HitTestResult result = scollView->windowToContents(point); + layer->hitTest(request, result); + m_gestureTargetNode = result.innerNode(); + + if (!hitScrollbar) + hitScrollbar = result.scrollbar(); + } + + if (hitScrollbar) { + canBeginPanning = false; + return; + } + + if (!m_gestureTargetNode) { + canBeginPanning = false; + return; + } + + for (RenderObject* renderer = m_gestureTargetNode->renderer(); renderer; renderer = renderer->parent()) { + if (renderer->isBox() && toRenderBox(renderer)->canBeScrolledAndHasScrollableArea()) { + canBeginPanning = true; + return; + } + } + + canBeginPanning = false; +} + +static bool scrollbarAtTopOrBottomOfDocument(Scrollbar* scrollbar) +{ + ASSERT_ARG(scrollbar, scrollbar); + return !scrollbar->currentPos() || scrollbar->currentPos() >= scrollbar->maximum(); +} + +void WebPage::gestureDidScroll(const IntSize& size) +{ + ASSERT_ARG(size, !size.isZero()); + + if (!m_gestureTargetNode || !m_gestureTargetNode->renderer() || !m_gestureTargetNode->renderer()->enclosingLayer()) + return; + + Scrollbar* verticalScrollbar = 0; + if (Frame* frame = m_page->mainFrame()) { + if (ScrollView* view = frame->view()) + verticalScrollbar = view->verticalScrollbar(); + } + + m_gestureTargetNode->renderer()->enclosingLayer()->scrollByRecursively(size.width(), size.height()); + bool gestureReachedScrollingLimit = verticalScrollbar && scrollbarAtTopOrBottomOfDocument(verticalScrollbar); + + // FIXME: We really only want to update this state if the state was updated via scrolling the main frame, + // not scrolling something in a main frame when the main frame had already reached its scrolling limit. + + if (gestureReachedScrollingLimit == m_gestureReachedScrollingLimit) + return; + + send(Messages::WebPageProxy::SetGestureReachedScrollingLimit(gestureReachedScrollingLimit)); + m_gestureReachedScrollingLimit = gestureReachedScrollingLimit; +} + +void WebPage::gestureDidEnd() +{ + m_gestureTargetNode = nullptr; +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp index ba3290b..20bd6e3 100644 --- a/Source/WebKit2/WebProcess/WebProcess.cpp +++ b/Source/WebKit2/WebProcess/WebProcess.cpp @@ -59,6 +59,7 @@ #include <WebCore/Logging.h> #include <WebCore/MemoryCache.h> #include <WebCore/Page.h> +#include <WebCore/PageCache.h> #include <WebCore/PageGroup.h> #include <WebCore/ResourceHandle.h> #include <WebCore/SchemeRegistry.h> @@ -69,7 +70,6 @@ #include <wtf/RandomNumber.h> #ifndef NDEBUG -#include <WebCore/MemoryCache.h> #include <WebCore/GCController.h> #endif @@ -117,8 +117,11 @@ WebProcess& WebProcess::shared() return process; } +static const double shutdownTimeout = 60; + WebProcess::WebProcess() - : m_inDidClose(false) + : ChildProcess(shutdownTimeout) + , m_inDidClose(false) , m_hasSetCacheModel(false) , m_cacheModel(CacheModelDocumentViewer) #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) @@ -145,6 +148,7 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru m_connection = CoreIPC::Connection::createClientConnection(serverIdentifier, this, runLoop); m_connection->setDidCloseOnConnectionWorkQueueCallback(didCloseOnConnectionWorkQueue); + m_connection->setShouldExitOnSyncMessageSendFailure(true); m_connection->open(); @@ -214,11 +218,6 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame for (size_t i = 0; i < parameters.mimeTypesWithCustomRepresentation.size(); ++i) m_mimeTypesWithCustomRepresentations.add(parameters.mimeTypesWithCustomRepresentation[i]); - - if (parameters.clearResourceCaches) - clearResourceCaches(); - if (parameters.clearApplicationCache) - clearApplicationCache(); #if PLATFORM(MAC) m_presenterApplicationPid = parameters.presenterApplicationPid; @@ -276,20 +275,28 @@ void WebProcess::setVisitedLinkTable(const SharedMemory::Handle& handle) m_visitedLinkTable.setSharedMemory(sharedMemory.release()); } -PageGroup* WebProcess::sharedPageGroup() -{ - return PageGroup::pageGroup("WebKit2Group"); -} - void WebProcess::visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes) { - for (size_t i = 0; i < linkHashes.size(); ++i) - Page::visitedStateChanged(sharedPageGroup(), linkHashes[i]); + // FIXME: We may want to track visited links per WebPageGroup rather than per WebContext. + for (size_t i = 0; i < linkHashes.size(); ++i) { + HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator it = m_pageGroupMap.begin(); + HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator end = m_pageGroupMap.end(); + for (; it != end; ++it) + Page::visitedStateChanged(PageGroup::pageGroup(it->second->identifier()), linkHashes[i]); + } + + pageCache()->markPagesForVistedLinkStyleRecalc(); } void WebProcess::allVisitedLinkStateChanged() { - Page::allVisitedStateChanged(sharedPageGroup()); + // FIXME: We may want to track visited links per WebPageGroup rather than per WebContext. + HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator it = m_pageGroupMap.begin(); + HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::const_iterator end = m_pageGroupMap.end(); + for (; it != end; ++it) + Page::allVisitedStateChanged(PageGroup::pageGroup(it->second->identifier())); + + pageCache()->markPagesForVistedLinkStyleRecalc(); } bool WebProcess::isLinkVisited(LinkHash linkHash) const @@ -490,6 +497,9 @@ void WebProcess::createWebPage(uint64_t pageID, const WebPageCreationParameters& if (result.second) { ASSERT(!result.first->second); result.first->second = WebPage::create(pageID, parameters); + + // Balanced by an enableTermination in removeWebPage. + disableTermination(); } ASSERT(result.first->second); @@ -497,8 +507,11 @@ void WebProcess::createWebPage(uint64_t pageID, const WebPageCreationParameters& void WebProcess::removeWebPage(uint64_t pageID) { + ASSERT(m_pageMap.contains(pageID)); + m_pageMap.remove(pageID); - terminateIfPossible(); + + enableTermination(); } bool WebProcess::isSeparateProcess() const @@ -507,29 +520,26 @@ bool WebProcess::isSeparateProcess() const return m_runLoop == RunLoop::main(); } -void WebProcess::terminateIfPossible() +bool WebProcess::shouldTerminate() { - if (!m_pageMap.isEmpty()) - return; - - if (m_inDidClose) - return; - - if (DownloadManager::shared().isDownloading()) - return; - // Keep running forever if we're running in the same process. if (!isSeparateProcess()) - return; + return false; + + ASSERT(m_pageMap.isEmpty()); + ASSERT(!DownloadManager::shared().isDownloading()); // FIXME: the ShouldTerminate message should also send termination parameters, such as any session cookies that need to be preserved. bool shouldTerminate = false; if (m_connection->sendSync(Messages::WebProcessProxy::ShouldTerminate(), Messages::WebProcessProxy::ShouldTerminate::Reply(shouldTerminate), 0) && !shouldTerminate) - return; + return false; - // Actually terminate the process. + return true; +} +void WebProcess::terminate() +{ #ifndef NDEBUG gcController().garbageCollectNow(); memoryCache()->setDisabled(true); @@ -656,11 +666,8 @@ void WebProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Message // we'll let it slide. } -NO_RETURN void WebProcess::didFailToSendSyncMessage(CoreIPC::Connection*) +void WebProcess::syncMessageSendTimedOut(CoreIPC::Connection*) { - // We were making a synchronous call to a UI process that doesn't exist any more. - // Callers are unlikely to be prepared for an error like this, so it's best to exit immediately. - exit(0); } WebFrame* WebProcess::webFrame(uint64_t frameID) const @@ -702,10 +709,8 @@ WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupDat return result.first->second.get(); } -void WebProcess::clearResourceCaches(uint32_t cachesToClear) +void WebProcess::clearResourceCaches(ResourceCachesToClear resourceCachesToClear) { - ResourceCachesToClear resourceCachesToClear = static_cast<ResourceCachesToClear>(cachesToClear); - platformClearResourceCaches(resourceCachesToClear); // Toggling the cache model like this forces the cache to evict all its in-memory resources. @@ -731,6 +736,8 @@ void WebProcess::clearApplicationCache() #if !ENABLE(PLUGIN_PROCESS) void WebProcess::getSitesWithPluginData(const Vector<String>& pluginPaths, uint64_t callbackID) { + LocalTerminationDisabler terminationDisabler(*this); + HashSet<String> sitesSet; for (size_t i = 0; i < pluginPaths.size(); ++i) { @@ -747,11 +754,12 @@ void WebProcess::getSitesWithPluginData(const Vector<String>& pluginPaths, uint6 copyToVector(sitesSet, sites); m_connection->send(Messages::WebContext::DidGetSitesWithPluginData(sites, callbackID), 0); - terminateIfPossible(); } void WebProcess::clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID) { + LocalTerminationDisabler terminationDisabler(*this); + for (size_t i = 0; i < pluginPaths.size(); ++i) { RefPtr<NetscapePluginModule> netscapePluginModule = NetscapePluginModule::getOrCreate(pluginPaths[i]); if (!netscapePluginModule) @@ -768,7 +776,6 @@ void WebProcess::clearPluginSiteData(const Vector<String>& pluginPaths, const Ve } m_connection->send(Messages::WebContext::DidClearPluginSiteData(callbackID), 0); - terminateIfPossible(); } #endif @@ -805,7 +812,22 @@ void WebProcess::stopMemorySampler() void WebProcess::setTextCheckerState(const TextCheckerState& textCheckerState) { + bool continuousSpellCheckingTurnedOff = !textCheckerState.isContinuousSpellCheckingEnabled && m_textCheckerState.isContinuousSpellCheckingEnabled; + bool grammarCheckingTurnedOff = !textCheckerState.isGrammarCheckingEnabled && m_textCheckerState.isGrammarCheckingEnabled; + m_textCheckerState = textCheckerState; + + if (!continuousSpellCheckingTurnedOff && !grammarCheckingTurnedOff) + return; + + HashMap<uint64_t, RefPtr<WebPage> >::iterator end = m_pageMap.end(); + for (HashMap<uint64_t, RefPtr<WebPage> >::iterator it = m_pageMap.begin(); it != end; ++it) { + WebPage* page = (*it).second.get(); + if (continuousSpellCheckingTurnedOff) + page->unmarkAllMisspellings(); + if (grammarCheckingTurnedOff) + page->unmarkAllBadGrammar(); + } } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h index d666910..e57fb3f 100644 --- a/Source/WebKit2/WebProcess/WebProcess.h +++ b/Source/WebKit2/WebProcess/WebProcess.h @@ -66,7 +66,7 @@ struct WebPageGroupData; struct WebPreferencesStore; struct WebProcessCreationParameters; -class WebProcess : ChildProcess { +class WebProcess : public ChildProcess { public: static WebProcess& shared(); @@ -99,7 +99,6 @@ public: WebPageGroupProxy* webPageGroup(uint64_t pageGroupID); WebPageGroupProxy* webPageGroup(const WebPageGroupData&); - static WebCore::PageGroup* sharedPageGroup(); #if PLATFORM(MAC) pid_t presenterApplicationPid() const { return m_presenterApplicationPid; } #endif @@ -108,9 +107,6 @@ public: QNetworkAccessManager* networkAccessManager() { return m_networkAccessManager; } #endif - // Will terminate the web process if there are no live pages or downloads. - void terminateIfPossible(); - bool shouldUseCustomRepresentationForMIMEType(const String& mimeType) const { return m_mimeTypesWithCustomRepresentations.contains(mimeType); } // Text Checking @@ -119,7 +115,7 @@ public: // Geolocation WebGeolocationManager& geolocationManager() { return m_geolocationManager; } - void clearResourceCaches(uint32_t cachesToClear = AllResourceCaches); + void clearResourceCaches(ResourceCachesToClear = AllResourceCaches); const String& localStorageDirectory() const { return m_localStorageDirectory; } @@ -167,12 +163,20 @@ private: void setTextCheckerState(const TextCheckerState&); + // ChildProcess + virtual bool shouldTerminate(); + virtual void terminate(); + // CoreIPC::Connection::Client - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); - void didClose(CoreIPC::Connection*); - void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - NO_RETURN void didFailToSendSyncMessage(CoreIPC::Connection*); + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + virtual CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); + virtual void didClose(CoreIPC::Connection*); + virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); + +#if PLATFORM(WIN) + Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply(); +#endif // Implemented in generated WebProcessMessageReceiver.cpp void didReceiveWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); diff --git a/Source/WebKit2/WebProcess/WebProcess.messages.in b/Source/WebKit2/WebProcess/WebProcess.messages.in index 36155a7..f50c979 100644 --- a/Source/WebKit2/WebProcess/WebProcess.messages.in +++ b/Source/WebKit2/WebProcess/WebProcess.messages.in @@ -50,16 +50,13 @@ messages -> WebProcess { GetSitesWithPluginData(Vector<WTF::String> pluginPaths, uint64_t callbackID) ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID) #endif - - ClearResourceCaches(uint32_t cachesToClear); - ClearApplicationCache(); void StartMemorySampler(WebKit::SandboxExtension::Handle sampleLogFileHandle, WTF::String sampleLogFilePath, double interval); void StopMemorySampler(); # Downloads. This should really be in a Download.messages.in, but it seemed unnecessary to create a new file just for # two messages. - void DownloadRequest(uint64_t downloadID, uint64_t initiatingPageID, WebCore::ResourceRequest request) + DownloadRequest(uint64_t downloadID, uint64_t initiatingPageID, WebCore::ResourceRequest request) CancelDownload(uint64_t downloadID) SetTextCheckerState(WebKit::TextCheckerState textCheckerState) diff --git a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb index fa81666..f4958d5 100644 --- a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb +++ b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb @@ -11,6 +11,7 @@ ;; Read-only preferences and data (allow file-read* ;; Basic system paths + (subpath "/Library/Dictionaries") (subpath "/Library/Fonts") (subpath "/Library/Frameworks") (subpath "/Library/Keychains") @@ -46,6 +47,28 @@ ;; FIXME: This should be removed when <rdar://problem/8957845> is fixed. (subpath (string-append (param "HOME_DIR") "/Library/Fonts")) + ;; FIXME: These should be removed when <rdar://problem/9217757> is fixed. + (subpath (string-append (param "HOME_DIR") "/Library/Audio/Plug-Ins/Components")) + (subpath (string-append (param "HOME_DIR") "/Library/Preferences/QuickTime Preferences")) + (subpath "/Library/Audio/Plug-Ins/Components") + (subpath "/Library/Audio/Plug-Ins/HAL") + (subpath "/Library/Video/Plug-Ins") + (subpath "/Library/QuickTime") + + ;; FIXME: This should be removed when <rdar://problem/9237619> is fixed. + (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.universalaccess.plist")) + + ;; FIXME: This should be removed when <rdar://problem/9276253> is fixed. + (subpath (string-append (param "HOME_DIR") "/Library/Keyboard Layouts")) + + ;; FIXME: This should be removed when <rdar://problem/9276268> is fixed. + (subpath (string-append (param "HOME_DIR") "/Library/Input Methods")) + + ;; FIXME: This should be removed when <rdar://problem/9276430> is fixed. + (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")) + + (subpath (string-append (param "HOME_DIR") "/Library/Dictionaries")) + ;; Extensions from UIProcess (extension) ) @@ -61,6 +84,9 @@ (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/ByHost/com\.apple\.HIToolbox\.")) (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/com\.apple\.WebProcess\.")) (subpath (string-append (param "HOME_DIR") "/Library/Keychains")) + + ;; FIXME: This should be removed when <rdar://problem/9217757> is fixed. + (literal (string-append (param "HOME_DIR") "/Library/Caches/com.apple.coreaudio.components.plist")) ) ;; Darwin temporary files and caches, if present @@ -94,57 +120,45 @@ ;; Various services required by AppKit and other frameworks (allow mach-lookup - (global-name "com.apple.CoreServices.coreservicesd") - (global-name "com.apple.DiskArbitration.diskarbitrationd") - (global-name "com.apple.FileCoordination") - (global-name "com.apple.FontObjectsServer") - (global-name "com.apple.FontServer") - (global-name "com.apple.SecurityServer") - (global-name "com.apple.SystemConfiguration.configd") - (global-name "com.apple.audio.VDCAssistant") - (global-name "com.apple.audio.audiohald") - (global-name "com.apple.audio.coreaudiod") - (global-name "com.apple.cookied") - (global-name "com.apple.cvmsServ") - (global-name "com.apple.dock.server") - (global-name "com.apple.ocspd") - (global-name "com.apple.pasteboard.1") - (global-name "com.apple.system.opendirectoryd.api") - (global-name "com.apple.window_proxies") - (global-name "com.apple.windowserver.active") - (global-name-regex #"^com\.apple\.WebKit\.WebProcess-") - (global-name-regex #"^com\.apple\.qtkitserver\.") + (global-name "com.apple.CoreServices.coreservicesd") + (global-name "com.apple.DiskArbitration.diskarbitrationd") + (global-name "com.apple.FileCoordination") + (global-name "com.apple.FontObjectsServer") + (global-name "com.apple.FontServer") + (global-name "com.apple.SecurityServer") + (global-name "com.apple.SystemConfiguration.configd") + (global-name "com.apple.audio.VDCAssistant") + (global-name "com.apple.audio.audiohald") + (global-name "com.apple.audio.coreaudiod") + (global-name "com.apple.cookied") + (global-name "com.apple.cvmsServ") + (global-name "com.apple.networkd") + (global-name "com.apple.dock.server") + (global-name "com.apple.ocspd") + (global-name "com.apple.pasteboard.1") + (global-name "com.apple.system.opendirectoryd.api") + (global-name "com.apple.window_proxies") + (global-name "com.apple.windowserver.active") + (global-name-regex #"^com\.apple\.WebKit\.WebProcess-") + (global-name-regex #"^com\.apple\.qtkitserver\.") + + ;; FIXME: This should be removed when <rdar://problem/9276393> is fixed. + (global-name "com.apple.metadata.mds") ) -;; FIXME: These rules are required until <rdar://problem/8448410> is addressed. See <rdar://problem/8349882> for discussion. +;; FIXME: <rdar://problem/9263428> These rules are required to avoid +;; sandbox violation spam, but some narrower rule should be +;; sufficient. (allow network-outbound) (deny network-outbound (regex "")) (deny network-outbound (local ip)) + (allow network-outbound ;; Local mDNSResponder for DNS, arbitrary outbound TCP (literal "/private/var/run/mDNSResponder") (remote tcp) ) -;; FIXME: These rules are required until plug-ins are moved out of the web process. -(allow file-read* - (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/ByHost/com\.apple\.ist\.")) - (literal (string-append (param "HOME_DIR") "/Library/Preferences/edu.mit.Kerberos")) - (literal "/Library/Preferences/edu.mit.Kerberos") -) - -(allow mach-lookup - (global-name "org.h5l.kcm") - (global-name "com.apple.tsm.uiserver") - (global-name-regex #"^com\.apple\.ist") -) - -(allow network-outbound (remote ip)) - -;; These rules are required while QTKitServer is being launched directly via posix_spawn (<rdar://problem/6912494>). -(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")) diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm index 88ef834..4c23daf 100644 --- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm +++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm @@ -30,6 +30,7 @@ #import "SandboxExtension.h" #import "WebPage.h" #import "WebProcessCreationParameters.h" +#import <WebCore/FileSystem.h> #import <WebCore/MemoryCache.h> #import <WebCore/PageCache.h> #import <WebKitSystemInterface.h> @@ -122,7 +123,7 @@ bool WebProcess::fullKeyboardAccessEnabled() } #if ENABLE(WEB_PROCESS_SANDBOX) -static void appendSandboxParameterPath(Vector<const char*>& vector, const char* name, const char* path) +static void appendSandboxParameterPathInternal(Vector<const char*>& vector, const char* name, const char* path) { char normalizedPath[PATH_MAX]; if (!realpath(path, normalizedPath)) @@ -132,14 +133,31 @@ static void appendSandboxParameterPath(Vector<const char*>& vector, const char* vector.append(fastStrDup(normalizedPath)); } -static void appendSandboxParameterConfPath(Vector<const char*>& vector, const char* name, int confID) +static void appendReadwriteConfDirectory(Vector<const char*>& vector, const char* name, int confID) { char path[PATH_MAX]; if (confstr(confID, path, PATH_MAX) <= 0) path[0] = '\0'; - appendSandboxParameterPath(vector, name, path); + appendSandboxParameterPathInternal(vector, name, path); } + +static void appendReadonlySandboxDirectory(Vector<const char*>& vector, const char* name, NSString *path) +{ + appendSandboxParameterPathInternal(vector, name, [(NSString *)path fileSystemRepresentation]); +} + +static void appendReadwriteSandboxDirectory(Vector<const char*>& vector, const char* name, NSString *path) +{ + NSError *error = nil; + + // This is very unlikely to fail, but in case it actually happens, we'd like some sort of output in the console. + if (![[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]) + NSLog(@"could not create \"%@\", error %@", path, error); + + appendSandboxParameterPathInternal(vector, name, [(NSString *)path fileSystemRepresentation]); +} + #endif static void initializeSandbox(const WebProcessCreationParameters& parameters) @@ -152,14 +170,20 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters) Vector<const char*> sandboxParameters; - appendSandboxParameterPath(sandboxParameters, "HOME_DIR", [NSHomeDirectory() fileSystemRepresentation]); - appendSandboxParameterPath(sandboxParameters, "WEBKIT2_FRAMEWORK_DIR", [[[[NSBundle bundleForClass:NSClassFromString(@"WKView")] bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation]); - appendSandboxParameterConfPath(sandboxParameters, "DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR); - appendSandboxParameterConfPath(sandboxParameters, "DARWIN_USER_CACHE_DIR", _CS_DARWIN_USER_CACHE_DIR); - appendSandboxParameterPath(sandboxParameters, "WEBKIT_DATABASE_DIR", [(NSString *)parameters.databaseDirectory fileSystemRepresentation]); - appendSandboxParameterPath(sandboxParameters, "WEBKIT_LOCALSTORAGE_DIR", [(NSString *)parameters.localStorageDirectory fileSystemRepresentation]); - appendSandboxParameterPath(sandboxParameters, "NSURL_CACHE_DIR", parameters.nsURLCachePath.data()); - appendSandboxParameterPath(sandboxParameters, "UI_PROCESS_BUNDLE_RESOURCE_DIR", parameters.uiProcessBundleResourcePath.data()); + // These are read-only. + appendReadonlySandboxDirectory(sandboxParameters, "WEBKIT2_FRAMEWORK_DIR", [[[NSBundle bundleForClass:NSClassFromString(@"WKView")] bundlePath] stringByDeletingLastPathComponent]); + appendReadonlySandboxDirectory(sandboxParameters, "UI_PROCESS_BUNDLE_RESOURCE_DIR", parameters.uiProcessBundleResourcePath); + + // These are read-write getconf paths. + appendReadwriteConfDirectory(sandboxParameters, "DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR); + appendReadwriteConfDirectory(sandboxParameters, "DARWIN_USER_CACHE_DIR", _CS_DARWIN_USER_CACHE_DIR); + + // These are read-write paths. + appendReadwriteSandboxDirectory(sandboxParameters, "HOME_DIR", NSHomeDirectory()); + appendReadwriteSandboxDirectory(sandboxParameters, "WEBKIT_DATABASE_DIR", parameters.databaseDirectory); + appendReadwriteSandboxDirectory(sandboxParameters, "WEBKIT_LOCALSTORAGE_DIR", parameters.localStorageDirectory); + appendReadwriteSandboxDirectory(sandboxParameters, "NSURL_CACHE_DIR", parameters.nsURLCachePath); + sandboxParameters.append(static_cast<const char*>(0)); const char* profilePath = [[[NSBundle mainBundle] pathForResource:@"com.apple.WebProcess" ofType:@"sb"] fileSystemRepresentation]; @@ -193,7 +217,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters initializeSandbox(parameters); if (!parameters.parentProcessName.isNull()) { - NSString *applicationName = [NSString stringWithFormat:UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.parentProcessName]; + NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.parentProcessName]; WKSetVisibleApplicationName((CFStringRef)applicationName); } @@ -201,8 +225,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity; NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity; - NSString *nsCachePath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:parameters.nsURLCachePath.data() length:strlen(parameters.nsURLCachePath.data())]; - RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:nsCachePath]); + RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:parameters.nsURLCachePath]); [NSURLCache setSharedURLCache:parentProcessURLCache.get()]; } diff --git a/Source/WebKit2/WebProcess/win/WebProcessWin.cpp b/Source/WebKit2/WebProcess/win/WebProcessWin.cpp index d56fef6..d9a4af5 100644 --- a/Source/WebKit2/WebProcess/win/WebProcessWin.cpp +++ b/Source/WebKit2/WebProcess/win/WebProcessWin.cpp @@ -27,6 +27,7 @@ #include "WebProcess.h" #include "WebCookieManager.h" +#include "WebPage.h" #include "WebProcessCreationParameters.h" #include <WebCore/FileSystem.h> #include <WebCore/MemoryCache.h> @@ -137,4 +138,49 @@ void WebProcess::setShouldPaintNativeControls(bool shouldPaintNativeControls) #endif } +struct EnumWindowsContext { + DWORD currentThreadID; + Vector<HWND>* windows; +}; + +static BOOL CALLBACK addWindowToVectorIfOwnedByCurrentThread(HWND window, LPARAM lParam) +{ + EnumWindowsContext* context = reinterpret_cast<EnumWindowsContext*>(lParam); + + if (::GetWindowThreadProcessId(window, 0) != context->currentThreadID) + return TRUE; + + context->windows->append(window); + return TRUE; +} + +Vector<HWND> WebProcess::windowsToReceiveSentMessagesWhileWaitingForSyncReply() +{ + Vector<HWND> windows; + + // Any non-message-only window created by this thread needs to receive sent messages while we + // wait for a sync reply. Otherwise we could deadlock with the UI process if, e.g., the focus + // window changes. See <http://webkit.org/b/58239>. + + EnumWindowsContext context; + context.currentThreadID = ::GetCurrentThreadId(); + context.windows = &windows; + + // Start out with top-level windows created by this thread (like Flash's hidden + // SWFlash_PlaceholderX top-level windows). + ::EnumThreadWindows(context.currentThreadID, addWindowToVectorIfOwnedByCurrentThread, reinterpret_cast<LPARAM>(&context)); + + // Also include any descendants of those top-level windows. + size_t topLevelWindowCount = windows.size(); + for (size_t i = 0; i < topLevelWindowCount; ++i) + ::EnumChildWindows(windows[i], addWindowToVectorIfOwnedByCurrentThread, reinterpret_cast<LPARAM>(&context)); + + // Also include any descendants of the WebPages' windows which we've created (e.g., for windowed plugins). + HashMap<uint64_t, RefPtr<WebPage> >::const_iterator::Values end = m_pageMap.end(); + for (HashMap<uint64_t, RefPtr<WebPage> >::const_iterator::Values it = m_pageMap.begin(); it != end; ++it) + ::EnumChildWindows((*it)->nativeWindow(), addWindowToVectorIfOwnedByCurrentThread, reinterpret_cast<LPARAM>(&context)); + + return windows; +} + } // namespace WebKit diff --git a/Source/WebKit2/config.h b/Source/WebKit2/config.h index 3723185..8250891 100644 --- a/Source/WebKit2/config.h +++ b/Source/WebKit2/config.h @@ -125,7 +125,7 @@ static const type& name() \ #include <WebCore/config.h> #include <windows.h> -#if PLATFORM(CG) +#if USE(CG) #include <CoreGraphics/CoreGraphics.h> #endif @@ -141,12 +141,14 @@ static const type& name() \ #endif -#if PLATFORM(MAC) || (OS(MAC_OS_X) && PLATFORM(QT)) +#if PLATFORM(MAC) #define PLUGIN_ARCHITECTURE_MAC 1 -#elif PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(QT)) +#elif PLATFORM(WIN) #define PLUGIN_ARCHITECTURE_WIN 1 -#elif (PLATFORM(QT) && defined(Q_WS_X11)) || (PLATFORM(GTK) && OS(UNIX) && !OS(MAC_OS_X)) +#elif (PLATFORM(QT) || (PLATFORM(GTK))) && (OS(UNIX) && !OS(MAC_OS_X) && !OS(SYMBIAN)) #define PLUGIN_ARCHITECTURE_X11 1 +#else +#define PLUGIN_ARCHITECTURE_UNSUPPORTED 1 #endif #define PLUGIN_ARCHITECTURE(ARCH) (defined PLUGIN_ARCHITECTURE_##ARCH && PLUGIN_ARCHITECTURE_##ARCH) diff --git a/Source/WebKit2/win/WebKit2.vcproj b/Source/WebKit2/win/WebKit2.vcproj index 5e4ffa8..cf8ee60 100755 --- a/Source/WebKit2/win/WebKit2.vcproj +++ b/Source/WebKit2/win/WebKit2.vcproj @@ -431,6 +431,10 @@ > </File> <File + RelativePath="..\Shared\EditorState.h" + > + </File> + <File RelativePath="..\Shared\FontInfo.cpp" > </File> @@ -483,6 +487,10 @@ > </File> <File + RelativePath="..\Shared\NativeWebMouseEvent.h" + > + </File> + <File RelativePath="..\Shared\OriginAndDatabases.cpp" > </File> @@ -523,10 +531,6 @@ > </File> <File - RelativePath="..\Shared\SelectionState.h" - > - </File> - <File RelativePath="..\Shared\SessionState.cpp" > </File> @@ -1145,10 +1149,6 @@ RelativePath="..\Shared\CoreIPCSupport\WebPageProxyMessageKinds.h" > </File> - <File - RelativePath="..\Shared\CoreIPCSupport\WebProcessProxyMessageKinds.h" - > - </File> </Filter> <Filter Name="cf" @@ -1194,6 +1194,64 @@ > </File> <File + RelativePath="..\Shared\win\NativeWebMouseEventWin.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug_Cairo_CFLite|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + <FileConfiguration + Name="Release_Cairo_CFLite|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug_All|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + <FileConfiguration + Name="Production|Win32" + > + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)\$(InputName)1.obj" + XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" + /> + </FileConfiguration> + </File> + <File RelativePath="..\Shared\win\PlatformCertificateInfo.cpp" > </File> @@ -1905,6 +1963,10 @@ > </File> <File + RelativePath="..\WebProcess\WebPage\win\LayerTreeHostWin.cpp" + > + </File> + <File RelativePath="..\WebProcess\WebPage\win\WebInspectorWin.cpp" > </File> @@ -1963,6 +2025,10 @@ /> </FileConfiguration> </File> + <File + RelativePath="..\WebProcess\WebPage\ca\win\LayerTreeHostCAWin.h" + > + </File> </Filter> </Filter> </Filter> @@ -2767,6 +2833,14 @@ > </File> <File + RelativePath="..\UIProcess\WebIconDatabaseClient.cpp" + > + </File> + <File + RelativePath="..\UIProcess\WebIconDatabaseClient.h" + > + </File> + <File RelativePath="..\UIProcess\WebInspectorProxy.cpp" > </File> @@ -3236,6 +3310,22 @@ > </File> <File + RelativePath="..\UIProcess\API\C\win\WKGrammarDetail.cpp" + > + </File> + <File + RelativePath="..\UIProcess\API\C\win\WKGrammarDetail.h" + > + </File> + <File + RelativePath="..\UIProcess\API\C\win\WKTextChecker.cpp" + > + </File> + <File + RelativePath="..\UIProcess\API\C\win\WKTextChecker.h" + > + </File> + <File RelativePath="..\UIProcess\API\C\win\WKView.cpp" > </File> @@ -3390,6 +3480,14 @@ > </File> <File + RelativePath="..\UIProcess\win\WebGrammarDetail.cpp" + > + </File> + <File + RelativePath="..\UIProcess\win\WebGrammarDetail.h" + > + </File> + <File RelativePath="..\UIProcess\win\WebInspectorProxyWin.cpp" > </File> @@ -3406,6 +3504,26 @@ > </File> <File + RelativePath="..\UIProcess\win\WebProcessProxyWin.cpp" + > + </File> + <File + RelativePath="..\UIProcess\win\WebTextChecker.cpp" + > + </File> + <File + RelativePath="..\UIProcess\win\WebTextChecker.h" + > + </File> + <File + RelativePath="..\UIProcess\win\WebTextCheckerClient.cpp" + > + </File> + <File + RelativePath="..\UIProcess\win\WebTextCheckerClient.h" + > + </File> + <File RelativePath="..\UIProcess\win\WebUndoClient.cpp" > </File> diff --git a/Source/WebKit2/win/WebKit2Apple.vsprops b/Source/WebKit2/win/WebKit2Apple.vsprops index 68d01ac..2a45d65 100644 --- a/Source/WebKit2/win/WebKit2Apple.vsprops +++ b/Source/WebKit2/win/WebKit2Apple.vsprops @@ -6,7 +6,7 @@ > <Tool Name="VCCLCompilerTool" - AdditionalIncludeDirectories=""$(ProjectDir)..\WebProcess\WebPage\ca"" + AdditionalIncludeDirectories=""$(ProjectDir)..\WebProcess\WebPage\ca";"$(ProjectDir)..\WebProcess\WebPage\ca\win"" /> <Tool Name="VCLinkerTool" diff --git a/Source/WebKit2/win/WebKit2Generated.make b/Source/WebKit2/win/WebKit2Generated.make index 79c5f14..694c0d5 100644 --- a/Source/WebKit2/win/WebKit2Generated.make +++ b/Source/WebKit2/win/WebKit2Generated.make @@ -37,6 +37,7 @@ all: xcopy /y /d "..\Shared\API\c\WKURLRequest.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\Shared\API\c\WKURLResponse.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\Shared\API\c\WKUserContentURLPattern.h" "%ConfigurationBuildDir%\include\WebKit2" + xcopy /y /d "..\UIProcess\API\C\cg\WKIconDatabaseCG.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WebKit2.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKApplicationCacheManager.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKAuthenticationChallenge.h" "%ConfigurationBuildDir%\include\WebKit2" @@ -57,6 +58,7 @@ all: xcopy /y /d "..\UIProcess\API\C\WKGeolocationPermissionRequest.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKGeolocationPosition.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKInspector.h" "%ConfigurationBuildDir%\include\WebKit2" + xcopy /y /d "..\UIProcess\API\C\WKIconDatabase.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKKeyValueStorageManager.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKMediaCacheManager.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKNativeEvent.h" "%ConfigurationBuildDir%\include\WebKit2" @@ -73,6 +75,8 @@ all: xcopy /y /d "..\UIProcess\API\C\WKProtectionSpaceTypes.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\WKResourceCacheManager.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\win\WKContextPrivateWin.h" "%ConfigurationBuildDir%\include\WebKit2" + xcopy /y /d "..\UIProcess\API\C\win\WKGrammarDetail.h" "%ConfigurationBuildDir%\include\WebKit2" + xcopy /y /d "..\UIProcess\API\C\win\WKTextChecker.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\win\WKView.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\C\win\WKViewPrivate.h" "%ConfigurationBuildDir%\include\WebKit2" xcopy /y /d "..\UIProcess\API\cpp\WKRetainPtr.h" "%ConfigurationBuildDir%\include\WebKit2" diff --git a/Source/WebKit2/win/WebKit2Production.vsprops b/Source/WebKit2/win/WebKit2Production.vsprops index 5bdec6f..4387622 100644 --- a/Source/WebKit2/win/WebKit2Production.vsprops +++ b/Source/WebKit2/win/WebKit2Production.vsprops @@ -6,7 +6,7 @@ InheritedPropertySheets=" $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\FeatureDefines.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops; - $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops; + $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\releaseproduction.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\production.vsprops; .\WebKit2Common.vsprops; .\WebKit2DirectX.vsprops; diff --git a/Source/WebKit2/win/WebKit2Release.vsprops b/Source/WebKit2/win/WebKit2Release.vsprops index 7ae6676..698b8ff 100644 --- a/Source/WebKit2/win/WebKit2Release.vsprops +++ b/Source/WebKit2/win/WebKit2Release.vsprops @@ -6,6 +6,7 @@ InheritedPropertySheets=" $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\FeatureDefines.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops; + $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\releaseproduction.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops; .\WebKit2Common.vsprops; .\WebKit2DirectX.vsprops; diff --git a/Source/WebKit2/win/WebKit2ReleaseCairoCFLite.vsprops b/Source/WebKit2/win/WebKit2ReleaseCairoCFLite.vsprops index 685f929..7d5eeee 100644 --- a/Source/WebKit2/win/WebKit2ReleaseCairoCFLite.vsprops +++ b/Source/WebKit2/win/WebKit2ReleaseCairoCFLite.vsprops @@ -6,6 +6,7 @@ InheritedPropertySheets=" $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\FeatureDefinesCairo.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops; + $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\releaseproduction.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\WinCairo.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\cURL.vsprops; diff --git a/Source/WebKit2/win/WebKit2WebProcessProduction.vsprops b/Source/WebKit2/win/WebKit2WebProcessProduction.vsprops index 08c8ae2..20f75fc 100644 --- a/Source/WebKit2/win/WebKit2WebProcessProduction.vsprops +++ b/Source/WebKit2/win/WebKit2WebProcessProduction.vsprops @@ -6,7 +6,7 @@ InheritedPropertySheets=" $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\FeatureDefines.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops; - $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops; + $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\releaseproduction.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\production.vsprops; .\WebKit2WebProcessCommon.vsprops" > diff --git a/Source/WebKit2/win/WebKit2WebProcessRelease.vsprops b/Source/WebKit2/win/WebKit2WebProcessRelease.vsprops index a32a112..2dbbb93 100644 --- a/Source/WebKit2/win/WebKit2WebProcessRelease.vsprops +++ b/Source/WebKit2/win/WebKit2WebProcessRelease.vsprops @@ -6,6 +6,7 @@ InheritedPropertySheets=" $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\FeatureDefines.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops; + $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\releaseproduction.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops; .\WebKit2WebProcessCommon.vsprops" > diff --git a/Source/WebKit2/win/WebKit2WebProcessReleaseCairoCFLite.vsprops b/Source/WebKit2/win/WebKit2WebProcessReleaseCairoCFLite.vsprops index d278242..75811b0 100644 --- a/Source/WebKit2/win/WebKit2WebProcessReleaseCairoCFLite.vsprops +++ b/Source/WebKit2/win/WebKit2WebProcessReleaseCairoCFLite.vsprops @@ -6,6 +6,7 @@ InheritedPropertySheets=" $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\FeatureDefinesCairo.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\common.vsprops; + $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\releaseproduction.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\release.vsprops; $(WebKitVSPropsRedirectionDir)..\..\..\WebKitLibraries\win\tools\vsprops\WinCairo.vsprops; .\WebKit2WebProcessCommon.vsprops" diff --git a/Source/WebKit2/win/WebKitPreBuild.cmd b/Source/WebKit2/win/WebKitPreBuild.cmd index b6f0bd4..82f02e9 100644 --- a/Source/WebKit2/win/WebKitPreBuild.cmd +++ b/Source/WebKit2/win/WebKitPreBuild.cmd @@ -5,11 +5,6 @@ if exist "%CONFIGURATIONBUILDDIR%\buildfailed" grep XX%PROJECTNAME%XX "%CONFIGUR if errorlevel 1 exit 1 echo XX%PROJECTNAME%XX > "%CONFIGURATIONBUILDDIR%\buildfailed" -touch "%CONFIGURATIONBUILDDIR%\tmp.cpp" -cl /analyze /nologo /c "%CONFIGURATIONBUILDDIR%\tmp.cpp" /Fo"%INTDIR%\tmp.obj" 2>&1 | findstr D9040 -if ERRORLEVEL 1 (set EnablePREfast="true") else (set EnablePREfast="false") -if ERRORLEVEL 1 (set AnalyzeWithLargeStack="/analyze:65536") else (set AnalyzeWithLargeStack="") - mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\JavaScriptCore" xcopy /y /d "%WEBKITLIBRARIESDIR%\include\JavaScriptCore\*" "%CONFIGURATIONBUILDDIR%\include\JavaScriptCore" |