Title: [166649] trunk
Revision
166649
Author
[email protected]
Date
2014-04-02 09:31:15 -0700 (Wed, 02 Apr 2014)

Log Message

AX: Improve ARIA live region reliability by sending notifications when live regions are created/shown and hidden/destroyed
https://bugs.webkit.org/show_bug.cgi?id=124381

Reviewed by Mario Sanchez Prada.

Source/WebCore: 

Re-organize some code so that when we detect a new node has been created, we can safely determine its live region status.
If it is a live region, we fire off a live region created notification.

Test: platform/mac/accessibility/live-region-creation-notification.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleLiveRegionCreated):
(WebCore::AXObjectCache::childrenChanged):
(WebCore::AXObjectCache::handleAttributeChanged):
* accessibility/AXObjectCache.h:
(WebCore::AXObjectCache::childrenChanged):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::defaultLiveRegionStatusForRole):
(WebCore::AccessibilityObject::liveRegionStatusIsEnabled):
(WebCore::AccessibilityObject::supportsARIALiveRegion):
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::ariaLiveRegionStatus):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::ariaLiveRegionStatus):
* accessibility/AccessibilityRenderObject.h:
* accessibility/ios/AXObjectCacheIOS.mm:
(WebCore::AXObjectCache::postPlatformNotification):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.h:
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper postLiveRegionCreatedNotification]):
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::postPlatformNotification):

LayoutTests: 

* platform/mac/accessibility/live-region-creation-notification.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (166648 => 166649)


--- trunk/LayoutTests/ChangeLog	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/LayoutTests/ChangeLog	2014-04-02 16:31:15 UTC (rev 166649)
@@ -1,3 +1,12 @@
+2014-04-02  Chris Fleizach  <[email protected]>
+
+        AX: Improve ARIA live region reliability by sending notifications when live regions are created/shown and hidden/destroyed
+        https://bugs.webkit.org/show_bug.cgi?id=124381
+
+        Reviewed by Mario Sanchez Prada.
+
+        * platform/mac/accessibility/live-region-creation-notification.html: Added.
+
 2014-04-02  David Kilzer  <[email protected]>
 
         Add LayoutTest for crash with bidi isolates

Added: trunk/LayoutTests/platform/mac/accessibility/live-region-creation-notification.html (0 => 166649)


--- trunk/LayoutTests/platform/mac/accessibility/live-region-creation-notification.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/live-region-creation-notification.html	2014-04-02 16:31:15 UTC (rev 166649)
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+    
+<div id="content">
+<div id="first" role="log"></div>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    
+description("This tests that the AXLiveRegionCreated notification gets fired when live regions appear.");
+var notification = 0;
+var element = 0;
+
+function startTest() {
+    
+    var HIDE = true;
+    
+    // add second live region immediately
+    appendLiveRegion('second');
+    
+    // add third live region later
+    window.setTimeout(function() { 
+        appendLiveRegion('third'); 
+        window.setTimeout(function() { 
+            appendLiveRegion('fourth', HIDE); 
+            window.setTimeout(function() { 
+                unhide('fourth'); 
+                window.setTimeout(function() { 
+                    appendDiv('fifth'); 
+                    window.setTimeout(updateAll, 1);
+                }, 1);
+            }, 1);
+        }, 1);
+    }, 1);
+}
+
+var $ = function(id) {
+    return document.getElementById(id);
+}
+
+var updateAll = function() {
+    window.setTimeout(function() { 
+        updateLiveRegion('first'); 
+        window.setTimeout(function() { 
+            updateLiveRegion('second'); 
+            window.setTimeout(function() { 
+                updateLiveRegion('third'); 
+                window.setTimeout(function() { 
+                    updateLiveRegion('fourth'); 
+                    window.setTimeout(function() { endTest(); }, 1);
+                }, 1);
+            }, 1);
+        }, 1);
+    }, 1);
+    
+}
+var updateLiveRegion = function(id) {
+    var lr = $(id);
+    lr.innerHTML = id;
+}
+var appendLiveRegion = function(id, optHide) {
+    var lr = document.createElement('div');
+    lr.id = id;
+    lr.setAttribute('role', 'log');
+    if (optHide) {
+        lr.hidden = true;
+    }
+    $("content").appendChild(lr);
+}
+var appendDiv = function(id) {
+    var lr = document.createElement('div');
+    lr.id = id;
+    lr.setAttribute('role', 'group');
+    $("content").appendChild(lr);
+}
+var unhide = function(id){
+    $(id).hidden = false;
+}
+
+function ariaCallback(element, notification) {
+    if (notification == "AXLiveRegionCreated") {
+       debug("PASS Received live region created notification: " + notification + ": " + element.stringAttributeValue('AXDOMIdentifier'));
+    }
+}
+
+function endTest() {
+   document.getElementById("content").style.display = 'none';
+   finishJSTest();
+}
+
+window.jsTestIsAsync = true;
+if (window.accessibilityController) {
+    var addedNotification = accessibilityController.addNotificationListener(ariaCallback);
+
+    // Make sure AX is enabled by accessing root element.
+    accessibilityController.rootElement;
+
+    startTest();
+}
+successfullyParsed = true;
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (166648 => 166649)


