Commit 3053cc09 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

[omnibox] Update placeholder text and fade animation colors on theme change.

Without this, toggling between light/dark mode could produce hard-to-read
text.

Bug: none
Change-Id: Ic61c5d61b2da5dc6d58485dd0c604ab34da7d614
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986309
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728348}
parent 6e92cbd8
...@@ -619,12 +619,8 @@ void LocationBarView::OnThemeChanged() { ...@@ -619,12 +619,8 @@ void LocationBarView::OnThemeChanged() {
RefreshBackground(); RefreshBackground();
// When the native theme changes, so can the colors used for emphasized text.
omnibox_view_->EmphasizeURLComponents();
location_icon_view_->Update(/*suppress_animations=*/false); location_icon_view_->Update(/*suppress_animations=*/false);
RefreshClearAllButtonIcon(); RefreshClearAllButtonIcon();
SchedulePaint();
} }
void LocationBarView::ChildPreferredSizeChanged(views::View* child) { void LocationBarView::ChildPreferredSizeChanged(views::View* child) {
......
...@@ -204,15 +204,6 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, ...@@ -204,15 +204,6 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
friendly_suggestion_text_prefix_length_(0) { friendly_suggestion_text_prefix_length_(0) {
SetID(VIEW_ID_OMNIBOX); SetID(VIEW_ID_OMNIBOX);
SetFontList(font_list); SetFontList(font_list);
if (base::FeatureList::IsEnabled(
omnibox::kHideSteadyStateUrlPathQueryAndRef)) {
// The animation only applies when the path is dimmed to begin with.
SkColor starting_color =
location_bar_view_->GetColor(OmniboxPart::LOCATION_BAR_TEXT_DIMMED);
path_fade_animation_ =
std::make_unique<PathFadeAnimation>(this, starting_color);
}
} }
OmniboxViewViews::~OmniboxViewViews() { OmniboxViewViews::~OmniboxViewViews() {
...@@ -231,15 +222,14 @@ void OmniboxViewViews::Init() { ...@@ -231,15 +222,14 @@ void OmniboxViewViews::Init() {
SetTextInputType(ui::TEXT_INPUT_TYPE_URL); SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL); GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL);
GetRenderText()->set_symmetric_selection_visual_bounds(true); GetRenderText()->set_symmetric_selection_visual_bounds(true);
InstallPlaceholderText();
scoped_template_url_service_observer_.Add(
model()->client()->GetTemplateURLService());
if (popup_window_mode_) if (popup_window_mode_)
SetReadOnly(true); SetReadOnly(true);
if (location_bar_view_) { if (location_bar_view_) {
InstallPlaceholderText();
scoped_template_url_service_observer_.Add(
model()->client()->GetTemplateURLService());
// Initialize the popup view using the same font. // Initialize the popup view using the same font.
popup_view_.reset( popup_view_.reset(
new OmniboxPopupContentsView(this, model(), location_bar_view_, new OmniboxPopupContentsView(this, model(), location_bar_view_,
...@@ -309,9 +299,6 @@ void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { ...@@ -309,9 +299,6 @@ void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) {
} }
void OmniboxViewViews::InstallPlaceholderText() { void OmniboxViewViews::InstallPlaceholderText() {
set_placeholder_text_color(
location_bar_view_->GetColor(OmniboxPart::LOCATION_BAR_TEXT_DIMMED));
const TemplateURL* const default_provider = const TemplateURL* const default_provider =
model()->client()->GetTemplateURLService()->GetDefaultSearchProvider(); model()->client()->GetTemplateURLService()->GetDefaultSearchProvider();
if (default_provider) { if (default_provider) {
...@@ -586,6 +573,21 @@ bool OmniboxViewViews::ShouldDoLearning() { ...@@ -586,6 +573,21 @@ bool OmniboxViewViews::ShouldDoLearning() {
return location_bar_view_ && !location_bar_view_->profile()->IsOffTheRecord(); return location_bar_view_ && !location_bar_view_->profile()->IsOffTheRecord();
} }
void OmniboxViewViews::OnThemeChanged() {
const SkColor dimmed_text_color = GetOmniboxColor(
GetThemeProvider(), OmniboxPart::LOCATION_BAR_TEXT_DIMMED);
set_placeholder_text_color(dimmed_text_color);
if (base::FeatureList::IsEnabled(
omnibox::kHideSteadyStateUrlPathQueryAndRef)) {
// The animation only applies when the path is dimmed to begin with.
path_fade_animation_ =
std::make_unique<PathFadeAnimation>(this, dimmed_text_color);
}
EmphasizeURLComponents();
}
bool OmniboxViewViews::IsDropCursorForInsertion() const { bool OmniboxViewViews::IsDropCursorForInsertion() const {
// Dragging text from within omnibox itself will behave like text input // Dragging text from within omnibox itself will behave like text input
// editor, showing insertion-style drop cursor as usual; // editor, showing insertion-style drop cursor as usual;
...@@ -1060,9 +1062,9 @@ int OmniboxViewViews::GetOmniboxTextLength() const { ...@@ -1060,9 +1062,9 @@ int OmniboxViewViews::GetOmniboxTextLength() const {
} }
void OmniboxViewViews::SetEmphasis(bool emphasize, const gfx::Range& range) { void OmniboxViewViews::SetEmphasis(bool emphasize, const gfx::Range& range) {
SkColor color = location_bar_view_->GetColor( SkColor color = GetOmniboxColor(
emphasize ? OmniboxPart::LOCATION_BAR_TEXT_DEFAULT GetThemeProvider(), emphasize ? OmniboxPart::LOCATION_BAR_TEXT_DEFAULT
: OmniboxPart::LOCATION_BAR_TEXT_DIMMED); : OmniboxPart::LOCATION_BAR_TEXT_DIMMED);
if (range.IsValid()) if (range.IsValid())
ApplyColor(color, range); ApplyColor(color, range);
else else
......
...@@ -154,6 +154,7 @@ class OmniboxViewViews : public OmniboxView, ...@@ -154,6 +154,7 @@ class OmniboxViewViews : public OmniboxView,
protected: protected:
// views::Textfield: // views::Textfield:
void OnThemeChanged() override;
bool IsDropCursorForInsertion() const override; bool IsDropCursorForInsertion() const override;
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment