Title: [187278] trunk
Revision
187278
Author
[email protected]
Date
2015-07-23 17:32:32 -0700 (Thu, 23 Jul 2015)

Log Message

AX: AccessibilityNodeObject::childrenChanged() generates too many AXLiveRegionChanged notifications
https://bugs.webkit.org/show_bug.cgi?id=147211
<rdar://problem/19908029>

Patch by Nan Wang <[email protected]> on 2015-07-23
Reviewed by Chris Fleizach.

Source/WebCore:

AccessibilityNodeObject::childrenChanged() can be called repeatedly, generating a live region
change notification each time. Sometimes, so many happen that VoiceOver hangs. We can use a timer
to make sure that we coalesce these notifications.

Test: platform/mac/accessibility/aria-multiple-liveregions-notification.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXComputedObjectAttributeCache::getIgnored):
(WebCore::AXObjectCache::AXObjectCache):
(WebCore::AXObjectCache::~AXObjectCache):
(WebCore::AXObjectCache::frameLoadingEventNotification):
(WebCore::AXObjectCache::postLiveRegionChangeNotification):
(WebCore::AXObjectCache::liveRegionChangedNotificationPostTimerFired):
(WebCore::AXObjectCache::handleScrollbarUpdate):
* accessibility/AXObjectCache.h:
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::childrenChanged):

LayoutTests:

* platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt:
* platform/mac/accessibility/aria-liveregions-notifications-always-sent.html:
* platform/mac/accessibility/aria-liveregions-notifications-expected.txt:
* platform/mac/accessibility/aria-liveregions-notifications.html:
* platform/mac/accessibility/aria-multiple-liveregions-notification-expected.txt: Added.
* platform/mac/accessibility/aria-multiple-liveregions-notification.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187277 => 187278)


--- trunk/LayoutTests/ChangeLog	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/LayoutTests/ChangeLog	2015-07-24 00:32:32 UTC (rev 187278)
@@ -1,3 +1,18 @@
+2015-07-23  Nan Wang  <[email protected]>
+
+        AX: AccessibilityNodeObject::childrenChanged() generates too many AXLiveRegionChanged notifications
+        https://bugs.webkit.org/show_bug.cgi?id=147211
+        <rdar://problem/19908029>
+
+        Reviewed by Chris Fleizach.
+
+        * platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt:
+        * platform/mac/accessibility/aria-liveregions-notifications-always-sent.html:
+        * platform/mac/accessibility/aria-liveregions-notifications-expected.txt:
+        * platform/mac/accessibility/aria-liveregions-notifications.html:
+        * platform/mac/accessibility/aria-multiple-liveregions-notification-expected.txt: Added.
+        * platform/mac/accessibility/aria-multiple-liveregions-notification.html: Added.
+
 2015-07-22  Simon Fraser  <[email protected]>
 
         Layer z-ordering is incorrect when scrolling on page witih position:fixed

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt (187277 => 187278)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt	2015-07-24 00:32:32 UTC (rev 187278)
@@ -5,6 +5,7 @@
 
 
 PASS addedNotification is true
+PASS liveRegionChangeCount == 3 is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent.html (187277 => 187278)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent.html	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent.html	2015-07-24 00:32:32 UTC (rev 187278)
@@ -13,23 +13,18 @@
 <div id="console"></div>
 
 <script>
+    var jsTestIsAsync = true;
 
     description("This tests that ARIA live region notifications are sent even when an assistive technology is not accessing them directly on each update.");
 
     if (window.accessibilityController) {
-        window.testRunner.waitUntilDone();
 
-        document.getElementById("liveregion").focus();
-        liveRegion = window.accessibilityController.focusedElement;
+        liveRegion = accessibilityController.accessibleElementById("liveregion");
 
         var liveRegionChangeCount = 0;
         function ariaCallback(notification) {
            if (notification == "AXLiveRegionChanged") {
                liveRegionChangeCount++;
-               if (liveRegionChangeCount == 3) {
-                   liveRegion.removeNotificationListener();
-                   window.testRunner.notifyDone();
-               }
            }
         }
         var addedNotification = liveRegion.addNotificationListener(ariaCallback);
@@ -37,11 +32,33 @@
 
         // this should trigger our live region callback for a new element.
         for (var k = 0; k < 3; k++) {
-           var textNode = document.createTextNode("test" + k);
-           document.getElementById("liveregion").appendChild(textNode);
+            // AXLiveRegionsChanged notifications are sent after a delay, so in order to ensure we 
+            // get an notification for each operation we should avoid coalescing which can occur
+            doSetTimeout(k);
         }
+
+        // add a short delay to check after all the operations if we have exactly three notificaitons
+        setTimeout("finishTest()", 200);
     }
 
