[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

darin at apple.com darin at apple.com
Fri Jan 21 14:36:06 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit c73cf5140f7417a606375696339c0df098463629
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 23 00:44:56 2010 +0000

    2010-12-22  Darin Adler  <darin at apple.com>
    
            Reviewed by Anders Carlsson.
    
            Make Speech menu items work in WebKit2
            https://bugs.webkit.org/show_bug.cgi?id=51504
    
            * UIProcess/API/C/WKFrame.cpp:
            (WKFrameGetWebArchive): Updated to use new-named typedef.
            * UIProcess/API/C/WKPage.cpp:
            (WKPageRunJavaScriptInMainFrame): Ditto.
            (WKPageRenderTreeExternalRepresentation): Ditto.
            (WKPageGetSourceForFrame): Ditto.
            (WKPageGetContentsAsString): Ditto.
    
            * UIProcess/API/mac/WKView.mm:
            (menuItem): Added. Helper function to make it easy to call menu item
            functions on arbitrary user interface items.
            (toolbarItem): Ditto.
            (-[WKView validateUserInterfaceItem:]): Added validation for startSpeaking
            and stopSpeaking commands. Reworked the code to fix a bug where
            toggleContinuousSpellChecking would always be enabled even when it should
            be disabled. Reworked the asynchronous validation code so it works for
            items other than menu items and can also handle more than one item for the
            same command. Added some comments.
            (speakString): Added. Helper function to be used as a callback when we
            get the selection or contents to speak.
            (-[WKView startSpeaking:]): Added. Uses getSelectionOrContentsAsString.
            (-[WKView stopSpeaking:]): Added.
            (-[WKView _setUserInterfaceItemState:enabled:state:]): Reworked to work
            with the changes to validateUserInterfaceItem above.
    
            * UIProcess/WebFrameProxy.cpp:
            (WebKit::WebFrameProxy::isDisplayingMarkupDocument): Added a FIXME about
            a problem I noticed.
            (WebKit::WebFrameProxy::didCommitLoad): Tweaked argument name.
            (WebKit::WebFrameProxy::getWebArchive): Changed to use new-named typedef.
            * UIProcess/WebFrameProxy.h: Changed WebArchiveCallback to DataCallaback.
    
            * UIProcess/WebPageProxy.cpp:
            (WebKit::WebPageProxy::close): Invalidate the two callback maps since
            we only have two now.
            (WebKit::WebPageProxy::runJavaScriptInMainFrame): Changed to use merged
            maps and typedefs so we don't need a separate callback map for each function.
            (WebKit::WebPageProxy::getRenderTreeExternalRepresentation): Ditto.
            (WebKit::WebPageProxy::getSourceForFrame): Ditto.
            (WebKit::WebPageProxy::getContentsAsString): Ditto.
            (WebKit::WebPageProxy::getSelectionOrContentsAsString): Added.
            (WebKit::WebPageProxy::getWebArchiveOfFrame): Ditto.
            (WebKit::WebPageProxy::didGetContentsAsString): Ditto.
            (WebKit::WebPageProxy::didGetSelectionOrContentsAsString): Ditto.
            (WebKit::WebPageProxy::didRunJavaScriptInMainFrame): Ditto.
            (WebKit::WebPageProxy::didGetRenderTreeExternalRepresentation): Ditto.
            (WebKit::WebPageProxy::didGetSourceForFrame): Ditto.
            (WebKit::WebPageProxy::didGetWebArchiveOfFrame): Ditto.
            (WebKit::WebPageProxy::processDidCrash): Ditto.
    
            * UIProcess/WebPageProxy.h: Updated for changes above.
    
            * UIProcess/WebPageProxy.messages.in: Added DidGetSelectionOrContentsAsString,
            GetIsSpeaking, Speak, and StopSpeaking.
    
            * UIProcess/mac/WebPageProxyMac.mm:
            (WebKit::WebPageProxy::getIsSpeaking): Added.
            (WebKit::WebPageProxy::speak): Added.
            (WebKit::WebPageProxy::stopSpeaking): Added.
    
            * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
            (WebKit::WebContextMenuClient::isSpeaking): Call WebPage instead of doing
            the work directly, so it can run in the UI process.
            (WebKit::WebContextMenuClient::speak): Ditto.
            (WebKit::WebContextMenuClient::stopSpeaking): Ditto.
            (WebKit::WebContextMenuClient::searchWithSpotlight): Added FIXME comment and
            changed code to avoid a C-style cast.
    
            * WebProcess/WebPage/WebFrame.cpp:
            (WebKit::WebFrame::selectionAsString): Added.
            * WebProcess/WebPage/WebFrame.h: Ditto.
    
            * WebProcess/WebPage/WebPage.cpp:
            (WebKit::WebPage::changeAcceleratedCompositingMode): Use sendSync in the
            modern way instead of explicitly calling WebProcess.
            (WebKit::WebPage::getSelectionOrContentsAsString): Added.
            (WebKit::WebPage::isSpeaking): Added.
            (WebKit::WebPage::speak): Added.
            (WebKit::WebPage::stopSpeaking): Added.
            * WebProcess/WebPage/WebPage.h: Added functions.
    
            * WebProcess/WebPage/WebPage.messages.in: Added GetSelectionOrContentsAsString.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74521 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 1d258aa..8cd733d 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,93 @@
+2010-12-22  Darin Adler  <darin at apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Make Speech menu items work in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51504
+
+        * UIProcess/API/C/WKFrame.cpp:
+        (WKFrameGetWebArchive): Updated to use new-named typedef.
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageRunJavaScriptInMainFrame): Ditto.
+        (WKPageRenderTreeExternalRepresentation): Ditto.
+        (WKPageGetSourceForFrame): Ditto.
+        (WKPageGetContentsAsString): Ditto.
+
+        * UIProcess/API/mac/WKView.mm:
+        (menuItem): Added. Helper function to make it easy to call menu item
+        functions on arbitrary user interface items.
+        (toolbarItem): Ditto.
+        (-[WKView validateUserInterfaceItem:]): Added validation for startSpeaking
+        and stopSpeaking commands. Reworked the code to fix a bug where
+        toggleContinuousSpellChecking would always be enabled even when it should
+        be disabled. Reworked the asynchronous validation code so it works for
+        items other than menu items and can also handle more than one item for the
+        same command. Added some comments.
+        (speakString): Added. Helper function to be used as a callback when we
+        get the selection or contents to speak.
+        (-[WKView startSpeaking:]): Added. Uses getSelectionOrContentsAsString.
+        (-[WKView stopSpeaking:]): Added.
+        (-[WKView _setUserInterfaceItemState:enabled:state:]): Reworked to work
+        with the changes to validateUserInterfaceItem above.
+
+        * UIProcess/WebFrameProxy.cpp:
+        (WebKit::WebFrameProxy::isDisplayingMarkupDocument): Added a FIXME about
+        a problem I noticed.
+        (WebKit::WebFrameProxy::didCommitLoad): Tweaked argument name.
+        (WebKit::WebFrameProxy::getWebArchive): Changed to use new-named typedef.
+        * UIProcess/WebFrameProxy.h: Changed WebArchiveCallback to DataCallaback.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close): Invalidate the two callback maps since
+        we only have two now.
+        (WebKit::WebPageProxy::runJavaScriptInMainFrame): Changed to use merged
+        maps and typedefs so we don't need a separate callback map for each function.
+        (WebKit::WebPageProxy::getRenderTreeExternalRepresentation): Ditto.
+        (WebKit::WebPageProxy::getSourceForFrame): Ditto.
+        (WebKit::WebPageProxy::getContentsAsString): Ditto.
+        (WebKit::WebPageProxy::getSelectionOrContentsAsString): Added.
+        (WebKit::WebPageProxy::getWebArchiveOfFrame): Ditto.
+        (WebKit::WebPageProxy::didGetContentsAsString): Ditto.
+        (WebKit::WebPageProxy::didGetSelectionOrContentsAsString): Ditto.
+        (WebKit::WebPageProxy::didRunJavaScriptInMainFrame): Ditto.
+        (WebKit::WebPageProxy::didGetRenderTreeExternalRepresentation): Ditto.
+        (WebKit::WebPageProxy::didGetSourceForFrame): Ditto.
+        (WebKit::WebPageProxy::didGetWebArchiveOfFrame): Ditto.
+        (WebKit::WebPageProxy::processDidCrash): Ditto.
+
+        * UIProcess/WebPageProxy.h: Updated for changes above.
+
+        * UIProcess/WebPageProxy.messages.in: Added DidGetSelectionOrContentsAsString,
+        GetIsSpeaking, Speak, and StopSpeaking.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::getIsSpeaking): Added.
+        (WebKit::WebPageProxy::speak): Added.
+        (WebKit::WebPageProxy::stopSpeaking): Added.
+
+        * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
+        (WebKit::WebContextMenuClient::isSpeaking): Call WebPage instead of doing
+        the work directly, so it can run in the UI process.
+        (WebKit::WebContextMenuClient::speak): Ditto.
+        (WebKit::WebContextMenuClient::stopSpeaking): Ditto.
+        (WebKit::WebContextMenuClient::searchWithSpotlight): Added FIXME comment and
+        changed code to avoid a C-style cast.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::selectionAsString): Added.
+        * WebProcess/WebPage/WebFrame.h: Ditto.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::changeAcceleratedCompositingMode): Use sendSync in the
+        modern way instead of explicitly calling WebProcess.
+        (WebKit::WebPage::getSelectionOrContentsAsString): Added.
+        (WebKit::WebPage::isSpeaking): Added.
+        (WebKit::WebPage::speak): Added.
+        (WebKit::WebPage::stopSpeaking): Added.
+        * WebProcess/WebPage/WebPage.h: Added functions.
+
+        * WebProcess/WebPage/WebPage.messages.in: Added GetSelectionOrContentsAsString.
+
 2010-12-22  Anders Carlsson  <andersca at apple.com>
 
         Fix build.
