WebKit2: Show the substitutions panel on Mac and make sure the menu items titles are
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Apr 2011 01:31:30 +0000 (01:31 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Apr 2011 01:31:30 +0000 (01:31 +0000)
updated correctly.
https://bugs.webkit.org/show_bug.cgi?id=58179

Reviewed by Anders Carlsson.

* 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83369 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/TextChecker.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm

index 6483dcc..ab37b28 100644 (file)
@@ -1,3 +1,36 @@
+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.
index b4f1cd2..b15ab64 100644 (file)
@@ -639,7 +639,7 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
 
     if (action == @selector(orderFrontSubstitutionsPanel:)) {
         if (NSMenuItem *menuItem = ::menuItem(item))
-            [menuItem setTitle:contextMenuItemTagShowSubstitutions([[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
+            [menuItem setTitle:contextMenuItemTagShowSubstitutions(![[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
         return _data->_page->selectionState().isContentEditable;
     }
 
index 391fa44..12af936 100644 (file)
@@ -50,6 +50,9 @@ 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);
index 5bd0172..05104d0 100644 (file)
@@ -2283,6 +2283,10 @@ 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));
@@ -2958,7 +2962,14 @@ void WebPageProxy::linkClicked(const String& url, const WebMouseEvent& event)
     process()->send(Messages::WebPage::LinkClicked(url, event), m_pageID, 0);
 }
 
-#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#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);
@@ -2978,9 +2989,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)
@@ -2988,6 +2998,6 @@ void WebPageProxy::handleCorrectionPanelResult(const String& result)
         process()->send(Messages::WebPage::HandleCorrectionPanelResult(result), m_pageID, 0);
 #endif
 }
-#endif
+#endif // PLATFORM(MAC)
 
 } // namespace WebKit
index f2dc5e5..1e1d8ee 100644 (file)
@@ -688,12 +688,15 @@ 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();
 
index 9936c00..085ec9d 100644 (file)
@@ -223,6 +223,9 @@ messages -> WebPageProxy {
     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)
index 9e0594a..c48f8d3 100644 (file)
@@ -196,6 +196,21 @@ void TextChecker::setSmartInsertDeleteEnabled(bool flag)
     [[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled];
 }
 
+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()
 {
     return [NSSpellChecker uniqueSpellDocumentTag];
index ea440fc..10db383 100644 (file)
@@ -176,8 +176,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()