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

Unified Diff: ui/gfx/canvas_skia.cc

Issue 10384168: Fix incorrect forcing of text directionality in canvas_skia.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: . Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas_skia.cc
===================================================================
--- ui/gfx/canvas_skia.cc (revision 136322)
+++ ui/gfx/canvas_skia.cc (working copy)
@@ -19,14 +19,23 @@
namespace {
-// Based on |flags| and |text| content, returns whether text should be
-// rendered right-to-left.
-bool IsTextRTL(int flags, const string16& text) {
- if (flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY)
- return true;
- if (flags & gfx::Canvas::FORCE_LTR_DIRECTIONALITY)
- return false;
- return base::i18n::IsRTL() && base::i18n::StringContainsStrongRTLChars(text);
+// If necessary, wraps |text| with RTL/LTR directionality characters based on
+// |flags| and |text| content.
+// Returns true if the text should be rendered right-to-left.
+bool AdjustStringDirection(int flags, string16* text) {
+ bool is_rtl = false;
+ if (flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY) {
+ base::i18n::WrapStringWithRTLFormatting(text);
+ is_rtl = true;
+ } else if (flags & gfx::Canvas::FORCE_LTR_DIRECTIONALITY) {
+ base::i18n::WrapStringWithLTRFormatting(text);
xji 2012/05/14 22:50:51 This is a bit tricky. In systems without RTL suppo
xji 2012/05/14 23:09:10 long term wise, I think we should be able to set t
+ is_rtl = false;
+ } else if (base::i18n::IsRTL() &&
+ base::i18n::StringContainsStrongRTLChars(*text)) {
+ base::i18n::WrapStringWithRTLFormatting(text);
+ is_rtl = true;
+ }
+ return is_rtl;
}
// Checks each pixel immediately adjacent to the given pixel in the bitmap. If
@@ -250,8 +259,7 @@
string16 adjusted_text = text;
#if defined(OS_WIN)
- if (IsTextRTL(flags, adjusted_text))
- base::i18n::AdjustStringForLocaleDirection(&adjusted_text);
+ AdjustStringDirection(flags, &adjusted_text);
#endif
scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
@@ -392,9 +400,7 @@
scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
string16 clipped_text = text;
- const bool is_rtl = IsTextRTL(flags, text);
- if (is_rtl)
- base::i18n::AdjustStringForLocaleDirection(&clipped_text);
+ const bool is_rtl = AdjustStringDirection(flags, &clipped_text);
switch (truncate_mode) {
case TruncateFadeTail:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698