diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 04:50:21 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 04:50:21 +0000 |
commit | 208386048305a96323581eaca4e4c378d2d8534e (patch) | |
tree | 809f266c0b42c1dba64f4233bee4ae615c813cf3 /views/debug_utils.cc | |
parent | 35a43f9fc8b757adfe1226acd95dab7541e8a9a6 (diff) | |
download | chromium_src-208386048305a96323581eaca4e4c378d2d8534e.zip chromium_src-208386048305a96323581eaca4e4c378d2d8534e.tar.gz chromium_src-208386048305a96323581eaca4e4c378d2d8534e.tar.bz2 |
Rework tree APIs to reflect Google style and more const-correctness.Also, move PrintViewHierarchy/PrintFocusHierarchy out into a separate header.
BUG=72040
TEST=None
Review URL: http://codereview.chromium.org/6452011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/debug_utils.cc')
-rw-r--r-- | views/debug_utils.cc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/views/debug_utils.cc b/views/debug_utils.cc new file mode 100644 index 0000000..1a6cda2 --- /dev/null +++ b/views/debug_utils.cc @@ -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 (int 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 |