diff --git a/WebKit2/UIProcess/API/C/WKFrame.cpp b/WebKit2/UIProcess/API/C/WKFrame.cpp
index a5bc71d..cb44ed7 100644
--- a/WebKit2/UIProcess/API/C/WKFrame.cpp
+++ b/WebKit2/UIProcess/API/C/WKFrame.cpp
@@ -122,7 +122,7 @@ bool WKFrameIsFrameSet(WKFrameRef frameRef)
 
 void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context)
 {
-    toImpl(frameRef)->getWebArchive(WebArchiveCallback::create(context, callback));
+    toImpl(frameRef)->getWebArchive(DataCallback::create(context, callback));
 }
 
 #ifdef __BLOCKS__
diff --git a/WebKit2/UIProcess/API/C/WKPage.cpp b/WebKit2/UIProcess/API/C/WKPage.cpp
index b913fc5..25dede2 100644
--- a/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -326,7 +326,7 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClient* wkClient)
 
 void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
 {
-    toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), ScriptReturnValueCallback::create(context, callback));
+    toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), StringCallback::create(context, callback));
 }
 
 #ifdef __BLOCKS__
@@ -345,7 +345,7 @@ void WKPageRunJavaScriptInMainFrame_b(WKPageRef pageRef, WKStringRef scriptRef,
 
 void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
 {
-    toImpl(pageRef)->getRenderTreeExternalRepresentation(RenderTreeExternalRepresentationCallback::create(context, callback));
+    toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(context, callback));
 }
 
 #ifdef __BLOCKS__
