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

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

Issue 343513002: Refactor views::Label and gfx::RenderText shadow functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove forbidden static FontList. Created 6 years, 6 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/gfx/canvas_skia.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 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return directionality_mode_; 336 return directionality_mode_;
337 } 337 }
338 base::i18n::TextDirection GetTextDirection(); 338 base::i18n::TextDirection GetTextDirection();
339 339
340 // Returns the visual movement direction corresponding to the logical end 340 // Returns the visual movement direction corresponding to the logical end
341 // of the text, considering only the dominant direction returned by 341 // of the text, considering only the dominant direction returned by
342 // |GetTextDirection()|, not the direction of a particular run. 342 // |GetTextDirection()|, not the direction of a particular run.
343 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); 343 VisualCursorDirection GetVisualDirectionOfLogicalEnd();
344 344
345 // Returns the size required to display the current string (which is the 345 // Returns the size required to display the current string (which is the
346 // wrapped size in multiline mode). Note that this returns the raw size of the 346 // wrapped size in multiline mode). The returned size does not include space
347 // string, which does not include the cursor or the margin area of text 347 // reserved for the cursor or the offset text shadows.
348 // shadows.
349 virtual Size GetStringSize() = 0; 348 virtual Size GetStringSize() = 0;
350 349
351 // This is same as GetStringSize except that fractional size is returned. 350 // This is same as GetStringSize except that fractional size is returned.
352 // The default implementation is same as GetStringSize. Certain platforms that 351 // The default implementation is same as GetStringSize. Certain platforms that
353 // compute the text size as floating-point values, like Mac, will override 352 // compute the text size as floating-point values, like Mac, will override
354 // this method. 353 // this method.
355 // See comment in Canvas::GetStringWidthF for its usage. 354 // See comment in Canvas::GetStringWidthF for its usage.
356 virtual SizeF GetStringSizeF(); 355 virtual SizeF GetStringSizeF();
357 356
358 // Returns the width of the content (which is the wrapped width in multiline 357 // Returns the width of the content (which is the wrapped width in multiline
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // out of that range). Always moves by at least one character index unless the 400 // out of that range). Always moves by at least one character index unless the
402 // supplied index is already at the boundary of the string. 401 // supplied index is already at the boundary of the string.
403 size_t IndexOfAdjacentGrapheme(size_t index, 402 size_t IndexOfAdjacentGrapheme(size_t index,
404 LogicalCursorDirection direction); 403 LogicalCursorDirection direction);
405 404
406 // Return a SelectionModel with the cursor at the current selection's start. 405 // Return a SelectionModel with the cursor at the current selection's start.
407 // The returned value represents a cursor/caret position without a selection. 406 // The returned value represents a cursor/caret position without a selection.
408 SelectionModel GetSelectionModelForSelectionStart(); 407 SelectionModel GetSelectionModelForSelectionStart();
409 408
410 // Sets shadows to drawn with text. 409 // Sets shadows to drawn with text.
411 void SetTextShadows(const ShadowValues& shadows); 410 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; }
412 411
413 typedef std::pair<Font, Range> FontSpan; 412 typedef std::pair<Font, Range> FontSpan;
414 // For testing purposes, returns which fonts were chosen for which parts of 413 // For testing purposes, returns which fonts were chosen for which parts of
415 // the text by returning a vector of Font and Range pairs, where each range 414 // the text by returning a vector of Font and Range pairs, where each range
416 // specifies the character range for which the corresponding font has been 415 // specifies the character range for which the corresponding font has been
417 // chosen. 416 // chosen.
418 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; 417 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0;
419 418
420 // Gets the horizontal bounds (relative to the left of the text, not the view) 419 // Gets the horizontal bounds (relative to the left of the text, not the view)
421 // of the glyph starting at |index|. If the glyph is RTL then the returned 420 // of the glyph starting at |index|. If the glyph is RTL then the returned
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // The baseline of the text. This is determined from the height of the 686 // The baseline of the text. This is determined from the height of the
688 // display area and the cap height of the font list so the text is vertically 687 // display area and the cap height of the font list so the text is vertically
689 // centered. 688 // centered.
690 int baseline_; 689 int baseline_;
691 690
692 // The cached bounds and offset are invalidated by changes to the cursor, 691 // The cached bounds and offset are invalidated by changes to the cursor,
693 // selection, font, and other operations that adjust the visible text bounds. 692 // selection, font, and other operations that adjust the visible text bounds.
694 bool cached_bounds_and_offset_valid_; 693 bool cached_bounds_and_offset_valid_;
695 694
696 // Text shadows to be drawn. 695 // Text shadows to be drawn.
697 ShadowValues text_shadows_; 696 ShadowValues shadows_;
698 697
699 // A list of valid layout text line break positions. 698 // A list of valid layout text line break positions.
700 BreakList<size_t> line_breaks_; 699 BreakList<size_t> line_breaks_;
701 700
702 // Lines computed by EnsureLayout. These should be invalidated with 701 // Lines computed by EnsureLayout. These should be invalidated with
703 // ResetLayout and on |display_rect_| changes. 702 // ResetLayout and on |display_rect_| changes.
704 std::vector<internal::Line> lines_; 703 std::vector<internal::Line> lines_;
705 704
706 DISALLOW_COPY_AND_ASSIGN(RenderText); 705 DISALLOW_COPY_AND_ASSIGN(RenderText);
707 }; 706 };
708 707
709 } // namespace gfx 708 } // namespace gfx
710 709
711 #endif // UI_GFX_RENDER_TEXT_H_ 710 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698