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 {
void OmniboxMatchCellView::SetTailSuggestCommonPrefixWidth(
const base::string16& common_prefix) {
InvalidateLayout();
if (common_prefix.empty()) {
tail_suggest_common_prefix_width_ = 0;
return;
......
......@@ -228,7 +228,6 @@ bool OmniboxPopupContentsView::IsOpen() const {
void OmniboxPopupContentsView::InvalidateLine(size_t line) {
OmniboxResultView* result = result_view_at(line);
result->Invalidate();
result->SchedulePaint();
if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) {
result->ShowKeyword(IsSelectedIndex(line) &&
......
......@@ -137,8 +137,8 @@ void OmniboxResultView::SetMatch(const AutocompleteMatch& match) {
keyword_match->description_class);
}
InvalidateLayout();
Invalidate();
Layout();
}
void OmniboxResultView::ShowKeyword(bool show_keyword) {
......@@ -226,13 +226,10 @@ OmniboxPartState OmniboxResultView::GetThemeState() const {
void OmniboxResultView::OnMatchIconUpdated() {
// The new icon will be fetched during Invalidate().
Invalidate();
SchedulePaint();
}
void OmniboxResultView::SetRichSuggestionImage(const gfx::ImageSkia& image) {
suggestion_view_->SetImage(image);
Layout();
SchedulePaint();
}
////////////////////////////////////////////////////////////////////////////////
......@@ -418,7 +415,6 @@ gfx::Size OmniboxResultView::CalculatePreferredSize() const {
void OmniboxResultView::OnThemeChanged() {
Invalidate(true);
SchedulePaint();
}
void OmniboxResultView::ProvideButtonFocusHint() {
......@@ -461,7 +457,6 @@ void OmniboxResultView::SetHovered(bool hovered) {
if (is_hovered_ != hovered) {
is_hovered_ = hovered;
Invalidate();
SchedulePaint();
}
}
......@@ -480,13 +475,12 @@ const char* OmniboxResultView::GetClassName() const {
void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
animation_->SetSlideDuration(base::TimeDelta::FromMilliseconds(width() / 4));
Layout();
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////
// OmniboxResultView, gfx::AnimationProgressed overrides, private:
void OmniboxResultView::AnimationProgressed(const gfx::Animation* animation) {
Layout();
SchedulePaint();
InvalidateLayout();
}
......@@ -158,6 +158,7 @@ void OmniboxTextView::OnPaint(gfx::Canvas* canvas) {
void OmniboxTextView::ApplyTextColor(OmniboxPart part) {
render_text_->SetColor(result_view_->GetColor(part));
SchedulePaint();
}
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