diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 52f4dc71506..1fba9498a34 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -933,9 +933,10 @@ bool WebContents::OnMessageReceived(const IPC::Message& message, auto relay = NativeWindowRelay::FromWebContents(web_contents()); if (!relay) return false; + IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host) + IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup) + IPC_END_MESSAGE_MAP() IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host) - IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_ShowPopup, - relay->window.get(), NativeWindow::ShowAutofillPopup) IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup, relay->window.get(), NativeWindow::HideAutofillPopup) IPC_MESSAGE_UNHANDLED(handled = false) @@ -944,6 +945,16 @@ bool WebContents::OnMessageReceived(const IPC::Message& message, return handled; } +void WebContents::ShowAutofillPopup( + content::RenderFrameHost* frame_host, + const gfx::RectF& bounds, + const std::vector& values, + const std::vector& labels) { + auto relay = NativeWindowRelay::FromWebContents(web_contents()); + if (relay) + relay->window->ShowAutofillPopup(frame_host, this, bounds, values, labels); +} + // There are three ways of destroying a webContents: // 1. call webContents.destroy(); // 2. garbage collection; @@ -1624,7 +1635,7 @@ bool WebContents::IsOffScreen() const { } bool WebContents::IsOffScreenOrEmbedderOffscreen() const { - return IsOffScreen() || (embedder_ && embedder_->IsOffScreen()); + return IsOffScreen() || (IsGuest() && embedder_ && embedder_->IsOffScreen()); } void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) { diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 7a63ce3af44..d1ea99ce854 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -357,6 +357,12 @@ class WebContents : public mate::TrackableObject, void DevToolsFocused() override; void DevToolsOpened() override; void DevToolsClosed() override; + + void ShowAutofillPopup( + content::RenderFrameHost* frame_host, + const gfx::RectF& bounds, + const std::vector& values, + const std::vector& labels); private: AtomBrowserContext* GetBrowserContext() const; diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 618acef96b0..f6dfa37e3e1 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -11,6 +11,7 @@ #include #include "atom/browser/native_window_observer.h" +#include "atom/browser/api/atom_api_web_contents.h" #include "atom/browser/ui/accelerator_util.h" #include "atom/browser/ui/atom_menu_model.h" #include "base/cancelable_callback.h" @@ -231,6 +232,7 @@ class NativeWindow : public base::SupportsUserData, const content::NativeWebKeyboardEvent& event) {} virtual void ShowAutofillPopup( content::RenderFrameHost* frame_host, + atom::api::WebContents* web_contents, const gfx::RectF& bounds, const std::vector& values, const std::vector& labels) {} diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 444b8fc753a..296cff8aa70 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -1357,14 +1357,15 @@ void NativeWindowViews::HandleKeyboardEvent( void NativeWindowViews::ShowAutofillPopup( content::RenderFrameHost* frame_host, + atom::api::WebContents* web_contents, const gfx::RectF& bounds, const std::vector& values, const std::vector& labels) { - auto wc = atom::api::WebContents::FromWrappedClass( - v8::Isolate::GetCurrent(), web_contents()); + // auto wc = atom::api::WebContents::FromWrappedClass( + // v8::Isolate::GetCurrent(), web_contents()); autofill_popup_->CreateView( frame_host, - wc->IsOffScreenOrEmbedderOffscreen(), + web_contents->IsOffScreenOrEmbedderOffscreen(), widget(), bounds); autofill_popup_->SetItems(values, labels); diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 0f14f35c8f3..71a71275665 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -190,6 +190,7 @@ class NativeWindowViews : public NativeWindow, const content::NativeWebKeyboardEvent& event) override; void ShowAutofillPopup( content::RenderFrameHost* frame_host, + atom::api::WebContents* web_contents, const gfx::RectF& bounds, const std::vector& values, const std::vector& labels) override; diff --git a/atom/browser/ui/views/autofill_popup_view.cc b/atom/browser/ui/views/autofill_popup_view.cc index 2c7d28cb230..8b9b6d658c2 100644 --- a/atom/browser/ui/views/autofill_popup_view.cc +++ b/atom/browser/ui/views/autofill_popup_view.cc @@ -226,12 +226,13 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) { SkBitmap bitmap; #if defined(ENABLE_OSR) + cc::SkiaPaintCanvas* paint_canvas = nullptr; if (view_proxy_.get()) { bitmap.allocN32Pixels(popup_->popup_bounds_in_view_.width(), popup_->popup_bounds_in_view_.height(), true); - cc::SkiaPaintCanvas paint_canvas(new SkCanvas(bitmap)); - draw_canvas = new gfx::Canvas(&paint_canvas, 1.0); + paint_canvas = new cc::SkiaPaintCanvas(bitmap); + draw_canvas = new gfx::Canvas(paint_canvas, 1.0); } #endif @@ -249,6 +250,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) { if (view_proxy_.get()) { view_proxy_->SetBounds(popup_->popup_bounds_in_view_); view_proxy_->SetBitmap(bitmap); + delete paint_canvas; } #endif }