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

andersca at apple.com andersca at apple.com
Fri Jan 21 14:58:04 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 95dcf9731648572586efa88572cb8b95d3363eca
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 5 18:28:29 2011 +0000

    2011-01-05  Anders Carlsson  <andersca at apple.com>
    
            Reviewed by Dan Bernstein.
    
            Keep track of active text substitution preferences
            https://bugs.webkit.org/show_bug.cgi?id=51931
    
            * Shared/TextCheckerState.h:
            * UIProcess/API/mac/WKView.mm:
            (-[WKView validateUserInterfaceItem:]):
            Handle new selectors, mostly copied from WebKit1 code.
    
            (-[WKView orderFrontSubstitutionsPanel:]):
            Open the substitution panel.
    
            (-[WKView isAutomaticQuoteSubstitutionEnabled]):
            (-[WKView setAutomaticQuoteSubstitutionEnabled:]):
            (-[WKView toggleAutomaticQuoteSubstitution:]):
            (-[WKView isAutomaticDashSubstitutionEnabled]):
            (-[WKView setAutomaticDashSubstitutionEnabled:]):
            (-[WKView toggleAutomaticDashSubstitution:]):
            (-[WKView isAutomaticLinkDetectionEnabled]):
            (-[WKView setAutomaticLinkDetectionEnabled:]):
            (-[WKView toggleAutomaticLinkDetection:]):
            (-[WKView isAutomaticTextReplacementEnabled]):
            (-[WKView setAutomaticTextReplacementEnabled:]):
            (-[WKView toggleAutomaticTextReplacement:]):
            Call the text checker, and update the state in the web process if needed.
    
            * UIProcess/TextChecker.h:
            Add new flags.
    
            * UIProcess/mac/TextCheckerMac.mm:
            (WebKit::initializeState):
            Initialize flags from user defaults.
    
            (WebKit::TextChecker::setAutomaticQuoteSubstitutionEnabled):
            (WebKit::TextChecker::setAutomaticDashSubstitutionEnabled):
            (WebKit::TextChecker::setAutomaticLinkDetectionEnabled):
            (WebKit::TextChecker::setAutomaticTextReplacementEnabled):
            Update and save the flags.
    
            * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
            (WebKit::WebEditorClient::isAutomaticQuoteSubstitutionEnabled):
            (WebKit::WebEditorClient::isAutomaticLinkDetectionEnabled):
            (WebKit::WebEditorClient::isAutomaticDashSubstitutionEnabled):
            (WebKit::WebEditorClient::isAutomaticTextReplacementEnabled):
            Get the text checker state.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75079 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 899eee2..147d9cc 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,52 @@
+2011-01-05  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Keep track of active text substitution preferences
+        https://bugs.webkit.org/show_bug.cgi?id=51931
+
+        * Shared/TextCheckerState.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView validateUserInterfaceItem:]):
+        Handle new selectors, mostly copied from WebKit1 code.
+
+        (-[WKView orderFrontSubstitutionsPanel:]):
+        Open the substitution panel.
+
+        (-[WKView isAutomaticQuoteSubstitutionEnabled]):
+        (-[WKView setAutomaticQuoteSubstitutionEnabled:]):
+        (-[WKView toggleAutomaticQuoteSubstitution:]):
+        (-[WKView isAutomaticDashSubstitutionEnabled]):
+        (-[WKView setAutomaticDashSubstitutionEnabled:]):
+        (-[WKView toggleAutomaticDashSubstitution:]):
+        (-[WKView isAutomaticLinkDetectionEnabled]):
+        (-[WKView setAutomaticLinkDetectionEnabled:]):
+        (-[WKView toggleAutomaticLinkDetection:]):
+        (-[WKView isAutomaticTextReplacementEnabled]):
+        (-[WKView setAutomaticTextReplacementEnabled:]):
+        (-[WKView toggleAutomaticTextReplacement:]):
+        Call the text checker, and update the state in the web process if needed.
+
+        * UIProcess/TextChecker.h:
+        Add new flags.
+
+        * UIProcess/mac/TextCheckerMac.mm:
+        (WebKit::initializeState):
+        Initialize flags from user defaults.
+
+        (WebKit::TextChecker::setAutomaticQuoteSubstitutionEnabled):
+        (WebKit::TextChecker::setAutomaticDashSubstitutionEnabled):
+        (WebKit::TextChecker::setAutomaticLinkDetectionEnabled):
+        (WebKit::TextChecker::setAutomaticTextReplacementEnabled):
+        Update and save the flags.
+
+        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+        (WebKit::WebEditorClient::isAutomaticQuoteSubstitutionEnabled):
+        (WebKit::WebEditorClient::isAutomaticLinkDetectionEnabled):
+        (WebKit::WebEditorClient::isAutomaticDashSubstitutionEnabled):
+        (WebKit::WebEditorClient::isAutomaticTextReplacementEnabled):
+        Get the text checker state.
+
 2011-01-05  Dan Bernstein  <mitz at apple.com>
 
         Rubber-stamped by Darin Adler.
