diff options
41 files changed, 82 insertions, 123 deletions
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index 86a79e5..4797a73 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -925,9 +925,8 @@ class TryChromeDialog : public views::ButtonListener, // account the differences between XP and Vista fonts and buttons. layout->Layout(root_view); gfx::Size preferred = layout->GetPreferredSize(root_view); - pos = ComputeWindowPosition(preferred.width(), - preferred.height(), - root_view->UILayoutIsRightToLeft()); + pos = ComputeWindowPosition(preferred.width(), preferred.height(), + base::i18n::IsRTL()); popup->SetBounds(pos); // Carve the toast shape into the window. diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 3630b304..c22dec8 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -178,11 +178,8 @@ void AboutChromeView::Init() { // LTR UIs and one for RTL UIs. We load the correct bitmap based on the UI // layout of the view. about_dlg_background_logo_ = new views::ImageView(); - SkBitmap* about_background_logo; - if (UILayoutIsRightToLeft()) - about_background_logo = rb.GetBitmapNamed(IDR_ABOUT_BACKGROUND_RTL); - else - about_background_logo = rb.GetBitmapNamed(IDR_ABOUT_BACKGROUND); + SkBitmap* about_background_logo = rb.GetBitmapNamed(base::i18n::IsRTL() ? + IDR_ABOUT_BACKGROUND_RTL : IDR_ABOUT_BACKGROUND); about_dlg_background_logo_->SetImage(*about_background_logo); AddChildView(about_dlg_background_logo_); diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 400b63e..20a307a 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -847,7 +847,7 @@ void BookmarkBarView::GetAnchorPositionAndStartIndexForButton( *anchor = MenuItemView::TOPLEFT; // Invert orientation if right to left. - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { if (*anchor == MenuItemView::TOPRIGHT) *anchor = MenuItemView::TOPLEFT; else diff --git a/chrome/browser/views/bookmark_menu_button.cc b/chrome/browser/views/bookmark_menu_button.cc index c16b7fc..c9d17e4 100644 --- a/chrome/browser/views/bookmark_menu_button.cc +++ b/chrome/browser/views/bookmark_menu_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -137,7 +137,7 @@ void BookmarkMenuButton::RunMenu(views::View* source, GetBookmarkModel()->GetBookmarkBarNode(), 0, true); views::MenuItemView::AnchorPosition anchor = views::MenuItemView::TOPRIGHT; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) anchor = views::MenuItemView::TOPLEFT; if (for_drop) { bookmark_drop_menu_ = menu; diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index f4132bb..f546734 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -558,7 +558,7 @@ void BrowserActionsContainer::OnBrowserActionExecuted( gfx::NativeWindow frame_window = browser_->window()->GetNativeHandle(); - BubbleBorder::ArrowLocation arrow_location = UILayoutIsRightToLeft() ? + BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? BubbleBorder::TOP_LEFT : BubbleBorder::TOP_RIGHT; popup_ = ExtensionPopup::Show(button->GetPopupUrl(), browser_, @@ -616,7 +616,7 @@ void BrowserActionsContainer::Layout() { x += sz.width(); } - x += UILayoutIsRightToLeft() ? kHorizontalPaddingRtl : kHorizontalPadding; + x += base::i18n::IsRTL() ? kHorizontalPaddingRtl : kHorizontalPadding; // Calculate if all icons fit without showing the chevron. We need to know // this beforehand, because showing the chevron will decrease the space that @@ -661,8 +661,8 @@ void BrowserActionsContainer::Layout() { void BrowserActionsContainer::Paint(gfx::Canvas* canvas) { // The one-pixel themed vertical divider to the right of the browser actions. - int x = UILayoutIsRightToLeft() ? kDividerHorizontalMargin : - width() - kDividerHorizontalMargin; + int x = base::i18n::IsRTL() ? + kDividerHorizontalMargin : (width() - kDividerHorizontalMargin); DetachableToolbarView::PaintVerticalDivider( canvas, x, height(), kDividerVerticalPadding, DetachableToolbarView::kEdgeDividerColor, @@ -746,7 +746,7 @@ int BrowserActionsContainer::OnDragUpdated( x += chevron_->bounds().width(); x = ClampToNearestIconCount(x, false); - if (!UILayoutIsRightToLeft() && chevron_->IsVisible()) { + if (!base::i18n::IsRTL() && chevron_->IsVisible()) { // The clamping function includes the chevron width. In LTR locales, the // chevron is on the right and we never want to account for its width. In // RTL it is on the left and we always want to count the width. @@ -756,9 +756,8 @@ int BrowserActionsContainer::OnDragUpdated( // Clamping gives us a value where the next button will be drawn, but we want // to subtract the padding (and then some) to make it appear in-between the // buttons. - SetDropIndicator(x - kBrowserActionButtonPadding - - (UILayoutIsRightToLeft() ? kDropIndicatorOffsetRtl : - kDropIndicatorOffsetLtr)); + SetDropIndicator(x - kBrowserActionButtonPadding - (base::i18n::IsRTL() ? + kDropIndicatorOffsetRtl : kDropIndicatorOffsetLtr)); return DragDropTypes::DRAG_MOVE; } @@ -788,7 +787,7 @@ int BrowserActionsContainer::OnPerformDrop( int view_x = browser_action_views_[i]->GetBounds(APPLY_MIRRORING_TRANSFORMATION).x(); if (!browser_action_views_[i]->IsVisible() || - (UILayoutIsRightToLeft() ? view_x < target_x : view_x >= target_x)) { + (base::i18n::IsRTL() ? view_x < target_x : view_x >= target_x)) { // We have reached the end of the visible icons or found one that has a // higher x position than the drop point. break; @@ -1028,8 +1027,8 @@ void BrowserActionsContainer::SetContainerWidth() { int BrowserActionsContainer::WidthOfNonIconArea() const { int chevron_size = (chevron_->IsVisible()) ? chevron_->GetPreferredSize().width() : 0; - int padding = UILayoutIsRightToLeft() ? kHorizontalPaddingRtl : - kHorizontalPadding; + int padding = base::i18n::IsRTL() ? + kHorizontalPaddingRtl : kHorizontalPadding; return resize_gripper_->GetPreferredSize().width() + padding + chevron_size + kChevronRightMargin + kDividerHorizontalMargin; } diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index b38f4e7..d519783 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -226,7 +226,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download, box_y_ = kVerticalPadding; gfx::Size size = GetPreferredSize(); - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { // Drop down button is glued to the left of the download shelf. drop_down_x_left_ = 0; drop_down_x_right_ = normal_drop_down_image_set_.top->width(); @@ -508,7 +508,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) { // Paint the background images. int x = kLeftPadding; - bool rtl_ui = UILayoutIsRightToLeft(); + bool rtl_ui = base::i18n::IsRTL(); if (rtl_ui) { // Since we do not have the mirrored images for // (hot_)body_image_set->top_left, (hot_)body_image_set->left, @@ -810,7 +810,7 @@ bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) { // DownloadShelfContextMenu will take care of setting the right anchor for // the menu depending on the locale. point.set_y(height()); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) point.set_x(drop_down_x_right_); else point.set_x(drop_down_x_left_); diff --git a/chrome/browser/views/download_started_animation_win.cc b/chrome/browser/views/download_started_animation_win.cc index eb63f1c..e142b14 100644 --- a/chrome/browser/views/download_started_animation_win.cc +++ b/chrome/browser/views/download_started_animation_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -121,7 +121,7 @@ void DownloadStartedAnimationWin::Reposition() { // Align the image with the bottom left of the web contents (so that it // points to the newly created download). gfx::Size size = GetPreferredSize(); - int x = UILayoutIsRightToLeft() ? + int x = base::i18n::IsRTL() ? tab_contents_bounds_.right() - size.width() : tab_contents_bounds_.x(); popup_->MoveWindow( x, diff --git a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc index 2a07adb..0c1e355 100644 --- a/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc +++ b/chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc @@ -65,9 +65,8 @@ bool BrowserActionOverflowMenuController::RunMenu(gfx::NativeWindow window, bounds.set_x(screen_loc.x()); bounds.set_y(screen_loc.y()); - views::MenuItemView::AnchorPosition anchor = - menu_button_->UILayoutIsRightToLeft() ? views::MenuItemView::TOPLEFT : - views::MenuItemView::TOPRIGHT; + views::MenuItemView::AnchorPosition anchor = base::i18n::IsRTL() ? + views::MenuItemView::TOPLEFT : views::MenuItemView::TOPRIGHT; if (for_drop) { menu_->RunMenuForDropAt(window, bounds, anchor); } else { diff --git a/chrome/browser/views/find_bar_host.cc b/chrome/browser/views/find_bar_host.cc index cd4658f..5ee4d44 100644 --- a/chrome/browser/views/find_bar_host.cc +++ b/chrome/browser/views/find_bar_host.cc @@ -153,8 +153,8 @@ gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { // Place the view in the top right corner of the widget boundaries (top left // for RTL languages). gfx::Rect view_location; - int x = view()->UILayoutIsRightToLeft() ? - widget_bounds.x() : widget_bounds.width() - prefsize.width(); + int x = base::i18n::IsRTL() ? + widget_bounds.x() : widget_bounds.width() - prefsize.width(); int y = widget_bounds.y(); view_location.SetRect(x, y, prefsize.width(), prefsize.height()); diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc index 7e15345..c1f063e 100644 --- a/chrome/browser/views/find_bar_view.cc +++ b/chrome/browser/views/find_bar_view.cc @@ -156,10 +156,8 @@ FindBarView::FindBarView(FindBarHost* host) // Background images for the Find edit box. kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND); - if (UILayoutIsRightToLeft()) - kBackground_left = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND_LEFT_RTL); - else - kBackground_left = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND_LEFT); + kBackground_left = rb.GetBitmapNamed(base::i18n::IsRTL() ? + IDR_FIND_BOX_BACKGROUND_LEFT_RTL : IDR_FIND_BOX_BACKGROUND_LEFT); } } @@ -256,7 +254,7 @@ void FindBarView::Paint(gfx::Canvas* canvas) { gfx::Rect back_button_rect; int x = 0; // x coordinate of the curved edge background image. int w = 0; // width of the background image for the text field. - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { find_text_rect = find_text_->GetBounds(APPLY_MIRRORING_TRANSFORMATION); back_button_rect = find_previous_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION); @@ -281,7 +279,7 @@ void FindBarView::Paint(gfx::Canvas* canvas) { // find_text_ edit box and the match_count_text_ label). int background_height = kBackground->height(); canvas->TileImageInt(*kBackground, - UILayoutIsRightToLeft() ? + base::i18n::IsRTL() ? back_button_rect.right() : find_text_rect.x(), back_button_rect.y(), w, diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc index 995ba3a..47897cf 100644 --- a/chrome/browser/views/first_run_view_base.cc +++ b/chrome/browser/views/first_run_view_base.cc @@ -83,7 +83,7 @@ void FirstRunViewBase::SetupControls() { // image because the code above derives the background color from the LTR // image so we have to use the LTR logo initially and then replace it with // the RTL logo if we find out that we are running in a right-to-left locale. - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) background_image_->SetImage(rb.GetBitmapNamed(IDR_WIZARD_ICON_RTL)); background_image_->set_background(bkg); diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc index 3dcaf93..d0427d0 100644 --- a/chrome/browser/views/frame/browser_view_layout.cc +++ b/chrome/browser/views/frame/browser_view_layout.cc @@ -118,7 +118,7 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { // the vertical scroll bar. int scrollbar_width = gfx::scrollbar_size(); bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); - if (browser_view_->UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) bounding_box.set_x(bounding_box.x() + scrollbar_width); return bounding_box; diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index 0026e60..2e009c8 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -89,12 +89,12 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( // minimize_button_offset assumes LTR layout since the window controls // themselves are not flipped, so we need to adjust the tabstrip's x // position for them in RTL languages. - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) tabstrip_x += (width() - minimize_button_offset); int tabstrip_width = minimize_button_offset - tabstrip_x - (frame_->GetWindow()->IsMaximized() ? kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) tabstrip_width += tabstrip_x; return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(), std::max(0, tabstrip_width), @@ -114,10 +114,8 @@ void GlassBrowserFrameView::UpdateThrobber(bool running) { } void GlassBrowserFrameView::PaintTabStripShadow(gfx::Canvas* canvas) { - if (!browser_view_->UILayoutIsRightToLeft() || - !browser_view_->UseVerticalTabs()) { + if (!base::i18n::IsRTL() || !browser_view_->UseVerticalTabs()) return; - } ThemeProvider* tp = GetThemeProvider(); SkBitmap* shadow_top = tp->GetBitmapNamed(IDR_SIDETABS_SHADOW_TOP); diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 5bfb822..1b27d03 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -45,7 +45,7 @@ void BorderContents::SizeAndGetBounds( const gfx::Size& contents_size, gfx::Rect* contents_bounds, gfx::Rect* window_bounds) { - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) arrow_location = BubbleBorder::rtl_mirror(arrow_location); bubble_border_->set_arrow_location(arrow_location); // Set the border. diff --git a/chrome/browser/views/infobars/translate_infobars.cc b/chrome/browser/views/infobars/translate_infobars.cc index 7cc9f11..4ae395f 100644 --- a/chrome/browser/views/infobars/translate_infobars.cc +++ b/chrome/browser/views/infobars/translate_infobars.cc @@ -902,7 +902,7 @@ gfx::Point TranslateInfoBar::DetermineMenuPositionAndAlignment( gfx::Point menu_position(lb.origin()); menu_position.Offset(2, lb.height() - 3); *alignment = views::Menu2::ALIGN_TOPLEFT; - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { menu_position.Offset(lb.width() - 4, 0); } View::ConvertPointToScreen(menu_button, &menu_position); diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc index 0dee88f..5886983 100644 --- a/chrome/browser/views/location_bar/location_bar_view.cc +++ b/chrome/browser/views/location_bar/location_bar_view.cc @@ -778,7 +778,7 @@ void LocationBarView::ShowFirstRunBubbleInternal( // If the UI layout is RTL, the coordinate system is not transformed and // therefore we need to adjust the X coordinate so that bubble appears on the // right hand side of the location bar. - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) origin.set_x(width() - origin.x()); views::View::ConvertPointToScreen(this, &origin); FirstRunBubble::Show(profile_, GetWidget(), gfx::Rect(origin, gfx::Size()), diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index e85d420..5e5a24e 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -186,7 +186,7 @@ void FileDisplayArea::Init() { void FileDisplayArea::InitClass() { static bool initialized = false; if (!initialized) { - // We'd prefer to use UILayoutIsRightToLeft() to perform the RTL + // We'd prefer to use base::i18n::IsRTL() to perform the RTL // environment check, but it's nonstatic, so, instead, we check whether the // locale is RTL. bool ui_is_rtl = base::i18n::IsRTL(); diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index 1cc88b3..d1db4ed 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -8,7 +8,6 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/callback.h" -#include "base/i18n/rtl.h" #include "base/message_loop.h" #include "base/string_util.h" #include "chrome/browser/browser.h" diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index a44ef96..1a238026 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -368,7 +368,7 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) { rad[2] = 0; rad[3] = 0; } else { - if (UILayoutIsRightToLeft() ^ (style_ == STYLE_STANDARD_RIGHT)) { + if (base::i18n::IsRTL() != (style_ == STYLE_STANDARD_RIGHT)) { // The text is RtL or the bubble is on the right side (but not both). // Top Left corner. @@ -721,7 +721,7 @@ void StatusBubbleViews::AvoidMouse(const gfx::Point& location) { // Get the cursor position relative to the popup. gfx::Point relative_location = location; - if (view_->UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { int top_right_x = top_left.x() + window_width; relative_location.set_x(top_right_x - relative_location.x()); } else { diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc index aab8a0f..f3148c6 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/views/tabs/dragged_tab_view.cc @@ -69,7 +69,7 @@ DraggedTabView::~DraggedTabView() { void DraggedTabView::MoveTo(const gfx::Point& screen_point) { int x; - if (UILayoutIsRightToLeft() && !attached_) { + if (base::i18n::IsRTL() && !attached_) { // On RTL locales, a dragged tab (when it is not attached to a tab strip) // is rendered using a right-to-left orientation so we should calculate the // window position differently. @@ -155,7 +155,7 @@ void DraggedTabView::Layout() { renderer_->SetBounds(0, 0, prefsize.width(), prefsize.height()); } else { int left = 0; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) left = GetPreferredSize().width() - attached_tab_size_.width(); // The renderer_'s width should be attached_tab_size_.width() in both LTR // and RTL locales. Wrong width will cause the wrong positioning of the tab diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index 5f1254d..e9d47aa 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -533,7 +533,7 @@ void TabRenderer::OnMouseExited(const views::MouseEvent& e) { void TabRenderer::Paint(gfx::Canvas* canvas) { if (data_.render_as_new_tab) { - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { canvas->TranslateInt(width(), 0); canvas->ScaleInt(-1, 1); } @@ -923,7 +923,7 @@ void TabRenderer::PaintLoadingAnimation(gfx::Canvas* canvas) { if (favicon_bounds_.width() != kFavIconSize) dst_x += (favicon_bounds_.width() - kFavIconSize) / 2; } else { - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { dst_x = width() - kLeftPadding - image_size; } else { dst_x = kLeftPadding; diff --git a/chrome/browser/views/theme_install_bubble_view.cc b/chrome/browser/views/theme_install_bubble_view.cc index 3b3caa0..a03b8b5 100644 --- a/chrome/browser/views/theme_install_bubble_view.cc +++ b/chrome/browser/views/theme_install_bubble_view.cc @@ -99,7 +99,7 @@ void ThemeInstallBubbleView::Reposition() { int mid_x = tab_contents_bounds_.x() + (tab_contents_bounds_.right() - tab_contents_bounds_.x()) / 2; - int x = UILayoutIsRightToLeft() ? + int x = base::i18n::IsRTL() ? mid_x + size.width() / 2 : mid_x - size.width() / 2; int y = static_cast<int>(tab_contents_bounds_.y() + (tab_contents_bounds_.bottom() - tab_contents_bounds_.y()) / 2 - diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index b5e35e0..09f97ab 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -722,11 +722,11 @@ void ToolbarView::LoadRightSideControlsImages() { ThemeProvider* tp = GetThemeProvider(); // We use different menu button images if the locale is right-to-left. - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) page_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_PAGE_RTL)); else page_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_PAGE)); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) app_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_CHROME_RTL)); else app_menu_->SetIcon(*tp->GetBitmapNamed(IDR_MENU_CHROME)); diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index 2d3f30e..7b2b3d0 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -134,7 +134,7 @@ void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { // is right-to-left. gfx::Point menu_position(lb.origin()); menu_position.Offset(0, lb.height() - 1); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) menu_position.Offset(lb.width() - 1, 0); View::ConvertPointToScreen(this, &menu_position); diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index b45c2ac..b515e17 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -125,11 +125,11 @@ bool MenuButton::Activate() { // The position of the menu depends on whether or not the locale is // right-to-left. gfx::Point menu_position(lb.right(), lb.bottom()); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) menu_position.set_x(lb.x()); View::ConvertPointToScreen(this, &menu_position); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) menu_position.Offset(2, -4); else menu_position.Offset(-2, -4); diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc index 9728332..fe6ad38 100644 --- a/views/controls/image_view.cc +++ b/views/controls/image_view.cc @@ -80,7 +80,7 @@ gfx::Point ImageView::ComputeImageOrigin(const gfx::Size& image_size) const { // horizontal alignment is set to trailing, then we'll use left alignment for // the image instead of right alignment if the UI layout is RTL. Alignment actual_horiz_alignment = horiz_alignment_; - if (UILayoutIsRightToLeft() && (horiz_alignment_ != CENTER)) + if (base::i18n::IsRTL() && (horiz_alignment_ != CENTER)) actual_horiz_alignment = (horiz_alignment_ == LEADING) ? TRAILING : LEADING; switch (actual_horiz_alignment) { case LEADING: x = insets.left(); break; diff --git a/views/controls/label.cc b/views/controls/label.cc index 2aff154..9ab4e36 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -135,7 +135,7 @@ void Label::SetHorizontalAlignment(Alignment a) { // If the View's UI layout is right-to-left and rtl_alignment_mode_ is // USE_UI_ALIGNMENT, we need to flip the alignment so that the alignment // settings take into account the text directionality. - if (UILayoutIsRightToLeft() && (rtl_alignment_mode_ == USE_UI_ALIGNMENT) && + if (base::i18n::IsRTL() && (rtl_alignment_mode_ == USE_UI_ALIGNMENT) && (a != ALIGN_CENTER)) a = (a == ALIGN_LEFT) ? ALIGN_RIGHT : ALIGN_LEFT; if (horiz_alignment_ != a) { diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc index 19751ca..d238cb3 100644 --- a/views/controls/label_unittest.cc +++ b/views/controls/label_unittest.cc @@ -287,7 +287,7 @@ TEST(LabelTest, DrawSingleLineString) { // Turn off mirroring so that we don't need to figure out if // align right really means align left. - label.EnableUIMirroringForRTLLanguages(false); + label.set_rtl_alignment_mode(Label::AUTO_DETECT_ALIGNMENT); std::wstring test_text(L"Here's a string with no returns."); label.SetText(test_text); @@ -405,7 +405,7 @@ TEST(LabelTest, DrawMultiLineString) { // Turn off mirroring so that we don't need to figure out if // align right really means align left. - label.EnableUIMirroringForRTLLanguages(false); + label.set_rtl_alignment_mode(Label::AUTO_DETECT_ALIGNMENT); std::wstring test_text(L"Another string\nwith returns\n\n!"); label.SetText(test_text); @@ -550,7 +550,6 @@ TEST(LabelTest, DrawSingleLineStringInRTL) { Label label; label.SetFocusable(false); - label.EnableUIMirroringForRTLLanguages(true); std::string locale = l10n_util::GetApplicationLocale(std::wstring()); base::i18n::SetICUDefaultLocale("he"); @@ -673,7 +672,6 @@ TEST(LabelTest, DrawMultiLineStringInRTL) { label.SetFocusable(false); // Test for RTL. - label.EnableUIMirroringForRTLLanguages(true); std::string locale = l10n_util::GetApplicationLocale(std::wstring()); base::i18n::SetICUDefaultLocale("he"); diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index a89aa8c..9005fd6 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -1264,7 +1264,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, // We must make sure we take into account the UI layout. If the layout is // RTL, then a 'leading' menu is positioned to the left of the parent menu // item and not to the right. - bool layout_is_rtl = item->UILayoutIsRightToLeft(); + bool layout_is_rtl = base::i18n::IsRTL(); bool create_on_the_right = (prefer_leading && !layout_is_rtl) || (!prefer_leading && layout_is_rtl); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index 64b8270..29864b2 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -386,7 +386,7 @@ void MenuItemView::PrepareForRun(bool has_mnemonics) { int MenuItemView::GetDrawStringFlags() { int flags = 0; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; else flags |= gfx::Canvas::TEXT_ALIGN_LEFT; diff --git a/views/controls/menu/menu_item_view_win.cc b/views/controls/menu/menu_item_view_win.cc index 489fe90..cb956cb 100644 --- a/views/controls/menu/menu_item_view_win.cc +++ b/views/controls/menu/menu_item_view_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -134,7 +134,7 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) { // locale is RTL) then we should make sure the menu arrow points to the // right direction. NativeTheme::MenuArrowDirection arrow_direction; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) arrow_direction = NativeTheme::LEFT_POINTING_ARROW; else arrow_direction = NativeTheme::RIGHT_POINTING_ARROW; diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc index 347406f..f714382 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -330,7 +330,7 @@ DWORD NativeControl::GetAdditionalExStyle() const { // extended window style for a right-to-left layout so the subclass creates // a mirrored HWND for the underlying control. DWORD ex_style = 0; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) ex_style |= l10n_util::GetExtendedStyles(); return ex_style; @@ -341,7 +341,7 @@ DWORD NativeControl::GetAdditionalRTLStyle() const { // extended window style for a right-to-left layout so the subclass creates // a mirrored HWND for the underlying control. DWORD ex_style = 0; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) ex_style |= l10n_util::GetExtendedTooltipStyles(); return ex_style; diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc index baa5a19..c73d17c 100644 --- a/views/controls/native_control_win.cc +++ b/views/controls/native_control_win.cc @@ -134,7 +134,7 @@ DWORD NativeControlWin::GetAdditionalExStyle() const { // extended window style for a right-to-left layout so the subclass creates // a mirrored HWND for the underlying control. DWORD ex_style = 0; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) ex_style |= l10n_util::GetExtendedStyles(); return ex_style; @@ -145,7 +145,7 @@ DWORD NativeControlWin::GetAdditionalRTLStyle() const { // extended window style for a right-to-left layout so the subclass creates // a mirrored HWND for the underlying control. DWORD ex_style = 0; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) ex_style |= l10n_util::GetExtendedTooltipStyles(); return ex_style; diff --git a/views/controls/resize_gripper.cc b/views/controls/resize_gripper.cc index 1a49957..4d6d93b 100644 --- a/views/controls/resize_gripper.cc +++ b/views/controls/resize_gripper.cc @@ -87,7 +87,7 @@ void ResizeGripper::ReportResizeAmount(int resize_amount, bool last_update) { View::ConvertPointToScreen(this, &point); resize_amount = point.x() - initial_position_; - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) resize_amount = -1 * resize_amount; delegate_->OnResize(resize_amount, last_update); } diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc index f76acb3..298a540 100644 --- a/views/controls/single_split_view.cc +++ b/views/controls/single_split_view.cc @@ -151,7 +151,7 @@ bool SingleSplitView::OnMouseDragged(const MouseEvent& event) { int delta_offset = GetPrimaryAxisSize(event.x(), event.y()) - drag_info_.initial_mouse_offset; - if (is_horizontal_ && UILayoutIsRightToLeft()) + if (is_horizontal_ && base::i18n::IsRTL()) delta_offset *= -1; // Honor the minimum size when resizing. gfx::Size min = GetChildViewAt(0)->GetMinimumSize(); @@ -188,7 +188,7 @@ bool SingleSplitView::IsPointInDivider(const gfx::Point& p) { int divider_relative_offset; if (is_horizontal_) { divider_relative_offset = - p.x() - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width(); + p.x() - GetChildViewAt(base::i18n::IsRTL() ? 1 : 0)->width(); } else { divider_relative_offset = p.y() - GetChildViewAt(0)->height(); } diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc index 26579f9..87f2ebb 100644 --- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc +++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -107,7 +107,7 @@ void NativeTabbedPaneWin::AddNativeTab(int index, // If the locale is RTL, we set the TCIF_RTLREADING so that BiDi text is // rendered properly on the tabs. - if (UILayoutIsRightToLeft()) { + if (base::i18n::IsRTL()) { tcitem.mask |= TCIF_RTLREADING; } @@ -222,7 +222,7 @@ void NativeTabbedPaneWin::CreateNativeControl() { // Explicitly setting the WS_EX_LAYOUTRTL property for the HWND (see above // for a thorough explanation regarding why we waited until |content_window_| // if created before we set this property for the tabbed pane's HWND). - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) l10n_util::HWNDSetRTLLayout(tab_control); RootView* root_view = content_window_->GetRootView(); diff --git a/views/controls/table/native_table_win.cc b/views/controls/table/native_table_win.cc index 22ca250..d34856f 100644 --- a/views/controls/table/native_table_win.cc +++ b/views/controls/table/native_table_win.cc @@ -670,7 +670,7 @@ LRESULT CALLBACK NativeTableWin::TableWndProc(HWND window, // // As a work around this uses the position of the cursor and ignores // the position supplied in the l_param. - if (table->UILayoutIsRightToLeft() && + if (base::i18n::IsRTL() && (GET_X_LPARAM(l_param) != -1 || GET_Y_LPARAM(l_param) != -1)) { POINT screen_point; GetCursorPos(&screen_point); diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index c1d07d9..b165ba4 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -493,7 +493,7 @@ gfx::Point TableView::GetKeyboardContextMenuLocation() { } } gfx::Point screen_loc(0, y); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) screen_loc.set_x(width()); ConvertPointToScreen(this, &screen_loc); return screen_loc; @@ -538,7 +538,7 @@ LRESULT CALLBACK TableView::TableWndProc(HWND window, // // As a work around this uses the position of the cursor and ignores // the position supplied in the l_param. - if (table_view->UILayoutIsRightToLeft() && + if (base::i18n::IsRTL() && (GET_X_LPARAM(l_param) != -1 || GET_Y_LPARAM(l_param) != -1)) { POINT screen_point; GetCursorPos(&screen_point); diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc index e5587b9..b544abc 100644 --- a/views/controls/tree/tree_view.cc +++ b/views/controls/tree/tree_view.cc @@ -64,7 +64,7 @@ bool TreeView::GetAccessibleRole(AccessibilityTypes::Role* role) { bool TreeView::GetAccessibleState(AccessibilityTypes::State* state) { DCHECK(state); - + *state = AccessibilityTypes::STATE_READONLY; return true; } @@ -357,7 +357,7 @@ gfx::Point TreeView::GetKeyboardContextMenuLocation() { } } gfx::Point screen_loc(0, y); - if (UILayoutIsRightToLeft()) + if (base::i18n::IsRTL()) screen_loc.set_x(width()); ConvertPointToScreen(this, &screen_loc); return screen_loc; @@ -656,7 +656,7 @@ HIMAGELIST TreeView::CreateImageList() { std::vector<SkBitmap> model_images; model_->GetIcons(&model_images); - bool rtl = UILayoutIsRightToLeft(); + bool rtl = base::i18n::IsRTL(); // Creates the default image list used for trees. SkBitmap* closed_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( diff --git a/views/view.cc b/views/view.cc index d04ccec..4978003 100644 --- a/views/view.cc +++ b/views/view.cc @@ -10,7 +10,6 @@ #endif #include "app/drag_drop_types.h" -#include "base/i18n/rtl.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/scoped_handle.h" @@ -71,7 +70,6 @@ View::View() accessibility_(NULL), #endif drag_controller_(NULL), - ui_mirroring_is_enabled_for_rtl_languages_(true), flip_canvas_on_paint_for_rtl_ui_(false) { } @@ -234,10 +232,6 @@ void View::SetLayoutManager(LayoutManager* layout_manager) { layout_manager_->Installed(this); } -bool View::UILayoutIsRightToLeft() const { - return (ui_mirroring_is_enabled_for_rtl_languages_ && base::i18n::IsRTL()); -} - //////////////////////////////////////////////////////////////////////////////// // // View - Right-to-left UI layout @@ -250,7 +244,7 @@ int View::MirroredX() const { } int View::MirroredLeftPointForRect(const gfx::Rect& bounds) const { - return UILayoutIsRightToLeft() ? + return base::i18n::IsRTL() ? (width() - bounds.x() - bounds.width()) : bounds.x(); } diff --git a/views/view.h b/views/view.h index bdf1b23..68d583d 100644 --- a/views/view.h +++ b/views/view.h @@ -14,6 +14,7 @@ #include <vector> #include "app/os_exchange_data.h" +#include "base/i18n/rtl.h" #include "base/scoped_ptr.h" #include "gfx/native_widget_types.h" #include "gfx/rect.h" @@ -288,24 +289,6 @@ class View : public AcceleratorTarget { // Right-to-left UI layout functions - // Indicates whether the UI layout for this view is right-to-left. The view - // has an RTL UI layout if RTL hasn't been disabled for the view and if the - // locale's language is an RTL language. - bool UILayoutIsRightToLeft() const; - - // Enables or disables the right-to-left layout for the view. If |enable| is - // true, the layout will become right-to-left only if the locale's language - // is right-to-left. - // - // By default, right-to-left UI layout is enabled for the view and therefore - // this function must be called (with false as the |enable| parameter) in - // order to disable the right-to-left layout property for a specific instance - // of the view. Disabling the right-to-left UI layout is necessary in case a - // UI element will not appear correctly when mirrored. - void EnableUIMirroringForRTLLanguages(bool enable) { - ui_mirroring_is_enabled_for_rtl_languages_ = enable; - } - // This method determines whether the gfx::Canvas object passed to // View::Paint() needs to be transformed such that anything drawn on the // canvas object during View::Paint() is flipped horizontally. @@ -315,13 +298,13 @@ class View : public AcceleratorTarget { // a flipped gfx::Canvas when the UI layout is right-to-left need to call // EnableCanvasFlippingForRTLUI(). bool FlipCanvasOnPaintForRTLUI() const { - return flip_canvas_on_paint_for_rtl_ui_ ? UILayoutIsRightToLeft() : false; + return flip_canvas_on_paint_for_rtl_ui_ ? base::i18n::IsRTL() : false; } // Enables or disables flipping of the gfx::Canvas during View::Paint(). // Note that if canvas flipping is enabled, the canvas will be flipped only // if the UI layout is right-to-left; that is, the canvas will be flipped - // only if UILayoutIsRightToLeft() returns true. + // only if base::i18n::IsRTL() returns true. // // Enabling canvas flipping is useful for leaf views that draw a bitmap that // needs to be flipped horizontally when the UI layout is right-to-left @@ -361,7 +344,7 @@ class View : public AcceleratorTarget { // MirroredXCoordinateInsideView(20) -> 80 // MirroredXCoordinateInsideView(99) -> 1 int MirroredXCoordinateInsideView(int x) const { - return UILayoutIsRightToLeft() ? width() - x : x; + return base::i18n::IsRTL() ? width() - x : x; } // Given a X coordinate and a width inside the View, this function returns @@ -374,7 +357,7 @@ class View : public AcceleratorTarget { // MirroredXCoordinateInsideView(0, 10) -> 90 // MirroredXCoordinateInsideView(20, 20) -> 60 int MirroredXWithWidthInsideView(int x, int w) const { - return UILayoutIsRightToLeft() ? width() - x - w : x; + return base::i18n::IsRTL() ? width() - x - w : x; } // Painting functions @@ -1287,11 +1270,6 @@ class View : public AcceleratorTarget { DragController* drag_controller_; - // Indicates whether or not the view is going to be mirrored (that is, use a - // right-to-left UI layout) if the locale's language is a right-to-left - // language like Arabic or Hebrew. - bool ui_mirroring_is_enabled_for_rtl_languages_; - // Indicates whether or not the gfx::Canvas object passed to View::Paint() // is going to be flipped horizontally (using the appropriate transform) on // right-to-left locales for this View. |