build: remove enable_osr build flag (#38703)

Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Milan Burda 2023-06-13 20:48:53 +02:00 committed by GitHub
parent 80a3ba5c68
commit e37111edcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 21 additions and 108 deletions

View file

@ -457,6 +457,7 @@ source_set("electron_lib") {
"//services/proxy_resolver:lib",
"//services/video_capture/public/mojom:constants",
"//services/viz/privileged/mojom/compositing",
"//services/viz/public/mojom",
"//skia",
"//third_party/blink/public:blink",
"//third_party/blink/public:blink_devtools_inspector_resources",
@ -470,6 +471,7 @@ source_set("electron_lib") {
"//third_party/widevine/cdm:headers",
"//third_party/zlib/google:zip",
"//ui/base/idle",
"//ui/compositor",
"//ui/events:dom_keycode_converter",
"//ui/gl",
"//ui/native_theme",
@ -670,32 +672,6 @@ source_set("electron_lib") {
]
}
if (enable_osr) {
sources += [
"shell/browser/osr/osr_host_display_client.cc",
"shell/browser/osr/osr_host_display_client.h",
"shell/browser/osr/osr_render_widget_host_view.cc",
"shell/browser/osr/osr_render_widget_host_view.h",
"shell/browser/osr/osr_video_consumer.cc",
"shell/browser/osr/osr_video_consumer.h",
"shell/browser/osr/osr_view_proxy.cc",
"shell/browser/osr/osr_view_proxy.h",
"shell/browser/osr/osr_web_contents_view.cc",
"shell/browser/osr/osr_web_contents_view.h",
]
if (is_mac) {
sources += [
"shell/browser/osr/osr_host_display_client_mac.mm",
"shell/browser/osr/osr_web_contents_view_mac.mm",
]
}
deps += [
"//components/viz/service",
"//services/viz/public/mojom",
"//ui/compositor",
]
}
if (enable_views_api) {
sources += [
"shell/browser/api/views/electron_api_image_view.cc",
@ -946,11 +922,7 @@ if (is_mac) {
include_dirs = [ "." ]
sources = filenames.framework_sources
frameworks = []
if (enable_osr) {
frameworks += [ "IOSurface.framework" ]
}
frameworks = [ "IOSurface.framework" ]
ldflags = [
"-Wl,-install_name,@rpath/$output_name.framework/$output_name",

View file

@ -9,7 +9,6 @@ buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"ENABLE_OSR=$enable_osr",
"ENABLE_VIEWS_API=$enable_views_api",
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
"ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions",

View file

@ -3,8 +3,6 @@
# found in the LICENSE file.
declare_args() {
enable_osr = true
enable_views_api = true
enable_pdf_viewer = true

View file

@ -147,6 +147,8 @@ filenames = {
"shell/browser/notifications/mac/notification_center_delegate.mm",
"shell/browser/notifications/mac/notification_presenter_mac.h",
"shell/browser/notifications/mac/notification_presenter_mac.mm",
"shell/browser/osr/osr_host_display_client_mac.mm",
"shell/browser/osr/osr_web_contents_view_mac.mm",
"shell/browser/relauncher_mac.cc",
"shell/browser/ui/certificate_trust_mac.mm",
"shell/browser/ui/cocoa/delayed_native_view_host.mm",
@ -451,6 +453,16 @@ filenames = {
"shell/browser/notifications/notification_presenter.h",
"shell/browser/notifications/platform_notification_service.cc",
"shell/browser/notifications/platform_notification_service.h",
"shell/browser/osr/osr_host_display_client.cc",
"shell/browser/osr/osr_host_display_client.h",
"shell/browser/osr/osr_render_widget_host_view.cc",
"shell/browser/osr/osr_render_widget_host_view.h",
"shell/browser/osr/osr_video_consumer.cc",
"shell/browser/osr/osr_video_consumer.h",
"shell/browser/osr/osr_view_proxy.cc",
"shell/browser/osr/osr_view_proxy.h",
"shell/browser/osr/osr_web_contents_view.cc",
"shell/browser/osr/osr_web_contents_view.h",
"shell/browser/plugins/plugin_utils.cc",
"shell/browser/plugins/plugin_utils.h",
"shell/browser/protocol_registry.cc",

View file

@ -83,7 +83,6 @@ BaseWindow::BaseWindow(v8::Isolate* isolate,
if (options.Get("parent", &parent) && !parent.IsEmpty())
parent_window_.Reset(isolate, parent.ToV8());
#if BUILDFLAG(ENABLE_OSR)
// Offscreen windows are always created frameless.
gin_helper::Dictionary web_preferences;
bool offscreen;
@ -91,7 +90,6 @@ BaseWindow::BaseWindow(v8::Isolate* isolate,
web_preferences.Get(options::kOffscreen, &offscreen) && offscreen) {
const_cast<gin_helper::Dictionary&>(options).Set(options::kFrame, false);
}
#endif
// Creates NativeWindow.
window_.reset(NativeWindow::Create(

View file

@ -91,6 +91,8 @@
#include "shell/browser/electron_navigation_throttle.h"
#include "shell/browser/file_select_helper.h"
#include "shell/browser/native_window.h"
#include "shell/browser/osr/osr_render_widget_host_view.h"
#include "shell/browser/osr/osr_web_contents_view.h"
#include "shell/browser/session_preferences.h"
#include "shell/browser/ui/drag_util.h"
#include "shell/browser/ui/file_dialog.h"
@ -140,11 +142,6 @@
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#if BUILDFLAG(ENABLE_OSR)
#include "shell/browser/osr/osr_render_widget_host_view.h"
#include "shell/browser/osr/osr_web_contents_view.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "shell/browser/native_window_views.h"
#endif
@ -350,10 +347,8 @@ struct Converter<electron::api::WebContents::Type> {
*out = Type::kBrowserView;
} else if (type == "webview") {
*out = Type::kWebView;
#if BUILDFLAG(ENABLE_OSR)
} else if (type == "offscreen") {
*out = Type::kOffScreen;
#endif
} else {
return false;
}
@ -845,11 +840,9 @@ WebContents::WebContents(v8::Isolate* isolate,
// Get type
options.Get("type", &type_);
#if BUILDFLAG(ENABLE_OSR)
bool b = false;
if (options.Get(options::kOffscreen, &b) && b)
type_ = Type::kOffScreen;
#endif
// Init embedder earlier
options.Get("embedder", &embedder_);
@ -886,7 +879,6 @@ WebContents::WebContents(v8::Isolate* isolate,
std::make_unique<WebViewGuestDelegate>(embedder_->web_contents(), this);
params.guest_delegate = guest_delegate_.get();
#if BUILDFLAG(ENABLE_OSR)
if (embedder_ && embedder_->IsOffScreen()) {
auto* view = new OffScreenWebContentsView(
false,
@ -897,9 +889,7 @@ WebContents::WebContents(v8::Isolate* isolate,
web_contents = content::WebContents::Create(params);
view->SetWebContents(web_contents.get());
} else {
#endif
web_contents = content::WebContents::Create(params);
#if BUILDFLAG(ENABLE_OSR)
}
} else if (IsOffScreen()) {
// webPreferences does not have a transparent option, so if the window needs
@ -918,7 +908,6 @@ WebContents::WebContents(v8::Isolate* isolate,
web_contents = content::WebContents::Create(params);
view->SetWebContents(web_contents.get());
#endif
} else {
content::WebContents::CreateParams params(session->browser_context());
params.initially_hidden = !initially_shown;
@ -2304,11 +2293,9 @@ void WebContents::SetOwnerWindow(content::WebContents* web_contents,
owner_window_ = nullptr;
web_contents->RemoveUserData(NativeWindowRelay::UserDataKey());
}
#if BUILDFLAG(ENABLE_OSR)
auto* osr_wcv = GetOffScreenWebContentsView();
if (osr_wcv)
osr_wcv->SetNativeWindow(owner_window);
#endif
}
content::WebContents* WebContents::GetWebContents() const {
@ -3330,9 +3317,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
blink::WebMouseEvent mouse_event;
if (gin::ConvertFromV8(isolate, input_event, &mouse_event)) {
if (IsOffScreen()) {
#if BUILDFLAG(ENABLE_OSR)
GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
#endif
} else {
rwh->ForwardMouseEvent(mouse_event);
}
@ -3353,10 +3338,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
blink::WebMouseWheelEvent mouse_wheel_event;
if (gin::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
if (IsOffScreen()) {
#if BUILDFLAG(ENABLE_OSR)
GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(
mouse_wheel_event);
#endif
} else {
// Chromium expects phase info in wheel events (and applies a
// DCHECK to verify it). See: https://crbug.com/756524.
@ -3524,14 +3507,9 @@ void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
}
bool WebContents::IsOffScreen() const {
#if BUILDFLAG(ENABLE_OSR)
return type_ == Type::kOffScreen;
#else
return false;
#endif
}
#if BUILDFLAG(ENABLE_OSR)
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
}
@ -3563,15 +3541,12 @@ int WebContents::GetFrameRate() const {
auto* osr_wcv = GetOffScreenWebContentsView();
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
}
#endif
void WebContents::Invalidate() {
if (IsOffScreen()) {
#if BUILDFLAG(ENABLE_OSR)
auto* osr_rwhv = GetOffScreenRenderWidgetHostView();
if (osr_rwhv)
osr_rwhv->Invalidate();
#endif
} else {
auto* const window = owner_window();
if (window)
@ -4301,13 +4276,11 @@ void WebContents::FillObjectTemplate(v8::Isolate* isolate,
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
.SetMethod("detachFromOuterFrame", &WebContents::DetachFromOuterFrame)
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
#if BUILDFLAG(ENABLE_OSR)
.SetMethod("startPainting", &WebContents::StartPainting)
.SetMethod("stopPainting", &WebContents::StopPainting)
.SetMethod("isPainting", &WebContents::IsPainting)
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
#endif
.SetMethod("invalidate", &WebContents::Invalidate)
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
.SetMethod("getZoomLevel", &WebContents::GetZoomLevel)

View file

@ -91,11 +91,8 @@ class WebViewGuestDelegate;
class FrameSubscriber;
class WebDialogHelper;
class NativeWindow;
#if BUILDFLAG(ENABLE_OSR)
class OffScreenRenderWidgetHostView;
class OffScreenWebContentsView;
#endif
namespace api {
@ -285,14 +282,12 @@ class WebContents : public ExclusiveAccessContext,
// Methods for offscreen rendering
bool IsOffScreen() const;
#if BUILDFLAG(ENABLE_OSR)
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
void StartPainting();
void StopPainting();
bool IsPainting() const;
void SetFrameRate(int frame_rate);
int GetFrameRate() const;
#endif
void Invalidate();
gfx::Size GetSizeForNewRenderView(content::WebContents*) override;
@ -653,10 +648,8 @@ class WebContents : public ExclusiveAccessContext,
void OnElectronBrowserConnectionError();
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
#endif
// Called when received a synchronous message from renderer to
// get the zoom level.

View file

@ -7,11 +7,8 @@
#include "content/browser/renderer_host/frame_tree.h" // nogncheck
#include "content/browser/renderer_host/frame_tree_node.h" // nogncheck
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
#if BUILDFLAG(ENABLE_OSR)
#include "shell/browser/osr/osr_render_widget_host_view.h"
#include "shell/browser/osr/osr_web_contents_view.h"
#endif
// Including both web_contents_impl.h and node.h would introduce a error, we
// have to isolate the usage of WebContentsImpl into a clean file to fix it:
@ -31,7 +28,6 @@ void WebContents::DetachFromOuterFrame() {
}
}
#if BUILDFLAG(ENABLE_OSR)
OffScreenWebContentsView* WebContents::GetOffScreenWebContentsView() const {
if (IsOffScreen()) {
const auto* impl =
@ -51,6 +47,5 @@ OffScreenRenderWidgetHostView* WebContents::GetOffScreenRenderWidgetHostView()
return nullptr;
}
}
#endif
} // namespace electron::api

View file

@ -12,6 +12,8 @@
#include "electron/buildflags/buildflags.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/osr/osr_render_widget_host_view.h"
#include "shell/browser/osr/osr_view_proxy.h"
#include "shell/browser/ui/autofill_popup.h"
#include "shell/common/api/api.mojom.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
@ -25,11 +27,6 @@
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/text_utils.h"
#if BUILDFLAG(ENABLE_OSR)
#include "shell/browser/osr/osr_render_widget_host_view.h"
#include "shell/browser/osr/osr_view_proxy.h"
#endif
namespace electron {
namespace {
@ -194,7 +191,6 @@ void AutofillPopup::CreateView(content::RenderFrameHost* frame_host,
view_ = new AutofillPopupView(this, parent->GetWidget());
#if BUILDFLAG(ENABLE_OSR)
if (offscreen) {
auto* rwhv = frame_host->GetView();
if (embedder_frame_host != nullptr) {
@ -205,7 +201,6 @@ void AutofillPopup::CreateView(content::RenderFrameHost* frame_host,
view_->view_proxy_ = std::make_unique<OffscreenViewProxy>(view_);
osr_rwhv->AddViewProxy(view_->view_proxy_.get());
}
#endif
// Do this after OSR setup, we check for view_proxy_ when showing
view_->Show();

View file

@ -48,11 +48,9 @@ AutofillPopupView::~AutofillPopupView() {
RemoveObserver();
#if BUILDFLAG(ENABLE_OSR)
if (view_proxy_.get()) {
view_proxy_->ResetView();
}
#endif
if (GetWidget()) {
GetWidget()->Close();
@ -61,9 +59,7 @@ AutofillPopupView::~AutofillPopupView() {
void AutofillPopupView::Show() {
bool visible = parent_widget_->IsVisible();
#if BUILDFLAG(ENABLE_OSR)
visible = visible || view_proxy_;
#endif
if (!popup_ || !visible || parent_widget_->IsClosed())
return;
@ -228,11 +224,9 @@ void AutofillPopupView::DoUpdateBoundsAndRedrawPopup() {
popup_->popup_bounds_.Union(
gfx::Rect(popup_->popup_bounds_.origin(), gfx::Size(1, 1)));
GetWidget()->SetBounds(popup_->popup_bounds_);
#if BUILDFLAG(ENABLE_OSR)
if (view_proxy_.get()) {
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
}
#endif
SchedulePaint();
}
@ -243,7 +237,6 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
gfx::Canvas* draw_canvas = canvas;
SkBitmap bitmap;
#if BUILDFLAG(ENABLE_OSR)
std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
if (view_proxy_.get()) {
bitmap.allocN32Pixels(popup_->popup_bounds_in_view().width(),
@ -251,7 +244,6 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
paint_canvas = std::make_unique<cc::SkiaPaintCanvas>(bitmap);
draw_canvas = new gfx::Canvas(paint_canvas.get(), 1.0);
}
#endif
draw_canvas->DrawColor(
GetColorProvider()->GetColor(ui::kColorResultsTableNormalBackground));
@ -263,12 +255,10 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
DrawAutofillEntry(draw_canvas, i, line_rect);
}
#if BUILDFLAG(ENABLE_OSR)
if (view_proxy_.get()) {
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
view_proxy_->SetBitmap(bitmap);
}
#endif
}
void AutofillPopupView::GetAccessibleNodeData(ui::AXNodeData* node_data) {

View file

@ -13,6 +13,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_widget_host.h"
#include "electron/buildflags/buildflags.h"
#include "shell/browser/osr/osr_view_proxy.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/views/drag_controller.h"
@ -20,10 +21,6 @@
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_observer.h"
#if BUILDFLAG(ENABLE_OSR)
#include "shell/browser/osr/osr_view_proxy.h"
#endif
namespace electron {
const int kPopupBorderThickness = 1;
@ -142,9 +139,7 @@ class AutofillPopupView : public views::WidgetDelegateView,
// The index of the currently selected line
absl::optional<int> selected_line_;
#if BUILDFLAG(ENABLE_OSR)
std::unique_ptr<OffscreenViewProxy> view_proxy_;
#endif
// The registered keypress callback, responsible for switching lines on
// key presses

View file

@ -13,10 +13,6 @@ bool IsBuiltinSpellCheckerEnabled() {
return BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER);
}
bool IsOffscreenRenderingEnabled() {
return BUILDFLAG(ENABLE_OSR);
}
bool IsPDFViewerEnabled() {
return BUILDFLAG(ENABLE_PDF_VIEWER);
}
@ -51,7 +47,6 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
gin_helper::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("isBuiltinSpellCheckerEnabled", &IsBuiltinSpellCheckerEnabled);
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
dict.SetMethod("isFakeLocationProviderEnabled",
&IsFakeLocationProviderEnabled);

View file

@ -15,7 +15,6 @@ import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib
import { once } from 'events';
import { setTimeout } from 'timers/promises';
const features = process._linkedBinding('electron_common_features');
const fixtures = path.resolve(__dirname, 'fixtures');
const mainFixtures = path.resolve(__dirname, 'fixtures');
@ -6071,7 +6070,7 @@ describe('BrowserWindow module', () => {
});
});
ifdescribe(features.isOffscreenRenderingEnabled())('offscreen rendering', () => {
describe('offscreen rendering', () => {
let w: BrowserWindow;
beforeEach(function () {
w = new BrowserWindow({

View file

@ -5,7 +5,6 @@ declare const ENABLE_VIEWS_API: boolean;
declare namespace NodeJS {
interface FeaturesBinding {
isBuiltinSpellCheckerEnabled(): boolean;
isOffscreenRenderingEnabled(): boolean;
isPDFViewerEnabled(): boolean;
isFakeLocationProviderEnabled(): boolean;
isViewApiEnabled(): boolean;