[Mac] WebKit doesn't enable or disable autocorrections when system preferences are...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2013 01:54:27 +0000 (01:54 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2013 01:54:27 +0000 (01:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115463

Reviewed by Darin Adler.

Source/WebKit/mac:

Observe the default notification center for changes to autocorrection preferences.
Note system preferences may also update WebAutomatic* defaults.

* WebView/WebView.mm:
(+[WebView initialize]):
(+[WebView _shouldAutomaticTextReplacementBeEnabled]):
(+[WebView _didChangeAutomaticTextReplacementEnabled:]):
(+[WebView _shouldAutomaticSpellingCorrectionBeEnabled]):
(+[WebView _didChangeAutomaticSpellingCorrectionEnabled:]):
(+[WebView _shouldAutomaticQuoteSubstitutionBeEnabled]):
(+[WebView _shouldAutomaticDashSubstitutionBeEnabled]):
(+[WebView _didChangeAutomaticQuoteSubstitutionEnabled:]):
(+[WebView _didChangeAutomaticDashSubstitutionEnabled:]):

Source/WebKit2:

Observe the default notification center and propagate the changes to TextCheckerState and
to all WebProcesses when system preferences are updated.

* UIProcess/TextChecker.h:
* UIProcess/WebContext.h:
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::shouldAutomaticTextReplacementBeEnabled):
(WebKit::shouldAutomaticSpellingCorrectionBeEnabled):
(WebKit::shouldAutomaticQuoteSubstitutionBeEnabled):
(WebKit::shouldAutomaticDashSubstitutionBeEnabled):
(WebKit::initializeState):
(WebKit::TextChecker::didChangeAutomaticTextReplacementEnabled):
(WebKit::TextChecker::didChangeAutomaticSpellingCorrectionEnabled):
(WebKit::TextChecker::didChangeAutomaticQuoteSubstitutionEnabled):
(WebKit::TextChecker::didChangeAutomaticDashSubstitutionEnabled):
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::registerNotificationObservers):
(WebKit::WebContext::unregisterNotificationObservers):

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/TextChecker.h
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
Source/WebKit2/UIProcess/mac/WebContextMac.mm

index 27481fa01f049dfaa29e8b18bbdee64bba2a694b..9dcc116ce098062913c66a25af04e8b805e0979a 100644 (file)
@@ -1,3 +1,24 @@
+2011-05-01  Ryosuke Niwa  <rniwa@webkit.org>
+
+        [Mac] WebKit doesn't enable or disable autocorrections when system preferences are changed
+        https://bugs.webkit.org/show_bug.cgi?id=115463
+
+        Reviewed by Darin Adler.
+
+        Observe the default notification center for changes to autocorrection preferences.
+        Note system preferences may also update WebAutomatic* defaults.
+
+        * WebView/WebView.mm:
+        (+[WebView initialize]):
+        (+[WebView _shouldAutomaticTextReplacementBeEnabled]):
+        (+[WebView _didChangeAutomaticTextReplacementEnabled:]):
+        (+[WebView _shouldAutomaticSpellingCorrectionBeEnabled]):
+        (+[WebView _didChangeAutomaticSpellingCorrectionEnabled:]):
+        (+[WebView _shouldAutomaticQuoteSubstitutionBeEnabled]):
+        (+[WebView _shouldAutomaticDashSubstitutionBeEnabled]):
+        (+[WebView _didChangeAutomaticQuoteSubstitutionEnabled:]):
+        (+[WebView _didChangeAutomaticDashSubstitutionEnabled:]):
+
 2013-05-01  Benjamin Poulain  <bpoulain@apple.com>
 
         Fix the function names of r149453
