Commit 589de7d8 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

OmniboxMatchCellView cleanup, part 1.

Make overrides match superclass access level and order, and make definition
order match declaration order.  No code change, just reordering.

TBR=manukh

Bug: none
Change-Id: I4b36f022553781573244c99b47351d4a05cbb74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1812378Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697885}
parent 24d0cc75
...@@ -153,12 +153,14 @@ class RoundedCornerImageView : public views::ImageView { ...@@ -153,12 +153,14 @@ class RoundedCornerImageView : public views::ImageView {
public: public:
RoundedCornerImageView() = default; RoundedCornerImageView() = default;
// views::ImageView:
bool CanProcessEventsWithinSubtree() const override { return false; } bool CanProcessEventsWithinSubtree() const override { return false; }
private: protected:
// views::ImageView: // views::ImageView:
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
private:
DISALLOW_COPY_AND_ASSIGN(RoundedCornerImageView); DISALLOW_COPY_AND_ASSIGN(RoundedCornerImageView);
}; };
...@@ -194,41 +196,6 @@ OmniboxMatchCellView::OmniboxMatchCellView(OmniboxResultView* result_view) { ...@@ -194,41 +196,6 @@ OmniboxMatchCellView::OmniboxMatchCellView(OmniboxResultView* result_view) {
OmniboxMatchCellView::~OmniboxMatchCellView() = default; OmniboxMatchCellView::~OmniboxMatchCellView() = default;
gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const {
int height = 0;
switch (layout_style_) {
case LayoutStyle::OLD_ANSWER: {
int icon_width = icon_view_->width();
int answer_image_size =
answer_image_view_->GetImage().isNull()
? 0
: answer_image_view_->height() + kAnswerIconToTextPadding;
int deduction =
icon_width + (HorizontalPadding() * 3) + answer_image_size;
int description_width = std::max(width() - deduction, 0);
height = content_view_->GetLineHeight() +
description_view_->GetHeightForWidth(description_width);
break;
}
case LayoutStyle::ONE_LINE_SUGGESTION: {
height = content_view_->GetLineHeight();
break;
}
case LayoutStyle::TWO_LINE_SUGGESTION: {
height = content_view_->GetLineHeight() +
description_view_->GetHeightForWidth(width() - GetTextIndent());
break;
}
}
height += GetInsets().height();
// Width is not calculated because it's not needed by current callers.
return gfx::Size(0, height);
}
bool OmniboxMatchCellView::CanProcessEventsWithinSubtree() const {
return false;
}
// static // static
int OmniboxMatchCellView::GetTextIndent() { int OmniboxMatchCellView::GetTextIndent() {
return ui::MaterialDesignController::touch_ui() ? 51 : 47; return ui::MaterialDesignController::touch_ui() ? 51 : 47;
...@@ -375,6 +342,41 @@ void OmniboxMatchCellView::Layout() { ...@@ -375,6 +342,41 @@ void OmniboxMatchCellView::Layout() {
} }
} }
bool OmniboxMatchCellView::CanProcessEventsWithinSubtree() const {
return false;
}
gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const {
int height = 0;
switch (layout_style_) {
case LayoutStyle::OLD_ANSWER: {
int icon_width = icon_view_->width();
int answer_image_size =
answer_image_view_->GetImage().isNull()
? 0
: answer_image_view_->height() + kAnswerIconToTextPadding;
int deduction =
icon_width + (HorizontalPadding() * 3) + answer_image_size;
int description_width = std::max(width() - deduction, 0);
height = content_view_->GetLineHeight() +
description_view_->GetHeightForWidth(description_width);
break;
}
case LayoutStyle::ONE_LINE_SUGGESTION: {
height = content_view_->GetLineHeight();
break;
}
case LayoutStyle::TWO_LINE_SUGGESTION: {
height = content_view_->GetLineHeight() +
description_view_->GetHeightForWidth(width() - GetTextIndent());
break;
}
}
height += GetInsets().height();
// Width is not calculated because it's not needed by current callers.
return gfx::Size(0, height);
}
void OmniboxMatchCellView::LayoutOldStyleAnswer(int icon_view_width, void OmniboxMatchCellView::LayoutOldStyleAnswer(int icon_view_width,
int text_indent) { int text_indent) {
// TODO(dschuyler): Remove this layout once rich layouts are enabled by // TODO(dschuyler): Remove this layout once rich layouts are enabled by
......
...@@ -39,23 +39,22 @@ class OmniboxMatchCellView : public views::View { ...@@ -39,23 +39,22 @@ class OmniboxMatchCellView : public views::View {
void SetImage(const gfx::ImageSkia& image); void SetImage(const gfx::ImageSkia& image);
// views::View: // views::View:
gfx::Size CalculatePreferredSize() const override; const char* GetClassName() const override;
void Layout() override;
bool CanProcessEventsWithinSubtree() const override; bool CanProcessEventsWithinSubtree() const override;
gfx::Size CalculatePreferredSize() const override;
protected: private:
enum class LayoutStyle { enum class LayoutStyle {
OLD_ANSWER, OLD_ANSWER,
ONE_LINE_SUGGESTION, ONE_LINE_SUGGESTION,
TWO_LINE_SUGGESTION, TWO_LINE_SUGGESTION,
}; };
// views::View:
void Layout() override;
const char* GetClassName() const override;
void LayoutOldStyleAnswer(int icon_view_width, int text_indent); void LayoutOldStyleAnswer(int icon_view_width, int text_indent);
void LayoutNewStyleTwoLineSuggestion(); void LayoutNewStyleTwoLineSuggestion();
void LayoutOneLineSuggestion(int icon_view_width, int text_indent); void LayoutOneLineSuggestion(int icon_view_width, int text_indent);
void SetTailSuggestCommonPrefixWidth(const base::string16& common_prefix);
bool is_rich_suggestion_ = false; bool is_rich_suggestion_ = false;
bool is_search_type_ = false; bool is_search_type_ = false;
...@@ -70,9 +69,6 @@ class OmniboxMatchCellView : public views::View { ...@@ -70,9 +69,6 @@ class OmniboxMatchCellView : public views::View {
OmniboxTextView* description_view_; OmniboxTextView* description_view_;
OmniboxTextView* separator_view_; OmniboxTextView* separator_view_;
private:
void SetTailSuggestCommonPrefixWidth(const base::string16& common_prefix);
// This (permanently) holds the rendered width of // This (permanently) holds the rendered width of
// AutocompleteMatch::kEllipsis so that we don't have to keep calculating // AutocompleteMatch::kEllipsis so that we don't have to keep calculating
// it. // it.
......
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