mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Add support for Alloy style browsers and windows (see #3681)
Split the Alloy runtime into bootstrap and style components. Support creation of Alloy style browsers and windows with the Chrome runtime. Chrome runtime (`--enable-chrome-runtime`) + Alloy style (`--use-alloy-style`) supports Views (`--use-views`), native parent (`--use-native`) and windowless rendering (`--off-screen-rendering-enabled`). Print preview is supported in all cases except with windowless rendering on all platforms and native parent on MacOS. It is disabled by default with Alloy style for legacy compatibility. Where supported it can be enabled or disabled globally using `--[enable|disable]-print-preview` or configured on a per-RequestContext basis using the `printing.print_preview_disabled` preference. It also behaves as expected when triggered via the PDF viewer print button. Chrome runtime + Alloy style behavior differs from Alloy runtime in the following significant ways: - Supports Chrome error pages by default. - DevTools popups are Chrome style only (cannot be windowless). - The Alloy extension API will not supported. Chrome runtime + Alloy style passes all expected Alloy ceftests except the following: - `DisplayTest.AutoResize` (Alloy extension API not supported) - `DownloadTest.*` (Download API not yet supported) - `ExtensionTest.*` (Alloy extension API not supported) This change also adds Chrome runtime support for CefContextMenuHandler::RunContextMenu (see #3293). This change also explicitly blocks (and doesn't retry) FrameAttached requests from PDF viewer and print preview excluded frames (see #3664). Known issues specific to Chrome runtime + Alloy style: - DevTools popup with windowless rendering doesn't load successfully. Use windowed rendering or remote debugging as a workaround. - Chrome style Window with Alloy style BrowserView (`--use-alloy-style --use-chrome-style-window`) does not show Chrome theme changes. To test: - Run `ceftests --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native] --gtest_filter=...` - Run `cefclient --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native|--off-screen-rendering-enabled]` - Run `cefsimple --enable-chrome-runtime --use-alloy-style [--use-views]`
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=abcb584dbf5965834f415a0f2daeda3e361696b2$
|
||||
// $hash=7733ed87ade32dfd311c24c51263d20b9b469868$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
@@ -985,6 +985,13 @@ typedef struct _cef_browser_host_t {
|
||||
///
|
||||
int(CEF_CALLBACK* is_render_process_unresponsive)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this browser (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
|
||||
struct _cef_browser_host_t* self);
|
||||
} cef_browser_host_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=2e5a3b3b1f427a7eb1e6a447fe0d31c5ace49469$
|
||||
// $hash=1c2fbbffaf51e90a2d55bfa7eb3fa3a4e315f4ac$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
|
||||
@@ -93,6 +93,13 @@ typedef struct _cef_browser_view_t {
|
||||
///
|
||||
void(CEF_CALLBACK* set_prefer_accelerators)(struct _cef_browser_view_t* self,
|
||||
int prefer_accelerators);
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this BrowserView (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
|
||||
struct _cef_browser_view_t* self);
|
||||
} cef_browser_view_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=1f2a6e206b86945386bef57167b80e2fb6067c59$
|
||||
// $hash=a0a9f2bfcdf8e05d3d1114fcd8860caaa726ec98$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_DELEGATE_CAPI_H_
|
||||
@@ -141,6 +141,13 @@ typedef struct _cef_browser_view_delegate_t {
|
||||
struct _cef_browser_view_delegate_t* self,
|
||||
struct _cef_browser_view_t* browser_view,
|
||||
cef_gesture_command_t gesture_command);
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this BrowserView. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_browser_runtime_style)(
|
||||
struct _cef_browser_view_delegate_t* self);
|
||||
} cef_browser_view_delegate_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=2abb3759a22a95ffc0207f0538c645a74a5030c6$
|
||||
// $hash=dd32b58ec9aca0e04a1d30ccf94a741995fcc094$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
|
||||
@@ -401,6 +401,13 @@ typedef struct _cef_window_t {
|
||||
/// or cef_view_delegate_t::OnThemeChanged.
|
||||
///
|
||||
void(CEF_CALLBACK* theme_changed)(struct _cef_window_t* self);
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this Window (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_runtime_style)(
|
||||
struct _cef_window_t* self);
|
||||
} cef_window_t;
|
||||
|
||||
///
|
||||
|
@@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e6bbc33db1b5ed3832982f8799e14557204f4028$
|
||||
// $hash=e8c9e32caa8d317a7cb6ff2f0ad6be49cf1b7ad1$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
|
||||
@@ -275,6 +275,13 @@ typedef struct _cef_window_delegate_t {
|
||||
struct _cef_window_delegate_t* self,
|
||||
struct _cef_window_t* window,
|
||||
int chrome_theme);
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this Window. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t(CEF_CALLBACK* get_window_runtime_style)(
|
||||
struct _cef_window_delegate_t* self);
|
||||
} cef_window_delegate_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -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 "de72aee0623e568ded52b7075c7fda576844e8b3"
|
||||
#define CEF_API_HASH_UNIVERSAL "faa2d7c5a95e129e5a746785cbbcb5f5f99cfe53"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "46bb69fe7038d7e9f8d4ee86e4a0825bb2d289b7"
|
||||
#define CEF_API_HASH_PLATFORM "9123354f4395b59f275ee3389f21734aeeac7a5e"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "e3ef47d5541f5260eba70030386d692138315900"
|
||||
#define CEF_API_HASH_PLATFORM "5ae2b1b7fbe4bdbd25dc6f707f6e3bfc163120ad"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "579ef9c5282456c7de906cf055aed0ff4ba0a5a3"
|
||||
#define CEF_API_HASH_PLATFORM "41ddfb7023cda15e5b813b237b06111b6d4cabb8"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -1018,6 +1018,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsRenderProcessUnresponsive() = 0;
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this browser (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
||||
|
@@ -70,6 +70,7 @@ struct CefWindowInfoTraits {
|
||||
target->shared_texture_enabled = src->shared_texture_enabled;
|
||||
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
|
||||
target->window = src->window;
|
||||
target->runtime_style = src->runtime_style;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -110,6 +111,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
void SetAsWindowless(CefWindowHandle parent) {
|
||||
windowless_rendering_enabled = true;
|
||||
parent_window = parent;
|
||||
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -71,6 +71,7 @@ struct CefWindowInfoTraits {
|
||||
target->shared_texture_enabled = src->shared_texture_enabled;
|
||||
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
|
||||
target->view = src->view;
|
||||
target->runtime_style = src->runtime_style;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -112,6 +113,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
void SetAsWindowless(CefWindowHandle parent) {
|
||||
windowless_rendering_enabled = true;
|
||||
parent_view = parent;
|
||||
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -44,6 +44,7 @@ typedef struct _XDisplay XDisplay;
|
||||
#include "include/internal/cef_export.h"
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_types_geometry.h"
|
||||
#include "include/internal/cef_types_runtime.h"
|
||||
|
||||
// Handle types.
|
||||
#if defined(CEF_X11)
|
||||
@@ -135,6 +136,13 @@ typedef struct _cef_window_info_t {
|
||||
/// Pointer for the new browser window. Only used with windowed rendering.
|
||||
///
|
||||
cef_window_handle_t window;
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style. Alloy style will always be used if
|
||||
/// |windowless_rendering_enabled| is true. See cef_runtime_style_t
|
||||
/// documentation for details.
|
||||
///
|
||||
cef_runtime_style_t runtime_style;
|
||||
} cef_window_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#if defined(OS_MAC)
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_types_geometry.h"
|
||||
#include "include/internal/cef_types_runtime.h"
|
||||
|
||||
// Handle types.
|
||||
// Actually NSCursor*
|
||||
@@ -134,6 +135,13 @@ typedef struct _cef_window_info_t {
|
||||
/// rendering.
|
||||
///
|
||||
cef_window_handle_t view;
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style. Alloy style will always be used if
|
||||
/// |windowless_rendering_enabled| is true or if |parent_view| is provided.
|
||||
/// See cef_runtime_style_t documentation for details.
|
||||
///
|
||||
cef_runtime_style_t runtime_style;
|
||||
} cef_window_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
88
include/internal/cef_types_runtime.h
Normal file
88
include/internal/cef_types_runtime.h
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) 2024 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.
|
||||
|
||||
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// CEF supports both a Chrome runtime (based on the Chrome UI layer) and an
|
||||
/// Alloy runtime (based on the Chromium content layer). The Chrome runtime
|
||||
/// provides the full Chrome UI and browser functionality whereas the Alloy
|
||||
/// runtime provides less default browser functionality but adds additional
|
||||
/// client callbacks and support for windowless (off-screen) rendering. For
|
||||
/// additional comparative details on runtime types see
|
||||
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
|
||||
///
|
||||
/// Each runtime is composed of a bootstrap component and a style component. The
|
||||
/// bootstrap component is configured via CefSettings.chrome_runtime and cannot
|
||||
/// be changed after CefInitialize. The style component is individually
|
||||
/// configured for each window/browser at creation time and, in combination with
|
||||
/// the Chrome bootstrap, different styles can be mixed during runtime.
|
||||
///
|
||||
/// Windowless rendering will always use Alloy style. Windowed rendering with a
|
||||
/// default window or client-provided parent window can configure the style via
|
||||
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
|
||||
/// configure the style via CefWindowDelegate::GetWindowRuntimeStyle and
|
||||
/// CefBrowserViewDelegate::GetBrowserRuntimeStyle. Alloy style Windows with the
|
||||
/// Views framework can host only Alloy style BrowserViews but Chrome style
|
||||
/// Windows can host both style BrowserViews. Additionally, a Chrome style
|
||||
/// Window can host at most one Chrome style BrowserView but potentially
|
||||
/// multiple Alloy style BrowserViews. See CefWindowInfo.runtime_style
|
||||
/// documentation for any additional platform-specific limitations.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
/// Use the default runtime style. The default style will match the
|
||||
/// CefSettings.chrome_runtime value in most cases. See above documentation
|
||||
/// for exceptions.
|
||||
///
|
||||
CEF_RUNTIME_STYLE_DEFAULT,
|
||||
|
||||
///
|
||||
/// Use the Chrome runtime style. Only supported with the Chrome runtime.
|
||||
///
|
||||
CEF_RUNTIME_STYLE_CHROME,
|
||||
|
||||
///
|
||||
/// Use the Alloy runtime style. Supported with both the Alloy and Chrome
|
||||
/// runtime.
|
||||
///
|
||||
CEF_RUNTIME_STYLE_ALLOY,
|
||||
} cef_runtime_style_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_RUNTIME_H_
|
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_types_geometry.h"
|
||||
#include "include/internal/cef_types_runtime.h"
|
||||
|
||||
// Handle types.
|
||||
#define cef_cursor_handle_t HCURSOR
|
||||
@@ -102,6 +103,13 @@ typedef struct _cef_window_info_t {
|
||||
/// Handle for the new browser window. Only used with windowed rendering.
|
||||
///
|
||||
cef_window_handle_t window;
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style. Alloy style will always be used if
|
||||
/// |windowless_rendering_enabled| is true. See cef_runtime_style_t
|
||||
/// documentation for details.
|
||||
///
|
||||
cef_runtime_style_t runtime_style;
|
||||
} cef_window_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -73,6 +73,7 @@ struct CefWindowInfoTraits {
|
||||
target->shared_texture_enabled = src->shared_texture_enabled;
|
||||
target->external_begin_frame_enabled = src->external_begin_frame_enabled;
|
||||
target->window = src->window;
|
||||
target->runtime_style = src->runtime_style;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -130,6 +131,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||
void SetAsWindowless(CefWindowHandle parent) {
|
||||
windowless_rendering_enabled = TRUE;
|
||||
parent_window = parent;
|
||||
runtime_style = CEF_RUNTIME_STYLE_ALLOY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -107,6 +107,13 @@ class CefBrowserView : public CefView {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this BrowserView (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_H_
|
||||
|
@@ -140,6 +140,15 @@ class CefBrowserViewDelegate : public CefViewDelegate {
|
||||
cef_gesture_command_t gesture_command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this BrowserView. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetBrowserRuntimeStyle() {
|
||||
return CEF_RUNTIME_STYLE_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_
|
||||
|
@@ -414,6 +414,13 @@ class CefWindow : public CefPanel {
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void ThemeChanged() = 0;
|
||||
|
||||
///
|
||||
/// Returns the runtime style for this Window (ALLOY or CHROME). See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetRuntimeStyle() = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_H_
|
||||
|
@@ -271,6 +271,15 @@ class CefWindowDelegate : public CefPanelDelegate {
|
||||
/*--cef()--*/
|
||||
virtual void OnThemeColorsChanged(CefRefPtr<CefWindow> window,
|
||||
bool chrome_theme) {}
|
||||
|
||||
///
|
||||
/// Optionally change the runtime style for this Window. See
|
||||
/// cef_runtime_style_t documentation for details.
|
||||
///
|
||||
/*--cef(default_retval=CEF_RUNTIME_STYLE_DEFAULT)--*/
|
||||
virtual cef_runtime_style_t GetWindowRuntimeStyle() {
|
||||
return CEF_RUNTIME_STYLE_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_
|
||||
|
Reference in New Issue
Block a user