mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 759641 - small clean up of a11y logging, r=tbsaunde
This commit is contained in:
parent
94eb2b6481
commit
e3c338dfaf
@ -7,9 +7,10 @@
|
||||
#include "Logging.h"
|
||||
|
||||
#include "AccEvent.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsCoreUtils.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "OuterDocAccessible.h"
|
||||
|
||||
#include "nsDocShellLoadTypes.h"
|
||||
#include "nsIChannel.h"
|
||||
@ -43,7 +44,8 @@ EnableLogging(const char* aModulesStr)
|
||||
{ "doccreate", logging::eDocCreate },
|
||||
{ "docdestroy", logging::eDocDestroy },
|
||||
{ "doclifecycle", logging::eDocLifeCycle },
|
||||
{ "platforms", logging::ePlatforms }
|
||||
{ "platforms", logging::ePlatforms },
|
||||
{ "stack", logging::eStack }
|
||||
};
|
||||
|
||||
const char* token = aModulesStr;
|
||||
@ -182,8 +184,6 @@ LogDocParent(nsIDocument* aDocumentNode)
|
||||
static void
|
||||
LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
|
||||
{
|
||||
printf(" {\n");
|
||||
|
||||
printf(" DOM id: %p, acc id: %p\n ",
|
||||
static_cast<void*>(aDocumentNode), static_cast<void*>(aDocument));
|
||||
|
||||
@ -206,8 +206,6 @@ LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
|
||||
LogDocParent(aDocumentNode);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf(" }\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -334,21 +332,30 @@ GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// namespace logging:: document life cycle logging methods
|
||||
|
||||
static const char* sDocLoadTitle = "DOCLOAD";
|
||||
static const char* sDocCreateTitle = "DOCCREATE";
|
||||
static const char* sDocDestroyTitle = "DOCDESTROY";
|
||||
static const char* sDocEventTitle = "DOCEVENT";
|
||||
|
||||
void
|
||||
logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest, PRUint32 aStateFlags)
|
||||
{
|
||||
printf("\nA11Y DOCLOAD: %s\n", aMsg);
|
||||
MsgBegin(sDocLoadTitle, aMsg);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> DOMWindow;
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow));
|
||||
if (!DOMWindow)
|
||||
if (!DOMWindow) {
|
||||
MsgEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> DOMDocument;
|
||||
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
|
||||
if (!DOMDocument)
|
||||
if (!DOMDocument) {
|
||||
MsgEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> documentNode(do_QueryInterface(DOMDocument));
|
||||
DocAccessible* document =
|
||||
@ -356,10 +363,9 @@ logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
||||
|
||||
LogDocInfo(documentNode, document);
|
||||
|
||||
printf(" {\n");
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
|
||||
printf(" ");
|
||||
printf("\n ");
|
||||
LogShellLoadType(docShell);
|
||||
printf("\n");
|
||||
LogRequest(aRequest);
|
||||
@ -368,17 +374,20 @@ logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
||||
bool isDocLoading;
|
||||
aWebProgress->GetIsLoadingDocument(&isDocLoading);
|
||||
printf(", document is %sloading\n", (isDocLoading ? "" : "not "));
|
||||
printf(" }\n");
|
||||
|
||||
MsgEnd();
|
||||
}
|
||||
|
||||
void
|
||||
logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode)
|
||||
{
|
||||
printf("\nA11Y DOCLOAD: %s\n", aMsg);
|
||||
MsgBegin(sDocLoadTitle, aMsg);
|
||||
|
||||
DocAccessible* document =
|
||||
GetAccService()->GetDocAccessibleFromCache(aDocumentNode);
|
||||
LogDocInfo(aDocumentNode, document);
|
||||
|
||||
MsgEnd();
|
||||
}
|
||||
|
||||
void
|
||||
@ -395,18 +404,19 @@ logging::DocLoadEventHandled(AccEvent* aEvent)
|
||||
{
|
||||
nsCAutoString strEventType;
|
||||
GetDocLoadEventType(aEvent, strEventType);
|
||||
if (!strEventType.IsEmpty()) {
|
||||
printf("\nA11Y DOCEVENT: handled '%s' event ", strEventType.get());
|
||||
if (strEventType.IsEmpty())
|
||||
return;
|
||||
|
||||
nsINode* node = aEvent->GetNode();
|
||||
if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
|
||||
nsIDocument* documentNode = static_cast<nsIDocument*>(node);
|
||||
DocAccessible* document = aEvent->GetDocAccessible();
|
||||
LogDocInfo(documentNode, document);
|
||||
}
|
||||
MsgBegin(sDocEventTitle, "handled '%s' event", strEventType.get());
|
||||
|
||||
printf("\n");
|
||||
nsINode* node = aEvent->GetNode();
|
||||
if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
|
||||
nsIDocument* documentNode = static_cast<nsIDocument*>(node);
|
||||
DocAccessible* document = aEvent->GetDocAccessible();
|
||||
LogDocInfo(documentNode, document);
|
||||
}
|
||||
|
||||
MsgEnd();
|
||||
}
|
||||
|
||||
void
|
||||
@ -416,8 +426,9 @@ logging::DocCreate(const char* aMsg, nsIDocument* aDocumentNode,
|
||||
DocAccessible* document = aDocument ?
|
||||
aDocument : GetAccService()->GetDocAccessibleFromCache(aDocumentNode);
|
||||
|
||||
printf("\nA11Y DOCCREATE: %s\n", aMsg);
|
||||
MsgBegin(sDocCreateTitle, aMsg);
|
||||
LogDocInfo(aDocumentNode, document);
|
||||
MsgEnd();
|
||||
}
|
||||
|
||||
void
|
||||
@ -427,8 +438,17 @@ logging::DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
|
||||
DocAccessible* document = aDocument ?
|
||||
aDocument : GetAccService()->GetDocAccessibleFromCache(aDocumentNode);
|
||||
|
||||
printf("\nA11Y DOCDESTROY: %s\n", aMsg);
|
||||
MsgBegin(sDocDestroyTitle, aMsg);
|
||||
LogDocInfo(aDocumentNode, document);
|
||||
MsgEnd();
|
||||
}
|
||||
|
||||
void
|
||||
logging::OuterDocDestroy(OuterDocAccessible* aOuterDoc)
|
||||
{
|
||||
MsgBegin(sDocDestroyTitle, "outerdoc shutdown");
|
||||
logging::Address("outerdoc", aOuterDoc);
|
||||
MsgEnd();
|
||||
}
|
||||
|
||||
void
|
||||
@ -437,19 +457,32 @@ logging::Address(const char* aDescr, Accessible* aAcc)
|
||||
nsINode* node = aAcc->GetNode();
|
||||
nsIDocument* docNode = aAcc->GetDocumentNode();
|
||||
DocAccessible* doc = GetAccService()->GetDocAccessibleFromCache(docNode);
|
||||
printf(" %s accessible: %p, node: %p\n", aDescr,
|
||||
printf(" %s accessible: %p, node: %p\n", aDescr,
|
||||
static_cast<void*>(aAcc), static_cast<void*>(node));
|
||||
printf(" docacc for %s accessible: %p, node: %p\n", aDescr,
|
||||
printf(" docacc for %s accessible: %p, node: %p\n", aDescr,
|
||||
static_cast<void*>(doc), static_cast<void*>(docNode));
|
||||
printf(" ");
|
||||
printf(" ");
|
||||
LogDocURI(docNode);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
logging::Msg(const char* aMsg)
|
||||
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
|
||||
{
|
||||
printf("\n%s\n", aMsg);
|
||||
printf("\nA11Y %s: ", aTitle);
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, aMsgText);
|
||||
vprintf(aMsgText, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
printf("\n {\n");
|
||||
}
|
||||
|
||||
void
|
||||
logging::MsgEnd()
|
||||
{
|
||||
printf(" }\n");
|
||||
}
|
||||
|
||||
void
|
||||
@ -461,8 +494,10 @@ logging::Text(const char* aText)
|
||||
void
|
||||
logging::Stack()
|
||||
{
|
||||
printf(" stack: \n");
|
||||
nsTraceRefcntImpl::WalkTheStack(stdout);
|
||||
if (IsEnabled(eStack)) {
|
||||
printf(" stack: \n");
|
||||
nsTraceRefcntImpl::WalkTheStack(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -19,6 +19,9 @@ class nsIWebProgress;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class OuterDocAccessible;
|
||||
|
||||
namespace logging {
|
||||
|
||||
enum EModules {
|
||||
@ -26,7 +29,8 @@ enum EModules {
|
||||
eDocCreate = 1 << 1,
|
||||
eDocDestroy = 1 << 2,
|
||||
eDocLifeCycle = eDocLoad | eDocCreate | eDocDestroy,
|
||||
ePlatforms = 1 << 3
|
||||
ePlatforms = 1 << 3,
|
||||
eStack = 1 << 4
|
||||
};
|
||||
|
||||
/**
|
||||
@ -64,9 +68,17 @@ void DocDestroy(const char* aMsg, nsIDocument* aDocumentNode,
|
||||
DocAccessible* aDocument = nsnull);
|
||||
|
||||
/**
|
||||
* Log the message, a piece of text on own line, no offset.
|
||||
* Log the outer document was destroyed.
|
||||
*/
|
||||
void Msg(const char* aMsg);
|
||||
void OuterDocDestroy(OuterDocAccessible* OuterDoc);
|
||||
|
||||
/**
|
||||
* Log the message ('title: text' format) on new line. Print the start and end
|
||||
* boundaries of the message body designated by '{' and '}' (2 spaces indent for
|
||||
* body).
|
||||
*/
|
||||
void MsgBegin(const char* aTitle, const char* aMsgText, ...);
|
||||
void MsgEnd();
|
||||
|
||||
/**
|
||||
* Log the text, two spaces offset is used.
|
||||
@ -74,7 +86,7 @@ void Msg(const char* aMsg);
|
||||
void Text(const char* aText);
|
||||
|
||||
/**
|
||||
* Log the accesisble object address, two spaces offset is used.
|
||||
* Log the accesisble object address (4 spaces indent).
|
||||
*/
|
||||
void Address(const char* aDescr, Accessible* aAcc);
|
||||
|
||||
|
@ -124,10 +124,8 @@ OuterDocAccessible::Shutdown()
|
||||
// the document doesn't get pagehide events. Shutdown underlying document if
|
||||
// any to avoid hanging document accessible.
|
||||
#ifdef DEBUG
|
||||
if (logging::IsEnabled(logging::eDocDestroy)) {
|
||||
logging::Msg("A11y outerdoc shutdown");
|
||||
logging::Address("outerdoc", this);
|
||||
}
|
||||
if (logging::IsEnabled(logging::eDocDestroy))
|
||||
logging::OuterDocDestroy(this);
|
||||
#endif
|
||||
|
||||
Accessible* childAcc = mChildren.SafeElementAt(0, nsnull);
|
||||
@ -135,7 +133,7 @@ OuterDocAccessible::Shutdown()
|
||||
#ifdef DEBUG
|
||||
if (logging::IsEnabled(logging::eDocDestroy)) {
|
||||
logging::DocDestroy("outerdoc's child document shutdown",
|
||||
childAcc->GetDocumentNode());
|
||||
childAcc->GetDocumentNode());
|
||||
}
|
||||
#endif
|
||||
childAcc->Shutdown();
|
||||
@ -179,7 +177,7 @@ OuterDocAccessible::AppendChild(Accessible* aAccessible)
|
||||
#ifdef DEBUG
|
||||
if (logging::IsEnabled(logging::eDocCreate)) {
|
||||
logging::DocCreate("append document to outerdoc",
|
||||
aAccessible->GetDocumentNode());
|
||||
aAccessible->GetDocumentNode());
|
||||
logging::Address("outerdoc", this);
|
||||
}
|
||||
#endif
|
||||
@ -199,7 +197,7 @@ OuterDocAccessible::RemoveChild(Accessible* aAccessible)
|
||||
#ifdef DEBUG
|
||||
if (logging::IsEnabled(logging::eDocDestroy)) {
|
||||
logging::DocDestroy("remove document from outerdoc", child->GetDocumentNode(),
|
||||
child->AsDoc());
|
||||
child->AsDoc());
|
||||
logging::Address("outerdoc", this);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user