+    function doSetTimeout(k) {
+        setTimeout(function() {
+            operation(k);
+        }, k * 30);
+    }
+
+    function operation(k) {
+        var textNode = document.createTextNode("test" + k);
+        document.getElementById("liveregion").appendChild(textNode);
+    }
+    
+    function finishTest() {
+        // We should get a total of three live region changes.
+        liveRegion.removeNotificationListener();
+        shouldBeTrue("liveRegionChangeCount == 3");
+        finishJSTest();
+    }
+
 </script>
 
 <script src=""

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-expected.txt (187277 => 187278)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-expected.txt	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-expected.txt	2015-07-24 00:32:32 UTC (rev 187278)
@@ -5,6 +5,7 @@
 
 
 PASS addedNotification is true
+PASS liveRegionChangeCount == 4 is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications.html (187277 => 187278)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications.html	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications.html	2015-07-24 00:32:32 UTC (rev 187278)
@@ -14,6 +14,7 @@
 <div id="console"></div>
 
 <script>
+    var jsTestIsAsync = true;
 
     description("This tests that ARIA live regions are sending out the correct notifications. We perform four operations (add, remove, change text, change alt tag), each one should trigger a live region notification");
 
@@ -22,41 +23,58 @@
     function ariaCallback(notification) {
         if (notification == "AXLiveRegionChanged") {
             liveRegionChangeCount++;
-
-            // We should get a total of 4 live region changes.
-            if (liveRegionChangeCount == 4) {
-               liveRegion.removeNotificationListener();
-               window.testRunner.notifyDone();
-            }
         }
     }
 
     if (window.accessibilityController) {
-        window.testRunner.waitUntilDone();
 
-        document.getElementById("liveregion").focus();
-        liveRegion = window.accessibilityController.focusedElement;
+        liveRegion = accessibilityController.accessibleElementById("liveregion");
 
         var addedNotification = liveRegion.addNotificationListener(ariaCallback);
         shouldBe("addedNotification", "true");
 
+        // AXLiveRegionsChanged notifications are sent after a delay, so in order to ensure we 
+        // get an notification for each operation we should avoid coalescing which can occur
+        setTimeout("textChangeOperation()", 0);
+        setTimeout("newElementOperation()", 30);
+        setTimeout("alternativeChangeOperation()", 60);
+        setTimeout("removeElementOperation()", 90);
+
+        // add a short delay to check after all the operations if we have exactly four notificaitons
+        setTimeout("finishTest()", 200);
+    }
+
+    function textChangeOperation() {
         // this should trigger our live region callback for a text change.
-        document.getElementById("innerlive").innerText = "changed text";
+        document.getElementById("liveregion").childNodes[0].innerText = "changed text";
+    }
 
+    function newElementOperation() {
         // this should trigger our live region callback for a new element.
         document.getElementById("liveregion").innerHTML += "new text element";
+    }
 
+    function alternativeChangeOperation() {
         // this should also trigger our live region change because its a text alternative change. 
         document.getElementById("image").setAttribute('alt', "new image text");
 
         // Access the accessibility tree here because AX won't post the live region change
         // notification twice when the children have already been marked as dirty.
         liveRegion.childAtIndex(0);
+    }
 
+    function removeElementOperation() {
         // this should trigger our live region callback for a removed element.
         document.getElementById("liveregion").removeChild(document.getElementById("innerlive")); 
     }
 
+    function finishTest() {
+        // We should get a total of four live region changes.
+        liveRegion.removeNotificationListener();
+        shouldBeTrue("liveRegionChangeCount == 4");
+        finishJSTest();
+    }
+
 </script>
 
 <script src=""

Added: trunk/LayoutTests/platform/mac/accessibility/aria-multiple-liveregions-notification-expected.txt (0 => 187278)


--- trunk/LayoutTests/platform/mac/accessibility/aria-multiple-liveregions-notification-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-multiple-liveregions-notification-expected.txt	2015-07-24 00:32:32 UTC (rev 187278)
@@ -0,0 +1,15 @@
+changed text
+
+new text element
+This tests that ARIA live regions are sending out the correct notifications. We perform two operations to each aria region, at the end it should trigger two live region notifications
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS addedNotification1 is true
+PASS addedNotification2 is true
+PASS liveRegionChangeCount == 2 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/accessibility/aria-multiple-liveregions-notification.html (0 => 187278)