diff --git a/WebKit2/Shared/TextCheckerState.h b/WebKit2/Shared/TextCheckerState.h
index d17ba3f..3bb5332 100644
--- a/WebKit2/Shared/TextCheckerState.h
+++ b/WebKit2/Shared/TextCheckerState.h
@@ -36,6 +36,10 @@ struct TextCheckerState {
 
 #if PLATFORM(MAC)
     bool isAutomaticSpellingCorrectionEnabled;
+    bool isAutomaticQuoteSubstitutionEnabled;
+    bool isAutomaticDashSubstitutionEnabled;
+    bool isAutomaticLinkDetectionEnabled;
+    bool isAutomaticTextReplacementEnabled;
 #endif
 };
 
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index bd20fe2..e607b54 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -377,6 +377,40 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
         return _data->_page->selectionState().isContentEditable;
     }
 
+    if (action == @selector(orderFrontSubstitutionsPanel:)) {
+        if (NSMenuItem *menuItem = ::menuItem(item)) {
+            BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible];
+            [menuItem setTitle:panelShowing
+                ? UI_STRING("Hide Substitutions", "menu item title")
+                : UI_STRING("Show Substitutions", "menu item title")];
+        }
+        return _data->_page->selectionState().isContentEditable;
+    }
+
+    if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
+        bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
+        [menuItem(item) setState:checked ? NSOnState : NSOffState];
+        return _data->_page->selectionState().isContentEditable;
+    }
+
+    if (action == @selector(toggleAutomaticDashSubstitution:)) {
+        bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled;
+        [menuItem(item) setState:checked ? NSOnState : NSOffState];
+        return _data->_page->selectionState().isContentEditable;
+    }
+
+    if (action == @selector(toggleAutomaticLinkDetection:)) {
+        bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled;
+        [menuItem(item) setState:checked ? NSOnState : NSOffState];
+        return _data->_page->selectionState().isContentEditable;
+    }
+
+    if (action == @selector(toggleAutomaticTextReplacement:)) {
+        bool checked = TextChecker::state().isAutomaticTextReplacementEnabled;
+        [menuItem(item) setState:checked ? NSOnState : NSOffState];
+        return _data->_page->selectionState().isContentEditable;
+    }
+
     if (action == @selector(stopSpeaking:))
         return [NSApp isSpeaking];
 
@@ -463,6 +497,102 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
     _data->_page->process()->updateTextCheckerState();
 }
 
+- (void)orderFrontSubstitutionsPanel:(id)sender
+{
+    NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
+    if (!checker) {
+        LOG_ERROR("No NSSpellChecker");
+        return;
+    }
+    
+    NSPanel *substitutionsPanel = [checker substitutionsPanel];
+    if ([substitutionsPanel isVisible]) {
+        [substitutionsPanel orderOut:sender];
+        return;
+    }
+    [substitutionsPanel orderFront:sender];
+}
+
+- (BOOL)isAutomaticQuoteSubstitutionEnabled
+{
+    return TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
+}
+
+- (void)setAutomaticQuoteSubstitutionEnabled:(BOOL)flag
+{
+    if (static_cast<bool>(flag) == TextChecker::state().isAutomaticQuoteSubstitutionEnabled)
+        return;
+
+    TextChecker::setAutomaticQuoteSubstitutionEnabled(flag);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticQuoteSubstitution:(id)sender
+{
+    TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isAutomaticDashSubstitutionEnabled
+{
+    return TextChecker::state().isAutomaticDashSubstitutionEnabled;
+}
+
+- (void)setAutomaticDashSubstitutionEnabled:(BOOL)flag
+{
+    if (static_cast<bool>(flag) == TextChecker::state().isAutomaticDashSubstitutionEnabled)
+        return;
+
+    TextChecker::setAutomaticDashSubstitutionEnabled(flag);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticDashSubstitution:(id)sender
+{
+    TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isAutomaticLinkDetectionEnabled
+{
+    return TextChecker::state().isAutomaticLinkDetectionEnabled;
+}
+
+- (void)setAutomaticLinkDetectionEnabled:(BOOL)flag
+{
+    if (static_cast<bool>(flag) == TextChecker::state().isAutomaticLinkDetectionEnabled)
+        return;
+
+    TextChecker::setAutomaticLinkDetectionEnabled(flag);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticLinkDetection:(id)sender
+{
+    TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isAutomaticTextReplacementEnabled
+{
+    return TextChecker::state().isAutomaticTextReplacementEnabled;
+}
+
+- (void)setAutomaticTextReplacementEnabled:(BOOL)flag
+{
+    if (static_cast<bool>(flag) == TextChecker::state().isAutomaticTextReplacementEnabled)
+        return;
+
+    TextChecker::setAutomaticTextReplacementEnabled(flag);
+    _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticTextReplacement:(id)sender
+{
+    TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
+    _data->_page->process()->updateTextCheckerState();
+}
+
 // Events
 
 // Override this so that AppKit will send us arrow keys as key down events so we can
diff --git a/WebKit2/UIProcess/TextChecker.h b/WebKit2/UIProcess/TextChecker.h
index 94e119d..aa5b5ca 100644
--- a/WebKit2/UIProcess/TextChecker.h
+++ b/WebKit2/UIProcess/TextChecker.h
@@ -42,6 +42,10 @@ public:
 
 #if PLATFORM(MAC)
     static void setAutomaticSpellingCorrectionEnabled(bool);
+    static void setAutomaticQuoteSubstitutionEnabled(bool);
+    static void setAutomaticDashSubstitutionEnabled(bool);
+    static void setAutomaticLinkDetectionEnabled(bool);
+    static void setAutomaticTextReplacementEnabled(bool);
 #endif
 
     static int64_t uniqueSpellDocumentTag();
diff --git a/WebKit2/UIProcess/mac/TextCheckerMac.mm b/WebKit2/UIProcess/mac/TextCheckerMac.mm
index 86dded3..fd28a8d 100644
--- a/WebKit2/UIProcess/mac/TextCheckerMac.mm
+++ b/WebKit2/UIProcess/mac/TextCheckerMac.mm
@@ -35,6 +35,10 @@
 static const NSString * const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled";
 static const NSString * const WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckingEnabled";
 static const NSString * const WebGrammarCheckingEnabled = @"WebGrammarCheckingEnabled";
+static const NSString * const WebAutomaticQuoteSubstitutionEnabled = @"WebAutomaticQuoteSubstitutionEnabled";
+static const NSString * const WebAutomaticDashSubstitutionEnabled = @"WebAutomaticDashSubstitutionEnabled";
+static const NSString * const WebAutomaticLinkDetectionEnabled = @"WebAutomaticLinkDetectionEnabled";
+static const NSString * const WebAutomaticTextReplacementEnabled = @"WebAutomaticTextReplacementEnabled";
 
 using namespace WebCore;
 
@@ -51,7 +55,11 @@ static void initializeState()
     textCheckerState.isContinuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled] && TextChecker::isContinuousSpellCheckingAllowed();
     textCheckerState.isGrammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled];
     textCheckerState.isAutomaticSpellingCorrectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticSpellingCorrectionEnabled];
-    
+    textCheckerState.isAutomaticQuoteSubstitutionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticQuoteSubstitutionEnabled];
+    textCheckerState.isAutomaticDashSubstitutionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticDashSubstitutionEnabled];
+    textCheckerState.isAutomaticLinkDetectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticLinkDetectionEnabled];
+    textCheckerState.isAutomaticTextReplacementEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticTextReplacementEnabled];
+
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
     if (![[NSUserDefaults standardUserDefaults] objectForKey:WebAutomaticSpellingCorrectionEnabled])
         textCheckerState.isAutomaticSpellingCorrectionEnabled = [NSSpellChecker isAutomaticSpellingCorrectionEnabled];