index c85b9082c3a56a9f1d91cd2598a182057fddc22f..57f997671e11248bc32eb9a8e6191b5227a66bf0 100644 (file)
@@ -3136,7 +3136,7 @@ static Vector<String> toStringVector(NSArray* patterns)
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_cacheModelChangedNotification:) name:WebPreferencesCacheModelChangedInternalNotification object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesRemovedNotification:) name:WebPreferencesRemovedNotification object:nil];    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesRemovedNotification:) name:WebPreferencesRemovedNotification object:nil];
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
@@ -3149,20 +3149,87 @@ static Vector<String> toStringVector(NSArray* patterns)
 
     Font::setDefaultTypesettingFeatures([defaults boolForKey:WebKitKerningAndLigaturesEnabledByDefaultDefaultsKey] ? Kerning | Ligatures : 0);
 
-    automaticQuoteSubstitutionEnabled = [defaults boolForKey:WebAutomaticQuoteSubstitutionEnabled];
+    automaticQuoteSubstitutionEnabled = [self _shouldAutomaticQuoteSubstitutionBeEnabled];
     automaticLinkDetectionEnabled = [defaults boolForKey:WebAutomaticLinkDetectionEnabled];
-    automaticDashSubstitutionEnabled = [defaults boolForKey:WebAutomaticDashSubstitutionEnabled];
-    automaticTextReplacementEnabled = [defaults boolForKey:WebAutomaticTextReplacementEnabled];
-    automaticSpellingCorrectionEnabled = [defaults boolForKey:WebAutomaticSpellingCorrectionEnabled];
+    automaticDashSubstitutionEnabled = [self _shouldAutomaticDashSubstitutionBeEnabled];
+    automaticTextReplacementEnabled = [self _shouldAutomaticTextReplacementBeEnabled];
+    automaticSpellingCorrectionEnabled = [self _shouldAutomaticSpellingCorrectionBeEnabled];
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeAutomaticTextReplacementEnabled:)
+        name:NSSpellCheckerDidChangeAutomaticTextReplacementNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeAutomaticSpellingCorrectionEnabled:)
+        name:NSSpellCheckerDidChangeAutomaticSpellingCorrectionNotification object:nil];
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeAutomaticQuoteSubstitutionEnabled:)
+        name:NSSpellCheckerDidChangeAutomaticQuoteSubstitutionNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeAutomaticDashSubstitutionEnabled:)
+        name:NSSpellCheckerDidChangeAutomaticDashSubstitutionNotification object:nil];
+#endif
+}
+
++ (BOOL)_shouldAutomaticTextReplacementBeEnabled
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     if (![defaults objectForKey:WebAutomaticTextReplacementEnabled])
-        automaticTextReplacementEnabled = [NSSpellChecker isAutomaticTextReplacementEnabled];
+        return [NSSpellChecker isAutomaticTextReplacementEnabled];
+    return [defaults boolForKey:WebAutomaticTextReplacementEnabled];
+}
+
++ (void)_didChangeAutomaticTextReplacementEnabled:(NSNotification *)notification
+{
+    automaticTextReplacementEnabled = [self _shouldAutomaticTextReplacementBeEnabled];
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
++ (BOOL)_shouldAutomaticSpellingCorrectionBeEnabled
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     if (![defaults objectForKey:WebAutomaticSpellingCorrectionEnabled])
-        automaticSpellingCorrectionEnabled = [NSSpellChecker isAutomaticSpellingCorrectionEnabled];
+        return [NSSpellChecker isAutomaticTextReplacementEnabled];
+    return [defaults boolForKey:WebAutomaticSpellingCorrectionEnabled];
+}
+
++ (void)_didChangeAutomaticSpellingCorrectionEnabled:(NSNotification *)notification
+{
+    automaticSpellingCorrectionEnabled = [self _shouldAutomaticSpellingCorrectionBeEnabled];
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
++ (BOOL)_shouldAutomaticQuoteSubstitutionBeEnabled
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    if (![defaults objectForKey:WebAutomaticQuoteSubstitutionEnabled])
+        return [NSSpellChecker isAutomaticQuoteSubstitutionEnabled];
+#endif
+    return [defaults boolForKey:WebAutomaticQuoteSubstitutionEnabled];
+}
+
++ (BOOL)_shouldAutomaticDashSubstitutionBeEnabled
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    if (![defaults objectForKey:WebAutomaticDashSubstitutionEnabled])
+        return [NSSpellChecker isAutomaticDashSubstitutionEnabled];
 #endif
