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

Side by Side Diff: ui/gfx/render_text_win.cc

Issue 10807082: Add RenderText DirectionalityMode enum and support; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update and expand on unit tests. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_win.h" 5 #include "ui/gfx/render_text_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 needs_layout_(false) { 298 needs_layout_(false) {
299 memset(&script_control_, 0, sizeof(script_control_)); 299 memset(&script_control_, 0, sizeof(script_control_));
300 memset(&script_state_, 0, sizeof(script_state_)); 300 memset(&script_state_, 0, sizeof(script_state_));
301 301
302 MoveCursorTo(EdgeSelectionModel(CURSOR_LEFT)); 302 MoveCursorTo(EdgeSelectionModel(CURSOR_LEFT));
303 } 303 }
304 304
305 RenderTextWin::~RenderTextWin() { 305 RenderTextWin::~RenderTextWin() {
306 } 306 }
307 307
308 base::i18n::TextDirection RenderTextWin::GetTextDirection() {
309 EnsureLayout();
310 return (script_state_.uBidiLevel == 0) ?
311 base::i18n::LEFT_TO_RIGHT : base::i18n::RIGHT_TO_LEFT;
312 }
313
314 Size RenderTextWin::GetStringSize() { 308 Size RenderTextWin::GetStringSize() {
315 EnsureLayout(); 309 EnsureLayout();
316 return string_size_; 310 return string_size_;
317 } 311 }
318 312
319 int RenderTextWin::GetBaseline() { 313 int RenderTextWin::GetBaseline() {
320 EnsureLayout(); 314 EnsureLayout();
321 return common_baseline_; 315 return common_baseline_;
322 } 316 }
323 317
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 587
594 x = glyph_x; 588 x = glyph_x;
595 } 589 }
596 } 590 }
597 591
598 void RenderTextWin::ItemizeLogicalText() { 592 void RenderTextWin::ItemizeLogicalText() {
599 runs_.clear(); 593 runs_.clear();
600 string_size_ = Size(0, GetFont().GetHeight()); 594 string_size_ = Size(0, GetFont().GetHeight());
601 common_baseline_ = 0; 595 common_baseline_ = 0;
602 596
603 // Use the first strong character direction as the base text direction. 597 // Set the base text direction yeilded by the directionality mode.
Alexei Svitkine (slow) 2012/07/30 22:29:16 Nit: yielded. Although, the comment isn't really c
msw 2012/07/31 03:03:06 Done ("Set Uniscribe's base text direction."), sim
604 // TODO(msw): Use the application text direction instead of LTR by default?
605 script_state_.uBidiLevel = 598 script_state_.uBidiLevel =
606 (base::i18n::GetFirstStrongCharacterDirection(text()) == 599 (GetTextDirection() == base::i18n::RIGHT_TO_LEFT) ? 1 : 0;
607 base::i18n::RIGHT_TO_LEFT) ? 1 : 0;
608 600
609 if (text().empty()) 601 if (text().empty())
610 return; 602 return;
611 603
612 const wchar_t* raw_text = text().c_str(); 604 const wchar_t* raw_text = text().c_str();
613 const int text_length = text().length(); 605 const int text_length = text().length();
614 606
615 HRESULT hr = E_OUTOFMEMORY; 607 HRESULT hr = E_OUTOFMEMORY;
616 int script_items_count = 0; 608 int script_items_count = 0;
617 std::vector<SCRIPT_ITEM> script_items; 609 std::vector<SCRIPT_ITEM> script_items;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 const internal::TextRun* run) { 944 const internal::TextRun* run) {
953 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); 945 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD);
954 return SelectionModel(caret, CURSOR_FORWARD); 946 return SelectionModel(caret, CURSOR_FORWARD);
955 } 947 }
956 948
957 RenderText* RenderText::CreateInstance() { 949 RenderText* RenderText::CreateInstance() {
958 return new RenderTextWin; 950 return new RenderTextWin;
959 } 951 }
960 952
961 } // namespace gfx 953 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698