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

Unified Diff: ui/gfx/render_text_win.cc

Issue 10693061: Fix RenderTextWin base dir and adjacent char code; remove test exceptions; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/render_text_unittest.cc ('k') | ui/views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..65c7557f2b7a838bd89ec05b224e5d16ee8279b7 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,9 @@ 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;
+ EnsureLayout();
+ return (script_state_.uBidiLevel == 0) ?
+ base::i18n::LEFT_TO_RIGHT : base::i18n::RIGHT_TO_LEFT;
}
Size RenderTextWin::GetStringSize() {
@@ -365,12 +364,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.
@@ -596,6 +596,13 @@ void RenderTextWin::ItemizeLogicalText() {
runs_.reset();
string_size_ = Size(0, GetFont().GetHeight());
common_baseline_ = 0;
+
+ // Use the first strong character direction as the base text direction.
+ // TODO(msw): Use the application text direction instead of LTR by default?
+ script_state_.uBidiLevel =
+ (base::i18n::GetFirstStrongCharacterDirection(text()) ==
+ base::i18n::RIGHT_TO_LEFT) ? 1 : 0;
+
if (text().empty())
return;
« no previous file with comments | « ui/gfx/render_text_unittest.cc ('k') | ui/views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698