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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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
« no previous file with comments | « ui/views/debug_utils.h ('k') | ui/views/drag_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ui/views/debug_utils.h"
6
7 #include <ostream>
8
9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/views/view.h"
12
13 namespace views {
14 namespace {
15 void PrintViewHierarchyImp(const View* view,
16 int indent,
17 std::wostringstream* out) {
18 int ind = indent;
19 while (ind-- > 0)
20 *out << L' ';
21 *out << base::UTF8ToWide(view->GetClassName());
22 *out << L' ';
23 *out << view->id();
24 *out << L' ';
25 *out << view->x() << L"," << view->y() << L",";
26 *out << view->bounds().right() << L"," << view->bounds().bottom();
27 *out << L' ';
28 *out << view;
29 *out << L'\n';
30
31 for (int i = 0, count = view->child_count(); i < count; ++i)
32 PrintViewHierarchyImp(view->child_at(i), indent + 2, out);
33 }
34
35 void PrintFocusHierarchyImp(const View* view,
36 int indent,
37 std::wostringstream* out) {
38 int ind = indent;
39 while (ind-- > 0)
40 *out << L' ';
41 *out << base::UTF8ToWide(view->GetClassName());
42 *out << L' ';
43 *out << view->id();
44 *out << L' ';
45 *out << view->GetClassName();
46 *out << L' ';
47 *out << view;
48 *out << L'\n';
49
50 if (view->child_count() > 0)
51 PrintFocusHierarchyImp(view->child_at(0), indent + 2, out);
52
53 const View* next_focusable = view->GetNextFocusableView();
54 if (next_focusable)
55 PrintFocusHierarchyImp(next_focusable, indent, out);
56 }
57 } // namespace
58
59 void PrintViewHierarchy(const View* view) {
60 std::wostringstream out;
61 out << L"View hierarchy:\n";
62 PrintViewHierarchyImp(view, 0, &out);
63 // Error so users in the field can generate and upload logs.
64 LOG(ERROR) << out.str();
65 }
66
67 void PrintFocusHierarchy(const View* view) {
68 std::wostringstream out;
69 out << L"Focus hierarchy:\n";
70 PrintFocusHierarchyImp(view, 0, &out);
71 // Error so users in the field can generate and upload logs.
72 LOG(ERROR) << out.str();
73 }
74
75 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/debug_utils.h ('k') | ui/views/drag_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698