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:
Marshall Greenblatt
2024-04-17 12:01:26 -04:00
parent 62c93f01f4
commit dca0435d2f
216 changed files with 3388 additions and 1565 deletions

View File

@ -44,6 +44,14 @@ struct RootWindowConfig {
// Associated command-line.
CefRefPtr<CefCommandLine> command_line;
// If true the Views framework will be used.
bool use_views;
// If true Alloy style will be used. Alloy style is always used with
// the Alloy runtime and optional with the Chrome runtime. Windowless
// rendering requires Alloy style.
bool use_alloy_style;
// Configure the window type.
WindowType window_type = WindowType::NORMAL;
@ -53,7 +61,7 @@ struct RootWindowConfig {
// If true the window will show controls.
bool with_controls = true;
// If true the window will use off-screen rendering.
// If true the window will use windowless (off-screen) rendering.
bool with_osr = false;
// If true the window will be created initially hidden.
@ -146,11 +154,9 @@ class RootWindow
// Create a new RootWindow object. This method may be called on any thread.
// Use RootWindowManager::CreateRootWindow() or CreateRootWindowAsPopup()
// instead of calling this method directly. |use_views| will be true if the
// Views framework should be used. |parent_window| will be non-nullptr for
// popup browsers with a RootWindow parent (on the UI thread only).
static scoped_refptr<RootWindow> Create(
bool use_views,
scoped_refptr<RootWindow> parent_window);
// Views framework should be used. |use_alloy_style| will be true if Alloy
// style should be used.
static scoped_refptr<RootWindow> Create(bool use_views, bool use_alloy_style);
// Returns the RootWindow associated with the specified |browser_id|. Must be
// called on the main thread.
@ -159,6 +165,9 @@ class RootWindow
// Returns true if the RootWindow is Views-hosted.
virtual bool IsViewsHosted() const { return false; }
// Returns true if the RootWindow is Alloy style, otherwise Chrome style.
bool IsAlloyStyle() const { return use_alloy_style_; }
// Initialize as a normal window. This will create and show a native window
// hosting a single browser instance. This method may be called on any thread.
// |delegate| must be non-nullptr and outlive this object.
@ -231,10 +240,13 @@ class RootWindow
friend struct DeleteOnMainThread;
friend class base::RefCountedThreadSafe<RootWindow, DeleteOnMainThread>;
RootWindow();
explicit RootWindow(bool use_alloy_style);
virtual ~RootWindow();
Delegate* delegate_ = nullptr;
private:
const bool use_alloy_style_;
};
} // namespace client