+    return [defaults boolForKey:WebAutomaticDashSubstitutionEnabled];
 }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
++ (void)_didChangeAutomaticQuoteSubstitutionEnabled:(NSNotification *)notification
+{
+    automaticQuoteSubstitutionEnabled = [self _shouldAutomaticQuoteSubstitutionBeEnabled];
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
++ (void)_didChangeAutomaticDashSubstitutionEnabled:(NSNotification *)notification
+{
+    automaticDashSubstitutionEnabled = [self _shouldAutomaticDashSubstitutionBeEnabled];
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+#endif
+
 + (void)_applicationWillTerminate
 {   
     applicationIsTerminating = YES;
index 54d9ff227b3ada3866669acd205b17c7785e87d1..d787243bf9db803f1c8861f9f59ec4a71e4bc811 100644 (file)
@@ -1,3 +1,29 @@
+2013-05-01  Ryosuke Niwa  <rniwa@webkit.org>
+
+        [Mac] WebKit doesn't enable or disable autocorrections when system preferences are changed
+        https://bugs.webkit.org/show_bug.cgi?id=115463
+
+        Reviewed by Darin Adler.
+
+        Observe the default notification center and propagate the changes to TextCheckerState and
+        to all WebProcesses when system preferences are updated.
+
+        * UIProcess/TextChecker.h:
+        * UIProcess/WebContext.h:
+        * UIProcess/mac/TextCheckerMac.mm:
+        (WebKit::shouldAutomaticTextReplacementBeEnabled):
+        (WebKit::shouldAutomaticSpellingCorrectionBeEnabled):
+        (WebKit::shouldAutomaticQuoteSubstitutionBeEnabled):
+        (WebKit::shouldAutomaticDashSubstitutionBeEnabled):
+        (WebKit::initializeState):
+        (WebKit::TextChecker::didChangeAutomaticTextReplacementEnabled):
+        (WebKit::TextChecker::didChangeAutomaticSpellingCorrectionEnabled):
+        (WebKit::TextChecker::didChangeAutomaticQuoteSubstitutionEnabled):
+        (WebKit::TextChecker::didChangeAutomaticDashSubstitutionEnabled):
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::registerNotificationObservers):
+        (WebKit::WebContext::unregisterNotificationObservers):
+
 2013-05-01  Ryuan Choi  <ryuan.choi@samsung.com>
 
         [GTK] Fix build break after r149449
index a16cb18795bc123bde5929f215477aba0a3b41df..bd08d354d3eafdb6bcf5e0ec34f9be1513afea6f 100644 (file)
@@ -50,6 +50,11 @@ public:
     static void setAutomaticLinkDetectionEnabled(bool);
     static void setAutomaticTextReplacementEnabled(bool);
 
+    static void didChangeAutomaticTextReplacementEnabled();
+    static void didChangeAutomaticSpellingCorrectionEnabled();
+    static void didChangeAutomaticQuoteSubstitutionEnabled();
+    static void didChangeAutomaticDashSubstitutionEnabled();
+
     static bool isSmartInsertDeleteEnabled();
     static void setSmartInsertDeleteEnabled(bool);
 
index b6e02774987eee966deba797c4007b350d8ac979..c2ed8b5b9066cb9d87ee60fb8fa8fb1d3d079bdc 100644 (file)
@@ -59,6 +59,7 @@
 #endif
 
 #if PLATFORM(MAC)
+OBJC_CLASS NSObject;
 OBJC_CLASS NSString;
 #endif
 
@@ -454,9 +455,16 @@ private:
 #endif
 
 #if PLATFORM(MAC)
-    RetainPtr<CFTypeRef> m_enhancedAccessibilityObserver;
-    RetainPtr<CFTypeRef> m_customSchemeRegisteredObserver;
-    RetainPtr<CFTypeRef> m_customSchemeUnregisteredObserver;
+    RetainPtr<NSObject> m_enhancedAccessibilityObserver;
+    RetainPtr<NSObject> m_customSchemeRegisteredObserver;
+    RetainPtr<NSObject> m_customSchemeUnregisteredObserver;
+
+    RetainPtr<NSObject> m_automaticTextReplacementNotificationObserver;
+    RetainPtr<NSObject> m_automaticSpellingCorrectionNotificationObserver;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    RetainPtr<NSObject> m_automaticQuoteSubstitutionNotificationObserver;
+    RetainPtr<NSObject> m_automaticDashSubstitutionNotificationObserver;
+#endif
 #endif
 
     String m_overrideDatabaseDirectory;
index a3dcb19eb19c3dafccdb6a94cdcc00b1e99cd428..c9e3d6bc364ecac16ba40b2e4a468d9ea1543052 100644 (file)
@@ -49,22 +49,56 @@ namespace WebKit {
 
 TextCheckerState textCheckerState;
 
+static bool shouldAutomaticTextReplacementBeEnabled()
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+    if (![defaults objectForKey:WebAutomaticTextReplacementEnabled])
+        return [NSSpellChecker isAutomaticTextReplacementEnabled];
+    return [defaults boolForKey:WebAutomaticTextReplacementEnabled];
+}
+
+static bool shouldAutomaticSpellingCorrectionBeEnabled()
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+    if (![defaults objectForKey:WebAutomaticSpellingCorrectionEnabled])
+        return [NSSpellChecker isAutomaticTextReplacementEnabled];
+    return [defaults boolForKey:WebAutomaticSpellingCorrectionEnabled];
+}
+
+static bool shouldAutomaticQuoteSubstitutionBeEnabled()
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    if (![defaults objectForKey:WebAutomaticQuoteSubstitutionEnabled])
+        return [NSSpellChecker isAutomaticQuoteSubstitutionEnabled];
+#endif
+    return [defaults boolForKey:WebAutomaticQuoteSubstitutionEnabled];
+}
+
+static bool shouldAutomaticDashSubstitutionBeEnabled()
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    if (![defaults objectForKey:WebAutomaticDashSubstitutionEnabled])
+        return [NSSpellChecker isAutomaticDashSubstitutionEnabled];
+#endif
+    return [defaults boolForKey:WebAutomaticDashSubstitutionEnabled];
+}
+
 static void initializeState()
 {
-    static bool didInitializeState;
+    static bool didInitializeState = false;
+
     if (didInitializeState)
         return;
 
     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.isAutomaticTextReplacementEnabled = shouldAutomaticTextReplacementBeEnabled();
+    textCheckerState.isAutomaticSpellingCorrectionEnabled = shouldAutomaticSpellingCorrectionBeEnabled();
+    textCheckerState.isAutomaticQuoteSubstitutionEnabled = shouldAutomaticQuoteSubstitutionBeEnabled();
+    textCheckerState.isAutomaticDashSubstitutionEnabled = shouldAutomaticDashSubstitutionBeEnabled();
     textCheckerState.isAutomaticLinkDetectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticLinkDetectionEnabled];
