| Index: ui/gfx/render_text.h
|
| diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
|
| index ce0a027b7a1607a39fc7cca89e6226609875cc2a..6d998de4472580ba3e72ff6cf0ecf4324d5f7ab8 100644
|
| --- a/ui/gfx/render_text.h
|
| +++ b/ui/gfx/render_text.h
|
| @@ -167,11 +167,6 @@ class GFX_EXPORT RenderText {
|
| }
|
| void SetHorizontalAlignment(HorizontalAlignment alignment);
|
|
|
| - VerticalAlignment vertical_alignment() const {
|
| - return vertical_alignment_;
|
| - }
|
| - void SetVerticalAlignment(VerticalAlignment alignment);
|
| -
|
| const FontList& font_list() const { return font_list_; }
|
| void SetFontList(const FontList& font_list);
|
| void SetFont(const Font& font);
|
| @@ -338,9 +333,11 @@ class GFX_EXPORT RenderText {
|
| // mode). Reserves room for the cursor if |cursor_enabled_| is true.
|
| int GetContentWidth();
|
|
|
| - // Returns the common baseline of the text. The returned value is the vertical
|
| - // offset from the top of |display_rect| to the text baseline, in pixels.
|
| - virtual int GetBaseline() = 0;
|
| + // Returns the common baseline of the text. The return value is the vertical
|
| + // offset from the top of |display_rect_| to the text baseline, in pixels.
|
| + // The baseline is determined from the font list and display rect, and does
|
| + // not depend on the text.
|
| + int GetBaseline();
|
|
|
| void Draw(Canvas* canvas);
|
|
|
| @@ -398,6 +395,30 @@ class GFX_EXPORT RenderText {
|
| const std::vector<internal::Line>& lines() const { return lines_; }
|
| void set_lines(std::vector<internal::Line>* lines) { lines_.swap(*lines); }
|
|
|
| + // Returns the baseline of the current text. The return value depends on
|
| + // the text and its layout while the return value of GetBaseline() doesn't.
|
| + // GetAlignmentOffset() takes into account the difference between them.
|
| + //
|
| + // We'd like a RenderText to show the text always on the same baseline
|
| + // regardless of the text, so the text does not jump up or down depending
|
| + // on the text. However, underlying layout engines return different baselines
|
| + // depending on the text. In general, layout engines determine the minimum
|
| + // bounding box for the text and return the baseline from the top of the
|
| + // bounding box. So the baseline changes depending on font metrics used to
|
| + // layout the text.
|
| + //
|
| + // For example, suppose there are FontA and FontB and the baseline of FontA
|
| + // is smaller than the one of FontB. If the text is laid out only with FontA,
|
| + // then the baseline of FontA may be returned. If the text includes some
|
| + // characters which are laid out with FontB, then the baseline of FontB may
|
| + // be returned.
|
| + //
|
| + // GetBaseline() returns the fixed baseline regardless of the text.
|
| + // GetLayoutTextBaseline() returns the baseline determined by the underlying
|
| + // layout engine, and it changes depending on the text. GetAlignmentOffset()
|
| + // returns the difference between them.
|
| + virtual int GetLayoutTextBaseline() = 0;
|
| +
|
| const Vector2d& GetUpdatedDisplayOffset();
|
|
|
| void set_cached_bounds_and_offset_valid(bool valid) {
|
| @@ -542,10 +563,6 @@ class GFX_EXPORT RenderText {
|
| // default is to align left if the application UI is LTR and right if RTL.
|
| HorizontalAlignment horizontal_alignment_;
|
|
|
| - // Vertical alignment of the text with respect to |display_rect_|. The
|
| - // default is to align vertically centered.
|
| - VerticalAlignment vertical_alignment_;
|
| -
|
| // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT.
|
| DirectionalityMode directionality_mode_;
|
|
|
| @@ -631,6 +648,11 @@ class GFX_EXPORT RenderText {
|
| // Get this point with GetUpdatedDisplayOffset (or risk using a stale value).
|
| Vector2d display_offset_;
|
|
|
| + // The baseline of the text. This is determined from the height of the
|
| + // display area and the cap height of the font list so the text is vertically
|
| + // centered.
|
| + int baseline_;
|
| +
|
| // The cached bounds and offset are invalidated by changes to the cursor,
|
| // selection, font, and other operations that adjust the visible text bounds.
|
| bool cached_bounds_and_offset_valid_;
|
|
|