diff --git a/BUILD.gn b/BUILD.gn index 5793f124c..8459ad944 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -705,6 +705,7 @@ static_library("libcef_static") { "libcef/common/file_util_impl.cc", "libcef/common/frame_util.cc", "libcef/common/frame_util.h", + "libcef/common/i18n_util_impl.cc", "libcef/common/json_impl.cc", "libcef/common/main_runner_delegate.h", "libcef/common/main_runner_handler.h", @@ -1055,6 +1056,8 @@ static_library("libcef_static") { "libcef/browser/chrome/views/chrome_browser_frame.h", "libcef/browser/chrome/views/chrome_browser_view.cc", "libcef/browser/chrome/views/chrome_browser_view.h", + "libcef/browser/chrome/views/chrome_views_util.cc", + "libcef/browser/chrome/views/chrome_views_util.h", "libcef/browser/chrome/views/toolbar_view_impl.cc", "libcef/browser/chrome/views/toolbar_view_impl.h", "libcef/browser/chrome/views/toolbar_view_view.cc", @@ -1096,6 +1099,8 @@ static_library("libcef_static") { "libcef/browser/views/menu_button_view.h", "libcef/browser/views/menu_runner_views.cc", "libcef/browser/views/menu_runner_views.h", + "libcef/browser/views/overlay_view_host.cc", + "libcef/browser/views/overlay_view_host.h", "libcef/browser/views/panel_impl.h", "libcef/browser/views/panel_view.h", "libcef/browser/views/scroll_view_impl.cc", diff --git a/cef_paths.gypi b/cef_paths.gypi index b35068837..7e9a4e7e0 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -8,7 +8,7 @@ # by hand. See the translator.README.txt file in the tools directory for # more information. # -# $hash=f6950d026a9c92fbb58da3fe0cbcf0050c12ecf0$ +# $hash=216bf0511bdceca67cdbdcf30f8316db2d00e276$ # { @@ -41,6 +41,7 @@ 'include/cef_focus_handler.h', 'include/cef_frame.h', 'include/cef_frame_handler.h', + 'include/cef_i18n_util.h', 'include/cef_image.h', 'include/cef_jsdialog_handler.h', 'include/cef_keyboard_handler.h', @@ -101,6 +102,7 @@ 'include/views/cef_layout.h', 'include/views/cef_menu_button.h', 'include/views/cef_menu_button_delegate.h', + 'include/views/cef_overlay_controller.h', 'include/views/cef_panel.h', 'include/views/cef_panel_delegate.h', 'include/views/cef_scroll_view.h', @@ -139,6 +141,7 @@ 'include/capi/cef_focus_handler_capi.h', 'include/capi/cef_frame_capi.h', 'include/capi/cef_frame_handler_capi.h', + 'include/capi/cef_i18n_util_capi.h', 'include/capi/cef_image_capi.h', 'include/capi/cef_jsdialog_handler_capi.h', 'include/capi/cef_keyboard_handler_capi.h', @@ -199,6 +202,7 @@ 'include/capi/views/cef_layout_capi.h', 'include/capi/views/cef_menu_button_capi.h', 'include/capi/views/cef_menu_button_delegate_capi.h', + 'include/capi/views/cef_overlay_controller_capi.h', 'include/capi/views/cef_panel_capi.h', 'include/capi/views/cef_panel_delegate_capi.h', 'include/capi/views/cef_scroll_view_capi.h', @@ -352,6 +356,8 @@ 'libcef_dll/cpptoc/navigation_entry_cpptoc.h', 'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.cc', 'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h', + 'libcef_dll/cpptoc/views/overlay_controller_cpptoc.cc', + 'libcef_dll/cpptoc/views/overlay_controller_cpptoc.h', 'libcef_dll/cpptoc/views/panel_cpptoc.cc', 'libcef_dll/cpptoc/views/panel_cpptoc.h', 'libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc', @@ -662,6 +668,8 @@ 'libcef_dll/ctocpp/navigation_entry_ctocpp.h', 'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.cc', 'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h', + 'libcef_dll/ctocpp/views/overlay_controller_ctocpp.cc', + 'libcef_dll/ctocpp/views/overlay_controller_ctocpp.h', 'libcef_dll/ctocpp/views/panel_ctocpp.cc', 'libcef_dll/ctocpp/views/panel_ctocpp.h', 'libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc', diff --git a/cef_paths2.gypi b/cef_paths2.gypi index cbeb8bc18..66e46d283 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -265,6 +265,8 @@ 'tests/cefclient/browser/urlrequest_test.h', 'tests/cefclient/browser/views_menu_bar.cc', 'tests/cefclient/browser/views_menu_bar.h', + 'tests/cefclient/browser/views_overlay_controls.cc', + 'tests/cefclient/browser/views_overlay_controls.h', 'tests/cefclient/browser/views_style.cc', 'tests/cefclient/browser/views_style.h', 'tests/cefclient/browser/views_window.cc', diff --git a/include/capi/cef_i18n_util_capi.h b/include/capi/cef_i18n_util_capi.h new file mode 100644 index 000000000..d0473932e --- /dev/null +++ b/include/capi/cef_i18n_util_capi.h @@ -0,0 +1,58 @@ +// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=bf890f7b8e8edd423d71ad5a4d5bd43d81f1eb01$ +// + +#ifndef CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Returns true (1) if the application text direction is right-to-left. +/// +CEF_EXPORT int cef_is_rtl(); + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_ diff --git a/include/capi/views/cef_overlay_controller_capi.h b/include/capi/views/cef_overlay_controller_capi.h new file mode 100644 index 000000000..16473a464 --- /dev/null +++ b/include/capi/views/cef_overlay_controller_capi.h @@ -0,0 +1,216 @@ +// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +// $hash=60a15cb1c2e77544c20a3aafef1db736f07a5fb8$ +// + +#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_OVERLAY_CONTROLLER_CAPI_H_ +#define CEF_INCLUDE_CAPI_VIEWS_CEF_OVERLAY_CONTROLLER_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_view_t; +struct _cef_window_t; + +/// +// Controller for an overlay that contains a contents View added via +// cef_window_t::AddOverlayView. Methods exposed by this controller should be +// called in preference to functions of the same name exposed by the contents +// View unless otherwise indicated. Methods must be called on the browser +// process UI thread unless otherwise indicated. +/// +typedef struct _cef_overlay_controller_t { + /// + // Base structure. + /// + cef_base_ref_counted_t base; + + /// + // Returns true (1) if this object is valid. + /// + int(CEF_CALLBACK* is_valid)(struct _cef_overlay_controller_t* self); + + /// + // Returns true (1) if this object is the same as |that| object. + /// + int(CEF_CALLBACK* is_same)(struct _cef_overlay_controller_t* self, + struct _cef_overlay_controller_t* that); + + /// + // Returns the contents View for this overlay. + /// + struct _cef_view_t*(CEF_CALLBACK* get_contents_view)( + struct _cef_overlay_controller_t* self); + + /// + // Returns the top-level Window hosting this overlay. Use this function + // instead of calling get_window() on the contents View. + /// + struct _cef_window_t*(CEF_CALLBACK* get_window)( + struct _cef_overlay_controller_t* self); + + /// + // Returns the docking mode for this overlay. + /// + cef_docking_mode_t(CEF_CALLBACK* get_docking_mode)( + struct _cef_overlay_controller_t* self); + + /// + // Destroy this overlay. + /// + void(CEF_CALLBACK* destroy)(struct _cef_overlay_controller_t* self); + + /// + // Sets the bounds (size and position) of this overlay. This will set the + // bounds of the contents View to match and trigger a re-layout if necessary. + // |bounds| is in parent coordinates and any insets configured on this overlay + // will be ignored. Use this function only for overlays created with a docking + // mode value of CEF_DOCKING_MODE_CUSTOM. With other docking modes modify the + // insets of this overlay and/or layout of the contents View and call + // size_to_preferred_size() instead to calculate the new size and re-position + // the overlay if necessary. + /// + void(CEF_CALLBACK* set_bounds)(struct _cef_overlay_controller_t* self, + const cef_rect_t* bounds); + + /// + // Returns the bounds (size and position) of this overlay in parent + // coordinates. + /// + cef_rect_t(CEF_CALLBACK* get_bounds)(struct _cef_overlay_controller_t* self); + + /// + // Returns the bounds (size and position) of this overlay in DIP screen + // coordinates. + /// + cef_rect_t(CEF_CALLBACK* get_bounds_in_screen)( + struct _cef_overlay_controller_t* self); + + /// + // Sets the size of this overlay without changing the position. This will set + // the size of the contents View to match and trigger a re-layout if + // necessary. |size| is in parent coordinates and any insets configured on + // this overlay will be ignored. Use this function only for overlays created + // with a docking mode value of CEF_DOCKING_MODE_CUSTOM. With other docking + // modes modify the insets of this overlay and/or layout of the contents View + // and call size_to_preferred_size() instead to calculate the new size and re- + // position the overlay if necessary. + /// + void(CEF_CALLBACK* set_size)(struct _cef_overlay_controller_t* self, + const cef_size_t* size); + + /// + // Returns the size of this overlay in parent coordinates. + /// + cef_size_t(CEF_CALLBACK* get_size)(struct _cef_overlay_controller_t* self); + + /// + // Sets the position of this overlay without changing the size. |position| is + // in parent coordinates and any insets configured on this overlay will be + // ignored. Use this function only for overlays created with a docking mode + // value of CEF_DOCKING_MODE_CUSTOM. With other docking modes modify the + // insets of this overlay and/or layout of the contents View and call + // size_to_preferred_size() instead to calculate the new size and re-position + // the overlay if necessary. + /// + void(CEF_CALLBACK* set_position)(struct _cef_overlay_controller_t* self, + const cef_point_t* position); + + /// + // Returns the position of this overlay in parent coordinates. + /// + cef_point_t(CEF_CALLBACK* get_position)( + struct _cef_overlay_controller_t* self); + + /// + // Sets the insets for this overlay. |insets| is in parent coordinates. Use + // this function only for overlays created with a docking mode value other + // than CEF_DOCKING_MODE_CUSTOM. + /// + void(CEF_CALLBACK* set_insets)(struct _cef_overlay_controller_t* self, + const cef_insets_t* insets); + + /// + // Returns the insets for this overlay in parent coordinates. + /// + cef_insets_t(CEF_CALLBACK* get_insets)( + struct _cef_overlay_controller_t* self); + + /// + // Size this overlay to its preferred size and trigger a re-layout if + // necessary. The position of overlays created with a docking mode value of + // CEF_DOCKING_MODE_CUSTOM will not be modified by calling this function. With + // other docking modes this function may re-position the overlay if necessary + // to accommodate the new size and any insets configured on the contents View. + /// + void(CEF_CALLBACK* size_to_preferred_size)( + struct _cef_overlay_controller_t* self); + + /// + // Sets whether this overlay is visible. Overlays are hidden by default. If + // this overlay is hidden then it and any child Views will not be drawn and, + // if any of those Views currently have focus, then focus will also be + // cleared. Painting is scheduled as needed. + /// + void(CEF_CALLBACK* set_visible)(struct _cef_overlay_controller_t* self, + int visible); + + /// + // Returns whether this overlay is visible. A View may be visible but still + // not drawn in a Window if any parent Views are hidden. Call is_drawn() to + // determine whether this overlay and all parent Views are visible and will be + // drawn. + /// + int(CEF_CALLBACK* is_visible)(struct _cef_overlay_controller_t* self); + + /// + // Returns whether this overlay is visible and drawn in a Window. A View is + // drawn if it and all parent Views are visible. To determine if the + // containing Window is visible to the user on-screen call is_visible() on the + // Window. + /// + int(CEF_CALLBACK* is_drawn)(struct _cef_overlay_controller_t* self); +} cef_overlay_controller_t; + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_VIEWS_CEF_OVERLAY_CONTROLLER_CAPI_H_ diff --git a/include/capi/views/cef_view_capi.h b/include/capi/views/cef_view_capi.h index dcf0e9e4e..44472206c 100644 --- a/include/capi/views/cef_view_capi.h +++ b/include/capi/views/cef_view_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=9881a00ef237b6972f14c071544387fc90fe18f1$ +// $hash=84b29a8dcdadffae5466ac16e7aafd80471a0abd$ // #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_ @@ -220,6 +220,19 @@ typedef struct _cef_view_t { /// cef_point_t(CEF_CALLBACK* get_position)(struct _cef_view_t* self); + /// + // Sets the insets for this View. |insets| is in parent coordinates, or DIP + // screen coordinates if there is no parent. + /// + void(CEF_CALLBACK* set_insets)(struct _cef_view_t* self, + const cef_insets_t* insets); + + /// + // Returns the insets for this View in parent coordinates, or DIP screen + // coordinates if there is no parent. + /// + cef_insets_t(CEF_CALLBACK* get_insets)(struct _cef_view_t* self); + /// // Returns the size this View would like to be if enough space is available. // Size is in parent coordinates, or DIP screen coordinates if there is no diff --git a/include/capi/views/cef_view_delegate_capi.h b/include/capi/views/cef_view_delegate_capi.h index 9c2a0844e..85fa52b89 100644 --- a/include/capi/views/cef_view_delegate_capi.h +++ b/include/capi/views/cef_view_delegate_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=a060cb3c53317d758e7f6b4a275288cd08f086e7$ +// $hash=c8707f30655dc83c5f329d1dc22b14e9e06f4e76$ // #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_ @@ -121,6 +121,13 @@ typedef struct _cef_view_delegate_t { struct _cef_view_t* view, int added); + /// + // Called when the layout of |view| has changed. + /// + void(CEF_CALLBACK* on_layout_changed)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view, + const cef_rect_t* new_bounds); + /// // Called when |view| gains focus. /// diff --git a/include/capi/views/cef_window_capi.h b/include/capi/views/cef_window_capi.h index d9e584bfd..d61106b5f 100644 --- a/include/capi/views/cef_window_capi.h +++ b/include/capi/views/cef_window_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=15f88e3521ca96947fe8b1f91f251eb3405fb293$ +// $hash=0f5dad3572a20ee7395cb861b5c970cff382b61c$ // #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ @@ -43,6 +43,7 @@ #include "include/capi/cef_image_capi.h" #include "include/capi/cef_menu_model_capi.h" #include "include/capi/views/cef_display_capi.h" +#include "include/capi/views/cef_overlay_controller_capi.h" #include "include/capi/views/cef_panel_capi.h" #include "include/capi/views/cef_window_delegate_capi.h" @@ -197,6 +198,40 @@ typedef struct _cef_window_t { struct _cef_image_t*(CEF_CALLBACK* get_window_app_icon)( struct _cef_window_t* self); + /// + // Add a View that will be overlayed on the Window contents with absolute + // positioning and high z-order. Positioning is controlled by |docking_mode| + // as described below. The returned cef_overlay_controller_t object is used to + // control the overlay. Overlays are hidden by default. + // + // With CEF_DOCKING_MODE_CUSTOM: + // 1. The overlay is initially hidden, sized to |view|'s preferred size, and + // positioned in the top-left corner. + // 2. Optionally change the overlay position and/or size by calling + // CefOverlayController methods. + // 3. Call CefOverlayController::SetVisible(true) to show the overlay. + // 4. The overlay will be automatically re-sized if |view|'s layout changes. + // Optionally change the overlay position and/or size when + // OnLayoutChanged is called on the Window's delegate to indicate a + // change in Window bounds. + // + // With other docking modes: + // 1. The overlay is initially hidden, sized to |view|'s preferred size, and + // positioned based on |docking_mode|. + // 2. Call CefOverlayController::SetVisible(true) to show the overlay. + // 3. The overlay will be automatically re-sized if |view|'s layout changes + // and re-positioned as appropriate when the Window resizes. + // + // Overlays created by this function will receive a higher z-order then any + // child Views added previously. It is therefore recommended to call this + // function last after all other child Views have been added so that the + // overlay displays as the top-most child of the Window. + /// + struct _cef_overlay_controller_t*(CEF_CALLBACK* add_overlay_view)( + struct _cef_window_t* self, + struct _cef_view_t* view, + cef_docking_mode_t docking_mode); + /// // Show a menu with contents |menu_model|. |screen_point| specifies the menu // position in screen coordinates. |anchor_position| specifies how the menu diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 7dd46f925..46175fad6 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "5625e3ce80d2bbf5b5a39f8655d96c215f7685ee" +#define CEF_API_HASH_UNIVERSAL "e32fc367fb311d2d68f097d42a75357a3e339fdd" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "c20e4ffc24e6267b61774f49237d0f30a581f370" +#define CEF_API_HASH_PLATFORM "e40f20dc24610956c9e2768f4c9535502d68f70e" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "65731bc654ec6e1dbd48d6ff2336c4c8573f7d35" +#define CEF_API_HASH_PLATFORM "cb578fa9c253d93944f63d9bdc7a8f9e0a417bae" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "4e35b9cc9735c63ac9f16fbbb49a4b8e2307f23a" +#define CEF_API_HASH_PLATFORM "10b47123ea31edcf4a978a36e4ee2aa5bc755b2d" #endif #ifdef __cplusplus diff --git a/include/cef_i18n_util.h b/include/cef_i18n_util.h new file mode 100644 index 000000000..97461b935 --- /dev/null +++ b/include/cef_i18n_util.h @@ -0,0 +1,49 @@ +// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_I18N_UTIL_H_ +#define CEF_INCLUDE_CEF_I18N_UTIL_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Returns true if the application text direction is right-to-left. +/// +/*--cef()--*/ +bool CefIsRTL(); + +#endif // CEF_INCLUDE_CEF_I18N_UTIL_H_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index a2df43966..32868c06b 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -3198,6 +3198,17 @@ typedef enum { CEF_CTT_LOCATION, } cef_chrome_toolbar_type_t; +/// +// Docking modes supported by CefWindow::AddOverlay. +/// +typedef enum { + CEF_DOCKING_MODE_TOP_LEFT = 1, + CEF_DOCKING_MODE_TOP_RIGHT, + CEF_DOCKING_MODE_BOTTOM_LEFT, + CEF_DOCKING_MODE_BOTTOM_RIGHT, + CEF_DOCKING_MODE_CUSTOM, +} cef_docking_mode_t; + #ifdef __cplusplus } #endif diff --git a/include/views/cef_overlay_controller.h b/include/views/cef_overlay_controller.h new file mode 100644 index 000000000..b49022bb1 --- /dev/null +++ b/include/views/cef_overlay_controller.h @@ -0,0 +1,209 @@ +// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_VIEWS_CEF_OVERLAY_CONTROLLER_H_ +#define CEF_INCLUDE_VIEWS_CEF_OVERLAY_CONTROLLER_H_ +#pragma once + +#include "include/cef_base.h" + +class CefView; +class CefWindow; + +/// +// Controller for an overlay that contains a contents View added via +// CefWindow::AddOverlayView. Methods exposed by this controller should be +// called in preference to methods of the same name exposed by the contents View +// unless otherwise indicated. Methods must be called on the browser process UI +// thread unless otherwise indicated. +/// +/*--cef(source=library)--*/ +class CefOverlayController : public CefBaseRefCounted { + public: + /// + // Returns true if this object is valid. + /// + /*--cef()--*/ + virtual bool IsValid() = 0; + + /// + // Returns true if this object is the same as |that| object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) = 0; + + /// + // Returns the contents View for this overlay. + /// + /*--cef()--*/ + virtual CefRefPtr GetContentsView() = 0; + + /// + // Returns the top-level Window hosting this overlay. Use this method instead + // of calling GetWindow() on the contents View. + /// + /*--cef()--*/ + virtual CefRefPtr GetWindow() = 0; + + /// + // Returns the docking mode for this overlay. + /// + /*--cef(default_retval=CEF_DOCKING_MODE_TOP_LEFT)--*/ + virtual cef_docking_mode_t GetDockingMode() = 0; + + /// + // Destroy this overlay. + /// + /*--cef()--*/ + virtual void Destroy() = 0; + + /// + // Sets the bounds (size and position) of this overlay. This will set the + // bounds of the contents View to match and trigger a re-layout if necessary. + // |bounds| is in parent coordinates and any insets configured on this overlay + // will be ignored. Use this method only for overlays created with a docking + // mode value of CEF_DOCKING_MODE_CUSTOM. With other docking modes modify the + // insets of this overlay and/or layout of the contents View and call + // SizeToPreferredSize() instead to calculate the new size and re-position the + // overlay if necessary. + /// + /*--cef()--*/ + virtual void SetBounds(const CefRect& bounds) = 0; + + /// + // Returns the bounds (size and position) of this overlay in parent + // coordinates. + /// + /*--cef()--*/ + virtual CefRect GetBounds() = 0; + + /// + // Returns the bounds (size and position) of this overlay in DIP screen + // coordinates. + /// + /*--cef()--*/ + virtual CefRect GetBoundsInScreen() = 0; + + /// + // Sets the size of this overlay without changing the position. This will set + // the size of the contents View to match and trigger a re-layout if + // necessary. |size| is in parent coordinates and any insets configured on + // this overlay will be ignored. Use this method only for overlays created + // with a docking mode value of CEF_DOCKING_MODE_CUSTOM. With other docking + // modes modify the insets of this overlay and/or layout of the contents View + // and call SizeToPreferredSize() instead to calculate the new size and + // re-position the overlay if necessary. + /// + /*--cef()--*/ + virtual void SetSize(const CefSize& size) = 0; + + /// + // Returns the size of this overlay in parent coordinates. + /// + /*--cef()--*/ + virtual CefSize GetSize() = 0; + + /// + // Sets the position of this overlay without changing the size. |position| is + // in parent coordinates and any insets configured on this overlay will + // be ignored. Use this method only for overlays created with a docking mode + // value of CEF_DOCKING_MODE_CUSTOM. With other docking modes modify the + // insets of this overlay and/or layout of the contents View and call + // SizeToPreferredSize() instead to calculate the new size and re-position the + // overlay if necessary. + /// + /*--cef()--*/ + virtual void SetPosition(const CefPoint& position) = 0; + + /// + // Returns the position of this overlay in parent coordinates. + /// + /*--cef()--*/ + virtual CefPoint GetPosition() = 0; + + /// + // Sets the insets for this overlay. |insets| is in parent coordinates. Use + // this method only for overlays created with a docking mode value other than + // CEF_DOCKING_MODE_CUSTOM. + /// + /*--cef()--*/ + virtual void SetInsets(const CefInsets& insets) = 0; + + /// + // Returns the insets for this overlay in parent coordinates. + /// + /*--cef()--*/ + virtual CefInsets GetInsets() = 0; + + /// + // Size this overlay to its preferred size and trigger a re-layout if + // necessary. The position of overlays created with a docking mode value of + // CEF_DOCKING_MODE_CUSTOM will not be modified by calling this method. With + // other docking modes this method may re-position the overlay if necessary to + // accommodate the new size and any insets configured on the contents View. + /// + /*--cef()--*/ + virtual void SizeToPreferredSize() = 0; + + /// + // Sets whether this overlay is visible. Overlays are hidden by default. If + // this overlay is hidden then it and any child Views will not be drawn and, + // if any of those Views currently have focus, then focus will also be + // cleared. Painting is scheduled as needed. + /// + /*--cef()--*/ + virtual void SetVisible(bool visible) = 0; + + /// + // Returns whether this overlay is visible. A View may be visible but still + // not drawn in a Window if any parent Views are hidden. Call IsDrawn() to + // determine whether this overlay and all parent Views are visible and will be + // drawn. + /// + /*--cef()--*/ + virtual bool IsVisible() = 0; + + /// + // Returns whether this overlay is visible and drawn in a Window. A View is + // drawn if it and all parent Views are visible. To determine if the + // containing Window is visible to the user on-screen call IsVisible() on the + // Window. + /// + /*--cef()--*/ + virtual bool IsDrawn() = 0; +}; + +#endif // CEF_INCLUDE_VIEWS_CEF_OVERLAY_CONTROLLER_H_ diff --git a/include/views/cef_view.h b/include/views/cef_view.h index 509e3c0ce..90cb18032 100644 --- a/include/views/cef_view.h +++ b/include/views/cef_view.h @@ -222,6 +222,20 @@ class CefView : public CefBaseRefCounted { /*--cef()--*/ virtual CefPoint GetPosition() = 0; + /// + // Sets the insets for this View. |insets| is in parent coordinates, or DIP + // screen coordinates if there is no parent. + /// + /*--cef()--*/ + virtual void SetInsets(const CefInsets& insets) = 0; + + /// + // Returns the insets for this View in parent coordinates, or DIP screen + // coordinates if there is no parent. + /// + /*--cef()--*/ + virtual CefInsets GetInsets() = 0; + /// // Returns the size this View would like to be if enough space is available. // Size is in parent coordinates, or DIP screen coordinates if there is no diff --git a/include/views/cef_view_delegate.h b/include/views/cef_view_delegate.h index 152bd99fb..03b8b6893 100644 --- a/include/views/cef_view_delegate.h +++ b/include/views/cef_view_delegate.h @@ -108,9 +108,16 @@ class CefViewDelegate : public virtual CefBaseRefCounted { /// // Called when |view| is added or removed from the CefWindow. /// - /*--cef(optional_param=window)--*/ + /*--cef()--*/ virtual void OnWindowChanged(CefRefPtr view, bool added) {} + /// + // Called when the layout of |view| has changed. + /// + /*--cef()--*/ + virtual void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) {} + /// // Called when |view| gains focus. /// diff --git a/include/views/cef_window.h b/include/views/cef_window.h index 2dce0685c..3f8de0631 100644 --- a/include/views/cef_window.h +++ b/include/views/cef_window.h @@ -41,6 +41,7 @@ #include "include/cef_image.h" #include "include/cef_menu_model.h" #include "include/views/cef_display.h" +#include "include/views/cef_overlay_controller.h" #include "include/views/cef_panel.h" #include "include/views/cef_window_delegate.h" @@ -211,6 +212,40 @@ class CefWindow : public CefPanel { /*--cef()--*/ virtual CefRefPtr GetWindowAppIcon() = 0; + /// + // Add a View that will be overlayed on the Window contents with absolute + // positioning and high z-order. Positioning is controlled by |docking_mode| + // as described below. The returned CefOverlayController object is used to + // control the overlay. Overlays are hidden by default. + // + // With CEF_DOCKING_MODE_CUSTOM: + // 1. The overlay is initially hidden, sized to |view|'s preferred size, and + // positioned in the top-left corner. + // 2. Optionally change the overlay position and/or size by calling + // CefOverlayController methods. + // 3. Call CefOverlayController::SetVisible(true) to show the overlay. + // 4. The overlay will be automatically re-sized if |view|'s layout changes. + // Optionally change the overlay position and/or size when + // OnLayoutChanged is called on the Window's delegate to indicate a + // change in Window bounds. + // + // With other docking modes: + // 1. The overlay is initially hidden, sized to |view|'s preferred size, and + // positioned based on |docking_mode|. + // 2. Call CefOverlayController::SetVisible(true) to show the overlay. + // 3. The overlay will be automatically re-sized if |view|'s layout changes + // and re-positioned as appropriate when the Window resizes. + // + // Overlays created by this method will receive a higher z-order then any + // child Views added previously. It is therefore recommended to call this + // method last after all other child Views have been added so that the overlay + // displays as the top-most child of the Window. + /// + /*--cef()--*/ + virtual CefRefPtr AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode) = 0; + /// // Show a menu with contents |menu_model|. |screen_point| specifies the menu // position in screen coordinates. |anchor_position| specifies how the menu diff --git a/libcef/browser/chrome/views/chrome_views_util.cc b/libcef/browser/chrome/views/chrome_views_util.cc new file mode 100644 index 000000000..83254ab04 --- /dev/null +++ b/libcef/browser/chrome/views/chrome_views_util.cc @@ -0,0 +1,15 @@ +// Copyright 2021 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/chrome/views/chrome_views_util.h" + +#include "libcef/browser/views/view_util.h" + +namespace cef { + +bool IsCefView(views::View* view) { + return view_util::GetFor(view, /*find_known_parent=*/false) != nullptr; +} + +} // namespace cef diff --git a/libcef/browser/chrome/views/chrome_views_util.h b/libcef/browser/chrome/views/chrome_views_util.h new file mode 100644 index 000000000..20f528ab0 --- /dev/null +++ b/libcef/browser/chrome/views/chrome_views_util.h @@ -0,0 +1,20 @@ +// Copyright 2021 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. + +#ifndef CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_VIEWS_H_ +#define CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_VIEWS_H_ +#pragma once + +namespace views { +class View; +} + +namespace cef { + +// Returns true if |view| is a CefView. +bool IsCefView(views::View* view); + +} // namespace cef + +#endif // CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_VIEWS_H_ diff --git a/libcef/browser/views/overlay_view_host.cc b/libcef/browser/views/overlay_view_host.cc new file mode 100644 index 000000000..6c5d257f7 --- /dev/null +++ b/libcef/browser/views/overlay_view_host.cc @@ -0,0 +1,330 @@ +// Copyright 2021 The Chromium Embedded Framework Authors. Portions copyright +// 2011 The Chromium 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/overlay_view_host.h" + +#include "libcef/browser/views/view_util.h" +#include "libcef/browser/views/window_view.h" + +#include "base/i18n/rtl.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/views/theme_copying_widget.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/compositor/layer.h" + +#if defined(USE_AURA) +#include "ui/aura/window.h" +#include "ui/views/view_constants_aura.h" +#endif + +namespace { + +class CefOverlayControllerImpl : public CefOverlayController { + public: + CefOverlayControllerImpl(CefOverlayViewHost* host, CefRefPtr view) + : host_(host), view_(view) {} + + bool IsValid() override { + // View validity implies that CefOverlayViewHost is still valid, because the + // Widget that it owns (and that owns the View) is still valid. + return view_ && view_->IsValid(); + } + + bool IsSame(CefRefPtr that) override { + return that && that->GetContentsView()->IsSame(view_); + } + + CefRefPtr GetContentsView() override { return view_; } + + CefRefPtr GetWindow() override { + if (IsValid()) { + return view_util::GetWindowFor(host_->window_view()->GetWidget()); + } + return nullptr; + } + + cef_docking_mode_t GetDockingMode() override { + if (IsValid()) { + return host_->docking_mode(); + } + return CEF_DOCKING_MODE_TOP_LEFT; + } + + void Destroy() override { + if (IsValid()) { + host_->Destroy(); + view_ = nullptr; + } + } + + void SetBounds(const CefRect& bounds) override { + if (IsValid() && host_->docking_mode() == CEF_DOCKING_MODE_CUSTOM) { + host_->SetOverlayBounds( + gfx::Rect(bounds.x, bounds.y, bounds.width, bounds.height)); + } + } + + CefRect GetBounds() override { + if (IsValid()) { + const auto& bounds = host_->bounds(); + return CefRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()); + } + return CefRect(); + } + + CefRect GetBoundsInScreen() override { + if (IsValid()) { + const auto& bounds = host_->widget()->GetWindowBoundsInScreen(); + return CefRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()); + } + return CefRect(); + } + + void SetSize(const CefSize& size) override { + if (IsValid() && host_->docking_mode() == CEF_DOCKING_MODE_CUSTOM) { + // Update the size without changing the origin. + const auto& origin = host_->bounds().origin(); + host_->SetOverlayBounds( + gfx::Rect(origin, gfx::Size(size.width, size.height))); + } + } + + CefSize GetSize() override { + const auto& bounds = GetBounds(); + return CefSize(bounds.width, bounds.height); + } + + void SetPosition(const CefPoint& position) override { + if (IsValid() && host_->docking_mode() == CEF_DOCKING_MODE_CUSTOM) { + // Update the origin without changing the size. + const auto& size = host_->bounds().size(); + host_->SetOverlayBounds( + gfx::Rect(gfx::Point(position.x, position.y), size)); + } + } + + CefPoint GetPosition() override { + const auto& bounds = GetBounds(); + return CefPoint(bounds.x, bounds.y); + } + + void SetInsets(const CefInsets& insets) override { + if (IsValid() && host_->docking_mode() != CEF_DOCKING_MODE_CUSTOM) { + host_->SetOverlayInsets(insets); + } + } + + CefInsets GetInsets() override { + if (IsValid()) { + return host_->insets(); + } + return CefInsets(); + } + + void SizeToPreferredSize() override { + if (IsValid()) { + if (host_->docking_mode() == CEF_DOCKING_MODE_CUSTOM) { + // Update the size without changing the origin. + const auto& origin = host_->bounds().origin(); + const auto& preferred_size = host_->view()->GetPreferredSize(); + host_->SetOverlayBounds(gfx::Rect(origin, preferred_size)); + } else { + host_->MoveIfNecessary(); + } + } + } + + void SetVisible(bool visible) override { + if (IsValid()) { + if (visible) { + host_->MoveIfNecessary(); + host_->widget()->Show(); + } else { + host_->widget()->Hide(); + } + } + } + + bool IsVisible() override { + if (IsValid()) { + return host_->widget()->IsVisible(); + } + return false; + } + + bool IsDrawn() override { return IsVisible(); } + + private: + CefOverlayViewHost* const host_; + CefRefPtr view_; + + IMPLEMENT_REFCOUNTING(CefOverlayControllerImpl); + DISALLOW_COPY_AND_ASSIGN(CefOverlayControllerImpl); +}; + +} // namespace + +CefOverlayViewHost::CefOverlayViewHost(CefWindowView* window_view, + cef_docking_mode_t docking_mode) + : window_view_(window_view), docking_mode_(docking_mode) {} + +void CefOverlayViewHost::Init(views::View* widget_view, + CefRefPtr view) { + DCHECK(view); + + // Match the logic in CEF_PANEL_IMPL_D::AddChildView(). + auto controls_view = view->IsAttached() + ? base::WrapUnique(view_util::GetFor(view)) + : view_util::PassOwnership(view); + DCHECK(controls_view.get()); + + cef_controller_ = new CefOverlayControllerImpl(this, view); + + // Initialize the Widget. + widget_ = std::make_unique(window_view_->GetWidget()); + views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); + params.delegate = this; + params.name = "CefOverlayViewHost"; + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + params.parent = window_view_->GetWidget()->GetNativeView(); + params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent; + params.activatable = views::Widget::InitParams::Activatable::kNo; + widget_->Init(std::move(params)); + + view_ = widget_->GetContentsView()->AddChildView(std::move(controls_view)); + + // Make the Widget background transparent. The View might still be opaque. + if (widget_->GetCompositor()) { + widget_->GetCompositor()->SetBackgroundColor(SK_ColorTRANSPARENT); + } + +#if defined(USE_AURA) + // See matching logic in view_util::GetWindowFor. + widget_->GetNativeView()->SetProperty(views::kHostViewKey, widget_view); +#endif + + if (cef::IsChromeRuntimeEnabled()) { + // Some attributes associated with a Chrome toolbar are located via the + // Widget. See matching logic in BrowserView::AddedToWidget. + auto browser_view = BrowserView::GetBrowserViewForNativeWindow( + view_util::GetNativeWindow(window_view_->GetWidget())); + if (browser_view) { + widget_->SetNativeWindowProperty(BrowserView::kBrowserViewKey, + browser_view); + } + } + + // Set the initial bounds after the View has been added to the Widget. + // Otherwise, preferred size won't calculate correctly. + gfx::Rect bounds; + if (docking_mode_ == CEF_DOCKING_MODE_CUSTOM) { + if (view_->size().IsEmpty()) { + // Size to the preferred size to start. + view_->SizeToPreferredSize(); + } + + // Top-left origin with existing size. + bounds = gfx::Rect(gfx::Point(), view_->size()); + } else { + bounds = ComputeBounds(); + } + SetOverlayBounds(bounds); + + // Register for future bounds change notifications. + view_->AddObserver(this); + + // Initially hidden. + widget_->Hide(); +} + +void CefOverlayViewHost::Destroy() { + if (widget_ && !widget_->IsClosed()) { + // Remove the child View immediately. It may be reused by the client. + auto view = view_util::GetFor(view_, /*find_known_parent=*/false); + widget_->GetContentsView()->RemoveChildView(view_); + if (view) { + view_util::ResumeOwnership(view); + } + + widget_->Close(); + } +} + +void CefOverlayViewHost::MoveIfNecessary() { + if (bounds_changing_ || docking_mode_ == CEF_DOCKING_MODE_CUSTOM) { + return; + } + SetOverlayBounds(ComputeBounds()); +} + +void CefOverlayViewHost::SetOverlayBounds(const gfx::Rect& bounds) { + // Avoid re-entrancy of this method. + if (bounds_changing_) + return; + + gfx::Rect new_bounds = bounds; + + // Keep the result inside the widget. + new_bounds.Intersect(window_view_->bounds()); + + if (new_bounds == bounds_) + return; + + bounds_changing_ = true; + + bounds_ = new_bounds; + if (view_->size() != bounds_.size()) { + view_->SetSize(bounds_.size()); + } + widget_->SetBounds(bounds_); + + bounds_changing_ = false; +} + +void CefOverlayViewHost::SetOverlayInsets(const CefInsets& insets) { + if (insets == insets_) + return; + insets_ = insets; + MoveIfNecessary(); +} + +void CefOverlayViewHost::OnViewBoundsChanged(views::View* observed_view) { + MoveIfNecessary(); +} + +gfx::Rect CefOverlayViewHost::ComputeBounds() const { + // This method is only used with corner docking. + DCHECK_NE(docking_mode_, CEF_DOCKING_MODE_CUSTOM); + + // Find the area we have to work with. + const auto& widget_bounds = window_view_->bounds(); + + // Ask the view how large an area it needs to draw on. + const auto& prefsize = view_->GetPreferredSize(); + + // Swap left/right docking with RTL. + const bool is_rtl = base::i18n::IsRTL(); + + // Dock to the correct corner, considering insets in the docking corner only. + int x = widget_bounds.x(); + int y = widget_bounds.y(); + if (((docking_mode_ == CEF_DOCKING_MODE_TOP_RIGHT || + docking_mode_ == CEF_DOCKING_MODE_BOTTOM_RIGHT) && + !is_rtl) || + ((docking_mode_ == CEF_DOCKING_MODE_TOP_LEFT || + docking_mode_ == CEF_DOCKING_MODE_BOTTOM_LEFT) && + is_rtl)) { + x += widget_bounds.width() - prefsize.width() - insets_.right; + } else { + x += insets_.left; + } + if (docking_mode_ == CEF_DOCKING_MODE_BOTTOM_LEFT || + docking_mode_ == CEF_DOCKING_MODE_BOTTOM_RIGHT) { + y += widget_bounds.height() - prefsize.height() - insets_.bottom; + } else { + y += insets_.top; + } + + return gfx::Rect(x, y, prefsize.width(), prefsize.height()); +} diff --git a/libcef/browser/views/overlay_view_host.h b/libcef/browser/views/overlay_view_host.h new file mode 100644 index 000000000..6946c26d7 --- /dev/null +++ b/libcef/browser/views/overlay_view_host.h @@ -0,0 +1,79 @@ +// Copyright 2021 The Chromium Embedded Framework Authors. Portions copyright +// 2011 The Chromium Authors. All rights reserved. Use of this source code is +// governed by a BSD-style license that can be found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_VIEWS_OVERLAY_VIEW_HOST_H_ +#define CEF_LIBCEF_BROWSER_VIEWS_OVERLAY_VIEW_HOST_H_ +#pragma once + +#include + +#include "include/views/cef_overlay_controller.h" +#include "include/views/cef_view.h" + +#include "base/compiler_specific.h" +#include "base/macros.h" +#include "ui/views/view_observer.h" +#include "ui/views/widget/widget_delegate.h" + +class CefWindowView; + +// Host class for a child Widget that behaves as an overlay control. Based on +// Chrome's DropdownBarHost. +class CefOverlayViewHost : public views::WidgetDelegate, + public views::ViewObserver { + public: + // |window_view| is the top-level view that contains this overlay. + CefOverlayViewHost(CefWindowView* window_view, + cef_docking_mode_t docking_mode); + + // Initializes the CefOverlayViewHost. This creates the Widget that |view| + // paints into. |host_view| is the view whose position in the |window_view_| + // view hierarchy determines the z-order of the widget relative to views with + // layers and views with associated NativeViews. + void Init(views::View* host_view, CefRefPtr view); + + void Destroy(); + + void MoveIfNecessary(); + + void SetOverlayBounds(const gfx::Rect& bounds); + void SetOverlayInsets(const CefInsets& insets); + + // views::ViewObserver methods: + void OnViewBoundsChanged(views::View* observed_view) override; + + cef_docking_mode_t docking_mode() const { return docking_mode_; } + CefRefPtr controller() const { return cef_controller_; } + CefWindowView* window_view() const { return window_view_; } + views::Widget* widget() const { return widget_.get(); } + views::View* view() const { return view_; } + gfx::Rect bounds() const { return bounds_; } + CefInsets insets() const { return insets_; } + + private: + gfx::Rect ComputeBounds() const; + + // The CefWindowView that created us. + CefWindowView* const window_view_; + + const cef_docking_mode_t docking_mode_; + + // Our view, which is responsible for drawing the UI. + views::View* view_ = nullptr; + + // The Widget implementation that is created and maintained by the overlay. + // It contains |view_|. + std::unique_ptr widget_; + + CefRefPtr cef_controller_; + + gfx::Rect bounds_; + bool bounds_changing_ = false; + + CefInsets insets_; + + DISALLOW_COPY_AND_ASSIGN(CefOverlayViewHost); +}; + +#endif // CEF_LIBCEF_BROWSER_VIEWS_OVERLAY_VIEW_HOST_H_ diff --git a/libcef/browser/views/view_impl.h b/libcef/browser/views/view_impl.h index 3cd6e10ef..ef66a8527 100644 --- a/libcef/browser/views/view_impl.h +++ b/libcef/browser/views/view_impl.h @@ -299,6 +299,7 @@ #include "base/logging.h" #include "base/values.h" #include "ui/views/background.h" +#include "ui/views/border.h" #include "ui/views/view.h" // Helpers for template boiler-plate. @@ -384,6 +385,8 @@ CEF_VIEW_IMPL_T class CefViewImpl : public CefViewAdapter, public CefViewClass { CefSize GetSize() override; void SetPosition(const CefPoint& position) override; CefPoint GetPosition() override; + void SetInsets(const CefInsets& insets) override; + CefInsets GetInsets() override; CefSize GetPreferredSize() override; void SizeToPreferredSize() override; CefSize GetMinimumSize() override; @@ -571,6 +574,20 @@ CEF_VIEW_IMPL_T CefPoint CEF_VIEW_IMPL_D::GetPosition() { return CefPoint(bounds.x, bounds.y); } +CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetInsets(const CefInsets& insets) { + CEF_REQUIRE_VALID_RETURN_VOID(); + gfx::Insets gfx_insets(insets.top, insets.left, insets.bottom, insets.right); + root_view()->SetBorder( + gfx_insets.IsEmpty() ? nullptr : views::CreateEmptyBorder(gfx_insets)); +} + +CEF_VIEW_IMPL_T CefInsets CEF_VIEW_IMPL_D::GetInsets() { + CEF_REQUIRE_VALID_RETURN(CefInsets()); + const auto insets = root_view()->GetInsets(); + return CefInsets(insets.top(), insets.left(), insets.bottom(), + insets.right()); +} + CEF_VIEW_IMPL_T CefSize CEF_VIEW_IMPL_D::GetPreferredSize() { CEF_REQUIRE_VALID_RETURN(CefSize()); const gfx::Size& size = root_view()->GetPreferredSize(); diff --git a/libcef/browser/views/view_util.cc b/libcef/browser/views/view_util.cc index 6ed14522f..ab017b162 100644 --- a/libcef/browser/views/view_util.cc +++ b/libcef/browser/views/view_util.cc @@ -20,6 +20,11 @@ #include "ui/display/win/screen_win.h" #endif +#if defined(USE_AURA) +#include "ui/aura/window.h" +#include "ui/views/view_constants_aura.h" +#endif + namespace view_util { namespace { @@ -160,6 +165,18 @@ void ResumeOwnership(CefRefPtr view) { CefRefPtr GetWindowFor(views::Widget* widget) { CefRefPtr window; +#if defined(USE_AURA) + // Retrieve the parent Widget for an overlay. + if (widget) { + // See matching logic in CefOverlayViewHost::Init. + auto widget_view = + widget->GetNativeView()->GetProperty(views::kHostViewKey); + if (widget_view) { + widget = widget_view->GetWidget(); + } + } +#endif // defined(USE_AURA) + if (widget) { // The views::WidgetDelegate should be a CefWindowView and |content_view| // should be the same CefWindowView. However, just in case the views::Widget diff --git a/libcef/browser/views/view_view.h b/libcef/browser/views/view_view.h index 7073b687e..afa850d19 100644 --- a/libcef/browser/views/view_view.h +++ b/libcef/browser/views/view_view.h @@ -156,6 +156,13 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::Layout() { // If Layout() did not provide a size then use the preferred size. if (ParentClass::size().IsEmpty()) ParentClass::SizeToPreferredSize(); + + if (cef_delegate()) { + const auto new_bounds = ParentClass::bounds(); + CefRect new_rect(new_bounds.x(), new_bounds.y(), new_bounds.width(), + new_bounds.height()); + cef_delegate()->OnLayoutChanged(GetCefView(), new_rect); + } } CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::ViewHierarchyChanged( @@ -202,8 +209,9 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyChildViewChanged( // Only notify for children that have a known CEF root view. For example, // don't notify when ScrollView adds child scroll bars. CefRefPtr child = view_util::GetFor(details.child, false); - if (child) + if (child) { cef_delegate()->OnChildViewChanged(GetCefView(), details.is_add, child); + } } CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyParentViewChanged( @@ -217,10 +225,11 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyParentViewChanged( return; // The immediate parent might be an intermediate view so find the closest - // known CEF root view. + // known CEF root view. |parent| might be nullptr for overlays. CefRefPtr parent = view_util::GetFor(details.parent, true); - DCHECK(parent); - cef_delegate()->OnParentViewChanged(GetCefView(), details.is_add, parent); + if (parent) { + cef_delegate()->OnParentViewChanged(GetCefView(), details.is_add, parent); + } } #endif // CEF_LIBCEF_BROWSER_VIEWS_VIEW_VIEW_H_ diff --git a/libcef/browser/views/window_impl.cc b/libcef/browser/views/window_impl.cc index 40103d22b..5cb772020 100644 --- a/libcef/browser/views/window_impl.cc +++ b/libcef/browser/views/window_impl.cc @@ -12,6 +12,7 @@ #include "libcef/browser/views/view_util.h" #include "libcef/browser/views/window_view.h" +#include "base/i18n/rtl.h" #include "ui/base/test/ui_controls.h" #include "ui/compositor/compositor.h" #include "ui/gfx/geometry/rect.h" @@ -278,6 +279,15 @@ CefRefPtr CefWindowImpl::GetWindowAppIcon() { return nullptr; } +CefRefPtr CefWindowImpl::AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode) { + CEF_REQUIRE_VALID_RETURN(nullptr); + if (root_view()) + return root_view()->AddOverlayView(view, docking_mode); + return nullptr; +} + void CefWindowImpl::GetDebugInfo(base::DictionaryValue* info, bool include_children) { ParentClass::GetDebugInfo(info, include_children); diff --git a/libcef/browser/views/window_impl.h b/libcef/browser/views/window_impl.h index 857b830ed..755fd18ef 100644 --- a/libcef/browser/views/window_impl.h +++ b/libcef/browser/views/window_impl.h @@ -58,6 +58,9 @@ class CefWindowImpl CefRefPtr GetWindowIcon() override; void SetWindowAppIcon(CefRefPtr image) override; CefRefPtr GetWindowAppIcon() override; + CefRefPtr AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode) override; void ShowMenu(CefRefPtr menu_model, const CefPoint& screen_point, cef_menu_anchor_position_t anchor_position) override; diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index e3c2828f5..a8ace4c6c 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -312,6 +312,7 @@ void CefWindowView::CreateWidget() { #endif widget->Init(std::move(params)); + widget->AddObserver(this); // |widget| should now be associated with |this|. DCHECK_EQ(widget, GetWidget()); @@ -465,6 +466,11 @@ void CefWindowView::ViewHierarchyChanged( ParentClass::ViewHierarchyChanged(details); } +void CefWindowView::OnWidgetBoundsChanged(views::Widget* widget, + const gfx::Rect& new_bounds) { + MoveOverlaysIfNecessary(); +} + display::Display CefWindowView::GetDisplay() const { const views::Widget* widget = GetWidget(); if (widget) { @@ -500,6 +506,39 @@ void CefWindowView::SetWindowAppIcon(CefRefPtr window_app_icon) { widget->UpdateWindowIcon(); } +CefRefPtr CefWindowView::AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode) { + DCHECK(view.get()); + DCHECK(view->IsValid()); + if (!view.get() || !view->IsValid()) + return nullptr; + + views::Widget* widget = GetWidget(); + if (widget) { + // Owned by the View hierarchy. Acts as a z-order reference for the overlay. + auto overlay_host_view = AddChildView(std::make_unique()); + + overlay_hosts_.push_back( + std::make_unique(this, docking_mode)); + + auto& overlay_host = overlay_hosts_.back(); + overlay_host->Init(overlay_host_view, view); + + return overlay_host->controller(); + } + + return nullptr; +} + +void CefWindowView::MoveOverlaysIfNecessary() { + if (overlay_hosts_.empty()) + return; + for (auto& overlay_host : overlay_hosts_) { + overlay_host->MoveIfNecessary(); + } +} + void CefWindowView::SetDraggableRegions( const std::vector& regions) { if (regions.empty()) { diff --git a/libcef/browser/views/window_view.h b/libcef/browser/views/window_view.h index c012dc5a0..2f551b4b4 100644 --- a/libcef/browser/views/window_view.h +++ b/libcef/browser/views/window_view.h @@ -6,19 +6,24 @@ #define CEF_LIBCEF_BROWSER_VIEWS_WINDOW_VIEW_H_ #pragma once +#include + #include "include/views/cef_window.h" #include "include/views/cef_window_delegate.h" +#include "libcef/browser/views/overlay_view_host.h" #include "libcef/browser/views/panel_view.h" #include "third_party/skia/include/core/SkRegion.h" #include "ui/display/display.h" #include "ui/views/widget/widget_delegate.h" +#include "ui/views/widget/widget_observer.h" // Manages the views-based root window. This object will be deleted // automatically when the associated root window is destroyed. class CefWindowView - : public CefPanelView { + : public CefPanelView, + public views::WidgetObserver { public: typedef CefPanelView ParentClass; @@ -70,6 +75,10 @@ class CefWindowView void ViewHierarchyChanged( const views::ViewHierarchyChangedDetails& details) override; + // views::WidgetObserver methods: + void OnWidgetBoundsChanged(views::Widget* widget, + const gfx::Rect& new_bounds) override; + // Returns the Display containing this Window. display::Display GetDisplay() const; @@ -89,6 +98,10 @@ class CefWindowView void SetWindowAppIcon(CefRefPtr window_app_icon); CefRefPtr window_app_icon() const { return window_app_icon_; } + CefRefPtr AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode); + // Set/get the draggable regions. void SetDraggableRegions(const std::vector& regions); SkRegion* draggable_region() const { return draggable_region_.get(); } @@ -100,6 +113,8 @@ class CefWindowView // Called when removed from the Widget and before |this| is deleted. void DeleteDelegate(); + void MoveOverlaysIfNecessary(); + // Not owned by this object. Delegate* window_delegate_; @@ -112,6 +127,9 @@ class CefWindowView std::unique_ptr draggable_region_; + // Hosts for overlay widgets. + std::vector> overlay_hosts_; + DISALLOW_COPY_AND_ASSIGN(CefWindowView); }; diff --git a/libcef/common/i18n_util_impl.cc b/libcef/common/i18n_util_impl.cc new file mode 100644 index 000000000..b4f901b08 --- /dev/null +++ b/libcef/common/i18n_util_impl.cc @@ -0,0 +1,11 @@ +// Copyright 2021 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 "include/cef_i18n_util.h" + +#include "base/i18n/rtl.h" + +bool CefIsRTL() { + return base::i18n::IsRTL(); +} diff --git a/libcef_dll/cpptoc/views/browser_view_cpptoc.cc b/libcef_dll/cpptoc/views/browser_view_cpptoc.cc index bed65f7d6..94c1b4844 100644 --- a/libcef_dll/cpptoc/views/browser_view_cpptoc.cc +++ b/libcef_dll/cpptoc/views/browser_view_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=312985bb5cc971d1fe9d77af1f985f6a544e9db5$ +// $hash=7cbe7d4732eae535d759b62e718f5ab2de570f0a$ // #include "libcef_dll/cpptoc/views/browser_view_cpptoc.h" @@ -606,6 +606,46 @@ cef_point_t CEF_CALLBACK browser_view_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK browser_view_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefBrowserViewCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK browser_view_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefBrowserViewCppToC::Get(reinterpret_cast(self)) + ->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK browser_view_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1120,6 +1160,8 @@ CefBrowserViewCppToC::CefBrowserViewCppToC() { GetStruct()->base.get_size = browser_view_get_size; GetStruct()->base.set_position = browser_view_set_position; GetStruct()->base.get_position = browser_view_get_position; + GetStruct()->base.set_insets = browser_view_set_insets; + GetStruct()->base.get_insets = browser_view_get_insets; GetStruct()->base.get_preferred_size = browser_view_get_preferred_size; GetStruct()->base.size_to_preferred_size = browser_view_size_to_preferred_size; diff --git a/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc index 6cdb81427..ba9a614ee 100644 --- a/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=8e8daae6a8ed718582045ea42e16906813b77337$ +// $hash=3067f33d10bbd2f7555a6a809bad7ea8e97dbece$ // #include "libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.h" @@ -343,6 +343,35 @@ browser_view_delegate_on_window_changed(struct _cef_view_delegate_t* self, ->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false); } +void CEF_CALLBACK +browser_view_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefBrowserViewDelegateCppToC::Get( + reinterpret_cast(self)) + ->OnLayoutChanged(CefViewCToCpp::Wrap(view), new_boundsVal); +} + void CEF_CALLBACK browser_view_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { @@ -410,6 +439,7 @@ CefBrowserViewDelegateCppToC::CefBrowserViewDelegateCppToC() { GetStruct()->base.on_child_view_changed = browser_view_delegate_on_child_view_changed; GetStruct()->base.on_window_changed = browser_view_delegate_on_window_changed; + GetStruct()->base.on_layout_changed = browser_view_delegate_on_layout_changed; GetStruct()->base.on_focus = browser_view_delegate_on_focus; GetStruct()->base.on_blur = browser_view_delegate_on_blur; } diff --git a/libcef_dll/cpptoc/views/button_cpptoc.cc b/libcef_dll/cpptoc/views/button_cpptoc.cc index d8cea85c0..094c10351 100644 --- a/libcef_dll/cpptoc/views/button_cpptoc.cc +++ b/libcef_dll/cpptoc/views/button_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a0060b09d6eb4bbeeb69e4b80dccccee394d600e$ +// $hash=328f5caabb9eb92f668961216f9812b2a9bc3ee7$ // #include "libcef_dll/cpptoc/views/button_cpptoc.h" @@ -580,6 +580,45 @@ cef_point_t CEF_CALLBACK button_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK button_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefButtonCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK button_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefButtonCppToC::Get(reinterpret_cast(self))->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK button_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1076,6 +1115,8 @@ CefButtonCppToC::CefButtonCppToC() { GetStruct()->base.get_size = button_get_size; GetStruct()->base.set_position = button_set_position; GetStruct()->base.get_position = button_get_position; + GetStruct()->base.set_insets = button_set_insets; + GetStruct()->base.get_insets = button_get_insets; GetStruct()->base.get_preferred_size = button_get_preferred_size; GetStruct()->base.size_to_preferred_size = button_size_to_preferred_size; GetStruct()->base.get_minimum_size = button_get_minimum_size; diff --git a/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc index 2870db70e..e06284bb9 100644 --- a/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=52a0deb8b7ae62e474acb1474cf922c3e9a04f14$ +// $hash=ae5b6dce4c1840faa597c2dcb2b92772fa4f8de4$ // #include "libcef_dll/cpptoc/views/button_delegate_cpptoc.h" @@ -234,6 +234,34 @@ button_delegate_on_window_changed(struct _cef_view_delegate_t* self, ->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false); } +void CEF_CALLBACK +button_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefButtonDelegateCppToC::Get(reinterpret_cast(self)) + ->OnLayoutChanged(CefViewCToCpp::Wrap(view), new_boundsVal); +} + void CEF_CALLBACK button_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { shutdown_checker::AssertNotShutdown(); @@ -289,6 +317,7 @@ CefButtonDelegateCppToC::CefButtonDelegateCppToC() { GetStruct()->base.on_child_view_changed = button_delegate_on_child_view_changed; GetStruct()->base.on_window_changed = button_delegate_on_window_changed; + GetStruct()->base.on_layout_changed = button_delegate_on_layout_changed; GetStruct()->base.on_focus = button_delegate_on_focus; GetStruct()->base.on_blur = button_delegate_on_blur; } diff --git a/libcef_dll/cpptoc/views/label_button_cpptoc.cc b/libcef_dll/cpptoc/views/label_button_cpptoc.cc index d3c8c812d..b3e940e91 100644 --- a/libcef_dll/cpptoc/views/label_button_cpptoc.cc +++ b/libcef_dll/cpptoc/views/label_button_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=f723bc389e8df80f926a3e1952d9ba0241fcb494$ +// $hash=4831a878243309dc259eea8ac107a2654b0da9fd$ // #include "libcef_dll/cpptoc/views/label_button_cpptoc.h" @@ -826,6 +826,46 @@ cef_point_t CEF_CALLBACK label_button_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK label_button_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefLabelButtonCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK label_button_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefLabelButtonCppToC::Get(reinterpret_cast(self)) + ->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK label_button_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1355,6 +1395,8 @@ CefLabelButtonCppToC::CefLabelButtonCppToC() { GetStruct()->base.base.get_size = label_button_get_size; GetStruct()->base.base.set_position = label_button_set_position; GetStruct()->base.base.get_position = label_button_get_position; + GetStruct()->base.base.set_insets = label_button_set_insets; + GetStruct()->base.base.get_insets = label_button_get_insets; GetStruct()->base.base.get_preferred_size = label_button_get_preferred_size; GetStruct()->base.base.size_to_preferred_size = label_button_size_to_preferred_size; diff --git a/libcef_dll/cpptoc/views/menu_button_cpptoc.cc b/libcef_dll/cpptoc/views/menu_button_cpptoc.cc index 9d15b707e..d764dd969 100644 --- a/libcef_dll/cpptoc/views/menu_button_cpptoc.cc +++ b/libcef_dll/cpptoc/views/menu_button_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=97c8a26550af49abfe4a1fcf1d8d54193c5fb3b1$ +// $hash=17a2490a2076439fca2ee7e6c2984f9307b880fc$ // #include "libcef_dll/cpptoc/views/menu_button_cpptoc.h" @@ -878,6 +878,46 @@ cef_point_t CEF_CALLBACK menu_button_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK menu_button_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefMenuButtonCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK menu_button_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefMenuButtonCppToC::Get(reinterpret_cast(self)) + ->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK menu_button_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1407,6 +1447,8 @@ CefMenuButtonCppToC::CefMenuButtonCppToC() { GetStruct()->base.base.base.get_size = menu_button_get_size; GetStruct()->base.base.base.set_position = menu_button_set_position; GetStruct()->base.base.base.get_position = menu_button_get_position; + GetStruct()->base.base.base.set_insets = menu_button_set_insets; + GetStruct()->base.base.base.get_insets = menu_button_get_insets; GetStruct()->base.base.base.get_preferred_size = menu_button_get_preferred_size; GetStruct()->base.base.base.size_to_preferred_size = diff --git a/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc index f76e3053b..8e16879ea 100644 --- a/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=2fcd1d4d2126285209e1fa782beccbb363693bf3$ +// $hash=36a7761d47db5574fc6504b42a988e9f12ef234c$ // #include "libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h" @@ -274,6 +274,35 @@ menu_button_delegate_on_window_changed(struct _cef_view_delegate_t* self, ->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false); } +void CEF_CALLBACK +menu_button_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefMenuButtonDelegateCppToC::Get( + reinterpret_cast(self)) + ->OnLayoutChanged(CefViewCToCpp::Wrap(view), new_boundsVal); +} + void CEF_CALLBACK menu_button_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { @@ -340,6 +369,8 @@ CefMenuButtonDelegateCppToC::CefMenuButtonDelegateCppToC() { menu_button_delegate_on_child_view_changed; GetStruct()->base.base.on_window_changed = menu_button_delegate_on_window_changed; + GetStruct()->base.base.on_layout_changed = + menu_button_delegate_on_layout_changed; GetStruct()->base.base.on_focus = menu_button_delegate_on_focus; GetStruct()->base.base.on_blur = menu_button_delegate_on_blur; } diff --git a/libcef_dll/cpptoc/views/overlay_controller_cpptoc.cc b/libcef_dll/cpptoc/views/overlay_controller_cpptoc.cc new file mode 100644 index 000000000..ca3967ad4 --- /dev/null +++ b/libcef_dll/cpptoc/views/overlay_controller_cpptoc.cc @@ -0,0 +1,416 @@ +// Copyright (c) 2021 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=5f6f27874fc4e0ee698920fa734254eac9d14efa$ +// + +#include "libcef_dll/cpptoc/views/overlay_controller_cpptoc.h" +#include "libcef_dll/cpptoc/views/view_cpptoc.h" +#include "libcef_dll/cpptoc/views/window_cpptoc.h" +#include "libcef_dll/shutdown_checker.h" + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK +overlay_controller_is_valid(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefOverlayControllerCppToC::Get(self)->IsValid(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK +overlay_controller_is_same(struct _cef_overlay_controller_t* self, + struct _cef_overlay_controller_t* that) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: that; type: refptr_same + DCHECK(that); + if (!that) + return 0; + + // Execute + bool _retval = CefOverlayControllerCppToC::Get(self)->IsSame( + CefOverlayControllerCppToC::Unwrap(that)); + + // Return type: bool + return _retval; +} + +struct _cef_view_t* CEF_CALLBACK +overlay_controller_get_contents_view(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = + CefOverlayControllerCppToC::Get(self)->GetContentsView(); + + // Return type: refptr_same + return CefViewCppToC::Wrap(_retval); +} + +struct _cef_window_t* CEF_CALLBACK +overlay_controller_get_window(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = + CefOverlayControllerCppToC::Get(self)->GetWindow(); + + // Return type: refptr_same + return CefWindowCppToC::Wrap(_retval); +} + +cef_docking_mode_t CEF_CALLBACK +overlay_controller_get_docking_mode(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CEF_DOCKING_MODE_TOP_LEFT; + + // Execute + cef_docking_mode_t _retval = + CefOverlayControllerCppToC::Get(self)->GetDockingMode(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK +overlay_controller_destroy(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefOverlayControllerCppToC::Get(self)->Destroy(); +} + +void CEF_CALLBACK +overlay_controller_set_bounds(struct _cef_overlay_controller_t* self, + const cef_rect_t* bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: bounds; type: simple_byref_const + DCHECK(bounds); + if (!bounds) + return; + + // Translate param: bounds; type: simple_byref_const + CefRect boundsVal = bounds ? *bounds : CefRect(); + + // Execute + CefOverlayControllerCppToC::Get(self)->SetBounds(boundsVal); +} + +cef_rect_t CEF_CALLBACK +overlay_controller_get_bounds(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefRect(); + + // Execute + cef_rect_t _retval = CefOverlayControllerCppToC::Get(self)->GetBounds(); + + // Return type: simple + return _retval; +} + +cef_rect_t CEF_CALLBACK overlay_controller_get_bounds_in_screen( + struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefRect(); + + // Execute + cef_rect_t _retval = + CefOverlayControllerCppToC::Get(self)->GetBoundsInScreen(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK +overlay_controller_set_size(struct _cef_overlay_controller_t* self, + const cef_size_t* size) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: size; type: simple_byref_const + DCHECK(size); + if (!size) + return; + + // Translate param: size; type: simple_byref_const + CefSize sizeVal = size ? *size : CefSize(); + + // Execute + CefOverlayControllerCppToC::Get(self)->SetSize(sizeVal); +} + +cef_size_t CEF_CALLBACK +overlay_controller_get_size(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefSize(); + + // Execute + cef_size_t _retval = CefOverlayControllerCppToC::Get(self)->GetSize(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK +overlay_controller_set_position(struct _cef_overlay_controller_t* self, + const cef_point_t* position) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: position; type: simple_byref_const + DCHECK(position); + if (!position) + return; + + // Translate param: position; type: simple_byref_const + CefPoint positionVal = position ? *position : CefPoint(); + + // Execute + CefOverlayControllerCppToC::Get(self)->SetPosition(positionVal); +} + +cef_point_t CEF_CALLBACK +overlay_controller_get_position(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefPoint(); + + // Execute + cef_point_t _retval = CefOverlayControllerCppToC::Get(self)->GetPosition(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK +overlay_controller_set_insets(struct _cef_overlay_controller_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefOverlayControllerCppToC::Get(self)->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK +overlay_controller_get_insets(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = CefOverlayControllerCppToC::Get(self)->GetInsets(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK overlay_controller_size_to_preferred_size( + struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefOverlayControllerCppToC::Get(self)->SizeToPreferredSize(); +} + +void CEF_CALLBACK +overlay_controller_set_visible(struct _cef_overlay_controller_t* self, + int visible) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefOverlayControllerCppToC::Get(self)->SetVisible(visible ? true : false); +} + +int CEF_CALLBACK +overlay_controller_is_visible(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefOverlayControllerCppToC::Get(self)->IsVisible(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK +overlay_controller_is_drawn(struct _cef_overlay_controller_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefOverlayControllerCppToC::Get(self)->IsDrawn(); + + // Return type: bool + return _retval; +} + +} // namespace + +// CONSTRUCTOR - Do not edit by hand. + +CefOverlayControllerCppToC::CefOverlayControllerCppToC() { + GetStruct()->is_valid = overlay_controller_is_valid; + GetStruct()->is_same = overlay_controller_is_same; + GetStruct()->get_contents_view = overlay_controller_get_contents_view; + GetStruct()->get_window = overlay_controller_get_window; + GetStruct()->get_docking_mode = overlay_controller_get_docking_mode; + GetStruct()->destroy = overlay_controller_destroy; + GetStruct()->set_bounds = overlay_controller_set_bounds; + GetStruct()->get_bounds = overlay_controller_get_bounds; + GetStruct()->get_bounds_in_screen = overlay_controller_get_bounds_in_screen; + GetStruct()->set_size = overlay_controller_set_size; + GetStruct()->get_size = overlay_controller_get_size; + GetStruct()->set_position = overlay_controller_set_position; + GetStruct()->get_position = overlay_controller_get_position; + GetStruct()->set_insets = overlay_controller_set_insets; + GetStruct()->get_insets = overlay_controller_get_insets; + GetStruct()->size_to_preferred_size = + overlay_controller_size_to_preferred_size; + GetStruct()->set_visible = overlay_controller_set_visible; + GetStruct()->is_visible = overlay_controller_is_visible; + GetStruct()->is_drawn = overlay_controller_is_drawn; +} + +// DESTRUCTOR - Do not edit by hand. + +CefOverlayControllerCppToC::~CefOverlayControllerCppToC() { + shutdown_checker::AssertNotShutdown(); +} + +template <> +CefRefPtr CefCppToCRefCounted< + CefOverlayControllerCppToC, + CefOverlayController, + cef_overlay_controller_t>::UnwrapDerived(CefWrapperType type, + cef_overlay_controller_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return nullptr; +} + +template <> +CefWrapperType CefCppToCRefCounted::kWrapperType = + WT_OVERLAY_CONTROLLER; diff --git a/libcef_dll/cpptoc/views/overlay_controller_cpptoc.h b/libcef_dll/cpptoc/views/overlay_controller_cpptoc.h new file mode 100644 index 000000000..e4a80b31d --- /dev/null +++ b/libcef_dll/cpptoc/views/overlay_controller_cpptoc.h @@ -0,0 +1,42 @@ +// Copyright (c) 2021 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=a35c34c93f38c7db53ddd261a1631ef52d0f5ab5$ +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_VIEWS_OVERLAY_CONTROLLER_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_VIEWS_OVERLAY_CONTROLLER_CPPTOC_H_ +#pragma once + +#if !defined(BUILDING_CEF_SHARED) +#error This file can be included DLL-side only +#endif + +#include "include/capi/views/cef_overlay_controller_capi.h" +#include "include/capi/views/cef_view_capi.h" +#include "include/capi/views/cef_window_capi.h" +#include "include/views/cef_overlay_controller.h" +#include "include/views/cef_view.h" +#include "include/views/cef_window.h" +#include "libcef_dll/cpptoc/cpptoc_ref_counted.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefOverlayControllerCppToC + : public CefCppToCRefCounted { + public: + CefOverlayControllerCppToC(); + virtual ~CefOverlayControllerCppToC(); +}; + +#endif // CEF_LIBCEF_DLL_CPPTOC_VIEWS_OVERLAY_CONTROLLER_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/views/panel_cpptoc.cc b/libcef_dll/cpptoc/views/panel_cpptoc.cc index a9bcb8be7..34a567e69 100644 --- a/libcef_dll/cpptoc/views/panel_cpptoc.cc +++ b/libcef_dll/cpptoc/views/panel_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=46ba2afdb3ede88d0eb37df2726ab5ff33fb6983$ +// $hash=6a2e3823506ccfeeff53ac719edf6e912056e3a3$ // #include "libcef_dll/cpptoc/views/panel_cpptoc.h" @@ -713,6 +713,45 @@ cef_point_t CEF_CALLBACK panel_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK panel_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefPanelCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK panel_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefPanelCppToC::Get(reinterpret_cast(self))->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK panel_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1210,6 +1249,8 @@ CefPanelCppToC::CefPanelCppToC() { GetStruct()->base.get_size = panel_get_size; GetStruct()->base.set_position = panel_set_position; GetStruct()->base.get_position = panel_get_position; + GetStruct()->base.set_insets = panel_set_insets; + GetStruct()->base.get_insets = panel_get_insets; GetStruct()->base.get_preferred_size = panel_get_preferred_size; GetStruct()->base.size_to_preferred_size = panel_size_to_preferred_size; GetStruct()->base.get_minimum_size = panel_get_minimum_size; diff --git a/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc index 11f8ebfd1..8005b3eb4 100644 --- a/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=dd29f2990766a766a27dece7e39501eb11a296fd$ +// $hash=d212d26c4fdb8c0b24a9f1ea12d0a402b8466995$ // #include "libcef_dll/cpptoc/views/panel_delegate_cpptoc.h" @@ -193,6 +193,34 @@ panel_delegate_on_window_changed(struct _cef_view_delegate_t* self, ->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false); } +void CEF_CALLBACK +panel_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefPanelDelegateCppToC::Get(reinterpret_cast(self)) + ->OnLayoutChanged(CefViewCToCpp::Wrap(view), new_boundsVal); +} + void CEF_CALLBACK panel_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { shutdown_checker::AssertNotShutdown(); @@ -245,6 +273,7 @@ CefPanelDelegateCppToC::CefPanelDelegateCppToC() { GetStruct()->base.on_child_view_changed = panel_delegate_on_child_view_changed; GetStruct()->base.on_window_changed = panel_delegate_on_window_changed; + GetStruct()->base.on_layout_changed = panel_delegate_on_layout_changed; GetStruct()->base.on_focus = panel_delegate_on_focus; GetStruct()->base.on_blur = panel_delegate_on_blur; } diff --git a/libcef_dll/cpptoc/views/scroll_view_cpptoc.cc b/libcef_dll/cpptoc/views/scroll_view_cpptoc.cc index af6ad2e71..09342cb47 100644 --- a/libcef_dll/cpptoc/views/scroll_view_cpptoc.cc +++ b/libcef_dll/cpptoc/views/scroll_view_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=88d6df521d18ef28e9e2e7cbe31ecf6c96351430$ +// $hash=1b422791d4b286e5113f4867aa8da38e21e2a2ed$ // #include "libcef_dll/cpptoc/views/scroll_view_cpptoc.h" @@ -634,6 +634,46 @@ cef_point_t CEF_CALLBACK scroll_view_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK scroll_view_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefScrollViewCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK scroll_view_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefScrollViewCppToC::Get(reinterpret_cast(self)) + ->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK scroll_view_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1149,6 +1189,8 @@ CefScrollViewCppToC::CefScrollViewCppToC() { GetStruct()->base.get_size = scroll_view_get_size; GetStruct()->base.set_position = scroll_view_set_position; GetStruct()->base.get_position = scroll_view_get_position; + GetStruct()->base.set_insets = scroll_view_set_insets; + GetStruct()->base.get_insets = scroll_view_get_insets; GetStruct()->base.get_preferred_size = scroll_view_get_preferred_size; GetStruct()->base.size_to_preferred_size = scroll_view_size_to_preferred_size; GetStruct()->base.get_minimum_size = scroll_view_get_minimum_size; diff --git a/libcef_dll/cpptoc/views/textfield_cpptoc.cc b/libcef_dll/cpptoc/views/textfield_cpptoc.cc index 78286cae9..11cc839be 100644 --- a/libcef_dll/cpptoc/views/textfield_cpptoc.cc +++ b/libcef_dll/cpptoc/views/textfield_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=fd6b1cf787b563525dac101a765b7c399356e00c$ +// $hash=41aa4a08d59759dd53429976da36299374a554d7$ // #include "libcef_dll/cpptoc/views/textfield_cpptoc.h" @@ -1035,6 +1035,46 @@ cef_point_t CEF_CALLBACK textfield_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK textfield_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefTextfieldCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK textfield_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefTextfieldCppToC::Get(reinterpret_cast(self)) + ->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK textfield_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1572,6 +1612,8 @@ CefTextfieldCppToC::CefTextfieldCppToC() { GetStruct()->base.get_size = textfield_get_size; GetStruct()->base.set_position = textfield_set_position; GetStruct()->base.get_position = textfield_get_position; + GetStruct()->base.set_insets = textfield_set_insets; + GetStruct()->base.get_insets = textfield_get_insets; GetStruct()->base.get_preferred_size = textfield_get_preferred_size; GetStruct()->base.size_to_preferred_size = textfield_size_to_preferred_size; GetStruct()->base.get_minimum_size = textfield_get_minimum_size; diff --git a/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc index 7282c488c..5a32f1f37 100644 --- a/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=e35b635ec442c8910b02aca64d48760b1360c868$ +// $hash=9c22ccd70661c2c23bc5bbb6f80f4b04d42c90fe$ // #include "libcef_dll/cpptoc/views/textfield_delegate_cpptoc.h" @@ -249,6 +249,35 @@ textfield_delegate_on_window_changed(struct _cef_view_delegate_t* self, ->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false); } +void CEF_CALLBACK +textfield_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefTextfieldDelegateCppToC::Get( + reinterpret_cast(self)) + ->OnLayoutChanged(CefViewCToCpp::Wrap(view), new_boundsVal); +} + void CEF_CALLBACK textfield_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { shutdown_checker::AssertNotShutdown(); @@ -306,6 +335,7 @@ CefTextfieldDelegateCppToC::CefTextfieldDelegateCppToC() { GetStruct()->base.on_child_view_changed = textfield_delegate_on_child_view_changed; GetStruct()->base.on_window_changed = textfield_delegate_on_window_changed; + GetStruct()->base.on_layout_changed = textfield_delegate_on_layout_changed; GetStruct()->base.on_focus = textfield_delegate_on_focus; GetStruct()->base.on_blur = textfield_delegate_on_blur; } diff --git a/libcef_dll/cpptoc/views/view_cpptoc.cc b/libcef_dll/cpptoc/views/view_cpptoc.cc index 3a7dcc267..eaffe706d 100644 --- a/libcef_dll/cpptoc/views/view_cpptoc.cc +++ b/libcef_dll/cpptoc/views/view_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=0884539e94e09316a9e516d93d77743c6287fe9a$ +// $hash=df095c7377045f70561ee276a15fd0c13769851c$ // #include "libcef_dll/cpptoc/views/view_cpptoc.h" @@ -449,6 +449,43 @@ cef_point_t CEF_CALLBACK view_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK view_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefViewCppToC::Get(self)->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK view_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = CefViewCppToC::Get(self)->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK view_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -912,6 +949,8 @@ CefViewCppToC::CefViewCppToC() { GetStruct()->get_size = view_get_size; GetStruct()->set_position = view_set_position; GetStruct()->get_position = view_get_position; + GetStruct()->set_insets = view_set_insets; + GetStruct()->get_insets = view_get_insets; GetStruct()->get_preferred_size = view_get_preferred_size; GetStruct()->size_to_preferred_size = view_size_to_preferred_size; GetStruct()->get_minimum_size = view_get_minimum_size; diff --git a/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc index 9a06b6ff4..8903b8cfc 100644 --- a/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7c6283658d49420281d02b4793f65f478f261461$ +// $hash=fd17603645550a551edbab0248dbe75afa074c19$ // #include "libcef_dll/cpptoc/views/view_delegate_cpptoc.h" @@ -194,6 +194,34 @@ view_delegate_on_window_changed(struct _cef_view_delegate_t* self, added ? true : false); } +void CEF_CALLBACK +view_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefViewDelegateCppToC::Get(self)->OnLayoutChanged(CefViewCToCpp::Wrap(view), + new_boundsVal); +} + void CEF_CALLBACK view_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { shutdown_checker::AssertNotShutdown(); @@ -242,6 +270,7 @@ CefViewDelegateCppToC::CefViewDelegateCppToC() { GetStruct()->on_parent_view_changed = view_delegate_on_parent_view_changed; GetStruct()->on_child_view_changed = view_delegate_on_child_view_changed; GetStruct()->on_window_changed = view_delegate_on_window_changed; + GetStruct()->on_layout_changed = view_delegate_on_layout_changed; GetStruct()->on_focus = view_delegate_on_focus; GetStruct()->on_blur = view_delegate_on_blur; } diff --git a/libcef_dll/cpptoc/views/window_cpptoc.cc b/libcef_dll/cpptoc/views/window_cpptoc.cc index 6a5e0a9b6..e72373f9d 100644 --- a/libcef_dll/cpptoc/views/window_cpptoc.cc +++ b/libcef_dll/cpptoc/views/window_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=1d17ae751431af3baf83b3386f1cab410964a17f$ +// $hash=180f352b0c01effd2e61c3879b81dcd3b0989d0a$ // #include "libcef_dll/cpptoc/views/window_cpptoc.h" @@ -21,6 +21,7 @@ #include "libcef_dll/cpptoc/views/display_cpptoc.h" #include "libcef_dll/cpptoc/views/fill_layout_cpptoc.h" #include "libcef_dll/cpptoc/views/layout_cpptoc.h" +#include "libcef_dll/cpptoc/views/overlay_controller_cpptoc.h" #include "libcef_dll/cpptoc/views/panel_cpptoc.h" #include "libcef_dll/cpptoc/views/scroll_view_cpptoc.h" #include "libcef_dll/cpptoc/views/textfield_cpptoc.h" @@ -414,6 +415,31 @@ window_get_window_app_icon(struct _cef_window_t* self) { return CefImageCppToC::Wrap(_retval); } +cef_overlay_controller_t* CEF_CALLBACK +window_add_overlay_view(struct _cef_window_t* self, + cef_view_t* view, + cef_docking_mode_t docking_mode) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + // Verify param: view; type: refptr_same + DCHECK(view); + if (!view) + return NULL; + + // Execute + CefRefPtr _retval = + CefWindowCppToC::Get(self)->AddOverlayView(CefViewCppToC::Unwrap(view), + docking_mode); + + // Return type: refptr_same + return CefOverlayControllerCppToC::Wrap(_retval); +} + void CEF_CALLBACK window_show_menu(struct _cef_window_t* self, cef_menu_model_t* menu_model, const cef_point_t* screen_point, @@ -1309,6 +1335,45 @@ cef_point_t CEF_CALLBACK window_get_position(struct _cef_view_t* self) { return _retval; } +void CEF_CALLBACK window_set_insets(struct _cef_view_t* self, + const cef_insets_t* insets) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: insets; type: simple_byref_const + DCHECK(insets); + if (!insets) + return; + + // Translate param: insets; type: simple_byref_const + CefInsets insetsVal = insets ? *insets : CefInsets(); + + // Execute + CefWindowCppToC::Get(reinterpret_cast(self)) + ->SetInsets(insetsVal); +} + +cef_insets_t CEF_CALLBACK window_get_insets(struct _cef_view_t* self) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefInsets(); + + // Execute + cef_insets_t _retval = + CefWindowCppToC::Get(reinterpret_cast(self))->GetInsets(); + + // Return type: simple + return _retval; +} + cef_size_t CEF_CALLBACK window_get_preferred_size(struct _cef_view_t* self) { shutdown_checker::AssertNotShutdown(); @@ -1798,6 +1863,7 @@ CefWindowCppToC::CefWindowCppToC() { GetStruct()->get_window_icon = window_get_window_icon; GetStruct()->set_window_app_icon = window_set_window_app_icon; GetStruct()->get_window_app_icon = window_get_window_app_icon; + GetStruct()->add_overlay_view = window_add_overlay_view; GetStruct()->show_menu = window_show_menu; GetStruct()->cancel_menu = window_cancel_menu; GetStruct()->get_display = window_get_display; @@ -1848,6 +1914,8 @@ CefWindowCppToC::CefWindowCppToC() { GetStruct()->base.base.get_size = window_get_size; GetStruct()->base.base.set_position = window_set_position; GetStruct()->base.base.get_position = window_get_position; + GetStruct()->base.base.set_insets = window_set_insets; + GetStruct()->base.base.get_insets = window_get_insets; GetStruct()->base.base.get_preferred_size = window_get_preferred_size; GetStruct()->base.base.size_to_preferred_size = window_size_to_preferred_size; GetStruct()->base.base.get_minimum_size = window_get_minimum_size; diff --git a/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc index b3fb17135..c979e76f8 100644 --- a/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc +++ b/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a201b988556a825fffe39f58e378664b93795c72$ +// $hash=d6a40fcd6be6297224b573ac1600701ff6818680$ // #include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h" @@ -473,6 +473,34 @@ window_delegate_on_window_changed(struct _cef_view_delegate_t* self, ->OnWindowChanged(CefViewCToCpp::Wrap(view), added ? true : false); } +void CEF_CALLBACK +window_delegate_on_layout_changed(struct _cef_view_delegate_t* self, + cef_view_t* view, + const cef_rect_t* new_bounds) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: view; type: refptr_diff + DCHECK(view); + if (!view) + return; + // Verify param: new_bounds; type: simple_byref_const + DCHECK(new_bounds); + if (!new_bounds) + return; + + // Translate param: new_bounds; type: simple_byref_const + CefRect new_boundsVal = new_bounds ? *new_bounds : CefRect(); + + // Execute + CefWindowDelegateCppToC::Get(reinterpret_cast(self)) + ->OnLayoutChanged(CefViewCToCpp::Wrap(view), new_boundsVal); +} + void CEF_CALLBACK window_delegate_on_focus(struct _cef_view_delegate_t* self, cef_view_t* view) { shutdown_checker::AssertNotShutdown(); @@ -538,6 +566,7 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() { GetStruct()->base.base.on_child_view_changed = window_delegate_on_child_view_changed; GetStruct()->base.base.on_window_changed = window_delegate_on_window_changed; + GetStruct()->base.base.on_layout_changed = window_delegate_on_layout_changed; GetStruct()->base.base.on_focus = window_delegate_on_focus; GetStruct()->base.base.on_blur = window_delegate_on_blur; } diff --git a/libcef_dll/ctocpp/views/browser_view_ctocpp.cc b/libcef_dll/ctocpp/views/browser_view_ctocpp.cc index d2420a9f7..33e285efc 100644 --- a/libcef_dll/ctocpp/views/browser_view_ctocpp.cc +++ b/libcef_dll/ctocpp/views/browser_view_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=912a0807db8bc1405188d61961545cc8e540aacf$ +// $hash=fc8a176aa84aa99ad132a5d3853c8ea16ce6660f$ // #include "libcef_dll/ctocpp/views/browser_view_ctocpp.h" @@ -530,6 +530,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefBrowserViewCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefBrowserViewCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefBrowserViewCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefBrowserViewCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/browser_view_ctocpp.h b/libcef_dll/ctocpp/views/browser_view_ctocpp.h index d1759714a..8419c1af0 100644 --- a/libcef_dll/ctocpp/views/browser_view_ctocpp.h +++ b/libcef_dll/ctocpp/views/browser_view_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=1c713db1e73d434b6bce3aea8e3a6dddbc547b61$ +// $hash=93f91329a1d2db5d20805cb10ee30e1fcd6c3185$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_CTOCPP_H_ @@ -64,6 +64,8 @@ class CefBrowserViewCToCpp : public CefCToCppRefCounted view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefBrowserViewDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefBrowserViewDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h index 371638af5..eabb3b73e 100644 --- a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=20b067cabc4baa4c9edecaffb38a2ebb28524ccc$ +// $hash=13f61ebbe80de396a56f2dd894c8137031133c83$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_DELEGATE_CTOCPP_H_ @@ -65,6 +65,8 @@ class CefBrowserViewDelegateCToCpp bool added, CefRefPtr child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/ctocpp/views/button_ctocpp.cc b/libcef_dll/ctocpp/views/button_ctocpp.cc index 043f41fad..baf8e541c 100644 --- a/libcef_dll/ctocpp/views/button_ctocpp.cc +++ b/libcef_dll/ctocpp/views/button_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=b359b8f9e2c70946ed9831869100e82774a5ea2d$ +// $hash=d7b21b37439e1b87e9b9c61fbd86b6cfdb4d3c8d$ // #include "libcef_dll/ctocpp/views/button_ctocpp.h" @@ -526,6 +526,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefButtonCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefButtonCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefButtonCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefButtonCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/button_ctocpp.h b/libcef_dll/ctocpp/views/button_ctocpp.h index 366b8fa5f..684675b31 100644 --- a/libcef_dll/ctocpp/views/button_ctocpp.h +++ b/libcef_dll/ctocpp/views/button_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=b543831782043e1651b8adfa907a60b553267ca7$ +// $hash=bc6f35f85cc77030a7e36e1ebbb97cb9091cf976$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_CTOCPP_H_ @@ -68,6 +68,8 @@ class CefButtonCToCpp CefSize GetSize() override; void SetPosition(const CefPoint& position) override; CefPoint GetPosition() override; + void SetInsets(const CefInsets& insets) override; + CefInsets GetInsets() override; CefSize GetPreferredSize() override; void SizeToPreferredSize() override; CefSize GetMinimumSize() override; diff --git a/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc index 8f71a1612..e48991037 100644 --- a/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=fc962d2832eeb3dee99e9a201f234d4a4b4d6f0f$ +// $hash=10978e1021326cd0f21f84c0b35350e846b47fe9$ // #include "libcef_dll/ctocpp/views/button_delegate_ctocpp.h" @@ -231,6 +231,27 @@ void CefButtonDelegateCToCpp::OnWindowChanged(CefRefPtr view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefButtonDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefButtonDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/button_delegate_ctocpp.h b/libcef_dll/ctocpp/views/button_delegate_ctocpp.h index cffab417e..a17c6f4bb 100644 --- a/libcef_dll/ctocpp/views/button_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/button_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=6a72a71a9becd6103d44719ed88b000d576d95eb$ +// $hash=1120cbc3b78c41223e94493bf4416899f1b936ed$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_DELEGATE_CTOCPP_H_ @@ -52,6 +52,8 @@ class CefButtonDelegateCToCpp bool added, CefRefPtr child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/ctocpp/views/label_button_ctocpp.cc b/libcef_dll/ctocpp/views/label_button_ctocpp.cc index 066758771..3ad48248f 100644 --- a/libcef_dll/ctocpp/views/label_button_ctocpp.cc +++ b/libcef_dll/ctocpp/views/label_button_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7e8ef08cc7510dc0ca0b580ae4d8031cb7acc268$ +// $hash=21aa8991b400583b47f7cc29fb55334ff07b1eb4$ // #include "libcef_dll/ctocpp/views/label_button_ctocpp.h" @@ -737,6 +737,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefLabelButtonCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefLabelButtonCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefLabelButtonCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefLabelButtonCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/label_button_ctocpp.h b/libcef_dll/ctocpp/views/label_button_ctocpp.h index 9aa29766a..af188b744 100644 --- a/libcef_dll/ctocpp/views/label_button_ctocpp.h +++ b/libcef_dll/ctocpp/views/label_button_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=ef0338428bd0261ccfc0235718d8d1bd81e30315$ +// $hash=bb881cc52836308013fb9737d645077b623d55df$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_LABEL_BUTTON_CTOCPP_H_ @@ -83,6 +83,8 @@ class CefLabelButtonCToCpp : public CefCToCppRefCounted(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefMenuButtonCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefMenuButtonCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/menu_button_ctocpp.h b/libcef_dll/ctocpp/views/menu_button_ctocpp.h index 4de14cb90..4c6c08250 100644 --- a/libcef_dll/ctocpp/views/menu_button_ctocpp.h +++ b/libcef_dll/ctocpp/views/menu_button_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=90b4b0b803eaeef6873d455a2686dfd9f56a9fc3$ +// $hash=3b4a2266f93b3c3623b0f29831a7a7d57c52a628$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_CTOCPP_H_ @@ -87,6 +87,8 @@ class CefMenuButtonCToCpp : public CefCToCppRefCounted view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefMenuButtonDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefMenuButtonDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h index cfdf7c169..4f2227f87 100644 --- a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7836ec7b53349057b1d1d75c6ba8506620bed53d$ +// $hash=34037ec75b18dacfafd978da854131cfa0560d7d$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_DELEGATE_CTOCPP_H_ @@ -58,6 +58,8 @@ class CefMenuButtonDelegateCToCpp bool added, CefRefPtr child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/ctocpp/views/overlay_controller_ctocpp.cc b/libcef_dll/ctocpp/views/overlay_controller_ctocpp.cc new file mode 100644 index 000000000..7532beb93 --- /dev/null +++ b/libcef_dll/ctocpp/views/overlay_controller_ctocpp.cc @@ -0,0 +1,346 @@ +// Copyright (c) 2021 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=275cb37282252c06bd4fe5ad21291924d37937c0$ +// + +#include "libcef_dll/ctocpp/views/overlay_controller_ctocpp.h" +#include "libcef_dll/ctocpp/views/view_ctocpp.h" +#include "libcef_dll/ctocpp/views/window_ctocpp.h" +#include "libcef_dll/shutdown_checker.h" + +// VIRTUAL METHODS - Body may be edited by hand. + +NO_SANITIZE("cfi-icall") bool CefOverlayControllerCToCpp::IsValid() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, is_valid)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->is_valid(_struct); + + // Return type: bool + return _retval ? true : false; +} + +NO_SANITIZE("cfi-icall") +bool CefOverlayControllerCToCpp::IsSame(CefRefPtr that) { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, is_same)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: that; type: refptr_same + DCHECK(that.get()); + if (!that.get()) + return false; + + // Execute + int _retval = + _struct->is_same(_struct, CefOverlayControllerCToCpp::Unwrap(that)); + + // Return type: bool + return _retval ? true : false; +} + +NO_SANITIZE("cfi-icall") +CefRefPtr CefOverlayControllerCToCpp::GetContentsView() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_contents_view)) + return nullptr; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_view_t* _retval = _struct->get_contents_view(_struct); + + // Return type: refptr_same + return CefViewCToCpp::Wrap(_retval); +} + +NO_SANITIZE("cfi-icall") +CefRefPtr CefOverlayControllerCToCpp::GetWindow() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_window)) + return nullptr; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_window_t* _retval = _struct->get_window(_struct); + + // Return type: refptr_same + return CefWindowCToCpp::Wrap(_retval); +} + +NO_SANITIZE("cfi-icall") +cef_docking_mode_t CefOverlayControllerCToCpp::GetDockingMode() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_docking_mode)) + return CEF_DOCKING_MODE_TOP_LEFT; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_docking_mode_t _retval = _struct->get_docking_mode(_struct); + + // Return type: simple + return _retval; +} + +NO_SANITIZE("cfi-icall") void CefOverlayControllerCToCpp::Destroy() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, destroy)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->destroy(_struct); +} + +NO_SANITIZE("cfi-icall") +void CefOverlayControllerCToCpp::SetBounds(const CefRect& bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_bounds)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_bounds(_struct, &bounds); +} + +NO_SANITIZE("cfi-icall") CefRect CefOverlayControllerCToCpp::GetBounds() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_bounds)) + return CefRect(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_rect_t _retval = _struct->get_bounds(_struct); + + // Return type: simple + return _retval; +} + +NO_SANITIZE("cfi-icall") +CefRect CefOverlayControllerCToCpp::GetBoundsInScreen() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_bounds_in_screen)) + return CefRect(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_rect_t _retval = _struct->get_bounds_in_screen(_struct); + + // Return type: simple + return _retval; +} + +NO_SANITIZE("cfi-icall") +void CefOverlayControllerCToCpp::SetSize(const CefSize& size) { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_size)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_size(_struct, &size); +} + +NO_SANITIZE("cfi-icall") CefSize CefOverlayControllerCToCpp::GetSize() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_size)) + return CefSize(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_size_t _retval = _struct->get_size(_struct); + + // Return type: simple + return _retval; +} + +NO_SANITIZE("cfi-icall") +void CefOverlayControllerCToCpp::SetPosition(const CefPoint& position) { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_position)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_position(_struct, &position); +} + +NO_SANITIZE("cfi-icall") CefPoint CefOverlayControllerCToCpp::GetPosition() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_position)) + return CefPoint(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_point_t _retval = _struct->get_position(_struct); + + // Return type: simple + return _retval; +} + +NO_SANITIZE("cfi-icall") +void CefOverlayControllerCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefOverlayControllerCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + +NO_SANITIZE("cfi-icall") +void CefOverlayControllerCToCpp::SizeToPreferredSize() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, size_to_preferred_size)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->size_to_preferred_size(_struct); +} + +NO_SANITIZE("cfi-icall") +void CefOverlayControllerCToCpp::SetVisible(bool visible) { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_visible)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_visible(_struct, visible); +} + +NO_SANITIZE("cfi-icall") bool CefOverlayControllerCToCpp::IsVisible() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, is_visible)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->is_visible(_struct); + + // Return type: bool + return _retval ? true : false; +} + +NO_SANITIZE("cfi-icall") bool CefOverlayControllerCToCpp::IsDrawn() { + shutdown_checker::AssertNotShutdown(); + + cef_overlay_controller_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, is_drawn)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->is_drawn(_struct); + + // Return type: bool + return _retval ? true : false; +} + +// CONSTRUCTOR - Do not edit by hand. + +CefOverlayControllerCToCpp::CefOverlayControllerCToCpp() {} + +// DESTRUCTOR - Do not edit by hand. + +CefOverlayControllerCToCpp::~CefOverlayControllerCToCpp() { + shutdown_checker::AssertNotShutdown(); +} + +template <> +cef_overlay_controller_t* CefCToCppRefCounted< + CefOverlayControllerCToCpp, + CefOverlayController, + cef_overlay_controller_t>::UnwrapDerived(CefWrapperType type, + CefOverlayController* c) { + NOTREACHED() << "Unexpected class type: " << type; + return nullptr; +} + +template <> +CefWrapperType CefCToCppRefCounted::kWrapperType = + WT_OVERLAY_CONTROLLER; diff --git a/libcef_dll/ctocpp/views/overlay_controller_ctocpp.h b/libcef_dll/ctocpp/views/overlay_controller_ctocpp.h new file mode 100644 index 000000000..482ea24e5 --- /dev/null +++ b/libcef_dll/ctocpp/views/overlay_controller_ctocpp.h @@ -0,0 +1,63 @@ +// Copyright (c) 2021 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// +// $hash=3f0e14b544f91e4adfd0a3777242bc070025b927$ +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_OVERLAY_CONTROLLER_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_VIEWS_OVERLAY_CONTROLLER_CTOCPP_H_ +#pragma once + +#if !defined(WRAPPING_CEF_SHARED) +#error This file can be included wrapper-side only +#endif + +#include "include/capi/views/cef_overlay_controller_capi.h" +#include "include/capi/views/cef_view_capi.h" +#include "include/capi/views/cef_window_capi.h" +#include "include/views/cef_overlay_controller.h" +#include "include/views/cef_view.h" +#include "include/views/cef_window.h" +#include "libcef_dll/ctocpp/ctocpp_ref_counted.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefOverlayControllerCToCpp + : public CefCToCppRefCounted { + public: + CefOverlayControllerCToCpp(); + virtual ~CefOverlayControllerCToCpp(); + + // CefOverlayController methods. + bool IsValid() override; + bool IsSame(CefRefPtr that) override; + CefRefPtr GetContentsView() override; + CefRefPtr GetWindow() override; + cef_docking_mode_t GetDockingMode() override; + void Destroy() override; + void SetBounds(const CefRect& bounds) override; + CefRect GetBounds() override; + CefRect GetBoundsInScreen() override; + void SetSize(const CefSize& size) override; + CefSize GetSize() override; + void SetPosition(const CefPoint& position) override; + CefPoint GetPosition() override; + void SetInsets(const CefInsets& insets) override; + CefInsets GetInsets() override; + void SizeToPreferredSize() override; + void SetVisible(bool visible) override; + bool IsVisible() override; + bool IsDrawn() override; +}; + +#endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_OVERLAY_CONTROLLER_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/panel_ctocpp.cc b/libcef_dll/ctocpp/views/panel_ctocpp.cc index 3aa7739a0..0c768faac 100644 --- a/libcef_dll/ctocpp/views/panel_ctocpp.cc +++ b/libcef_dll/ctocpp/views/panel_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=3e77ca44ea8a99a3fc8c335cca58b4cbc790e9cb$ +// $hash=48fcc126726458e5391885e4513d74d56b0c5fdb$ // #include "libcef_dll/ctocpp/views/panel_ctocpp.h" @@ -658,6 +658,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefPanelCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefPanelCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefPanelCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefPanelCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/panel_ctocpp.h b/libcef_dll/ctocpp/views/panel_ctocpp.h index 69833bec5..07471c1b2 100644 --- a/libcef_dll/ctocpp/views/panel_ctocpp.h +++ b/libcef_dll/ctocpp/views/panel_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=c2d630805de3dbcb47933c566b791c0e2fb7e6d7$ +// $hash=a6e6ceefb7e403c46c00c59dd86104787ab77f7a$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_PANEL_CTOCPP_H_ @@ -81,6 +81,8 @@ class CefPanelCToCpp CefSize GetSize() override; void SetPosition(const CefPoint& position) override; CefPoint GetPosition() override; + void SetInsets(const CefInsets& insets) override; + CefInsets GetInsets() override; CefSize GetPreferredSize() override; void SizeToPreferredSize() override; CefSize GetMinimumSize() override; diff --git a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc index 0553e5896..873a4ea69 100644 --- a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=4bffffc0fe09523839a08109aef1e3de90f6e25c$ +// $hash=2606f866b3a2d6a4d582a5c2c1990d8f8a7ff65d$ // #include "libcef_dll/ctocpp/views/panel_delegate_ctocpp.h" @@ -191,6 +191,27 @@ void CefPanelDelegateCToCpp::OnWindowChanged(CefRefPtr view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefPanelDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefPanelDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h index 5830b5edd..3ebba59be 100644 --- a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=d508126f22cba29931a4d53aecbdaaca7dd39b9d$ +// $hash=c5368e0456a726a09fd5a76ec65cd3e9f6a04d0f$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_PANEL_DELEGATE_CTOCPP_H_ @@ -48,6 +48,8 @@ class CefPanelDelegateCToCpp bool added, CefRefPtr child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc b/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc index 0a459c6ac..e4665d5b5 100644 --- a/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc +++ b/libcef_dll/ctocpp/views/scroll_view_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=8c2b3c821c18076ce40392ea339c177c66d53cc2$ +// $hash=73f1e51eafb9ec8797e8f0753b33c2261c3b0e2f$ // #include "libcef_dll/ctocpp/views/scroll_view_ctocpp.h" @@ -565,6 +565,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefScrollViewCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefScrollViewCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefScrollViewCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefScrollViewCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/scroll_view_ctocpp.h b/libcef_dll/ctocpp/views/scroll_view_ctocpp.h index bde1b1dd3..ce986b484 100644 --- a/libcef_dll/ctocpp/views/scroll_view_ctocpp.h +++ b/libcef_dll/ctocpp/views/scroll_view_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=20f4f752402507b4573596d6759c93cd1bc7a982$ +// $hash=cc3bfb5c57f0b7b31997bfb5226dd3dd77f6d40c$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_SCROLL_VIEW_CTOCPP_H_ @@ -68,6 +68,8 @@ class CefScrollViewCToCpp : public CefCToCppRefCounted(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefTextfieldCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefTextfieldCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/textfield_ctocpp.h b/libcef_dll/ctocpp/views/textfield_ctocpp.h index b3dcd470f..9b25857ea 100644 --- a/libcef_dll/ctocpp/views/textfield_ctocpp.h +++ b/libcef_dll/ctocpp/views/textfield_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=e907d476bdd6717660c7e35f55ab9a1679f0f1fb$ +// $hash=b5dc694168601801e87d3b92544f3eb9ea3cecc9$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_TEXTFIELD_CTOCPP_H_ @@ -94,6 +94,8 @@ class CefTextfieldCToCpp : public CefCToCppRefCounted view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefTextfieldDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefTextfieldDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h index dd2af4586..1666396b2 100644 --- a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=3a83b906a29ba302874b73804e457680d2b7251e$ +// $hash=7c27f6f641fa940331d727bacfa1ac527a98e441$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_TEXTFIELD_DELEGATE_CTOCPP_H_ @@ -53,6 +53,8 @@ class CefTextfieldDelegateCToCpp bool added, CefRefPtr child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/ctocpp/views/view_ctocpp.cc b/libcef_dll/ctocpp/views/view_ctocpp.cc index 631c02cf3..2a2a0cee9 100644 --- a/libcef_dll/ctocpp/views/view_ctocpp.cc +++ b/libcef_dll/ctocpp/views/view_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=d791f23eeaa056cdc478743acd452c1d60a4fd00$ +// $hash=de07e058ed3b4435bc0f57cbdfc2160fae143112$ // #include "libcef_dll/ctocpp/views/view_ctocpp.h" @@ -426,6 +426,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefViewCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefViewCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefViewCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefViewCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/view_ctocpp.h b/libcef_dll/ctocpp/views/view_ctocpp.h index 94ba42392..d6df822eb 100644 --- a/libcef_dll/ctocpp/views/view_ctocpp.h +++ b/libcef_dll/ctocpp/views/view_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a821d193174f4b6e06db1a003aece65eb1e0db02$ +// $hash=a6a2a188d28fd07a4026ace975f42eef7853ba3c$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_VIEW_CTOCPP_H_ @@ -70,6 +70,8 @@ class CefViewCToCpp CefSize GetSize() override; void SetPosition(const CefPoint& position) override; CefPoint GetPosition() override; + void SetInsets(const CefInsets& insets) override; + CefInsets GetInsets() override; CefSize GetPreferredSize() override; void SizeToPreferredSize() override; CefSize GetMinimumSize() override; diff --git a/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc index a0351ab67..3e02377dd 100644 --- a/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7a6d2ca91509c2e6c510d5c9585a74c2fe10499b$ +// $hash=ddd89002a51c428cb66fb95990b935f214ab0090$ // #include "libcef_dll/ctocpp/views/view_delegate_ctocpp.h" @@ -189,6 +189,26 @@ void CefViewDelegateCToCpp::OnWindowChanged(CefRefPtr view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefViewDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefViewDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/view_delegate_ctocpp.h b/libcef_dll/ctocpp/views/view_delegate_ctocpp.h index c1465a6ff..fa72616ca 100644 --- a/libcef_dll/ctocpp/views/view_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/view_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=f049a053042a00be15899439f324a376ee309dbb$ +// $hash=a1888753d972c3f041c0ba24394ea032814a0d64$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_VIEW_DELEGATE_CTOCPP_H_ @@ -47,6 +47,8 @@ class CefViewDelegateCToCpp : public CefCToCppRefCounted child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/ctocpp/views/window_ctocpp.cc b/libcef_dll/ctocpp/views/window_ctocpp.cc index 6905ef769..af3361d22 100644 --- a/libcef_dll/ctocpp/views/window_ctocpp.cc +++ b/libcef_dll/ctocpp/views/window_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=6480777364c6c194652bf69ef2bb087c0805eddf$ +// $hash=e4088be2354bf7a1151044c472b2a98e8130acb7$ // #include "libcef_dll/ctocpp/views/window_ctocpp.h" @@ -23,6 +23,7 @@ #include "libcef_dll/ctocpp/views/display_ctocpp.h" #include "libcef_dll/ctocpp/views/fill_layout_ctocpp.h" #include "libcef_dll/ctocpp/views/layout_ctocpp.h" +#include "libcef_dll/ctocpp/views/overlay_controller_ctocpp.h" #include "libcef_dll/ctocpp/views/panel_ctocpp.h" #include "libcef_dll/ctocpp/views/scroll_view_ctocpp.h" #include "libcef_dll/ctocpp/views/textfield_ctocpp.h" @@ -408,6 +409,31 @@ CefRefPtr CefWindowCToCpp::GetWindowAppIcon() { return CefImageCToCpp::Wrap(_retval); } +NO_SANITIZE("cfi-icall") +CefRefPtr CefWindowCToCpp::AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode) { + shutdown_checker::AssertNotShutdown(); + + cef_window_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, add_overlay_view)) + return nullptr; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_same + DCHECK(view.get()); + if (!view.get()) + return nullptr; + + // Execute + cef_overlay_controller_t* _retval = _struct->add_overlay_view( + _struct, CefViewCToCpp::Unwrap(view), docking_mode); + + // Return type: refptr_same + return CefOverlayControllerCToCpp::Wrap(_retval); +} + NO_SANITIZE("cfi-icall") void CefWindowCToCpp::ShowMenu(CefRefPtr menu_model, const CefPoint& screen_point, @@ -1229,6 +1255,36 @@ NO_SANITIZE("cfi-icall") CefPoint CefWindowCToCpp::GetPosition() { return _retval; } +NO_SANITIZE("cfi-icall") +void CefWindowCToCpp::SetInsets(const CefInsets& insets) { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, set_insets)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + _struct->set_insets(_struct, &insets); +} + +NO_SANITIZE("cfi-icall") CefInsets CefWindowCToCpp::GetInsets() { + shutdown_checker::AssertNotShutdown(); + + cef_view_t* _struct = reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, get_insets)) + return CefInsets(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_insets_t _retval = _struct->get_insets(_struct); + + // Return type: simple + return _retval; +} + NO_SANITIZE("cfi-icall") CefSize CefWindowCToCpp::GetPreferredSize() { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/window_ctocpp.h b/libcef_dll/ctocpp/views/window_ctocpp.h index 77e4e05a7..50c707ad0 100644 --- a/libcef_dll/ctocpp/views/window_ctocpp.h +++ b/libcef_dll/ctocpp/views/window_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=f2fbf4be1755ed8793c2d471d65eddbdf4ba148b$ +// $hash=9f4b4ed83102b989f2f436e56d311b4dcb8abe54$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_CTOCPP_H_ @@ -58,6 +58,9 @@ class CefWindowCToCpp CefRefPtr GetWindowIcon() override; void SetWindowAppIcon(CefRefPtr image) override; CefRefPtr GetWindowAppIcon() override; + CefRefPtr AddOverlayView( + CefRefPtr view, + cef_docking_mode_t docking_mode) override; void ShowMenu(CefRefPtr menu_model, const CefPoint& screen_point, cef_menu_anchor_position_t anchor_position) override; @@ -121,6 +124,8 @@ class CefWindowCToCpp CefSize GetSize() override; void SetPosition(const CefPoint& position) override; CefPoint GetPosition() override; + void SetInsets(const CefInsets& insets) override; + CefInsets GetInsets() override; CefSize GetPreferredSize() override; void SizeToPreferredSize() override; CefSize GetMinimumSize() override; diff --git a/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc index 6e724157e..e30e1078e 100644 --- a/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=dda345b957ac58c71770da1cf4813ce16ea568b8$ +// $hash=1035cc694edfd110c5a64b042a6e7ca2e975003a$ // #include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h" @@ -457,6 +457,27 @@ void CefWindowDelegateCToCpp::OnWindowChanged(CefRefPtr view, _struct->on_window_changed(_struct, CefViewCppToC::Wrap(view), added); } +NO_SANITIZE("cfi-icall") +void CefWindowDelegateCToCpp::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_layout_changed)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: view; type: refptr_diff + DCHECK(view.get()); + if (!view.get()) + return; + + // Execute + _struct->on_layout_changed(_struct, CefViewCppToC::Wrap(view), &new_bounds); +} + NO_SANITIZE("cfi-icall") void CefWindowDelegateCToCpp::OnFocus(CefRefPtr view) { shutdown_checker::AssertNotShutdown(); diff --git a/libcef_dll/ctocpp/views/window_delegate_ctocpp.h b/libcef_dll/ctocpp/views/window_delegate_ctocpp.h index 5790e9a73..7ad9857bf 100644 --- a/libcef_dll/ctocpp/views/window_delegate_ctocpp.h +++ b/libcef_dll/ctocpp/views/window_delegate_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=4e5e470d6aa929b3b2d4286eb4bcdc90dba052dc$ +// $hash=8a77494e63a8e06241f675c020532ac20fbaaab0$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ @@ -66,6 +66,8 @@ class CefWindowDelegateCToCpp bool added, CefRefPtr child) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; }; diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index f2404a7ea..b224f999d 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -9,12 +9,13 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=232cd54c28334b9a3d98ebfb5a291643f0a7db62$ +// $hash=e55370b133d3c3b7e7c903557cae0cd04173ebd1$ // #include "include/capi/cef_app_capi.h" #include "include/capi/cef_crash_util_capi.h" #include "include/capi/cef_file_util_capi.h" +#include "include/capi/cef_i18n_util_capi.h" #include "include/capi/cef_origin_whitelist_capi.h" #include "include/capi/cef_parser_capi.h" #include "include/capi/cef_path_util_capi.h" @@ -29,6 +30,7 @@ #include "include/cef_app.h" #include "include/cef_crash_util.h" #include "include/cef_file_util.h" +#include "include/cef_i18n_util.h" #include "include/cef_origin_whitelist.h" #include "include/cef_parser.h" #include "include/cef_path_util.h" @@ -329,6 +331,16 @@ CEF_EXPORT void cef_load_crlsets_file(const cef_string_t* path) { CefLoadCRLSetsFile(CefString(path)); } +CEF_EXPORT int cef_is_rtl() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefIsRTL(); + + // Return type: bool + return _retval; +} + CEF_EXPORT int cef_add_cross_origin_whitelist_entry( const cef_string_t* source_origin, const cef_string_t* target_protocol, diff --git a/libcef_dll/wrapper/libcef_dll_dylib.cc b/libcef_dll/wrapper/libcef_dll_dylib.cc index 71919a9d4..dc2cbaa8f 100644 --- a/libcef_dll/wrapper/libcef_dll_dylib.cc +++ b/libcef_dll/wrapper/libcef_dll_dylib.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=01fb8dd98e44b937595c1e1f987f5e4850bff64d$ +// $hash=e3347463db785cc5e6c0aa840dedcef116a11043$ // #include @@ -23,6 +23,7 @@ #include "include/capi/cef_crash_util_capi.h" #include "include/capi/cef_drag_data_capi.h" #include "include/capi/cef_file_util_capi.h" +#include "include/capi/cef_i18n_util_capi.h" #include "include/capi/cef_image_capi.h" #include "include/capi/cef_media_router_capi.h" #include "include/capi/cef_menu_model_capi.h" @@ -115,6 +116,7 @@ typedef int (*cef_zip_directory_ptr)(const cef_string_t*, const cef_string_t*, int); typedef void (*cef_load_crlsets_file_ptr)(const cef_string_t*); +typedef int (*cef_is_rtl_ptr)(); typedef int (*cef_add_cross_origin_whitelist_entry_ptr)(const cef_string_t*, const cef_string_t*, const cef_string_t*, @@ -533,6 +535,7 @@ struct libcef_pointers { cef_delete_file_ptr cef_delete_file; cef_zip_directory_ptr cef_zip_directory; cef_load_crlsets_file_ptr cef_load_crlsets_file; + cef_is_rtl_ptr cef_is_rtl; cef_add_cross_origin_whitelist_entry_ptr cef_add_cross_origin_whitelist_entry; cef_remove_cross_origin_whitelist_entry_ptr cef_remove_cross_origin_whitelist_entry; @@ -750,6 +753,7 @@ int libcef_init_pointers(const char* path) { INIT_ENTRY(cef_delete_file); INIT_ENTRY(cef_zip_directory); INIT_ENTRY(cef_load_crlsets_file); + INIT_ENTRY(cef_is_rtl); INIT_ENTRY(cef_add_cross_origin_whitelist_entry); INIT_ENTRY(cef_remove_cross_origin_whitelist_entry); INIT_ENTRY(cef_clear_cross_origin_whitelist); @@ -1057,6 +1061,10 @@ NO_SANITIZE("cfi-icall") void cef_load_crlsets_file(const cef_string_t* path) { g_libcef_pointers.cef_load_crlsets_file(path); } +NO_SANITIZE("cfi-icall") int cef_is_rtl() { + return g_libcef_pointers.cef_is_rtl(); +} + NO_SANITIZE("cfi-icall") int cef_add_cross_origin_whitelist_entry(const cef_string_t* source_origin, const cef_string_t* target_protocol, diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index 8be481e35..44f3eef2f 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -9,12 +9,13 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=7fef7aaa85b96ed7c7fc82542cd393210e1d89ee$ +// $hash=e71ff10558002c5a09d9348d2b128facd881b869$ // #include "include/capi/cef_app_capi.h" #include "include/capi/cef_crash_util_capi.h" #include "include/capi/cef_file_util_capi.h" +#include "include/capi/cef_i18n_util_capi.h" #include "include/capi/cef_origin_whitelist_capi.h" #include "include/capi/cef_parser_capi.h" #include "include/capi/cef_path_util_capi.h" @@ -30,6 +31,7 @@ #include "include/cef_app.h" #include "include/cef_crash_util.h" #include "include/cef_file_util.h" +#include "include/cef_i18n_util.h" #include "include/cef_origin_whitelist.h" #include "include/cef_parser.h" #include "include/cef_path_util.h" @@ -309,6 +311,16 @@ CEF_GLOBAL void CefLoadCRLSetsFile(const CefString& path) { cef_load_crlsets_file(path.GetStruct()); } +NO_SANITIZE("cfi-icall") CEF_GLOBAL bool CefIsRTL() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_is_rtl(); + + // Return type: bool + return _retval ? true : false; +} + NO_SANITIZE("cfi-icall") CEF_GLOBAL bool CefAddCrossOriginWhitelistEntry(const CefString& source_origin, diff --git a/libcef_dll/wrapper_types.h b/libcef_dll/wrapper_types.h index a175a6e39..4efe7281c 100644 --- a/libcef_dll/wrapper_types.h +++ b/libcef_dll/wrapper_types.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=abd4c6d471c9ff3d7113b6125a6cfb2a26d58304$ +// $hash=e09286ac977f5f06cf356eb8a5e04b48b0836523$ // #ifndef CEF_LIBCEF_DLL_WRAPPER_TYPES_H_ @@ -90,6 +90,7 @@ enum CefWrapperType { WT_MENU_MODEL_DELEGATE, WT_NAVIGATION_ENTRY, WT_NAVIGATION_ENTRY_VISITOR, + WT_OVERLAY_CONTROLLER, WT_PANEL, WT_PANEL_DELEGATE, WT_PDF_PRINT_CALLBACK, diff --git a/patch/patches/chrome_runtime_views.patch b/patch/patches/chrome_runtime_views.patch index b35ea6dd3..6d5e87ec5 100644 --- a/patch/patches/chrome_runtime_views.patch +++ b/patch/patches/chrome_runtime_views.patch @@ -1,5 +1,5 @@ diff --git chrome/browser/ui/browser_command_controller.cc chrome/browser/ui/browser_command_controller.cc -index 9188154824c4d..d01f610a64135 100644 +index 9188154824c4..d01f610a6413 100644 --- chrome/browser/ui/browser_command_controller.cc +++ chrome/browser/ui/browser_command_controller.cc @@ -351,8 +351,10 @@ bool BrowserCommandController::ExecuteCommandWithDisposition( @@ -31,7 +31,7 @@ index 9188154824c4d..d01f610a64135 100644 void BrowserCommandController::InitCommandState() { diff --git chrome/browser/ui/views/frame/browser_frame.cc chrome/browser/ui/views/frame/browser_frame.cc -index 2c4624fb0cd05..57c087dcbaaee 100644 +index 2c4624fb0cd0..57c087dcbaae 100644 --- chrome/browser/ui/views/frame/browser_frame.cc +++ chrome/browser/ui/views/frame/browser_frame.cc @@ -69,15 +69,23 @@ bool IsUsingGtkTheme(Profile* profile) { @@ -106,7 +106,7 @@ index 2c4624fb0cd05..57c087dcbaaee 100644 // or not we always use the dark ui instance. if (base::FeatureList::IsEnabled( diff --git chrome/browser/ui/views/frame/browser_frame.h chrome/browser/ui/views/frame/browser_frame.h -index 0ce7abdeb7d9f..8197a6bb7da98 100644 +index 0ce7abdeb7d9..8197a6bb7da9 100644 --- chrome/browser/ui/views/frame/browser_frame.h +++ chrome/browser/ui/views/frame/browser_frame.h @@ -54,7 +54,9 @@ enum class TabDragKind { @@ -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 f0b0bd645a3ce..0d8475b411512 100644 +index f0b0bd645a3c..ae1449aa9986 100644 --- chrome/browser/ui/views/frame/browser_view.cc +++ chrome/browser/ui/views/frame/browser_view.cc -@@ -593,11 +593,22 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver { +@@ -274,11 +274,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. +@@ -593,11 +592,22 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver { /////////////////////////////////////////////////////////////////////////////// // BrowserView, public: @@ -147,7 +162,7 @@ index f0b0bd645a3ce..0d8475b411512 100644 SetShowIcon(::ShouldShowWindowIcon(browser_.get())); // In forced app mode, all size controls are always disabled. Otherwise, use -@@ -611,7 +622,6 @@ BrowserView::BrowserView(std::unique_ptr browser) +@@ -611,7 +621,6 @@ BrowserView::BrowserView(std::unique_ptr browser) } browser_->tab_strip_model()->AddObserver(this); @@ -155,7 +170,7 @@ index f0b0bd645a3ce..0d8475b411512 100644 // Top container holds tab strip region and toolbar and lives at the front of // the view hierarchy. -@@ -655,8 +665,15 @@ BrowserView::BrowserView(std::unique_ptr browser) +@@ -655,8 +664,15 @@ BrowserView::BrowserView(std::unique_ptr browser) contents_container->SetLayoutManager(std::make_unique( devtools_web_view_, contents_web_view_)); @@ -173,7 +188,7 @@ index f0b0bd645a3ce..0d8475b411512 100644 contents_separator_ = top_container_->AddChildView(std::make_unique()); -@@ -1440,6 +1457,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const { +@@ -1440,6 +1456,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const { if (immersive_mode_controller_->IsEnabled()) return false; @@ -182,7 +197,7 @@ index f0b0bd645a3ce..0d8475b411512 100644 return frame_->GetFrameView()->ShouldHideTopUIForFullscreen(); } -@@ -2482,7 +2501,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const { +@@ -2482,7 +2500,8 @@ BrowserView::GetNativeViewHostsForTopControlsSlide() const { } void BrowserView::ReparentTopContainerForEndOfImmersive() { @@ -192,7 +207,7 @@ index f0b0bd645a3ce..0d8475b411512 100644 top_container()->DestroyLayer(); AddChildViewAt(top_container(), 0); EnsureFocusOrder(); -@@ -2934,8 +2954,10 @@ void BrowserView::Layout() { +@@ -2934,8 +2953,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 f0b0bd645a3ce..0d8475b411512 100644 // Some of the situations when the BrowserView is laid out are: // - Enter/exit immersive fullscreen mode. -@@ -2998,6 +3020,11 @@ void BrowserView::AddedToWidget() { +@@ -2998,6 +3019,11 @@ void BrowserView::AddedToWidget() { SetThemeProfileForWindow(GetNativeWindow(), browser_->profile()); #endif @@ -217,7 +232,7 @@ index f0b0bd645a3ce..0d8475b411512 100644 toolbar_->Init(); #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) -@@ -3033,13 +3060,9 @@ void BrowserView::AddedToWidget() { +@@ -3033,13 +3059,9 @@ void BrowserView::AddedToWidget() { EnsureFocusOrder(); @@ -234,10 +249,10 @@ index f0b0bd645a3ce..0d8475b411512 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 021f04720e56..98097fd4f11f 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 18a85f436bd9..cf880936a8ed 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; @@ -278,7 +310,7 @@ index 18a85f436bd97..0d6e4c9f916e7 100644 bool toolbar_visible = delegate_->IsToolbarVisible(); int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; diff --git chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc -index 5e516ea5873ca..b9890fbe050af 100644 +index 5e516ea5873c..b9890fbe050a 100644 --- chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc @@ -587,37 +587,53 @@ gfx::Range BrowserTabStripController::ListTabsInGroup( @@ -336,7 +368,7 @@ index 5e516ea5873ca..b9890fbe050af 100644 } diff --git chrome/browser/ui/views/toolbar/toolbar_view.cc chrome/browser/ui/views/toolbar/toolbar_view.cc -index 7bc5cd3dabf7d..ea706584db609 100644 +index 7bc5cd3dabf7..ea706584db60 100644 --- chrome/browser/ui/views/toolbar/toolbar_view.cc +++ chrome/browser/ui/views/toolbar/toolbar_view.cc @@ -162,12 +162,13 @@ auto& GetViewCommandMap() { @@ -365,7 +397,7 @@ index 7bc5cd3dabf7d..ea706584db609 100644 size_animation_.Reset(1); diff --git chrome/browser/ui/views/toolbar/toolbar_view.h chrome/browser/ui/views/toolbar/toolbar_view.h -index 8346b612cfbe6..d7fc5440af829 100644 +index 8346b612cfbe..d7fc5440af82 100644 --- chrome/browser/ui/views/toolbar/toolbar_view.h +++ chrome/browser/ui/views/toolbar/toolbar_view.h @@ -90,7 +90,8 @@ class ToolbarView : public views::AccessiblePaneView, diff --git a/tests/cefclient/browser/root_window_views.cc b/tests/cefclient/browser/root_window_views.cc index d4135bc52..7cee5ebbc 100644 --- a/tests/cefclient/browser/root_window_views.cc +++ b/tests/cefclient/browser/root_window_views.cc @@ -341,7 +341,7 @@ void RootWindowViews::OnSetAddress(const std::string& url) { return; } - if (window_ && config_->with_controls) + if (window_) window_->SetAddress(url); } @@ -420,8 +420,7 @@ void RootWindowViews::OnSetLoadingState(bool isLoading, } if (window_) { - if (config_->with_controls) - window_->SetLoadingState(isLoading, canGoBack, canGoForward); + window_->SetLoadingState(isLoading, canGoBack, canGoForward); if (isLoading) { // Reset to the default window icon when loading begins. diff --git a/tests/cefclient/browser/views_menu_bar.cc b/tests/cefclient/browser/views_menu_bar.cc index 135d52680..a92d05b05 100644 --- a/tests/cefclient/browser/views_menu_bar.cc +++ b/tests/cefclient/browser/views_menu_bar.cc @@ -4,6 +4,7 @@ #include "tests/cefclient/browser/views_menu_bar.h" +#include "include/cef_i18n_util.h" #include "include/views/cef_box_layout.h" #include "include/views/cef_window.h" #include "tests/cefclient/browser/views_style.h" @@ -153,9 +154,13 @@ void ViewsMenuBar::OnMenuButtonPressed( CefRefPtr button_pressed_lock) { CefRefPtr menu_model = GetMenuModel(menu_button->GetID()); - // Adjust menu position left by button width. + // Adjust menu position to align with the button. CefPoint point = screen_point; - point.x -= menu_button->GetBounds().width - 4; + if (CefIsRTL()) { + point.x += menu_button->GetBounds().width - 4; + } else { + point.x -= menu_button->GetBounds().width - 4; + } // Keep track of the current |last_nav_with_keyboard_| status and restore it // after displaying the new menu. @@ -211,6 +216,11 @@ void ViewsMenuBar::MouseOutsideMenu(CefRefPtr menu_model, CefRefPtr button = panel_->GetViewForID(id); CefRect button_bounds = button->GetBounds(); + if (CefIsRTL()) { + // Adjust for right-to-left button layout. + button_bounds.x = + panel_bounds.width - button_bounds.x - button_bounds.width; + } if (button_bounds.Contains(window_point)) { // Trigger the hovered MenuButton. TriggerMenuButton(button); diff --git a/tests/cefclient/browser/views_overlay_controls.cc b/tests/cefclient/browser/views_overlay_controls.cc new file mode 100644 index 000000000..0945a791c --- /dev/null +++ b/tests/cefclient/browser/views_overlay_controls.cc @@ -0,0 +1,192 @@ +// Copyright (c) 2021 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 "tests/cefclient/browser/views_overlay_controls.h" + +#include + +#include "include/views/cef_box_layout.h" +#include "include/views/cef_window.h" +#include "tests/cefclient/browser/views_style.h" + +namespace client { + +namespace { + +constexpr int kInsets = 4; +constexpr int kLocationBarPadding = 100; + +// White with 80% opacity. +constexpr auto kBackgroundColor = CefColorSetARGB(255 * .80, 255, 255, 255); + +std::string GetLabel(ViewsOverlayControls::Command command, bool maximized) { + switch (command) { + case ViewsOverlayControls::Command::kMinimize: + return "-"; + case ViewsOverlayControls::Command::kMaximize: + return maximized ? "O" : "o"; + case ViewsOverlayControls::Command::kClose: + return "X"; + } +} + +} // namespace + +ViewsOverlayControls::ViewsOverlayControls() = default; + +void ViewsOverlayControls::Initialize(CefRefPtr window, + CefRefPtr menu_button, + CefRefPtr location_bar, + bool is_chrome_toolbar) { + DCHECK(!window_); + DCHECK(menu_button); + DCHECK(location_bar); + + window_ = window; + window_maximized_ = window_->IsMaximized(); + + // Window control buttons. These controls are currently text which means that + // we can't use a transparent background because subpixel text rendering will + // break. See comments on the related DCHECK in Label::PaintText. + panel_ = CefPanel::CreatePanel(nullptr); + views_style::ApplyTo(panel_); + + // Use a horizontal box layout. + CefBoxLayoutSettings panel_layout_settings; + panel_layout_settings.horizontal = true; + panel_->SetToBoxLayout(panel_layout_settings); + + panel_->AddChildView(CreateButton(ViewsOverlayControls::Command::kMinimize)); + panel_->AddChildView(CreateButton(ViewsOverlayControls::Command::kMaximize)); + panel_->AddChildView(CreateButton(ViewsOverlayControls::Command::kClose)); + + panel_controller_ = + window->AddOverlayView(panel_, CEF_DOCKING_MODE_TOP_RIGHT); + panel_controller_->SetVisible(true); + + // Menu button. + menu_button->SetBackgroundColor(kBackgroundColor); + menu_controller_ = + window_->AddOverlayView(menu_button, CEF_DOCKING_MODE_TOP_LEFT); + menu_controller_->SetInsets(CefInsets(kInsets, kInsets, 0, 0)); + menu_controller_->SetVisible(true); + + // Location bar. Will be made visible in UpdateControls(). + location_bar_ = location_bar; + is_chrome_toolbar_ = is_chrome_toolbar; + // Use a 100% transparent background for the Chrome toolbar. + location_bar_->SetBackgroundColor(is_chrome_toolbar_ ? 0 : kBackgroundColor); + location_controller_ = + window_->AddOverlayView(location_bar_, CEF_DOCKING_MODE_CUSTOM); +} + +void ViewsOverlayControls::Destroy() { + window_ = nullptr; + panel_ = nullptr; + panel_controller_->Destroy(); + panel_controller_ = nullptr; + menu_controller_->Destroy(); + menu_controller_ = nullptr; + location_bar_ = nullptr; + location_controller_->Destroy(); + location_controller_ = nullptr; +} + +void ViewsOverlayControls::UpdateControls() { + // Update location bar size, position and visibility. + auto bounds = window_->GetBounds(); + bounds.x = kLocationBarPadding; + bounds.width -= kLocationBarPadding * 2; + bounds.y = kInsets; + if (is_chrome_toolbar_) { + // Fit the standard Chrome toolbar. + const auto preferred_size = location_bar_->GetPreferredSize(); + bounds.height = + std::max(menu_controller_->GetSize().height, preferred_size.height); + } else { + bounds.height = menu_controller_->GetSize().height; + } + if (bounds.width < kLocationBarPadding * 2) { + // Not enough space. + location_controller_->SetVisible(false); + } else { + location_bar_->SetSize(CefSize(bounds.width, bounds.height)); + location_controller_->SetBounds(bounds); + location_controller_->SetVisible(true); + } + + MaybeUpdateMaximizeButton(); +} + +void ViewsOverlayControls::UpdateDraggableRegions( + std::vector& window_regions) { + if (panel_controller_ && panel_controller_->IsVisible()) { + window_regions.push_back(CefDraggableRegion(panel_controller_->GetBounds(), + /*draggable=*/false)); + } + + if (menu_controller_ && menu_controller_->IsVisible()) { + window_regions.push_back( + CefDraggableRegion(menu_controller_->GetBounds(), /*draggable=*/false)); + } + + if (location_controller_ && location_controller_->IsVisible()) { + window_regions.push_back(CefDraggableRegion( + location_controller_->GetBounds(), /*draggable=*/false)); + } +} + +void ViewsOverlayControls::OnButtonPressed(CefRefPtr button) { + auto command = static_cast(button->GetID()); + switch (command) { + case ViewsOverlayControls::Command::kMinimize: + window_->Minimize(); + break; + case ViewsOverlayControls::Command::kMaximize: + if (window_->IsMaximized()) + window_->Restore(); + else + window_->Maximize(); + break; + case ViewsOverlayControls::Command::kClose: + window_->Close(); + return; + } + + // Explicitly reset button state because the button may have moved and it + // won't receive the corresponding mouse move events. + button->SetState(CEF_BUTTON_STATE_NORMAL); + button->SetInkDropEnabled(false); + button->SetInkDropEnabled(true); + + if (command == Command::kMaximize) + MaybeUpdateMaximizeButton(); +} + +CefRefPtr ViewsOverlayControls::CreateButton(Command command) { + CefRefPtr button = CefLabelButton::CreateLabelButton( + this, GetLabel(command, window_maximized_)); + button->SetID(static_cast(command)); + views_style::ApplyTo(button); + button->SetInkDropEnabled(true); + button->SetFocusable(false); // Don't give focus to the button. + return button; +} + +void ViewsOverlayControls::MaybeUpdateMaximizeButton() { + if (window_->IsMaximized() == window_maximized_) + return; + window_maximized_ = !window_maximized_; + + auto max_button = panel_->GetChildViewAt(1); + auto command = static_cast(max_button->GetID()); + DCHECK(command == Command::kMaximize); + max_button->AsButton()->AsLabelButton()->SetText( + GetLabel(command, window_maximized_)); + + // Adjust overlay size and placement due to layout changing. + panel_controller_->SizeToPreferredSize(); +} + +} // namespace client diff --git a/tests/cefclient/browser/views_overlay_controls.h b/tests/cefclient/browser/views_overlay_controls.h new file mode 100644 index 000000000..c33ab9eb5 --- /dev/null +++ b/tests/cefclient/browser/views_overlay_controls.h @@ -0,0 +1,71 @@ +// Copyright (c) 2021 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. + +#ifndef CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_CONTROLS_H_ +#define CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_CONTROLS_H_ +#pragma once + +#include "include/views/cef_button_delegate.h" +#include "include/views/cef_label_button.h" +#include "include/views/cef_menu_button.h" +#include "include/views/cef_overlay_controller.h" +#include "include/views/cef_panel.h" + +namespace client { + +// Implements window overlay controls that receive absolute positioning on top +// of the browser view. All methods must be called on the browser process UI +// thread. +class ViewsOverlayControls : public CefButtonDelegate { + public: + enum class Command { + kMinimize = 1, + kMaximize, + kClose, + }; + + ViewsOverlayControls(); + + void Initialize(CefRefPtr window, + CefRefPtr menu_button, + CefRefPtr location_bar, + bool is_chrome_toolbar); + void Destroy(); + + // Update window control button state and location bar bounds. + void UpdateControls(); + + // Exclude all regions obscured by overlays. + void UpdateDraggableRegions(std::vector& window_regions); + + private: + // CefButtonDelegate methods: + void OnButtonPressed(CefRefPtr button) override; + + CefRefPtr CreateButton(Command command); + + void MaybeUpdateMaximizeButton(); + + CefRefPtr window_; + bool window_maximized_; + + // Window control buttons. + CefRefPtr panel_; + CefRefPtr panel_controller_; + + // Location bar. + CefRefPtr location_bar_; + bool is_chrome_toolbar_; + CefRefPtr location_controller_; + + // Menu button. + CefRefPtr menu_controller_; + + IMPLEMENT_REFCOUNTING(ViewsOverlayControls); + DISALLOW_COPY_AND_ASSIGN(ViewsOverlayControls); +}; + +} // namespace client + +#endif // CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_CONTROLS_H_ diff --git a/tests/cefclient/browser/views_style.cc b/tests/cefclient/browser/views_style.cc index 830b7ceee..eea8bf184 100644 --- a/tests/cefclient/browser/views_style.cc +++ b/tests/cefclient/browser/views_style.cc @@ -49,6 +49,13 @@ bool IsSet() { return g_background_color != 0; } +void ApplyBackgroundTo(CefRefPtr view) { + if (!IsSet()) + return; + + view->SetBackgroundColor(g_background_color); +} + void ApplyTo(CefRefPtr panel) { if (!IsSet()) return; diff --git a/tests/cefclient/browser/views_style.h b/tests/cefclient/browser/views_style.h index 0d32f2cba..f9b7c9702 100644 --- a/tests/cefclient/browser/views_style.h +++ b/tests/cefclient/browser/views_style.h @@ -19,6 +19,7 @@ namespace views_style { bool IsSet(); // Apply style to views objects. +void ApplyBackgroundTo(CefRefPtr view); void ApplyTo(CefRefPtr panel); void ApplyTo(CefRefPtr label_button); void ApplyTo(CefRefPtr textfield); diff --git a/tests/cefclient/browser/views_window.cc b/tests/cefclient/browser/views_window.cc index b948ba77c..62b4e74b5 100644 --- a/tests/cefclient/browser/views_window.cc +++ b/tests/cefclient/browser/views_window.cc @@ -9,6 +9,7 @@ #include "include/base/cef_build.h" #include "include/base/cef_callback.h" #include "include/cef_app.h" +#include "include/cef_i18n_util.h" #include "include/views/cef_box_layout.h" #include "include/wrapper/cef_helpers.h" #include "tests/cefclient/browser/main_context.h" @@ -190,12 +191,12 @@ void ViewsWindow::Close(bool force) { void ViewsWindow::SetAddress(const std::string& url) { CEF_REQUIRE_UI_THREAD(); - if (!window_ || !with_controls_) + if (!window_) return; - CefRefPtr view = window_->GetViewForID(ID_URL_TEXTFIELD); - if (view && view->AsTextfield()) - view->AsTextfield()->SetText(url); + // |location_bar_| may instead be a Chrome toolbar. + if (location_bar_ && location_bar_->AsTextfield()) + location_bar_->AsTextfield()->SetText(url); } void ViewsWindow::SetTitle(const std::string& title) { @@ -236,14 +237,18 @@ void ViewsWindow::SetLoadingState(bool isLoading, bool canGoBack, bool canGoForward) { CEF_REQUIRE_UI_THREAD(); - if (!window_ || !with_controls_ || chrome_toolbar_type_ == CEF_CTT_NORMAL) + if (!window_ || chrome_toolbar_type_ == CEF_CTT_NORMAL) return; - EnableView(ID_BACK_BUTTON, canGoBack); - EnableView(ID_FORWARD_BUTTON, canGoForward); - EnableView(ID_RELOAD_BUTTON, !isLoading); - EnableView(ID_STOP_BUTTON, isLoading); - EnableView(ID_URL_TEXTFIELD, true); + if (with_controls_) { + EnableView(ID_BACK_BUTTON, canGoBack); + EnableView(ID_FORWARD_BUTTON, canGoForward); + EnableView(ID_RELOAD_BUTTON, !isLoading); + EnableView(ID_STOP_BUTTON, isLoading); + } + if (location_bar_) { + EnableView(ID_URL_TEXTFIELD, true); + } } void ViewsWindow::SetDraggableRegions( @@ -266,20 +271,25 @@ void ViewsWindow::SetDraggableRegions( window_regions.push_back(region); } + if (overlay_controls_) { + // Exclude all regions obscured by overlays. + overlay_controls_->UpdateDraggableRegions(window_regions); + } + window_->SetDraggableRegions(window_regions); } void ViewsWindow::TakeFocus(bool next) { CEF_REQUIRE_UI_THREAD(); - if (!window_ || !with_controls_) + if (!window_) return; if (chrome_toolbar_type_ == CEF_CTT_NORMAL) { top_toolbar_->RequestFocus(); - } else { - // Give focus to the URL textfield. - location_->RequestFocus(); + } else if (location_bar_) { + // Give focus to the location bar. + location_bar_->RequestFocus(); } } @@ -427,18 +437,30 @@ void ViewsWindow::OnMenuButtonPressed( return; } - DCHECK(with_controls_); + DCHECK(with_controls_ || with_overlay_controls_); DCHECK_EQ(ID_MENU_BUTTON, id); - menu_button->ShowMenu(button_menu_model_, screen_point, - CEF_MENU_ANCHOR_TOPRIGHT); + auto point = screen_point; + if (with_overlay_controls_) { + // Align the menu correctly under the button. + const int button_width = menu_button->GetSize().width; + if (CefIsRTL()) { + point.x += button_width - 4; + } else { + point.x -= button_width - 4; + } + } + + menu_button->ShowMenu(button_menu_model_, point, + with_overlay_controls_ ? CEF_MENU_ANCHOR_TOPLEFT + : CEF_MENU_ANCHOR_TOPRIGHT); } void ViewsWindow::ExecuteCommand(CefRefPtr menu_model, int command_id, cef_event_flags_t event_flags) { CEF_REQUIRE_UI_THREAD(); - DCHECK(with_controls_); + DCHECK(with_controls_ || with_overlay_controls_); if (command_id == ID_QUIT) { delegate_->OnExit(); @@ -452,7 +474,6 @@ void ViewsWindow::ExecuteCommand(CefRefPtr menu_model, bool ViewsWindow::OnKeyEvent(CefRefPtr textfield, const CefKeyEvent& event) { CEF_REQUIRE_UI_THREAD(); - DCHECK(with_controls_); DCHECK_EQ(ID_URL_TEXTFIELD, textfield->GetID()); // Trigger when the return key is pressed. @@ -460,12 +481,9 @@ bool ViewsWindow::OnKeyEvent(CefRefPtr textfield, event.windows_key_code == VK_RETURN) { CefRefPtr browser = browser_view_->GetBrowser(); if (browser) { - CefRefPtr view = window_->GetViewForID(ID_URL_TEXTFIELD); - if (view && view->AsTextfield()) { - const CefString& url = view->AsTextfield()->GetText(); - if (!url.empty()) - browser->GetMainFrame()->LoadURL(url); - } + const CefString& url = textfield->GetText(); + if (!url.empty()) + browser->GetMainFrame()->LoadURL(url); } // We handled the event. @@ -500,9 +518,14 @@ void ViewsWindow::OnWindowCreated(CefRefPtr window) { // Set the background color for regions that are not obscured by other Views. views_style::ApplyTo(window_.get()); + if (with_controls_ || with_overlay_controls_) { + // Create the MenuModel that will be displayed via the menu button. + CreateMenuModel(); + } + if (with_controls_) { // Add the BrowserView and other controls to the Window. - AddControls(); + AddBrowserView(); // Add keyboard accelerators to the Window. AddAccelerators(); @@ -535,6 +558,7 @@ void ViewsWindow::OnWindowDestroyed(CefRefPtr window) { top_menu_bar_ = nullptr; } extensions_panel_ = nullptr; + menu_button_ = nullptr; window_ = nullptr; } @@ -681,117 +705,41 @@ void ViewsWindow::OnBlur(CefRefPtr view) { } void ViewsWindow::OnWindowChanged(CefRefPtr view, bool added) { - if (!with_controls_ || !added) - return; - const int view_id = view->GetID(); if (view_id != ID_BROWSER_VIEW) return; - // Build the remainder of the UI now that the BrowserView has been added to - // the CefWindow. This is a requirement to use Chrome toolbars. - - CefRefPtr top_menu_panel; - if (top_menu_bar_) - top_menu_panel = top_menu_bar_->GetMenuPanel(); - - LabelButtons browse_buttons; - CefRefPtr menu_button; - - if (chrome_toolbar_type_ == CEF_CTT_NORMAL) { - // Chrome will provide a normal toolbar with location, menu, etc. - top_toolbar_ = browser_view_->GetChromeToolbar(); - DCHECK(top_toolbar_); - } - - if (!top_toolbar_) { - // Create the browse buttons. - browse_buttons.push_back(CreateBrowseButton("Back", ID_BACK_BUTTON)); - browse_buttons.push_back(CreateBrowseButton("Forward", ID_FORWARD_BUTTON)); - browse_buttons.push_back(CreateBrowseButton("Reload", ID_RELOAD_BUTTON)); - browse_buttons.push_back(CreateBrowseButton("Stop", ID_STOP_BUTTON)); - - if (chrome_toolbar_type_ == CEF_CTT_LOCATION) { - // Chrome will provide a minimal location bar. - location_ = browser_view_->GetChromeToolbar(); - DCHECK(location_); - } - if (!location_) { - // Create the URL textfield. - CefRefPtr url_textfield = - CefTextfield::CreateTextfield(this); - url_textfield->SetID(ID_URL_TEXTFIELD); - url_textfield->SetEnabled(false); // Disabled by default. - views_style::ApplyTo(url_textfield); - location_ = url_textfield; + if (added) { + if (with_controls_) { + AddControls(); } - // Create the menu button. - menu_button = CefMenuButton::CreateMenuButton(this, CefString()); - menu_button->SetID(ID_MENU_BUTTON); - menu_button->SetImage( - CEF_BUTTON_STATE_NORMAL, - delegate_->GetImageCache()->GetCachedImage("menu_icon")); - views_style::ApplyTo(menu_button.get()); - menu_button->SetInkDropEnabled(true); - // Override the default minimum size. - menu_button->SetMinimumSize(CefSize(0, 0)); - - // Create the top panel. - CefRefPtr top_panel = CefPanel::CreatePanel(nullptr); - - // Use a horizontal box layout for |top_panel|. - CefBoxLayoutSettings top_panel_layout_settings; - top_panel_layout_settings.horizontal = true; - CefRefPtr top_panel_layout = - top_panel->SetToBoxLayout(top_panel_layout_settings); - - // Add the buttons and URL textfield to |top_panel|. - for (size_t i = 0U; i < browse_buttons.size(); ++i) - top_panel->AddChildView(browse_buttons[i]); - top_panel->AddChildView(location_); - - UpdateExtensionControls(); - DCHECK(extensions_panel_); - top_panel->AddChildView(extensions_panel_); - - top_panel->AddChildView(menu_button); - views_style::ApplyTo(top_panel); - - // Allow |location| to grow and fill any remaining space. - top_panel_layout->SetFlexForView(location_, 1); - - top_toolbar_ = top_panel; + if (with_overlay_controls_) { + overlay_controls_ = new ViewsOverlayControls(); + overlay_controls_->Initialize(window_, CreateMenuButton(), + CreateLocationBar(), + chrome_toolbar_type_ != CEF_CTT_NONE); + } + } else { + if (overlay_controls_) { + // Overlay controls may include the Chrome toolbar, in which case they + // need to be removed before the BrowserView. + overlay_controls_->Destroy(); + overlay_controls_ = nullptr; + location_bar_ = nullptr; + } } +} - // Add the top panel and browser view to |window|. - int top_index = 0; - if (top_menu_panel) - window_->AddChildViewAt(top_menu_panel, top_index++); - window_->AddChildViewAt(top_toolbar_, top_index); +void ViewsWindow::OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) { + const int view_id = view->GetID(); + if (view_id != ID_BROWSER_VIEW) + return; - // Lay out |window| so we can get the default button sizes. - window_->Layout(); - - int min_width = 200; - if (!browse_buttons.empty()) { - // Make all browse buttons the same size. - MakeButtonsSameSize(browse_buttons); - - // Lay out |window| again with the new button sizes. - window_->Layout(); - - // Minimum window width is the size of all buttons plus some extra. - min_width = browse_buttons[0]->GetBounds().width * 4 + - menu_button->GetBounds().width + 100; + if (overlay_controls_) { + overlay_controls_->UpdateControls(); } - - // Minimum window height is the hight of the top toolbar plus some extra. - int min_height = top_toolbar_->GetBounds().height + 100; - if (top_menu_panel) - min_height += top_menu_panel->GetBounds().height; - - minimum_window_size_ = CefSize(min_width, min_height); } void ViewsWindow::MenuBarExecuteCommand(CefRefPtr menu_model, @@ -812,8 +760,16 @@ ViewsWindow::ViewsWindow(Delegate* delegate, CefRefPtr command_line = CefCommandLine::GetGlobalCommandLine(); - frameless_ = command_line->HasSwitch(switches::kHideFrame) || - delegate_->WithExtension(); + + const bool hide_frame = command_line->HasSwitch(switches::kHideFrame); + const bool hide_overlays = command_line->HasSwitch(switches::kHideOverlays); + + // Without a window frame. + frameless_ = hide_frame || delegate_->WithExtension(); + + // With an overlay that mimics window controls. + with_overlay_controls_ = + hide_frame && !hide_overlays && !delegate_->WithControls(); if (MainContext::Get()->UseChromeRuntime()) { const std::string& toolbar_type = @@ -823,7 +779,8 @@ ViewsWindow::ViewsWindow(Delegate* delegate, } else if (toolbar_type == "location") { chrome_toolbar_type_ = CEF_CTT_LOCATION; } else { - chrome_toolbar_type_ = CEF_CTT_NORMAL; + chrome_toolbar_type_ = + with_overlay_controls_ ? CEF_CTT_LOCATION : CEF_CTT_NORMAL; } } else { chrome_toolbar_type_ = CEF_CTT_NONE; @@ -869,16 +826,49 @@ CefRefPtr ViewsWindow::CreateBrowseButton( CefRefPtr button = CefLabelButton::CreateLabelButton(this, label); button->SetID(id); + views_style::ApplyTo(button.get()); + button->SetInkDropEnabled(true); button->SetEnabled(false); // Disabled by default. button->SetFocusable(false); // Don't give focus to the button. return button; } -void ViewsWindow::AddControls() { - // Create the MenuModel that will be displayed via the menu button. - CreateMenuModel(); +CefRefPtr ViewsWindow::CreateMenuButton() { + // Create the menu button. + DCHECK(!menu_button_); + menu_button_ = CefMenuButton::CreateMenuButton(this, CefString()); + menu_button_->SetID(ID_MENU_BUTTON); + menu_button_->SetImage( + CEF_BUTTON_STATE_NORMAL, + delegate_->GetImageCache()->GetCachedImage("menu_icon")); + views_style::ApplyTo(menu_button_.get()); + menu_button_->SetInkDropEnabled(true); + // Override the default minimum size. + menu_button_->SetMinimumSize(CefSize(0, 0)); + return menu_button_; +} +CefRefPtr ViewsWindow::CreateLocationBar() { + DCHECK(!location_bar_); + if (chrome_toolbar_type_ == CEF_CTT_LOCATION) { + // Chrome will provide a minimal location bar. + location_bar_ = browser_view_->GetChromeToolbar(); + DCHECK(location_bar_); + views_style::ApplyBackgroundTo(location_bar_); + } + if (!location_bar_) { + // Create the URL textfield. + CefRefPtr url_textfield = CefTextfield::CreateTextfield(this); + url_textfield->SetID(ID_URL_TEXTFIELD); + url_textfield->SetEnabled(false); // Disabled by default. + views_style::ApplyTo(url_textfield); + location_bar_ = url_textfield; + } + return location_bar_; +} + +void ViewsWindow::AddBrowserView() { // Use a vertical box layout for |window|. CefBoxLayoutSettings window_layout_settings; window_layout_settings.horizontal = false; @@ -896,6 +886,89 @@ void ViewsWindow::AddControls() { // only available after the BrowserView is added. } +void ViewsWindow::AddControls() { + // Build the remainder of the UI now that the BrowserView has been added to + // the CefWindow. This is a requirement to use Chrome toolbars. + + CefRefPtr top_menu_panel; + if (top_menu_bar_) + top_menu_panel = top_menu_bar_->GetMenuPanel(); + + LabelButtons browse_buttons; + + if (chrome_toolbar_type_ == CEF_CTT_NORMAL) { + // Chrome will provide a normal toolbar with location, menu, etc. + top_toolbar_ = browser_view_->GetChromeToolbar(); + DCHECK(top_toolbar_); + } + + if (!top_toolbar_) { + // Create the browse buttons. + browse_buttons.push_back(CreateBrowseButton("Back", ID_BACK_BUTTON)); + browse_buttons.push_back(CreateBrowseButton("Forward", ID_FORWARD_BUTTON)); + browse_buttons.push_back(CreateBrowseButton("Reload", ID_RELOAD_BUTTON)); + browse_buttons.push_back(CreateBrowseButton("Stop", ID_STOP_BUTTON)); + + CreateLocationBar(); + CreateMenuButton(); + + // Create the top panel. + CefRefPtr top_panel = CefPanel::CreatePanel(nullptr); + + // Use a horizontal box layout for |top_panel|. + CefBoxLayoutSettings top_panel_layout_settings; + top_panel_layout_settings.horizontal = true; + CefRefPtr top_panel_layout = + top_panel->SetToBoxLayout(top_panel_layout_settings); + + // Add the buttons and URL textfield to |top_panel|. + for (size_t i = 0U; i < browse_buttons.size(); ++i) + top_panel->AddChildView(browse_buttons[i]); + top_panel->AddChildView(location_bar_); + + UpdateExtensionControls(); + DCHECK(extensions_panel_); + top_panel->AddChildView(extensions_panel_); + + top_panel->AddChildView(menu_button_); + views_style::ApplyTo(top_panel); + + // Allow |location| to grow and fill any remaining space. + top_panel_layout->SetFlexForView(location_bar_, 1); + + top_toolbar_ = top_panel; + } + + // Add the top panel and browser view to |window|. + int top_index = 0; + if (top_menu_panel) + window_->AddChildViewAt(top_menu_panel, top_index++); + window_->AddChildViewAt(top_toolbar_, top_index); + + // Lay out |window| so we can get the default button sizes. + window_->Layout(); + + int min_width = 200; + if (!browse_buttons.empty()) { + // Make all browse buttons the same size. + MakeButtonsSameSize(browse_buttons); + + // Lay out |window| again with the new button sizes. + window_->Layout(); + + // Minimum window width is the size of all buttons plus some extra. + min_width = browse_buttons[0]->GetBounds().width * 4 + + menu_button_->GetBounds().width + 100; + } + + // Minimum window height is the hight of the top toolbar plus some extra. + int min_height = top_toolbar_->GetBounds().height + 100; + if (top_menu_panel) + min_height += top_menu_panel->GetBounds().height; + + minimum_window_size_ = CefSize(min_width, min_height); +} + void ViewsWindow::AddAccelerators() { // Trigger accelerators without first forwarding to web content. browser_view_->SetPreferAccelerators(true); @@ -926,7 +999,10 @@ void ViewsWindow::SetMenuFocusable(bool focusable) { void ViewsWindow::EnableView(int id, bool enable) { if (!window_) return; - CefRefPtr view = window_->GetViewForID(id); + // Special handling for |location_bar_| which may be an overlay (e.g. not a + // child of this view). + CefRefPtr view = + id == ID_URL_TEXTFIELD ? location_bar_ : window_->GetViewForID(id); if (view) view->SetEnabled(enable); } diff --git a/tests/cefclient/browser/views_window.h b/tests/cefclient/browser/views_window.h index a8490f4e6..3ca8fb5af 100644 --- a/tests/cefclient/browser/views_window.h +++ b/tests/cefclient/browser/views_window.h @@ -18,12 +18,14 @@ #include "include/views/cef_label_button.h" #include "include/views/cef_menu_button.h" #include "include/views/cef_menu_button_delegate.h" +#include "include/views/cef_overlay_controller.h" #include "include/views/cef_textfield.h" #include "include/views/cef_textfield_delegate.h" #include "include/views/cef_window.h" #include "include/views/cef_window_delegate.h" #include "tests/cefclient/browser/image_cache.h" #include "tests/cefclient/browser/views_menu_bar.h" +#include "tests/cefclient/browser/views_overlay_controls.h" namespace client { @@ -167,6 +169,8 @@ class ViewsWindow : public CefBrowserViewDelegate, void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; void OnWindowChanged(CefRefPtr view, bool added) override; + void OnLayoutChanged(CefRefPtr view, + const CefRect& new_bounds) override; // ViewsMenuBar::Delegate methods: void MenuBarExecuteCommand(CefRefPtr menu_model, @@ -185,8 +189,13 @@ class ViewsWindow : public CefBrowserViewDelegate, void CreateMenuModel(); CefRefPtr CreateBrowseButton(const std::string& label, int id); + CefRefPtr CreateMenuButton(); + CefRefPtr CreateLocationBar(); - // Add controls to the Window. + // Add the BrowserView to the Window. + void AddBrowserView(); + + // Add other controls to the Window. void AddControls(); // Add keyboard accelerators to the Window. @@ -214,18 +223,22 @@ class ViewsWindow : public CefBrowserViewDelegate, CefRefPtr browser_view_; bool frameless_; bool with_controls_; + bool with_overlay_controls_; ChromeToolbarType chrome_toolbar_type_; CefRefPtr window_; CefRefPtr button_menu_model_; CefRefPtr top_menu_bar_; CefRefPtr top_toolbar_; - CefRefPtr location_; + CefRefPtr menu_button_; + CefRefPtr location_bar_; bool menu_has_focus_; int last_focused_view_; CefSize minimum_window_size_; + CefRefPtr overlay_controls_; + // Structure representing an extension. struct ExtensionInfo { ExtensionInfo(CefRefPtr extension, CefRefPtr image) diff --git a/tests/cefclient/resources/draggable.html b/tests/cefclient/resources/draggable.html index 6b1ecf060..354ed57a6 100644 --- a/tests/cefclient/resources/draggable.html +++ b/tests/cefclient/resources/draggable.html @@ -2,6 +2,24 @@ Draggable Regions Test - + +
+
Draggable regions can be defined using the -webkit-app-region CSS property.
In the below example the red region is draggable and the blue sub-region is non-draggable.
Windows can be resized by default and closed using JavaScript window.close(). +
diff --git a/tests/shared/common/client_switches.cc b/tests/shared/common/client_switches.cc index 61d9320a9..d85fa6b00 100644 --- a/tests/shared/common/client_switches.cc +++ b/tests/shared/common/client_switches.cc @@ -37,6 +37,7 @@ const char kFilterURL[] = "filter-url"; const char kUseViews[] = "use-views"; const char kHideFrame[] = "hide-frame"; const char kHideControls[] = "hide-controls"; +const char kHideOverlays[] = "hide-overlays"; const char kAlwaysOnTop[] = "always-on-top"; const char kHideTopMenu[] = "hide-top-menu"; const char kSslClientCertificate[] = "ssl-client-certificate"; diff --git a/tests/shared/common/client_switches.h b/tests/shared/common/client_switches.h index 1ab303309..73918d3b6 100644 --- a/tests/shared/common/client_switches.h +++ b/tests/shared/common/client_switches.h @@ -31,6 +31,7 @@ extern const char kFilterURL[]; extern const char kUseViews[]; extern const char kHideFrame[]; extern const char kHideControls[]; +extern const char kHideOverlays[]; extern const char kAlwaysOnTop[]; extern const char kHideTopMenu[]; extern const char kSslClientCertificate[]; diff --git a/tools/cef_parser.py b/tools/cef_parser.py index dd80aedff..d624358ad 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -398,6 +398,7 @@ _simpletypes = { ], 'CefEventHandle': ['cef_event_handle_t', 'kNullEventHandle'], 'CefWindowHandle': ['cef_window_handle_t', 'kNullWindowHandle'], + 'CefInsets': ['cef_insets_t', 'CefInsets()'], 'CefPoint': ['cef_point_t', 'CefPoint()'], 'CefRect': ['cef_rect_t', 'CefRect()'], 'CefSize': ['cef_size_t', 'CefSize()'],