--- trunk/Source/WebCore/ChangeLog	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/ChangeLog	2014-04-02 16:31:15 UTC (rev 166649)
@@ -1,3 +1,38 @@
+2014-04-02  Chris Fleizach  <[email protected]>
+
+        AX: Improve ARIA live region reliability by sending notifications when live regions are created/shown and hidden/destroyed
+        https://bugs.webkit.org/show_bug.cgi?id=124381
+
+        Reviewed by Mario Sanchez Prada.
+
+        Re-organize some code so that when we detect a new node has been created, we can safely determine its live region status.
+        If it is a live region, we fire off a live region created notification.
+
+        Test: platform/mac/accessibility/live-region-creation-notification.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::handleLiveRegionCreated):
+        (WebCore::AXObjectCache::childrenChanged):
+        (WebCore::AXObjectCache::handleAttributeChanged):
+        * accessibility/AXObjectCache.h:
+        (WebCore::AXObjectCache::childrenChanged):
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::defaultLiveRegionStatusForRole):
+        (WebCore::AccessibilityObject::liveRegionStatusIsEnabled):
+        (WebCore::AccessibilityObject::supportsARIALiveRegion):
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::ariaLiveRegionStatus):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::ariaLiveRegionStatus):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/ios/AXObjectCacheIOS.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.h:
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper postLiveRegionCreatedNotification]):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+
 2014-04-02  Martin Robinson  <[email protected]>
 
         REGRESSION(r165704): [GTK] Inspector resources not correctly generated

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (166648 => 166649)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2014-04-02 16:31:15 UTC (rev 166649)
@@ -636,8 +636,30 @@
     postNotification(getOrCreate(node), &document(), AXMenuOpened);
 }
     
-void AXObjectCache::childrenChanged(Node* node)
+void AXObjectCache::handleLiveRegionCreated(Node* node)
 {
+    if (!node || !node->renderer() || !node->isElementNode())
+        return;
+    
+    Element* element = toElement(node);
+    String liveRegionStatus = element->fastGetAttribute(aria_liveAttr);
+    if (liveRegionStatus.isEmpty()) {
+        const AtomicString& ariaRole = element->fastGetAttribute(roleAttr);
+        if (!ariaRole.isEmpty())
+            liveRegionStatus = AccessibilityObject::defaultLiveRegionStatusForRole(AccessibilityObject::ariaRoleToWebCoreRole(ariaRole));
+    }
+    
+    if (AccessibilityObject::liveRegionStatusIsEnabled(liveRegionStatus))
+        postNotification(getOrCreate(node), &document(), AXLiveRegionCreated);
+}
+    
+void AXObjectCache::childrenChanged(Node* node, Node* newChild)
+{
+    if (newChild) {
+        handleMenuOpened(newChild);
+        handleLiveRegionCreated(newChild);
+    }
+    
     childrenChanged(get(node));
 }
 
@@ -645,8 +667,11 @@
 {
     if (!renderer)
         return;
-    if (newChild)
+    
+    if (newChild) {
         handleMenuOpened(newChild->node());
+        handleLiveRegionCreated(newChild->node());
+    }
     
     childrenChanged(get(renderer));
 }
@@ -899,7 +924,7 @@
     else if (attrName == aria_expandedAttr)
         handleAriaExpandedChange(element);
     else if (attrName == aria_hiddenAttr)
