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