From d5ab691fdb2f954141c9b1713346a13efd9151ab Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Thu, 23 Nov 2017 20:46:26 +0100 Subject: [PATCH 1/3] fix osr devtools crash introduced during merge --- atom/browser/native_window_views.cc | 32 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 357afe35ca31..4b1bcbaca74e 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -1369,22 +1369,26 @@ void NativeWindowViews::ShowAutofillPopup( const gfx::RectF& bounds, const std::vector& values, const std::vector& labels) { - const auto* web_preferences = - WebContentsPreferences::FromWebContents(web_contents)->web_preferences(); - bool is_offsceen = false; - web_preferences->GetBoolean("offscreen", &is_offsceen); - int guest_instance_id = 0; - web_preferences->GetInteger(options::kGuestInstanceID, &guest_instance_id); - bool is_embedder_offscreen = false; - if (guest_instance_id) { - auto manager = WebViewManager::GetWebViewManager(web_contents); - if (manager) { - auto embedder = manager->GetEmbedder(guest_instance_id); - if (embedder) { - is_embedder_offscreen = WebContentsPreferences::IsPreferenceEnabled( - "offscreen", embedder); + + auto* web_contents_preferences = + WebContentsPreferences::FromWebContents(web_contents); + if (web_contents_preferences) { + const auto* web_preferences = web_contents_preferences->web_preferences(); + + web_preferences->GetBoolean("offscreen", &is_offsceen); + int guest_instance_id = 0; + web_preferences->GetInteger(options::kGuestInstanceID, &guest_instance_id); + + if (guest_instance_id) { + auto manager = WebViewManager::GetWebViewManager(web_contents); + if (manager) { + auto embedder = manager->GetEmbedder(guest_instance_id); + if (embedder) { + is_embedder_offscreen = WebContentsPreferences::IsPreferenceEnabled( + "offscreen", embedder); + } } } } From fdcac8552f2417a06fbd5f2753cca8045ab2b6b3 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Thu, 23 Nov 2017 20:47:01 +0100 Subject: [PATCH 2/3] dont change window background after devtools is closed --- brightray/browser/inspectable_web_contents_impl.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index ad18f69bce50..76ae267e7c65 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -31,6 +31,7 @@ #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_widget_host_view.h" #include "content/public/common/user_agent.h" #include "ipc/ipc_channel.h" #include "net/http/http_response_headers.h" @@ -337,6 +338,14 @@ void InspectableWebContentsImpl::CloseDevTools() { } embedder_message_dispatcher_.reset(); web_contents_->Focus(); + + // Restore background color of the page since closing devtools changes the + // color to the default white. TODO(brenca): remove this once this fix is + // not necessary + const auto view = web_contents_->GetRenderWidgetHostView(); + if (view) { + view->SetBackgroundColor(view->background_color()); + } } } From 0d9ff95526695d7b1284366b0cea0b0fa4df422a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 20 Dec 2017 15:18:26 +0900 Subject: [PATCH 3/3] Revert "dont change window background after devtools is closed" This reverts commit fdcac8552f2417a06fbd5f2753cca8045ab2b6b3. We are looking for a better fix. --- brightray/browser/inspectable_web_contents_impl.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 76ae267e7c65..ad18f69bce50 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -31,7 +31,6 @@ #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" -#include "content/public/browser/render_widget_host_view.h" #include "content/public/common/user_agent.h" #include "ipc/ipc_channel.h" #include "net/http/http_response_headers.h" @@ -338,14 +337,6 @@ void InspectableWebContentsImpl::CloseDevTools() { } embedder_message_dispatcher_.reset(); web_contents_->Focus(); - - // Restore background color of the page since closing devtools changes the - // color to the default white. TODO(brenca): remove this once this fix is - // not necessary - const auto view = web_contents_->GetRenderWidgetHostView(); - if (view) { - view->SetBackgroundColor(view->background_color()); - } } }