@@ -364,7 +364,7 @@ void WKPageRenderTreeExternalRepresentation_b(WKPageRef pageRef, WKPageRenderTre
 
 void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
 {
-    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), FrameSourceCallback::create(context, callback));
+    toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(context, callback));
 }
 
 #ifdef __BLOCKS__
@@ -383,7 +383,7 @@ void WKPageGetSourceForFrame_b(WKPageRef pageRef, WKFrameRef frameRef, WKPageGet
 
 void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
 {
-    toImpl(pageRef)->getContentsAsString(ContentsAsStringCallback::create(context, callback));
+    toImpl(pageRef)->getContentsAsString(StringCallback::create(context, callback));
 }
 
 #ifdef __BLOCKS__
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index 21af4ae..7b5c49a 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -25,10 +25,6 @@
 
 #import "WKView.h"
 
-// C API
-#import "WKAPICast.h"
-
-// Implementation
 #import "ChunkedUpdateDrawingAreaProxy.h"
 #import "FindIndicator.h"
 #import "FindIndicatorWindow.h"
@@ -39,6 +35,8 @@
 #import "PageClientImpl.h"
 #import "RunLoop.h"
 #import "TextChecker.h"
+#import "WKAPICast.h"
+#import "WKStringCF.h"
 #import "WKTextInputWindowController.h"
 #import "WebContext.h"
 #import "WebEventFactory.h"
@@ -56,22 +54,31 @@
 #import <wtf/RefPtr.h>
 #import <wtf/RetainPtr.h>
 
+ at interface NSApplication (Details)
+- (void)speakString:(NSString *)string;
+ at end
+
+ at interface NSWindow (Details)
+- (NSRect)_growBoxRect;
+- (BOOL)_updateGrowBoxForWindowFrameChange;
+ at 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;
 
- at interface NSWindow (Details)
-- (NSRect)_growBoxRect;
-- (BOOL)_updateGrowBoxForWindowFrameChange;
- at end
+namespace WebKit {
+
+typedef id <NSValidatedUserInterfaceItem> ValidationItem;
+typedef Vector<RetainPtr<ValidationItem> > ValidationVector;
+typedef HashMap<String, ValidationVector> ValidationMap;
+
+}
 
 @interface WKViewData : NSObject {
 @public
@@ -86,8 +93,9 @@ using namespace WebCore;
 #if USE(ACCELERATED_COMPOSITING)
     NSView *_layerHostingView;
 #endif
-    // For Menus.
-    HashMap<String, RetainPtr<NSMenuItem> > _menuItemsMap;
+
+    // For asynchronous validation.
+    ValidationMap _validationMap;
 
     OwnPtr<PDFViewController> _pdfViewController;
 
@@ -294,7 +302,6 @@ static String commandNameForSelector(SEL selector)
 }
 
 // Editing commands
-// FIXME: we should add all the commands here as we implement them.
 
 #define WEBCORE_COMMAND(command) - (void)command:(id)sender { _data->_page->executeEditCommand(commandNameForSelector(_cmd)); }
 
@@ -310,41 +317,90 @@ WEBCORE_COMMAND(takeFindStringFromSelection)
 
 // Menu items validation
 
-- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+static NSMenuItem *menuItem(id <NSValidatedUserInterfaceItem> item)
 {
-    NSMenuItem *menuItem = (NSMenuItem *)item;
-    if (![menuItem isKindOfClass:[NSMenuItem class]])
-        return NO; // FIXME: We need to be able to handle other user interface elements.
+    if (![(NSObject *)item isKindOfClass:[NSMenuItem class]])
+        return nil;
+    return (NSMenuItem *)item;
+}
 
+static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
+{
+    if (![(NSObject *)item isKindOfClass:[NSToolbarItem class]])
+        return nil;
+    return (NSToolbarItem *)item;
+}
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
     SEL action = [item action];
 
+    // FIXME: This is only needed to work around the fact that we don't return YES for
+    // selectors that are not editing commands (see below). If that's fixed, this can be removed.
+    if (action == @selector(startSpeaking:))
+        return YES;
+
+    if (action == @selector(stopSpeaking:))
+        return [NSApp isSpeaking];
+
     if (action == @selector(toggleContinuousSpellChecking:)) {
-        bool checkMark = false;
-        bool returnValue = false;
-        if (TextChecker::isContinuousSpellCheckingAllowed())
-            checkMark = TextChecker::isContinuousSpellCheckingEnabled();
-        returnValue = true;
-
-        [menuItem setState:checkMark ? NSOnState : NSOffState];
-        return returnValue;
+        bool enabled = TextChecker::isContinuousSpellCheckingAllowed();
+        bool checked = enabled && TextChecker::isContinuousSpellCheckingEnabled();
+        [menuItem(item) setState:checked ? NSOnState : NSOffState];
+        return enabled;
     }
 
     if (action == @selector(toggleGrammarChecking:)) {
-        bool checkMark = TextChecker::isGrammarCheckingEnabled();
-        [menuItem setState:checkMark ? NSOnState : NSOffState];
+        bool checked = TextChecker::isGrammarCheckingEnabled();
+        [menuItem(item) setState:checked ? NSOnState : NSOffState];
         return YES;
     }
-    
+
+    // FIXME: We should return YES here for selectors that are not editing commands.
+    // But at the moment there is no way to find out if a selector is an editing command or not
+    // in the UI process. So for now we assume any selectors not handled above are editing commands.
+
     String commandName = commandNameForSelector([item action]);
+    if (commandName.isEmpty())
+        return YES;
 
-    if (_data->_menuItemsMap.find(commandName) == _data->_menuItemsMap.end()) {
-        _data->_menuItemsMap.add(commandName, menuItem);
+    // Add this menu item to the vector of items for a given command that are awaiting validation.
+    // If the item is the first to be added, then call validateMenuItem to start the asynchronous
+    // validation process.
+    pair<ValidationMap::iterator, bool> addResult = _data->_validationMap.add(commandName, ValidationVector());
+    addResult.first->second.append(item);
+    if (addResult.second) {
+        // FIXME: The function should be renamed validateCommand because it is not specific to menu items.
         _data->_page->validateMenuItem(commandName);
     }
 
+    // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called.
+    // FIXME: This means that items will flash enabled at first, and only then disable a moment later, which is unattractive.
+    // But returning NO here is worse, because that makes keyboard commands such as command-C fail.
     return YES;
 }
 
+static void speakString(WKStringRef string, WKErrorRef error, void*)
+{
+    if (error)
+        return;
+    if (!string)
+        return;
+
+    NSString *convertedString = toImpl(string)->string();
+    [NSApp speakString:convertedString];
+}
+
+- (IBAction)startSpeaking:(id)sender
+{
+    _data->_page->getSelectionOrContentsAsString(StringCallback::create(0, speakString));
+}
+
+- (IBAction)stopSpeaking:(id)sender
+{
+    [NSApp stopSpeaking:sender];
+}
+
 - (IBAction)toggleContinuousSpellChecking:(id)sender
 {
     bool spellCheckingEnabled = !TextChecker::isContinuousSpellCheckingEnabled();
@@ -354,7 +410,7 @@ WEBCORE_COMMAND(takeFindStringFromSelection)
         _data->_page->unmarkAllMisspellings();
 }
 
-- (void)toggleGrammarChecking:(id)sender
+- (IBAction)toggleGrammarChecking:(id)sender
 {
     bool grammarCheckingEnabled = !TextChecker::isGrammarCheckingEnabled();
     TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled);
@@ -372,7 +428,6 @@ WEBCORE_COMMAND(takeFindStringFromSelection)
     return YES;
 }
 
