зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1251752 - logging: add tree specific methods, r=yzen
This commit is contained in:
Родитель
c3f1865ad8
Коммит
b5d992383d
|
@ -45,14 +45,16 @@ static ModuleRep sModuleMap[] = {
|
|||
|
||||
{ "events", logging::eEvents },
|
||||
{ "platforms", logging::ePlatforms },
|
||||
{ "stack", logging::eStack },
|
||||
{ "text", logging::eText },
|
||||
{ "tree", logging::eTree },
|
||||
|
||||
{ "DOMEvents", logging::eDOMEvents },
|
||||
{ "focus", logging::eFocus },
|
||||
{ "selection", logging::eSelection },
|
||||
{ "notifications", logging::eNotifications }
|
||||
{ "notifications", logging::eNotifications },
|
||||
|
||||
{ "stack", logging::eStack },
|
||||
{ "verbose", logging::eVerbose }
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -606,6 +608,61 @@ logging::SelChange(nsISelection* aSelection, DocAccessible* aDocument,
|
|||
Stack();
|
||||
}
|
||||
|
||||
void
|
||||
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...)
|
||||
{
|
||||
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
||||
MsgBegin("TREE", aMsg);
|
||||
|
||||
va_list vl;
|
||||
va_start(vl, aExtraFlags);
|
||||
const char* descr = nullptr;
|
||||
while ((descr = va_arg(vl, const char*))) {
|
||||
AccessibleInfo(descr, va_arg(vl, Accessible*));
|
||||
}
|
||||
va_end(vl);
|
||||
|
||||
MsgEnd();
|
||||
|
||||
if (aExtraFlags & eStack) {
|
||||
Stack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
||||
const char* aMsg1, Accessible* aAcc,
|
||||
const char* aMsg2, nsINode* aNode)
|
||||
{
|
||||
if (IsEnabledAll(logging::eTree | logging::eVerbose)) {
|
||||
MsgBegin("TREE", aMsg);
|
||||
AccessibleInfo(aMsg1, aAcc);
|
||||
Accessible* acc = aAcc->Document()->GetAccessible(aNode);
|
||||
if (acc) {
|
||||
AccessibleInfo(aMsg2, acc);
|
||||
}
|
||||
else {
|
||||
Node(aMsg2, aNode);
|
||||
}
|
||||
MsgEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
|
||||
{
|
||||
if (IsEnabledAll(logging::eTree | aExtraFlags)) {
|
||||
MsgBegin("TREE", aMsg);
|
||||
AccessibleInfo("container", aParent);
|
||||
for (uint32_t idx = 0; idx < aParent->ChildCount(); idx++) {
|
||||
AccessibleInfo("child", aParent->GetChildAt(idx));
|
||||
}
|
||||
MsgEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
|
||||
{
|
||||
|
@ -736,6 +793,62 @@ logging::Document(DocAccessible* aDocument)
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
|
||||
{
|
||||
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());
|
||||
|
||||
nsINode* node = aAccessible->GetNode();
|
||||
if (!node) {
|
||||
printf(", node: null\n");
|
||||
}
|
||||
else if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
|
||||
printf(", document node: %p\n", static_cast<void*>(node));
|
||||
}
|
||||
else if (node->IsNodeOfType(nsINode::eTEXT)) {
|
||||
printf(", text node: %p\n", static_cast<void*>(node));
|
||||
}
|
||||
else if (node->IsElement()) {
|
||||
dom::Element* el = node->AsElement();
|
||||
|
||||
nsAutoCString tag;
|
||||
el->NodeInfo()->NameAtom()->ToUTF8String(tag);
|
||||
|
||||
nsIAtom* idAtom = el->GetID();
|
||||
nsAutoCString id;
|
||||
if (idAtom) {
|
||||
idAtom->ToUTF8String(id);
|
||||
}
|
||||
|
||||
printf(", element node: %p, %s@id='%s'\n",
|
||||
static_cast<void*>(el), tag.get(), id.get());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
logging::AccessibleNNode(const char* aDescr, Accessible* aAccessible)
|
||||
{
|
||||
|
@ -814,6 +927,12 @@ logging::IsEnabled(uint32_t aModules)
|
|||
return sModules & aModules;
|
||||
}
|
||||
|
||||
bool
|
||||
logging::IsEnabledAll(uint32_t aModules)
|
||||
{
|
||||
return (sModules & aModules) == aModules;
|
||||
}
|
||||
|
||||
bool
|
||||
logging::IsEnabled(const nsAString& aModuleStr)
|
||||
{
|
||||
|
|
|
@ -35,14 +35,17 @@ enum EModules {
|
|||
|
||||
eEvents = 1 << 3,
|
||||
ePlatforms = 1 << 4,
|
||||
eStack = 1 << 5,
|
||||
eText = 1 << 6,
|
||||
eTree = 1 << 7,
|
||||
eText = 1 << 5,
|
||||
eTree = 1 << 6,
|
||||
|
||||
eDOMEvents = 1 << 8,
|
||||
eFocus = 1 << 9,
|
||||
eSelection = 1 << 10,
|
||||
eNotifications = eDOMEvents | eSelection | eFocus
|
||||
eDOMEvents = 1 << 7,
|
||||
eFocus = 1 << 8,
|
||||
eSelection = 1 << 9,
|
||||
eNotifications = eDOMEvents | eSelection | eFocus,
|
||||
|
||||
// extras
|
||||
eStack = 1 << 10,
|
||||
eVerbose = 1 << 11
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -50,6 +53,11 @@ enum EModules {
|
|||
*/
|
||||
bool IsEnabled(uint32_t aModules);
|
||||
|
||||
/**
|
||||
* Return true if all of the given modules are logged.
|
||||
*/
|
||||
bool IsEnabledAll(uint32_t aModules);
|
||||
|
||||
/**
|
||||
* Return true if the given module is logged.
|
||||
*/
|
||||
|
@ -121,6 +129,15 @@ void FocusDispatched(Accessible* aTarget);
|
|||
void SelChange(nsISelection* aSelection, DocAccessible* aDocument,
|
||||
int16_t aReason);
|
||||
|
||||
/**
|
||||
* Log the given accessible elements info.
|
||||
*/
|
||||
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, ...);
|
||||
void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
|
||||
const char* aMsg1, Accessible* aAcc,
|
||||
const char* aMsg2, nsINode* aNode);
|
||||
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -164,6 +181,7 @@ void Document(DocAccessible* aDocument);
|
|||
/**
|
||||
* Log the accessible and its DOM node as a message entry.
|
||||
*/
|
||||
void AccessibleInfo(const char* aDescr, Accessible* aAccessible);
|
||||
void AccessibleNNode(const char* aDescr, Accessible* aAccessible);
|
||||
void AccessibleNNode(const char* aDescr, nsINode* aNode);
|
||||
|
||||
|
@ -189,7 +207,8 @@ void Enable(const nsAFlatCString& aModules);
|
|||
*/
|
||||
void CheckEnv();
|
||||
|
||||
} // namespace logs
|
||||
} // namespace logging
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче