OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/debug_utils.h" | 5 #include "ui/views/debug_utils.h" |
6 | 6 |
7 #include <iostream> | |
8 | |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
9 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
10 | 12 |
11 #ifndef NDEBUG | |
12 #include <iostream> | |
13 #endif | |
14 | |
15 #ifndef NDEBUG | |
16 | |
17 namespace views { | 13 namespace views { |
18 namespace { | 14 namespace { |
19 void PrintViewHierarchyImp(const View* view, int indent) { | 15 void PrintViewHierarchyImp(const View* view, int indent) { |
20 std::wostringstream buf; | 16 std::wostringstream buf; |
21 int ind = indent; | 17 int ind = indent; |
22 while (ind-- > 0) | 18 while (ind-- > 0) |
23 buf << L' '; | 19 buf << L' '; |
24 buf << UTF8ToWide(view->GetClassName()); | 20 buf << UTF8ToWide(view->GetClassName()); |
25 buf << L' '; | 21 buf << L' '; |
26 buf << view->id(); | 22 buf << view->id(); |
27 buf << L' '; | 23 buf << L' '; |
28 buf << view->x() << L"," << view->y() << L","; | 24 buf << view->x() << L"," << view->y() << L","; |
29 buf << view->bounds().right() << L"," << view->bounds().bottom(); | 25 buf << view->bounds().right() << L"," << view->bounds().bottom(); |
30 buf << L' '; | 26 buf << L' '; |
31 buf << view; | 27 buf << view; |
32 | 28 |
33 DVLOG(1) << buf.str(); | 29 // Warning so users in the field can generate and upload logs. |
34 std::cout << buf.str() << std::endl; | 30 LOG(WARNING) << buf.str(); |
35 | 31 |
36 for (int i = 0, count = view->child_count(); i < count; ++i) | 32 for (int i = 0, count = view->child_count(); i < count; ++i) |
37 PrintViewHierarchyImp(view->child_at(i), indent + 2); | 33 PrintViewHierarchyImp(view->child_at(i), indent + 2); |
38 } | 34 } |
39 | 35 |
40 void PrintFocusHierarchyImp(const View* view, int indent) { | 36 void PrintFocusHierarchyImp(const View* view, int indent) { |
41 std::wostringstream buf; | 37 std::wostringstream buf; |
42 int ind = indent; | 38 int ind = indent; |
43 while (ind-- > 0) | 39 while (ind-- > 0) |
44 buf << L' '; | 40 buf << L' '; |
45 buf << UTF8ToWide(view->GetClassName()); | 41 buf << UTF8ToWide(view->GetClassName()); |
46 buf << L' '; | 42 buf << L' '; |
47 buf << view->id(); | 43 buf << view->id(); |
48 buf << L' '; | 44 buf << L' '; |
49 buf << view->GetClassName().c_str(); | 45 buf << view->GetClassName().c_str(); |
50 buf << L' '; | 46 buf << L' '; |
51 buf << view; | 47 buf << view; |
52 | 48 |
53 DVLOG(1) << buf.str(); | 49 // Warning so users in the field can generate and upload logs. |
54 std::cout << buf.str() << std::endl; | 50 LOG(WARNING) << buf.str(); |
Daniel Erat
2013/03/16 03:32:23
any reason why this is WARNING instead of ERROR?
James Cook
2013/03/16 04:09:24
No, good catch.
| |
55 | 51 |
56 if (view->child_count() > 0) | 52 if (view->child_count() > 0) |
57 PrintFocusHierarchyImp(view->child_at(0), indent + 2); | 53 PrintFocusHierarchyImp(view->child_at(0), indent + 2); |
58 | 54 |
59 const View* next_focusable = view->GetNextFocusableView(); | 55 const View* next_focusable = view->GetNextFocusableView(); |
60 if (next_focusable) | 56 if (next_focusable) |
61 PrintFocusHierarchyImp(next_focusable, indent); | 57 PrintFocusHierarchyImp(next_focusable, indent); |
62 } | 58 } |
63 } // namespace | 59 } // namespace |
64 | 60 |
65 void PrintViewHierarchy(const View* view) { | 61 void PrintViewHierarchy(const View* view) { |
66 PrintViewHierarchyImp(view, 0); | 62 PrintViewHierarchyImp(view, 0); |
67 } | 63 } |
68 | 64 |
69 void PrintFocusHierarchy(const View* view) { | 65 void PrintFocusHierarchy(const View* view) { |
70 PrintFocusHierarchyImp(view, 0); | 66 PrintFocusHierarchyImp(view, 0); |
71 } | 67 } |
72 | 68 |
73 } // namespace views | 69 } // namespace views |
74 | |
75 #endif // NDEBUG | |
OLD | NEW |