-
 #define EVENT_HANDLER(Selector, Type) \
     - (void)Selector:(NSEvent *)theEvent \
     { \
@@ -926,9 +981,16 @@ static bool isViewVisible(NSView *view)
 
 - (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState
 {
-    NSMenuItem *menuItem = _data->_menuItemsMap.take(commandName).get();
-    [menuItem setState:newState];
-    [menuItem setEnabled:isEnabled];
+    ValidationVector items = _data->_validationMap.take(commandName);
+    size_t size = items.size();
+    for (size_t i = 0; i < size; ++i) {
+        ValidationItem item = items[i].get();
+        [menuItem(item) setState:newState];
+        [menuItem(item) setEnabled:isEnabled];
+        [toolbarItem(item) setEnabled:isEnabled];
+        // FIXME: If the user interface item is neither a menu item nor a toolbar, it will be left enabled.
+        // It's not obvious how to fix this.
+    }
 }
 
 - (NSRect)_convertToDeviceSpace:(NSRect)rect
diff --git a/WebKit2/UIProcess/WebFrameProxy.cpp b/WebKit2/UIProcess/WebFrameProxy.cpp
index 7bd4cd7..b33acfa 100644
--- a/WebKit2/UIProcess/WebFrameProxy.cpp
+++ b/WebKit2/UIProcess/WebFrameProxy.cpp
@@ -98,7 +98,8 @@ bool WebFrameProxy::isDisplayingStandaloneImageDocument() const
 
 bool WebFrameProxy::isDisplayingMarkupDocument() const
 {
-    // FIXME: This check should be moved to somewhere in WebCore. 
+    // FIXME: This check should be moved to somewhere in WebCore.
+    // FIXME: This returns false when displaying a web archive.
     return m_MIMEType == "text/html" || m_MIMEType == "image/svg+xml" || DOMImplementation::isXMLMIMEType(m_MIMEType);
 }
 
@@ -127,7 +128,7 @@ void WebFrameProxy::didFailProvisionalLoad()
     m_provisionalURL = String();
 }
 
-void WebFrameProxy::didCommitLoad(const String& mimeType, const PlatformCertificateInfo& certificateInfo)
+void WebFrameProxy::didCommitLoad(const String& contentType, const PlatformCertificateInfo& certificateInfo)
 {
     ASSERT(m_loadState == LoadStateProvisional);
     ASSERT(!m_provisionalURL.isEmpty());
@@ -135,7 +136,7 @@ void WebFrameProxy::didCommitLoad(const String& mimeType, const PlatformCertific
     m_url = m_provisionalURL;
     m_provisionalURL = String();
     m_title = String();
-    m_MIMEType = mimeType;
+    m_MIMEType = contentType;
     m_isFrameSet = false;
     m_certificateInfo = WebCertificateInfo::create(certificateInfo);
 }
@@ -193,7 +194,7 @@ WebFormSubmissionListenerProxy* WebFrameProxy::setUpFormSubmissionListenerProxy(
     return static_cast<WebFormSubmissionListenerProxy*>(m_activeListener.get());
 }
 
-void WebFrameProxy::getWebArchive(PassRefPtr<WebArchiveCallback> callback)
+void WebFrameProxy::getWebArchive(PassRefPtr<DataCallback> callback)
 {
     if (!m_page) {
         callback->invalidate();
diff --git a/WebKit2/UIProcess/WebFrameProxy.h b/WebKit2/UIProcess/WebFrameProxy.h
index b5cd9cb..2d9f804 100644
--- a/WebKit2/UIProcess/WebFrameProxy.h
+++ b/WebKit2/UIProcess/WebFrameProxy.h
@@ -48,7 +48,7 @@ class WebFormSubmissionListenerProxy;
 class WebFramePolicyListenerProxy;
 class WebPageProxy;
 
-typedef GenericCallback<WKDataRef> WebArchiveCallback;
+typedef GenericCallback<WKDataRef> DataCallback;
 
 class WebFrameProxy : public APIObject {
 public:
@@ -96,7 +96,7 @@ public:
     bool isDisplayingStandaloneImageDocument() const;
     bool isDisplayingMarkupDocument() const;
 
-    void getWebArchive(PassRefPtr<WebArchiveCallback>);
+    void getWebArchive(PassRefPtr<DataCallback>);
 
     void didStartProvisionalLoad(const String& url);
     void didReceiveServerRedirectForProvisionalLoad(const String& url);
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 2a0e77c..dafe7ef 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -245,11 +245,8 @@ void WebPageProxy::close()
 
     m_toolTip = String();
 
-    invalidateCallbackMap(m_contentsAsStringCallbacks);
-    invalidateCallbackMap(m_frameSourceCallbacks);
-    invalidateCallbackMap(m_renderTreeExternalRepresentationCallbacks);
-    invalidateCallbackMap(m_scriptReturnValueCallbacks);
-    invalidateCallbackMap(m_webArchiveCallbacks);
+    invalidateCallbackMap(m_dataCallbacks);
+    invalidateCallbackMap(m_stringCallbacks);
 
     Vector<WebEditCommandProxy*> editCommandVector;
     copyToVector(m_editCommandSet, editCommandVector);
@@ -784,43 +781,51 @@ void WebPageProxy::countStringMatches(const String& string, FindOptions options,
     process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
 }
     
-void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptReturnValueCallback> prpCallback)
+void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<StringCallback> prpCallback)
 {
-    RefPtr<ScriptReturnValueCallback> callback = prpCallback;
+    RefPtr<StringCallback> callback = prpCallback;
     uint64_t callbackID = callback->callbackID();
-    m_scriptReturnValueCallbacks.set(callbackID, callback.get());
+    m_stringCallbacks.set(callbackID, callback.get());
     process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
 }
 
-void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<RenderTreeExternalRepresentationCallback> prpCallback)
+void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
 {
-    RefPtr<RenderTreeExternalRepresentationCallback> callback = prpCallback;
+    RefPtr<StringCallback> callback = prpCallback;
     uint64_t callbackID = callback->callbackID();
-    m_renderTreeExternalRepresentationCallbacks.set(callbackID, callback.get());
+    m_stringCallbacks.set(callbackID, callback.get());
     process()->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
 }
 
-void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<FrameSourceCallback> prpCallback)
+void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
 {
-    RefPtr<FrameSourceCallback> callback = prpCallback;
+    RefPtr<StringCallback> callback = prpCallback;
     uint64_t callbackID = callback->callbackID();
-    m_frameSourceCallbacks.set(callbackID, callback.get());
+    m_stringCallbacks.set(callbackID, callback.get());
     process()->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
 }
 
-void WebPageProxy::getContentsAsString(PassRefPtr<ContentsAsStringCallback> prpCallback)
+void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
 {
-    RefPtr<ContentsAsStringCallback> callback = prpCallback;
+    RefPtr<StringCallback> callback = prpCallback;
     uint64_t callbackID = callback->callbackID();
-    m_contentsAsStringCallbacks.set(callbackID, callback.get());
+    m_stringCallbacks.set(callbackID, callback.get());
     process()->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
 }
 
-void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<WebArchiveCallback> prpCallback)
+void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
 {
-    RefPtr<WebArchiveCallback> callback = prpCallback;
+    RefPtr<StringCallback> callback = prpCallback;
     uint64_t callbackID = callback->callbackID();
-    m_webArchiveCallbacks.set(callbackID, callback.get());
+    m_stringCallbacks.set(callbackID, callback.get());
+    process()->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
+}
+
+void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
+{
+    RefPtr<DataCallback> callback = prpCallback;
+    uint64_t callbackID = callback->callbackID();
+    m_dataCallbacks.set(callbackID, callback.get());
     process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
 }
 
