Commit 0de73720 authored by dmazzoni@chromium.org's avatar dmazzoni@chromium.org

Send AXLayoutComplete even when document hasn't finished loading yet.

Because these notifications only got sent if the corresponding AXObject
already existed, they were effectively never sent before the first
load complete notification. This change creates the AXObject for the
document element after the first layout, allowing future notifications too.

BUG=353067

Review URL: https://codereview.chromium.org/199693003

git-svn-id: svn://svn.chromium.org/blink/trunk@170085 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c5a05a92
This tests that accessibility events will be fired after the first layout, rather than only after the document loads.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS elapsedTime is >= 1000
PASS gotLayoutCompleteBeforeOneSecond is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<head>
<title>Accessibility: slow document load</title>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="console"></div>
<script>
description("This tests that accessibility events will be fired after the first layout, rather than only after the document loads.");
window.jsTestIsAsync = true;
if (window.testRunner && window.accessibilityController) {
testRunner.dumpAsText();
startTime = new Date();
gotLayoutCompleteBeforeOneSecond = false;
accessibilityController.addNotificationListener(function (target, notification) {
elapsedTime = new Date() - startTime;
if (notification == "LayoutComplete" && elapsedTime < 1000) {
gotLayoutCompleteBeforeOneSecond = true;
}
if (notification == "LoadComplete") {
accessibilityController.removeNotificationListener();
shouldBeGreaterThanOrEqual("elapsedTime", "1000");
shouldBeTrue("gotLayoutCompleteBeforeOneSecond");
finishJSTest();
}
});
}
</script>
<!-- This is a cgi script that waits 1 second before loading. -->
<script src="slow-loading-script.cgi"></script>
</body>
</html>
#!/usr/bin/perl -wT
use Time::HiRes;
Time::HiRes::sleep(1.0);
print "Content-type: application/octet-stream\n";
print "Cache-control: no-cache, no-store\n\n";
......@@ -804,6 +804,20 @@ void AXObjectCache::handleScrollbarUpdate(ScrollView* view)
}
}
void AXObjectCache::handleLayoutComplete(RenderObject* renderer)
{
if (!renderer)
return;
m_computedObjectAttributeCache->clear();
// Create the AXObject if it didn't yet exist - that's always safe at the end of a layout, and it
// allows an AX notification to be sent when a page has its first layout, rather than when the
// document first loads.
if (AXObject* obj = getOrCreate(renderer))
postNotification(obj, obj->document(), AXLayoutComplete, true);
}
void AXObjectCache::handleAriaExpandedChange(Node* node)
{
if (AXObject* obj = getOrCreate(node))
......
......@@ -132,6 +132,8 @@ public:
// Called when scroll bars are added / removed (as the view resizes).
void handleScrollbarUpdate(ScrollView*);
void handleLayoutComplete(RenderObject*);
// Called when the scroll offset changes.
void handleScrollPositionChanged(ScrollView*);
void handleScrollPositionChanged(RenderObject*);
......
......@@ -974,8 +974,8 @@ void FrameView::layout(bool allowSubtree)
m_layoutCount++;
if (AXObjectCache* cache = rootForThisLayout->document().existingAXObjectCache())
cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComplete, true);
if (AXObjectCache* cache = rootForThisLayout->document().axObjectCache())
cache->handleLayoutComplete(rootForThisLayout);
updateAnnotatedRegions();
ASSERT(!rootForThisLayout->needsLayout());
......
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