AX: Defer attribute computation until needed.
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 18:10:20 +0000 (18:10 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Feb 2018 18:10:20 +0000 (18:10 +0000)
commitbc8441ece1851c726098802c7cb1308255b2714e
treebcc8f5c65539dcf5835eb7342de46ec420f47158
parenta480ed19d906ea0bcfb6cd64bc63c9a0ce45179c
AX: Defer attribute computation until needed.
https://bugs.webkit.org/show_bug.cgi?id=182386
<rdar://problem/37115277>

Reviewed by Zalan Bujtas.

Source/WebCore:

Accessibility is doing too much work when handling attribute changes. Here's how we can improve this:
   1) Defer attribute changes while the tree is dirty (and coalesce them).
   2) Don't create AXObjects when an attribute changes unnecessarily. If no client has requested an ax object, it's likely no work needs to be done
         (with the exception of a few attributes like aria-modal)
   3) Stop calculating the entire accessible ARIA label when trying to decide if an element should be ignored. That's generally wasteful and the
         consequence of including more AX elements in the tree is very minimal.

* accessibility/AXObjectCache.cpp:
(WebCore::rendererNeedsDeferredUpdate):
(WebCore::nodeAndRendererAreValid):
(WebCore::AXObjectCache::remove):
(WebCore::AXObjectCache::handleAriaExpandedChange):
(WebCore::AXObjectCache::handleAriaRoleChanged):
(WebCore::AXObjectCache::deferAttributeChangeIfNeeded):
(WebCore::AXObjectCache::shouldProcessAttributeChange):
(WebCore::AXObjectCache::handleAttributeChange):
(WebCore::AXObjectCache::prepareForDocumentDestruction):
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::deferRecomputeIsIgnoredIfNeeded):
(WebCore::AXObjectCache::deferRecomputeIsIgnored):
(WebCore::AXObjectCache::deferTextChangedIfNeeded):
(WebCore::AXObjectCache::deferSelectedChildrenChangedIfNeeded):
(WebCore::AXObjectCache::handleAttributeChanged): Deleted.
* accessibility/AXObjectCache.h:
(WebCore::AXObjectCache::deferAttributeChangeIfNeeded):
(WebCore::AXObjectCache::handleAttributeChanged): Deleted.
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::hasAttributesRequiredForInclusion const):
* accessibility/AccessibleNode.cpp:
(WebCore::AccessibleNode::notifyAttributeChanged):
* dom/Element.cpp:
(WebCore::Element::attributeChanged):

LayoutTests:

Update tests to reflect new world of delayed attribute handling for accessibility.

* accessibility/canvas-fallback-content.html:
     Make test async so attributes can be checked after deferred handling.
* accessibility/mac/aria-expanded-notifications.html:
     Access elements through AX tree so attribute changes generate notifications.
* accessibility/mac/aria-listbox-selectedchildren-change.html:
     Make test async so attributes can be checked after deferred handling.
* accessibility/mac/aria-menu-item-selected-notification.html:
     Access menu item through AX tree so attribute changes generate notifications.
* accessibility/mac/aria-modal-auto-focus.html:
     Access buttons after delay so attributes have time to be deferred.
* accessibility/mac/element-busy-changed.html:
     Process second attribute change after delay so we generate two notifications.
* accessibility/mac/expanded-notification.html:
     Set attributes after a delay so they generate individual notifications.
* accessibility/notification-listeners.html:
      Access elements through AX tree so attribute changes generate notifications.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/canvas-fallback-content.html
LayoutTests/accessibility/mac/aria-expanded-notifications.html
LayoutTests/accessibility/mac/aria-listbox-selectedchildren-change.html
LayoutTests/accessibility/mac/aria-menu-item-selected-notification.html
LayoutTests/accessibility/mac/aria-modal-auto-focus.html
LayoutTests/accessibility/mac/element-busy-changed.html
LayoutTests/accessibility/mac/expanded-notification.html
LayoutTests/accessibility/notification-listeners.html
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AXObjectCache.h
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibleNode.cpp
Source/WebCore/dom/Element.cpp