2012-05-23 13:21:40 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "Logging.h"
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
#include "LocalAccessible-inl.h"
|
2012-05-23 13:21:40 +04:00
|
|
|
#include "AccEvent.h"
|
2012-06-01 08:26:28 +04:00
|
|
|
#include "DocAccessible.h"
|
2021-08-22 13:21:56 +03:00
|
|
|
#include "DocAccessible-inl.h"
|
2012-05-23 13:21:40 +04:00
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "nsCoreUtils.h"
|
2012-06-01 08:26:28 +04:00
|
|
|
#include "OuterDocAccessible.h"
|
2012-05-23 13:21:40 +04:00
|
|
|
|
|
|
|
#include "nsDocShellLoadTypes.h"
|
|
|
|
#include "nsIChannel.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
|
|
#include "nsIWebProgress.h"
|
|
|
|
#include "prenv.h"
|
2012-08-01 22:31:10 +04:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2021-12-09 14:55:36 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2019-03-29 18:12:47 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2021-03-23 00:25:30 +03:00
|
|
|
#include "mozilla/StackWalk.h"
|
2021-12-09 14:55:36 +03:00
|
|
|
#include "mozilla/ToString.h"
|
2020-05-01 07:28:35 +03:00
|
|
|
#include "mozilla/dom/BorrowedAttrInfo.h"
|
2021-01-05 12:47:12 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2018-03-12 21:03:55 +03:00
|
|
|
#include "mozilla/dom/HTMLBodyElement.h"
|
2018-05-08 20:52:38 +03:00
|
|
|
#include "mozilla/dom/Selection.h"
|
2012-05-23 13:21:40 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2020-05-01 07:28:35 +03:00
|
|
|
using mozilla::dom::BorrowedAttrInfo;
|
|
|
|
|
2021-05-05 23:56:06 +03:00
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF(AccessibleLoggingMallocSizeOf)
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Logging helpers
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t sModules = 0;
|
2012-05-23 13:21:40 +04:00
|
|
|
|
|
|
|
struct ModuleRep {
|
|
|
|
const char* mStr;
|
|
|
|
logging::EModules mModule;
|
|
|
|
};
|
|
|
|
|
2012-11-04 06:19:56 +04:00
|
|
|
static ModuleRep sModuleMap[] = {{"docload", logging::eDocLoad},
|
|
|
|
{"doccreate", logging::eDocCreate},
|
|
|
|
{"docdestroy", logging::eDocDestroy},
|
|
|
|
{"doclifecycle", logging::eDocLifeCycle},
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-11-04 06:19:56 +04:00
|
|
|
{"events", logging::eEvents},
|
2016-04-07 16:30:22 +03:00
|
|
|
{"eventTree", logging::eEventTree},
|
2012-11-04 06:19:56 +04:00
|
|
|
{"platforms", logging::ePlatforms},
|
|
|
|
{"text", logging::eText},
|
|
|
|
{"tree", logging::eTree},
|
2021-05-05 23:56:06 +03:00
|
|
|
{"treeSize", logging::eTreeSize},
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-11-04 06:19:56 +04:00
|
|
|
{"DOMEvents", logging::eDOMEvents},
|
|
|
|
{"focus", logging::eFocus},
|
|
|
|
{"selection", logging::eSelection},
|
2016-03-01 21:07:20 +03:00
|
|
|
{"notifications", logging::eNotifications},
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-03-01 21:07:20 +03:00
|
|
|
{"stack", logging::eStack},
|
2021-09-29 00:55:41 +03:00
|
|
|
{"verbose", logging::eVerbose},
|
|
|
|
{"cache", logging::eCache}};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
static void EnableLogging(const char* aModulesStr) {
|
|
|
|
sModules = 0;
|
|
|
|
if (!aModulesStr) return;
|
|
|
|
|
|
|
|
const char* token = aModulesStr;
|
|
|
|
while (*token != '\0') {
|
|
|
|
size_t tokenLen = strcspn(token, ",");
|
2012-11-04 06:19:56 +04:00
|
|
|
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
|
|
|
|
if (strncmp(token, sModuleMap[idx].mStr, tokenLen) == 0) {
|
2013-03-01 08:06:16 +04:00
|
|
|
#if !defined(MOZ_PROFILING) && (!defined(DEBUG) || defined(MOZ_OPTIMIZE))
|
2012-11-04 06:19:56 +04:00
|
|
|
// Stack tracing on profiling enabled or debug not optimized builds.
|
|
|
|
if (strncmp(token, "stack", tokenLen) == 0) break;
|
|
|
|
#endif
|
|
|
|
sModules |= sModuleMap[idx].mModule;
|
|
|
|
printf("\n\nmodule enabled: %s\n", sModuleMap[idx].mStr);
|
2012-05-23 13:21:40 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
token += tokenLen;
|
|
|
|
|
|
|
|
if (*token == ',') token++; // skip ',' char
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocURI(dom::Document* aDocumentNode) {
|
2021-09-24 23:31:00 +03:00
|
|
|
nsIURI* uri = aDocumentNode->GetDocumentURI();
|
|
|
|
if (uri) {
|
|
|
|
printf("uri: %s", uri->GetSpecOrDefault().get());
|
|
|
|
} else {
|
|
|
|
printf("uri: null");
|
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocShellState(dom::Document* aDocumentNode) {
|
2012-05-23 13:21:40 +04:00
|
|
|
printf("docshell busy: ");
|
2021-09-24 23:31:00 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = aDocumentNode->GetDocShell();
|
|
|
|
if (!docShell) {
|
|
|
|
printf("null docshell");
|
|
|
|
return;
|
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString docShellBusy;
|
2018-11-28 06:30:56 +03:00
|
|
|
nsIDocShell::BusyFlags busyFlags = nsIDocShell::BUSY_FLAGS_NONE;
|
2013-11-15 20:32:12 +04:00
|
|
|
docShell->GetBusyFlags(&busyFlags);
|
2016-08-24 16:19:23 +03:00
|
|
|
if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) {
|
2013-11-15 20:32:12 +04:00
|
|
|
printf("'none'");
|
2016-08-24 16:19:23 +03:00
|
|
|
}
|
|
|
|
if (busyFlags & nsIDocShell::BUSY_FLAGS_BUSY) {
|
2013-11-15 20:32:12 +04:00
|
|
|
printf("'busy'");
|
2016-08-24 16:19:23 +03:00
|
|
|
}
|
|
|
|
if (busyFlags & nsIDocShell::BUSY_FLAGS_BEFORE_PAGE_LOAD) {
|
2013-11-15 20:32:12 +04:00
|
|
|
printf(", 'before page load'");
|
2016-08-24 16:19:23 +03:00
|
|
|
}
|
|
|
|
if (busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING) {
|
2013-11-15 20:32:12 +04:00
|
|
|
printf(", 'page loading'");
|
2016-08-24 16:19:23 +03:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocType(dom::Document* aDocumentNode) {
|
2012-05-23 13:21:40 +04:00
|
|
|
if (aDocumentNode->IsActive()) {
|
2021-09-14 00:01:23 +03:00
|
|
|
bool isContent = aDocumentNode->IsContentDocument();
|
2012-05-23 13:21:40 +04:00
|
|
|
printf("%s document", (isContent ? "content" : "chrome"));
|
|
|
|
} else {
|
|
|
|
printf("document type: [failed]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocShellTree(dom::Document* aDocumentNode) {
|
2012-05-23 13:21:40 +04:00
|
|
|
if (aDocumentNode->IsActive()) {
|
2013-11-15 20:32:12 +04:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocumentNode->GetDocShell());
|
2021-09-24 23:31:00 +03:00
|
|
|
if (!treeItem) {
|
|
|
|
printf("in-process docshell hierarchy, null docshell;");
|
|
|
|
return;
|
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
2019-07-26 19:48:31 +03:00
|
|
|
treeItem->GetInProcessParent(getter_AddRefs(parentTreeItem));
|
2012-05-23 13:21:40 +04:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
|
2019-08-07 22:24:00 +03:00
|
|
|
treeItem->GetInProcessRootTreeItem(getter_AddRefs(rootTreeItem));
|
2020-05-11 17:38:53 +03:00
|
|
|
printf(
|
|
|
|
"in-process docshell hierarchy, parent: %p, root: %p, "
|
2020-06-10 08:03:05 +03:00
|
|
|
"is top level: %s;",
|
2020-05-11 17:38:53 +03:00
|
|
|
static_cast<void*>(parentTreeItem), static_cast<void*>(rootTreeItem),
|
2020-06-10 08:03:05 +03:00
|
|
|
(nsCoreUtils::IsTopLevelContentDocInProcess(aDocumentNode) ? "yes"
|
|
|
|
: "no"));
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocState(dom::Document* aDocumentNode) {
|
2012-07-30 18:20:58 +04:00
|
|
|
const char* docState = nullptr;
|
2019-01-02 16:05:23 +03:00
|
|
|
dom::Document::ReadyState docStateFlag = aDocumentNode->GetReadyStateEnum();
|
2012-05-23 13:21:40 +04:00
|
|
|
switch (docStateFlag) {
|
2019-01-02 16:05:23 +03:00
|
|
|
case dom::Document::READYSTATE_UNINITIALIZED:
|
2012-05-23 13:21:40 +04:00
|
|
|
docState = "uninitialized";
|
|
|
|
break;
|
2019-01-02 16:05:23 +03:00
|
|
|
case dom::Document::READYSTATE_LOADING:
|
2012-05-23 13:21:40 +04:00
|
|
|
docState = "loading";
|
|
|
|
break;
|
2019-01-02 16:05:23 +03:00
|
|
|
case dom::Document::READYSTATE_INTERACTIVE:
|
2012-05-23 13:21:40 +04:00
|
|
|
docState = "interactive";
|
|
|
|
break;
|
2019-01-02 16:05:23 +03:00
|
|
|
case dom::Document::READYSTATE_COMPLETE:
|
2012-05-23 13:21:40 +04:00
|
|
|
docState = "complete";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("doc state: %s", docState);
|
|
|
|
printf(", %sinitial", aDocumentNode->IsInitialDocument() ? "" : "not ");
|
|
|
|
printf(", %sshowing", aDocumentNode->IsShowing() ? "" : "not ");
|
|
|
|
printf(", %svisible", aDocumentNode->IsVisible() ? "" : "not ");
|
2021-02-09 03:44:21 +03:00
|
|
|
printf(
|
|
|
|
", %svisible considering ancestors",
|
|
|
|
nsCoreUtils::IsDocumentVisibleConsideringInProcessAncestors(aDocumentNode)
|
|
|
|
? ""
|
|
|
|
: "not ");
|
2012-05-23 13:21:40 +04:00
|
|
|
printf(", %sactive", aDocumentNode->IsActive() ? "" : "not ");
|
2012-10-11 19:13:18 +04:00
|
|
|
printf(", %sresource", aDocumentNode->IsResourceDoc() ? "" : "not ");
|
2016-03-04 18:36:18 +03:00
|
|
|
|
|
|
|
dom::Element* rootEl = aDocumentNode->GetBodyElement();
|
|
|
|
if (!rootEl) {
|
|
|
|
rootEl = aDocumentNode->GetRootElement();
|
|
|
|
}
|
|
|
|
printf(", has %srole content", rootEl ? "" : "no ");
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogPresShell(dom::Document* aDocumentNode) {
|
2019-03-29 18:12:47 +03:00
|
|
|
PresShell* presShell = aDocumentNode->GetPresShell();
|
|
|
|
printf("presshell: %p", static_cast<void*>(presShell));
|
2012-11-30 06:09:41 +04:00
|
|
|
|
|
|
|
nsIScrollableFrame* sf = nullptr;
|
2019-03-29 18:12:47 +03:00
|
|
|
if (presShell) {
|
|
|
|
printf(", is %s destroying", (presShell->IsDestroying() ? "" : "not"));
|
|
|
|
sf = presShell->GetRootScrollFrameAsScrollable();
|
2012-11-30 06:09:41 +04:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
printf(", root scroll frame: %p", static_cast<void*>(sf));
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocLoadGroup(dom::Document* aDocumentNode) {
|
2012-05-23 13:21:40 +04:00
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup = aDocumentNode->GetDocumentLoadGroup();
|
|
|
|
printf("load group: %p", static_cast<void*>(loadGroup));
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocParent(dom::Document* aDocumentNode) {
|
2019-07-26 19:48:31 +03:00
|
|
|
dom::Document* parentDoc = aDocumentNode->GetInProcessParentDocument();
|
2014-08-16 00:24:22 +04:00
|
|
|
printf("parent DOM document: %p", static_cast<void*>(parentDoc));
|
2012-05-23 13:21:40 +04:00
|
|
|
if (parentDoc) {
|
2014-08-16 00:24:22 +04:00
|
|
|
printf(", parent acc document: %p",
|
|
|
|
static_cast<void*>(GetExistingDocAccessible(parentDoc)));
|
2012-05-23 13:21:40 +04:00
|
|
|
printf("\n parent ");
|
|
|
|
LogDocURI(parentDoc);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void LogDocInfo(dom::Document* aDocumentNode, DocAccessible* aDocument) {
|
2012-10-10 05:01:46 +04:00
|
|
|
printf(" DOM document: %p, acc document: %p\n ",
|
2012-05-23 13:21:40 +04:00
|
|
|
static_cast<void*>(aDocumentNode), static_cast<void*>(aDocument));
|
|
|
|
|
|
|
|
// log document info
|
|
|
|
if (aDocumentNode) {
|
|
|
|
LogDocURI(aDocumentNode);
|
|
|
|
printf("\n ");
|
|
|
|
LogDocShellState(aDocumentNode);
|
|
|
|
printf("; ");
|
|
|
|
LogDocType(aDocumentNode);
|
|
|
|
printf("\n ");
|
|
|
|
LogDocShellTree(aDocumentNode);
|
|
|
|
printf("\n ");
|
|
|
|
LogDocState(aDocumentNode);
|
|
|
|
printf("\n ");
|
|
|
|
LogPresShell(aDocumentNode);
|
|
|
|
printf("\n ");
|
|
|
|
LogDocLoadGroup(aDocumentNode);
|
|
|
|
printf(", ");
|
|
|
|
LogDocParent(aDocumentNode);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LogShellLoadType(nsIDocShell* aDocShell) {
|
|
|
|
printf("load type: ");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t loadType = 0;
|
2012-05-23 13:21:40 +04:00
|
|
|
aDocShell->GetLoadType(&loadType);
|
|
|
|
switch (loadType) {
|
|
|
|
case LOAD_NORMAL:
|
|
|
|
printf("normal; ");
|
|
|
|
break;
|
|
|
|
case LOAD_NORMAL_REPLACE:
|
|
|
|
printf("normal replace; ");
|
|
|
|
break;
|
|
|
|
case LOAD_HISTORY:
|
|
|
|
printf("history; ");
|
|
|
|
break;
|
|
|
|
case LOAD_NORMAL_BYPASS_CACHE:
|
|
|
|
printf("normal bypass cache; ");
|
|
|
|
break;
|
|
|
|
case LOAD_NORMAL_BYPASS_PROXY:
|
|
|
|
printf("normal bypass proxy; ");
|
|
|
|
break;
|
|
|
|
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
|
|
|
|
printf("normal bypass proxy and cache; ");
|
|
|
|
break;
|
|
|
|
case LOAD_RELOAD_NORMAL:
|
|
|
|
printf("reload normal; ");
|
|
|
|
break;
|
|
|
|
case LOAD_RELOAD_BYPASS_CACHE:
|
|
|
|
printf("reload bypass cache; ");
|
|
|
|
break;
|
|
|
|
case LOAD_RELOAD_BYPASS_PROXY:
|
|
|
|
printf("reload bypass proxy; ");
|
|
|
|
break;
|
|
|
|
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
|
|
|
|
printf("reload bypass proxy and cache; ");
|
|
|
|
break;
|
|
|
|
case LOAD_LINK:
|
|
|
|
printf("link; ");
|
|
|
|
break;
|
|
|
|
case LOAD_REFRESH:
|
|
|
|
printf("refresh; ");
|
|
|
|
break;
|
2021-03-25 22:47:01 +03:00
|
|
|
case LOAD_REFRESH_REPLACE:
|
|
|
|
printf("refresh replace; ");
|
|
|
|
break;
|
2012-05-23 13:21:40 +04:00
|
|
|
case LOAD_RELOAD_CHARSET_CHANGE:
|
|
|
|
printf("reload charset change; ");
|
|
|
|
break;
|
|
|
|
case LOAD_BYPASS_HISTORY:
|
|
|
|
printf("bypass history; ");
|
|
|
|
break;
|
|
|
|
case LOAD_STOP_CONTENT:
|
|
|
|
printf("stop content; ");
|
|
|
|
break;
|
|
|
|
case LOAD_STOP_CONTENT_AND_REPLACE:
|
|
|
|
printf("stop content and replace; ");
|
|
|
|
break;
|
|
|
|
case LOAD_PUSHSTATE:
|
|
|
|
printf("load pushstate; ");
|
|
|
|
break;
|
2012-06-21 21:31:07 +04:00
|
|
|
case LOAD_REPLACE_BYPASS_CACHE:
|
|
|
|
printf("replace bypass cache; ");
|
2012-06-22 01:03:44 +04:00
|
|
|
break;
|
2012-05-23 13:21:40 +04:00
|
|
|
case LOAD_ERROR_PAGE:
|
|
|
|
printf("error page;");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("unknown");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LogRequest(nsIRequest* aRequest) {
|
|
|
|
if (aRequest) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString name;
|
2012-05-23 13:21:40 +04:00
|
|
|
aRequest->GetName(name);
|
|
|
|
printf(" request spec: %s\n", name.get());
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t loadFlags = 0;
|
2012-05-23 13:21:40 +04:00
|
|
|
aRequest->GetLoadFlags(&loadFlags);
|
|
|
|
printf(" request load flags: %x; ", loadFlags);
|
|
|
|
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) printf("document uri; ");
|
2021-02-20 02:14:32 +03:00
|
|
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
2012-05-23 13:21:40 +04:00
|
|
|
printf("retargeted document uri; ");
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
if (loadFlags & nsIChannel::LOAD_REPLACE) printf("replace; ");
|
2021-02-20 02:14:32 +03:00
|
|
|
if (loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI) {
|
2012-05-23 13:21:40 +04:00
|
|
|
printf("initial document uri; ");
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
if (loadFlags & nsIChannel::LOAD_TARGETED) printf("targeted; ");
|
2021-02-20 02:14:32 +03:00
|
|
|
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS) {
|
2012-05-23 13:21:40 +04:00
|
|
|
printf("call content sniffers; ");
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2019-03-25 15:48:25 +03:00
|
|
|
if (loadFlags & nsIChannel::LOAD_BYPASS_URL_CLASSIFIER) {
|
|
|
|
printf("bypass classify uri; ");
|
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
} else {
|
|
|
|
printf(" no request");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-10 05:01:46 +04:00
|
|
|
static void LogDocAccState(DocAccessible* aDocument) {
|
|
|
|
printf("document acc state: ");
|
2021-02-20 02:14:32 +03:00
|
|
|
if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded)) {
|
2012-10-10 05:01:46 +04:00
|
|
|
printf("completely loaded;");
|
2021-02-20 02:14:32 +03:00
|
|
|
} else if (aDocument->HasLoadState(DocAccessible::eReady)) {
|
2012-10-10 05:01:46 +04:00
|
|
|
printf("ready;");
|
2021-02-20 02:14:32 +03:00
|
|
|
} else if (aDocument->HasLoadState(DocAccessible::eDOMLoaded)) {
|
2012-10-10 05:01:46 +04:00
|
|
|
printf("DOM loaded;");
|
2021-02-20 02:14:32 +03:00
|
|
|
} else if (aDocument->HasLoadState(DocAccessible::eTreeConstructed)) {
|
2012-10-10 05:01:46 +04:00
|
|
|
printf("tree constructed;");
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-10-10 05:01:46 +04:00
|
|
|
}
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
static void GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t type = aEvent->GetEventType();
|
2012-05-23 13:21:40 +04:00
|
|
|
if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED) {
|
|
|
|
aEventType.AssignLiteral("load stopped");
|
|
|
|
} else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE) {
|
|
|
|
aEventType.AssignLiteral("load complete");
|
|
|
|
} else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD) {
|
|
|
|
aEventType.AssignLiteral("reload");
|
|
|
|
} else if (type == nsIAccessibleEvent::EVENT_STATE_CHANGE) {
|
|
|
|
AccStateChangeEvent* event = downcast_accEvent(aEvent);
|
|
|
|
if (event->GetState() == states::BUSY) {
|
|
|
|
aEventType.AssignLiteral("busy ");
|
2021-02-20 02:14:32 +03:00
|
|
|
if (event->IsStateEnabled()) {
|
2012-05-23 13:21:40 +04:00
|
|
|
aEventType.AppendLiteral("true");
|
2021-02-20 02:14:32 +03:00
|
|
|
} else {
|
2012-05-23 13:21:40 +04:00
|
|
|
aEventType.AppendLiteral("false");
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 03:02:51 +03:00
|
|
|
static void DescribeNode(nsINode* aNode, nsAString& aOutDescription) {
|
|
|
|
if (!aNode) {
|
|
|
|
aOutDescription.AppendLiteral("null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-27 05:02:01 +03:00
|
|
|
aOutDescription.AppendPrintf("0x%p, ", (void*)aNode);
|
2019-08-09 03:02:51 +03:00
|
|
|
aOutDescription.Append(aNode->NodeInfo()->QualifiedName());
|
|
|
|
|
|
|
|
if (!aNode->IsElement()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dom::Element* elm = aNode->AsElement();
|
|
|
|
|
|
|
|
nsAtom* idAtom = elm->GetID();
|
|
|
|
if (idAtom) {
|
|
|
|
nsAutoCString id;
|
|
|
|
idAtom->ToUTF8String(id);
|
|
|
|
aOutDescription.AppendPrintf("@id=\"%s\" ", id.get());
|
|
|
|
} else {
|
|
|
|
aOutDescription.Append(' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t attrCount = elm->GetAttrCount();
|
|
|
|
if (!attrCount || (idAtom && attrCount == 1)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutDescription.AppendLiteral("[ ");
|
|
|
|
|
|
|
|
for (uint32_t index = 0; index < attrCount; index++) {
|
|
|
|
BorrowedAttrInfo info = elm->GetAttrInfoAt(index);
|
|
|
|
|
|
|
|
// Skip redundant display of id attribute.
|
|
|
|
if (info.mName->Equals(nsGkAtoms::id)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// name
|
|
|
|
nsAutoString name;
|
|
|
|
info.mName->GetQualifiedName(name);
|
|
|
|
aOutDescription.Append(name);
|
|
|
|
|
|
|
|
aOutDescription.AppendLiteral("=\"");
|
|
|
|
|
|
|
|
// value
|
|
|
|
nsAutoString value;
|
|
|
|
info.mValue->ToString(value);
|
|
|
|
for (uint32_t i = value.Length(); i > 0; --i) {
|
|
|
|
if (value[i - 1] == char16_t('"')) value.Insert(char16_t('\\'), i - 1);
|
|
|
|
}
|
|
|
|
aOutDescription.Append(value);
|
|
|
|
aOutDescription.AppendLiteral("\" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutDescription.Append(']');
|
|
|
|
}
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// namespace logging:: document life cycle logging methods
|
|
|
|
|
2012-06-01 08:26:28 +04:00
|
|
|
static const char* sDocLoadTitle = "DOCLOAD";
|
|
|
|
static const char* sDocCreateTitle = "DOCCREATE";
|
|
|
|
static const char* sDocDestroyTitle = "DOCDESTROY";
|
|
|
|
static const char* sDocEventTitle = "DOCEVENT";
|
2012-09-27 03:53:23 +04:00
|
|
|
static const char* sFocusTitle = "FOCUS";
|
2012-06-01 08:26:28 +04:00
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
void logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIRequest* aRequest, uint32_t aStateFlags) {
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sDocLoadTitle, "%s", aMsg);
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> DOMWindow;
|
2012-05-23 13:21:40 +04:00
|
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow));
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter* window = nsPIDOMWindowOuter::From(DOMWindow);
|
2013-08-14 11:01:27 +04:00
|
|
|
if (!window) {
|
2012-06-01 08:26:28 +04:00
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
return;
|
2012-06-01 08:26:28 +04:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<dom::Document> documentNode = window->GetDoc();
|
2013-08-14 11:01:27 +04:00
|
|
|
if (!documentNode) {
|
2012-06-01 08:26:28 +04:00
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
return;
|
2012-06-01 08:26:28 +04:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2012-11-03 03:57:58 +04:00
|
|
|
DocAccessible* document = GetExistingDocAccessible(documentNode);
|
2012-05-23 13:21:40 +04:00
|
|
|
|
|
|
|
LogDocInfo(documentNode, document);
|
|
|
|
|
2014-01-10 06:03:47 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
|
2012-06-01 08:26:28 +04:00
|
|
|
printf("\n ");
|
2012-05-23 13:21:40 +04:00
|
|
|
LogShellLoadType(docShell);
|
|
|
|
printf("\n");
|
|
|
|
LogRequest(aRequest);
|
|
|
|
printf("\n");
|
|
|
|
printf(" state flags: %x", aStateFlags);
|
|
|
|
bool isDocLoading;
|
|
|
|
aWebProgress->GetIsLoadingDocument(&isDocLoading);
|
|
|
|
printf(", document is %sloading\n", (isDocLoading ? "" : "not "));
|
2012-06-01 08:26:28 +04:00
|
|
|
|
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
void logging::DocLoad(const char* aMsg, dom::Document* aDocumentNode) {
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sDocLoadTitle, "%s", aMsg);
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2012-11-03 03:57:58 +04:00
|
|
|
DocAccessible* document = GetExistingDocAccessible(aDocumentNode);
|
2012-05-23 13:21:40 +04:00
|
|
|
LogDocInfo(aDocumentNode, document);
|
2012-06-01 08:26:28 +04:00
|
|
|
|
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2012-10-10 05:01:46 +04:00
|
|
|
void logging::DocCompleteLoad(DocAccessible* aDocument,
|
|
|
|
bool aIsLoadEventTarget) {
|
|
|
|
MsgBegin(sDocLoadTitle, "document loaded *completely*");
|
|
|
|
|
|
|
|
printf(" DOM document: %p, acc document: %p\n",
|
2012-10-12 06:25:34 +04:00
|
|
|
static_cast<void*>(aDocument->DocumentNode()),
|
2012-10-10 05:01:46 +04:00
|
|
|
static_cast<void*>(aDocument));
|
|
|
|
|
|
|
|
printf(" ");
|
2012-10-12 06:25:34 +04:00
|
|
|
LogDocURI(aDocument->DocumentNode());
|
2012-10-10 05:01:46 +04:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf(" ");
|
|
|
|
LogDocAccState(aDocument);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf(" document is load event target: %s\n",
|
|
|
|
(aIsLoadEventTarget ? "true" : "false"));
|
|
|
|
|
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
void logging::DocLoadEventFired(AccEvent* aEvent) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString strEventType;
|
2012-05-23 13:21:40 +04:00
|
|
|
GetDocLoadEventType(aEvent, strEventType);
|
|
|
|
if (!strEventType.IsEmpty()) printf(" fire: %s\n", strEventType.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::DocLoadEventHandled(AccEvent* aEvent) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString strEventType;
|
2012-05-23 13:21:40 +04:00
|
|
|
GetDocLoadEventType(aEvent, strEventType);
|
2012-06-01 08:26:28 +04:00
|
|
|
if (strEventType.IsEmpty()) return;
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2012-06-01 08:26:28 +04:00
|
|
|
MsgBegin(sDocEventTitle, "handled '%s' event", strEventType.get());
|
|
|
|
|
2012-11-20 08:53:38 +04:00
|
|
|
DocAccessible* document = aEvent->GetAccessible()->AsDoc();
|
|
|
|
if (document) LogDocInfo(document->DocumentNode(), document);
|
2012-06-01 08:26:28 +04:00
|
|
|
|
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
void logging::DocCreate(const char* aMsg, dom::Document* aDocumentNode,
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* aDocument) {
|
|
|
|
DocAccessible* document =
|
2012-11-03 03:57:58 +04:00
|
|
|
aDocument ? aDocument : GetExistingDocAccessible(aDocumentNode);
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sDocCreateTitle, "%s", aMsg);
|
2012-05-23 13:21:40 +04:00
|
|
|
LogDocInfo(aDocumentNode, document);
|
2012-06-01 08:26:28 +04:00
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
void logging::DocDestroy(const char* aMsg, dom::Document* aDocumentNode,
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* aDocument) {
|
|
|
|
DocAccessible* document =
|
2012-11-03 03:57:58 +04:00
|
|
|
aDocument ? aDocument : GetExistingDocAccessible(aDocumentNode);
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sDocDestroyTitle, "%s", aMsg);
|
2012-05-23 13:21:40 +04:00
|
|
|
LogDocInfo(aDocumentNode, document);
|
2012-06-01 08:26:28 +04:00
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::OuterDocDestroy(OuterDocAccessible* aOuterDoc) {
|
|
|
|
MsgBegin(sDocDestroyTitle, "outerdoc shutdown");
|
|
|
|
logging::Address("outerdoc", aOuterDoc);
|
|
|
|
MsgEnd();
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
2012-09-27 03:53:23 +04:00
|
|
|
void logging::FocusNotificationTarget(const char* aMsg,
|
|
|
|
const char* aTargetDescr,
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* aTarget) {
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sFocusTitle, "%s", aMsg);
|
2012-09-27 03:53:23 +04:00
|
|
|
AccessibleNNode(aTargetDescr, aTarget);
|
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::FocusNotificationTarget(const char* aMsg,
|
|
|
|
const char* aTargetDescr,
|
|
|
|
nsINode* aTargetNode) {
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sFocusTitle, "%s", aMsg);
|
2012-09-27 03:53:23 +04:00
|
|
|
Node(aTargetDescr, aTargetNode);
|
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::FocusNotificationTarget(const char* aMsg,
|
|
|
|
const char* aTargetDescr,
|
|
|
|
nsISupports* aTargetThing) {
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin(sFocusTitle, "%s", aMsg);
|
2012-09-27 03:53:23 +04:00
|
|
|
|
|
|
|
if (aTargetThing) {
|
|
|
|
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTargetThing));
|
2021-02-20 02:14:32 +03:00
|
|
|
if (targetNode) {
|
2012-10-11 19:13:18 +04:00
|
|
|
AccessibleNNode(aTargetDescr, targetNode);
|
2021-02-20 02:14:32 +03:00
|
|
|
} else {
|
2012-09-27 03:53:23 +04:00
|
|
|
printf(" %s: %p, window\n", aTargetDescr,
|
|
|
|
static_cast<void*>(aTargetThing));
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-09-27 03:53:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::ActiveItemChangeCausedBy(const char* aCause,
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* aTarget) {
|
2012-09-27 03:53:23 +04:00
|
|
|
SubMsgBegin();
|
|
|
|
printf(" Caused by: %s\n", aCause);
|
|
|
|
AccessibleNNode("Item", aTarget);
|
|
|
|
SubMsgEnd();
|
|
|
|
}
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void logging::ActiveWidget(LocalAccessible* aWidget) {
|
2012-09-27 03:53:23 +04:00
|
|
|
SubMsgBegin();
|
|
|
|
|
|
|
|
AccessibleNNode("Widget", aWidget);
|
|
|
|
printf(" Widget is active: %s, has operable items: %s\n",
|
|
|
|
(aWidget && aWidget->IsActiveWidget() ? "true" : "false"),
|
|
|
|
(aWidget && aWidget->AreItemsOperable() ? "true" : "false"));
|
|
|
|
|
|
|
|
SubMsgEnd();
|
|
|
|
}
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void logging::FocusDispatched(LocalAccessible* aTarget) {
|
2012-09-27 03:53:23 +04:00
|
|
|
SubMsgBegin();
|
|
|
|
AccessibleNNode("A11y target", aTarget);
|
|
|
|
SubMsgEnd();
|
|
|
|
}
|
|
|
|
|
2018-05-08 20:52:38 +03:00
|
|
|
void logging::SelChange(dom::Selection* aSelection, DocAccessible* aDocument,
|
2014-02-12 05:18:31 +04:00
|
|
|
int16_t aReason) {
|
2018-05-08 20:52:38 +03:00
|
|
|
SelectionType type = aSelection->GetType();
|
2012-06-02 05:58:44 +04:00
|
|
|
|
|
|
|
const char* strType = 0;
|
2021-02-20 02:14:32 +03:00
|
|
|
if (type == SelectionType::eNormal) {
|
2012-06-02 05:58:44 +04:00
|
|
|
strType = "normal";
|
2021-02-20 02:14:32 +03:00
|
|
|
} else if (type == SelectionType::eSpellCheck) {
|
2012-06-02 05:58:44 +04:00
|
|
|
strType = "spellcheck";
|
2021-02-20 02:14:32 +03:00
|
|
|
} else {
|
2012-06-02 05:58:44 +04:00
|
|
|
strType = "unknown";
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-06-02 05:58:44 +04:00
|
|
|
|
|
|
|
bool isIgnored = !aDocument || !aDocument->IsContentLoaded();
|
2014-02-12 05:18:31 +04:00
|
|
|
printf(
|
|
|
|
"\nSelection changed, selection type: %s, notification %s, reason: %d\n",
|
|
|
|
strType, (isIgnored ? "ignored" : "pending"), aReason);
|
|
|
|
|
|
|
|
Stack();
|
2012-06-02 05:58:44 +04:00
|
|
|
}
|
|
|
|
|
2016-03-01 21:07:20 +03:00
|
|
|
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...) {
|
|
|
|
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
|
|
|
va_list vl;
|
|
|
|
va_start(vl, aExtraFlags);
|
2016-06-08 00:20:12 +03:00
|
|
|
const char* descr = va_arg(vl, const char*);
|
|
|
|
if (descr) {
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* acc = va_arg(vl, LocalAccessible*);
|
2016-06-08 00:20:12 +03:00
|
|
|
MsgBegin("TREE", "%s; doc: %p", aMsg, acc ? acc->Document() : nullptr);
|
|
|
|
AccessibleInfo(descr, acc);
|
|
|
|
while ((descr = va_arg(vl, const char*))) {
|
2021-02-20 02:14:32 +03:00
|
|
|
AccessibleInfo(descr, va_arg(vl, LocalAccessible*));
|
2016-06-08 00:20:12 +03:00
|
|
|
}
|
|
|
|
} else {
|
2017-05-03 23:47:35 +03:00
|
|
|
MsgBegin("TREE", "%s", aMsg);
|
2016-03-01 21:07:20 +03:00
|
|
|
}
|
|
|
|
va_end(vl);
|
|
|
|
MsgEnd();
|
|
|
|
|
|
|
|
if (aExtraFlags & eStack) {
|
|
|
|
Stack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
2021-02-20 02:14:32 +03:00
|
|
|
const char* aMsg1, LocalAccessible* aAcc,
|
|
|
|
const char* aMsg2, nsINode* aNode) {
|
2016-06-08 14:33:06 +03:00
|
|
|
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
2016-06-08 00:20:12 +03:00
|
|
|
MsgBegin("TREE", "%s; doc: %p", aMsg, aAcc ? aAcc->Document() : nullptr);
|
2016-03-01 21:07:20 +03:00
|
|
|
AccessibleInfo(aMsg1, aAcc);
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* acc =
|
|
|
|
aAcc ? aAcc->Document()->GetAccessible(aNode) : nullptr;
|
2016-03-01 21:07:20 +03:00
|
|
|
if (acc) {
|
|
|
|
AccessibleInfo(aMsg2, acc);
|
|
|
|
} else {
|
|
|
|
Node(aMsg2, aNode);
|
|
|
|
}
|
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* aParent) {
|
2016-03-01 21:07:20 +03:00
|
|
|
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
2016-06-08 00:20:12 +03:00
|
|
|
MsgBegin("TREE", "%s; doc: %p", aMsg, aParent->Document());
|
2016-03-01 21:07:20 +03:00
|
|
|
AccessibleInfo("container", aParent);
|
|
|
|
for (uint32_t idx = 0; idx < aParent->ChildCount(); idx++) {
|
2021-02-16 23:05:10 +03:00
|
|
|
AccessibleInfo("child", aParent->LocalChildAt(idx));
|
2016-03-01 21:07:20 +03:00
|
|
|
}
|
|
|
|
MsgEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void logging::Tree(const char* aTitle, const char* aMsgText,
|
|
|
|
LocalAccessible* aRoot, GetTreePrefix aPrefixFunc,
|
|
|
|
void* aGetTreePrefixData) {
|
2017-05-03 23:47:35 +03:00
|
|
|
logging::MsgBegin(aTitle, "%s", aMsgText);
|
2016-06-20 18:35:38 +03:00
|
|
|
|
|
|
|
nsAutoString level;
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* root = aRoot;
|
2016-06-20 18:35:38 +03:00
|
|
|
do {
|
|
|
|
const char* prefix =
|
|
|
|
aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
|
|
|
|
printf("%s", NS_ConvertUTF16toUTF8(level).get());
|
|
|
|
logging::AccessibleInfo(prefix, root);
|
2021-02-16 23:05:10 +03:00
|
|
|
if (root->LocalFirstChild() && !root->LocalFirstChild()->IsDoc()) {
|
2017-09-08 04:32:54 +03:00
|
|
|
level.AppendLiteral(u" ");
|
2021-02-16 23:05:10 +03:00
|
|
|
root = root->LocalFirstChild();
|
2016-06-20 18:35:38 +03:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-19 19:10:58 +03:00
|
|
|
int32_t idxInParent = root != aRoot && root->mParent
|
2016-06-20 18:35:38 +03:00
|
|
|
? root->mParent->mChildren.IndexOf(root)
|
|
|
|
: -1;
|
|
|
|
if (idxInParent != -1 &&
|
|
|
|
idxInParent <
|
|
|
|
static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
|
|
|
|
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
|
|
|
|
continue;
|
|
|
|
}
|
2021-02-16 23:05:10 +03:00
|
|
|
while (root != aRoot && (root = root->LocalParent())) {
|
2016-06-20 18:35:38 +03:00
|
|
|
level.Cut(0, 2);
|
|
|
|
int32_t idxInParent = !root->IsDoc() && root->mParent
|
|
|
|
? root->mParent->mChildren.IndexOf(root)
|
|
|
|
: -1;
|
|
|
|
if (idxInParent != -1 &&
|
|
|
|
idxInParent <
|
|
|
|
static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
|
|
|
|
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-08-19 19:10:58 +03:00
|
|
|
} while (root && root != aRoot);
|
2016-06-20 18:35:38 +03:00
|
|
|
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
|
2016-06-21 14:41:06 +03:00
|
|
|
void logging::DOMTree(const char* aTitle, const char* aMsgText,
|
|
|
|
DocAccessible* aDocument) {
|
2017-05-03 23:47:35 +03:00
|
|
|
logging::MsgBegin(aTitle, "%s", aMsgText);
|
2016-06-21 14:41:06 +03:00
|
|
|
nsAutoString level;
|
|
|
|
nsINode* root = aDocument->DocumentNode();
|
|
|
|
do {
|
|
|
|
printf("%s", NS_ConvertUTF16toUTF8(level).get());
|
|
|
|
logging::Node("", root);
|
|
|
|
if (root->GetFirstChild()) {
|
2017-09-08 04:32:54 +03:00
|
|
|
level.AppendLiteral(u" ");
|
2016-06-21 14:41:06 +03:00
|
|
|
root = root->GetFirstChild();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (root->GetNextSibling()) {
|
|
|
|
root = root->GetNextSibling();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
while ((root = root->GetParentNode())) {
|
|
|
|
level.Cut(0, 2);
|
|
|
|
if (root->GetNextSibling()) {
|
|
|
|
root = root->GetNextSibling();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (root);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
|
2021-05-05 23:56:06 +03:00
|
|
|
void logging::TreeSize(const char* aTitle, const char* aMsgText,
|
|
|
|
LocalAccessible* aRoot) {
|
|
|
|
logging::MsgBegin(aTitle, "%s", aMsgText);
|
|
|
|
logging::AccessibleInfo("Logging tree size from: ", aRoot);
|
|
|
|
size_t b = 0;
|
|
|
|
size_t n = 0;
|
|
|
|
LocalAccessible* root = aRoot;
|
|
|
|
do {
|
|
|
|
// Process the current acc
|
|
|
|
b += AccessibleLoggingMallocSizeOf(root);
|
|
|
|
n++;
|
|
|
|
|
|
|
|
// Get next acc
|
|
|
|
if (root->LocalFirstChild() && !root->LocalFirstChild()->IsDoc()) {
|
|
|
|
root = root->LocalFirstChild();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int32_t idxInParent = root != aRoot && root->mParent
|
|
|
|
? root->mParent->mChildren.IndexOf(root)
|
|
|
|
: -1;
|
|
|
|
if (idxInParent != -1 &&
|
|
|
|
idxInParent <
|
|
|
|
static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
|
|
|
|
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
while (root != aRoot && (root = root->LocalParent())) {
|
|
|
|
int32_t idxInParent = !root->IsDoc() && root->mParent
|
|
|
|
? root->mParent->mChildren.IndexOf(root)
|
|
|
|
: -1;
|
|
|
|
if (idxInParent != -1 &&
|
|
|
|
idxInParent <
|
|
|
|
static_cast<int32_t>(root->mParent->mChildren.Length() - 1)) {
|
|
|
|
root = root->mParent->mChildren.ElementAt(idxInParent + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (root && root != aRoot);
|
|
|
|
|
|
|
|
printf("\nTree contains %zu accessibles and is %zu bytes\n", n, b);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
|
2012-06-01 08:26:28 +04:00
|
|
|
void logging::MsgBegin(const char* aTitle, const char* aMsgText, ...) {
|
|
|
|
printf("\nA11Y %s: ", aTitle);
|
|
|
|
|
|
|
|
va_list argptr;
|
|
|
|
va_start(argptr, aMsgText);
|
|
|
|
vprintf(aMsgText, argptr);
|
|
|
|
va_end(argptr);
|
|
|
|
|
2012-09-27 03:53:23 +04:00
|
|
|
PRIntervalTime time = PR_IntervalNow();
|
|
|
|
uint32_t mins = (PR_IntervalToSeconds(time) / 60) % 60;
|
|
|
|
uint32_t secs = PR_IntervalToSeconds(time) % 60;
|
|
|
|
uint32_t msecs = PR_IntervalToMilliseconds(time) % 1000;
|
2017-11-08 19:42:35 +03:00
|
|
|
printf("; %02u:%02u.%03u", mins, secs, msecs);
|
2012-09-27 03:53:23 +04:00
|
|
|
|
2012-06-01 08:26:28 +04:00
|
|
|
printf("\n {\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::MsgEnd() { printf(" }\n"); }
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2012-09-27 03:53:23 +04:00
|
|
|
void logging::SubMsgBegin() { printf(" {\n"); }
|
|
|
|
|
|
|
|
void logging::SubMsgEnd() { printf(" }\n"); }
|
|
|
|
|
2012-06-01 08:27:25 +04:00
|
|
|
void logging::MsgEntry(const char* aEntryText, ...) {
|
|
|
|
printf(" ");
|
|
|
|
|
|
|
|
va_list argptr;
|
|
|
|
va_start(argptr, aEntryText);
|
|
|
|
vprintf(aEntryText, argptr);
|
|
|
|
va_end(argptr);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
void logging::Text(const char* aText) { printf(" %s\n", aText); }
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void logging::Address(const char* aDescr, LocalAccessible* aAcc) {
|
2012-06-02 05:58:44 +04:00
|
|
|
if (!aAcc->IsDoc()) {
|
|
|
|
printf(" %s accessible: %p, node: %p\n", aDescr,
|
|
|
|
static_cast<void*>(aAcc), static_cast<void*>(aAcc->GetNode()));
|
|
|
|
}
|
|
|
|
|
|
|
|
DocAccessible* doc = aAcc->Document();
|
2019-01-02 16:05:23 +03:00
|
|
|
dom::Document* docNode = doc->DocumentNode();
|
2012-06-02 05:58:44 +04:00
|
|
|
printf(" document: %p, node: %p\n", static_cast<void*>(doc),
|
2012-06-01 08:27:25 +04:00
|
|
|
static_cast<void*>(docNode));
|
2012-06-02 05:58:44 +04:00
|
|
|
|
2012-06-01 08:27:25 +04:00
|
|
|
printf(" ");
|
|
|
|
LogDocURI(docNode);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::Node(const char* aDescr, nsINode* aNode) {
|
2021-12-09 15:03:00 +03:00
|
|
|
Maybe<uint32_t> idxInParent = aNode->ComputeIndexInParentNode();
|
2019-08-09 03:02:51 +03:00
|
|
|
nsAutoString nodeDesc;
|
|
|
|
DescribeNode(aNode, nodeDesc);
|
2021-12-09 14:55:36 +03:00
|
|
|
printf(" %s: %s, idx in parent %s\n", aDescr,
|
|
|
|
NS_ConvertUTF16toUTF8(nodeDesc).get(), ToString(idxInParent).c_str());
|
2012-06-01 08:27:25 +04:00
|
|
|
}
|
|
|
|
|
2012-10-11 19:13:18 +04:00
|
|
|
void logging::Document(DocAccessible* aDocument) {
|
|
|
|
printf(" Document: %p, document node: %p\n", static_cast<void*>(aDocument),
|
2012-10-12 06:25:34 +04:00
|
|
|
static_cast<void*>(aDocument->DocumentNode()));
|
2012-10-11 19:13:18 +04:00
|
|
|
|
|
|
|
printf(" Document ");
|
2012-10-12 06:25:34 +04:00
|
|
|
LogDocURI(aDocument->DocumentNode());
|
2012-10-11 19:13:18 +04:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void logging::AccessibleInfo(const char* aDescr, LocalAccessible* aAccessible) {
|
2016-03-01 21:07:20 +03:00
|
|
|
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
|
|
|
|
if (!aAccessible) {
|
|
|
|
printf("\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (aAccessible->IsDefunct()) {
|
|
|
|
printf("defunct\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!aAccessible->Document() || aAccessible->Document()->IsDefunct()) {
|
|
|
|
printf("document is shutting down, no info\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString role;
|
|
|
|
GetAccService()->GetStringRole(aAccessible->Role(), role);
|
|
|
|
printf("role: %s", NS_ConvertUTF16toUTF8(role).get());
|
|
|
|
|
|
|
|
nsAutoString name;
|
|
|
|
aAccessible->Name(name);
|
|
|
|
if (!name.IsEmpty()) {
|
|
|
|
printf(", name: '%s'", NS_ConvertUTF16toUTF8(name).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(", idx: %d", aAccessible->IndexInParent());
|
|
|
|
|
2019-08-09 03:02:51 +03:00
|
|
|
nsAutoString nodeDesc;
|
|
|
|
DescribeNode(aAccessible->GetNode(), nodeDesc);
|
|
|
|
printf(", node: %s\n", NS_ConvertUTF16toUTF8(nodeDesc).get());
|
2016-03-01 21:07:20 +03:00
|
|
|
}
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void logging::AccessibleNNode(const char* aDescr,
|
|
|
|
LocalAccessible* aAccessible) {
|
2012-09-27 03:53:23 +04:00
|
|
|
printf(" %s: %p; ", aDescr, static_cast<void*>(aAccessible));
|
|
|
|
if (!aAccessible) return;
|
|
|
|
|
|
|
|
nsAutoString role;
|
|
|
|
GetAccService()->GetStringRole(aAccessible->Role(), role);
|
|
|
|
nsAutoString name;
|
|
|
|
aAccessible->Name(name);
|
|
|
|
|
|
|
|
printf("role: %s, name: '%s';\n", NS_ConvertUTF16toUTF8(role).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(name).get());
|
|
|
|
|
|
|
|
nsAutoCString nodeDescr(aDescr);
|
|
|
|
nodeDescr.AppendLiteral(" node");
|
|
|
|
Node(nodeDescr.get(), aAccessible->GetNode());
|
|
|
|
|
2012-10-11 19:13:18 +04:00
|
|
|
Document(aAccessible->Document());
|
2012-09-27 03:53:23 +04:00
|
|
|
}
|
|
|
|
|
2012-10-05 17:00:28 +04:00
|
|
|
void logging::AccessibleNNode(const char* aDescr, nsINode* aNode) {
|
|
|
|
DocAccessible* document =
|
|
|
|
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
|
|
|
|
|
|
|
|
if (document) {
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* accessible = document->GetAccessible(aNode);
|
2012-10-05 17:00:28 +04:00
|
|
|
if (accessible) {
|
|
|
|
AccessibleNNode(aDescr, accessible);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-11 19:13:18 +04:00
|
|
|
nsAutoCString nodeDescr("[not accessible] ");
|
2012-10-05 17:00:28 +04:00
|
|
|
nodeDescr.Append(aDescr);
|
|
|
|
Node(nodeDescr.get(), aNode);
|
2012-10-11 19:13:18 +04:00
|
|
|
|
|
|
|
if (document) {
|
|
|
|
Document(document);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" [contained by not accessible document]:\n");
|
|
|
|
LogDocInfo(aNode->OwnerDoc(), document);
|
|
|
|
printf("\n");
|
2012-10-05 17:00:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void logging::DOMEvent(const char* aDescr, nsINode* aOrigTarget,
|
|
|
|
const nsAString& aEventType) {
|
|
|
|
logging::MsgBegin("DOMEvents", "event '%s' %s",
|
|
|
|
NS_ConvertUTF16toUTF8(aEventType).get(), aDescr);
|
|
|
|
logging::AccessibleNNode("Target", aOrigTarget);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
void logging::Stack() {
|
2012-06-01 08:26:28 +04:00
|
|
|
if (IsEnabled(eStack)) {
|
|
|
|
printf(" stack: \n");
|
2021-03-23 00:25:30 +03:00
|
|
|
MozWalkTheStack(stdout);
|
2012-06-01 08:26:28 +04:00
|
|
|
}
|
2012-05-23 13:21:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// namespace logging:: initialization
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
bool logging::IsEnabled(uint32_t aModules) { return sModules & aModules; }
|
2012-05-23 13:21:40 +04:00
|
|
|
|
2016-03-01 21:07:20 +03:00
|
|
|
bool logging::IsEnabledAll(uint32_t aModules) {
|
|
|
|
return (sModules & aModules) == aModules;
|
|
|
|
}
|
|
|
|
|
2012-11-04 06:19:56 +04:00
|
|
|
bool logging::IsEnabled(const nsAString& aModuleStr) {
|
|
|
|
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
|
2021-02-20 02:14:32 +03:00
|
|
|
if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr)) {
|
2012-11-04 06:19:56 +04:00
|
|
|
return sModules & sModuleMap[idx].mModule;
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2012-11-04 06:19:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-20 12:19:05 +03:00
|
|
|
void logging::Enable(const nsCString& aModules) {
|
2012-05-23 13:21:40 +04:00
|
|
|
EnableLogging(aModules.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void logging::CheckEnv() { EnableLogging(PR_GetEnv("A11YLOG")); }
|