WebCore:
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 01:25:52 +0000 (01:25 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 01:25:52 +0000 (01:25 +0000)
        Reviewed by Geoff Garen.

        Moved spelling-related methods from bridge to EditorClient. Added one not-yet-used
        grammar-related method.

        * bridge/EditorClient.h:
        declare isContinuousSpellCheckingEnabled(), spellCheckerDocumentTag(), and new
        isGrammarCheckingEnabled()

        * bridge/mac/WebCoreFrameBridge.h:
        removed bridge equivalents

        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::advanceToNextMisspelling):
        convert bridge-using code to editor()->client()-using code
        (WebCore::FrameMac::markMisspellingsInAdjacentWords):
        ditto
        (WebCore::FrameMac::markMisspellings):
        ditto
        (WebCore::FrameMac::respondToChangedSelection):
        ditto

        * editing/Editor.h:
        * editing/Editor.cpp:
        (WebCore::Editor::client):
        new method, returns EditorClient pointer. In an ideal world all the code that needed to
        access the EditorClient would be in Editor.cpp, and we wouldn't need this accessor.
        But for now it's too tricky to extricate the spelling-related code from FrameMac.mm.

WebKit:

        Reviewed by Geoff Garen.

        Moved spelling-related methods from bridge to EditorClient. Added one not-yet-used
        grammar-related method.

        * WebCoreSupport/WebEditorClient.h:
        declare overrides of isContinuousSpellCheckingEnabled(), spellCheckerDocumentTag(), and new
        isGrammarCheckingEnabled()
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::isContinuousSpellCheckingEnabled):
        implement by calling through to WebView
        (WebEditorClient::isGrammarCheckingEnabled):
        ditto
        (WebEditorClient::spellCheckerDocumentTag):
        ditto

        * WebCoreSupport/WebFrameBridge.mm:
        removed bridge equivalents of these methods

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

WebCore/ChangeLog
WebCore/bridge/EditorClient.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebKit/ChangeLog
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebCoreSupport/WebFrameBridge.mm

index 74e5107753169f2aa2ba5e362d86227f0994d792..2dc232b4fc1081352e27c5e41a06adaf88384b49 100644 (file)
@@ -1,3 +1,34 @@
+2006-10-30  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Geoff Garen.
+        
+        Moved spelling-related methods from bridge to EditorClient. Added one not-yet-used
+        grammar-related method.
+
+        * bridge/EditorClient.h:
+        declare isContinuousSpellCheckingEnabled(), spellCheckerDocumentTag(), and new
+        isGrammarCheckingEnabled()
+        
+        * bridge/mac/WebCoreFrameBridge.h:
+        removed bridge equivalents
+
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::advanceToNextMisspelling):
+        convert bridge-using code to editor()->client()-using code
+        (WebCore::FrameMac::markMisspellingsInAdjacentWords):
+        ditto
+        (WebCore::FrameMac::markMisspellings):
+        ditto
+        (WebCore::FrameMac::respondToChangedSelection):
+        ditto
+        
+        * editing/Editor.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::client):
+        new method, returns EditorClient pointer. In an ideal world all the code that needed to
+        access the EditorClient would be in Editor.cpp, and we wouldn't need this accessor.
+        But for now it's too tricky to extricate the spelling-related code from FrameMac.mm.
+
 2006-10-30  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Darin.
index 53ae84e69d8702d80594861741cfdbe001fc4e9f..3dc9097ce4609e0d9095fad439d99dfb4c29761a 100644 (file)
@@ -39,6 +39,10 @@ public:
 
     virtual bool shouldDeleteRange(Range *range) = 0;
     virtual bool shouldShowDeleteInterface(HTMLElement*) = 0;
+    
+    virtual bool isContinuousSpellCheckingEnabled() = 0;
+    virtual bool isGrammarCheckingEnabled() = 0;
+    virtual int spellCheckerDocumentTag() = 0;
 
 //    virtual bool shouldBeginEditingInRange(Range *range) = 0;
 //    virtual bool shouldEndEditingInRange(Range *range) = 0;
index 2ee3cef5b01cdf5f195738e770cd0731d6f23bfe..00dc5e063a61bf22aa0182b5e4db17cb0fe881f0 100644 (file)
@@ -635,7 +635,7 @@ String FrameMac::advanceToNextMisspelling(bool startBeforeSelection)
             int len = it.length();
             if (len > 1 || !DeprecatedChar(chars[0]).isSpace()) {
                 NSString *chunk = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(chars) length:len freeWhenDone:NO];
