🎨 lint fix
This commit is contained in:
parent
f360104bee
commit
4949531f57
8 changed files with 88 additions and 76 deletions
|
@ -749,7 +749,7 @@ void WebContents::RenderFrameCreated(content::RenderFrameHost* host) {
|
||||||
host->GetRoutingID(), routing_id()));
|
host->GetRoutingID(), routing_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
void WebContents::RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
||||||
content::RenderFrameHost* new_host) {
|
content::RenderFrameHost* new_host) {
|
||||||
Send(new AtomAutofillViewHostMsg_RoutingId(
|
Send(new AtomAutofillViewHostMsg_RoutingId(
|
||||||
new_host->GetRoutingID(), routing_id()));
|
new_host->GetRoutingID(), routing_id()));
|
||||||
|
@ -1628,14 +1628,14 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||||
void WebContents::OnShowAutofillPopup(
|
void WebContents::OnShowAutofillPopup(
|
||||||
int routing_id,
|
int routing_id,
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) {
|
const std::vector<base::string16>& labels) {
|
||||||
auto relay = reinterpret_cast<NativeWindowViews*>(
|
auto relay = reinterpret_cast<NativeWindowViews*>(
|
||||||
NativeWindow::FromWebContents(web_contents()));
|
NativeWindow::FromWebContents(web_contents()));
|
||||||
autofill_popup_->CreateView(
|
autofill_popup_->CreateView(
|
||||||
routing_id,
|
routing_id,
|
||||||
web_contents(),
|
web_contents(),
|
||||||
relay->widget(),
|
relay->widget(),
|
||||||
bounds);
|
bounds);
|
||||||
autofill_popup_->SetItems(values, labels);
|
autofill_popup_->SetItems(values, labels);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||||
void RenderViewCreated(content::RenderViewHost*) override;
|
void RenderViewCreated(content::RenderViewHost*) override;
|
||||||
void RenderFrameCreated(content::RenderFrameHost*) override;
|
void RenderFrameCreated(content::RenderFrameHost*) override;
|
||||||
void RenderFrameHostChanged(content::RenderFrameHost*,
|
void RenderFrameHostChanged(content::RenderFrameHost*,
|
||||||
content::RenderFrameHost*) override;
|
content::RenderFrameHost*) override;
|
||||||
void RenderViewDeleted(content::RenderViewHost*) override;
|
void RenderViewDeleted(content::RenderViewHost*) override;
|
||||||
void RenderProcessGone(base::TerminationStatus status) override;
|
void RenderProcessGone(base::TerminationStatus status) override;
|
||||||
|
@ -377,10 +377,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
|
|
||||||
// Called when we receive a CursorChange message from chromium.
|
// Called when we receive a CursorChange message from chromium.
|
||||||
void OnCursorChange(const content::WebCursor& cursor);
|
void OnCursorChange(const content::WebCursor& cursor);
|
||||||
|
|
||||||
void OnShowAutofillPopup(int routing_id,
|
void OnShowAutofillPopup(int routing_id,
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels);
|
const std::vector<base::string16>& labels);
|
||||||
void OnHideAutofillPopup();
|
void OnHideAutofillPopup();
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,18 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/browser/ui/autofill_popup.h"
|
#include "atom/browser/ui/autofill_popup.h"
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "ui/display/display.h"
|
#include "ui/display/display.h"
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
#include "ui/gfx/text_utils.h"
|
|
||||||
#include "ui/gfx/geometry/point.h"
|
#include "ui/gfx/geometry/point.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
#include "ui/gfx/geometry/vector2d.h"
|
#include "ui/gfx/geometry/vector2d.h"
|
||||||
|
#include "ui/gfx/text_utils.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -97,9 +101,9 @@ display::Display GetDisplayNearestPoint(
|
||||||
|
|
||||||
AutofillPopup::AutofillPopup(gfx::NativeView container_view)
|
AutofillPopup::AutofillPopup(gfx::NativeView container_view)
|
||||||
: container_view_(container_view) {
|
: container_view_(container_view) {
|
||||||
bold_font_list_ =
|
bold_font_list_ =
|
||||||
gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD);
|
gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD);
|
||||||
smaller_font_list_ =
|
smaller_font_list_ =
|
||||||
gfx::FontList().DeriveWithSizeDelta(kSmallerFontSizeDelta);
|
gfx::FontList().DeriveWithSizeDelta(kSmallerFontSizeDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,19 +114,20 @@ AutofillPopup::~AutofillPopup() {
|
||||||
void AutofillPopup::CreateView(
|
void AutofillPopup::CreateView(
|
||||||
int routing_id,
|
int routing_id,
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
views::Widget* parent_widget,
|
views::Widget* parent_widget,
|
||||||
const gfx::RectF& r) {
|
const gfx::RectF& r) {
|
||||||
web_contents_ = web_contents;
|
web_contents_ = web_contents;
|
||||||
gfx::Rect lb(std::floor(r.x()), std::floor(r.y() + r.height()),
|
gfx::Rect lb(std::floor(r.x()), std::floor(r.y() + r.height()),
|
||||||
std::floor(r.width()), std::floor(r.height()));
|
std::floor(r.width()), std::floor(r.height()));
|
||||||
gfx::Point menu_position(lb.origin());
|
gfx::Point menu_position(lb.origin());
|
||||||
views::View::ConvertPointToScreen(parent_widget->GetContentsView(), &menu_position);
|
views::View::ConvertPointToScreen(
|
||||||
|
parent_widget->GetContentsView(), &menu_position);
|
||||||
popup_bounds_ = gfx::Rect(menu_position, lb.size());
|
popup_bounds_ = gfx::Rect(menu_position, lb.size());
|
||||||
element_bounds_ = popup_bounds_;
|
element_bounds_ = popup_bounds_;
|
||||||
|
|
||||||
view_.reset(new AutofillPopupView(this, parent_widget));
|
view_.reset(new AutofillPopupView(this, parent_widget));
|
||||||
view_->Show();
|
view_->Show();
|
||||||
|
|
||||||
frame_routing_id_ = routing_id;
|
frame_routing_id_ = routing_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +157,7 @@ void AutofillPopup::UpdatePopupBounds() {
|
||||||
int desired_width = GetDesiredPopupWidth();
|
int desired_width = GetDesiredPopupWidth();
|
||||||
int desired_height = GetDesiredPopupHeight();
|
int desired_height = GetDesiredPopupHeight();
|
||||||
bool is_rtl = false;
|
bool is_rtl = false;
|
||||||
|
|
||||||
gfx::Point top_left_corner_of_popup =
|
gfx::Point top_left_corner_of_popup =
|
||||||
element_bounds_.origin() +
|
element_bounds_.origin() +
|
||||||
gfx::Vector2d(element_bounds_.width() - desired_width, -desired_height);
|
gfx::Vector2d(element_bounds_.width() - desired_width, -desired_height);
|
||||||
|
@ -187,10 +192,10 @@ int AutofillPopup::GetDesiredPopupWidth() {
|
||||||
int popup_width = element_bounds_.width();
|
int popup_width = element_bounds_.width();
|
||||||
|
|
||||||
for (int i = 0; i < values_.size(); ++i) {
|
for (int i = 0; i < values_.size(); ++i) {
|
||||||
int row_size = kEndPadding + 2 * kPopupBorderThickness +
|
int row_size = kEndPadding + 2 * kPopupBorderThickness +
|
||||||
gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) +
|
gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) +
|
||||||
gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i));
|
gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i));
|
||||||
if (GetLabelAt(i).length() > 0)
|
if (GetLabelAt(i).length() > 0)
|
||||||
row_size += kNamePadding + kEndPadding;
|
row_size += kNamePadding + kEndPadding;
|
||||||
|
|
||||||
popup_width = std::max(popup_width, row_size);
|
popup_width = std::max(popup_width, row_size);
|
||||||
|
@ -243,8 +248,8 @@ int AutofillPopup::LineFromY(int y) const {
|
||||||
if (y <= current_height)
|
if (y <= current_height)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return values_.size() - 1;
|
return values_.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
|
#ifndef ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
|
||||||
#define ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
|
#define ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/browser/ui/views/autofill_popup_view.h"
|
#include "atom/browser/ui/views/autofill_popup_view.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "ui/gfx/font_list.h"
|
#include "ui/gfx/font_list.h"
|
||||||
|
@ -14,23 +16,24 @@
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class AutofillPopupView;
|
class AutofillPopupView;
|
||||||
|
|
||||||
class AutofillPopup {
|
class AutofillPopup {
|
||||||
public:
|
public:
|
||||||
AutofillPopup(gfx::NativeView);
|
explicit AutofillPopup(gfx::NativeView);
|
||||||
~AutofillPopup();
|
~AutofillPopup();
|
||||||
|
|
||||||
void CreateView(int routing_id, content::WebContents* web_contents,
|
void CreateView(int routing_id, content::WebContents* web_contents,
|
||||||
views::Widget* widget, const gfx::RectF& bounds);
|
views::Widget* widget, const gfx::RectF& bounds);
|
||||||
void Hide();
|
void Hide();
|
||||||
|
|
||||||
void SetItems(const std::vector<base::string16>& values,
|
void SetItems(const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels);
|
const std::vector<base::string16>& labels);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AutofillPopupView;
|
friend class AutofillPopupView;
|
||||||
|
|
||||||
void AcceptSuggestion(int index);
|
void AcceptSuggestion(int index);
|
||||||
|
|
||||||
void UpdatePopupBounds();
|
void UpdatePopupBounds();
|
||||||
int GetDesiredPopupHeight();
|
int GetDesiredPopupHeight();
|
||||||
int GetDesiredPopupWidth();
|
int GetDesiredPopupWidth();
|
||||||
|
@ -38,36 +41,36 @@ class AutofillPopup {
|
||||||
const gfx::FontList& GetValueFontListForRow(int index) const;
|
const gfx::FontList& GetValueFontListForRow(int index) const;
|
||||||
const gfx::FontList& GetLabelFontListForRow(int index) const;
|
const gfx::FontList& GetLabelFontListForRow(int index) const;
|
||||||
ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
|
ui::NativeTheme::ColorId GetBackgroundColorIDForRow(int index) const;
|
||||||
|
|
||||||
int GetLineCount();
|
int GetLineCount();
|
||||||
base::string16 GetValueAt(int i);
|
base::string16 GetValueAt(int i);
|
||||||
base::string16 GetLabelAt(int i);
|
base::string16 GetLabelAt(int i);
|
||||||
int LineFromY(int y) const;
|
int LineFromY(int y) const;
|
||||||
|
|
||||||
// The native view that contains this
|
// The native view that contains this
|
||||||
gfx::NativeView container_view_;
|
gfx::NativeView container_view_;
|
||||||
|
|
||||||
int selected_index_;
|
int selected_index_;
|
||||||
|
|
||||||
// Popup location
|
// Popup location
|
||||||
gfx::Rect popup_bounds_;
|
gfx::Rect popup_bounds_;
|
||||||
|
|
||||||
// Bounds of the autofilled element
|
// Bounds of the autofilled element
|
||||||
gfx::Rect element_bounds_;
|
gfx::Rect element_bounds_;
|
||||||
|
|
||||||
// Datalist suggestions
|
// Datalist suggestions
|
||||||
std::vector<base::string16> values_;
|
std::vector<base::string16> values_;
|
||||||
std::vector<base::string16> labels_;
|
std::vector<base::string16> labels_;
|
||||||
|
|
||||||
// Font lists for the suggestions
|
// Font lists for the suggestions
|
||||||
gfx::FontList smaller_font_list_;
|
gfx::FontList smaller_font_list_;
|
||||||
gfx::FontList bold_font_list_;
|
gfx::FontList bold_font_list_;
|
||||||
|
|
||||||
// For sending the accepted suggestion to the render frame that
|
// For sending the accepted suggestion to the render frame that
|
||||||
// asked to open the popup
|
// asked to open the popup
|
||||||
int frame_routing_id_;
|
int frame_routing_id_;
|
||||||
content::WebContents* web_contents_;
|
content::WebContents* web_contents_;
|
||||||
|
|
||||||
// The popup view
|
// The popup view
|
||||||
std::unique_ptr<AutofillPopupView> view_;
|
std::unique_ptr<AutofillPopupView> view_;
|
||||||
|
|
||||||
|
@ -76,4 +79,4 @@ class AutofillPopup {
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
|
#endif // ATOM_BROWSER_UI_AUTOFILL_POPUP_H_
|
||||||
|
|
|
@ -80,7 +80,7 @@ void AutofillPopupView::Show() {
|
||||||
|
|
||||||
if (initialize_widget)
|
if (initialize_widget)
|
||||||
views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
|
views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
|
||||||
|
|
||||||
keypress_callback_ = base::Bind(&AutofillPopupView::HandleKeyPressEvent,
|
keypress_callback_ = base::Bind(&AutofillPopupView::HandleKeyPressEvent,
|
||||||
base::Unretained(this));
|
base::Unretained(this));
|
||||||
auto host = popup_->web_contents_->GetRenderViewHost()->GetWidget();
|
auto host = popup_->web_contents_->GetRenderViewHost()->GetWidget();
|
||||||
|
@ -129,13 +129,13 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
|
||||||
entry_rect,
|
entry_rect,
|
||||||
GetNativeTheme()->GetSystemColor(
|
GetNativeTheme()->GetSystemColor(
|
||||||
popup_->GetBackgroundColorIDForRow(index)));
|
popup_->GetBackgroundColorIDForRow(index)));
|
||||||
|
|
||||||
const bool is_rtl = false;
|
const bool is_rtl = false;
|
||||||
const int text_align =
|
const int text_align =
|
||||||
is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
|
is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
|
||||||
gfx::Rect value_rect = entry_rect;
|
gfx::Rect value_rect = entry_rect;
|
||||||
value_rect.Inset(kEndPadding, 0);
|
value_rect.Inset(kEndPadding, 0);
|
||||||
|
|
||||||
int x_align_left = value_rect.x();
|
int x_align_left = value_rect.x();
|
||||||
const int value_width = gfx::GetStringWidth(
|
const int value_width = gfx::GetStringWidth(
|
||||||
popup_->GetValueAt(index),
|
popup_->GetValueAt(index),
|
||||||
|
@ -143,7 +143,7 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
|
||||||
int value_x_align_left = x_align_left;
|
int value_x_align_left = x_align_left;
|
||||||
value_x_align_left =
|
value_x_align_left =
|
||||||
is_rtl ? value_rect.right() - value_width : value_rect.x();
|
is_rtl ? value_rect.right() - value_width : value_rect.x();
|
||||||
|
|
||||||
canvas->DrawStringRectWithFlags(
|
canvas->DrawStringRectWithFlags(
|
||||||
popup_->GetValueAt(index),
|
popup_->GetValueAt(index),
|
||||||
popup_->GetValueFontListForRow(index),
|
popup_->GetValueFontListForRow(index),
|
||||||
|
@ -159,7 +159,7 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
|
||||||
popup_->GetLabelAt(index),
|
popup_->GetLabelAt(index),
|
||||||
popup_->GetLabelFontListForRow(index));
|
popup_->GetLabelFontListForRow(index));
|
||||||
int label_x_align_left = x_align_left;
|
int label_x_align_left = x_align_left;
|
||||||
label_x_align_left =
|
label_x_align_left =
|
||||||
is_rtl ? value_rect.x() : value_rect.right() - label_width;
|
is_rtl ? value_rect.x() : value_rect.right() - label_width;
|
||||||
|
|
||||||
canvas->DrawStringRectWithFlags(
|
canvas->DrawStringRectWithFlags(
|
||||||
|
@ -191,15 +191,15 @@ void AutofillPopupView::DoUpdateBoundsAndRedrawPopup() {
|
||||||
void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
|
void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
|
||||||
if (!popup_)
|
if (!popup_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
canvas->DrawColor(GetNativeTheme()->GetSystemColor(
|
canvas->DrawColor(GetNativeTheme()->GetSystemColor(
|
||||||
ui::NativeTheme::kColorId_ResultsTableNormalBackground));
|
ui::NativeTheme::kColorId_ResultsTableNormalBackground));
|
||||||
OnPaintBorder(canvas);
|
OnPaintBorder(canvas);
|
||||||
|
|
||||||
DCHECK_EQ(popup_->GetLineCount(), child_count());
|
DCHECK_EQ(popup_->GetLineCount(), child_count());
|
||||||
for (int i = 0; i < popup_->GetLineCount(); ++i) {
|
for (int i = 0; i < popup_->GetLineCount(); ++i) {
|
||||||
gfx::Rect line_rect = popup_->GetRowBounds(i);
|
gfx::Rect line_rect = popup_->GetRowBounds(i);
|
||||||
|
|
||||||
DrawAutofillEntry(canvas, i, line_rect);
|
DrawAutofillEntry(canvas, i, line_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,4 +411,4 @@ void AutofillPopupView::RemoveObserver() {
|
||||||
views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this);
|
views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -57,12 +57,12 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
explicit AutofillPopupView(AutofillPopup* popup,
|
explicit AutofillPopupView(AutofillPopup* popup,
|
||||||
views::Widget* parent_widget);
|
views::Widget* parent_widget);
|
||||||
~AutofillPopupView() override;
|
~AutofillPopupView() override;
|
||||||
|
|
||||||
void Show();
|
void Show();
|
||||||
void Hide();
|
void Hide();
|
||||||
|
|
||||||
void OnSuggestionsChanged();
|
void OnSuggestionsChanged();
|
||||||
|
|
||||||
int GetSelectedLine() { return selected_line_.value_or(-1); }
|
int GetSelectedLine() { return selected_line_.value_or(-1); }
|
||||||
|
|
||||||
void WriteDragDataForView(
|
void WriteDragDataForView(
|
||||||
|
@ -71,8 +71,8 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
return ui::DragDropTypes::DRAG_NONE;
|
return ui::DragDropTypes::DRAG_NONE;
|
||||||
}
|
}
|
||||||
bool CanStartDragForView(
|
bool CanStartDragForView(
|
||||||
views::View*, const gfx::Point&, const gfx::Point&) override {
|
views::View*, const gfx::Point&, const gfx::Point&) override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -88,9 +88,9 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
// child views are used for accessibility events only. We need child views to
|
// child views are used for accessibility events only. We need child views to
|
||||||
// populate the correct |AXNodeData| when user selects a suggestion.
|
// populate the correct |AXNodeData| when user selects a suggestion.
|
||||||
void CreateChildViews();
|
void CreateChildViews();
|
||||||
|
|
||||||
void DoUpdateBoundsAndRedrawPopup();
|
void DoUpdateBoundsAndRedrawPopup();
|
||||||
|
|
||||||
// views::Views implementation.
|
// views::Views implementation.
|
||||||
void OnPaint(gfx::Canvas* canvas) override;
|
void OnPaint(gfx::Canvas* canvas) override;
|
||||||
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
|
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
|
||||||
|
@ -103,7 +103,7 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
void OnGestureEvent(ui::GestureEvent* event) override;
|
void OnGestureEvent(ui::GestureEvent* event) override;
|
||||||
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
||||||
bool HandleKeyPressEvent(const content::NativeWebKeyboardEvent& event);
|
bool HandleKeyPressEvent(const content::NativeWebKeyboardEvent& event);
|
||||||
|
|
||||||
// views::WidgetFocusChangeListener implementation.
|
// views::WidgetFocusChangeListener implementation.
|
||||||
void OnNativeFocusChanged(gfx::NativeView focused_now) override;
|
void OnNativeFocusChanged(gfx::NativeView focused_now) override;
|
||||||
|
|
||||||
|
@ -131,10 +131,10 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
|
|
||||||
// The time when the popup was shown.
|
// The time when the popup was shown.
|
||||||
base::Time show_time_;
|
base::Time show_time_;
|
||||||
|
|
||||||
// The index of the currently selected line
|
// The index of the currently selected line
|
||||||
base::Optional<int> selected_line_;
|
base::Optional<int> selected_line_;
|
||||||
|
|
||||||
// The registered keypress callback, responsible for switching lines on
|
// The registered keypress callback, responsible for switching lines on
|
||||||
// key presses
|
// key presses
|
||||||
content::RenderWidgetHost::KeyPressEventCallback keypress_callback_;
|
content::RenderWidgetHost::KeyPressEventCallback keypress_callback_;
|
||||||
|
@ -144,4 +144,4 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_BROWSER_UI_VIEWS_AUTOFILL_POPUP_VIEW_H_
|
#endif // ATOM_BROWSER_UI_VIEWS_AUTOFILL_POPUP_VIEW_H_
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "atom/renderer/atom_autofill_agent.h"
|
#include "atom/renderer/atom_autofill_agent.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
|
@ -17,11 +19,11 @@
|
||||||
#include "ui/gfx/geometry/rect_f.h"
|
#include "ui/gfx/geometry/rect_f.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const size_t kMaxDataLength = 1024;
|
const size_t kMaxDataLength = 1024;
|
||||||
const size_t kMaxListSize = 512;
|
const size_t kMaxListSize = 512;
|
||||||
|
|
||||||
void GetDataListSuggestions(const blink::WebInputElement& element,
|
void GetDataListSuggestions(const blink::WebInputElement& element,
|
||||||
std::vector<base::string16>* values,
|
std::vector<base::string16>* values,
|
||||||
std::vector<base::string16>* labels) {
|
std::vector<base::string16>* labels) {
|
||||||
|
@ -45,7 +47,7 @@ void TrimStringVectorForIPC(std::vector<base::string16>* strings) {
|
||||||
(*strings)[i].resize(kMaxDataLength);
|
(*strings)[i].resize(kMaxDataLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AutofillAgent::AutofillAgent(
|
AutofillAgent::AutofillAgent(
|
||||||
content::RenderFrame* frame)
|
content::RenderFrame* frame)
|
||||||
|
@ -73,10 +75,10 @@ void AutofillAgent::textFieldDidEndEditing(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillAgent::textFieldDidChange(
|
void AutofillAgent::textFieldDidChange(
|
||||||
const blink::WebFormControlElement& element) {
|
const blink::WebFormControlElement& element) {
|
||||||
if (!IsUserGesture() && !render_frame()->IsPasting())
|
if (!IsUserGesture() && !render_frame()->IsPasting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||||
FROM_HERE, base::Bind(&AutofillAgent::textFieldDidChangeImpl,
|
FROM_HERE, base::Bind(&AutofillAgent::textFieldDidChangeImpl,
|
||||||
|
@ -84,14 +86,14 @@ void AutofillAgent::textFieldDidChange(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillAgent::textFieldDidChangeImpl(
|
void AutofillAgent::textFieldDidChangeImpl(
|
||||||
const blink::WebFormControlElement& element) {
|
const blink::WebFormControlElement& element) {
|
||||||
ShowSuggestionsOptions options;
|
ShowSuggestionsOptions options;
|
||||||
options.requires_caret_at_end = true;
|
options.requires_caret_at_end = true;
|
||||||
ShowSuggestions(element, options);
|
ShowSuggestions(element, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillAgent::textFieldDidReceiveKeyDown(
|
void AutofillAgent::textFieldDidReceiveKeyDown(
|
||||||
const blink::WebInputElement& element,
|
const blink::WebInputElement& element,
|
||||||
const blink::WebKeyboardEvent& event) {
|
const blink::WebKeyboardEvent& event) {
|
||||||
if (event.windowsKeyCode == ui::VKEY_DOWN ||
|
if (event.windowsKeyCode == ui::VKEY_DOWN ||
|
||||||
event.windowsKeyCode == ui::VKEY_UP) {
|
event.windowsKeyCode == ui::VKEY_UP) {
|
||||||
|
@ -113,7 +115,7 @@ void AutofillAgent::dataListOptionsChanged(
|
||||||
const blink::WebInputElement& element) {
|
const blink::WebInputElement& element) {
|
||||||
if (!element.focused())
|
if (!element.focused())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ShowSuggestionsOptions options;
|
ShowSuggestionsOptions options;
|
||||||
options.requires_caret_at_end = true;
|
options.requires_caret_at_end = true;
|
||||||
ShowSuggestions(element, options);
|
ShowSuggestions(element, options);
|
||||||
|
@ -136,7 +138,7 @@ void AutofillAgent::ShowSuggestions(
|
||||||
if (!input_element->isTextField())
|
if (!input_element->isTextField())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blink::WebString value = element.editingValue();
|
blink::WebString value = element.editingValue();
|
||||||
if (value.length() > kMaxDataLength ||
|
if (value.length() > kMaxDataLength ||
|
||||||
(!options.autofill_on_empty_values && value.isEmpty()) ||
|
(!options.autofill_on_empty_values && value.isEmpty()) ||
|
||||||
|
@ -146,7 +148,7 @@ void AutofillAgent::ShowSuggestions(
|
||||||
HidePopup();
|
HidePopup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<base::string16> data_list_values;
|
std::vector<base::string16> data_list_values;
|
||||||
std::vector<base::string16> data_list_labels;
|
std::vector<base::string16> data_list_labels;
|
||||||
if (input_element) {
|
if (input_element) {
|
||||||
|
@ -155,7 +157,7 @@ void AutofillAgent::ShowSuggestions(
|
||||||
TrimStringVectorForIPC(&data_list_values);
|
TrimStringVectorForIPC(&data_list_values);
|
||||||
TrimStringVectorForIPC(&data_list_labels);
|
TrimStringVectorForIPC(&data_list_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowPopup(element, data_list_values, data_list_labels);
|
ShowPopup(element, data_list_values, data_list_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,10 +198,10 @@ void AutofillAgent::ShowPopup(
|
||||||
const blink::WebFormControlElement& element,
|
const blink::WebFormControlElement& element,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) {
|
const std::vector<base::string16>& labels) {
|
||||||
gfx::RectF bounds =
|
gfx::RectF bounds =
|
||||||
render_frame_->GetRenderView()->ElementBoundsInWindow(element);
|
render_frame_->GetRenderView()->ElementBoundsInWindow(element);
|
||||||
Send(new AtomAutofillViewMsg_ShowPopup(
|
Send(new AtomAutofillViewMsg_ShowPopup(
|
||||||
web_contents_routing_id_, routing_id(), bounds, values, labels));
|
web_contents_routing_id_, routing_id(), bounds, values, labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef ATOM_RENDERER_ATOM_AUTOFILL_AGENT_H_
|
#ifndef ATOM_RENDERER_ATOM_AUTOFILL_AGENT_H_
|
||||||
#define ATOM_RENDERER_ATOM_AUTOFILL_AGENT_H_
|
#define ATOM_RENDERER_ATOM_AUTOFILL_AGENT_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "content/public/renderer/render_frame_observer.h"
|
#include "content/public/renderer/render_frame_observer.h"
|
||||||
#include "third_party/WebKit/public/web/WebAutofillClient.h"
|
#include "third_party/WebKit/public/web/WebAutofillClient.h"
|
||||||
|
@ -14,14 +16,14 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class AutofillAgent : public content::RenderFrameObserver,
|
class AutofillAgent : public content::RenderFrameObserver,
|
||||||
public blink::WebAutofillClient {
|
public blink::WebAutofillClient {
|
||||||
public:
|
public:
|
||||||
AutofillAgent(content::RenderFrame* frame);
|
explicit AutofillAgent(content::RenderFrame* frame);
|
||||||
|
|
||||||
// content::RenderFrameObserver:
|
// content::RenderFrameObserver:
|
||||||
void OnDestruct() override;
|
void OnDestruct() override;
|
||||||
|
|
||||||
void DidChangeScrollOffset() override;
|
void DidChangeScrollOffset() override;
|
||||||
void FocusedNodeChanged(const blink::WebNode&) override;
|
void FocusedNodeChanged(const blink::WebNode&) override;
|
||||||
|
|
||||||
|
@ -31,9 +33,9 @@ class AutofillAgent : public content::RenderFrameObserver,
|
||||||
bool autofill_on_empty_values;
|
bool autofill_on_empty_values;
|
||||||
bool requires_caret_at_end;
|
bool requires_caret_at_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
void OnWebContentsRoutingIdReceived(int);
|
void OnWebContentsRoutingIdReceived(int routing_id);
|
||||||
|
|
||||||
// blink::WebAutofillClient:
|
// blink::WebAutofillClient:
|
||||||
void textFieldDidEndEditing(const blink::WebInputElement&) override;
|
void textFieldDidEndEditing(const blink::WebInputElement&) override;
|
||||||
|
@ -43,7 +45,7 @@ class AutofillAgent : public content::RenderFrameObserver,
|
||||||
const blink::WebKeyboardEvent&) override;
|
const blink::WebKeyboardEvent&) override;
|
||||||
void openTextDataListChooser(const blink::WebInputElement&) override;
|
void openTextDataListChooser(const blink::WebInputElement&) override;
|
||||||
void dataListOptionsChanged(const blink::WebInputElement&) override;
|
void dataListOptionsChanged(const blink::WebInputElement&) override;
|
||||||
|
|
||||||
bool IsUserGesture() const;
|
bool IsUserGesture() const;
|
||||||
void HidePopup();
|
void HidePopup();
|
||||||
void ShowPopup(const blink::WebFormControlElement&,
|
void ShowPopup(const blink::WebFormControlElement&,
|
||||||
|
|
Loading…
Reference in a new issue