@@ -1710,7 +1715,18 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
 
 void WebPageProxy::didGetContentsAsString(const String& resultString, uint64_t callbackID)
 {
-    RefPtr<ContentsAsStringCallback> callback = m_contentsAsStringCallbacks.take(callbackID);
+    RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
+    if (!callback) {
+        // FIXME: Log error or assert.
+        return;
+    }
+
+    callback->performCallbackWithReturnValue(resultString.impl());
+}
+
+void WebPageProxy::didGetSelectionOrContentsAsString(const String& resultString, uint64_t callbackID)
+{
+    RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
     if (!callback) {
         // FIXME: Log error or assert.
         return;
@@ -1721,7 +1737,7 @@ void WebPageProxy::didGetContentsAsString(const String& resultString, uint64_t c
 
 void WebPageProxy::didRunJavaScriptInMainFrame(const String& resultString, uint64_t callbackID)
 {
-    RefPtr<ScriptReturnValueCallback> callback = m_scriptReturnValueCallbacks.take(callbackID);
+    RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
     if (!callback) {
         // FIXME: Log error or assert.
         return;
@@ -1732,7 +1748,7 @@ void WebPageProxy::didRunJavaScriptInMainFrame(const String& resultString, uint6
 
 void WebPageProxy::didGetRenderTreeExternalRepresentation(const String& resultString, uint64_t callbackID)
 {
-    RefPtr<RenderTreeExternalRepresentationCallback> callback = m_renderTreeExternalRepresentationCallbacks.take(callbackID);
+    RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
     if (!callback) {
         // FIXME: Log error or assert.
         return;
@@ -1743,7 +1759,7 @@ void WebPageProxy::didGetRenderTreeExternalRepresentation(const String& resultSt
 
 void WebPageProxy::didGetSourceForFrame(const String& resultString, uint64_t callbackID)
 {
-    RefPtr<FrameSourceCallback> callback = m_frameSourceCallbacks.take(callbackID);
+    RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
     if (!callback) {
         // FIXME: Log error or assert.
         return;
@@ -1754,7 +1770,7 @@ void WebPageProxy::didGetSourceForFrame(const String& resultString, uint64_t cal
 
 void WebPageProxy::didGetWebArchiveOfFrame(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
 {
-    RefPtr<WebArchiveCallback> callback = m_webArchiveCallbacks.take(callbackID);
+    RefPtr<DataCallback> callback = m_dataCallbacks.take(callbackID);
     if (!callback) {
         // FIXME: Log error or assert.
         return;
@@ -1819,11 +1835,8 @@ void WebPageProxy::processDidCrash()
 
     m_toolTip = String();
 
-    invalidateCallbackMap(m_contentsAsStringCallbacks);
-    invalidateCallbackMap(m_frameSourceCallbacks);
-    invalidateCallbackMap(m_renderTreeExternalRepresentationCallbacks);
-    invalidateCallbackMap(m_scriptReturnValueCallbacks);
-    invalidateCallbackMap(m_webArchiveCallbacks);
+    invalidateCallbackMap(m_dataCallbacks);
+    invalidateCallbackMap(m_stringCallbacks);
 
     Vector<WebEditCommandProxy*> editCommandVector;
     copyToVector(m_editCommandSet, editCommandVector);
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 18c191a..1b10fc1 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -96,10 +96,7 @@ struct PlatformPopupMenuData;
 struct WebPageCreationParameters;
 struct WebPopupItem;
 
-typedef GenericCallback<WKStringRef, StringImpl*> FrameSourceCallback;
-typedef GenericCallback<WKStringRef, StringImpl*> RenderTreeExternalRepresentationCallback;
-typedef GenericCallback<WKStringRef, StringImpl*> ScriptReturnValueCallback;
-typedef GenericCallback<WKStringRef, StringImpl*> ContentsAsStringCallback;
+typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
 
 class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
 public:
@@ -240,11 +237,12 @@ public:
     void hideFindUI();
     void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
 
-    void runJavaScriptInMainFrame(const String&, PassRefPtr<ScriptReturnValueCallback>);
-    void getRenderTreeExternalRepresentation(PassRefPtr<RenderTreeExternalRepresentationCallback>);
-    void getSourceForFrame(WebFrameProxy*, PassRefPtr<FrameSourceCallback>);
-    void getContentsAsString(PassRefPtr<ContentsAsStringCallback>);
-    void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<WebArchiveCallback>);
+    void runJavaScriptInMainFrame(const String&, PassRefPtr<StringCallback>);
+    void getRenderTreeExternalRepresentation(PassRefPtr<StringCallback>);
+    void getSourceForFrame(WebFrameProxy*, PassRefPtr<StringCallback>);
+    void getContentsAsString(PassRefPtr<StringCallback>);
+    void getSelectionOrContentsAsString(PassRefPtr<StringCallback>);
+    void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>);
 
     void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID);
 
@@ -395,8 +393,8 @@ private:
     void registerEditCommandForUndo(uint64_t commandID, uint32_t editAction);
     void clearAllEditCommands();
 
-#if PLATFORM(MAC)
     // Keyboard handling
+#if PLATFORM(MAC)
     void interpretKeyEvent(uint32_t eventType, Vector<WebCore::KeypressCommand>&, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines);
 #endif
     
@@ -413,6 +411,13 @@ private:
     // Context Menu.
     void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*);
 
+    // Speech.
+#if PLATFORM(MAC)
+    void getIsSpeaking(bool&);
+    void speak(const String&);
+    void stopSpeaking();
+#endif
+
     void takeFocus(bool direction);
     void setToolTip(const String&);
     void setCursor(const WebCore::Cursor&);
@@ -421,10 +426,11 @@ private:
     void didReceiveEvent(uint32_t opaqueType, bool handled);
 
     void didGetContentsAsString(const String&, uint64_t);
-    void didRunJavaScriptInMainFrame(const String&, uint64_t);
     void didGetRenderTreeExternalRepresentation(const String&, uint64_t);
+    void didGetSelectionOrContentsAsString(const String&, uint64_t);
     void didGetSourceForFrame(const String&, uint64_t);
     void didGetWebArchiveOfFrame(const CoreIPC::DataReference&, uint64_t);
+    void didRunJavaScriptInMainFrame(const String&, uint64_t);
 
     void focusedFrameChanged(uint64_t frameID);
 
@@ -467,11 +473,8 @@ private:
     RefPtr<WebInspectorProxy> m_inspector;
 #endif
 
-    HashMap<uint64_t, RefPtr<ContentsAsStringCallback> > m_contentsAsStringCallbacks;
-    HashMap<uint64_t, RefPtr<FrameSourceCallback> > m_frameSourceCallbacks;
-    HashMap<uint64_t, RefPtr<RenderTreeExternalRepresentationCallback> > m_renderTreeExternalRepresentationCallbacks;
-    HashMap<uint64_t, RefPtr<ScriptReturnValueCallback> > m_scriptReturnValueCallbacks;
-    HashMap<uint64_t, RefPtr<WebArchiveCallback> > m_webArchiveCallbacks;
+    HashMap<uint64_t, RefPtr<DataCallback> > m_dataCallbacks;
+    HashMap<uint64_t, RefPtr<StringCallback> > m_stringCallbacks;
 
     HashSet<WebEditCommandProxy*> m_editCommandSet;
 
diff --git a/WebKit2/UIProcess/WebPageProxy.messages.in b/WebKit2/UIProcess/WebPageProxy.messages.in
index 6da2f03..f8d721f 100644
--- a/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -109,13 +109,14 @@ messages -> WebPageProxy {
 
     # Callback messages.
     DidGetContentsAsString(WTF::String resultString, uint64_t callbackID)
+    DidGetSelectionOrContentsAsString(WTF::String resultString, uint64_t callbackID)
     DidGetRenderTreeExternalRepresentation(WTF::String resultString, uint64_t callbackID)
     DidGetSourceForFrame(WTF::String resultString, uint64_t callbackID)
     DidGetWebArchiveOfFrame(CoreIPC::DataReference archiveData, uint64_t callbackID)
     DidRunJavaScriptInMainFrame(WTF::String resultString, uint64_t callbackID)
 
 #if PLATFORM(MAC)
-    # Keyboard support
+    # Keyboard support messages.
     InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline> underlines)
 #endif
     
@@ -142,33 +143,40 @@ messages -> WebPageProxy {
     DidChangeCompositionSelection(bool hasChanged)
 #endif
 
-    # Find.
+    # Find messages.
     DidCountStringMatches(WTF::String string, uint32_t matchCount)
     SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut)
     DidFindString(WTF::String string, uint32_t matchCount)
     DidFailToFindString(WTF::String string)
 
-    # PopupMenu.
+    # PopupMenu messages.
     ShowPopupMenu(WebCore::IntRect rect, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data)
     HidePopupMenu()
     
-    # ContextMenu
+    # ContextMenu messages.
     ShowContextMenu(WebCore::IntPoint point, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData)
 
 #if USE(ACCELERATED_COMPOSITING)
-    # Accelerated compsiting messages.
+    # Accelerated compositing messages.
     DidChangeAcceleratedCompositing(bool compositing) -> (WebKit::DrawingAreaInfo newDrawingArea)
 #endif
 
-    # Authentication
+    # Authentication messages.
     CanAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, WebCore::ProtectionSpace protectionSpace) -> (bool canAuthenticate)
     DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
 
-    # Databases
+    # Database messages.
     ExceededDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, WTF::String databaseName, WTF::String databaseDisplayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage) -> (uint64_t newQuota)
 
-    # Complex text input support for plug-ins.
+    # Plug-in complex text input support messages.
 #if PLATFORM(MAC)
     SetComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled)
 #endif
+
+    # Speech messages.
+#if PLATFORM(MAC)
+    GetIsSpeaking() -> (bool isSpeaking)
+    Speak(WTF::String string)
+    StopSpeaking()
+#endif
 }
diff --git a/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/WebKit2/UIProcess/mac/WebPageProxyMac.mm
index 0fc3fa7..36905fb 100644
--- a/WebKit2/UIProcess/mac/WebPageProxyMac.mm
+++ b/WebKit2/UIProcess/mac/WebPageProxyMac.mm
@@ -28,6 +28,10 @@
 #include <WebCore/Language.h>
 #include <wtf/text/StringConcatenate.h>
 
+ at interface NSApplication (Details)
+- (void)speakString:(NSString *)string;
+ at end
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -90,4 +94,20 @@ String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent
     return makeString("Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent);
 }
 
+void WebPageProxy::getIsSpeaking(bool& isSpeaking)
+{
+    isSpeaking = [NSApp isSpeaking];
+}
+
+void WebPageProxy::speak(const String& string)
+{
+    NSString *convertedString = string;
+    [NSApp speakString:convertedString];
+}
+
+void WebPageProxy::stopSpeaking()
+{
+    [NSApp stopSpeaking:nil];
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
index 66277af..32d08b2 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
@@ -25,18 +25,12 @@
 
 #include "WebContextMenuClient.h"
 
+#include "NotImplemented.h"
 #include "WebPage.h"
-
 #include <WebCore/Frame.h>
 #include <WebCore/Page.h>
 #include <wtf/text/WTFString.h>
 
-#include "NotImplemented.h"
-
- at interface NSApplication (AppKitSecretsIKnowAbout)
-- (void)speakString:(NSString *)string;
- at end
-
 using namespace WebCore;
 
 namespace WebKit {
@@ -49,21 +43,25 @@ void WebContextMenuClient::lookUpInDictionary(Frame*)
 
 bool WebContextMenuClient::isSpeaking()
 {
-    return [NSApp isSpeaking];
+    return m_page->isSpeaking();
 }
 
 void WebContextMenuClient::speak(const String& string)
 {
-    [NSApp speakString:[[(NSString*)string copy] autorelease]];
+    m_page->speak(string);
 }
 
 void WebContextMenuClient::stopSpeaking()
 {
-    [NSApp stopSpeaking:nil];
+    m_page->stopSpeaking();
 }
 
 void WebContextMenuClient::searchWithSpotlight()
 {
+    // FIXME: Why do we need to search all the frames like this?
+    // Isn't there any function in WebCore that can do this?
+    // If not, can we find a place in WebCore to put this?
+
     Frame* mainFrame = m_page->corePage()->mainFrame();
     
     Frame* selectionFrame = mainFrame;
@@ -79,7 +77,9 @@ void WebContextMenuClient::searchWithSpotlight()
     if (selectedString.isEmpty())
         return;
 
-    [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:(NSString *)selectedString];
+    NSString *convertedSelectedString = selectedString;
+
+    [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:convertedSelectedString];
 }
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
index 1a9eb89..4bea928 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -278,6 +278,14 @@ String WebFrame::contentsAsString() const
     return plainText(range.get());
 }
 
+String WebFrame::selectionAsString() const 
+{
+    if (!m_coreFrame)
+        return String();
+
+    return m_coreFrame->displayStringModifiedByEncoding(m_coreFrame->editor()->selectedText());
+}
+
 bool WebFrame::isFrameSet() const
 {
     if (!m_coreFrame)
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.h b/WebKit2/WebProcess/WebPage/WebFrame.h
index f69da71..1693fe9 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.h
+++ b/WebKit2/WebProcess/WebPage/WebFrame.h
@@ -75,6 +75,7 @@ public:
 
     String source() const;
     String contentsAsString() const;
+    String selectionAsString() const;
 
     // WKBundleFrame API and SPI functions
     bool isMainFrame() const;
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 6df0ebf..f00b467 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -284,7 +284,7 @@ void WebPage::changeAcceleratedCompositingMode(WebCore::GraphicsLayer* layer)
     // drawing area types.
     DrawingAreaInfo newDrawingAreaInfo;
 
-    if (!WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::DidChangeAcceleratedCompositing(compositing), Messages::WebPageProxy::DidChangeAcceleratedCompositing::Reply(newDrawingAreaInfo), m_pageID))
+    if (!sendSync(Messages::WebPageProxy::DidChangeAcceleratedCompositing(compositing), Messages::WebPageProxy::DidChangeAcceleratedCompositing::Reply(newDrawingAreaInfo)))
         return;
     
     if (newDrawingAreaInfo.type != drawingArea()->info().type) {
@@ -926,6 +926,14 @@ void WebPage::getRenderTreeExternalRepresentation(uint64_t callbackID)
     send(Messages::WebPageProxy::DidGetRenderTreeExternalRepresentation(resultString, callbackID));
 }
 
+void WebPage::getSelectionOrContentsAsString(uint64_t callbackID)
+{
+    String resultString = m_mainFrame->selectionAsString();
+    if (resultString.isEmpty())
+        resultString = m_mainFrame->contentsAsString();
+    send(Messages::WebPageProxy::DidGetContentsAsString(resultString, callbackID));
+}
+
 void WebPage::getSourceForFrame(uint64_t frameID, uint64_t callbackID)
 {
     String resultString;
@@ -1362,4 +1370,20 @@ void WebPage::setCustomTextEncodingName(const String& encoding)
     m_page->mainFrame()->loader()->reloadWithOverrideEncoding(encoding);
 }
 
+bool WebPage::isSpeaking()
+{
+    bool result;
+    return sendSync(Messages::WebPageProxy::GetIsSpeaking(), Messages::WebPageProxy::GetIsSpeaking::Reply(result)) && result;
+}
+
+void WebPage::speak(const String& string)
+{
+    send(Messages::WebPageProxy::Speak(string));
+}
+
+void WebPage::stopSpeaking()
+{
+    send(Messages::WebPageProxy::StopSpeaking());
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index cacfd0b..81c5933 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -258,8 +258,17 @@ public:
     void firstRectForCharacterInSelectedRange(const uint64_t characterPosition, WebCore::IntRect& resultRect);
     void getSelectedText(WTF::String&);
 #endif
+
+    // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
+    // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
     void dummy(bool&);
 
+#if PLATFORM(MAC)
+    bool isSpeaking();
+    void speak(const String&);
+    void stopSpeaking();
+#endif
+
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 
@@ -309,6 +318,7 @@ private:
 
     void getContentsAsString(uint64_t callbackID);
     void getRenderTreeExternalRepresentation(uint64_t callbackID);
+    void getSelectionOrContentsAsString(uint64_t callbackID);
     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
diff --git a/WebKit2/WebProcess/WebPage/WebPage.messages.in b/WebKit2/WebProcess/WebPage/WebPage.messages.in
index 37b860f..fc7a885 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -52,6 +52,7 @@ messages -> WebPage {
     # Callbacks.
     GetRenderTreeExternalRepresentation(uint64_t callbackID)
     GetContentsAsString(uint64_t callbackID)
+    GetSelectionOrContentsAsString(uint64_t callbackID)
     GetSourceForFrame(uint64_t frameID, uint64_t callbackID)
     GetWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID)
     RunJavaScriptInMainFrame(WTF::String script, uint64_t callbackID)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list