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

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

Issue 795933009: [AiS] for desktop, two lines and font sytles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Positive/Negative font change Created 5 years, 9 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
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 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/search/search.h" 9 #include "chrome/browser/search/search.h"
10 #include "chrome/browser/themes/theme_properties.h" 10 #include "chrome/browser/themes/theme_properties.h"
11 #include "chrome/browser/ui/omnibox/omnibox_view.h" 11 #include "chrome/browser/ui/omnibox/omnibox_view.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
14 #include "components/omnibox/omnibox_field_trial.h"
14 #include "ui/base/theme_provider.h" 15 #include "ui/base/theme_provider.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/path.h" 18 #include "ui/gfx/path.h"
18 #include "ui/resources/grit/ui_resources.h" 19 #include "ui/resources/grit/ui_resources.h"
19 #include "ui/views/controls/image_view.h" 20 #include "ui/views/controls/image_view.h"
20 #include "ui/views/view_targeter.h" 21 #include "ui/views/view_targeter.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
22 #include "ui/views/window/non_client_view.h" 23 #include "ui/views/window/non_client_view.h"
23 24
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 View::PaintChildren(canvas, views::CullSet()); 378 View::PaintChildren(canvas, views::CullSet());
378 } 379 }
379 380
380 int OmniboxPopupContentsView::CalculatePopupHeight() { 381 int OmniboxPopupContentsView::CalculatePopupHeight() {
381 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); 382 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
382 int popup_height = 0; 383 int popup_height = 0;
383 for (size_t i = model_->result().ShouldHideTopMatch() ? 1 : 0; 384 for (size_t i = model_->result().ShouldHideTopMatch() ? 1 : 0;
384 i < model_->result().size(); ++i) 385 i < model_->result().size(); ++i)
385 popup_height += child_at(i)->GetPreferredSize().height(); 386 popup_height += child_at(i)->GetPreferredSize().height();
386 387
387 // Add enough space on the top and bottom so it looks like there is the same 388 if (OmniboxFieldTrial::EnableAnswersInSuggest()) {
388 // amount of space between the text and the popup border as there is in the 389 // In the current mockup, the cell heights for the result views can
Peter Kasting 2015/03/12 09:45:59 Nit: Remove "In the current mockup"
dschuyler 2015/03/13 06:01:20 Done.
389 // interior between each row of text. 390 // vary cell to cell. They may vary by the number of lines used for the
390 // 391 // result or by the fonts used. Because of this, we're not able to use the
391 // Discovering the exact amount of leading and padding around the font is 392 // <preferred size height minus text height> method used below.
392 // a bit tricky and platform-specific, but this computation seems to work in 393 outside_vertical_padding_ =
393 // practice. 394 result_view_at(0)->get_minimum_text_vertical_padding();
Peter Kasting 2015/03/12 09:45:59 So, in practice, what does this end up computing t
dschuyler 2015/03/13 06:01:20 The padding was 3 pixels. In the other case it may
394 OmniboxResultView* result_view = result_view_at(0); 395 return popup_height +
395 outside_vertical_padding_ = 396 views::NonClientFrameView::kClientEdgeThickness + // Top border.
396 (result_view->GetPreferredSize().height() - 397 outside_vertical_padding_ * 2 + // Padding.
397 result_view->GetTextHeight()); 398 bottom_shadow_->height() - kBorderInterior; // Bottom border.
Peter Kasting 2015/03/12 09:45:59 This return statement is a duplicate of the one be
dschuyler 2015/03/13 06:01:20 Done.
399 } else {
400 // Add enough space on the top and bottom so it looks like there is the same
401 // amount of space between the text and the popup border as there is in the
402 // interior between each row of text.
403 //
404 // Discovering the exact amount of leading and padding around the font is
405 // a bit tricky and platform-specific, but this computation seems to work in
406 // practice.
407 OmniboxResultView* result_view = result_view_at(0);
408 outside_vertical_padding_ = (result_view->GetPreferredSize().height() -
409 result_view->GetTextHeight());
398 410
399 return popup_height + 411 return popup_height +
400 views::NonClientFrameView::kClientEdgeThickness + // Top border. 412 views::NonClientFrameView::kClientEdgeThickness + // Top border.
401 outside_vertical_padding_ * 2 + // Padding. 413 outside_vertical_padding_ * 2 + // Padding.
402 bottom_shadow_->height() - kBorderInterior; // Bottom border. 414 bottom_shadow_->height() - kBorderInterior; // Bottom border.
415 }
403 } 416 }
404 417
405 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( 418 OmniboxResultView* OmniboxPopupContentsView::CreateResultView(
406 int model_index, 419 int model_index,
407 const gfx::FontList& font_list) { 420 const gfx::FontList& font_list) {
408 return new OmniboxResultView(this, model_index, location_bar_view_, 421 return new OmniboxResultView(this, model_index, location_bar_view_,
409 font_list); 422 font_list);
410 } 423 }
411 424
412 //////////////////////////////////////////////////////////////////////////////// 425 ////////////////////////////////////////////////////////////////////////////////
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 size_t index = GetIndexForPoint(event.location()); 520 size_t index = GetIndexForPoint(event.location());
508 if (!HasMatchAt(index)) 521 if (!HasMatchAt(index))
509 return; 522 return;
510 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, 523 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition,
511 GURL(), base::string16(), index); 524 GURL(), base::string16(), index);
512 } 525 }
513 526
514 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 527 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
515 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 528 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
516 } 529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698