| OLD | NEW |
| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <atlbase.h> // NOLINT | 8 #include <atlbase.h> // NOLINT |
| 9 #include <atlwin.h> // NOLINT | 9 #include <atlwin.h> // NOLINT |
| 10 #endif | 10 #endif |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); | 617 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); |
| 618 // |theme_provider| can be null when animations are running during shutdown, | 618 // |theme_provider| can be null when animations are running during shutdown, |
| 619 // after OmniboxResultView has been removed from the tree of Views. | 619 // after OmniboxResultView has been removed from the tree of Views. |
| 620 if (!theme_provider) | 620 if (!theme_provider) |
| 621 return; | 621 return; |
| 622 const int horizontal_padding = theme_provider->GetDisplayProperty( | 622 const int horizontal_padding = theme_provider->GetDisplayProperty( |
| 623 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); | 623 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); |
| 624 const int trailing_padding = theme_provider->GetDisplayProperty( | 624 const int trailing_padding = theme_provider->GetDisplayProperty( |
| 625 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING); | 625 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING); |
| 626 | 626 |
| 627 const int start_x = StartMargin() + horizontal_padding; |
| 628 const int end_x = width() - EndMargin() - horizontal_padding; |
| 629 |
| 627 icon_bounds_.SetRect( | 630 icon_bounds_.SetRect( |
| 628 horizontal_padding + | 631 start_x + ((icon.width() == default_icon_size_) ? 0 : trailing_padding), |
| 629 ((icon.width() == default_icon_size_) ? 0 : trailing_padding), | 632 (GetContentLineHeight() - icon.height()) / 2, |
| 630 (GetContentLineHeight() - icon.height()) / 2, icon.width(), | 633 icon.width(), icon.height()); |
| 631 icon.height()); | |
| 632 | 634 |
| 633 int text_x = (2 * horizontal_padding) + default_icon_size_; | 635 const int text_x = start_x + default_icon_size_ + horizontal_padding; |
| 634 int text_width = width() - text_x - horizontal_padding; | 636 int text_width = end_x - text_x; |
| 635 | 637 |
| 636 if (match_.associated_keyword.get()) { | 638 if (match_.associated_keyword.get()) { |
| 637 const int kw_collapsed_size = keyword_icon_->width() + horizontal_padding; | 639 const int max_kw_x = end_x - keyword_icon_->width(); |
| 638 const int max_kw_x = width() - kw_collapsed_size; | 640 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); |
| 639 const int kw_x = | |
| 640 animation_->CurrentValueBetween(max_kw_x, horizontal_padding); | |
| 641 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; | 641 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; |
| 642 | 642 |
| 643 text_width = kw_x - text_x - horizontal_padding; | 643 text_width = kw_x - text_x - horizontal_padding; |
| 644 keyword_text_bounds_.SetRect( | 644 keyword_text_bounds_.SetRect( |
| 645 kw_text_x, 0, std::max(width() - kw_text_x - horizontal_padding, 0), | 645 kw_text_x, 0, std::max(end_x - kw_text_x, 0), height()); |
| 646 height()); | |
| 647 keyword_icon_->SetPosition( | 646 keyword_icon_->SetPosition( |
| 648 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); | 647 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); |
| 649 } | 648 } |
| 650 | 649 |
| 651 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); | 650 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); |
| 652 } | 651 } |
| 653 | 652 |
| 654 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 653 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 655 animation_->SetSlideDuration(width() / 4); | 654 animation_->SetSlideDuration((width() - StartMargin() - EndMargin()) / 4); |
| 656 } | 655 } |
| 657 | 656 |
| 658 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { | 657 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { |
| 659 const ResultViewState state = GetState(); | 658 const ResultViewState state = GetState(); |
| 660 if (state != NORMAL) | 659 if (state != NORMAL) |
| 661 canvas->DrawColor(GetColor(state, BACKGROUND)); | 660 canvas->DrawColor(GetColor(state, BACKGROUND)); |
| 662 | 661 |
| 663 // NOTE: While animating the keyword match, both matches may be visible. | 662 // NOTE: While animating the keyword match, both matches may be visible. |
| 664 | 663 |
| 665 if (!ShowOnlyKeywordMatch()) { | 664 if (!ShowOnlyKeywordMatch()) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 gfx::Range range(offset, offset + text.length()); | 791 gfx::Range range(offset, offset + text.length()); |
| 793 destination->AppendText(text); | 792 destination->AppendText(text); |
| 794 const TextStyle& text_style = GetTextStyle(text_type); | 793 const TextStyle& text_style = GetTextStyle(text_type); |
| 795 // TODO(dschuyler): follow up on the problem of different font sizes within | 794 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 796 // one RenderText. Maybe with destination->SetFontList(...). | 795 // one RenderText. Maybe with destination->SetFontList(...). |
| 797 destination->ApplyStyle(gfx::BOLD, is_bold, range); | 796 destination->ApplyStyle(gfx::BOLD, is_bold, range); |
| 798 destination->ApplyColor( | 797 destination->ApplyColor( |
| 799 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 798 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 800 destination->ApplyBaselineStyle(text_style.baseline, range); | 799 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 801 } | 800 } |
| 801 |
| 802 int OmniboxResultView::StartMargin() const { |
| 803 return ui::MaterialDesignController::IsModeMaterial() ? |
| 804 model_->start_margin() : 0; |
| 805 } |
| 806 |
| 807 int OmniboxResultView::EndMargin() const { |
| 808 return ui::MaterialDesignController::IsModeMaterial() ? |
| 809 model_->end_margin() : 0; |
| 810 } |
| OLD | NEW |