@@ -116,6 +124,50 @@ void TextChecker::setAutomaticSpellingCorrectionEnabled(bool isAutomaticSpelling
     [[NSSpellChecker sharedSpellChecker] updatePanels];
 }
 
+void TextChecker::setAutomaticQuoteSubstitutionEnabled(bool isAutomaticQuoteSubstitutionEnabled)
+{
+    if (state().isAutomaticQuoteSubstitutionEnabled == isAutomaticQuoteSubstitutionEnabled)
+        return;
+
+    textCheckerState.isAutomaticQuoteSubstitutionEnabled = isAutomaticQuoteSubstitutionEnabled;
+    [[NSUserDefaults standardUserDefaults] setBool:isAutomaticQuoteSubstitutionEnabled forKey:WebAutomaticQuoteSubstitutionEnabled];    
+    
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticDashSubstitutionEnabled(bool isAutomaticDashSubstitutionEnabled)
+{
+    if (state().isAutomaticDashSubstitutionEnabled == isAutomaticDashSubstitutionEnabled)
+        return;
+
+    textCheckerState.isAutomaticDashSubstitutionEnabled = isAutomaticDashSubstitutionEnabled;
+    [[NSUserDefaults standardUserDefaults] setBool:isAutomaticDashSubstitutionEnabled forKey:WebAutomaticDashSubstitutionEnabled];
+
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticLinkDetectionEnabled(bool isAutomaticLinkDetectionEnabled)
+{
+    if (state().isAutomaticLinkDetectionEnabled == isAutomaticLinkDetectionEnabled)
+        return;
+    
+    textCheckerState.isAutomaticLinkDetectionEnabled = isAutomaticLinkDetectionEnabled;
+    [[NSUserDefaults standardUserDefaults] setBool:isAutomaticLinkDetectionEnabled forKey:WebAutomaticLinkDetectionEnabled];
+    
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticTextReplacementEnabled(bool isAutomaticTextReplacementEnabled)
+{
+    if (state().isAutomaticTextReplacementEnabled == isAutomaticTextReplacementEnabled)
+        return;
+    
+    textCheckerState.isAutomaticTextReplacementEnabled = isAutomaticTextReplacementEnabled;
+    [[NSUserDefaults standardUserDefaults] setBool:isAutomaticTextReplacementEnabled forKey:WebAutomaticTextReplacementEnabled];
+
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
 int64_t TextChecker::uniqueSpellDocumentTag()
 {
     return [NSSpellChecker uniqueSpellDocumentTag];
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
index b1888d6..f3b7c0b 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
@@ -164,8 +164,7 @@ void WebEditorClient::toggleSmartInsertDelete()
 
 bool WebEditorClient::isAutomaticQuoteSubstitutionEnabled()
 {
-    notImplemented();
-    return false;
+    return WebProcess::shared().textCheckerState().isAutomaticQuoteSubstitutionEnabled;
 }
 
 void WebEditorClient::toggleAutomaticQuoteSubstitution()
@@ -175,8 +174,7 @@ void WebEditorClient::toggleAutomaticQuoteSubstitution()
 
 bool WebEditorClient::isAutomaticLinkDetectionEnabled()
 {
-    notImplemented();
-    return false;
+    return WebProcess::shared().textCheckerState().isAutomaticLinkDetectionEnabled;
 }
 
 void WebEditorClient::toggleAutomaticLinkDetection()
@@ -186,8 +184,7 @@ void WebEditorClient::toggleAutomaticLinkDetection()
 
 bool WebEditorClient::isAutomaticDashSubstitutionEnabled()
 {
-    notImplemented();
-    return false;
+    return WebProcess::shared().textCheckerState().isAutomaticDashSubstitutionEnabled;
 }
 
 void WebEditorClient::toggleAutomaticDashSubstitution()
@@ -197,8 +194,7 @@ void WebEditorClient::toggleAutomaticDashSubstitution()
 
 bool WebEditorClient::isAutomaticTextReplacementEnabled()
 {
-    notImplemented();
-    return false;
+    return WebProcess::shared().textCheckerState().isAutomaticTextReplacementEnabled;
 }
 
 void WebEditorClient::toggleAutomaticTextReplacement()
@@ -221,7 +217,6 @@ void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, uint64
     // 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));
 }
-
 #endif
 
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list