-        childrenChanged(element->parentNode());
+        childrenChanged(element->parentNode(), element);
     else if (attrName == aria_invalidAttr)
         postNotification(element, AXObjectCache::AXInvalidStatusChanged);
     else

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (166648 => 166649)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2014-04-02 16:31:15 UTC (rev 166649)
@@ -104,7 +104,7 @@
 
     void detachWrapper(AccessibilityObject*, AccessibilityDetachmentType);
     void attachWrapper(AccessibilityObject*);
-    void childrenChanged(Node*);
+    void childrenChanged(Node*, Node* newChild = nullptr);
     void childrenChanged(RenderObject*, RenderObject* newChild = nullptr);
     void childrenChanged(AccessibilityObject*);
     void checkedStateChanged(Node*);
@@ -169,6 +169,7 @@
         AXSelectedTextChanged,
         AXValueChanged,
         AXScrolledToAnchor,
+        AXLiveRegionCreated,
         AXLiveRegionChanged,
         AXMenuListItemSelected,
         AXMenuListValueChanged,
@@ -243,6 +244,7 @@
     Vector<std::pair<RefPtr<AccessibilityObject>, AXNotification>> m_notificationsToPost;
     void notificationPostTimerFired(Timer<AXObjectCache>&);
     void handleMenuOpened(Node*);
+    void handleLiveRegionCreated(Node*);
     void handleMenuItemSelected(Node*);
     
     static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*);
@@ -288,7 +290,7 @@
 inline void AXObjectCache::attachWrapper(AccessibilityObject*) { }
 inline void AXObjectCache::checkedStateChanged(Node*) { }
 inline void AXObjectCache::childrenChanged(RenderObject*, RenderObject*) { }
-inline void AXObjectCache::childrenChanged(Node*) { }
+inline void AXObjectCache::childrenChanged(Node*, Node*) { }
 inline void AXObjectCache::childrenChanged(AccessibilityObject*) { }
 inline void AXObjectCache::textChanged(RenderObject*) { }
 inline void AXObjectCache::textChanged(Node*) { }

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (166648 => 166649)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-04-02 16:31:15 UTC (rev 166649)
@@ -1489,7 +1489,24 @@
             obj->ariaTreeRows(result);
     }    
 }
-
+    
+const String AccessibilityObject::defaultLiveRegionStatusForRole(AccessibilityRole role)
+{
+    switch (role) {
+    case ApplicationAlertDialogRole:
+    case ApplicationAlertRole:
+        return ASCIILiteral("assertive");
+    case ApplicationLogRole:
+    case ApplicationStatusRole:
+        return ASCIILiteral("polite");
+    case ApplicationTimerRole:
+    case ApplicationMarqueeRole:
+        return ASCIILiteral("off");
+    default:
+        return nullAtom;
+    }
+}
+    
 #if HAVE(ACCESSIBILITY)
 const String& AccessibilityObject::actionVerb() const
 {
@@ -1825,10 +1842,14 @@
         || hasAttribute(aria_relevantAttr);
 }
     
+bool AccessibilityObject::liveRegionStatusIsEnabled(const AtomicString& liveRegionStatus)
+{
+    return equalIgnoringCase(liveRegionStatus, "polite") || equalIgnoringCase(liveRegionStatus, "assertive");
+}
+    
 bool AccessibilityObject::supportsARIALiveRegion() const
 {
-    const AtomicString& liveRegion = ariaLiveRegionStatus();
-    return equalIgnoringCase(liveRegion, "polite") || equalIgnoringCase(liveRegion, "assertive");
+    return liveRegionStatusIsEnabled(ariaLiveRegionStatus());
 }
 
 AccessibilityObject* AccessibilityObject::elementAccessibilityHitTest(const IntPoint& point) const

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (166648 => 166649)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2014-04-02 16:31:15 UTC (rev 166649)
@@ -837,10 +837,12 @@
     // ARIA live-region features.
     bool supportsARIALiveRegion() const;
     bool isInsideARIALiveRegion() const;
-    virtual const AtomicString& ariaLiveRegionStatus() const { return nullAtom; }
+    virtual const String ariaLiveRegionStatus() const { return String(); }
     virtual const AtomicString& ariaLiveRegionRelevant() const { return nullAtom; }
     virtual bool ariaLiveRegionAtomic() const { return false; }
     virtual bool ariaLiveRegionBusy() const { return false; }
+    static const String defaultLiveRegionStatusForRole(AccessibilityRole);
+    static bool liveRegionStatusIsEnabled(const AtomicString&);
     
     bool supportsARIAAttributes() const;
     

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (166648 => 166649)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2014-04-02 16:31:15 UTC (rev 166649)
@@ -3049,29 +3049,12 @@
     return AccessibilityNodeObject::canHaveChildren();
 }
 
