diff --git a/include/capi/views/cef_view_capi.h b/include/capi/views/cef_view_capi.h index 58ab06c30..c8c1c537c 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=48df6ccac2c68f32c7024ae68c8a6b6a5f8ed914$ +// $hash=0ea5c2c5c1a8e8349f199a46642631be0c1bfb6b$ // #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_CAPI_H_ @@ -338,13 +338,16 @@ typedef struct _cef_view_t { void(CEF_CALLBACK* request_focus)(struct _cef_view_t* self); /// - /// Sets the background color for this View. + /// Sets the background color for this View. The background color will be + /// automatically reset if the current theme changes. See + /// cef_view_delegate_t::OnThemeChanged for related documentation. /// void(CEF_CALLBACK* set_background_color)(struct _cef_view_t* self, cef_color_t color); /// - /// Returns the background color for this View. + /// Returns the background color for this View. If the background color has + /// not been explicitly set then the current theme color will be returned. /// cef_color_t(CEF_CALLBACK* get_background_color)(struct _cef_view_t* self); diff --git a/include/capi/views/cef_view_delegate_capi.h b/include/capi/views/cef_view_delegate_capi.h index d12344b47..6fb6c6512 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=4e421d2d1e24df6e58f7a7c0c074056bc5284df4$ +// $hash=d3624baa94bb722c48880b4319f5d5e8035eaa46$ // #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_VIEW_DELEGATE_CAPI_H_ @@ -140,6 +140,17 @@ typedef struct _cef_view_delegate_t { /// void(CEF_CALLBACK* on_blur)(struct _cef_view_delegate_t* self, struct _cef_view_t* view); + + /// + /// Called when the theme for |view| has changed, after the new theme colors + /// have already been applied. This will be called at least one time when + /// |view| is added to a parent View. Further theme changes can be disabled by + /// passing the `--force-dark-mode` or `--force-light-mode` command-line flag. + /// Optionally use this callback to override the new theme colors by calling + /// the appropriate cef_view_t functions (SetBackgroundColor, etc). + /// + void(CEF_CALLBACK* on_theme_changed)(struct _cef_view_delegate_t* self, + struct _cef_view_t* view); } cef_view_delegate_t; #ifdef __cplusplus diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 8cce853ba..45e290ccb 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 "a419379d63087c1c3fb8a8215c066882fd4fce03" +#define CEF_API_HASH_UNIVERSAL "a741045ff32b6feeaedf4e767ee0a18ed1c68007" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "04f4a1140954f4b11e6fef271d39908ecff07b86" +#define CEF_API_HASH_PLATFORM "1180df9630b71b08a4c4874aa66484c3ca391327" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "d0143d677ea9945ed5e0c3624afdb444796661ee" +#define CEF_API_HASH_PLATFORM "eaed012692fa480863cb78189e21ddf738fb8d5d" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "cac5605286f35bf76576098a0da810a9a34b418a" +#define CEF_API_HASH_PLATFORM "e17a9dca9ce61905920a734e71333729578da10e" #endif #ifdef __cplusplus diff --git a/include/views/cef_view.h b/include/views/cef_view.h index 9bfd1f47b..cd4a4dd71 100644 --- a/include/views/cef_view.h +++ b/include/views/cef_view.h @@ -357,13 +357,16 @@ class CefView : public CefBaseRefCounted { virtual void RequestFocus() = 0; /// - /// Sets the background color for this View. + /// Sets the background color for this View. The background color will be + /// automatically reset if the current theme changes. See + /// CefViewDelegate::OnThemeChanged for related documentation. /// /*--cef()--*/ virtual void SetBackgroundColor(cef_color_t color) = 0; /// - /// Returns the background color for this View. + /// Returns the background color for this View. If the background color has + /// not been explicitly set then the current theme color will be returned. /// /*--cef()--*/ virtual cef_color_t GetBackgroundColor() = 0; diff --git a/include/views/cef_view_delegate.h b/include/views/cef_view_delegate.h index 23878323e..13908c344 100644 --- a/include/views/cef_view_delegate.h +++ b/include/views/cef_view_delegate.h @@ -131,6 +131,17 @@ class CefViewDelegate : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void OnBlur(CefRefPtr view) {} + + /// + /// Called when the theme for |view| has changed, after the new theme colors + /// have already been applied. This will be called at least one time when + /// |view| is added to a parent View. Further theme changes can be disabled by + /// passing the `--force-dark-mode` or `--force-light-mode` command-line flag. + /// Optionally use this callback to override the new theme colors by calling + /// the appropriate CefView methods (SetBackgroundColor, etc). + /// + /*--cef()--*/ + virtual void OnThemeChanged(CefRefPtr view) {} }; #endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_ diff --git a/libcef/browser/alloy/alloy_browser_main.cc b/libcef/browser/alloy/alloy_browser_main.cc index 18b20dd91..5992cdde2 100644 --- a/libcef/browser/alloy/alloy_browser_main.cc +++ b/libcef/browser/alloy/alloy_browser_main.cc @@ -37,6 +37,7 @@ #include "chrome/browser/ui/ui_features.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "components/color/color_mixers.h" #include "components/constrained_window/constrained_window_views.h" #include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/network_service_instance.h" @@ -246,6 +247,8 @@ void AlloyBrowserMainParts::ToolkitInitialized() { // On GTK that builds the native theme that, in turn, adds the GTK core color // mixer; core mixers should all be added before we add chrome mixers. + ui::ColorProviderManager::Get().AppendColorProviderInitializer( + base::BindRepeating(color::AddComponentsColorMixers)); ui::ColorProviderManager::Get().AppendColorProviderInitializer( base::BindRepeating(AddChromeColorMixers)); } diff --git a/libcef/browser/views/button_impl.h b/libcef/browser/views/button_impl.h index 247b11be6..7a4c3385c 100644 --- a/libcef/browser/views/button_impl.h +++ b/libcef/browser/views/button_impl.h @@ -85,7 +85,7 @@ CEF_BUTTON_IMPL_T void CEF_BUTTON_IMPL_D::SetInkDropEnabled(bool enabled) { if (enabled) { views::InkDrop::Get(ParentClass::root_view()) ->SetBaseColor(color_utils::BlendTowardMaxContrast( - ParentClass::root_view()->background()->get_color(), 0x61)); + ParentClass::GetBackgroundColor(), 0x61)); } } diff --git a/libcef/browser/views/overlay_view_host.cc b/libcef/browser/views/overlay_view_host.cc index acbb93e7c..080d0ac5f 100644 --- a/libcef/browser/views/overlay_view_host.cc +++ b/libcef/browser/views/overlay_view_host.cc @@ -193,8 +193,6 @@ void CefOverlayViewHost::Init(views::View* host_view, : 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); @@ -213,6 +211,11 @@ void CefOverlayViewHost::Init(views::View* host_view, } } + // Call AddChildView after the Widget properties have been configured. + // Notifications resulting from this call may attempt to access those + // properties (OnThemeChanged calling GetHostView, for example). + view_ = widget_->GetContentsView()->AddChildView(std::move(controls_view)); + // Set the initial bounds after the View has been added to the Widget. // Otherwise, preferred size won't calculate correctly. gfx::Rect bounds; diff --git a/libcef/browser/views/view_impl.h b/libcef/browser/views/view_impl.h index d9e105d85..2162bca57 100644 --- a/libcef/browser/views/view_impl.h +++ b/libcef/browser/views/view_impl.h @@ -675,12 +675,15 @@ CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::RequestFocus() { CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetBackgroundColor(cef_color_t color) { CEF_REQUIRE_VALID_RETURN_VOID(); - content_view()->SetBackground(views::CreateSolidBackground(color)); + root_view()->SetBackground(views::CreateSolidBackground(color)); } CEF_VIEW_IMPL_T cef_color_t CEF_VIEW_IMPL_D::GetBackgroundColor() { CEF_REQUIRE_VALID_RETURN(0U); - return content_view()->background()->get_color(); + if (root_view()->background()) { + return root_view()->background()->get_color(); + } + return view_util::GetColor(root_view(), ui::kColorPrimaryBackground); } CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToScreen(CefPoint& point) { diff --git a/libcef/browser/views/view_util.cc b/libcef/browser/views/view_util.cc index 13f42ac90..b7c5c1482 100644 --- a/libcef/browser/views/view_util.cc +++ b/libcef/browser/views/view_util.cc @@ -8,10 +8,13 @@ #include "libcef/browser/views/view_adapter.h" +#include "ui/color/color_provider.h" +#include "ui/color/color_provider_manager.h" #include "ui/display/display.h" #include "ui/display/screen.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point_conversions.h" +#include "ui/native_theme/native_theme.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #include "ui/views/window/non_client_view.h" @@ -118,9 +121,24 @@ class UserData : public base::SupportsUserData::Data { CefView* view_ref_; }; +// Based on Widget::GetNativeTheme. +const ui::NativeTheme* GetDefaultNativeTheme() { + return ui::NativeTheme::GetInstanceForNativeUi(); +} + +// Based on Widget::GetColorProviderKey. +ui::ColorProviderKey GetDefaultColorProviderKey() { + return GetDefaultNativeTheme()->GetColorProviderKey(/*custom_theme=*/nullptr); +} + +// Based on Widget::GetColorProvider. +ui::ColorProvider* GetDefaultColorProvider() { + return ui::ColorProviderManager::Get().GetColorProviderFor( + GetDefaultColorProviderKey()); +} + } // namespace -const SkColor kDefaultBackgroundColor = SkColorSetARGB(255, 255, 255, 255); const char kDefaultFontList[] = "Arial, Helvetica, 14px"; void Register(CefRefPtr view) { @@ -323,4 +341,14 @@ bool ConvertPointFromWindow(views::View* view, gfx::Point* point) { return true; } +SkColor GetColor(views::View* view, ui::ColorId id) { + // |color_provider| will be nullptr if |view| has not yet been added to a + // Widget. + if (auto color_provider = view->GetColorProvider()) { + return color_provider->GetColor(id); + } + + return GetDefaultColorProvider()->GetColor(id); +} + } // namespace view_util diff --git a/libcef/browser/views/view_util.h b/libcef/browser/views/view_util.h index a5fb6e522..e08e6f79d 100644 --- a/libcef/browser/views/view_util.h +++ b/libcef/browser/views/view_util.h @@ -9,6 +9,7 @@ #include "include/views/cef_view.h" #include "include/views/cef_window.h" +#include "ui/color/color_id.h" #include "ui/gfx/native_widget_types.h" #include "ui/views/view.h" @@ -45,7 +46,6 @@ class CefWindowDelegate; namespace view_util { // Default values. -extern const SkColor kDefaultBackgroundColor; extern const char kDefaultFontList[]; // Called when a CefView is initialized to create the initial association @@ -165,6 +165,11 @@ views::View* GetHostView(views::Widget* widget); float GetNSWindowTitleBarHeight(views::Widget* widget); #endif +// Returns the mixer color for |id|. If |view| has been added to a Widget it +// will use the Widget's ColorProvider, otherwise it will use the default theme +// ColorProvider. Returns gfx::kPlaceholderColor if |id| cannot be constructed. +SkColor GetColor(views::View* view, ui::ColorId id); + } // namespace view_util #endif // CEF_LIBCEF_BROWSER_VIEWS_VIEW_UTIL_H_ diff --git a/libcef/browser/views/view_view.h b/libcef/browser/views/view_view.h index 263ee3b96..6a07e2582 100644 --- a/libcef/browser/views/view_view.h +++ b/libcef/browser/views/view_view.h @@ -44,10 +44,6 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass { // CefViewImpl registration has completed so it is safe to call complex // views::View-derived methods here. virtual void Initialize() { - // Use our defaults instead of the Views framework defaults. - ParentClass::SetBackground( - views::CreateSolidBackground(view_util::kDefaultBackgroundColor)); - // TODO(crbug.com/1218186): Remove this, if this view is focusable then it // needs to add a name so that the screen reader knows what to announce. ParentClass::SetProperty(views::kSkipAccessibilityPaintChecks, true); @@ -80,6 +76,7 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass { void RemovedFromWidget() override; void OnFocus() override; void OnBlur() override; + void OnThemeChanged() override; // Return true if this View is expected to have a minimum size (for example, // a button where the minimum size is based on the label). @@ -214,6 +211,35 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnBlur() { ParentClass::OnBlur(); } +CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnThemeChanged() { + // Clear the background, if set. + if (ParentClass::background()) { + ParentClass::SetBackground(nullptr); + } + + // Apply default theme colors. + ParentClass::OnThemeChanged(); + + // Allow the client to override the default colors. + if (cef_delegate()) { + cef_delegate()->OnThemeChanged(GetCefView()); + } + + // If the background is still unset, and the containing Widget is not an + // overlay (which has transparent background), then set the background based + // on the current theme. + if (!ParentClass::background()) { + const bool is_overlay_hosted = + ParentClass::GetWidget() && + view_util::GetHostView(ParentClass::GetWidget()) != nullptr; + if (!is_overlay_hosted) { + const SkColor color = + view_util::GetColor(this, ui::kColorPrimaryBackground); + ParentClass::SetBackground(views::CreateSolidBackground(color)); + } + } +} + CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyChildViewChanged( const views::ViewHierarchyChangedDetails& details) { if (!cef_delegate()) { diff --git a/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.cc index e7956f7b8..728ae26ea 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=5e87111d30f695b234fe6e0fee539e8e15453c66$ +// $hash=c8365b492a81de537ee4d337ca18dae8b3f20e0d$ // #include "libcef_dll/cpptoc/views/browser_view_delegate_cpptoc.h" @@ -513,6 +513,29 @@ browser_view_delegate_on_blur(struct _cef_view_delegate_t* self, ->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +browser_view_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefBrowserViewDelegateCppToC::Get( + reinterpret_cast(self)) + ->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -544,6 +567,7 @@ CefBrowserViewDelegateCppToC::CefBrowserViewDelegateCppToC() { 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; + GetStruct()->base.on_theme_changed = browser_view_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/button_delegate_cpptoc.cc index e7cec05c9..4552d0787 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=4dce379ea37fb6976b0af5f46fc1eeccf2e8606d$ +// $hash=0e5cf49bf903204aa1241520c8acf1cb5767da65$ // #include "libcef_dll/cpptoc/views/button_delegate_cpptoc.h" @@ -327,6 +327,28 @@ void CEF_CALLBACK button_delegate_on_blur(struct _cef_view_delegate_t* self, ->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +button_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefButtonDelegateCppToC::Get(reinterpret_cast(self)) + ->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -347,6 +369,7 @@ CefButtonDelegateCppToC::CefButtonDelegateCppToC() { 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; + GetStruct()->base.on_theme_changed = button_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc index f4a25cbd5..784974654 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=5e0418c416ecd0c23cb7fcc9d6a52ef06ba86686$ +// $hash=e279bb0412c82b1235a5f4cd860ad2d5aab07042$ // #include "libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h" @@ -376,6 +376,29 @@ menu_button_delegate_on_blur(struct _cef_view_delegate_t* self, ->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +menu_button_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefMenuButtonDelegateCppToC::Get( + reinterpret_cast(self)) + ->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -404,6 +427,8 @@ CefMenuButtonDelegateCppToC::CefMenuButtonDelegateCppToC() { 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; + GetStruct()->base.base.on_theme_changed = + menu_button_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc index 257fa8457..f4836f2f6 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=cb28c29eeb68707fb9b164f539804a6d8a7e61be$ +// $hash=cb2d1231eb279cea9a132af8bded03032307cb45$ // #include "libcef_dll/cpptoc/views/panel_delegate_cpptoc.h" @@ -282,6 +282,28 @@ void CEF_CALLBACK panel_delegate_on_blur(struct _cef_view_delegate_t* self, ->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +panel_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefPanelDelegateCppToC::Get(reinterpret_cast(self)) + ->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -299,6 +321,7 @@ CefPanelDelegateCppToC::CefPanelDelegateCppToC() { 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; + GetStruct()->base.on_theme_changed = panel_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc index d54cad1bb..b687b875e 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=e0a80958b419a73b1f57655ef19f4aa7064bd19d$ +// $hash=3a3696160ea6f07beb0a7c68e415e2c71490963e$ // #include "libcef_dll/cpptoc/views/textfield_delegate_cpptoc.h" @@ -344,6 +344,29 @@ void CEF_CALLBACK textfield_delegate_on_blur(struct _cef_view_delegate_t* self, ->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +textfield_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefTextfieldDelegateCppToC::Get( + reinterpret_cast(self)) + ->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -364,6 +387,7 @@ CefTextfieldDelegateCppToC::CefTextfieldDelegateCppToC() { 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; + GetStruct()->base.on_theme_changed = textfield_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/view_delegate_cpptoc.cc index fdcb75d38..effd372d8 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=a73bcac096d32c3a63cca3f3006d70a803c00626$ +// $hash=bd18088799d97c56459bce12fb0cb2177caecead$ // #include "libcef_dll/cpptoc/views/view_delegate_cpptoc.h" @@ -281,6 +281,27 @@ void CEF_CALLBACK view_delegate_on_blur(struct _cef_view_delegate_t* self, CefViewDelegateCppToC::Get(self)->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +view_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefViewDelegateCppToC::Get(self)->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -296,6 +317,7 @@ CefViewDelegateCppToC::CefViewDelegateCppToC() { GetStruct()->on_layout_changed = view_delegate_on_layout_changed; GetStruct()->on_focus = view_delegate_on_focus; GetStruct()->on_blur = view_delegate_on_blur; + GetStruct()->on_theme_changed = view_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc b/libcef_dll/cpptoc/views/window_delegate_cpptoc.cc index de1109bb8..685db20d3 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=1f438b082c8c499084a3e494e1bb83adaecf91d1$ +// $hash=1829e6ed7282ca9a0b34e825a11c229ddd48590d$ // #include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h" @@ -793,6 +793,28 @@ void CEF_CALLBACK window_delegate_on_blur(struct _cef_view_delegate_t* self, ->OnBlur(CefViewCToCpp::Wrap(view)); } +void CEF_CALLBACK +window_delegate_on_theme_changed(struct _cef_view_delegate_t* self, + cef_view_t* view) { + 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; + } + + // Execute + CefWindowDelegateCppToC::Get(reinterpret_cast(self)) + ->OnThemeChanged(CefViewCToCpp::Wrap(view)); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -835,6 +857,7 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() { 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; + GetStruct()->base.base.on_theme_changed = window_delegate_on_theme_changed; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc index b8119d8a5..2bcdcff50 100644 --- a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=07f16fe4afc8f6c558d40bdc2852a27920dd779c$ +// $hash=bf57f469c4dc266377346d8874406c437b682112$ // #include "libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h" @@ -486,6 +486,28 @@ void CefBrowserViewDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefBrowserViewDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefBrowserViewDelegateCToCpp::CefBrowserViewDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h b/libcef_dll/ctocpp/views/browser_view_delegate_ctocpp.h index 766243f1d..6dbe90209 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=a10c42b7075bc78e51a99ff5aa7da9effa4fe6f5$ +// $hash=b7d2905473b08d50a876b01f9e6a275316166c72$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_DELEGATE_CTOCPP_H_ @@ -74,6 +74,7 @@ class CefBrowserViewDelegateCToCpp const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_BROWSER_VIEW_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/button_delegate_ctocpp.cc index 47811ad7e..53855392f 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=68df0ecd51479bdc9f55fb605933ac10ca15affd$ +// $hash=564f44a20f3eab8c45fe840cb8d65f399f3ee0db$ // #include "libcef_dll/ctocpp/views/button_delegate_ctocpp.h" @@ -318,6 +318,28 @@ void CefButtonDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefButtonDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefButtonDelegateCToCpp::CefButtonDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/button_delegate_ctocpp.h b/libcef_dll/ctocpp/views/button_delegate_ctocpp.h index 31ba282a9..a38cba5cd 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=53e751a5b54ab964ee2aef1a8232a9647f47db00$ +// $hash=0e50e8cd82200398ce91a03a6c0ef51da5ac956b$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_DELEGATE_CTOCPP_H_ @@ -56,6 +56,7 @@ class CefButtonDelegateCToCpp const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_BUTTON_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc index 0508f365e..6824b28f7 100644 --- a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=f65b17eb26f40ebf503684544969eed98dcabd9b$ +// $hash=a6485751f5491da5b4a762d8f70c80fec73d0a95$ // #include "libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h" @@ -353,6 +353,28 @@ void CefMenuButtonDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefMenuButtonDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefMenuButtonDelegateCToCpp::CefMenuButtonDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h b/libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h index fe3c94ca3..7bc75d6da 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=a95e80394596beec91e6f8915fed15fdd52bea96$ +// $hash=99795614556ff22cbcbac94cfb9f4794e5fe5c81$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_DELEGATE_CTOCPP_H_ @@ -62,6 +62,7 @@ class CefMenuButtonDelegateCToCpp const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_MENU_BUTTON_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc index 9a9ba3d6f..4cd395aa0 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=eeb999ed9ff1b98afba6cc6d0c4c7917c4d28230$ +// $hash=96114a38e7bbf499fcb245d029164975b8d10ebe$ // #include "libcef_dll/ctocpp/views/panel_delegate_ctocpp.h" @@ -274,6 +274,28 @@ void CefPanelDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefPanelDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefPanelDelegateCToCpp::CefPanelDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h b/libcef_dll/ctocpp/views/panel_delegate_ctocpp.h index af4b136b0..3cd26cba9 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=26cc71f954f212dae798b7c0ffb99f9ec7b8caac$ +// $hash=74dcb25fa301e2442b1275efa20421e0477b47e0$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_PANEL_DELEGATE_CTOCPP_H_ @@ -52,6 +52,7 @@ class CefPanelDelegateCToCpp const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_PANEL_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc index f85ab50e7..be6b60cfc 100644 --- a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc +++ b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=974d55311d65e2bea484c9c8721e138018f4ab10$ +// $hash=6bb6403f617d98d48362f9038b648a176b67e585$ // #include "libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h" @@ -323,6 +323,28 @@ void CefTextfieldDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefTextfieldDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefTextfieldDelegateCToCpp::CefTextfieldDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h b/libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h index 6ef92d150..065e9994e 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=343716f91bef33f5c84bd269d5755b142010f8be$ +// $hash=c8a4c746300947cd664bbea7b85811e77f7f7bc4$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_TEXTFIELD_DELEGATE_CTOCPP_H_ @@ -57,6 +57,7 @@ class CefTextfieldDelegateCToCpp const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_TEXTFIELD_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/view_delegate_ctocpp.cc index 6971b547d..bc1e8627e 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=db639bf9fe95b7a04e6d126b32ba4ba797a82ef0$ +// $hash=4a5c6a3e8b378e785f57c0749926b380cc29ad43$ // #include "libcef_dll/ctocpp/views/view_delegate_ctocpp.h" @@ -269,6 +269,27 @@ void CefViewDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefViewDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefViewDelegateCToCpp::CefViewDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/view_delegate_ctocpp.h b/libcef_dll/ctocpp/views/view_delegate_ctocpp.h index 13c8647c5..1818b9d51 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=e6d59b73a62b960955749e557d300f656a95297c$ +// $hash=de93178ea96887a8dc558c96f46f2ed075fae0a6$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_VIEW_DELEGATE_CTOCPP_H_ @@ -51,6 +51,7 @@ class CefViewDelegateCToCpp : public CefCToCppRefCounted view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_VIEW_DELEGATE_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc b/libcef_dll/ctocpp/views/window_delegate_ctocpp.cc index 1ddf021c6..04c8e2a66 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=cfe4f7b7980000ea0bf223db0d717ed44e8b880b$ +// $hash=1d798c20b6e7325b2e769185739288682b037960$ // #include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h" @@ -766,6 +766,28 @@ void CefWindowDelegateCToCpp::OnBlur(CefRefPtr view) { _struct->on_blur(_struct, CefViewCppToC::Wrap(view)); } +NO_SANITIZE("cfi-icall") +void CefWindowDelegateCToCpp::OnThemeChanged(CefRefPtr view) { + shutdown_checker::AssertNotShutdown(); + + cef_view_delegate_t* _struct = + reinterpret_cast(GetStruct()); + if (CEF_MEMBER_MISSING(_struct, on_theme_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_theme_changed(_struct, CefViewCppToC::Wrap(view)); +} + // CONSTRUCTOR - Do not edit by hand. CefWindowDelegateCToCpp::CefWindowDelegateCToCpp() {} diff --git a/libcef_dll/ctocpp/views/window_delegate_ctocpp.h b/libcef_dll/ctocpp/views/window_delegate_ctocpp.h index b59e3fd40..fa21232ad 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=ffa207a19ab4e538ce2f6071584c56c82233921c$ +// $hash=80e6d33af9304311baec72c039930dc22d38bd53$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ @@ -82,6 +82,7 @@ class CefWindowDelegateCToCpp const CefRect& new_bounds) override; void OnFocus(CefRefPtr view) override; void OnBlur(CefRefPtr view) override; + void OnThemeChanged(CefRefPtr view) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ diff --git a/tests/cefclient/browser/main_context_impl.cc b/tests/cefclient/browser/main_context_impl.cc index 24365bdcf..345c74cfa 100644 --- a/tests/cefclient/browser/main_context_impl.cc +++ b/tests/cefclient/browser/main_context_impl.cc @@ -124,9 +124,6 @@ MainContextImpl::MainContextImpl(CefRefPtr command_line, // Parse the background color value. background_color_ = ParseColor(command_line_->GetSwitchValue(switches::kBackgroundColor)); - } else if (command_line_->HasSwitch("force-dark-mode")) { - // Use black background color by default with dark mode. - background_color_ = ParseColor("black"); } if (background_color_ == 0 && !use_views_) { diff --git a/tests/cefclient/browser/views_menu_bar.cc b/tests/cefclient/browser/views_menu_bar.cc index 8567d688d..14632b672 100644 --- a/tests/cefclient/browser/views_menu_bar.cc +++ b/tests/cefclient/browser/views_menu_bar.cc @@ -83,7 +83,6 @@ CefRefPtr ViewsMenuBar::CreateMenuModel(const CefString& label, CefRefPtr button = CefMenuButton::CreateMenuButton(this, label); button->SetID(new_menu_id); - views_style::ApplyTo(button.get()); button->SetInkDropEnabled(true); // Assign a group ID to allow focus traversal between MenuButtons using the @@ -283,13 +282,17 @@ void ViewsMenuBar::MenuClosed(CefRefPtr menu_model) { } } +void ViewsMenuBar::OnThemeChanged(CefRefPtr view) { + // Apply colors when the theme changes. + views_style::ApplyTo(view); +} + void ViewsMenuBar::EnsureMenuPanel() { if (panel_) { return; } - panel_ = CefPanel::CreatePanel(nullptr); - views_style::ApplyTo(panel_); + panel_ = CefPanel::CreatePanel(this); // Use a horizontal box layout. CefBoxLayoutSettings top_panel_layout_settings; diff --git a/tests/cefclient/browser/views_menu_bar.h b/tests/cefclient/browser/views_menu_bar.h index b11872985..9001577f2 100644 --- a/tests/cefclient/browser/views_menu_bar.h +++ b/tests/cefclient/browser/views_menu_bar.h @@ -21,7 +21,9 @@ namespace client { // Implements a menu bar which is composed of CefMenuButtons positioned in a // row with automatic switching between them via mouse/keyboard. All methods // must be called on the browser process UI thread. -class ViewsMenuBar : public CefMenuButtonDelegate, public CefMenuModelDelegate { +class ViewsMenuBar : public CefMenuButtonDelegate, + public CefMenuModelDelegate, + public CefPanelDelegate { public: // Delegate methods will be called on the browser process UI thread. class Delegate { @@ -90,6 +92,9 @@ class ViewsMenuBar : public CefMenuButtonDelegate, public CefMenuModelDelegate { bool is_rtl) override; void MenuClosed(CefRefPtr menu_model) override; + // CefViewDelegate methods: + void OnThemeChanged(CefRefPtr view) override; + private: // Creates the menu panel if it doesn't already exist. void EnsureMenuPanel(); diff --git a/tests/cefclient/browser/views_overlay_controls.cc b/tests/cefclient/browser/views_overlay_controls.cc index c946805ac..2840a8590 100644 --- a/tests/cefclient/browser/views_overlay_controls.cc +++ b/tests/cefclient/browser/views_overlay_controls.cc @@ -96,8 +96,7 @@ void ViewsOverlayControls::Initialize(CefRefPtr window, // 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_); + panel_ = CefPanel::CreatePanel(this); // Use a horizontal box layout. CefBoxLayoutSettings panel_layout_settings; @@ -226,11 +225,15 @@ void ViewsOverlayControls::OnButtonPressed(CefRefPtr button) { } } +void ViewsOverlayControls::OnThemeChanged(CefRefPtr view) { + // Apply colors when the theme changes. + views_style::ApplyTo(view); +} + 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; diff --git a/tests/cefclient/browser/views_overlay_controls.h b/tests/cefclient/browser/views_overlay_controls.h index 0a794242b..42ea36399 100644 --- a/tests/cefclient/browser/views_overlay_controls.h +++ b/tests/cefclient/browser/views_overlay_controls.h @@ -17,7 +17,7 @@ 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 { +class ViewsOverlayControls : public CefButtonDelegate, public CefPanelDelegate { public: enum class Command { kMinimize = 1, @@ -43,6 +43,9 @@ class ViewsOverlayControls : public CefButtonDelegate { // CefButtonDelegate methods: void OnButtonPressed(CefRefPtr button) override; + // CefViewDelegate methods: + void OnThemeChanged(CefRefPtr view) override; + CefRefPtr CreateButton(Command command); void MaybeUpdateMaximizeButton(); diff --git a/tests/cefclient/browser/views_style.cc b/tests/cefclient/browser/views_style.cc index 475cc9ed3..4bbff7eb6 100644 --- a/tests/cefclient/browser/views_style.cc +++ b/tests/cefclient/browser/views_style.cc @@ -48,44 +48,6 @@ 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; - } - - panel->SetBackgroundColor(g_background_color); -} - -void ApplyTo(CefRefPtr label_button) { - if (!IsSet()) { - return; - } - - // All text except disabled gets the same color. - label_button->SetEnabledTextColors(g_text_color); - label_button->SetTextColor(CEF_BUTTON_STATE_DISABLED, - g_background_hover_color); - - label_button->SetBackgroundColor(g_background_color); -} - -void ApplyTo(CefRefPtr textfield) { - if (!IsSet()) { - return; - } - - textfield->SetBackgroundColor(g_background_color); - textfield->SetTextColor(g_text_color); -} - void ApplyTo(CefRefPtr menu_model) { if (!IsSet()) { return; @@ -111,4 +73,23 @@ void ApplyTo(CefRefPtr menu_model) { } } +void ApplyTo(CefRefPtr view) { + if (!IsSet()) { + return; + } + + if (auto button = view->AsButton()) { + if (auto label_button = button->AsLabelButton()) { + // All text except disabled gets the same color. + label_button->SetEnabledTextColors(g_text_color); + label_button->SetTextColor(CEF_BUTTON_STATE_DISABLED, + g_background_hover_color); + } + } else if (auto textfield = view->AsTextfield()) { + textfield->SetTextColor(g_text_color); + } + + view->SetBackgroundColor(g_background_color); +} + } // namespace client::views_style diff --git a/tests/cefclient/browser/views_style.h b/tests/cefclient/browser/views_style.h index bd4ecf0d0..362f720c1 100644 --- a/tests/cefclient/browser/views_style.h +++ b/tests/cefclient/browser/views_style.h @@ -17,11 +17,8 @@ namespace client::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); void ApplyTo(CefRefPtr menu_model); +void ApplyTo(CefRefPtr view); } // namespace client::views_style diff --git a/tests/cefclient/browser/views_window.cc b/tests/cefclient/browser/views_window.cc index 5d07512c5..029d5c9a3 100644 --- a/tests/cefclient/browser/views_window.cc +++ b/tests/cefclient/browser/views_window.cc @@ -1060,6 +1060,11 @@ void ViewsWindow::OnLayoutChanged(CefRefPtr view, } } +void ViewsWindow::OnThemeChanged(CefRefPtr view) { + // Apply colors when the theme changes. + views_style::ApplyTo(view); +} + void ViewsWindow::MenuBarExecuteCommand(CefRefPtr menu_model, int command_id, cef_event_flags_t event_flags) { @@ -1157,7 +1162,6 @@ 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. @@ -1173,7 +1177,6 @@ CefRefPtr ViewsWindow::CreateMenuButton() { 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)); @@ -1186,14 +1189,12 @@ CefRefPtr ViewsWindow::CreateLocationBar() { // 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_; @@ -1264,7 +1265,6 @@ void ViewsWindow::AddControls() { panel->AddChildView(extensions_panel_); panel->AddChildView(menu_button_); - views_style::ApplyTo(panel); // Allow |location| to grow and fill any remaining space. panel_layout->SetFlexForView(location_bar_, 1); @@ -1405,7 +1405,6 @@ void ViewsWindow::UpdateExtensionControls() { CefMenuButton::CreateMenuButton(this, CefString()); button->SetID(id); button->SetImage(CEF_BUTTON_STATE_NORMAL, (*it).image_); - views_style::ApplyTo(button.get()); button->SetInkDropEnabled(true); // Override the default minimum size. button->SetMinimumSize(CefSize(0, 0)); diff --git a/tests/cefclient/browser/views_window.h b/tests/cefclient/browser/views_window.h index f4087b2a8..f1e2fe817 100644 --- a/tests/cefclient/browser/views_window.h +++ b/tests/cefclient/browser/views_window.h @@ -202,6 +202,7 @@ class ViewsWindow : public CefBrowserViewDelegate, void OnWindowChanged(CefRefPtr view, bool added) override; void OnLayoutChanged(CefRefPtr view, const CefRect& new_bounds) override; + void OnThemeChanged(CefRefPtr view) override; // ViewsMenuBar::Delegate methods: void MenuBarExecuteCommand(CefRefPtr menu_model, diff --git a/tests/ceftests/views/panel_unittest.cc b/tests/ceftests/views/panel_unittest.cc index 2018c16a1..84e680d51 100644 --- a/tests/ceftests/views/panel_unittest.cc +++ b/tests/ceftests/views/panel_unittest.cc @@ -56,7 +56,6 @@ void CreatePanel(CefRefPtr delegate) { EXPECT_TRUE(panel->IsEnabled()); EXPECT_FALSE(panel->IsFocusable()); EXPECT_FALSE(panel->IsAccessibilityFocusable()); - EXPECT_EQ(CefColorSetARGB(255, 255, 255, 255), panel->GetBackgroundColor()); // Verify default Panel state. EXPECT_TRUE(panel->GetLayout().get());