2016-01-19 21:09:01 +01:00
|
|
|
// Copyright 2016 The Chromium Embedded Framework 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 "libcef/browser/views/browser_view_view.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/views/browser_view_impl.h"
|
|
|
|
|
|
|
|
CefBrowserViewView::CefBrowserViewView(CefBrowserViewDelegate* cef_delegate,
|
|
|
|
Delegate* browser_view_delegate)
|
2017-05-17 11:29:28 +02:00
|
|
|
: ParentClass(cef_delegate), browser_view_delegate_(browser_view_delegate) {
|
2016-01-19 21:09:01 +01:00
|
|
|
DCHECK(browser_view_delegate_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserViewView::ViewHierarchyChanged(
|
2019-04-16 16:38:48 +02:00
|
|
|
const views::ViewHierarchyChangedDetails& details) {
|
2016-01-19 21:09:01 +01:00
|
|
|
ParentClass::ViewHierarchyChanged(details);
|
|
|
|
if (details.is_add && details.child == this) {
|
|
|
|
gfx::Size size = GetPreferredSize();
|
|
|
|
if (size.IsEmpty()) {
|
|
|
|
// No size was provided for this View. Size it to the parent by default
|
|
|
|
// or, depending on the Layout, the browser may be initially 0x0 size and
|
|
|
|
// will not display until the parent is next resized (resulting in a call
|
|
|
|
// to WebView::OnBoundsChanged). For example, this can happen when adding
|
|
|
|
// this View to a CefWindow with FillLayout and then calling
|
|
|
|
// CefWindow::Show() without first resizing the CefWindow.
|
|
|
|
size = details.parent->GetPreferredSize();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!size.IsEmpty()) {
|
2016-01-19 21:09:01 +01:00
|
|
|
SetSize(size);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
browser_view_delegate_->OnBrowserViewAdded();
|
|
|
|
}
|
|
|
|
}
|
2019-07-17 20:47:27 +02:00
|
|
|
|
|
|
|
void CefBrowserViewView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
|
|
|
|
ParentClass::OnBoundsChanged(previous_bounds);
|
|
|
|
browser_view_delegate_->OnBoundsChanged();
|
|
|
|
}
|
2023-05-26 11:05:33 +02:00
|
|
|
|
|
|
|
void CefBrowserViewView::OnGestureEvent(ui::GestureEvent* event) {
|
2023-08-31 19:16:46 +02:00
|
|
|
if (browser_view_delegate_->OnGestureEvent(event)) {
|
|
|
|
return;
|
2023-05-26 11:05:33 +02:00
|
|
|
}
|
2023-08-31 19:16:46 +02:00
|
|
|
ParentClass::OnGestureEvent(event);
|
2023-05-26 11:05:33 +02:00
|
|
|
}
|