Commit 6a49ac90 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Trace BrowserView layout

This is intended to show redundant layouts occurring on the switch
between touch and non-touch mode. Especially, traces produced by perf
bots will be easier to debug. See the bug for a motivating case.

Bug: 1054489
Change-Id: I108053677429b2b9c6c62c5f97ba81b4e63e8e52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134699Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758292}
parent 46d67e5f
......@@ -25,6 +25,7 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
......@@ -2577,6 +2578,7 @@ const char* BrowserView::GetClassName() const {
}
void BrowserView::Layout() {
TRACE_EVENT0("ui", "BrowserView::Layout");
if (!initialized_ || in_process_fullscreen_)
return;
......@@ -2804,6 +2806,7 @@ void BrowserView::InfoBarContainerStateChanged(bool is_animating) {
void BrowserView::MaybeInitializeWebUITabStrip() {
#if BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
TRACE_EVENT0("ui", "BrowserView::MaybeInitializeWebUITabStrip");
if (browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) &&
WebUITabStripContainerView::UseTouchableTabStrip()) {
if (!webui_tab_strip_) {
......
......@@ -8,6 +8,7 @@
#include "base/observer_list.h"
#include "base/stl_util.h"
#include "base/trace_event/common/trace_event_common.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
......@@ -283,6 +284,7 @@ int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
// BrowserViewLayout, views::LayoutManager implementation:
void BrowserViewLayout::Layout(views::View* browser_view) {
TRACE_EVENT0("ui", "BrowserViewLayout::Layout");
vertical_layout_rect_ = browser_view->GetLocalBounds();
int top_inset = delegate_->GetTopInsetInBrowserView();
int top = LayoutTabStripRegion(top_inset);
......@@ -348,6 +350,7 @@ gfx::Size BrowserViewLayout::GetPreferredSize(const views::View* host) const {
// BrowserViewLayout, private:
int BrowserViewLayout::LayoutTabStripRegion(int top) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutTabStripRegion");
if (!delegate_->IsTabStripVisible()) {
SetViewVisibility(tab_strip_region_view_, false);
tab_strip_region_view_->SetBounds(0, 0, 0, 0);
......@@ -366,6 +369,7 @@ int BrowserViewLayout::LayoutTabStripRegion(int top) {
}
int BrowserViewLayout::LayoutWebUITabStrip(int top) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutWebUITabStrip");
if (!webui_tab_strip_)
return top;
if (!webui_tab_strip_->GetVisible()) {
......@@ -379,6 +383,7 @@ int BrowserViewLayout::LayoutWebUITabStrip(int top) {
}
int BrowserViewLayout::LayoutToolbar(int top) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutToolbar");
int browser_view_width = vertical_layout_rect_.width();
bool toolbar_visible = delegate_->IsToolbarVisible();
int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0;
......@@ -389,6 +394,7 @@ int BrowserViewLayout::LayoutToolbar(int top) {
}
int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top, int browser_view_y) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutBookmarkAndInfoBars");
web_contents_modal_dialog_top_y_ =
top + browser_view_y - kConstrainedWindowOverlap;
......@@ -459,6 +465,7 @@ int BrowserViewLayout::LayoutInfoBar(int top) {
}
void BrowserViewLayout::LayoutContentsContainerView(int top, int bottom) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutContentsContainerView");
// |contents_container_| contains web page contents and devtools.
// See browser_view.h for details.
gfx::Rect contents_container_bounds(vertical_layout_rect_.x(),
......@@ -512,6 +519,7 @@ void BrowserViewLayout::UpdateTopContainerBounds() {
}
int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutDownloadShelf");
if (delegate_->DownloadShelfNeedsLayout()) {
bool visible =
delegate_->SupportsWindowFeature(Browser::FEATURE_DOWNLOADSHELF);
......
......@@ -16,6 +16,7 @@
#include "base/numerics/ranges.h"
#include "base/scoped_observer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
......@@ -258,6 +259,7 @@ WebUITabStripContainerView::WebUITabStripContainerView(
base::Unretained(this)))),
drag_to_open_handler_(
std::make_unique<DragToOpenHandler>(this, drag_handle)) {
TRACE_EVENT0("ui", "WebUITabStripContainerView.Init");
DCHECK(UseTouchableTabStrip());
animation_.SetTweenType(gfx::Tween::Type::FAST_OUT_SLOW_IN);
......
......@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop_current.h"
#include "base/no_destructor.h"
#include "base/trace_event/trace_event.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
......@@ -78,8 +79,10 @@ TouchUiController::~TouchUiController() = default;
void TouchUiController::OnTabletModeToggled(bool enabled) {
const bool was_touch_ui = touch_ui();
tablet_mode_ = enabled;
if (touch_ui() != was_touch_ui)
if (touch_ui() != was_touch_ui) {
TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
callback_list_.Notify();
}
}
std::unique_ptr<TouchUiController::Subscription>
......@@ -91,8 +94,10 @@ TouchUiController::TouchUiState TouchUiController::SetTouchUiState(
TouchUiState touch_ui_state) {
const bool was_touch_ui = touch_ui();
const TouchUiState old_state = std::exchange(touch_ui_state_, touch_ui_state);
if (touch_ui() != was_touch_ui)
if (touch_ui() != was_touch_ui) {
TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
callback_list_.Notify();
}
return old_state;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment