Bug 1278294 - move accessible tree logging into separate method, part=6, r=yzen

This commit is contained in:
Alexander Surkov 2016-06-20 11:35:38 -04:00
Родитель 150bcb573b
Коммит f33c2d2c00
5 изменённых файлов: 84 добавлений и 44 удалений

Просмотреть файл

@ -36,52 +36,10 @@ TreeMutation::TreeMutation(Accessible* aParent, bool aNoEvents) :
Controller()->RootEventTree().Log();
logging::MsgEnd();
logging::MsgBegin("EVENTS_TREE", "Container tree");
if (logging::IsEnabled(logging::eVerbose)) {
nsAutoString level;
Accessible* root = mParent->Document();
do {
const char* prefix = "";
if (mParent == root) {
prefix = "_X_";
}
else {
const EventTree& ret = Controller()->RootEventTree();
if (ret.Find(root)) {
prefix = "_с_";
}
}
printf("%s", NS_ConvertUTF16toUTF8(level).get());
logging::AccessibleInfo(prefix, root);
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
level.Append(NS_LITERAL_STRING(" "));
root = root->FirstChild();
continue;
}
int32_t idxInParent = 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 = root->Parent()) && !root->IsDoc()) {
level.Cut(0, 2);
int32_t idxInParent = 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->IsDoc());
logging::Tree("EVENTS_TREE", "Container tree", mParent->Document(),
PrefixLog, static_cast<void*>(this));
}
logging::MsgEnd();
}
#endif
@ -173,6 +131,22 @@ TreeMutation::Done()
#endif
}
#ifdef A11Y_LOG
const char*
TreeMutation::PrefixLog(void* aData, Accessible* aAcc)
{
TreeMutation* thisObj = reinterpret_cast<TreeMutation*>(aData);
if (thisObj->mParent == aAcc) {
return "_X_";
}
const EventTree& ret = thisObj->Controller()->RootEventTree();
if (ret.Find(aAcc)) {
return "_с_";
}
return "";
}
#endif
////////////////////////////////////////////////////////////////////////////////
// EventTree

Просмотреть файл

@ -39,6 +39,10 @@ private:
static EventTree* const kNoEventTree;
#ifdef A11Y_LOG
static const char* PrefixLog(void* aData, Accessible*);
#endif
Accessible* mParent;
uint32_t mStartIdx;
uint32_t mStateFlagsCopy;

Просмотреть файл

@ -673,6 +673,47 @@ logging::TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent)
}
}
void
logging::Tree(const char* aTitle, const char* aMsgText,
DocAccessible* aDocument, GetTreePrefix aPrefixFunc,
void* aGetTreePrefixData)
{
logging::MsgBegin(aTitle, aMsgText);
nsAutoString level;
Accessible* root = aDocument;
do {
const char* prefix = aPrefixFunc ? aPrefixFunc(aGetTreePrefixData, root) : "";
printf("%s", NS_ConvertUTF16toUTF8(level).get());
logging::AccessibleInfo(prefix, root);
if (root->FirstChild() && !root->FirstChild()->IsDoc()) {
level.Append(NS_LITERAL_STRING(" "));
root = root->FirstChild();
continue;
}
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);
continue;
}
while (!root->IsDoc() && (root = root->Parent())) {
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;
}
}
}
while (root && !root->IsDoc());
logging::MsgEnd();
}
void
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
{

Просмотреть файл

@ -139,6 +139,13 @@ void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
const char* aMsg2, nsINode* aNode);
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
/**
* Log the accessible tree.
*/
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
void Tree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc,
GetTreePrefix aPrefixFunc = nullptr, void* aGetTreePrefixData = nullptr);
/**
* 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

Просмотреть файл

@ -50,6 +50,14 @@ class TextLeafAccessible;
class XULLabelAccessible;
class XULTreeAccessible;
#ifdef A11Y_LOG
namespace logging {
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
void Tree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc,
GetTreePrefix aPrefixFunc, void* GetTreePrefixData);
};
#endif
/**
* Name type flags.
*/
@ -1120,6 +1128,12 @@ protected:
void StaticAsserts() const;
#ifdef A11Y_LOG
friend void logging::Tree(const char* aTitle, const char* aMsgText,
DocAccessible* aDoc,
logging::GetTreePrefix aPrefixFunc,
void* aGetTreePrefixData);
#endif
friend class DocAccessible;
friend class xpcAccessible;
friend class TreeMutation;