Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Side by Side Diff: ui/gfx/render_text.h

Issue 8747001: Reintroduce password support to NativeTextfieldViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for dcommit Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/text/utf16_indexing_unittest.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 SkColor cursor_color() const { return cursor_color_; } 150 SkColor cursor_color() const { return cursor_color_; }
151 void set_cursor_color(SkColor color) { cursor_color_ = color; } 151 void set_cursor_color(SkColor color) { cursor_color_ = color; }
152 152
153 bool focused() const { return focused_; } 153 bool focused() const { return focused_; }
154 void set_focused(bool focused) { focused_ = focused; } 154 void set_focused(bool focused) { focused_ = focused; }
155 155
156 const StyleRange& default_style() const { return default_style_; } 156 const StyleRange& default_style() const { return default_style_; }
157 void set_default_style(const StyleRange& style) { default_style_ = style; } 157 void set_default_style(const StyleRange& style) { default_style_ = style; }
158 158
159 // In an obscured (password) field, all text is drawn as asterisks or bullets.
160 bool is_obscured() const { return obscured_; }
161 void SetObscured(bool obscured);
162
159 const Rect& display_rect() const { return display_rect_; } 163 const Rect& display_rect() const { return display_rect_; }
160 void SetDisplayRect(const Rect& r); 164 void SetDisplayRect(const Rect& r);
161 165
162 void set_fade_head(bool fade_head) { fade_head_ = fade_head; } 166 void set_fade_head(bool fade_head) { fade_head_ = fade_head; }
163 bool fade_head() const { return fade_head_; } 167 bool fade_head() const { return fade_head_; }
164 void set_fade_tail(bool fade_tail) { fade_tail_ = fade_tail; } 168 void set_fade_tail(bool fade_tail) { fade_tail_ = fade_tail; }
165 bool fade_tail() const { return fade_tail_; } 169 bool fade_tail() const { return fade_tail_; }
166 170
167 bool background_is_transparent() const { return background_is_transparent_; } 171 bool background_is_transparent() const { return background_is_transparent_; }
168 void set_background_is_transparent(bool transparent) { 172 void set_background_is_transparent(bool transparent) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Update the layout so that the next draw request can correctly 331 // Update the layout so that the next draw request can correctly
328 // render the text and its attributes. 332 // render the text and its attributes.
329 virtual void UpdateLayout() = 0; 333 virtual void UpdateLayout() = 0;
330 334
331 // Ensure the text is laid out. 335 // Ensure the text is laid out.
332 virtual void EnsureLayout() = 0; 336 virtual void EnsureLayout() = 0;
333 337
334 // Draw the text. 338 // Draw the text.
335 virtual void DrawVisualText(Canvas* canvas) = 0; 339 virtual void DrawVisualText(Canvas* canvas) = 0;
336 340
341 // Like text() except that it returns asterisks or bullets if this is an
342 // obscured field.
343 string16 GetDisplayText() const;
344
337 // Apply composition style (underline) to composition range and selection 345 // Apply composition style (underline) to composition range and selection
338 // style (foreground) to selection range. 346 // style (foreground) to selection range.
339 void ApplyCompositionAndSelectionStyles(StyleRanges* style_ranges); 347 void ApplyCompositionAndSelectionStyles(StyleRanges* style_ranges);
340 348
341 // Returns the text origin after applying text alignment and display offset. 349 // Returns the text origin after applying text alignment and display offset.
342 Point GetTextOrigin(); 350 Point GetTextOrigin();
343 351
344 // Convert points from the text space to the view space and back. 352 // Convert points from the text space to the view space and back.
345 // Handles the display area, display offset, and the application LTR/RTL mode. 353 // Handles the display area, display offset, and the application LTR/RTL mode.
346 Point ToTextPoint(const Point& point); 354 Point ToTextPoint(const Point& point);
(...skipping 12 matching lines...) Expand all
359 // Applies fade effects to |renderer|. 367 // Applies fade effects to |renderer|.
360 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); 368 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer);
361 369
362 private: 370 private:
363 friend class RenderTextTest; 371 friend class RenderTextTest;
364 372
365 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyle); 373 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, DefaultStyle);
366 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, CustomDefaultStyle); 374 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, CustomDefaultStyle);
367 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ApplyStyleRange); 375 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ApplyStyleRange);
368 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StyleRangesAdjust); 376 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StyleRangesAdjust);
377 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PasswordCensorship);
369 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); 378 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions);
370 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SelectionModels); 379 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SelectionModels);
371 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, OriginForSkiaDrawing); 380 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, OriginForSkiaDrawing);
372 381
373 // Set the cursor to |position|, with the caret trailing the previous 382 // Set the cursor to |position|, with the caret trailing the previous
374 // grapheme, or if there is no previous grapheme, leading the cursor position. 383 // grapheme, or if there is no previous grapheme, leading the cursor position.
375 // If |select| is false, the selection start is moved to the same position. 384 // If |select| is false, the selection start is moved to the same position.
376 // If the |position| is not a cursorable position (not on grapheme boundary), 385 // If the |position| is not a cursorable position (not on grapheme boundary),
377 // it is a NO-OP. 386 // it is a NO-OP.
378 void MoveCursorTo(size_t position, bool select); 387 void MoveCursorTo(size_t position, bool select);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 bool focused_; 424 bool focused_;
416 425
417 // Composition text range. 426 // Composition text range.
418 ui::Range composition_range_; 427 ui::Range composition_range_;
419 428
420 // List of style ranges. Elements in the list never overlap each other. 429 // List of style ranges. Elements in the list never overlap each other.
421 StyleRanges style_ranges_; 430 StyleRanges style_ranges_;
422 // The default text style. 431 // The default text style.
423 StyleRange default_style_; 432 StyleRange default_style_;
424 433
434 // True if this is an obscured (password) field.
435 bool obscured_;
436
425 // Fade text head and/or tail, if text doesn't fit into |display_rect_|. 437 // Fade text head and/or tail, if text doesn't fit into |display_rect_|.
426 bool fade_head_; 438 bool fade_head_;
427 bool fade_tail_; 439 bool fade_tail_;
428 440
429 // Is the background transparent (either partially or fully)? 441 // Is the background transparent (either partially or fully)?
430 bool background_is_transparent_; 442 bool background_is_transparent_;
431 443
432 // The local display area for rendering the text. 444 // The local display area for rendering the text.
433 Rect display_rect_; 445 Rect display_rect_;
434 446
435 // The offset for the text to be drawn, relative to the display area. 447 // The offset for the text to be drawn, relative to the display area.
436 // Get this point with GetUpdatedDisplayOffset (or risk using a stale value). 448 // Get this point with GetUpdatedDisplayOffset (or risk using a stale value).
437 Point display_offset_; 449 Point display_offset_;
438 450
439 // The cached bounds and offset are invalidated by changes to the cursor, 451 // The cached bounds and offset are invalidated by changes to the cursor,
440 // selection, font, and other operations that adjust the visible text bounds. 452 // selection, font, and other operations that adjust the visible text bounds.
441 bool cached_bounds_and_offset_valid_; 453 bool cached_bounds_and_offset_valid_;
442 454
443 DISALLOW_COPY_AND_ASSIGN(RenderText); 455 DISALLOW_COPY_AND_ASSIGN(RenderText);
444 }; 456 };
445 457
446 } // namespace gfx 458 } // namespace gfx
447 459
448 #endif // UI_GFX_RENDER_TEXT_H_ 460 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « ui/base/text/utf16_indexing_unittest.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698