Fix cookie searchbox bug.
[chromium-blink-merge.git] / ui / views / debug_utils.cc
blob8259d6212eb6734da2dc4da0141f584ebfcefb65
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"
11 #ifndef NDEBUG
12 #include <iostream>
13 #endif
15 #ifndef NDEBUG
17 namespace views {
18 namespace {
19 void PrintViewHierarchyImp(const View* view, int indent) {
20 std::wostringstream buf;
21 int ind = indent;
22 while (ind-- > 0)
23 buf << L' ';
24 buf << UTF8ToWide(view->GetClassName());
25 buf << L' ';
26 buf << view->id();
27 buf << L' ';
28 buf << view->x() << L"," << view->y() << L",";
29 buf << view->bounds().right() << L"," << view->bounds().bottom();
30 buf << L' ';
31 buf << view;
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;
42 int ind = indent;
43 while (ind-- > 0)
44 buf << L' ';
45 buf << UTF8ToWide(view->GetClassName());
46 buf << L' ';
47 buf << view->id();
48 buf << L' ';
49 buf << view->GetClassName().c_str();
50 buf << L' ';
51 buf << view;
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();
60 if (next_focusable)
61 PrintFocusHierarchyImp(next_focusable, indent);
63 } // namespace
65 void PrintViewHierarchy(const View* view) {
66 PrintViewHierarchyImp(view, 0);
69 void PrintFocusHierarchy(const View* view) {
70 PrintFocusHierarchyImp(view, 0);
73 } // namespace views
75 #endif // NDEBUG