1 // Copyright (c) 2012 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 "ui/views/debug_utils.h"
7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h"
9 #include "ui/views/view.h"
19 void PrintViewHierarchyImp(const View
* view
, int indent
) {
20 std::wostringstream buf
;
24 buf
<< UTF8ToWide(view
->GetClassName());
28 buf
<< view
->x() << L
"," << view
->y() << L
",";
29 buf
<< view
->bounds().right() << L
"," << view
->bounds().bottom();
33 DVLOG(1) << buf
.str();
34 std::cout
<< buf
.str() << std::endl
;
36 for (int i
= 0, count
= view
->child_count(); i
< count
; ++i
)
37 PrintViewHierarchyImp(view
->child_at(i
), indent
+ 2);
40 void PrintFocusHierarchyImp(const View
* view
, int indent
) {
41 std::wostringstream buf
;
45 buf
<< UTF8ToWide(view
->GetClassName());
49 buf
<< view
->GetClassName().c_str();
53 DVLOG(1) << buf
.str();
54 std::cout
<< buf
.str() << std::endl
;
56 if (view
->child_count() > 0)
57 PrintFocusHierarchyImp(view
->child_at(0), indent
+ 2);
59 const View
* next_focusable
= view
->GetNextFocusableView();
61 PrintFocusHierarchyImp(next_focusable
, indent
);
65 void PrintViewHierarchy(const View
* view
) {
66 PrintViewHierarchyImp(view
, 0);
69 void PrintFocusHierarchy(const View
* view
) {
70 PrintFocusHierarchyImp(view
, 0);