OLD | NEW |
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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
19 #include "third_party/skia/include/core/SkPaint.h" | 19 #include "third_party/skia/include/core/SkPaint.h" |
20 #include "third_party/skia/include/core/SkRect.h" | 20 #include "third_party/skia/include/core/SkRect.h" |
21 #include "ui/gfx/break_list.h" | 21 #include "ui/gfx/break_list.h" |
22 #include "ui/gfx/font_list.h" | 22 #include "ui/gfx/font_list.h" |
23 #include "ui/gfx/point.h" | 23 #include "ui/gfx/point.h" |
24 #include "ui/gfx/range/range.h" | 24 #include "ui/gfx/range/range.h" |
25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
26 #include "ui/gfx/selection_model.h" | 26 #include "ui/gfx/selection_model.h" |
27 #include "ui/gfx/shadow_value.h" | 27 #include "ui/gfx/shadow_value.h" |
| 28 #include "ui/gfx/size_f.h" |
28 #include "ui/gfx/text_constants.h" | 29 #include "ui/gfx/text_constants.h" |
29 #include "ui/gfx/vector2d.h" | 30 #include "ui/gfx/vector2d.h" |
30 | 31 |
31 class SkCanvas; | 32 class SkCanvas; |
32 class SkDrawLooper; | 33 class SkDrawLooper; |
33 struct SkPoint; | 34 struct SkPoint; |
34 class SkShader; | 35 class SkShader; |
35 class SkTypeface; | 36 class SkTypeface; |
36 | 37 |
37 namespace gfx { | 38 namespace gfx { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // of the text, considering only the dominant direction returned by | 320 // of the text, considering only the dominant direction returned by |
320 // |GetTextDirection()|, not the direction of a particular run. | 321 // |GetTextDirection()|, not the direction of a particular run. |
321 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); | 322 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); |
322 | 323 |
323 // Returns the size required to display the current string (which is the | 324 // Returns the size required to display the current string (which is the |
324 // wrapped size in multiline mode). Note that this returns the raw size of the | 325 // wrapped size in multiline mode). Note that this returns the raw size of the |
325 // string, which does not include the cursor or the margin area of text | 326 // string, which does not include the cursor or the margin area of text |
326 // shadows. | 327 // shadows. |
327 virtual Size GetStringSize() = 0; | 328 virtual Size GetStringSize() = 0; |
328 | 329 |
| 330 // This is same as GetStringSize except that fractional size is returned. |
| 331 // The default implementation is same as GetStringSize. Certain platforms that |
| 332 // compute the text size as floating-point values, like Mac, will override |
| 333 // this method. |
| 334 virtual SizeF GetStringSizeF(); |
| 335 |
329 // Returns the width of the content (which is the wrapped width in multiline | 336 // Returns the width of the content (which is the wrapped width in multiline |
330 // mode). Reserves room for the cursor if |cursor_enabled_| is true. | 337 // mode). Reserves room for the cursor if |cursor_enabled_| is true. |
331 int GetContentWidth(); | 338 int GetContentWidth(); |
332 | 339 |
333 // Returns the common baseline of the text. The returned value is the vertical | 340 // Returns the common baseline of the text. The returned value is the vertical |
334 // offset from the top of |display_rect| to the text baseline, in pixels. | 341 // offset from the top of |display_rect| to the text baseline, in pixels. |
335 virtual int GetBaseline() = 0; | 342 virtual int GetBaseline() = 0; |
336 | 343 |
337 void Draw(Canvas* canvas); | 344 void Draw(Canvas* canvas); |
338 | 345 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 // Lines computed by EnsureLayout. These should be invalidated with | 643 // Lines computed by EnsureLayout. These should be invalidated with |
637 // ResetLayout and on |display_rect_| changes. | 644 // ResetLayout and on |display_rect_| changes. |
638 std::vector<internal::Line> lines_; | 645 std::vector<internal::Line> lines_; |
639 | 646 |
640 DISALLOW_COPY_AND_ASSIGN(RenderText); | 647 DISALLOW_COPY_AND_ASSIGN(RenderText); |
641 }; | 648 }; |
642 | 649 |
643 } // namespace gfx | 650 } // namespace gfx |
644 | 651 |
645 #endif // UI_GFX_RENDER_TEXT_H_ | 652 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |