| 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include <gtk/gtk.h> | 27 #include <gtk/gtk.h> |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 namespace gfx { | 30 namespace gfx { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // Various weak, LTR, RTL, and Bidi string cases with three characters each. | 34 // Various weak, LTR, RTL, and Bidi string cases with three characters each. |
| 35 const wchar_t kWeak[] = L" . "; | 35 const wchar_t kWeak[] = L" . "; |
| 36 const wchar_t kLtr[] = L"abc"; | 36 const wchar_t kLtr[] = L"abc"; |
| 37 const wchar_t kRtl[] = L"\x5d0\x5d1\x5d2"; |
| 38 #if !defined(OS_MACOSX) |
| 37 const wchar_t kLtrRtl[] = L"a" L"\x5d0\x5d1"; | 39 const wchar_t kLtrRtl[] = L"a" L"\x5d0\x5d1"; |
| 38 const wchar_t kLtrRtlLtr[] = L"a" L"\x5d1" L"b"; | 40 const wchar_t kLtrRtlLtr[] = L"a" L"\x5d1" L"b"; |
| 39 const wchar_t kRtl[] = L"\x5d0\x5d1\x5d2"; | |
| 40 const wchar_t kRtlLtr[] = L"\x5d0\x5d1" L"a"; | 41 const wchar_t kRtlLtr[] = L"\x5d0\x5d1" L"a"; |
| 41 const wchar_t kRtlLtrRtl[] = L"\x5d0" L"a" L"\x5d1"; | 42 const wchar_t kRtlLtrRtl[] = L"\x5d0" L"a" L"\x5d1"; |
| 43 #endif |
| 42 | 44 |
| 43 // Checks whether |range| contains |index|. This is not the same as calling | 45 // Checks whether |range| contains |index|. This is not the same as calling |
| 44 // |range.Contains(gfx::Range(index))| - as that would return true when | 46 // |range.Contains(gfx::Range(index))| - as that would return true when |
| 45 // |index| == |range.end()|. | 47 // |index| == |range.end()|. |
| 46 bool IndexInRange(const Range& range, size_t index) { | 48 bool IndexInRange(const Range& range, size_t index) { |
| 47 return index >= range.start() && index < range.end(); | 49 return index >= range.start() && index < range.end(); |
| 48 } | 50 } |
| 49 | 51 |
| 50 base::string16 GetSelectedText(RenderText* render_text) { | 52 base::string16 GetSelectedText(RenderText* render_text) { |
| 51 return render_text->text().substr(render_text->selection().GetMin(), | 53 return render_text->text().substr(render_text->selection().GetMin(), |
| (...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 render_text->EnsureLayout(); | 1750 render_text->EnsureLayout(); |
| 1749 ASSERT_EQ(3U, render_text->runs_.size()); | 1751 ASSERT_EQ(3U, render_text->runs_.size()); |
| 1750 EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range); | 1752 EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range); |
| 1751 EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range); | 1753 EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range); |
| 1752 EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range); | 1754 EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range); |
| 1753 | 1755 |
| 1754 } | 1756 } |
| 1755 #endif // !defined(OS_WIN) | 1757 #endif // !defined(OS_WIN) |
| 1756 | 1758 |
| 1757 } // namespace gfx | 1759 } // namespace gfx |
| OLD | NEW |