| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "views/debug_utils.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "views/view.h" | |
| 10 | |
| 11 #ifndef NDEBUG | |
| 12 #include <iostream> | |
| 13 #endif | |
| 14 | |
| 15 namespace views { | |
| 16 | |
| 17 #ifndef NDEBUG | |
| 18 | |
| 19 namespace { | |
| 20 void PrintViewHierarchyImp(const View* view, int indent) { | |
| 21 std::wostringstream buf; | |
| 22 int ind = indent; | |
| 23 while (ind-- > 0) | |
| 24 buf << L' '; | |
| 25 buf << UTF8ToWide(view->GetClassName()); | |
| 26 buf << L' '; | |
| 27 buf << view->id(); | |
| 28 buf << L' '; | |
| 29 buf << view->x() << L"," << view->y() << L","; | |
| 30 buf << view->bounds().right() << L"," << view->bounds().bottom(); | |
| 31 buf << L' '; | |
| 32 buf << view; | |
| 33 | |
| 34 VLOG(1) << buf.str(); | |
| 35 std::cout << buf.str() << std::endl; | |
| 36 | |
| 37 for (int i = 0, count = view->child_count(); i < count; ++i) | |
| 38 PrintViewHierarchyImp(view->GetChildViewAt(i), indent + 2); | |
| 39 } | |
| 40 | |
| 41 void PrintFocusHierarchyImp(const View* view, int indent) { | |
| 42 std::wostringstream buf; | |
| 43 int ind = indent; | |
| 44 while (ind-- > 0) | |
| 45 buf << L' '; | |
| 46 buf << UTF8ToWide(view->GetClassName()); | |
| 47 buf << L' '; | |
| 48 buf << view->id(); | |
| 49 buf << L' '; | |
| 50 buf << view->GetClassName().c_str(); | |
| 51 buf << L' '; | |
| 52 buf << view; | |
| 53 | |
| 54 VLOG(1) << buf.str(); | |
| 55 std::cout << buf.str() << std::endl; | |
| 56 | |
| 57 if (view->child_count() > 0) | |
| 58 PrintFocusHierarchyImp(view->GetChildViewAt(0), indent + 2); | |
| 59 | |
| 60 const View* next_focusable = view->GetNextFocusableView(); | |
| 61 if (next_focusable) | |
| 62 PrintFocusHierarchyImp(next_focusable, indent); | |
| 63 } | |
| 64 } // namespace | |
| 65 | |
| 66 void PrintViewHierarchy(const View* view) { | |
| 67 PrintViewHierarchyImp(view, 0); | |
| 68 } | |
| 69 | |
| 70 void PrintFocusHierarchy(const View* view) { | |
| 71 PrintFocusHierarchyImp(view, 0); | |
| 72 } | |
| 73 | |
| 74 } // namespace views | |
| 75 | |
| 76 #endif // NDEBUG | |
| OLD | NEW |