Commit 1bb2e6a5 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Clean up/simplify StyledLabel, part 4.

A whole bunch of miscellaneous small changes.

Bug: 1015717
Change-Id: Ia769176e993e46e0adba7993378a575445df7a5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1874705Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708854}
parent 93cf00b4
This diff is collapsed.
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <set> #include <set>
#include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
...@@ -169,6 +170,11 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { ...@@ -169,6 +170,11 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
}; };
using StyleRanges = std::list<StyleRange>; using StyleRanges = std::list<StyleRange>;
// Returns the starting X coordinate for the views in a line, based on the
// current |horizontal_alignment_| and insets and given the amount of excess
// space available on that line.
int StartX(int excess_space) const;
// Returns the default line height, based on the default style. // Returns the default line height, based on the default style.
int GetDefaultLineHeight() const; int GetDefaultLineHeight() const;
...@@ -194,7 +200,7 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { ...@@ -194,7 +200,7 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
int default_text_style_ = style::STYLE_PRIMARY; int default_text_style_ = style::STYLE_PRIMARY;
// Line height. If zero, style::GetLineHeight() is used. // Line height. If zero, style::GetLineHeight() is used.
int specified_line_height_; int specified_line_height_ = 0;
// The listener that will be informed of link clicks. // The listener that will be informed of link clicks.
StyledLabelListener* listener_; StyledLabelListener* listener_;
...@@ -212,16 +218,16 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener { ...@@ -212,16 +218,16 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
// This variable saves the result of the last GetHeightForWidth call in order // This variable saves the result of the last GetHeightForWidth call in order
// to avoid repeated calculation. // to avoid repeated calculation.
mutable gfx::Size calculated_size_; mutable gfx::Size calculated_size_;
mutable int width_at_last_size_calculation_; mutable int width_at_last_calculation_ = 0;
int width_at_last_layout_; int width_at_last_layout_ = 0;
// Background color on which the label is drawn, for auto color readability. // Background color on which the label is drawn, for auto color readability.
SkColor displayed_on_background_color_; SkColor displayed_on_background_color_ = SK_ColorWHITE;
bool displayed_on_background_color_set_; bool displayed_on_background_color_set_ = false;
// Controls whether the text is automatically re-colored to be readable on the // Controls whether the text is automatically re-colored to be readable on the
// background. // background.
bool auto_color_readability_enabled_; bool auto_color_readability_enabled_ = true;
// The horizontal alignment. This value is flipped for RTL. The default // The horizontal alignment. This value is flipped for RTL. The default
// behavior is to align left in LTR UI and right in RTL UI. // behavior is to align left in LTR UI and right in RTL UI.
......
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