1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "views/debug_utils.h"
7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h"
9 #include "views/view.h"
20 void PrintViewHierarchyImp(const View
* view
, int indent
) {
21 std::wostringstream buf
;
25 buf
<< UTF8ToWide(view
->GetClassName());
29 buf
<< view
->x() << L
"," << view
->y() << L
",";
30 buf
<< view
->bounds().right() << L
"," << view
->bounds().bottom();
35 std::cout
<< buf
.str() << std::endl
;
37 for (int i
= 0, count
= view
->child_count(); i
< count
; ++i
)
38 PrintViewHierarchyImp(view
->GetChildViewAt(i
), indent
+ 2);
41 void PrintFocusHierarchyImp(const View
* view
, int indent
) {
42 std::wostringstream buf
;
46 buf
<< UTF8ToWide(view
->GetClassName());
50 buf
<< view
->GetClassName().c_str();
55 std::cout
<< buf
.str() << std::endl
;
57 if (view
->child_count() > 0)
58 PrintFocusHierarchyImp(view
->GetChildViewAt(0), indent
+ 2);
60 const View
* next_focusable
= view
->GetNextFocusableView();
62 PrintFocusHierarchyImp(next_focusable
, indent
);
66 void PrintViewHierarchy(const View
* view
) {
67 PrintViewHierarchyImp(view
, 0);
70 void PrintFocusHierarchy(const View
* view
) {
71 PrintFocusHierarchyImp(view
, 0);