Commit f8ef156d authored by tdanderson's avatar tdanderson Committed by Commit bot

[Ash] Disallow calling HoverHighlightView::SetSubText() with an empty string

SetSubText() in HoverHighlight view should not be called
if the parameter string is empty, otherwise multi-line
rows in the system menu will have the incorrect layout
of their primary text.

BUG=715615
TEST=manual

Review-Url: https://codereview.chromium.org/2844933003
Cr-Commit-Position: refs/heads/master@{#467813}
parent 0b6049cb
......@@ -57,11 +57,13 @@ void HoverHighlightView::SetRightViewVisible(bool visible) {
void HoverHighlightView::SetSubText(const base::string16& sub_text) {
DCHECK(text_label_);
DCHECK(!sub_text.empty());
if (!sub_text_label_) {
sub_text_label_ = TrayPopupUtils::CreateDefaultLabel();
tri_view_->AddView(TriView::Container::CENTER, sub_text_label_);
}
TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION);
sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
sub_style.SetupLabel(sub_text_label_);
......@@ -117,7 +119,8 @@ void HoverHighlightView::DoAddIconAndLabels(
style.SetupLabel(text_label_);
tri_view_->AddView(TriView::Container::CENTER, text_label_);
SetSubText(sub_text);
if (!sub_text.empty())
SetSubText(sub_text);
tri_view_->SetContainerVisible(TriView::Container::END, false);
......
......@@ -69,8 +69,8 @@ class HoverHighlightView : public ActionableView {
// Hide or show the right view.
void SetRightViewVisible(bool visible);
// Sets text for the sub label. Precondition for this function is that
// |text_label_| is non-null.
// Sets the text of |sub_text_label_| to |sub_text|. Prior to calling this
// function, |text_label_| must not be null and |sub_text| must not be empty.
void SetSubText(const base::string16& sub_text);
// Allows view to expand its height. Size of unexapandable view is fixed and
......
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