move popup related code to nativewindow
This commit is contained in:
parent
039908a244
commit
192cd7787b
11 changed files with 95 additions and 99 deletions
|
@ -114,12 +114,11 @@ AutofillPopup::~AutofillPopup() {
|
|||
}
|
||||
|
||||
void AutofillPopup::CreateView(
|
||||
int routing_id,
|
||||
content::WebContents* web_contents,
|
||||
content::RenderFrameHost* frame_host,
|
||||
bool offscreen,
|
||||
views::Widget* parent_widget,
|
||||
const gfx::RectF& r) {
|
||||
web_contents_ = web_contents;
|
||||
frame_host_ = frame_host;
|
||||
gfx::Rect lb(std::floor(r.x()), std::floor(r.y() + r.height()),
|
||||
std::floor(r.width()), std::floor(r.height()));
|
||||
gfx::Point menu_position(lb.origin());
|
||||
|
@ -135,12 +134,10 @@ void AutofillPopup::CreateView(
|
|||
|
||||
if (offscreen) {
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents->GetRenderWidgetHostView());
|
||||
frame_host_->GetView());
|
||||
view_->view_proxy_.reset(new OffscreenViewProxy(view_));
|
||||
osr_rwhv->AddViewProxy(view_->view_proxy_.get());
|
||||
}
|
||||
|
||||
frame_routing_id_ = routing_id;
|
||||
}
|
||||
|
||||
void AutofillPopup::Hide() {
|
||||
|
@ -161,8 +158,8 @@ void AutofillPopup::SetItems(const std::vector<base::string16>& values,
|
|||
}
|
||||
|
||||
void AutofillPopup::AcceptSuggestion(int index) {
|
||||
web_contents_->Send(new AtomAutofillViewMsg_AcceptSuggestion(
|
||||
frame_routing_id_, GetValueAt(index)));
|
||||
frame_host_->Send(new AtomAutofillFrameMsg_AcceptSuggestion(
|
||||
frame_host_->GetRoutingID(), GetValueAt(index)));
|
||||
}
|
||||
|
||||
void AutofillPopup::UpdatePopupBounds() {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "atom/browser/ui/views/autofill_popup_view.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "ui/gfx/font_list.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
@ -22,7 +22,7 @@ class AutofillPopup {
|
|||
explicit AutofillPopup(gfx::NativeView);
|
||||
~AutofillPopup();
|
||||
|
||||
void CreateView(int routing_id, content::WebContents* web_contents,
|
||||
void CreateView(content::RenderFrameHost* render_frame,
|
||||
bool offscreen, views::Widget* widget, const gfx::RectF& bounds);
|
||||
void Hide();
|
||||
|
||||
|
@ -69,10 +69,9 @@ class AutofillPopup {
|
|||
|
||||
// For sending the accepted suggestion to the render frame that
|
||||
// asked to open the popup
|
||||
int frame_routing_id_;
|
||||
content::WebContents* web_contents_;
|
||||
content::RenderFrameHost* frame_host_;
|
||||
|
||||
// The popup view
|
||||
// The popup view. The lifetime is managed by the owning Widget
|
||||
AutofillPopupView* view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AutofillPopup);
|
||||
|
|
|
@ -31,8 +31,9 @@ AutofillPopupView::AutofillPopupView(
|
|||
|
||||
AutofillPopupView::~AutofillPopupView() {
|
||||
if (popup_) {
|
||||
auto host = popup_->web_contents_->GetRenderViewHost()->GetWidget();
|
||||
auto host = popup_->frame_host_->GetRenderViewHost()->GetWidget();
|
||||
host->RemoveKeyPressEventCallback(keypress_callback_);
|
||||
popup_->view_ = nullptr;
|
||||
popup_ = nullptr;
|
||||
}
|
||||
|
||||
|
@ -92,23 +93,24 @@ void AutofillPopupView::Show() {
|
|||
|
||||
keypress_callback_ = base::Bind(&AutofillPopupView::HandleKeyPressEvent,
|
||||
base::Unretained(this));
|
||||
auto host = popup_->web_contents_->GetRenderViewHost()->GetWidget();
|
||||
auto host = popup_->frame_host_->GetRenderViewHost()->GetWidget();
|
||||
host->AddKeyPressEventCallback(keypress_callback_);
|
||||
|
||||
NotifyAccessibilityEvent(ui::AX_EVENT_MENU_START, true);
|
||||
}
|
||||
|
||||
void AutofillPopupView::Hide() {
|
||||
if (popup_) {
|
||||
auto host = popup_->web_contents_->GetRenderViewHost()->GetWidget();
|
||||
auto host = popup_->frame_host_->GetRenderViewHost()->GetWidget();
|
||||
host->RemoveKeyPressEventCallback(keypress_callback_);
|
||||
popup_ = NULL;
|
||||
popup_ = nullptr;
|
||||
}
|
||||
|
||||
RemoveObserver();
|
||||
NotifyAccessibilityEvent(ui::AX_EVENT_MENU_END, true);
|
||||
|
||||
if (GetWidget()) {
|
||||
GetWidget()->Close();
|
||||
} else {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue