File: text_constants.h

package info (click to toggle)
chromium-browser 70.0.3538.110-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,619,476 kB
  • sloc: cpp: 13,024,755; ansic: 1,349,823; python: 916,672; xml: 314,489; java: 280,047; asm: 276,936; perl: 75,771; objc: 66,634; sh: 45,860; cs: 28,354; php: 11,064; makefile: 10,911; yacc: 9,109; tcl: 8,403; ruby: 4,065; lex: 1,779; pascal: 1,411; lisp: 1,055; awk: 41; jsp: 39; sed: 17; sql: 3
file content (141 lines) | stat: -rw-r--r-- 6,218 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GFX_TEXT_CONSTANTS_H_
#define UI_GFX_TEXT_CONSTANTS_H_

namespace gfx {

// TODO(msw): Distinguish between logical character stops and glyph stops?
// TODO(msw): Merge with base::i18n::BreakIterator::BreakType.
enum BreakType {
  CHARACTER_BREAK = 0, // Stop cursor movement on neighboring characters.
  WORD_BREAK,          // Stop cursor movement on nearest word boundaries.
  LINE_BREAK,          // Stop cursor movement on line ends as shown on screen.
};

// Specifies the selection behavior for a move/move-and-select command. For
// example consider the state "ab|cd|e", i.e. cd is selected. Assume the
// selection direction is from left to right. If we move to the beginning of the
// line (LINE_BREAK, CURSOR_LEFT), the resultant state is:
// "|ab|cde" for SELECTION_RETAIN, selection direction from right to left.
// "|abcd|e" for SELECTION_EXTEND, selection direction from right to left.
// "ab|cde" for SELECTION_CARET.
// "|abcde" for SELECTION_NONE.
enum SelectionBehavior {
  // Default behavior for a move-and-select command. The selection start point
  // remains the same. For example, this is the behavior of textfields on Mac
  // for the command moveUpAndModifySelection (Shift + Up).
  SELECTION_RETAIN,

  // Use for move-and-select commands that want the existing selection to be
  // extended in the opposite direction, when the selection direction is
  // reversed. For example, this is the behavior for textfields on Mac for the
  // command moveToLeftEndOfLineAndModifySelection (Command + Shift + Left).
  SELECTION_EXTEND,

  // Use for move-and-select commands that want the existing selection to reduce
  // to a caret, when the selection direction is reversed. For example, this is
  // the behavior for textfields on Mac for the command
  // moveWordLeftAndModifySelection (Alt + Shift + Left).
  SELECTION_CARET,

  // No selection. To be used for move commands that don't want to cause a
  // selection, and that want to collapse any pre-existing selection.
  SELECTION_NONE,
};

// Specifies the word wrapping behavior when a word would exceed the available
// display width. All words that are too wide will be put on a new line, and
// then:
enum WordWrapBehavior {
  IGNORE_LONG_WORDS,   // Overflowing word text is left on that line.
  TRUNCATE_LONG_WORDS, // Overflowing word text is truncated.
  ELIDE_LONG_WORDS,    // Overflowing word text is elided at the ellipsis.
  WRAP_LONG_WORDS,     // Overflowing word text is wrapped over multiple lines.
};

// Horizontal text alignment modes.
enum HorizontalAlignment {
  ALIGN_LEFT = 0, // Align the text's left edge with that of its display area.
  ALIGN_CENTER,   // Align the text's center with that of its display area.
  ALIGN_RIGHT,    // Align the text's right edge with that of its display area.
  ALIGN_TO_HEAD,  // Align the text to its first strong character's direction.
};

// The directionality modes used to determine the base text direction.
enum DirectionalityMode {
  DIRECTIONALITY_FROM_TEXT = 0,  // Use the first strong character's direction.
  DIRECTIONALITY_FROM_UI,        // Use the UI locale's text reading direction.
  DIRECTIONALITY_FORCE_LTR,      // Use LTR regardless of content or UI locale.
  DIRECTIONALITY_FORCE_RTL,      // Use RTL regardless of content or UI locale.
  // Note: Unless the experimental feature LeftToRightUrls is enabled,
  // DIRECTIONALITY_AS_URL is the same as DIRECTIONALITY_FORCE_LTR.
  DIRECTIONALITY_AS_URL,  // FORCE_LTR with additional rules for URLs.
};

// Text styles and adornments.
// TODO(msw): Merge with gfx::Font::FontStyle.
enum TextStyle {
  ITALIC = 0,
  STRIKE,
  UNDERLINE,
  HEAVY_UNDERLINE,
  NUM_TEXT_STYLES,
};

// Text baseline offset types.
// Figure of font metrics:
//   +--------+--------+------------------------+-------------+
//   |        |        | internal leading       | SUPERSCRIPT |
//   |        |        +------------+-----------|             |
//   |        | ascent |            | SUPERIOR  |-------------+
//   | height |        | cap height |-----------|
//   |        |        |            | INFERIOR  |-------------+
//   |        |--------+------------+-----------|             |
//   |        | descent                         | SUBSCRIPT   |
//   +--------+---------------------------------+-------------+
enum BaselineStyle {
  NORMAL_BASELINE = 0,
  SUPERSCRIPT,  // e.g. a mathematical exponent would be superscript.
  SUPERIOR,     // e.g. 8th, the "th" would be superior script.
  INFERIOR,     // e.g. 1/2, the "2" would be inferior ("1" is superior).
  SUBSCRIPT,    // e.g. H2O, the "2" would be subscript.
};

// Elision behaviors of text that exceeds constrained dimensions.
enum ElideBehavior {
  NO_ELIDE = 0, // Do not modify the text, it may overflow its available bounds.
  TRUNCATE,     // Do not elide or fade, just truncate at the end of the string.
  ELIDE_HEAD,   // Add an ellipsis at the start of the string.
  ELIDE_MIDDLE, // Add an ellipsis in the middle of the string.
  ELIDE_TAIL,   // Add an ellipsis at the end of the string.
  ELIDE_EMAIL,  // Add ellipses to username and domain substrings.
  FADE_TAIL,    // Fade the string's end opposite of its horizontal alignment.
};

// The typesetter that will be used for text when displayed in UI. This can
// influence things like string width in subtle ways and is necessary to help
// transition Mac to the Harfbuzz typesetter (http://crbug.com/454835).
enum class Typesetter {
  // The typesetter that is used by UI parts of the browser window on this
  // platform.
  BROWSER,

  // The Harfbuzz typesetter, which is typically used for secondary UI.
  HARFBUZZ,

  // The typesetter used for native UI such as tooltips, native menus and system
  // notifications.
  NATIVE,

  // The typesetter used for function default arguments. The default can be used
  // from locations that are unaffected by the Mac Harfbuzz transition. Cocoa UI
  // on Mac must specify something else.
  DEFAULT = HARFBUZZ
};

}  // namespace gfx

#endif  // UI_GFX_TEXT_CONSTANTS_H_