| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_RENDER_TEXT_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_H_ |
| 6 #define UI_GFX_RENDER_TEXT_H_ | 6 #define UI_GFX_RENDER_TEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 bool insert_mode() const { return insert_mode_; } | 147 bool insert_mode() const { return insert_mode_; } |
| 148 void ToggleInsertMode(); | 148 void ToggleInsertMode(); |
| 149 | 149 |
| 150 bool focused() const { return focused_; } | 150 bool focused() const { return focused_; } |
| 151 void set_focused(bool focused) { focused_ = focused; } | 151 void set_focused(bool focused) { focused_ = focused; } |
| 152 | 152 |
| 153 const StyleRange& default_style() const { return default_style_; } | 153 const StyleRange& default_style() const { return default_style_; } |
| 154 void set_default_style(const StyleRange& style) { default_style_ = style; } | 154 void set_default_style(const StyleRange& style) { default_style_ = style; } |
| 155 | 155 |
| 156 // In an obscured (password) field, all text is drawn as asterisks or bullets. |
| 157 bool is_obscured() const { return obscured_; } |
| 158 void SetObscured(bool obscured); |
| 159 |
| 156 const Rect& display_rect() const { return display_rect_; } | 160 const Rect& display_rect() const { return display_rect_; } |
| 157 void SetDisplayRect(const Rect& r); | 161 void SetDisplayRect(const Rect& r); |
| 158 | 162 |
| 159 void set_fade_head(bool fade_head) { fade_head_ = fade_head; } | 163 void set_fade_head(bool fade_head) { fade_head_ = fade_head; } |
| 160 bool fade_head() const { return fade_head_; } | 164 bool fade_head() const { return fade_head_; } |
| 161 void set_fade_tail(bool fade_tail) { fade_tail_ = fade_tail; } | 165 void set_fade_tail(bool fade_tail) { fade_tail_ = fade_tail; } |
| 162 bool fade_tail() const { return fade_tail_; } | 166 bool fade_tail() const { return fade_tail_; } |
| 163 | 167 |
| 164 // This cursor position corresponds to SelectionModel::selection_end. In | 168 // This cursor position corresponds to SelectionModel::selection_end. In |
| 165 // addition to representing the selection end, it's also where logical text | 169 // addition to representing the selection end, it's also where logical text |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // Update the layout so that the next draw request can correctly | 323 // Update the layout so that the next draw request can correctly |
| 320 // render the text and its attributes. | 324 // render the text and its attributes. |
| 321 virtual void UpdateLayout() = 0; | 325 virtual void UpdateLayout() = 0; |
| 322 | 326 |
| 323 // Ensure the text is laid out. | 327 // Ensure the text is laid out. |
| 324 virtual void EnsureLayout() = 0; | 328 virtual void EnsureLayout() = 0; |
| 325 | 329 |
| 326 // Draw the text. | 330 // Draw the text. |
| 327 virtual void DrawVisualText(Canvas* canvas) = 0; | 331 virtual void DrawVisualText(Canvas* canvas) = 0; |
| 328 | 332 |
| 333 // Like text() except that it returns asterisks or bullets if this is an |
| 334 // obscured field. |
| 335 string16 GetDisplayText() const; |
| 336 |
| 329 // Apply composition style (underline) to composition range and selection | 337 // Apply composition style (underline) to composition range and selection |
| 330 // style (foreground) to selection range. | 338 // style (foreground) to selection range. |
| 331 void ApplyCompositionAndSelectionStyles(StyleRanges* style_ranges); | 339 void ApplyCompositionAndSelectionStyles(StyleRanges* style_ranges); |
| 332 | 340 |
| 333 // Returns the text origin after applying text alignment and display offset. | 341 // Returns the text origin after applying text alignment and display offset. |
| 334 Point GetTextOrigin(); | 342 Point GetTextOrigin(); |
| 335 | 343 |
| 336 // Convert points from the text space to the view space and back. | 344 // Convert points from the text space to the view space and back. |
| 337 // Handles the display area, display offset, and the application LTR/RTL mode. | 345 // Handles the display area, display offset, and the application LTR/RTL mode. |
| 338 Point ToTextPoint(const Point& point); | 346 Point ToTextPoint(const Point& point); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 351 // Applies fade effects to |renderer|. | 359 // Applies fade effects to |renderer|. |
| 352 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); | 360 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); |
| 353 | 361 |
| 354 private: | 362 private: |
| 355 friend class RenderTextTest; | 363 friend class RenderTextTest; |
| 356 | 364 |
| 357 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyle); | 365 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyle); |
| 358 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, CustomDefaultStyle); | 366 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, CustomDefaultStyle); |
| 359 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ApplyStyleRange); | 367 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ApplyStyleRange); |
| 360 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StyleRangesAdjust); | 368 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StyleRangesAdjust); |
| 369 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PasswordCensorship); |
| 361 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); | 370 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); |
| 362 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SelectionModels); | 371 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SelectionModels); |
| 363 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, OriginForSkiaDrawing); | 372 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, OriginForSkiaDrawing); |
| 364 | 373 |
| 365 // Set the cursor to |position|, with the caret trailing the previous | 374 // Set the cursor to |position|, with the caret trailing the previous |
| 366 // grapheme, or if there is no previous grapheme, leading the cursor position. | 375 // grapheme, or if there is no previous grapheme, leading the cursor position. |
| 367 // If |select| is false, the selection start is moved to the same position. | 376 // If |select| is false, the selection start is moved to the same position. |
| 368 // If the |position| is not a cursorable position (not on grapheme boundary), | 377 // If the |position| is not a cursorable position (not on grapheme boundary), |
| 369 // it is a NO-OP. | 378 // it is a NO-OP. |
| 370 void MoveCursorTo(size_t position, bool select); | 379 void MoveCursorTo(size_t position, bool select); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 bool focused_; | 413 bool focused_; |
| 405 | 414 |
| 406 // Composition text range. | 415 // Composition text range. |
| 407 ui::Range composition_range_; | 416 ui::Range composition_range_; |
| 408 | 417 |
| 409 // List of style ranges. Elements in the list never overlap each other. | 418 // List of style ranges. Elements in the list never overlap each other. |
| 410 StyleRanges style_ranges_; | 419 StyleRanges style_ranges_; |
| 411 // The default text style. | 420 // The default text style. |
| 412 StyleRange default_style_; | 421 StyleRange default_style_; |
| 413 | 422 |
| 423 // True if this is an obscured (password) field. |
| 424 bool obscured_; |
| 425 |
| 414 // Fade text head and/or tail, if text doesn't fit into |display_rect_|. | 426 // Fade text head and/or tail, if text doesn't fit into |display_rect_|. |
| 415 bool fade_head_; | 427 bool fade_head_; |
| 416 bool fade_tail_; | 428 bool fade_tail_; |
| 417 | 429 |
| 418 // The local display area for rendering the text. | 430 // The local display area for rendering the text. |
| 419 Rect display_rect_; | 431 Rect display_rect_; |
| 420 | 432 |
| 421 // The offset for the text to be drawn, relative to the display area. | 433 // The offset for the text to be drawn, relative to the display area. |
| 422 // Get this point with GetUpdatedDisplayOffset (or risk using a stale value). | 434 // Get this point with GetUpdatedDisplayOffset (or risk using a stale value). |
| 423 Point display_offset_; | 435 Point display_offset_; |
| 424 | 436 |
| 425 // The cached bounds and offset are invalidated by changes to the cursor, | 437 // The cached bounds and offset are invalidated by changes to the cursor, |
| 426 // selection, font, and other operations that adjust the visible text bounds. | 438 // selection, font, and other operations that adjust the visible text bounds. |
| 427 bool cached_bounds_and_offset_valid_; | 439 bool cached_bounds_and_offset_valid_; |
| 428 | 440 |
| 429 DISALLOW_COPY_AND_ASSIGN(RenderText); | 441 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 430 }; | 442 }; |
| 431 | 443 |
| 432 } // namespace gfx | 444 } // namespace gfx |
| 433 | 445 |
| 434 #endif // UI_GFX_RENDER_TEXT_H_ | 446 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |