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

Unified Diff: views/debug_utils.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: views/debug_utils.cc
===================================================================
--- views/debug_utils.cc (revision 0)
+++ views/debug_utils.cc (revision 0)
@@ -0,0 +1,76 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "views/debug_utils.h"
+
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "views/view.h"
+
+#ifndef NDEBUG
+#include <iostream>
+#endif
+
+namespace views {
+
+#ifndef NDEBUG
+
+namespace {
+void PrintViewHierarchyImp(const View* view, int indent) {
+ std::wostringstream buf;
+ int ind = indent;
+ while (ind-- > 0)
+ buf << L' ';
+ buf << UTF8ToWide(view->GetClassName());
+ buf << L' ';
+ buf << view->GetID();
+ buf << L' ';
+ buf << view->x() << L"," << view->y() << L",";
+ buf << view->bounds().right() << L"," << view->bounds().bottom();
+ buf << L' ';
+ buf << view;
+
+ VLOG(1) << buf.str();
+ std::cout << buf.str() << std::endl;
+
+ for (size_t i = 0, count = view->child_count(); i < count; ++i)
+ PrintViewHierarchyImp(view->GetChildViewAt(i), indent + 2);
+}
+
+void PrintFocusHierarchyImp(const View* view, int indent) {
+ std::wostringstream buf;
+ int ind = indent;
+ while (ind-- > 0)
+ buf << L' ';
+ buf << UTF8ToWide(view->GetClassName());
+ buf << L' ';
+ buf << view->GetID();
+ buf << L' ';
+ buf << view->GetClassName().c_str();
+ buf << L' ';
+ buf << view;
+
+ VLOG(1) << buf.str();
+ std::cout << buf.str() << std::endl;
+
+ if (view->child_count() > 0)
+ PrintFocusHierarchyImp(view->GetChildViewAt(0), indent + 2);
+
+ const View* next_focusable = view->GetNextFocusableView();
+ if (next_focusable)
+ PrintFocusHierarchyImp(next_focusable, indent);
+}
+} // namespace
+
+void PrintViewHierarchy(const View* view) {
+ PrintViewHierarchyImp(view, 0);
+}
+
+void PrintFocusHierarchy(const View* view) {
+ PrintFocusHierarchyImp(view, 0);
+}
+
+} // namespace views
+
+#endif // NDEBUG
Property changes on: views\debug_utils.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698