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 #include "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/gfx/font.h" | 21 #include "ui/gfx/font.h" |
22 #include "ui/gfx/range/range.h" | 22 #include "ui/gfx/range/range.h" |
23 #include "ui/gfx/range/range_f.h" | 23 #include "ui/gfx/range/range_f.h" |
24 #include "ui/gfx/render_text_harfbuzz.h" | 24 #include "ui/gfx/render_text_harfbuzz.h" |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
28 #include "ui/gfx/platform_font_win.h" | 28 #include "ui/gfx/platform_font_win.h" |
29 #endif | 29 #endif |
30 | 30 |
| 31 #if defined(OS_MACOSX) |
| 32 #include <ApplicationServices/ApplicationServices.h> |
| 33 |
| 34 #include "ui/gfx/render_text_mac.h" |
| 35 #endif |
| 36 |
31 using base::ASCIIToUTF16; | 37 using base::ASCIIToUTF16; |
32 using base::UTF8ToUTF16; | 38 using base::UTF8ToUTF16; |
33 using base::WideToUTF16; | 39 using base::WideToUTF16; |
34 using base::WideToUTF8; | 40 using base::WideToUTF8; |
35 | 41 |
36 namespace gfx { | 42 namespace gfx { |
37 | 43 |
38 namespace { | 44 namespace { |
39 | 45 |
40 // Various weak, LTR, RTL, and Bidi string cases with three characters each. | 46 // Various weak, LTR, RTL, and Bidi string cases with three characters each. |
(...skipping 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2619 SkColor color = buffer[width + y * kCanvasSize.width()]; | 2625 SkColor color = buffer[width + y * kCanvasSize.width()]; |
2620 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; | 2626 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; |
2621 for (int x = 1; x < kTestWidth; ++x) { | 2627 for (int x = 1; x < kTestWidth; ++x) { |
2622 color = buffer[width + x + y * kCanvasSize.width()]; | 2628 color = buffer[width + x + y * kCanvasSize.width()]; |
2623 EXPECT_EQ(SK_ColorWHITE, color) << string; | 2629 EXPECT_EQ(SK_ColorWHITE, color) << string; |
2624 } | 2630 } |
2625 } | 2631 } |
2626 } | 2632 } |
2627 } | 2633 } |
2628 | 2634 |
| 2635 #if defined(OS_MACOSX) |
| 2636 TEST_F(RenderTextTest, Mac_ElidedText) { |
| 2637 RenderTextMac render_text; |
| 2638 base::string16 text(ASCIIToUTF16("This is an example.")); |
| 2639 render_text.SetText(text); |
| 2640 gfx::Size string_size = render_text.GetStringSize(); |
| 2641 render_text.SetDisplayRect(gfx::Rect(string_size)); |
| 2642 render_text.EnsureLayout(); |
| 2643 // NOTE: Character and glyph counts are only comparable for simple text. |
| 2644 EXPECT_EQ(text.size(), |
| 2645 static_cast<size_t>(CTLineGetGlyphCount(render_text.line_))); |
| 2646 |
| 2647 render_text.SetElideBehavior(ELIDE_TAIL); |
| 2648 string_size.set_width(string_size.width() / 2); |
| 2649 render_text.SetDisplayRect(gfx::Rect(string_size)); |
| 2650 render_text.EnsureLayout(); |
| 2651 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); |
| 2652 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); |
| 2653 EXPECT_NE(0, glyph_count); |
| 2654 } |
| 2655 #endif |
| 2656 |
2629 } // namespace gfx | 2657 } // namespace gfx |
OLD | NEW |