Chromium Code Reviews| Index: ui/gfx/render_text.h |
| diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h |
| index 7e0b48310116e1fa2cf8ac004389c6bae197a084..9d1676a5b46513ba74149114e9498d478726e5e1 100644 |
| --- a/ui/gfx/render_text.h |
| +++ b/ui/gfx/render_text.h |
| @@ -40,6 +40,10 @@ struct SkPoint; |
| class SkShader; |
| class SkTypeface; |
| +namespace views { |
|
msw
2016/12/13 03:04:55
Hmm, gfx shouldn't reference views, and I'm not su
karandeepb
2016/12/16 02:58:38
Would like to have a test testing multiline select
|
| +class LabelSelectionTest; |
| +} |
| + |
| namespace gfx { |
| namespace test { |
| class RenderTextTestApi; |
| @@ -209,14 +213,17 @@ void ApplyRenderParams(const FontRenderParams& params, |
| // for rendering and translation between logical and visual data. |
| class GFX_EXPORT RenderText { |
| public: |
| -// The character used for displaying obscured text. |
| -// TODO(benrg): GTK uses the first of U+25CF, U+2022, U+2731, U+273A, '*' |
| -// that's available in the font (find_invisible_char() in gtkentry.c). |
| -// Use a bullet character on Mac. |
| #if defined(OS_MACOSX) |
| + // The character used for displaying obscured text. Use a bullet character on |
| + // Mac. |
| static constexpr base::char16 kPasswordReplacementChar = 0x2022; |
| + |
| + // On Mac, while selecting text if the cursor is outside the vertical text |
| + // bounds, drag to the end of the text. |
| + static constexpr bool kDragToEndIfOutsideVerticalBounds = true; |
| #else |
| static constexpr base::char16 kPasswordReplacementChar = '*'; |
| + static constexpr bool kDragToEndIfOutsideVerticalBounds = false; |
| #endif |
| virtual ~RenderText(); |
| @@ -412,10 +419,11 @@ class GFX_EXPORT RenderText { |
| } |
| base::i18n::TextDirection GetDisplayTextDirection(); |
| - // Returns the visual movement direction corresponding to the logical end |
| - // of the text, considering only the dominant direction returned by |
| - // |GetDisplayTextDirection()|, not the direction of a particular run. |
| + // Returns the visual movement direction corresponding to the logical |
| + // end/beginning of the text, considering only the dominant direction returned |
| + // by |GetDisplayTextDirection()|, not the direction of a particular run. |
| VisualCursorDirection GetVisualDirectionOfLogicalEnd(); |
| + VisualCursorDirection GetVisualDirectionOfLogicalBeginning(); |
| // Returns the text used to display, which may be obscured, truncated or |
| // elided. The subclass may compute elided text on the fly, or use |
| @@ -473,6 +481,7 @@ class GFX_EXPORT RenderText { |
| // is longer than the textfield. Subsequent text, cursor, or bounds changes |
| // may invalidate returned values. Note that |caret| must be placed at |
| // grapheme boundary, i.e. caret.caret_pos() must be a cursorable position. |
| + // TODO(crbug.com/248597): Add multiline support. |
| Rect GetCursorBounds(const SelectionModel& caret, bool insert_mode); |
| // Compute the current cursor bounds, panning the text to show the cursor in |
| @@ -591,10 +600,15 @@ class GFX_EXPORT RenderText { |
| const SelectionModel& selection, |
| VisualCursorDirection direction) = 0; |
| - // Get the SelectionModels corresponding to visual text ends. |
| + // Get the selection model corresponding to visual text ends. |
| // The returned value represents a cursor/caret position without a selection. |
| SelectionModel EdgeSelectionModel(VisualCursorDirection direction); |
| + // Get the selection model corresponding to visual text ends for |line_index|. |
| + // The returned value represents a cursor/caret position without a selection. |
| + SelectionModel LineSelectionModel(size_t line_index, |
| + gfx::VisualCursorDirection direction); |
| + |
| // Sets the selection model, the argument is assumed to be valid. |
| virtual void SetSelectionModel(const SelectionModel& model); |
| @@ -640,14 +654,10 @@ class GFX_EXPORT RenderText { |
| void ApplyCompositionAndSelectionStyles(); |
| void UndoCompositionAndSelectionStyles(); |
| - // Convert points from the text space to the view space and back. Handles the |
| - // display area, display offset, application LTR/RTL mode and multiline. |
| - Point ToTextPoint(const Point& point); |
| + // Convert points from the text space to the view space. Handles the display |
| + // area, display offset, application LTR/RTL mode and multiline. |
| Point ToViewPoint(const Point& point); |
| - // Convert a text space x-coordinate range to rects in view space. |
| - std::vector<Rect> TextBoundsToViewBounds(const Range& x); |
| - |
| // Get the alignment, resolving ALIGN_TO_HEAD with the current text direction. |
| HorizontalAlignment GetCurrentHorizontalAlignment(); |
| @@ -681,6 +691,7 @@ class GFX_EXPORT RenderText { |
| private: |
| friend class test::RenderTextTestApi; |
| + friend class ::views::LabelSelectionTest; |
| // Set the cursor to |position|, with the caret trailing the previous |
| // grapheme, or if there is no previous grapheme, leading the cursor position. |