Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_view.cc

Issue 2929003002: Omnibox UI: Fix Answers in Suggest display in Views (Closed)
Patch Set: fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <atlbase.h> // NOLINT 9 #include <atlbase.h> // NOLINT
10 #include <atlwin.h> // NOLINT 10 #include <atlwin.h> // NOLINT
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 match.answer != nullptr || 358 match.answer != nullptr ||
359 base::FeatureList::IsEnabled(omnibox::kUIExperimentVerticalLayout); 359 base::FeatureList::IsEnabled(omnibox::kUIExperimentVerticalLayout);
360 OmniboxPopupModel::ComputeMatchMaxWidths( 360 OmniboxPopupModel::ComputeMatchMaxWidths(
361 contents->GetContentWidth(), separator_width_, 361 contents->GetContentWidth(), separator_width_,
362 description ? description->GetContentWidth() : 0, 362 description ? description->GetContentWidth() : 0,
363 mirroring_context_->remaining_width(x), description_on_separate_line, 363 mirroring_context_->remaining_width(x), description_on_separate_line,
364 !AutocompleteMatch::IsSearchType(match.type), &contents_max_width, 364 !AutocompleteMatch::IsSearchType(match.type), &contents_max_width,
365 &description_max_width); 365 &description_max_width);
366 366
367 // Answers in Suggest results. 367 // Answers in Suggest results.
368 if (match.answer && description_max_width != 0) { 368 if (match.answer && description_max_width != 0) {
Peter Kasting 2017/06/09 02:33:48 Looking more closely at this code I'm concerned wi
tommycli 2017/06/09 16:09:21 Hey Peter... I think we are okay since we have des
Peter Kasting 2017/06/09 19:30:53 Wow, I totally didn't see that functionality. I =
369 DrawRenderText(match, contents, CONTENTS, canvas, x, y, contents_max_width); 369 DrawRenderText(match, contents, CONTENTS, canvas, x, y, contents_max_width);
370 y += GetTextHeight() + kVerticalPadding; 370 y += GetTextHeight() + kVerticalPadding;
371 if (!answer_image_.isNull()) { 371 if (!answer_image_.isNull()) {
372 int answer_icon_size = GetAnswerHeight(); 372 int answer_icon_size = GetAnswerHeight();
373 canvas->DrawImageInt(answer_image_, 0, 0, answer_image_.width(), 373 canvas->DrawImageInt(answer_image_, 0, 0, answer_image_.width(),
374 answer_image_.height(), GetMirroredXInView(x), y, 374 answer_image_.height(), GetMirroredXInView(x), y,
375 answer_icon_size, answer_icon_size, true); 375 answer_icon_size, answer_icon_size, true);
376 // TODO(dschuyler): Perhaps this should be based on the font size 376 // TODO(dschuyler): Perhaps this should be based on the font size
377 // instead of hardcoded to 2 dp (e.g. by adding a space in an 377 // instead of hardcoded to 2 dp (e.g. by adding a space in an
378 // appropriate font to the beginning of the description, then reducing 378 // appropriate font to the beginning of the description, then reducing
379 // the additional padding here to zero). 379 // the additional padding here to zero).
380 const int kAnswerIconToTextPadding = 2; 380 const int kAnswerIconToTextPadding = 2;
381 x += answer_icon_size + kAnswerIconToTextPadding; 381 x += answer_icon_size + kAnswerIconToTextPadding;
382 } 382 }
383 DrawRenderText(match, description, DESCRIPTION, canvas, x, y,
384 description_max_width);
Peter Kasting 2017/06/09 02:33:48 Depending on how we address the above, we may be a
tommycli 2017/06/09 16:09:21 Yes I definitely thought about this. Ultimately I
Peter Kasting 2017/06/09 19:30:53 I think we should change it. Here's my mock attem
383 return; 385 return;
384 } 386 }
385 387
386 // Regular results. 388 // Regular results.
387 if (base::FeatureList::IsEnabled(omnibox::kUIExperimentVerticalLayout)) { 389 if (base::FeatureList::IsEnabled(omnibox::kUIExperimentVerticalLayout)) {
388 // For no description, shift down halfways to draw contents in middle. 390 // For no description, shift down halfways to draw contents in middle.
389 if (description_max_width == 0) 391 if (description_max_width == 0)
390 y += (GetTextHeight() + kVerticalPadding) / 2; 392 y += (GetTextHeight() + kVerticalPadding) / 2;
391 393
392 DrawRenderText(match, contents, CONTENTS, canvas, x, y, contents_max_width); 394 DrawRenderText(match, contents, CONTENTS, canvas, x, y, contents_max_width);
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 destination->AppendText(text); 846 destination->AppendText(text);
845 const TextStyle& text_style = GetTextStyle(text_type); 847 const TextStyle& text_style = GetTextStyle(text_type);
846 // TODO(dschuyler): follow up on the problem of different font sizes within 848 // TODO(dschuyler): follow up on the problem of different font sizes within
847 // one RenderText. Maybe with destination->SetFontList(...). 849 // one RenderText. Maybe with destination->SetFontList(...).
848 destination->ApplyWeight( 850 destination->ApplyWeight(
849 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); 851 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range);
850 destination->ApplyColor( 852 destination->ApplyColor(
851 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 853 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
852 destination->ApplyBaselineStyle(text_style.baseline, range); 854 destination->ApplyBaselineStyle(text_style.baseline, range);
853 } 855 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698