1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #include "libcef/browser/views/browser_view_view.h" 6 7 #include "libcef/browser/views/browser_view_impl.h" 8 CefBrowserViewView(CefBrowserViewDelegate * cef_delegate,Delegate * browser_view_delegate)9CefBrowserViewView::CefBrowserViewView(CefBrowserViewDelegate* cef_delegate, 10 Delegate* browser_view_delegate) 11 : ParentClass(cef_delegate), browser_view_delegate_(browser_view_delegate) { 12 DCHECK(browser_view_delegate_); 13 } 14 ViewHierarchyChanged(const views::ViewHierarchyChangedDetails & details)15void CefBrowserViewView::ViewHierarchyChanged( 16 const views::ViewHierarchyChangedDetails& details) { 17 ParentClass::ViewHierarchyChanged(details); 18 if (details.is_add && details.child == this) { 19 gfx::Size size = GetPreferredSize(); 20 if (size.IsEmpty()) { 21 // No size was provided for this View. Size it to the parent by default 22 // or, depending on the Layout, the browser may be initially 0x0 size and 23 // will not display until the parent is next resized (resulting in a call 24 // to WebView::OnBoundsChanged). For example, this can happen when adding 25 // this View to a CefWindow with FillLayout and then calling 26 // CefWindow::Show() without first resizing the CefWindow. 27 size = details.parent->GetPreferredSize(); 28 if (!size.IsEmpty()) 29 SetSize(size); 30 } 31 32 browser_view_delegate_->OnBrowserViewAdded(); 33 } 34 } 35 OnBoundsChanged(const gfx::Rect & previous_bounds)36void CefBrowserViewView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 37 ParentClass::OnBoundsChanged(previous_bounds); 38 browser_view_delegate_->OnBoundsChanged(); 39 } 40