-const AtomicString& AccessibilityRenderObject::ariaLiveRegionStatus() const
+const String AccessibilityRenderObject::ariaLiveRegionStatus() const
 {
-    static NeverDestroyed<const AtomicString> liveRegionStatusAssertive("assertive", AtomicString::ConstructFromLiteral);
-    static NeverDestroyed<const AtomicString> liveRegionStatusPolite("polite", AtomicString::ConstructFromLiteral);
-    static NeverDestroyed<const AtomicString> liveRegionStatusOff("off", AtomicString::ConstructFromLiteral);
-    
     const AtomicString& liveRegionStatus = getAttribute(aria_liveAttr);
     // These roles have implicit live region status.
-    if (liveRegionStatus.isEmpty()) {
-        switch (roleValue()) {
-        case ApplicationAlertDialogRole:
-        case ApplicationAlertRole:
-            return liveRegionStatusAssertive;
-        case ApplicationLogRole:
-        case ApplicationStatusRole:
-            return liveRegionStatusPolite;
-        case ApplicationTimerRole:
-        case ApplicationMarqueeRole:
-            return liveRegionStatusOff;
-        default:
-            break;
-        }
-    }
+    if (liveRegionStatus.isEmpty())
+        return defaultLiveRegionStatusForRole(roleValue());
 
     return liveRegionStatus;
 }

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (166648 => 166649)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2014-04-02 16:31:15 UTC (rev 166649)
@@ -278,7 +278,7 @@
     
     virtual ESpeak speakProperty() const override;
     
-    virtual const AtomicString& ariaLiveRegionStatus() const override;
+    virtual const String ariaLiveRegionStatus() const override;
     virtual const AtomicString& ariaLiveRegionRelevant() const override;
     virtual bool ariaLiveRegionAtomic() const override;
     virtual bool ariaLiveRegionBusy() const override;

Modified: trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm (166648 => 166649)


--- trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/ios/AXObjectCacheIOS.mm	2014-04-02 16:31:15 UTC (rev 166649)
@@ -70,6 +70,9 @@
         case AXLiveRegionChanged:
             [obj->wrapper() postLiveRegionChangeNotification];
             break;
+        case AXLiveRegionCreated:
+            [obj->wrapper() postLiveRegionCreatedNotification];
+            break;
         case AXChildrenChanged:
             [obj->wrapper() postChildrenChangedNotification];
             break;

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h (166648 => 166649)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h	2014-04-02 16:31:15 UTC (rev 166649)
@@ -60,6 +60,7 @@
 - (void)postLoadCompleteNotification;
 - (void)postChildrenChangedNotification;
 - (void)postInvalidStatusChangedNotification;
+- (void)postLiveRegionCreatedNotification;
 
 @end
 

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (166648 => 166649)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2014-04-02 16:31:15 UTC (rev 166649)
@@ -1367,6 +1367,11 @@
     // The UIKit accessibility wrapper will override and post appropriate notification.    
 }
 
+- (void)postLiveRegionCreatedNotification
+{
+    // The UIKit accessibility wrapper will override and post appropriate notification.    
+}
+
 - (void)postLoadCompleteNotification
 {
     // The UIKit accessibility wrapper will override and post appropriate notification.    

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (166648 => 166649)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2014-04-02 15:38:40 UTC (rev 166648)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2014-04-02 16:31:15 UTC (rev 166649)
@@ -39,6 +39,10 @@
 #define NSAccessibilityLiveRegionChangedNotification @"AXLiveRegionChanged"
 #endif
 
+#ifndef NSAccessibilityLiveRegionCreatedNotification 
+#define NSAccessibilityLiveRegionCreatedNotification @"AXLiveRegionCreated"
+#endif
+
 // The simple Cocoa calls in this file don't throw exceptions.
 
 namespace WebCore {
@@ -103,6 +107,9 @@
         case AXValueChanged:
             macNotification = NSAccessibilityValueChangedNotification;
             break;
+        case AXLiveRegionCreated:
+            macNotification = NSAccessibilityLiveRegionCreatedNotification;
+            break;
         case AXLiveRegionChanged:
             macNotification = NSAccessibilityLiveRegionChangedNotification;
             break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to