Chromium Code Reviews| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 324 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| 325 separator_rendertext_.reset(CreateRenderText(separator).release()); | 325 separator_rendertext_.reset(CreateRenderText(separator).release()); |
| 326 separator_rendertext_->SetColor(GetColor(GetState(), DIMMED_TEXT)); | 326 separator_rendertext_->SetColor(GetColor(GetState(), DIMMED_TEXT)); |
| 327 separator_width_ = separator_rendertext_->GetContentWidth(); | 327 separator_width_ = separator_rendertext_->GetContentWidth(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 contents->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); | 330 contents->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); |
| 331 if (description) | 331 if (description) |
| 332 description->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); | 332 description->SetDisplayRect(gfx::Rect(gfx::Size(INT_MAX, 0))); |
| 333 int contents_max_width, description_max_width; | 333 int contents_max_width, description_max_width; |
| 334 | |
| 335 int remaining_width = mirroring_context_->remaining_width(x); | |
| 336 if (ui::MaterialDesignController::IsModeMaterial()) { | |
|
Peter Kasting
2015/08/19 20:37:34
On more reflection: why is this block needed at al
tdanderson
2015/08/19 22:32:57
Without this block, the "Search <site> for <query>
Peter Kasting
2015/08/21 22:13:06
This is because the change to Layout() is incomple
| |
| 337 const int max_x = width() - RightMargin(); | |
| 338 remaining_width = std::min(remaining_width, std::max(0, max_x - x)); | |
| 339 } | |
| 340 | |
| 334 OmniboxPopupModel::ComputeMatchMaxWidths( | 341 OmniboxPopupModel::ComputeMatchMaxWidths( |
| 335 contents->GetContentWidth(), | 342 contents->GetContentWidth(), |
| 336 separator_width_, | 343 separator_width_, |
| 337 description ? description->GetContentWidth() : 0, | 344 description ? description->GetContentWidth() : 0, |
| 338 mirroring_context_->remaining_width(x), | 345 remaining_width, |
| 339 !AutocompleteMatch::IsSearchType(match.type), | 346 !AutocompleteMatch::IsSearchType(match.type), |
| 340 &contents_max_width, | 347 &contents_max_width, |
| 341 &description_max_width); | 348 &description_max_width); |
| 342 | 349 |
| 343 int after_contents_x = | 350 int after_contents_x = |
| 344 DrawRenderText(match, contents, true, canvas, x, y, contents_max_width); | 351 DrawRenderText(match, contents, true, canvas, x, y, contents_max_width); |
| 345 | 352 |
| 346 if (description_max_width != 0) { | 353 if (description_max_width != 0) { |
| 347 if (match.answer) { | 354 if (match.answer) { |
| 348 y += GetContentLineHeight(); | 355 y += GetContentLineHeight(); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); | 625 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); |
| 619 // |theme_provider| can be null when animations are running during shutdown, | 626 // |theme_provider| can be null when animations are running during shutdown, |
| 620 // after OmniboxResultView has been removed from the tree of Views. | 627 // after OmniboxResultView has been removed from the tree of Views. |
| 621 if (!theme_provider) | 628 if (!theme_provider) |
| 622 return; | 629 return; |
| 623 const int horizontal_padding = theme_provider->GetDisplayProperty( | 630 const int horizontal_padding = theme_provider->GetDisplayProperty( |
| 624 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); | 631 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); |
| 625 const int trailing_padding = theme_provider->GetDisplayProperty( | 632 const int trailing_padding = theme_provider->GetDisplayProperty( |
| 626 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING); | 633 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING); |
| 627 | 634 |
| 635 const int start_x = LeftMargin() + horizontal_padding; | |
| 636 const int end_x = width() - RightMargin() - horizontal_padding; | |
| 637 | |
| 628 icon_bounds_.SetRect( | 638 icon_bounds_.SetRect( |
| 629 horizontal_padding + | 639 start_x + ((icon.width() == default_icon_size_) ? 0 : trailing_padding), |
| 630 ((icon.width() == default_icon_size_) ? 0 : trailing_padding), | 640 (GetContentLineHeight() - icon.height()) / 2, |
| 631 (GetContentLineHeight() - icon.height()) / 2, icon.width(), | 641 icon.width(), icon.height()); |
| 632 icon.height()); | |
| 633 | 642 |
| 634 int text_x = (2 * horizontal_padding) + default_icon_size_; | 643 const int text_x = start_x + horizontal_padding + default_icon_size_; |
|
Peter Kasting
2015/08/19 20:37:34
Nit: Put |default_icon_size_| before |horizontal_p
tdanderson
2015/08/19 22:32:57
Done.
| |
| 635 int text_width = width() - text_x - horizontal_padding; | 644 int text_width = end_x - text_x; |
| 636 | 645 |
| 637 if (match_.associated_keyword.get()) { | 646 if (match_.associated_keyword.get()) { |
| 638 const int kw_collapsed_size = keyword_icon_->width() + horizontal_padding; | 647 const int max_kw_x = end_x - keyword_icon_->width(); |
| 639 const int max_kw_x = width() - kw_collapsed_size; | 648 const int kw_x = animation_->CurrentValueBetween(max_kw_x, start_x); |
| 640 const int kw_x = | |
| 641 animation_->CurrentValueBetween(max_kw_x, horizontal_padding); | |
| 642 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; | 649 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; |
| 643 | 650 |
| 644 text_width = kw_x - text_x - horizontal_padding; | 651 text_width = kw_x - text_x - horizontal_padding; |
| 645 keyword_text_bounds_.SetRect( | 652 keyword_text_bounds_.SetRect( |
| 646 kw_text_x, 0, std::max(width() - kw_text_x - horizontal_padding, 0), | 653 kw_text_x, 0, std::max(width() - kw_text_x - horizontal_padding, 0), |
| 647 height()); | 654 height()); |
| 648 keyword_icon_->SetPosition( | 655 keyword_icon_->SetPosition( |
| 649 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); | 656 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); |
| 650 } | 657 } |
| 651 | 658 |
| 652 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); | 659 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); |
| 653 } | 660 } |
| 654 | 661 |
| 655 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 662 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 656 animation_->SetSlideDuration(width() / 4); | 663 animation_->SetSlideDuration((width() - LeftMargin() - RightMargin()) / 4); |
| 657 } | 664 } |
| 658 | 665 |
| 659 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { | 666 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { |
| 660 const ResultViewState state = GetState(); | 667 const ResultViewState state = GetState(); |
| 661 if (state != NORMAL) | 668 if (state != NORMAL) |
| 662 canvas->DrawColor(GetColor(state, BACKGROUND)); | 669 canvas->DrawColor(GetColor(state, BACKGROUND)); |
| 663 | 670 |
| 664 // NOTE: While animating the keyword match, both matches may be visible. | 671 // NOTE: While animating the keyword match, both matches may be visible. |
| 665 | 672 |
| 666 if (!ShowOnlyKeywordMatch()) { | 673 if (!ShowOnlyKeywordMatch()) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 gfx::Range range(offset, offset + text.length()); | 800 gfx::Range range(offset, offset + text.length()); |
| 794 destination->AppendText(text); | 801 destination->AppendText(text); |
| 795 const TextStyle& text_style = GetTextStyle(text_type); | 802 const TextStyle& text_style = GetTextStyle(text_type); |
| 796 // TODO(dschuyler): follow up on the problem of different font sizes within | 803 // TODO(dschuyler): follow up on the problem of different font sizes within |
| 797 // one RenderText. Maybe with destination->SetFontList(...). | 804 // one RenderText. Maybe with destination->SetFontList(...). |
| 798 destination->ApplyStyle(gfx::BOLD, is_bold, range); | 805 destination->ApplyStyle(gfx::BOLD, is_bold, range); |
| 799 destination->ApplyColor( | 806 destination->ApplyColor( |
| 800 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); | 807 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); |
| 801 destination->ApplyBaselineStyle(text_style.baseline, range); | 808 destination->ApplyBaselineStyle(text_style.baseline, range); |
| 802 } | 809 } |
| 810 | |
| 811 int OmniboxResultView::LeftMargin() const { | |
| 812 return ui::MaterialDesignController::IsModeMaterial() ? | |
| 813 model_->left_margin() : 0; | |
| 814 } | |
| 815 | |
| 816 int OmniboxResultView::RightMargin() const { | |
| 817 return ui::MaterialDesignController::IsModeMaterial() ? | |
| 818 model_->right_margin() : 0; | |
| 819 } | |
| OLD | NEW |