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

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

Issue 2555623002: Last round of cleaning up MD layout constants. (Closed)
Patch Set: rebase Created 4 years 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 // 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
11 #endif 11 #endif
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" 14 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
15 15
16 #include <limits.h> 16 #include <limits.h>
17 17
18 #include <algorithm> // NOLINT 18 #include <algorithm> // NOLINT
19 19
20 #include "base/i18n/bidi_line_iterator.h" 20 #include "base/i18n/bidi_line_iterator.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "chrome/browser/ui/layout_constants.h"
24 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" 23 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
25 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 24 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
26 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 25 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
27 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
28 #include "components/grit/components_scaled_resources.h" 27 #include "components/grit/components_scaled_resources.h"
29 #include "components/omnibox/browser/omnibox_popup_model.h" 28 #include "components/omnibox/browser/omnibox_popup_model.h"
30 #include "third_party/skia/include/core/SkColor.h" 29 #include "third_party/skia/include/core/SkColor.h"
31 #include "ui/accessibility/ax_node_data.h" 30 #include "ui/accessibility/ax_node_data.h"
32 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/material_design/material_design_controller.h" 32 #include "ui/base/material_design/material_design_controller.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 582
584 void OmniboxResultView::InitContentsRenderTextIfNecessary() const { 583 void OmniboxResultView::InitContentsRenderTextIfNecessary() const {
585 if (!contents_rendertext_) { 584 if (!contents_rendertext_) {
586 contents_rendertext_.reset( 585 contents_rendertext_.reset(
587 CreateClassifiedRenderText( 586 CreateClassifiedRenderText(
588 match_.contents, match_.contents_class, false).release()); 587 match_.contents, match_.contents_class, false).release());
589 } 588 }
590 } 589 }
591 590
592 void OmniboxResultView::Layout() { 591 void OmniboxResultView::Layout() {
593 int horizontal_padding = 592 int horizontal_padding = LocationBarView::kHorizontalPadding;
Peter Kasting 2016/12/08 20:57:49 Nit: Make constexpr?
Evan Stade 2016/12/13 01:31:18 Done.
594 GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
595 // The horizontal bounds we're given are the outside bounds, so we can match 593 // The horizontal bounds we're given are the outside bounds, so we can match
596 // the omnibox border outline shape exactly in OnPaint(). We have to inset 594 // the omnibox border outline shape exactly in OnPaint(). We have to inset
597 // here to keep the icons lined up. 595 // here to keep the icons lined up.
598 const int start_x = 596 const int start_x = BackgroundWith1PxBorder::kLocationBarBorderThicknessDip +
599 GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) + horizontal_padding; 597 horizontal_padding;
600 const int end_x = width() - start_x; 598 const int end_x = width() - start_x;
601 599
602 const gfx::ImageSkia icon = GetIcon(); 600 const gfx::ImageSkia icon = GetIcon();
603 icon_bounds_.SetRect(start_x, (GetContentLineHeight() - icon.height()) / 2, 601 icon_bounds_.SetRect(start_x, (GetContentLineHeight() - icon.height()) / 2,
604 icon.width(), icon.height()); 602 icon.width(), icon.height());
605 603
606 const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding; 604 const int text_x = start_x + LocationBarView::kIconWidth + horizontal_padding;
607 int text_width = end_x - text_x; 605 int text_width = end_x - text_x;
608 606
609 if (match_.associated_keyword.get()) { 607 if (match_.associated_keyword.get()) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 destination->AppendText(text); 766 destination->AppendText(text);
769 const TextStyle& text_style = GetTextStyle(text_type); 767 const TextStyle& text_style = GetTextStyle(text_type);
770 // TODO(dschuyler): follow up on the problem of different font sizes within 768 // TODO(dschuyler): follow up on the problem of different font sizes within
771 // one RenderText. Maybe with destination->SetFontList(...). 769 // one RenderText. Maybe with destination->SetFontList(...).
772 destination->ApplyWeight( 770 destination->ApplyWeight(
773 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range); 771 is_bold ? gfx::Font::Weight::BOLD : gfx::Font::Weight::NORMAL, range);
774 destination->ApplyColor( 772 destination->ApplyColor(
775 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 773 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
776 destination->ApplyBaselineStyle(text_style.baseline, range); 774 destination->ApplyBaselineStyle(text_style.baseline, range);
777 } 775 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698