Commit 50b5f88f authored by Dave Schuyler's avatar Dave Schuyler Committed by Commit Bot

[Omnibox] fix to OmniboxTextView to improve CharTypedToRepaintLatency

This Cl potentially fixes a regression in CharTypedToRepaintLatency UMA
by restoring a shortcut for one line (non-wrapping) answers.

Change-Id: I93d264610f73dfab9db10c81c4ba198adab14c90
Reviewed-on: https://chromium-review.googlesource.com/1014412
Commit-Queue: Dave Schuyler <dschuyler@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551220}
parent 294998d2
......@@ -131,7 +131,8 @@ OmniboxTextView::OmniboxTextView(OmniboxResultView* result_view,
: result_view_(result_view),
font_height_(std::max(
font_list.GetHeight(),
font_list.DeriveWithWeight(gfx::Font::Weight::BOLD).GetHeight())) {}
font_list.DeriveWithWeight(gfx::Font::Weight::BOLD).GetHeight())),
wrap_text_lines_(false) {}
OmniboxTextView::~OmniboxTextView() {}
......@@ -152,6 +153,10 @@ const char* OmniboxTextView::GetClassName() const {
int OmniboxTextView::GetHeightForWidth(int width) const {
if (!render_text_)
return 0;
// If text wrapping is not called for we can simply return the font height.
if (!wrap_text_lines_) {
return font_height_;
}
render_text_->SetDisplayRect(gfx::Rect(width, 0));
gfx::Size string_size = render_text_->GetStringSize();
return string_size.height();
......@@ -229,6 +234,7 @@ void OmniboxTextView::SetText(const base::string16& text) {
}
void OmniboxTextView::SetText(const SuggestionAnswer::ImageLine& line) {
wrap_text_lines_ = line.num_text_lines() > 1;
// This assumes that the first text type in the line can be used to specify
// the font for all the text fields in the line. For now this works but
// eventually it may be necessary to get RenderText to support multiple font
......
......@@ -88,6 +88,10 @@ class OmniboxTextView : public views::View {
// Font settings for this view.
int font_height_;
// Whether to wrap lines if the width is too narrow for the whole string.
bool wrap_text_lines_;
// The primary data for this class.
mutable std::unique_ptr<gfx::RenderText> render_text_;
DISALLOW_COPY_AND_ASSIGN(OmniboxTextView);
......
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