2011-04-06 Jia Pu <jpu@apple.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 14:57:21 +0000 (14:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 14:57:21 +0000 (14:57 +0000)
        Reviewed by Darin Adler.

        [Mac] When autocorrection occurs without showing correction panel, WebCore need to post accessibility notification.
        https://bugs.webkit.org/show_bug.cgi?id=57800
        <rdar://problem/9218223>

        Defined a new accessibility notification type, AXAutocorrectionOccured. Editor::markAllMisspellingsAndBadGrammarInRanges()
        now posts said notification when any autocorrection or text replacement (e.g. replacing "(c)" with copyright mark) takes place.

        * accessibility/AXObjectCache.h:
        * accessibility/chromium/AXObjectCacheChromium.cpp:
        (WebCore::AXObjectCache::postPlatformNotification):
        * accessibility/mac/AXObjectCacheMac.mm:
        (WebCore::AXObjectCache::postPlatformNotification):
        * editing/Editor.cpp:
        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.h
Source/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
Source/WebCore/editing/Editor.cpp

index 0425382..92638e7 100644 (file)
@@ -1,3 +1,22 @@
+2011-04-06  Jia Pu  <jpu@apple.com>
+
+        Reviewed by Darin Adler.
+
+        [Mac] When autocorrection occurs without showing correction panel, WebCore need to post accessibility notification.
+        https://bugs.webkit.org/show_bug.cgi?id=57800
+        <rdar://problem/9218223>
+
+        Defined a new accessibility notification type, AXAutocorrectionOccured. Editor::markAllMisspellingsAndBadGrammarInRanges()
+        now posts said notification when any autocorrection or text replacement (e.g. replacing "(c)" with copyright mark) takes place.
+
+        * accessibility/AXObjectCache.h:
+        * accessibility/chromium/AXObjectCacheChromium.cpp:
+        (WebCore::AXObjectCache::postPlatformNotification):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+        * editing/Editor.cpp:
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+
 2011-04-06  Martin Robinson  <mrobinson@igalia.com>
 
         Build fix for debug Cairo builds.
index 4805a7f..95cc7f3 100644 (file)
@@ -118,6 +118,7 @@ public:
 
     enum AXNotification {
         AXActiveDescendantChanged,
+        AXAutocorrectionOccured,
         AXCheckedStateChanged,
         AXChildrenChanged,
         AXFocusedUIElementChanged,
index 0dddc17..b79fd0c 100644 (file)
@@ -76,6 +76,7 @@ void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotific
         // descendant and send the AXFocusedUIElementChanged notification.
         handleFocusedUIElementChanged(0, obj->document()->focusedNode()->renderer());
         break;
+    case AXAutocorrectionOccured:
     case AXCheckedStateChanged:
     case AXChildrenChanged:
     case AXFocusedUIElementChanged:
index e223bf4..27c4e93 100644 (file)
@@ -70,6 +70,13 @@ void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotific
             else
                 macNotification = NSAccessibilityFocusedUIElementChangedNotification;                
             break;
+        case AXAutocorrectionOccured:
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+            macNotification = @"AXAutocorrectionOccurred";
+            break;
+#else
+            return;
+#endif
         case AXFocusedUIElementChanged:
             macNotification = NSAccessibilityFocusedUIElementChangedNotification;
             break;
index 67f54c4..d8ad42f 100644 (file)
@@ -2385,7 +2385,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
                     replacedString = plainText(rangeToReplace.get());
 
                 bool useSpellingCorrectionCommand = false;
-#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#if SUPPORT_AUTOCORRECTION_PANEL
                 if (result->type == TextCheckingTypeCorrection)
                     useSpellingCorrectionCommand = true;
 #endif
@@ -2396,6 +2396,11 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
                     replaceSelectionWithText(result->replacement, false, false);
                 }
 
+                if (AXObjectCache::accessibilityEnabled()) {
+                    if (Element* root = m_frame->selection()->selection().rootEditableElement())
+                        m_frame->document()->axObjectCache()->postNotification(root->renderer(), AXObjectCache::AXAutocorrectionOccured, true);
+                }
+
                 selectionChanged = true;
                 offsetDueToReplacement += replacementLength - resultLength;
                 if (resultLocation < selectionOffset) {