Commit 87b1f815 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[Fullscreen Control] Delay creation of FullscreenControlHost

Currently we create FullscreenControlHost when the view hierarchy is
changed, which adds ~27ms to the app startup time. This CL delays the
creation of FullscreenControlHost until the browser enters fullscreen.

Bug: 833594
Change-Id: I291aa8e84eb154bbda52434d17e430d54c0507c6
Reviewed-on: https://chromium-review.googlesource.com/1014658Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551803}
parent 8b8e6209
......@@ -2023,18 +2023,6 @@ void BrowserView::ViewHierarchyChanged(
InitViews();
initialized_ = true;
}
#if defined(USE_AURA)
if (init) {
if (FullscreenControlHost::IsFullscreenExitUIEnabled()) {
widget->GetNativeView()->AddPreTargetHandler(GetFullscreenControlHost());
}
} else if (fullscreen_control_host_) {
auto* native_view = widget->GetNativeView();
if (native_view)
native_view->RemovePreTargetHandler(fullscreen_control_host_.get());
}
#endif
}
void BrowserView::PaintChildren(const views::PaintInfo& paint_info) {
......@@ -2411,12 +2399,26 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
// Look for focus in the location bar itself or any child view.
if (GetLocationBarView()->Contains(focus_manager->GetFocusedView()))
focus_manager->ClearFocus();
#if defined(USE_AURA)
if (FullscreenControlHost::IsFullscreenExitUIEnabled()) {
frame_->GetNativeView()->AddPreTargetHandler(
GetFullscreenControlHost(), ui::EventTarget::Priority::kSystem);
}
#endif
} else {
// Hide the fullscreen bubble as soon as possible, since the mode toggle can
// take enough time for the user to notice.
exclusive_access_bubble_.reset();
if (fullscreen_control_host_)
if (fullscreen_control_host_) {
fullscreen_control_host_->Hide(false);
#if defined(USE_AURA)
auto* native_view = frame_->GetNativeView();
if (native_view)
native_view->RemovePreTargetHandler(fullscreen_control_host_.get());
#endif
}
}
// Toggle fullscreen mode.
......
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