diff --git a/accessible/src/base/Logging.cpp b/accessible/src/base/Logging.cpp index ffdb22456752..ae3564588e87 100644 --- a/accessible/src/base/Logging.cpp +++ b/accessible/src/base/Logging.cpp @@ -196,7 +196,7 @@ LogDocParent(nsIDocument* aDocumentNode) static void LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument) { - printf(" DOM id: %p, acc id: %p\n ", + printf(" DOM document: %p, acc document: %p\n ", static_cast(aDocumentNode), static_cast(aDocument)); // log document info @@ -322,6 +322,20 @@ LogRequest(nsIRequest* aRequest) } } +static void +LogDocAccState(DocAccessible* aDocument) +{ + printf("document acc state: "); + if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded)) + printf("completely loaded;"); + else if (aDocument->HasLoadState(DocAccessible::eReady)) + printf("ready;"); + else if (aDocument->HasLoadState(DocAccessible::eDOMLoaded)) + printf("DOM loaded;"); + else if (aDocument->HasLoadState(DocAccessible::eTreeConstructed)) + printf("tree constructed;"); +} + static void GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType) { @@ -406,6 +420,30 @@ logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode) MsgEnd(); } +void +logging::DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget) +{ + MsgBegin(sDocLoadTitle, "document loaded *completely*"); + + nsIDocument* docNode = aDocument->GetDocumentNode(); + printf(" DOM document: %p, acc document: %p\n", + static_cast(aDocument->GetDocumentNode()), + static_cast(aDocument)); + + printf(" "); + LogDocURI(aDocument->GetDocumentNode()); + printf("\n"); + + printf(" "); + LogDocAccState(aDocument); + printf("\n"); + + printf(" document is load event target: %s\n", + (aIsLoadEventTarget ? "true" : "false")); + + MsgEnd(); +} + void logging::DocLoadEventFired(AccEvent* aEvent) { diff --git a/accessible/src/base/Logging.h b/accessible/src/base/Logging.h index 397ee9662c6f..631ec34046e7 100644 --- a/accessible/src/base/Logging.h +++ b/accessible/src/base/Logging.h @@ -56,6 +56,7 @@ bool IsEnabled(uint32_t aModules); void DocLoad(const char* aMsg, nsIWebProgress* aWebProgress, nsIRequest* aRequest, uint32_t aStateFlags); void DocLoad(const char* aMsg, nsIDocument* aDocumentNode); +void DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget); /** * Log that document load event was fired. diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 472a2b5958e1..32dc7bd0819c 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -1587,6 +1587,11 @@ DocAccessible::ProcessLoad() { mLoadState |= eCompletelyLoaded; +#ifdef A11Y_LOG + if (logging::IsEnabled(logging::eDocLoad)) + logging::DocCompleteLoad(this, IsLoadEventTarget()); +#endif + // Do not fire document complete/stop events for root chrome document // accessibles and for frame/iframe documents because // a) screen readers start working on focus event in the case of root chrome @@ -2072,25 +2077,31 @@ bool DocAccessible::IsLoadEventTarget() const { nsCOMPtr container = mDocument->GetContainer(); - nsCOMPtr docShellTreeItem = - do_QueryInterface(container); - NS_ASSERTION(docShellTreeItem, "No document shell for document!"); + nsCOMPtr treeItem = do_QueryInterface(container); + NS_ASSERTION(treeItem, "No document shell for document!"); nsCOMPtr parentTreeItem; - docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem)); + treeItem->GetParent(getter_AddRefs(parentTreeItem)); - // Return true if it's not a root document (either tab document or - // frame/iframe document) and its parent document is not in loading state. - // Note: we can get notifications while document is loading (and thus - // while there's no parent document yet). + // Not a root document. if (parentTreeItem) { + // Return true if it's either: + // a) tab document; + nsCOMPtr rootTreeItem; + treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem)); + if (parentTreeItem == rootTreeItem) + return true; + + // b) frame/iframe document and its parent document is not in loading state + // Note: we can get notifications while document is loading (and thus + // while there's no parent document yet). DocAccessible* parentDoc = ParentDocument(); return parentDoc && parentDoc->HasLoadState(eCompletelyLoaded); } // It's content (not chrome) root document. int32_t contentType; - docShellTreeItem->GetItemType(&contentType); + treeItem->GetItemType(&contentType); return (contentType == nsIDocShellTreeItem::typeContent); } diff --git a/accessible/tests/mochitest/states/test_link.html b/accessible/tests/mochitest/states/test_link.html index f3aa4b7f35b4..4ceecf704e28 100644 --- a/accessible/tests/mochitest/states/test_link.html +++ b/accessible/tests/mochitest/states/test_link.html @@ -21,7 +21,7 @@ src="../events.js">