summaryrefslogtreecommitdiffstats
path: root/ui/gfx/render_text.h
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 21:57:31 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 21:57:31 +0000
commit46cb5380832a688d32cc39a25080381f90a204f2 (patch)
tree66795e797e715e0a32b2098ad955f93cd8bb08b0 /ui/gfx/render_text.h
parentf06188681397c7d6bc785d5dc9c26092c1f3ac03 (diff)
downloadchromium_src-46cb5380832a688d32cc39a25080381f90a204f2.zip
chromium_src-46cb5380832a688d32cc39a25080381f90a204f2.tar.gz
chromium_src-46cb5380832a688d32cc39a25080381f90a204f2.tar.bz2
Add RenderText DirectionalityMode enum and support; etc.
Add gfx::DirectionalityMode enum. Add RenderText::SetDirectionalityMode and member. Revise/consolidate RenderText::GetTextDirection. Expand on existing unit tests; minor cleanup. Consume GetTextDirection in layout initialization: -Windows: RenderTextWin::ItemizeLogicalText() -Linux: SetupPangoLayoutWithoutFont() -Mac: Add TODO in RenderTextMac::EnsureLayout() BUG=134746 TEST=Existing/updated unit tests, no behavioral changes! Review URL: https://chromiumcodereview.appspot.com/10807082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text.h')
-rw-r--r--ui/gfx/render_text.h30
1 files changed, 11 insertions, 19 deletions
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index a6265b0..bebe109 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -22,6 +22,7 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/selection_model.h"
#include "ui/gfx/shadow_value.h"
+#include "ui/gfx/text_constants.h"
class SkCanvas;
class SkDrawLooper;
@@ -90,23 +91,6 @@ struct UI_EXPORT StyleRange {
typedef std::vector<StyleRange> StyleRanges;
-// TODO(msw): Distinguish between logical character stops and glyph stops?
-// CHARACTER_BREAK cursor movements should stop at neighboring characters.
-// WORD_BREAK cursor movements should stop at the nearest word boundaries.
-// LINE_BREAK cursor movements should stop at the text ends as shown on screen.
-enum BreakType {
- CHARACTER_BREAK,
- WORD_BREAK,
- LINE_BREAK,
-};
-
-// Horizontal text alignment styles.
-enum HorizontalAlignment {
- ALIGN_LEFT,
- ALIGN_CENTER,
- ALIGN_RIGHT,
-};
-
// RenderText represents an abstract model of styled text and its corresponding
// visual layout. Support is built in for a cursor, a selection, simple styling,
// complex scripts, and bi-directional text. Implementations provide mechanisms
@@ -246,8 +230,9 @@ class UI_EXPORT RenderText {
// Apply |default_style_| over the entire text range.
void ApplyDefaultStyle();
- // Returns the dominant direction of the current text.
- virtual base::i18n::TextDirection GetTextDirection() = 0;
+ // Set the text directionality mode and get the text direction yielded.
+ void SetDirectionalityMode(DirectionalityMode mode);
+ base::i18n::TextDirection GetTextDirection();
// Returns the visual movement direction corresponding to the logical end
// of the text, considering only the dominant direction returned by
@@ -439,6 +424,13 @@ class UI_EXPORT RenderText {
// Horizontal alignment of the text with respect to |display_rect_|.
HorizontalAlignment horizontal_alignment_;
+ // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT.
+ DirectionalityMode directionality_mode_;
+
+ // The cached text direction, potentially computed from the text or UI locale.
+ // Use GetTextDirection(), do not use this potentially invalid value directly!
+ base::i18n::TextDirection text_direction_;
+
// A list of fonts used to render |text_|.
FontList font_list_;