views: Add support for absolute positioned overlay views.

To test:
Run `cefclient.exe --use-views --hide-frame --hide-controls`
Add `--enable-chrome-runtime` for the same behavior using the Chrome location
bar instead of a text field.
This commit is contained in:
Marshall Greenblatt
2021-08-27 21:55:15 -04:00
parent 7eb813e7e7
commit 40dcd29b63
96 changed files with 3869 additions and 224 deletions

View File

@@ -120,10 +120,25 @@ index 0ce7abdeb7d9f..8197a6bb7da98 100644
// Initialize the frame (creates the underlying native window).
diff --git chrome/browser/ui/views/frame/browser_view.cc chrome/browser/ui/views/frame/browser_view.cc
index 621fbe0c72d07..f556734d79428 100644
index 621fbe0c72d07..cf658ca239889 100644
--- chrome/browser/ui/views/frame/browser_view.cc
+++ chrome/browser/ui/views/frame/browser_view.cc
@@ -594,11 +594,22 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver {
@@ -275,11 +275,10 @@ using content::WebContents;
using views::ColumnSet;
using web_modal::WebContentsModalDialogHost;
-namespace {
+// static
+const char BrowserView::kBrowserViewKey[] = "__BROWSER_VIEW__";
-// The name of a key to store on the window handle so that other code can
-// locate this object using just the handle.
-const char* const kBrowserViewKey = "__BROWSER_VIEW__";
+namespace {
#if BUILDFLAG(IS_CHROMEOS_ASH)
// UMA histograms that record animation smoothness for tab loading animation.
@@ -594,11 +593,22 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver {
///////////////////////////////////////////////////////////////////////////////
// BrowserView, public:
@@ -147,7 +162,7 @@ index 621fbe0c72d07..f556734d79428 100644
SetShowIcon(::ShouldShowWindowIcon(browser_.get()));
// In forced app mode, all size controls are always disabled. Otherwise, use
@@ -612,7 +623,6 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
@@ -612,7 +622,6 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
}
browser_->tab_strip_model()->AddObserver(this);
@@ -155,7 +170,7 @@ index 621fbe0c72d07..f556734d79428 100644
// Top container holds tab strip region and toolbar and lives at the front of
// the view hierarchy.
@@ -656,8 +666,15 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
@@ -656,8 +665,15 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
contents_container->SetLayoutManager(std::make_unique<ContentsLayoutManager>(
devtools_web_view_, contents_web_view_));
@@ -173,7 +188,7 @@ index 621fbe0c72d07..f556734d79428 100644
contents_separator_ =
top_container_->AddChildView(std::make_unique<ContentsSeparator>());
@@ -1441,6 +1458,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const {
@@ -1441,6 +1457,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const {
if (immersive_mode_controller_->IsEnabled())
return false;
@@ -182,7 +197,7 @@ index 621fbe0c72d07..f556734d79428 100644
return frame_->GetFrameView()->ShouldHideTopUIForFullscreen();
}
@@ -2492,7 +2511,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const {
@@ -2492,7 +2510,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const {
}
void BrowserView::ReparentTopContainerForEndOfImmersive() {
@@ -192,7 +207,7 @@ index 621fbe0c72d07..f556734d79428 100644
top_container()->DestroyLayer();
AddChildViewAt(top_container(), 0);
EnsureFocusOrder();
@@ -2944,8 +2964,10 @@ void BrowserView::Layout() {
@@ -2944,8 +2963,10 @@ void BrowserView::Layout() {
// TODO(jamescook): Why was this in the middle of layout code?
toolbar_->location_bar()->omnibox_view()->SetFocusBehavior(
@@ -205,7 +220,7 @@ index 621fbe0c72d07..f556734d79428 100644
// Some of the situations when the BrowserView is laid out are:
// - Enter/exit immersive fullscreen mode.
@@ -3008,6 +3030,11 @@ void BrowserView::AddedToWidget() {
@@ -3008,6 +3029,11 @@ void BrowserView::AddedToWidget() {
SetThemeProfileForWindow(GetNativeWindow(), browser_->profile());
#endif
@@ -217,7 +232,7 @@ index 621fbe0c72d07..f556734d79428 100644
toolbar_->Init();
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -3043,13 +3070,9 @@ void BrowserView::AddedToWidget() {
@@ -3043,13 +3069,9 @@ void BrowserView::AddedToWidget() {
EnsureFocusOrder();
@@ -234,10 +249,10 @@ index 621fbe0c72d07..f556734d79428 100644
MaybeInitializeWebUITabStrip();
diff --git chrome/browser/ui/views/frame/browser_view.h chrome/browser/ui/views/frame/browser_view.h
index 021f04720e567..8c4f2cbf34f25 100644
index 021f04720e567..98097fd4f11f5 100644
--- chrome/browser/ui/views/frame/browser_view.h
+++ chrome/browser/ui/views/frame/browser_view.h
@@ -114,7 +114,9 @@ class BrowserView : public BrowserWindow,
@@ -114,11 +114,16 @@ class BrowserView : public BrowserWindow,
public webapps::AppBannerManager::Observer {
public:
METADATA_HEADER(BrowserView);
@@ -247,7 +262,14 @@ index 021f04720e567..8c4f2cbf34f25 100644
BrowserView(const BrowserView&) = delete;
BrowserView& operator=(const BrowserView&) = delete;
~BrowserView() override;
@@ -668,6 +670,12 @@ class BrowserView : public BrowserWindow,
+ // Key used to bind BrowserView to the Widget with which it is associated.
+ static const char kBrowserViewKey[];
+
void set_frame(BrowserFrame* frame) { frame_ = frame; }
BrowserFrame* frame() const { return frame_; }
@@ -668,6 +673,12 @@ class BrowserView : public BrowserWindow,
return accessibility_focus_highlight_.get();
}
@@ -261,15 +283,25 @@ index 021f04720e567..8c4f2cbf34f25 100644
// Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
// interface to keep these two classes decoupled and testable.
diff --git chrome/browser/ui/views/frame/browser_view_layout.cc chrome/browser/ui/views/frame/browser_view_layout.cc
index 18a85f436bd97..0d6e4c9f916e7 100644
index 18a85f436bd97..cf880936a8edf 100644
--- chrome/browser/ui/views/frame/browser_view_layout.cc
+++ chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -441,6 +441,12 @@ int BrowserViewLayout::LayoutWebUITabStrip(int top) {
@@ -39,6 +39,10 @@
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/browser/chrome/views/chrome_views_util.h"
+#endif
+
using views::View;
using web_modal::WebContentsModalDialogHost;
using web_modal::ModalDialogHostObserver;
@@ -441,6 +445,11 @@ int BrowserViewLayout::LayoutWebUITabStrip(int top) {
int BrowserViewLayout::LayoutToolbar(int top) {
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutToolbar");
+ if (toolbar_->parent() && toolbar_->parent()->GetLayoutManager() != this &&
+ toolbar_->parent()->GetLayoutManager() != nullptr) {
+ if (cef::IsCefView(toolbar_)) {
+ // CEF may take ownership of the toolbar. Early exit to avoid the DCHECK
+ // in LayoutManager::SetViewVisibility().
+ return top;