Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ui/views/debug_utils.cc

Issue 10736061: Enable debug logging for views::View (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile glitch in release Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/debug_utils.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ui/views/view.h" 9 #include "ui/views/view.h"
10 10
11 #ifndef NDEBUG 11 #ifndef NDEBUG
12 #include <iostream> 12 #include <iostream>
13 #endif 13 #endif
14 14
15 namespace views {
16
17 #ifndef NDEBUG 15 #ifndef NDEBUG
18 16
17 namespace views {
19 namespace { 18 namespace {
20 void PrintViewHierarchyImp(const View* view, int indent) { 19 void PrintViewHierarchyImp(const View* view, int indent) {
21 std::wostringstream buf; 20 std::wostringstream buf;
22 int ind = indent; 21 int ind = indent;
23 while (ind-- > 0) 22 while (ind-- > 0)
24 buf << L' '; 23 buf << L' ';
25 buf << UTF8ToWide(view->GetClassName()); 24 buf << UTF8ToWide(view->GetClassName());
26 buf << L' '; 25 buf << L' ';
27 buf << view->id(); 26 buf << view->id();
28 buf << L' '; 27 buf << L' ';
29 buf << view->x() << L"," << view->y() << L","; 28 buf << view->x() << L"," << view->y() << L",";
30 buf << view->bounds().right() << L"," << view->bounds().bottom(); 29 buf << view->bounds().right() << L"," << view->bounds().bottom();
31 buf << L' '; 30 buf << L' ';
32 buf << view; 31 buf << view;
33 32
34 DVLOG(1) << buf.str(); 33 DVLOG(1) << buf.str();
35 std::cout << buf.str() << std::endl; 34 std::cout << buf.str() << std::endl;
36 35
37 for (int i = 0, count = view->child_count(); i < count; ++i) 36 for (int i = 0, count = view->child_count(); i < count; ++i)
38 PrintViewHierarchyImp(view->GetChildViewAt(i), indent + 2); 37 PrintViewHierarchyImp(view->child_at(i), indent + 2);
39 } 38 }
40 39
41 void PrintFocusHierarchyImp(const View* view, int indent) { 40 void PrintFocusHierarchyImp(const View* view, int indent) {
42 std::wostringstream buf; 41 std::wostringstream buf;
43 int ind = indent; 42 int ind = indent;
44 while (ind-- > 0) 43 while (ind-- > 0)
45 buf << L' '; 44 buf << L' ';
46 buf << UTF8ToWide(view->GetClassName()); 45 buf << UTF8ToWide(view->GetClassName());
47 buf << L' '; 46 buf << L' ';
48 buf << view->id(); 47 buf << view->id();
49 buf << L' '; 48 buf << L' ';
50 buf << view->GetClassName().c_str(); 49 buf << view->GetClassName().c_str();
51 buf << L' '; 50 buf << L' ';
52 buf << view; 51 buf << view;
53 52
54 DVLOG(1) << buf.str(); 53 DVLOG(1) << buf.str();
55 std::cout << buf.str() << std::endl; 54 std::cout << buf.str() << std::endl;
56 55
57 if (view->child_count() > 0) 56 if (view->child_count() > 0)
58 PrintFocusHierarchyImp(view->GetChildViewAt(0), indent + 2); 57 PrintFocusHierarchyImp(view->child_at(0), indent + 2);
59 58
60 const View* next_focusable = view->GetNextFocusableView(); 59 const View* next_focusable = view->GetNextFocusableView();
61 if (next_focusable) 60 if (next_focusable)
62 PrintFocusHierarchyImp(next_focusable, indent); 61 PrintFocusHierarchyImp(next_focusable, indent);
63 } 62 }
64 } // namespace 63 } // namespace
65 64
66 void PrintViewHierarchy(const View* view) { 65 void PrintViewHierarchy(const View* view) {
67 PrintViewHierarchyImp(view, 0); 66 PrintViewHierarchyImp(view, 0);
68 } 67 }
69 68
70 void PrintFocusHierarchy(const View* view) { 69 void PrintFocusHierarchy(const View* view) {
71 PrintFocusHierarchyImp(view, 0); 70 PrintFocusHierarchyImp(view, 0);
72 } 71 }
73 72
74 } // namespace views 73 } // namespace views
75 74
76 #endif // NDEBUG 75 #endif // NDEBUG
OLDNEW
« no previous file with comments | « ui/views/debug_utils.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698