--- trunk/LayoutTests/platform/mac/accessibility/aria-multiple-liveregions-notification.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-multiple-liveregions-notification.html	2015-07-24 00:32:32 UTC (rev 187278)
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div role="group" tabindex=0 id="liveregion1" aria-live="polite" aria-relevant="additions">
+<h3 id="innerlive">text</h3>
+</div>
+
+<div role="group" tabindex=0 id="liveregion2" aria-live="polite" aria-relevant="additions">
+<img src="" width=100 height=100 alt="alt text" tabindex=0 id="image">
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    var jsTestIsAsync = true;
+
+    description("This tests that ARIA live regions are sending out the correct notifications. We perform two operations to each aria region, at the end it should trigger two live region notifications");
+
+    var liveRegion1 = 0;
+    var liveRegion2 = 0;
+    var liveRegionChangeCount = 0;
+    function ariaCallback(notification) {
+        if (notification == "AXLiveRegionChanged") {
+            liveRegionChangeCount++;
+        }
+    }
+
+    if (window.accessibilityController) {
+
+        liveRegion1 = accessibilityController.accessibleElementById("liveregion1");
+        var addedNotification1 = liveRegion1.addNotificationListener(ariaCallback);
+        shouldBe("addedNotification1", "true");
+
+        liveRegion2 = accessibilityController.accessibleElementById("liveregion2");
+        var addedNotification2 = liveRegion2.addNotificationListener(ariaCallback);
+        shouldBe("addedNotification2", "true");
+
+        // perform operations on both live regions.
+        textChangeOperation();
+        newElementOperation();
+        alternativeChangeOperation();
+        removeElementOperation();
+
+        // add a short delay to check after all the operations if we have exactly two notificaitons
+        setTimeout("finishTest()", 10);
+    }
+
+    function textChangeOperation() {
+        // this should trigger a live region change for a text change.
+        document.getElementById("innerlive").innerText = "changed text";
+    }
+
+    function newElementOperation() {
+        // this should trigger a live region change for a new element.
+        document.getElementById("liveregion1").innerHTML += "new text element";
+    }
+
+    function alternativeChangeOperation() {
+        // this should also trigger a live region change because its a text alternative change. 
+        document.getElementById("image").setAttribute('alt', "new image text");
+    }
+
+    function removeElementOperation() {
+        // this should trigger a live region change for a removed element.
+        document.getElementById("liveregion2").removeChild(document.getElementById("image")); 
+    }
+
+    function finishTest() {
+        // We should get a total of two live region changes.
+        liveRegion1.removeNotificationListener();
+        liveRegion2.removeNotificationListener();
+        shouldBeTrue("liveRegionChangeCount == 2");
+        finishJSTest();
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (187277 => 187278)


--- trunk/Source/WebCore/ChangeLog	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/Source/WebCore/ChangeLog	2015-07-24 00:32:32 UTC (rev 187278)
@@ -1,3 +1,29 @@
+2015-07-23  Nan Wang  <[email protected]>
+
+        AX: AccessibilityNodeObject::childrenChanged() generates too many AXLiveRegionChanged notifications
+        https://bugs.webkit.org/show_bug.cgi?id=147211
+        <rdar://problem/19908029>
+
+        Reviewed by Chris Fleizach.
+
+        AccessibilityNodeObject::childrenChanged() can be called repeatedly, generating a live region
+        change notification each time. Sometimes, so many happen that VoiceOver hangs. We can use a timer
+        to make sure that we coalesce these notifications.
+
+        Test: platform/mac/accessibility/aria-multiple-liveregions-notification.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXComputedObjectAttributeCache::getIgnored):
+        (WebCore::AXObjectCache::AXObjectCache):
+        (WebCore::AXObjectCache::~AXObjectCache):
+        (WebCore::AXObjectCache::frameLoadingEventNotification):
+        (WebCore::AXObjectCache::postLiveRegionChangeNotification):
+        (WebCore::AXObjectCache::liveRegionChangedNotificationPostTimerFired):
+        (WebCore::AXObjectCache::handleScrollbarUpdate):
+        * accessibility/AXObjectCache.h:
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::childrenChanged):
+
 2015-07-23  Timothy Horton  <[email protected]>
 
         [iOS] Frame snapshots don't factor in page scale

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (187277 => 187278)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2015-07-24 00:32:32 UTC (rev 187278)
@@ -91,6 +91,7 @@
 
 // Post value change notifications for password fields or elements contained in password fields at a 40hz interval to thwart analysis of typing cadence
 static double AccessibilityPasswordValueChangeNotificationInterval = 0.025;
