| Index: ui/gfx/render_text.cc
|
| diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
|
| index 696a4f040911421072729dcd7ee58fc7c8b6def7..cf065157da70dbf635c52a532e514b1f271ed31f 100644
|
| --- a/ui/gfx/render_text.cc
|
| +++ b/ui/gfx/render_text.cc
|
| @@ -15,6 +15,11 @@
|
|
|
| namespace {
|
|
|
| +// All chars are replaced by this char when the password style is set.
|
| +// 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).
|
| +const char16 PASSWORD_REPLACEMENT_CHAR = '*';
|
| +
|
| #ifndef NDEBUG
|
| // Check StyleRanges invariant conditions: sorted and non-overlapping ranges.
|
| void CheckStyleRanges(const gfx::StyleRanges& style_ranges, size_t length) {
|
| @@ -83,6 +88,7 @@ StyleRange::StyleRange()
|
| foreground(SK_ColorBLACK),
|
| strike(false),
|
| underline(false),
|
| + password(false),
|
| range() {
|
| }
|
|
|
| @@ -127,6 +133,22 @@ void RenderText::SetText(const string16& text) {
|
| UpdateLayout();
|
| }
|
|
|
| +string16 RenderText::GetCensoredText() const {
|
| + string16 txt = text();
|
| + for (gfx::StyleRanges::const_iterator i = style_ranges().begin();
|
| + i != style_ranges().end(); ++i) {
|
| + if (i->password) {
|
| + // TODO(benrg): There should probably be one bullet/asterisk per
|
| + // cursorable character, not one per UTF-16 word. However, I'm not sure
|
| + // it's worth the effort. GTK appears to use one per code point. Do people
|
| + // use non-BMP code points and combining diacritics in their passwords?
|
| + std::fill(txt.begin() + i->range.start(),
|
| + txt.begin() + i->range.end(), PASSWORD_REPLACEMENT_CHAR);
|
| + }
|
| + }
|
| + return txt;
|
| +}
|
| +
|
| void RenderText::ToggleInsertMode() {
|
| insert_mode_ = !insert_mode_;
|
| cached_bounds_and_offset_valid_ = false;
|
|
|