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

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

Issue 2914163004: Omnibox UI Experiments: Make suggestions dropdown match omnibox width. (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
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 "base/feature_list.h"
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "chrome/browser/search/search.h" 13 #include "chrome/browser/search/search.h"
13 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
15 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 16 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
16 #include "chrome/browser/ui/views/theme_copying_widget.h" 17 #include "chrome/browser/ui/views/theme_copying_widget.h"
18 #include "components/omnibox/browser/omnibox_field_trial.h"
17 #include "components/omnibox/browser/omnibox_view.h" 19 #include "components/omnibox/browser/omnibox_view.h"
18 #include "third_party/skia/include/core/SkDrawLooper.h" 20 #include "third_party/skia/include/core/SkDrawLooper.h"
19 #include "ui/base/theme_provider.h" 21 #include "ui/base/theme_provider.h"
20 #include "ui/compositor/clip_recorder.h" 22 #include "ui/compositor/clip_recorder.h"
21 #include "ui/compositor/paint_recorder.h" 23 #include "ui/compositor/paint_recorder.h"
22 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/geometry/safe_integer_conversions.h" 25 #include "ui/gfx/geometry/safe_integer_conversions.h"
24 #include "ui/gfx/image/image.h" 26 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/image/image_skia_operations.h" 27 #include "ui/gfx/image/image_skia_operations.h"
26 #include "ui/gfx/path.h" 28 #include "ui/gfx/path.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 450 }
449 451
450 //////////////////////////////////////////////////////////////////////////////// 452 ////////////////////////////////////////////////////////////////////////////////
451 // OmniboxPopupContentsView, views::View overrides, private: 453 // OmniboxPopupContentsView, views::View overrides, private:
452 454
453 const char* OmniboxPopupContentsView::GetClassName() const { 455 const char* OmniboxPopupContentsView::GetClassName() const {
454 return "OmniboxPopupContentsView"; 456 return "OmniboxPopupContentsView";
455 } 457 }
456 458
457 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) { 459 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) {
458 canvas->TileImageInt(g_top_shadow.Get(), 0, 0, width(), 460 bool match_omnibox_width = base::FeatureList::IsEnabled(
Peter Kasting 2017/06/05 18:25:45 It seems like the implementation in this file leav
tommycli 2017/06/05 22:39:21 Done. Thank you for this feedback! This made thing
461 omnibox::kUIExperimentSuggestionsDropdownWidth);
462 int shadow_x = match_omnibox_width ? start_margin_ : 0;
463 int shadow_width =
464 match_omnibox_width ? width() - start_margin_ - end_margin_ : 0;
465
466 canvas->TileImageInt(g_top_shadow.Get(), shadow_x, 0, shadow_width,
459 g_top_shadow.Get().height()); 467 g_top_shadow.Get().height());
460 canvas->TileImageInt(g_bottom_shadow.Get(), 0, 468 canvas->TileImageInt(g_bottom_shadow.Get(), shadow_x,
461 height() - g_bottom_shadow.Get().height(), width(), 469 height() - g_bottom_shadow.Get().height(), shadow_width,
462 g_bottom_shadow.Get().height()); 470 g_bottom_shadow.Get().height());
463 } 471 }
464 472
465 void OmniboxPopupContentsView::PaintChildren(const ui::PaintContext& context) { 473 void OmniboxPopupContentsView::PaintChildren(const ui::PaintContext& context) {
466 gfx::Rect contents_bounds = GetContentsBounds(); 474 gfx::Rect contents_bounds = GetContentsBounds();
467 contents_bounds.Inset(0, g_top_shadow.Get().height(), 0, 475 bool match_omnibox_width = base::FeatureList::IsEnabled(
468 g_bottom_shadow.Get().height()); 476 omnibox::kUIExperimentSuggestionsDropdownWidth);
477 int contents_start = match_omnibox_width ? start_margin_ : 0;
478 int contents_end = match_omnibox_width ? end_margin_ : 0;
479
480 contents_bounds.Inset(contents_start, g_top_shadow.Get().height(),
481 contents_end, g_bottom_shadow.Get().height());
469 482
470 ui::ClipRecorder clip_recorder(context); 483 ui::ClipRecorder clip_recorder(context);
471 clip_recorder.ClipRect(contents_bounds); 484 clip_recorder.ClipRect(contents_bounds);
472 { 485 {
473 ui::PaintRecorder recorder(context, size()); 486 ui::PaintRecorder recorder(context, size());
474 SkColor background_color = result_view_at(0)->GetColor( 487 SkColor background_color = result_view_at(0)->GetColor(
475 OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND); 488 OmniboxResultView::NORMAL, OmniboxResultView::BACKGROUND);
476 recorder.canvas()->DrawColor(background_color); 489 recorder.canvas()->DrawColor(background_color);
477 } 490 }
478 View::PaintChildren(context); 491 View::PaintChildren(context);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 size_t index = GetIndexForPoint(event.location()); 541 size_t index = GetIndexForPoint(event.location());
529 if (!HasMatchAt(index)) 542 if (!HasMatchAt(index))
530 return; 543 return;
531 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, 544 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition,
532 GURL(), base::string16(), index); 545 GURL(), base::string16(), index);
533 } 546 }
534 547
535 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 548 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
536 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 549 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
537 } 550 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698