Commit 4f8a1ad4 authored by Imranur Rahman's avatar Imranur Rahman Committed by Commit Bot

Correcting AutofillPopupRowView C++ style rules.

Protected member variables of AutofillPopupRowView is
made public. Also, DISALLOW_COPY_AND_ASSIGN is used in
AutofillPopupRowView.

Bug: 1001633
Signed-off-by: default avatarImranur Rahman <i.rahman@samsung.com>
Change-Id: Ia6e5163b601f01e05a9b9685bcea37c1630684a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1798224
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697284}
parent 42f981be
...@@ -366,6 +366,7 @@ Ibrar Ahmed <ibrar.ahmad@gmail.com> ...@@ -366,6 +366,7 @@ Ibrar Ahmed <ibrar.ahmad@gmail.com>
Ilia Demianenko <ilia.demianenko@gmail.com> Ilia Demianenko <ilia.demianenko@gmail.com>
Ilia K <ki.stfu@gmail.com> Ilia K <ki.stfu@gmail.com>
Ilya Konstantinov <ilya.konstantinov@gmail.com> Ilya Konstantinov <ilya.konstantinov@gmail.com>
Imranur Rahman <i.rahman@samsung.com>
Imranur Rahman <ir.shimul@gmail.com> Imranur Rahman <ir.shimul@gmail.com>
Ion Rosca <rosca@adobe.com> Ion Rosca <rosca@adobe.com>
Irmak Kavasoglu <irmakkavasoglu@gmail.com> Irmak Kavasoglu <irmakkavasoglu@gmail.com>
......
...@@ -317,8 +317,8 @@ class AutofillPopupWarningView : public AutofillPopupRowView { ...@@ -317,8 +317,8 @@ class AutofillPopupWarningView : public AutofillPopupRowView {
/************** AutofillPopupItemView **************/ /************** AutofillPopupItemView **************/
void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
auto suggestion = controller->GetSuggestionAt(line_number_); auto suggestion = controller->GetSuggestionAt(line_number());
std::vector<base::string16> text; std::vector<base::string16> text;
text.push_back(suggestion.value); text.push_back(suggestion.value);
...@@ -337,17 +337,17 @@ void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -337,17 +337,17 @@ void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
// Options are selectable. // Options are selectable.
node_data->role = ax::mojom::Role::kMenuItem; node_data->role = ax::mojom::Role::kMenuItem;
node_data->AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, node_data->AddBoolAttribute(ax::mojom::BoolAttribute::kSelected,
is_selected_); is_selected());
// Compute set size and position in set, by checking the frontend_id of each // Compute set size and position in set, by checking the frontend_id of each
// row, summing the number of non-separator rows, and subtracting the number // row, summing the number of non-separator rows, and subtracting the number
// of separators found before this row from its |pos_in_set|. // of separators found before this row from its |pos_in_set|.
int set_size = 0; int set_size = 0;
int pos_in_set = line_number_ + 1; int pos_in_set = line_number() + 1;
for (int i = 0; i < controller->GetLineCount(); ++i) { for (int i = 0; i < controller->GetLineCount(); ++i) {
if (controller->GetSuggestionAt(i).frontend_id == if (controller->GetSuggestionAt(i).frontend_id ==
autofill::POPUP_ITEM_ID_SEPARATOR) { autofill::POPUP_ITEM_ID_SEPARATOR) {
if (i < line_number_) if (i < line_number())
--pos_in_set; --pos_in_set;
} else { } else {
++set_size; ++set_size;
...@@ -358,27 +358,27 @@ void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -358,27 +358,27 @@ void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
} }
void AutofillPopupItemView::OnMouseEntered(const ui::MouseEvent& event) { void AutofillPopupItemView::OnMouseEntered(const ui::MouseEvent& event) {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
if (controller) if (controller)
controller->SetSelectedLine(line_number_); controller->SetSelectedLine(line_number());
} }
void AutofillPopupItemView::OnMouseExited(const ui::MouseEvent& event) { void AutofillPopupItemView::OnMouseExited(const ui::MouseEvent& event) {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
if (controller) if (controller)
controller->SelectionCleared(); controller->SelectionCleared();
} }
void AutofillPopupItemView::OnMouseReleased(const ui::MouseEvent& event) { void AutofillPopupItemView::OnMouseReleased(const ui::MouseEvent& event) {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
if (controller && event.IsOnlyLeftMouseButton() && if (controller && event.IsOnlyLeftMouseButton() &&
HitTestPoint(event.location())) { HitTestPoint(event.location())) {
controller->AcceptSuggestion(line_number_); controller->AcceptSuggestion(line_number());
} }
} }
void AutofillPopupItemView::CreateContent() { void AutofillPopupItemView::CreateContent() {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
auto* layout_manager = SetLayoutManager(std::make_unique<views::BoxLayout>( auto* layout_manager = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, views::BoxLayout::Orientation::kHorizontal,
...@@ -388,7 +388,7 @@ void AutofillPopupItemView::CreateContent() { ...@@ -388,7 +388,7 @@ void AutofillPopupItemView::CreateContent() {
views::BoxLayout::CrossAxisAlignment::kCenter); views::BoxLayout::CrossAxisAlignment::kCenter);
const gfx::ImageSkia icon = const gfx::ImageSkia icon =
controller->layout_model().GetIconImage(line_number_); controller->layout_model().GetIconImage(line_number());
if (!icon.isNull()) { if (!icon.isNull()) {
AddIcon(icon); AddIcon(icon);
...@@ -434,15 +434,15 @@ void AutofillPopupItemView::RefreshStyle() { ...@@ -434,15 +434,15 @@ void AutofillPopupItemView::RefreshStyle() {
std::unique_ptr<views::View> AutofillPopupItemView::CreateValueLabel() { std::unique_ptr<views::View> AutofillPopupItemView::CreateValueLabel() {
// TODO(crbug.com/831603): Remove elision responsibilities from controller. // TODO(crbug.com/831603): Remove elision responsibilities from controller.
base::string16 text = base::string16 text =
popup_view_->controller()->GetElidedValueAt(line_number_); popup_view()->controller()->GetElidedValueAt(line_number());
if (popup_view_->controller() if (popup_view()->controller()
->GetSuggestionAt(line_number_) ->GetSuggestionAt(line_number())
.is_value_secondary) { .is_value_secondary) {
return CreateSecondaryLabel(text); return CreateSecondaryLabel(text);
} }
auto text_label = CreateLabelWithStyleAndContext( auto text_label = CreateLabelWithStyleAndContext(
popup_view_->controller()->GetElidedValueAt(line_number_), popup_view()->controller()->GetElidedValueAt(line_number()),
ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, GetPrimaryTextStyle()); ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, GetPrimaryTextStyle());
const gfx::Font::Weight font_weight = GetPrimaryTextWeight(); const gfx::Font::Weight font_weight = GetPrimaryTextWeight();
...@@ -512,8 +512,8 @@ AutofillPopupSuggestionView* AutofillPopupSuggestionView::Create( ...@@ -512,8 +512,8 @@ AutofillPopupSuggestionView* AutofillPopupSuggestionView::Create(
std::unique_ptr<views::Background> std::unique_ptr<views::Background>
AutofillPopupSuggestionView::CreateBackground() { AutofillPopupSuggestionView::CreateBackground() {
return is_selected_ ? views::CreateSolidBackground( return is_selected() ? views::CreateSolidBackground(
popup_view_->GetSelectedBackgroundColor()) popup_view()->GetSelectedBackgroundColor())
: nullptr; : nullptr;
} }
...@@ -535,7 +535,7 @@ AutofillPopupSuggestionView::AutofillPopupSuggestionView( ...@@ -535,7 +535,7 @@ AutofillPopupSuggestionView::AutofillPopupSuggestionView(
std::unique_ptr<views::View> AutofillPopupSuggestionView::CreateSubtextLabel() { std::unique_ptr<views::View> AutofillPopupSuggestionView::CreateSubtextLabel() {
base::string16 label_text = base::string16 label_text =
popup_view_->controller()->GetSuggestionAt(line_number_).label; popup_view()->controller()->GetSuggestionAt(line_number()).label;
if (label_text.empty()) if (label_text.empty())
return nullptr; return nullptr;
...@@ -590,9 +590,9 @@ PasswordPopupSuggestionView::PasswordPopupSuggestionView( ...@@ -590,9 +590,9 @@ PasswordPopupSuggestionView::PasswordPopupSuggestionView(
int line_number, int line_number,
int frontend_id) int frontend_id)
: AutofillPopupSuggestionView(popup_view, line_number, frontend_id) { : AutofillPopupSuggestionView(popup_view, line_number, frontend_id) {
origin_ = popup_view_->controller()->GetElidedLabelAt(line_number_); origin_ = popup_view->controller()->GetElidedLabelAt(line_number);
masked_password_ = masked_password_ =
popup_view_->controller()->GetSuggestionAt(line_number_).additional_label; popup_view->controller()->GetSuggestionAt(line_number).additional_label;
} }
/************** AutofillPopupFooterView **************/ /************** AutofillPopupFooterView **************/
...@@ -614,9 +614,9 @@ void AutofillPopupFooterView::CreateContent() { ...@@ -614,9 +614,9 @@ void AutofillPopupFooterView::CreateContent() {
/*left=*/0, /*left=*/0,
/*bottom=*/0, /*bottom=*/0,
/*right=*/0, /*right=*/0,
/*color=*/popup_view_->GetSeparatorColor())); /*color=*/popup_view()->GetSeparatorColor()));
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
views::BoxLayout* layout_manager = views::BoxLayout* layout_manager =
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
...@@ -627,7 +627,7 @@ void AutofillPopupFooterView::CreateContent() { ...@@ -627,7 +627,7 @@ void AutofillPopupFooterView::CreateContent() {
views::BoxLayout::CrossAxisAlignment::kStretch); views::BoxLayout::CrossAxisAlignment::kStretch);
const gfx::ImageSkia icon = const gfx::ImageSkia icon =
controller->layout_model().GetIconImage(line_number_); controller->layout_model().GetIconImage(line_number());
// A FooterView shows an icon, if any, on the trailing (right in LTR) side, // A FooterView shows an icon, if any, on the trailing (right in LTR) side,
// but the Show Account Cards context is an anomaly. Its icon is on the // but the Show Account Cards context is an anomaly. Its icon is on the
...@@ -660,8 +660,8 @@ void AutofillPopupFooterView::CreateContent() { ...@@ -660,8 +660,8 @@ void AutofillPopupFooterView::CreateContent() {
} }
std::unique_ptr<views::Background> AutofillPopupFooterView::CreateBackground() { std::unique_ptr<views::Background> AutofillPopupFooterView::CreateBackground() {
return is_selected_ ? views::CreateSolidBackground( return is_selected() ? views::CreateSolidBackground(
popup_view_->GetSelectedBackgroundColor()) popup_view()->GetSelectedBackgroundColor())
: nullptr; : nullptr;
} }
...@@ -703,7 +703,7 @@ void AutofillPopupSeparatorView::CreateContent() { ...@@ -703,7 +703,7 @@ void AutofillPopupSeparatorView::CreateContent() {
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
views::Separator* separator = new views::Separator(); views::Separator* separator = new views::Separator();
separator->SetColor(popup_view_->GetSeparatorColor()); separator->SetColor(popup_view()->GetSeparatorColor());
// Add some spacing between the the previous item and the separator. // Add some spacing between the the previous item and the separator.
separator->SetPreferredHeight( separator->SetPreferredHeight(
views::MenuConfig::instance().separator_thickness); views::MenuConfig::instance().separator_thickness);
...@@ -745,16 +745,16 @@ AutofillPopupWarningView* AutofillPopupWarningView::Create( ...@@ -745,16 +745,16 @@ AutofillPopupWarningView* AutofillPopupWarningView::Create(
void AutofillPopupWarningView::GetAccessibleNodeData( void AutofillPopupWarningView::GetAccessibleNodeData(
ui::AXNodeData* node_data) { ui::AXNodeData* node_data) {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
if (!controller) if (!controller)
return; return;
node_data->SetName(controller->GetSuggestionAt(line_number_).value); node_data->SetName(controller->GetSuggestionAt(line_number()).value);
node_data->role = ax::mojom::Role::kStaticText; node_data->role = ax::mojom::Role::kStaticText;
} }
void AutofillPopupWarningView::CreateContent() { void AutofillPopupWarningView::CreateContent() {
AutofillPopupController* controller = popup_view_->controller(); AutofillPopupController* controller = popup_view()->controller();
int horizontal_margin = GetHorizontalMargin(); int horizontal_margin = GetHorizontalMargin();
int vertical_margin = AutofillPopupBaseView::GetCornerRadius(); int vertical_margin = AutofillPopupBaseView::GetCornerRadius();
...@@ -764,9 +764,9 @@ void AutofillPopupWarningView::CreateContent() { ...@@ -764,9 +764,9 @@ void AutofillPopupWarningView::CreateContent() {
gfx::Insets(vertical_margin, horizontal_margin))); gfx::Insets(vertical_margin, horizontal_margin)));
auto text_label = CreateLabelWithColorReadabilityDisabled( auto text_label = CreateLabelWithColorReadabilityDisabled(
controller->GetElidedValueAt(line_number_), controller->GetElidedValueAt(line_number()),
ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, ChromeTextStyle::STYLE_RED); ChromeTextContext::CONTEXT_BODY_TEXT_LARGE, ChromeTextStyle::STYLE_RED);
text_label->SetEnabledColor(popup_view_->GetWarningColor()); text_label->SetEnabledColor(popup_view()->GetWarningColor());
text_label->SetMultiLine(true); text_label->SetMultiLine(true);
int max_width = int max_width =
std::min(kAutofillPopupMaxWidth, std::min(kAutofillPopupMaxWidth,
......
...@@ -51,13 +51,20 @@ class AutofillPopupRowView : public views::View { ...@@ -51,13 +51,20 @@ class AutofillPopupRowView : public views::View {
// method which calls Init before returning. // method which calls Init before returning.
void Init(); void Init();
AutofillPopupViewNativeViews* popup_view() { return popup_view_; }
int line_number() const { return line_number_; }
bool is_selected() const { return is_selected_; }
virtual void CreateContent() = 0; virtual void CreateContent() = 0;
virtual void RefreshStyle() = 0; virtual void RefreshStyle() = 0;
virtual std::unique_ptr<views::Background> CreateBackground() = 0; virtual std::unique_ptr<views::Background> CreateBackground() = 0;
private:
AutofillPopupViewNativeViews* popup_view_; AutofillPopupViewNativeViews* popup_view_;
const int line_number_; const int line_number_;
bool is_selected_ = false; bool is_selected_ = false;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupRowView);
}; };
// Views implementation for the autofill and password suggestion. // Views implementation for the autofill and password suggestion.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment