Commit c4fe135b authored by Dave Schuyler's avatar Dave Schuyler Committed by Commit Bot

[Omnibox] New Answer Layout

This cl makes use of the previously added omnibox-new-answer-layout flag.
It separates the omnibox-rich-entity-suggestion flag from answer layout
so that the two changes can be tested together or individually.

Bug: 838733
Change-Id: I30d9acc5d32fd603010f0dea6b9c8f38df29cf10
Reviewed-on: https://chromium-review.googlesource.com/1038744Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Dave Schuyler <dschuyler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555841}
parent 2dd9ae13
...@@ -110,7 +110,7 @@ OmniboxMatchCellView::OmniboxMatchCellView(OmniboxResultView* result_view, ...@@ -110,7 +110,7 @@ OmniboxMatchCellView::OmniboxMatchCellView(OmniboxResultView* result_view,
const gfx::FontList& font_list, const gfx::FontList& font_list,
int text_height) int text_height)
: is_old_style_answer_(false), : is_old_style_answer_(false),
is_entity_(false), is_rich_suggestion_(false),
is_search_type_(false), is_search_type_(false),
text_height_(text_height) { text_height_(text_height) {
AddChildView(icon_view_ = new OmniboxImageView()); AddChildView(icon_view_ = new OmniboxImageView());
...@@ -129,10 +129,11 @@ OmniboxMatchCellView::~OmniboxMatchCellView() = default; ...@@ -129,10 +129,11 @@ OmniboxMatchCellView::~OmniboxMatchCellView() = default;
gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const { gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const {
int height = text_height_ + int height = text_height_ +
GetVerticalInsets(text_height_, is_old_style_answer_).height(); GetVerticalInsets(text_height_, is_old_style_answer_).height();
if (is_old_style_answer_) if (is_rich_suggestion_) {
height += GetOldStyleAnswerHeight();
if (is_entity_)
height += text_height_; height += text_height_;
} else if (is_old_style_answer_) {
height += GetOldStyleAnswerHeight();
}
return gfx::Size(0, height); return gfx::Size(0, height);
} }
bool OmniboxMatchCellView::CanProcessEventsWithinSubtree() const { bool OmniboxMatchCellView::CanProcessEventsWithinSubtree() const {
...@@ -155,14 +156,16 @@ int OmniboxMatchCellView::GetOldStyleAnswerHeight() const { ...@@ -155,14 +156,16 @@ int OmniboxMatchCellView::GetOldStyleAnswerHeight() const {
void OmniboxMatchCellView::OnMatchUpdate(const AutocompleteMatch& match) { void OmniboxMatchCellView::OnMatchUpdate(const AutocompleteMatch& match) {
is_old_style_answer_ = !!match.answer; is_old_style_answer_ = !!match.answer;
if (base::FeatureList::IsEnabled(omnibox::kOmniboxRichEntitySuggestions)) { is_rich_suggestion_ =
is_entity_ = !match.image_url.empty(); (base::FeatureList::IsEnabled(omnibox::kOmniboxNewAnswerLayout) &&
} !!match.answer) ||
(base::FeatureList::IsEnabled(omnibox::kOmniboxRichEntitySuggestions) &&
!match.image_url.empty());
is_search_type_ = AutocompleteMatch::IsSearchType(match.type); is_search_type_ = AutocompleteMatch::IsSearchType(match.type);
if (is_old_style_answer_ || is_entity_) { if (is_old_style_answer_ || is_rich_suggestion_) {
separator_view_->SetSize(gfx::Size()); separator_view_->SetSize(gfx::Size());
} }
if (is_entity_) { if (is_rich_suggestion_) {
icon_view_->SetSize(gfx::Size()); icon_view_->SetSize(gfx::Size());
} }
} }
...@@ -173,8 +176,8 @@ const char* OmniboxMatchCellView::GetClassName() const { ...@@ -173,8 +176,8 @@ const char* OmniboxMatchCellView::GetClassName() const {
void OmniboxMatchCellView::Layout() { void OmniboxMatchCellView::Layout() {
views::View::Layout(); views::View::Layout();
if (is_entity_) { if (is_rich_suggestion_) {
LayoutEntity(); LayoutRichSuggestion();
} else if (is_old_style_answer_) { } else if (is_old_style_answer_) {
LayoutOldStyleAnswer(); LayoutOldStyleAnswer();
} else { } else {
...@@ -209,7 +212,7 @@ void OmniboxMatchCellView::LayoutOldStyleAnswer() { ...@@ -209,7 +212,7 @@ void OmniboxMatchCellView::LayoutOldStyleAnswer() {
kVerticalPadding); kVerticalPadding);
} }
void OmniboxMatchCellView::LayoutEntity() { void OmniboxMatchCellView::LayoutRichSuggestion() {
int x = GetIconAlignmentOffset() + HorizontalPadding() + int x = GetIconAlignmentOffset() + HorizontalPadding() +
LocationBarView::GetBorderThicknessDip(); LocationBarView::GetBorderThicknessDip();
int y = GetVerticalInsets(text_height_, /*is_old_style_answer=*/false).top(); int y = GetVerticalInsets(text_height_, /*is_old_style_answer=*/false).top();
......
...@@ -47,11 +47,11 @@ class OmniboxMatchCellView : public views::View { ...@@ -47,11 +47,11 @@ class OmniboxMatchCellView : public views::View {
int GetOldStyleAnswerHeight() const; int GetOldStyleAnswerHeight() const;
void LayoutOldStyleAnswer(); void LayoutOldStyleAnswer();
void LayoutEntity(); void LayoutRichSuggestion();
void LayoutSplit(); void LayoutSplit();
bool is_old_style_answer_; bool is_old_style_answer_;
bool is_entity_; bool is_rich_suggestion_;
bool is_search_type_; bool is_search_type_;
int text_height_; int text_height_;
......
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