diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 2e5a19e36a82d90c47452c5c67104494954a8f74..daa50ff7b64cacf51c607e6cf430b35f77541c11 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,43 @@ +2009-09-08 Chris Fleizach + + Reviewed by Darin Adler. + + AX notifications should be an ENUM type instead of strings + https://bugs.webkit.org/show_bug.cgi?id=28963 + + Moves AX notifications over to an ENUM type instead of + using the actual string values that are used on OS X. + + * accessibility/AXObjectCache.cpp: + (WebCore::AXObjectCache::postNotification): + (WebCore::AXObjectCache::selectedChildrenChanged): + * accessibility/AXObjectCache.h: + (WebCore::AXObjectCache::): + * accessibility/AccessibilityRenderObject.cpp: + (WebCore::AccessibilityRenderObject::handleActiveDescendantChanged): + * accessibility/chromium/AXObjectCacheChromium.cpp: + (WebCore::AXObjectCache::postPlatformNotification): + * accessibility/gtk/AXObjectCacheAtk.cpp: + (WebCore::AXObjectCache::postPlatformNotification): + * accessibility/mac/AXObjectCacheMac.mm: + (WebCore::AXObjectCache::postPlatformNotification): + * accessibility/win/AXObjectCacheWin.cpp: + (WebCore::AXObjectCache::postPlatformNotification): + * dom/Document.cpp: + (WebCore::Document::implicitClose): + * dom/Element.cpp: + (WebCore::Element::updateAfterAttributeChanged): + * editing/Editor.cpp: + (WebCore::Editor::respondToChangedContents): + * editing/mac/SelectionControllerMac.mm: + (WebCore::SelectionController::notifyAccessibilityForSelectionChange): + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::setChecked): + * page/FrameView.cpp: + (WebCore::FrameView::layout): + * rendering/RenderTextControl.cpp: + (WebCore::RenderTextControl::setInnerTextValue): + 2009-09-08 Adam Barth Reviewed by Eric Seidel. diff --git a/WebCore/accessibility/AXObjectCache.cpp b/WebCore/accessibility/AXObjectCache.cpp index f2b274c790d5ae775412afbd7dc9b6f08505b524..55199a32570deb4dac6f15f7ffc247130e0c70af 100644 --- a/WebCore/accessibility/AXObjectCache.cpp +++ b/WebCore/accessibility/AXObjectCache.cpp @@ -339,7 +339,7 @@ void AXObjectCache::notificationPostTimerFired(Timer*) } #if HAVE(ACCESSIBILITY) -void AXObjectCache::postNotification(RenderObject* renderer, const String& message, bool postToElement) +void AXObjectCache::postNotification(RenderObject* renderer, AXNotification notification, bool postToElement) { // Notifications for text input objects are sent to that object. // All others are sent to the top WebArea. @@ -367,14 +367,14 @@ void AXObjectCache::postNotification(RenderObject* renderer, const String& messa if (!obj) return; - m_notificationsToPost.append(make_pair(obj, message)); + m_notificationsToPost.append(make_pair(obj, notification)); if (!m_notificationPostTimer.isActive()) m_notificationPostTimer.startOneShot(0); } void AXObjectCache::selectedChildrenChanged(RenderObject* renderer) { - postNotification(renderer, "AXSelectedChildrenChanged", true); + postNotification(renderer, AXSelectedChildrenChanged, true); } #endif diff --git a/WebCore/accessibility/AXObjectCache.h b/WebCore/accessibility/AXObjectCache.h index 5f873e00c30583a6cb7511184b521a590bb3e3e1..4105a504d791bc148601add734bd6aed517a1fbf 100644 --- a/WebCore/accessibility/AXObjectCache.h +++ b/WebCore/accessibility/AXObjectCache.h @@ -76,8 +76,6 @@ namespace WebCore { void detachWrapper(AccessibilityObject*); void attachWrapper(AccessibilityObject*); - void postNotification(RenderObject*, const String&, bool postToElement); - void postPlatformNotification(AccessibilityObject*, const String&); void childrenChanged(RenderObject*); void selectedChildrenChanged(RenderObject*); void handleActiveDescendantChanged(RenderObject*); @@ -98,6 +96,21 @@ namespace WebCore { static void textMarkerDataForVisiblePosition(TextMarkerData&, const VisiblePosition&); static VisiblePosition visiblePositionForTextMarkerData(TextMarkerData&); + enum AXNotification { + AXCheckedStateChanged, + AXFocusedUIElementChanged, + AXLayoutComplete, + AXLoadComplete, + AXSelectedChildrenChanged, + AXSelectedTextChanged, + AXValueChanged + }; + + void postNotification(RenderObject*, AXNotification, bool postToElement); + + protected: + void postPlatformNotification(AccessibilityObject*, AXNotification); + private: HashMap > m_objects; HashMap m_renderObjectMapping; @@ -107,7 +120,7 @@ namespace WebCore { HashSet m_idsInUse; Timer m_notificationPostTimer; - Vector, const String> > m_notificationsToPost; + Vector, AXNotification> > m_notificationsToPost; void notificationPostTimerFired(Timer*); AXID getAXID(AccessibilityObject*); diff --git a/WebCore/accessibility/AccessibilityRenderObject.cpp b/WebCore/accessibility/AccessibilityRenderObject.cpp index 3a3a138b58bbb91a23afc6f3f74e7df147fd4e2e..d19e854fdd27587d4448d96a772cbd97280e7828 100644 --- a/WebCore/accessibility/AccessibilityRenderObject.cpp +++ b/WebCore/accessibility/AccessibilityRenderObject.cpp @@ -2174,7 +2174,7 @@ void AccessibilityRenderObject::handleActiveDescendantChanged() AccessibilityRenderObject* activedescendant = static_cast(activeDescendant()); if (activedescendant && shouldFocusActiveDescendant()) - doc->axObjectCache()->postNotification(activedescendant->renderer(), "AXFocusedUIElementChanged", true); + doc->axObjectCache()->postNotification(activedescendant->renderer(), AXObjectCache::AXFocusedUIElementChanged, true); } diff --git a/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp b/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp index 87f55202e707f687ec5f12688558d0d723168937..c5d1dd4bdcb0206f76629f5b1d2a7535d027e1f6 100644 --- a/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp +++ b/WebCore/accessibility/chromium/AXObjectCacheChromium.cpp @@ -43,7 +43,7 @@ void AXObjectCache::attachWrapper(AccessibilityObject*) // In Chromium, AccessibilityObjects are wrapped lazily. } -void AXObjectCache::postPlatformNotification(AccessibilityObject*, const String&) +void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { } diff --git a/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp b/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp index c7dde8ded5423a16e9710ba5f9a158997e0c6226..2e7ca66c239ffdde07b7e18b06e305b3ebda04e7 100644 --- a/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp +++ b/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp @@ -37,9 +37,9 @@ void AXObjectCache::attachWrapper(AccessibilityObject* obj) g_object_unref(atkObj); } -void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, const String& message) +void AXObjectCache::postPlatformNotification(AccessibilityObject* coreObject, AXNotification notification) { - if (message == "AXCheckedStateChanged") { + if (notification == AXCheckedStateChanged) { if (!coreObject->isCheckboxOrRadio()) return; g_signal_emit_by_name(coreObject->wrapper(), "state-change", "checked", coreObject->isChecked()); diff --git a/WebCore/accessibility/mac/AXObjectCacheMac.mm b/WebCore/accessibility/mac/AXObjectCacheMac.mm index 21307bb9bcc6c0bc9382c5a895fb65824d74a6a6..f6f7bd7bd0922211bd946ec4760a76174bbe0c0a 100644 --- a/WebCore/accessibility/mac/AXObjectCacheMac.mm +++ b/WebCore/accessibility/mac/AXObjectCacheMac.mm @@ -51,12 +51,38 @@ void AXObjectCache::attachWrapper(AccessibilityObject* obj) obj->setWrapper([[AccessibilityObjectWrapper alloc] initWithAccessibilityObject:obj]); } -void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, const String& message) +void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification) { if (!obj) return; - NSAccessibilityPostNotification(obj->wrapper(), message); + // Some notifications are unique to Safari and do not have NSAccessibility equivalents. + String macNotification; + switch (notification) { + case AXCheckedStateChanged: + macNotification = "AXCheckedStateChanged"; + break; + case AXFocusedUIElementChanged: + macNotification = NSAccessibilityFocusedUIElementChangedNotification; + break; + case AXLayoutComplete: + macNotification = "AXLayoutComplete"; + break; + case AXLoadComplete: + macNotification = "AXLoadComplete"; + break; + case AXSelectedChildrenChanged: + macNotification = NSAccessibilitySelectedChildrenChangedNotification; + break; + case AXSelectedTextChanged: + macNotification = NSAccessibilitySelectedTextChangedNotification; + break; + case AXValueChanged: + macNotification = NSAccessibilityValueChangedNotification; + break; + } + + NSAccessibilityPostNotification(obj->wrapper(), macNotification); } void AXObjectCache::handleFocusedUIElementChanged(RenderObject*, RenderObject*) diff --git a/WebCore/accessibility/win/AXObjectCacheWin.cpp b/WebCore/accessibility/win/AXObjectCacheWin.cpp index 7a84cc10acbabd4673dd1ab22e5112989dea8e64..6f0620371651c8c037dd69a693ae587afaf0eebd 100644 --- a/WebCore/accessibility/win/AXObjectCacheWin.cpp +++ b/WebCore/accessibility/win/AXObjectCacheWin.cpp @@ -51,7 +51,7 @@ void AXObjectCache::attachWrapper(AccessibilityObject*) // software requests them via get_accChild. } -void AXObjectCache::postPlatformNotification(AccessibilityObject*, const String&) +void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { } diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index e0d156046fb5dc786ac60e29d340205d2d273a61..bf22d88fb4917692ef0fee75eec8522952e914c0 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -1758,7 +1758,7 @@ void Document::implicitClose() // exists in the cache (we ignore the return value because we don't need it here). This is // only safe to call when a layout is not in progress, so it can not be used in postNotification. axObjectCache()->getOrCreate(renderObject); - axObjectCache()->postNotification(renderObject, "AXLoadComplete", true); + axObjectCache()->postNotification(renderObject, AXObjectCache::AXLoadComplete, true); } #endif diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index 1260f9b86ae2b3b051a2648c0f7c84883d36e77f..218d6bf96f7089dffca8bb83c32cdf0965a888ab 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -602,16 +602,17 @@ void Element::attributeChanged(Attribute* attr, bool) void Element::updateAfterAttributeChanged(Attribute* attr) { - if (!document()->axObjectCache()->accessibilityEnabled()) + AXObjectCache* axObjectCache = document()->axObjectCache(); + if (!axObjectCache->accessibilityEnabled()) return; const QualifiedName& attrName = attr->name(); if (attrName == aria_activedescendantAttr) { // any change to aria-activedescendant attribute triggers accessibility focus change, but document focus remains intact - document()->axObjectCache()->handleActiveDescendantChanged(renderer()); + axObjectCache->handleActiveDescendantChanged(renderer()); } else if (attrName == roleAttr) { // the role attribute can change at any time, and the AccessibilityObject must pick up these changes - document()->axObjectCache()->handleAriaRoleChanged(renderer()); + axObjectCache->handleAriaRoleChanged(renderer()); } } diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp index b9dfc5dd3c2c6781c4dc60d8930d1d2635c62a7f..3f3f736ec73b19460a1e2953d184fb7f271aa9c9 100644 --- a/WebCore/editing/Editor.cpp +++ b/WebCore/editing/Editor.cpp @@ -393,7 +393,7 @@ void Editor::respondToChangedContents(const VisibleSelection& endingSelection) if (AXObjectCache::accessibilityEnabled()) { Node* node = endingSelection.start().node(); if (node) - m_frame->document()->axObjectCache()->postNotification(node->renderer(), "AXValueChanged", false); + m_frame->document()->axObjectCache()->postNotification(node->renderer(), AXObjectCache::AXValueChanged, false); } if (client()) diff --git a/WebCore/editing/mac/SelectionControllerMac.mm b/WebCore/editing/mac/SelectionControllerMac.mm index 5970f99a5ff3222d61c12cb2fadd589e318141f4..47fb4343f103efb0b1bd66368f7b0347454cd9de 100644 --- a/WebCore/editing/mac/SelectionControllerMac.mm +++ b/WebCore/editing/mac/SelectionControllerMac.mm @@ -38,7 +38,7 @@ void SelectionController::notifyAccessibilityForSelectionChange() Document* document = m_frame->document(); if (AXObjectCache::accessibilityEnabled() && m_sel.start().isNotNull() && m_sel.end().isNotNull()) - document->axObjectCache()->postNotification(m_sel.start().node()->renderer(), "AXSelectedTextChanged", false); + document->axObjectCache()->postNotification(m_sel.start().node()->renderer(), AXObjectCache::AXSelectedTextChanged, false); // if zoom feature is enabled, insertion point changes should update the zoom if (!UAZoomEnabled() || !m_sel.isCaret()) diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp index 4ae2ec91e0d99b95301896d8ea22c7f0bae2df6e..0e98a46b5bc486bbb2ae95f60d5c41f4006252dd 100644 --- a/WebCore/html/HTMLInputElement.cpp +++ b/WebCore/html/HTMLInputElement.cpp @@ -1000,7 +1000,7 @@ void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent) // RenderTextView), but it's not possible to do it at the moment // because of the way the code is structured. if (renderer() && AXObjectCache::accessibilityEnabled()) - renderer()->document()->axObjectCache()->postNotification(renderer(), "AXCheckedStateChanged", true); + renderer()->document()->axObjectCache()->postNotification(renderer(), AXObjectCache::AXCheckedStateChanged, true); // Only send a change event for items in the document (avoid firing during // parsing) and don't send a change event for a radio button that's getting diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp index c8a0e1dab2e2a30741b3841ab9631622e5400e20..b28c32bd9637625a6c0f1ef0d62482a25a9a8735 100644 --- a/WebCore/page/FrameView.cpp +++ b/WebCore/page/FrameView.cpp @@ -649,7 +649,7 @@ void FrameView::layout(bool allowSubtree) #if PLATFORM(MAC) if (AXObjectCache::accessibilityEnabled()) - root->document()->axObjectCache()->postNotification(root, "AXLayoutComplete", true); + root->document()->axObjectCache()->postNotification(root, AXObjectCache::AXLayoutComplete, true); #endif #if ENABLE(DASHBOARD_SUPPORT) updateDashboardRegions(); diff --git a/WebCore/rendering/RenderTextControl.cpp b/WebCore/rendering/RenderTextControl.cpp index 72444bef0e99bead5f9d65a6e286553add283366..4f4b5703058fe2456d9d7dd3c52a857e0435d496 100644 --- a/WebCore/rendering/RenderTextControl.cpp +++ b/WebCore/rendering/RenderTextControl.cpp @@ -182,7 +182,7 @@ void RenderTextControl::setInnerTextValue(const String& innerTextValue) frame->editor()->clearUndoRedoOperations(); if (AXObjectCache::accessibilityEnabled()) - document()->axObjectCache()->postNotification(this, "AXValueChanged", false); + document()->axObjectCache()->postNotification(this, AXObjectCache::AXValueChanged, false); } }