-                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:[_bridge spellCheckerDocumentTag] wordCount:NULL];
+                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag() wordCount:NULL];
                 [chunk release];
                 if (misspelling.length > 0) {
                     // Build up result range and string.  Note the misspelling may span many text nodes,
@@ -2442,7 +2442,7 @@ bool FrameMac::canPaste() const
 
 void FrameMac::markMisspellingsInAdjacentWords(const VisiblePosition &p)
 {
-    if (![_bridge isContinuousSpellCheckingEnabled])
+    if (!editor()->client()->isContinuousSpellCheckingEnabled())
         return;
     markMisspellings(Selection(startOfWord(p, LeftWordIfOnBoundary), endOfWord(p, RightWordIfOnBoundary)));
 }
@@ -2452,7 +2452,7 @@ void FrameMac::markMisspellings(const Selection& selection)
     // This function is called with a selection already expanded to word boundaries.
     // Might be nice to assert that here.
 
-    if (![_bridge isContinuousSpellCheckingEnabled])
+    if (!editor()->client()->isContinuousSpellCheckingEnabled())
         return;
 
     RefPtr<Range> searchRange(selection.toRange());
@@ -2480,7 +2480,7 @@ void FrameMac::markMisspellings(const Selection& selection)
             int startIndex = 0;
             // Loop over the chunk to find each misspelling in it.
             while (startIndex < len) {
-                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:startIndex language:nil wrap:NO inSpellDocumentWithTag:[_bridge spellCheckerDocumentTag] wordCount:NULL];
+                NSRange misspelling = [checker checkSpellingOfString:chunk startingAt:startIndex language:nil wrap:NO inSpellDocumentWithTag:editor()->client()->spellCheckerDocumentTag() wordCount:NULL];
                 if (misspelling.length == 0)
                     break;
                 else {
@@ -2507,7 +2507,7 @@ void FrameMac::markMisspellings(const Selection& selection)
 void FrameMac::respondToChangedSelection(const Selection &oldSelection, bool closeTyping)
 {
     if (document()) {
-        if ([_bridge isContinuousSpellCheckingEnabled]) {
+        if (editor()->client()->isContinuousSpellCheckingEnabled()) {
             Selection oldAdjacentWords;
             
             // If this is a change in selection resulting from a delete operation, oldSelection may no longer
index 2bdc309a1d298be25908cc2bdaf95d3382007258..d426b787ac008f6bf47d296f540439c8b0fa96fa 100644 (file)
@@ -508,9 +508,6 @@ typedef enum {
 
 - (void)windowObjectCleared;
 
-- (int)spellCheckerDocumentTag;
-- (BOOL)isContinuousSpellCheckingEnabled;
-
 - (void)dashboardRegionsChanged:(NSMutableDictionary *)regions;
 - (void)willPopupMenu:(NSMenu *)menu;
 
index 51b7954f2e640e3d1edf95ebe645a7a5a2eb7347..ab2fb852b8cdc5bcbdc8c2ec2f902ab038195fd7 100644 (file)
@@ -55,6 +55,11 @@ static Pasteboard generalPasteboard()
     return 0;
 }
 
+EditorClient* Editor::client() const
+{
+    return m_client.get();
+}
+
 bool Editor::canCopy()
 {
     return false;
index 9ab2364c84c78108ead418a60c145fffa669351c..1fc988412d28e7dd698d1f406fa2e554065966c2 100644 (file)
@@ -49,6 +49,8 @@ public:
     Editor(Frame*, PassRefPtr<EditorClient>);
     ~Editor();
 
+    EditorClient* client() const;
+
     void cut();
     void copy();
     void paste();
index 1d4c1862c7c78478bde9219bbff71c11a07bf855..0b425b7b174e5f5255ba68db08f5e17e3729c58b 100644 (file)
@@ -1,3 +1,24 @@
+2006-10-30  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Geoff Garen.
+        
+        Moved spelling-related methods from bridge to EditorClient. Added one not-yet-used
+        grammar-related method.
+
+        * WebCoreSupport/WebEditorClient.h:
+        declare overrides of isContinuousSpellCheckingEnabled(), spellCheckerDocumentTag(), and new
+        isGrammarCheckingEnabled()
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::isContinuousSpellCheckingEnabled):
+        implement by calling through to WebView
+        (WebEditorClient::isGrammarCheckingEnabled):
+        ditto
+        (WebEditorClient::spellCheckerDocumentTag):
+        ditto
+        
+        * WebCoreSupport/WebFrameBridge.mm:
+        removed bridge equivalents of these methods
+
 2006-10-30  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Beth.
index 542e7f6b838d4ee0a9468a128502f5e10c2159fa..6d05701c681514c73b2c23d5ceac3b226e7a7700 100644 (file)
@@ -37,6 +37,10 @@ public:
     ~WebEditorClient();
 
     void setWebView(WebView* webView);
+    
+    bool isGrammarCheckingEnabled();
+    bool isContinuousSpellCheckingEnabled();
+    int spellCheckerDocumentTag();
 
     bool shouldDeleteRange(WebCore::Range*);    
     bool shouldShowDeleteInterface(WebCore::HTMLElement*);
index 3b2995bab948b33126f6e2e7b3424795613f3ad2..aaeee3c08670b9f283ba0551cbc5da8395c60426 100644 (file)
@@ -51,6 +51,25 @@ void WebEditorClient::setWebView(WebView* webView)
     m_webView = webView; 
 }
 
+bool WebEditorClient::isContinuousSpellCheckingEnabled()
+{
+    return [m_webView isContinuousSpellCheckingEnabled];
+}
+
+bool WebEditorClient::isGrammarCheckingEnabled()
+{
+#ifdef BUILDING_ON_TIGER
+    return false;
+#else
+    return [m_webView isGrammarCheckingEnabled];
+#endif
+}
+
+int WebEditorClient::spellCheckerDocumentTag()
+{
+    return [m_webView spellCheckerDocumentTag];
+}
+
 bool WebEditorClient::shouldDeleteRange(WebCore::Range* range)
 {
     return [[m_webView _editingDelegateForwarder] webView:m_webView
index 47a22b31cfd94ad683d47a43bbbb6b37edc5c318..33b0af22ec3bd3080d432f96f5bba5d811d66f9c 100644 (file)
@@ -1241,16 +1241,6 @@ static id <WebFormDelegate> formDelegate(WebFrameBridge *self)
     }
 }
 
-- (int)spellCheckerDocumentTag
-{
-    return [[self webView] spellCheckerDocumentTag];
-}
-
-- (BOOL)isContinuousSpellCheckingEnabled
-{
-    return [[self webView] isContinuousSpellCheckingEnabled];
-}
-
 - (BOOL)_compareDashboardRegions:(NSDictionary *)regions
 {
     return [lastDashboardRegions isEqualToDictionary:regions];