-    textCheckerState.isAutomaticTextReplacementEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticTextReplacementEnabled];
-
-    if (![[NSUserDefaults standardUserDefaults] objectForKey:WebAutomaticSpellingCorrectionEnabled])
-        textCheckerState.isAutomaticSpellingCorrectionEnabled = [NSSpellChecker isAutomaticSpellingCorrectionEnabled];
 
     didInitializeState = true;
 }
@@ -194,6 +228,34 @@ void TextChecker::setSmartInsertDeleteEnabled(bool flag)
     [[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled];
 }
 
+void TextChecker::didChangeAutomaticTextReplacementEnabled()
+{
+    textCheckerState.isAutomaticTextReplacementEnabled = shouldAutomaticTextReplacementBeEnabled();
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::didChangeAutomaticSpellingCorrectionEnabled()
+{
+    textCheckerState.isAutomaticSpellingCorrectionEnabled = shouldAutomaticSpellingCorrectionBeEnabled();
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::didChangeAutomaticQuoteSubstitutionEnabled()
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    textCheckerState.isAutomaticQuoteSubstitutionEnabled = shouldAutomaticQuoteSubstitutionBeEnabled();
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+#endif
+}
+
+void TextChecker::didChangeAutomaticDashSubstitutionEnabled()
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    textCheckerState.isAutomaticDashSubstitutionEnabled = shouldAutomaticDashSubstitutionBeEnabled();
+    [[NSSpellChecker sharedSpellChecker] updatePanels];
+#endif
+}
+
 bool TextChecker::substitutionsPanelIsShowing()
 {
     return [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible];
index 5ff9a3bff7c8a163c7c100dff9eb15eccc98d2ba..5bdca0ecd4531da69233d9de25035bf5ca69492b 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "PluginProcessManager.h"
 #import "SharedWorkerProcessManager.h"
+#import "TextChecker.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WebKitSystemInterface.h"
@@ -510,24 +511,53 @@ void WebContext::registerNotificationObservers()
         ASSERT([scheme isKindOfClass:[NSString class]]);
         registerSchemeForCustomProtocol(scheme);
     }];
-    
+
     m_customSchemeUnregisteredObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKit::SchemeForCustomProtocolUnregisteredNotificationName object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
         NSString *scheme = [notification object];
         ASSERT([scheme isKindOfClass:[NSString class]]);
         unregisterSchemeForCustomProtocol(scheme);
     }];
-    
+
     // Listen for enhanced accessibility changes and propagate them to the WebProcess.
     m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
         setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]);
     }];
+
+    m_automaticTextReplacementNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticTextReplacementNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
+        TextChecker::didChangeAutomaticTextReplacementEnabled();
+        textCheckerStateChanged();
+    }];
+    
+    m_automaticSpellingCorrectionNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticSpellingCorrectionNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
+        TextChecker::didChangeAutomaticSpellingCorrectionEnabled();
+        textCheckerStateChanged();
+    }];
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    m_automaticQuoteSubstitutionNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticQuoteSubstitutionNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
+        TextChecker::didChangeAutomaticQuoteSubstitutionEnabled();
+        textCheckerStateChanged();
+    }];
+
+    m_automaticDashSubstitutionNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSSpellCheckerDidChangeAutomaticDashSubstitutionNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
+        TextChecker::didChangeAutomaticDashSubstitutionEnabled();
+        textCheckerStateChanged();
+    }];
+#endif
 }
 
 void WebContext::unregisterNotificationObservers()
 {
-    [[NSNotificationCenter defaultCenter] removeObserver:(id)m_customSchemeRegisteredObserver.get()];
-    [[NSNotificationCenter defaultCenter] removeObserver:(id)m_customSchemeUnregisteredObserver.get()];
-    [[NSNotificationCenter defaultCenter] removeObserver:(id)m_enhancedAccessibilityObserver.get()];
+    [[NSNotificationCenter defaultCenter] removeObserver:m_customSchemeRegisteredObserver.get()];
+    [[NSNotificationCenter defaultCenter] removeObserver:m_customSchemeUnregisteredObserver.get()];
+    [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
+    
+    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
+    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticQuoteSubstitutionNotificationObserver.get()];
+    [[NSNotificationCenter defaultCenter] removeObserver:m_automaticDashSubstitutionNotificationObserver.get()];
+#endif
 }
 
 } // namespace WebKit