+static double AccessibilityLiveRegionChangedNotificationInterval = 0.020;
 
 AccessibilityObjectInclusion AXComputedObjectAttributeCache::getIgnored(AXID id) const
 {
@@ -132,12 +133,14 @@
     : m_document(document)
     , m_notificationPostTimer(*this, &AXObjectCache::notificationPostTimerFired)
     , m_passwordNotificationPostTimer(*this, &AXObjectCache::passwordNotificationPostTimerFired)
+    , m_liveRegionChangedPostTimer(*this, &AXObjectCache::liveRegionChangedNotificationPostTimerFired)
 {
 }
 
 AXObjectCache::~AXObjectCache()
 {
     m_notificationPostTimer.stop();
+    m_liveRegionChangedPostTimer.stop();
 
     for (const auto& object : m_objects.values()) {
         detachWrapper(object.get(), CacheDestroyed);
@@ -1144,6 +1147,29 @@
     frameLoadingEventPlatformNotification(obj, loadingEvent);
 }
 
+void AXObjectCache::postLiveRegionChangeNotification(AccessibilityObject* object)
+{
+    if (m_liveRegionChangedPostTimer.isActive())
+        m_liveRegionChangedPostTimer.stop();
+
+    if (!m_liveRegionObjectsSet.contains(object))
+        m_liveRegionObjectsSet.add(object);
+
+    m_liveRegionChangedPostTimer.startOneShot(AccessibilityLiveRegionChangedNotificationInterval);
+}
+
+void AXObjectCache::liveRegionChangedNotificationPostTimerFired()
+{
+    m_liveRegionChangedPostTimer.stop();
+
+    if (m_liveRegionObjectsSet.isEmpty())
+        return;
+
+    for (auto& object : m_liveRegionObjectsSet)
+        postNotification(object.get(), object->document(), AXObjectCache::AXLiveRegionChanged);
+    m_liveRegionObjectsSet.clear();
+}
+
 void AXObjectCache::handleScrollbarUpdate(ScrollView* view)
 {
     if (!view)

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (187277 => 187278)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2015-07-24 00:32:32 UTC (rev 187278)
@@ -206,6 +206,7 @@
     void postTextReplacementNotification(Node*, AXTextEditType deletionType, const String& deletedText, AXTextEditType insertionType, const String& insertedText, const VisiblePosition&);
     void postTextStateChangeNotification(Node*, const AXTextStateChangeIntent&, const VisibleSelection&);
     void postTextStateChangeNotification(const Position&, const AXTextStateChangeIntent&, const VisibleSelection&);
+    void postLiveRegionChangeNotification(AccessibilityObject*);
 
     enum AXLoadingEvent {
         AXLoadingStarted,
@@ -260,6 +261,8 @@
 
     void notificationPostTimerFired();
 
+    void liveRegionChangedNotificationPostTimerFired();
+
     void postTextStateChangeNotification(AccessibilityObject*, const AXTextStateChangeIntent&, const VisibleSelection&);
 
     bool enqueuePasswordValueChangeNotification(AccessibilityObject*);
@@ -287,6 +290,9 @@
     Timer m_passwordNotificationPostTimer;
 
     ListHashSet<RefPtr<AccessibilityObject>> m_passwordNotificationsToPost;
+    
+    Timer m_liveRegionChangedPostTimer;
+    ListHashSet<RefPtr<AccessibilityObject>> m_liveRegionObjectsSet;
 
     AXTextStateChangeIntent m_textSelectionIntent;
     bool m_isSynchronizingSelection { false };

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (187277 => 187278)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2015-07-24 00:28:58 UTC (rev 187277)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2015-07-24 00:32:32 UTC (rev 187278)
@@ -152,8 +152,11 @@
         // In other words, they need to be sent even when the screen reader has not accessed this live region since the last update.
 
         // If this element supports ARIA live regions, then notify the AT of changes.
+        // Sometimes this function can be called many times within a short period of time, leading to posting too many AXLiveRegionChanged
+        // notifications. To fix this, we used a timer to make sure we only post one notification for the children changes within a pre-defined
+        // time interval.
         if (parent->supportsARIALiveRegion())
-            cache->postNotification(parent, parent->document(), AXObjectCache::AXLiveRegionChanged);
+            cache->postLiveRegionChangeNotification(parent);
         
         // If this element is an ARIA text control, notify the AT of changes.
         if ((parent->isARIATextControl() || parent->hasContentEditableAttributeSet()) && !parent->isNativeTextControl())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to