AX: Use caching when requesting children object on iOS
https://bugs.webkit.org/show_bug.cgi?id=116112
Reviewed by David Kilzer.
Building up the children list in the AX hierarchy can be time consuming. On iOS, this
is now much more noticeable (I believe due to the way tables calculate their AX ignored flag).
We can speed everything up if we just cache the isIgnored() attribute while building up children.
* accessibility/AXObjectCache.cpp:
(WebCore::AXAttributeCacheEnabler::AXAttributeCacheEnabler):
(WebCore):
(WebCore::AXAttributeCacheEnabler::~AXAttributeCacheEnabler):
* accessibility/AXObjectCache.h:
(AXAttributeCacheEnabler):
(WebCore):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityHitTest:]):
(-[WebAccessibilityObjectWrapper accessibilityElementCount]):
(-[WebAccessibilityObjectWrapper accessibilityElementAtIndex:]):
(-[WebAccessibilityObjectWrapper indexOfAccessibilityElement:]):
(-[WebAccessibilityObjectWrapper accessibilityContainer]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 94cc21e..d6bc9d9 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2013-05-15 Chris Fleizach <cfleizach@apple.com>
+
+ AX: Use caching when requesting children object on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=116112
+
+ Reviewed by David Kilzer.
+
+ Building up the children list in the AX hierarchy can be time consuming. On iOS, this
+ is now much more noticeable (I believe due to the way tables calculate their AX ignored flag).
+
+ We can speed everything up if we just cache the isIgnored() attribute while building up children.
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXAttributeCacheEnabler::AXAttributeCacheEnabler):
+ (WebCore):
+ (WebCore::AXAttributeCacheEnabler::~AXAttributeCacheEnabler):
+ * accessibility/AXObjectCache.h:
+ (AXAttributeCacheEnabler):
+ (WebCore):
+ * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+ (-[WebAccessibilityObjectWrapper accessibilityHitTest:]):
+ (-[WebAccessibilityObjectWrapper accessibilityElementCount]):
+ (-[WebAccessibilityObjectWrapper accessibilityElementAtIndex:]):
+ (-[WebAccessibilityObjectWrapper indexOfAccessibilityElement:]):
+ (-[WebAccessibilityObjectWrapper accessibilityContainer]):
+
2013-05-15 Anders Carlsson <andersca@apple.com>
Remove WebSocketHandshakeRequest class
diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp
index cae58b6..f899a50 100644
--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ b/Source/WebCore/accessibility/AXObjectCache.cpp
@@ -954,6 +954,19 @@
return equalIgnoringCase(toElement(node)->getAttribute(aria_hiddenAttr), "false");
}
+AXAttributeCacheEnabler::AXAttributeCacheEnabler(AXObjectCache* cache)
+ : m_cache(cache)
+{
+ if (m_cache)
+ m_cache->startCachingComputedObjectAttributesUntilTreeMutates();
+}
+
+AXAttributeCacheEnabler::~AXAttributeCacheEnabler()
+{
+ if (m_cache)
+ m_cache->stopCachingComputedObjectAttributes();
+}
+
} // namespace WebCore
#endif // HAVE(ACCESSIBILITY)
diff --git a/Source/WebCore/accessibility/AXObjectCache.h b/Source/WebCore/accessibility/AXObjectCache.h
index 4811877..52b4e2f 100644
--- a/Source/WebCore/accessibility/AXObjectCache.h
+++ b/Source/WebCore/accessibility/AXObjectCache.h
@@ -240,6 +240,16 @@
AXID getAXID(AccessibilityObject*);
};
+class AXAttributeCacheEnabler
+{
+public:
+ explicit AXAttributeCacheEnabler(AXObjectCache *cache);
+ ~AXAttributeCacheEnabler();
+
+private:
+ AXObjectCache* m_cache;
+};
+
bool nodeHasRole(Node*, const String& role);
// This will let you know if aria-hidden was explicitly set to false.
bool isNodeAriaVisible(Node*);
diff --git a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm b/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
index ed4838f..47de168 100644
--- a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
+++ b/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
@@ -302,7 +302,12 @@
return nil;
// Try a fuzzy hit test first to find an accessible element.
- RefPtr<AccessibilityObject> axObject = m_object->accessibilityHitTest(IntPoint(point));
+ RefPtr<AccessibilityObject> axObject;
+ {
+ AXAttributeCacheEnabler enableCache(m_object->axObjectCache());
+ axObject = m_object->accessibilityHitTest(IntPoint(point));
+ }
+
if (!axObject)
return nil;
@@ -324,6 +329,7 @@
if (![self _prepareAccessibilityCall])
return nil;
+ AXAttributeCacheEnabler enableCache(m_object->axObjectCache());
if ([self isAttachment])
return [[self attachmentView] accessibilityElementCount];
@@ -335,6 +341,7 @@
if (![self _prepareAccessibilityCall])
return nil;
+ AXAttributeCacheEnabler enableCache(m_object->axObjectCache());
if ([self isAttachment])
return [[self attachmentView] accessibilityElementAtIndex:index];
@@ -354,6 +361,7 @@
if (![self _prepareAccessibilityCall])
return NSNotFound;
+ AXAttributeCacheEnabler enableCache(m_object->axObjectCache());
if ([self isAttachment])
return [[self attachmentView] indexOfAccessibilityElement:element];
@@ -1071,6 +1079,8 @@
{
if (![self _prepareAccessibilityCall])
return nil;
+
+ AXAttributeCacheEnabler enableCache(m_object->axObjectCache());
// As long as there's a parent wrapper, that's the correct chain to climb.
AccessibilityObject* parent = m_object->parentObjectUnignored();