diff --git a/atom/browser/osr/osr_web_contents_view.cc b/atom/browser/osr/osr_web_contents_view.cc index 03cf5980c42c..5bcfa69543c9 100644 --- a/atom/browser/osr/osr_web_contents_view.cc +++ b/atom/browser/osr/osr_web_contents_view.cc @@ -151,10 +151,6 @@ void OffScreenWebContentsView::RenderViewCreated( content::RenderViewHost* host) { if (GetView()) GetView()->InstallTransparency(); - -#if defined(OS_MACOSX) - host->Send(new AtomViewMsg_Offscreen(host->GetRoutingID())); -#endif } void OffScreenWebContentsView::RenderViewReady() {} diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 260cad9a7949..6ffa5ceafd63 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -147,6 +147,23 @@ WebContentsPreferences::WebContentsPreferences( #endif SetDefaultBoolIfUndefined(options::kOffscreen, false); + // If this is a tag, and the embedder is offscreen-rendered, then + // this WebContents is also offscreen-rendered. + int guest_instance_id = 0; + if (web_preferences.Get(options::kGuestInstanceID, &guest_instance_id)) { + auto* manager = WebViewManager::GetWebViewManager(web_contents); + if (manager) { + auto* embedder = manager->GetEmbedder(guest_instance_id); + if (embedder) { + auto* embedder_preferences = WebContentsPreferences::From(embedder); + if (embedder_preferences && + embedder_preferences->IsEnabled(options::kOffscreen)) { + preference_.SetKey(options::kOffscreen, base::Value(true)); + } + } + } + } + last_preference_ = preference_.Clone(); } @@ -309,6 +326,11 @@ void WebContentsPreferences::AppendCommandLineSwitches( command_line->AppendSwitchASCII(switches::kBackgroundColor, "#fff"); } + // --offscreen + if (IsEnabled(options::kOffscreen)) { + command_line->AppendSwitch(options::kOffscreen); + } + // --guest-instance-id, which is used to identify guest WebContents. int guest_instance_id = 0; if (GetAsInteger(&preference_, options::kGuestInstanceID, &guest_instance_id)) diff --git a/atom/common/api/api_messages.h b/atom/common/api/api_messages.h index 8f6a773cd850..3f7f10774d30 100644 --- a/atom/common/api/api_messages.h +++ b/atom/common/api/api_messages.h @@ -25,8 +25,6 @@ IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion) IPC_STRUCT_TRAITS_MEMBER(bounds) IPC_STRUCT_TRAITS_END() -IPC_MESSAGE_ROUTED0(AtomViewMsg_Offscreen) - IPC_MESSAGE_ROUTED3(AtomAutofillFrameHostMsg_ShowPopup, gfx::RectF /* bounds */, std::vector /* values */, diff --git a/atom/renderer/atom_autofill_agent.h b/atom/renderer/atom_autofill_agent.h index d16d64e57c17..b621506a1806 100644 --- a/atom/renderer/atom_autofill_agent.h +++ b/atom/renderer/atom_autofill_agent.h @@ -9,7 +9,6 @@ #include "base/memory/weak_ptr.h" #include "content/public/renderer/render_frame_observer.h" -#include "content/public/renderer/render_view_observer.h" #include "third_party/blink/public/web/web_autofill_client.h" #include "third_party/blink/public/web/web_form_control_element.h" #include "third_party/blink/public/web/web_input_element.h" diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc deleted file mode 100644 index 89abe602a431..000000000000 --- a/atom/renderer/atom_render_view_observer.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/renderer/atom_render_view_observer.h" - -#include "atom/common/api/api_messages.h" -#include "content/public/renderer/render_view.h" -#include "ipc/ipc_message_macros.h" -#include "third_party/blink/public/web/web_view.h" - -namespace atom { - -AtomRenderViewObserver::AtomRenderViewObserver(content::RenderView* render_view) - : content::RenderViewObserver(render_view) {} - -AtomRenderViewObserver::~AtomRenderViewObserver() {} - -bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message) - IPC_MESSAGE_HANDLER(AtomViewMsg_Offscreen, OnOffscreen) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - - return handled; -} - -void AtomRenderViewObserver::OnDestruct() { - delete this; -} - -void AtomRenderViewObserver::OnOffscreen() { - blink::WebView::SetUseExternalPopupMenus(false); -} - -} // namespace atom diff --git a/atom/renderer/atom_render_view_observer.h b/atom/renderer/atom_render_view_observer.h deleted file mode 100644 index 097616e12369..000000000000 --- a/atom/renderer/atom_render_view_observer.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ -#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ - -#include "content/public/renderer/render_view_observer.h" - -namespace atom { - -class AtomRenderViewObserver : public content::RenderViewObserver { - public: - explicit AtomRenderViewObserver(content::RenderView* render_view); - - protected: - ~AtomRenderViewObserver() override; - - private: - // content::RenderViewObserver implementation. - bool OnMessageReceived(const IPC::Message& message) override; - void OnDestruct() override; - - void OnOffscreen(); - - DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver); -}; - -} // namespace atom - -#endif // ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_ diff --git a/atom/renderer/renderer_client_base.cc b/atom/renderer/renderer_client_base.cc index 645cd1edce92..f024bf55d52c 100644 --- a/atom/renderer/renderer_client_base.cc +++ b/atom/renderer/renderer_client_base.cc @@ -13,13 +13,13 @@ #include "atom/common/options_switches.h" #include "atom/renderer/atom_autofill_agent.h" #include "atom/renderer/atom_render_frame_observer.h" -#include "atom/renderer/atom_render_view_observer.h" #include "atom/renderer/content_settings_observer.h" #include "atom/renderer/electron_api_service_impl.h" #include "atom/renderer/preferences_manager.h" #include "base/command_line.h" #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" +#include "content/common/buildflags.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_frame.h" @@ -142,6 +142,15 @@ void RendererClientBase::AddRenderBindings( void RendererClientBase::RenderThreadStarted() { auto* command_line = base::CommandLine::ForCurrentProcess(); +#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) + // On macOS, popup menus are rendered by the main process by default. + // This causes problems in OSR, since when the popup is rendered separately, + // it won't be captured in the rendered image. + if (command_line->HasSwitch(options::kOffscreen)) { + blink::WebView::SetUseExternalPopupMenus(false); + } +#endif + blink::WebCustomElement::AddEmbedderCustomElementName("webview"); blink::WebCustomElement::AddEmbedderCustomElementName("browserplugin"); @@ -252,10 +261,6 @@ void RendererClientBase::RenderFrameCreated( } } -void RendererClientBase::RenderViewCreated(content::RenderView* render_view) { - new AtomRenderViewObserver(render_view); -} - void RendererClientBase::DidClearWindowObject( content::RenderFrame* render_frame) { // Make sure every page will get a script context created. diff --git a/atom/renderer/renderer_client_base.h b/atom/renderer/renderer_client_base.h index 918e18870c88..8c4049d51ec9 100644 --- a/atom/renderer/renderer_client_base.h +++ b/atom/renderer/renderer_client_base.h @@ -54,7 +54,6 @@ class RendererClientBase : public content::ContentRendererClient { // content::ContentRendererClient: void RenderThreadStarted() override; void RenderFrameCreated(content::RenderFrame*) override; - void RenderViewCreated(content::RenderView*) override; std::unique_ptr OverrideSpeechSynthesizer( blink::WebSpeechSynthesizerClient* client) override; bool OverrideCreatePlugin(content::RenderFrame* render_frame, diff --git a/filenames.gni b/filenames.gni index 3a28a67af638..f5be6a89c614 100644 --- a/filenames.gni +++ b/filenames.gni @@ -656,8 +656,6 @@ filenames = { "atom/renderer/atom_autofill_agent.h", "atom/renderer/atom_render_frame_observer.cc", "atom/renderer/atom_render_frame_observer.h", - "atom/renderer/atom_render_view_observer.cc", - "atom/renderer/atom_render_view_observer.h", "atom/renderer/atom_renderer_client.cc", "atom/renderer/atom_renderer_client.h", "atom/renderer/content_settings_observer.cc",