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

Issue 2929003002: Omnibox UI: Fix Answers in Suggest display in Views (Closed)

Created:
3 years, 6 months ago by tommycli
Modified:
3 years, 6 months ago
CC:
chromium-reviews, tfarina, jdonnelly+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Omnibox UI: Fix Answers in Suggest display in Views Fixes a regression introduced by an Omnibox UI experiment patch. BUG=729974 Review-Url: https://codereview.chromium.org/2929003002 Cr-Commit-Position: refs/heads/master@{#478299} Committed: https://chromium.googlesource.com/chromium/src/+/f2637fc408350b9cd9fa90cf35bad8c286776b9c

Patch Set 1 #

Patch Set 2 : fix #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -0 lines) Patch
M chrome/browser/ui/views/omnibox/omnibox_result_view.cc View 1 chunk +2 lines, -0 lines 6 comments Download

Messages

Total messages: 18 (9 generated)
tommycli
pkasting / jdonnelly: PTAL.
3 years, 6 months ago (2017-06-08 17:14:50 UTC) #2
tommycli
On 2017/06/08 17:14:50, tommycli wrote: > pkasting / jdonnelly: PTAL. Prev. patch accidentally drops draw ...
3 years, 6 months ago (2017-06-08 17:16:05 UTC) #3
Justin Donnelly
lgtm
3 years, 6 months ago (2017-06-08 17:21:09 UTC) #4
tommycli
On 2017/06/08 17:21:09, Justin Donnelly wrote: > lgtm Great thanks. pkasting: PTAL (or maybe I ...
3 years, 6 months ago (2017-06-09 00:03:51 UTC) #10
Peter Kasting
This change made me stare at the code longer, and I think it's wrong the ...
3 years, 6 months ago (2017-06-09 02:33:48 UTC) #11
tommycli
pkasting: Thanks! https://codereview.chromium.org/2929003002/diff/20001/chrome/browser/ui/views/omnibox/omnibox_result_view.cc File chrome/browser/ui/views/omnibox/omnibox_result_view.cc (right): https://codereview.chromium.org/2929003002/diff/20001/chrome/browser/ui/views/omnibox/omnibox_result_view.cc#newcode368 chrome/browser/ui/views/omnibox/omnibox_result_view.cc:368: if (match.answer && description_max_width != 0) { ...
3 years, 6 months ago (2017-06-09 16:09:21 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2929003002/20001
3 years, 6 months ago (2017-06-09 16:09:46 UTC) #14
commit-bot: I haz the power
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/chromium/src/+/f2637fc408350b9cd9fa90cf35bad8c286776b9c
3 years, 6 months ago (2017-06-09 16:13:29 UTC) #17
Peter Kasting
3 years, 6 months ago (2017-06-09 19:30:53 UTC) #18
Message was sent while issue was closed.
https://codereview.chromium.org/2929003002/diff/20001/chrome/browser/ui/views...
File chrome/browser/ui/views/omnibox/omnibox_result_view.cc (right):

https://codereview.chromium.org/2929003002/diff/20001/chrome/browser/ui/views...
chrome/browser/ui/views/omnibox/omnibox_result_view.cc:368: if (match.answer &&
description_max_width != 0) {
On 2017/06/09 16:09:21, tommycli wrote:
> On 2017/06/09 02:33:48, Peter Kasting (busy Wed-Thu) wrote:
> > Looking more closely at this code I'm concerned with this conditional.  I
> don't
> > think we want to check description_max_width for the answer case.  That will
> be
> > true when the omnibox is too narrow to display both contents and description
> on
> > one line.  But since answers are always vertical layout, we don't care about
> > checking that.
> > 
> > This is one reason why it may have made sense to collapse "answer" with
> > "vertical layout" as I proposed in your refactor, though I didn't realize it
> at
> > the time.
> > 
> > Also, in both the answer and vertical layout cases, we want to draw both
> > contents and description with the full width.  The xxx_max_width variables
> will
> > be set incorrectly today since ComputeMaxMatchWidths() assumes horizontal
> > layout.
> 
> Hey Peter... I think we are okay since we have description_on_separate_line
set
> to true for the vertical layout case. Both the max width variables should be
set
> correctly.

Wow, I totally didn't see that functionality.  I = blind.  Sorry.

> I can definitely buy that we don't need to check description_max_width != 0 on
> this line though. WDYT?

Yeah, it seems like it should be removed.

https://codereview.chromium.org/2929003002/diff/20001/chrome/browser/ui/views...
chrome/browser/ui/views/omnibox/omnibox_result_view.cc:384:
description_max_width);
On 2017/06/09 16:09:21, tommycli wrote:
> On 2017/06/09 02:33:48, Peter Kasting (busy Wed-Thu) wrote:
> > Depending on how we address the above, we may be able to refactor this so
this
> > DrawRenderText() call happens after these conditional blocks that draw the
> > CONTENTS and update x/y.
> 
> Yes I definitely thought about this. Ultimately I thought it would be clearer
if
> all the operations for the answer case were together and all the operations
for
> the non-answer horizontal, and all the operations for the non-answer vertical
> were together.
> 
> We can change in a followup if you hove strong opinions here.

I think we should change it.  Here's my mock attempt to do so.  To me this is
clearer and simpler.  You'd want to address the TODOs I added here.

  // Draw contents.
  // For vertical layouts with no description, vertically center.
  // TODO(pkasting): I think we should remove this behavior
  const bool vertical =
      base::FeatureList::IsEnabled(omnibox::kUIExperimentVerticalLayout);
  const bool show_description = description_max_width > 0;
  if (vertical && !show_description)
    y += (GetTextHeight() + kVerticalPadding) / 2;
  const int contents_end = DrawRenderText(match, contents, CONTENTS, canvas, x,
                                          y, contents_max_width);

  // Move to position to draw answer/description.
  if (vertical || match.answer) {
    y += GetTextHeight() + kVerticalPadding;
  } else if (show_description) {
    x = DrawRenderText(match, separator_rendertext_.get(), SEPARATOR, canvas,
                       contents_end, y, separator_width_);
  }

  // Draw answer image, if any.
  // TODO(pkasting): Not clear whether we need first half of conditional
  if (match.answer && !answer_image_.isNull()) {
    int answer_icon_size = GetAnswerHeight();
    canvas->DrawImageInt(answer_image_, 0, 0, answer_image_.width(),
                         answer_image_.height(), GetMirroredXInView(x), y,
                         answer_icon_size, answer_icon_size, true);
    // TODO(dschuyler): Perhaps this should be based on the font size
    // instead of hardcoded to 2 dp (e.g. by adding a space in an
    // appropriate font to the beginning of the description, then reducing
    // the additional padding here to zero).
    const int kAnswerIconToTextPadding = 2;
    x += answer_icon_size + kAnswerIconToTextPadding;
  }

  // Draw description.
  // TODO(pkasting): Conditional should maybe be hoisted to DrawRenderText()
  if (show_description) {
    DrawRenderText(match, description, DESCRIPTION, canvas, x, y,
                   description_max_width);
  }

Powered by Google App Engine
This is Rietveld 408576698