diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-20 06:37:01 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-20 06:37:01 +0000 |
commit | 7cf1b6ced3b14cce1d66ca0ddc713851f0d37536 (patch) | |
tree | 1c2fc9f4d52bf3046addf820d5eec03a2e150749 /app/gfx | |
parent | f9f4841b14a9f309ce5ee613f0d4de6afad88767 (diff) | |
download | chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.zip chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.tar.gz chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.tar.bz2 |
Move RTL related functions from app/l10n_util to base/i18n/rtl
TBR=darin
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1073005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx')
-rw-r--r-- | app/gfx/canvas.cc | 10 | ||||
-rw-r--r-- | app/gfx/canvas.h | 9 | ||||
-rw-r--r-- | app/gfx/canvas_win.cc | 10 |
3 files changed, 23 insertions, 6 deletions
diff --git a/app/gfx/canvas.cc b/app/gfx/canvas.cc index 75f8011..75ec0a1 100644 --- a/app/gfx/canvas.cc +++ b/app/gfx/canvas.cc @@ -8,6 +8,7 @@ #include "app/gfx/font.h" #include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "base/logging.h" #include "gfx/rect.h" #include "third_party/skia/include/core/SkShader.h" @@ -218,7 +219,7 @@ void Canvas::DrawStringInt(const std::wstring& text, const SkColor& color, int x, int y, int w, int h) { DrawStringInt(text, font, color, x, y, w, h, - l10n_util::DefaultCanvasTextAlignment()); + gfx::Canvas::DefaultCanvasTextAlignment()); } void Canvas::DrawStringInt(const std::wstring& text, @@ -267,4 +268,11 @@ SkBitmap Canvas::ExtractBitmap() const { return result; } +// static +int Canvas::DefaultCanvasTextAlignment() { + if (!base::i18n::IsRTL()) + return gfx::Canvas::TEXT_ALIGN_LEFT; + return gfx::Canvas::TEXT_ALIGN_RIGHT; +} + } // namespace gfx diff --git a/app/gfx/canvas.h b/app/gfx/canvas.h index 79eed9c..ea4fbf3 100644 --- a/app/gfx/canvas.h +++ b/app/gfx/canvas.h @@ -211,6 +211,15 @@ class Canvas : public skia::PlatformCanvas { static void SizeStringInt(const std::wstring& test, const gfx::Font& font, int *width, int* height, int flags); + // Returns the default text alignment to be used when drawing text on a + // gfx::Canvas based on the directionality of the system locale language. This + // function is used by gfx::Canvas::DrawStringInt when the text alignment is + // not specified. + // + // This function returns either gfx::Canvas::TEXT_ALIGN_LEFT or + // gfx::Canvas::TEXT_ALIGN_RIGHT. + static int DefaultCanvasTextAlignment(); + private: #if defined(OS_WIN) // Draws text with the specified color, font and location. The text is diff --git a/app/gfx/canvas_win.cc b/app/gfx/canvas_win.cc index de9d45a..abe722c 100644 --- a/app/gfx/canvas_win.cc +++ b/app/gfx/canvas_win.cc @@ -7,7 +7,7 @@ #include <limits> #include "app/gfx/font.h" -#include "app/l10n_util.h" +#include "base/i18n/rtl.h" #include "gfx/rect.h" #include "third_party/skia/include/core/SkShader.h" @@ -24,7 +24,7 @@ void DoDrawText(HDC hdc, const std::wstring& text, // 1. The current locale is RTL. // 2. The string itself has RTL directionality. if (flags & DT_RTLREADING) { - if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text)) { + if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text)) { string_ptr = localized_text.c_str(); string_size = static_cast<int>(localized_text.length()); } @@ -42,7 +42,7 @@ int ComputeFormatFlags(int flags, const std::wstring& text) { if (!(flags & (gfx::Canvas::TEXT_ALIGN_CENTER | gfx::Canvas::TEXT_ALIGN_RIGHT | gfx::Canvas::TEXT_ALIGN_LEFT))) { - flags |= l10n_util::DefaultCanvasTextAlignment(); + flags |= gfx::Canvas::DefaultCanvasTextAlignment(); } // horizontal alignment @@ -113,8 +113,8 @@ int ComputeFormatFlags(int flags, const std::wstring& text) { // using RTL directionality then we respect that and pass DT_RTLREADING to // ::DrawText even if the locale is LTR. if ((flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY) || - ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && - (f & DT_RIGHT) && l10n_util::StringContainsStrongRTLChars(text))) { + (base::i18n::IsRTL() && + (f & DT_RIGHT) && base::i18n::StringContainsStrongRTLChars(text))) { f |= DT_RTLREADING; } |