Index: ui/gfx/render_text_win.cc |
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc |
index c2a2c2c047b3422daf88eeacc1b6d62bb136c64a..0d1f7394b3f0a85d98dc56a4749a99a88728d27e 100644 |
--- a/ui/gfx/render_text_win.cc |
+++ b/ui/gfx/render_text_win.cc |
@@ -7,6 +7,7 @@ |
#include <algorithm> |
#include "base/i18n/break_iterator.h" |
+#include "base/i18n/rtl.h" |
#include "base/logging.h" |
#include "base/string_split.h" |
#include "base/string_util.h" |
@@ -302,11 +303,7 @@ RenderTextWin::~RenderTextWin() { |
} |
base::i18n::TextDirection RenderTextWin::GetTextDirection() { |
- // TODO(benrg): Code moved from RenderText::GetTextDirection. Needs to be |
- // replaced by a correct Windows implementation. |
- if (base::i18n::IsRTL()) |
- return base::i18n::RIGHT_TO_LEFT; |
- return base::i18n::LEFT_TO_RIGHT; |
+ return base::i18n::GetFirstStrongCharacterDirection(text()); |
Alexei Svitkine (slow)
2012/07/02 16:21:11
What do you think of making this depend on EnsureL
msw
2012/07/02 19:54:49
Done.
|
} |
Size RenderTextWin::GetStringSize() { |
@@ -365,12 +362,13 @@ SelectionModel RenderTextWin::AdjacentCharSelectionModel( |
DCHECK(!needs_layout_); |
internal::TextRun* run; |
size_t run_index = GetRunContainingCaret(selection); |
- if (run_index == runs_.size()) { |
+ if (run_index >= runs_.size()) { |
// The cursor is not in any run: we're at the visual and logical edge. |
SelectionModel edge = EdgeSelectionModel(direction); |
if (edge.caret_pos() == selection.caret_pos()) |
return edge; |
- run = direction == CURSOR_RIGHT ? runs_.front() : runs_.back(); |
+ int visual_index = (direction == CURSOR_RIGHT) ? 0 : runs_.size() - 1; |
+ run = runs_[visual_to_logical_[visual_index]]; |
} else { |
// If the cursor is moving within the current run, just move it by one |
// grapheme in the appropriate direction. |
@@ -602,6 +600,10 @@ void RenderTextWin::ItemizeLogicalText() { |
const wchar_t* raw_text = text().c_str(); |
const int text_length = text().length(); |
+ // Initialize the base direction of the text. |
+ script_state_.uBidiLevel = |
Alexei Svitkine (slow)
2012/07/02 16:21:11
Can you clear uBidiLevel to 0 above the early retu
msw
2012/07/02 19:54:49
Done.
|
+ (GetTextDirection() == base::i18n::LEFT_TO_RIGHT) ? 0 : 1; |
+ |
HRESULT hr = E_OUTOFMEMORY; |
int script_items_count = 0; |
std::vector<SCRIPT_ITEM> script_items; |