Commit aad67f4e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

[omnibox] use InvalidateLayout()/SchedulePaint() more correctly.

Some places called Layout() instead of InvalidateLayout(), which is less
efficient and works poorly with layout managers.

Some places did not SchedulePaint() when changing characteristics that would
affect paint, e.g. text color.

Some places called InvalidateLayout() or SchedulePaint() unnecessarily, e.g.
after calling another function that should do these as needed.

Bug: none
Change-Id: Ie2cf7f01c0e1bccaf0a98365ed0e6fb63bfe7f67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857569
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706264}
parent d5a7fb16
...@@ -333,6 +333,7 @@ gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const { ...@@ -333,6 +333,7 @@ gfx::Size OmniboxMatchCellView::CalculatePreferredSize() const {
void OmniboxMatchCellView::SetTailSuggestCommonPrefixWidth( void OmniboxMatchCellView::SetTailSuggestCommonPrefixWidth(
const base::string16& common_prefix) { const base::string16& common_prefix) {
InvalidateLayout();
if (common_prefix.empty()) { if (common_prefix.empty()) {
tail_suggest_common_prefix_width_ = 0; tail_suggest_common_prefix_width_ = 0;
return; return;
......
...@@ -228,7 +228,6 @@ bool OmniboxPopupContentsView::IsOpen() const { ...@@ -228,7 +228,6 @@ bool OmniboxPopupContentsView::IsOpen() const {
void OmniboxPopupContentsView::InvalidateLine(size_t line) { void OmniboxPopupContentsView::InvalidateLine(size_t line) {
OmniboxResultView* result = result_view_at(line); OmniboxResultView* result = result_view_at(line);
result->Invalidate(); result->Invalidate();
result->SchedulePaint();
if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) { if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) {
result->ShowKeyword(IsSelectedIndex(line) && result->ShowKeyword(IsSelectedIndex(line) &&
......
...@@ -137,8 +137,8 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) { ...@@ -137,8 +137,8 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) {
keyword_match->description_class); keyword_match->description_class);
} }
InvalidateLayout();
Invalidate(); Invalidate();
Layout();
} }
void OmniboxResultView::ShowKeyword(bool show_keyword) { void OmniboxResultView::ShowKeyword(bool show_keyword) {
...@@ -226,13 +226,10 @@ OmniboxPartState OmniboxResultView::GetThemeState() const { ...@@ -226,13 +226,10 @@ OmniboxPartState OmniboxResultView::GetThemeState() const {
void OmniboxResultView::OnMatchIconUpdated() { void OmniboxResultView::OnMatchIconUpdated() {
// The new icon will be fetched during Invalidate(). // The new icon will be fetched during Invalidate().
Invalidate(); Invalidate();
SchedulePaint();
} }
void OmniboxResultView::SetRichSuggestionImage(const gfx::ImageSkia& image) { void OmniboxResultView::SetRichSuggestionImage(const gfx::ImageSkia& image) {
suggestion_view_->SetImage(image); suggestion_view_->SetImage(image);
Layout();
SchedulePaint();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -418,7 +415,6 @@ gfx::Size OmniboxResultView::CalculatePreferredSize() const { ...@@ -418,7 +415,6 @@ gfx::Size OmniboxResultView::CalculatePreferredSize() const {
void OmniboxResultView::OnThemeChanged() { void OmniboxResultView::OnThemeChanged() {
Invalidate(true); Invalidate(true);
SchedulePaint();
} }
void OmniboxResultView::ProvideButtonFocusHint() { void OmniboxResultView::ProvideButtonFocusHint() {
...@@ -461,7 +457,6 @@ void OmniboxResultView::SetHovered(bool hovered) { ...@@ -461,7 +457,6 @@ void OmniboxResultView::SetHovered(bool hovered) {
if (is_hovered_ != hovered) { if (is_hovered_ != hovered) {
is_hovered_ = hovered; is_hovered_ = hovered;
Invalidate(); Invalidate();
SchedulePaint();
} }
} }
...@@ -480,13 +475,12 @@ const char* OmniboxResultView::GetClassName() const { ...@@ -480,13 +475,12 @@ const char* OmniboxResultView::GetClassName() const {
void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
animation_->SetSlideDuration(base::TimeDelta::FromMilliseconds(width() / 4)); animation_->SetSlideDuration(base::TimeDelta::FromMilliseconds(width() / 4));
Layout(); InvalidateLayout();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// OmniboxResultView, gfx::AnimationProgressed overrides, private: // OmniboxResultView, gfx::AnimationProgressed overrides, private:
void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) { void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) {
Layout(); InvalidateLayout();
SchedulePaint();
} }
...@@ -158,6 +158,7 @@ void OmniboxTextView::OnPaint(gfx::Canvas* canvas) { ...@@ -158,6 +158,7 @@ void OmniboxTextView::OnPaint(gfx::Canvas* canvas) {
void OmniboxTextView::ApplyTextColor(OmniboxPart part) { void OmniboxTextView::ApplyTextColor(OmniboxPart part) {
render_text_->SetColor(result_view_->GetColor(part)); render_text_->SetColor(result_view_->GetColor(part));
SchedulePaint();
} }
const base::string16& OmniboxTextView::text() const { const base::string16& OmniboxTextView::text() const {
......
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