This source file includes following definitions.
- PrintViewHierarchyImp
- PrintFocusHierarchyImp
- PrintViewHierarchy
- PrintFocusHierarchy
#include "ui/views/debug_utils.h"
#include <iostream>
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/views/view.h"
namespace views {
namespace {
void PrintViewHierarchyImp(const View* view,
int indent,
std::wostringstream* out) {
int ind = indent;
while (ind-- > 0)
*out << L' ';
*out << base::UTF8ToWide(view->GetClassName());
*out << L' ';
*out << view->id();
*out << L' ';
*out << view->x() << L"," << view->y() << L",";
*out << view->bounds().right() << L"," << view->bounds().bottom();
*out << L' ';
*out << view;
*out << L'\n';
for (int i = 0, count = view->child_count(); i < count; ++i)
PrintViewHierarchyImp(view->child_at(i), indent + 2, out);
}
void PrintFocusHierarchyImp(const View* view,
int indent,
std::wostringstream* out) {
int ind = indent;
while (ind-- > 0)
*out << L' ';
*out << base::UTF8ToWide(view->GetClassName());
*out << L' ';
*out << view->id();
*out << L' ';
*out << view->GetClassName();
*out << L' ';
*out << view;
*out << L'\n';
if (view->child_count() > 0)
PrintFocusHierarchyImp(view->child_at(0), indent + 2, out);
const View* next_focusable = view->GetNextFocusableView();
if (next_focusable)
PrintFocusHierarchyImp(next_focusable, indent, out);
}
}
void PrintViewHierarchy(const View* view) {
std::wostringstream out;
out << L"View hierarchy:\n";
PrintViewHierarchyImp(view, 0, &out);
LOG(ERROR) << out.str();
}
void PrintFocusHierarchy(const View* view) {
std::wostringstream out;
out << L"Focus hierarchy:\n";
PrintFocusHierarchyImp(view, 0, &out);
LOG(ERROR) << out.str();
}
}