Commit b54cc00f authored by cfleizach@apple.com's avatar cfleizach@apple.com

AX notifications should be an ENUM type instead of strings

https://bugs.webkit.org/show_bug.cgi?id=28963

Reviewed by Darin Adler.

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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48244 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d6bc07e0
2009-09-08 Chris Fleizach <cfleizach@apple.com>
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 <abarth@webkit.org>
Reviewed by Eric Seidel.
......@@ -339,7 +339,7 @@ void AXObjectCache::notificationPostTimerFired(Timer<AXObjectCache>*)
}
#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
......
......@@ -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<AXID, RefPtr<AccessibilityObject> > m_objects;
HashMap<RenderObject*, AXID> m_renderObjectMapping;
......@@ -107,7 +120,7 @@ namespace WebCore {
HashSet<AXID> m_idsInUse;
Timer<AXObjectCache> m_notificationPostTimer;
Vector<pair<RefPtr<AccessibilityObject>, const String> > m_notificationsToPost;
Vector<pair<RefPtr<AccessibilityObject>, AXNotification> > m_notificationsToPost;
void notificationPostTimerFired(Timer<AXObjectCache>*);
AXID getAXID(AccessibilityObject*);
......
......@@ -2174,7 +2174,7 @@ void AccessibilityRenderObject::handleActiveDescendantChanged()
AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRenderObject*>(activeDescendant());
if (activedescendant && shouldFocusActiveDescendant())
doc->axObjectCache()->postNotification(activedescendant->renderer(), "AXFocusedUIElementChanged", true);
doc->axObjectCache()->postNotification(activedescendant->renderer(), AXObjectCache::AXFocusedUIElementChanged, true);
}
......
......@@ -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)
{
}
......
......@@ -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());
......
......@@ -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*)
......
......@@ -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)
{
}
......
......@@ -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
......
......@@ -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());
}
}
......
......@@ -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())
......
......@@ -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())
......
......@@ -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
......
......@@ -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();
......
......@@ -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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment