diff options
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.cc | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_win.cc | 1 | ||||
-rw-r--r-- | chrome/browser/views/fullscreen_exit_bubble.cc | 1 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.cc | 1 | ||||
-rw-r--r-- | chrome/common/common.vcproj | 8 | ||||
-rw-r--r-- | chrome/common/l10n_util.cc | 25 | ||||
-rw-r--r-- | chrome/common/l10n_util.h | 22 | ||||
-rw-r--r-- | chrome/common/l10n_util_win.cc | 31 | ||||
-rw-r--r-- | chrome/common/l10n_util_win.h | 28 | ||||
-rw-r--r-- | chrome/views/aero_tooltip_manager.cc | 2 | ||||
-rw-r--r-- | chrome/views/menu.cc | 1 | ||||
-rw-r--r-- | chrome/views/native_control.cc | 2 | ||||
-rw-r--r-- | chrome/views/tabbed_pane.cc | 2 | ||||
-rw-r--r-- | chrome/views/text_field.cc | 1 | ||||
-rw-r--r-- | chrome/views/tooltip_manager.cc | 1 |
15 files changed, 77 insertions, 50 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 4b92d0f..b332832 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -31,6 +31,7 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/utils.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/notification_service.h" #include "chrome/common/os_exchange_data.h" #include "chrome/common/win_util.h" diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 871be4a..b9fe070 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -18,6 +18,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/resource_bundle.h" diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc index 667088a..170763b 100644 --- a/chrome/browser/views/fullscreen_exit_bubble.cc +++ b/chrome/browser/views/fullscreen_exit_bubble.cc @@ -6,6 +6,7 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/root_view.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index f3ec662..8cc1ad2 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -12,6 +12,7 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/text_elider.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/label.h" #include "chrome/views/root_view.h" diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index 2e91a0d..100f0b7 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -506,6 +506,14 @@ > </File> <File + RelativePath=".\l10n_util_win.cc" + > + </File> + <File + RelativePath=".\l10n_util_win.h" + > + </File> + <File RelativePath=".\libxml_utils.cc" > </File> diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc index c576a4b..9fcee980 100644 --- a/chrome/common/l10n_util.cc +++ b/chrome/common/l10n_util.cc @@ -614,31 +614,6 @@ int DefaultCanvasTextAlignment() { } } -#if defined(OS_WIN) -int GetExtendedStyles() { - return GetTextDirection() == LEFT_TO_RIGHT ? 0 : - WS_EX_LAYOUTRTL | WS_EX_RTLREADING; -} - -int GetExtendedTooltipStyles() { - return GetTextDirection() == LEFT_TO_RIGHT ? 0 : WS_EX_LAYOUTRTL; -} - -void HWNDSetRTLLayout(HWND hwnd) { - DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE); - - // We don't have to do anything if the style is already set for the HWND. - if (!(ex_style & WS_EX_LAYOUTRTL)) { - ex_style |= WS_EX_LAYOUTRTL; - ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style); - - // Right-to-left layout changes are not applied to the window immediately - // so we should make sure a WM_PAINT is sent to the window by invalidating - // the entire window rect. - ::InvalidateRect(hwnd, NULL, true); - } -} -#endif // defined(OS_WIN) // Compares the character data stored in two different strings by specified // Collator instance. diff --git a/chrome/common/l10n_util.h b/chrome/common/l10n_util.h index 51160cd..480c1bd 100644 --- a/chrome/common/l10n_util.h +++ b/chrome/common/l10n_util.h @@ -10,9 +10,6 @@ #include "build/build_config.h" -#if defined(OS_WIN) -#include <windows.h> -#endif #include <algorithm> #include <functional> #include <string> @@ -172,17 +169,6 @@ void WrapStringWithRTLFormatting(std::wstring* text); void WrapPathWithLTRFormatting(const FilePath& path, string16* rtl_safe_path); -// Returns the locale-dependent extended window styles. -// This function is used for adding locale-dependent extended window styles -// (e.g. WS_EX_LAYOUTRTL, WS_EX_RTLREADING, etc.) when creating a window. -// Callers should OR this value into their extended style value when creating -// a window. -int GetExtendedStyles(); - -// TODO(xji): -// This is a temporary name, it will eventually replace GetExtendedStyles -int GetExtendedTooltipStyles(); - // Returns the default text alignment to be used when drawing text on a // ChromeCanvas based on the directionality of the system locale language. This // function is used by ChromeCanvas::DrawStringInt when the text alignment is @@ -192,14 +178,6 @@ int GetExtendedTooltipStyles(); // ChromeCanvas::TEXT_ALIGN_RIGHT. int DefaultCanvasTextAlignment(); -#if defined(OS_WIN) -// Give an HWND, this function sets the WS_EX_LAYOUTRTL extended style for the -// underlying window. When this style is set, the UI for the window is going to -// be mirrored. This is generally done for the UI of right-to-left languages -// such as Hebrew. -void HWNDSetRTLLayout(HWND hwnd); -#endif - // Compares the two strings using the specified collator. UCollationResult CompareStringWithCollator(const Collator* collator, const std::wstring& lhs, diff --git a/chrome/common/l10n_util_win.cc b/chrome/common/l10n_util_win.cc new file mode 100644 index 0000000..5d85951 --- /dev/null +++ b/chrome/common/l10n_util_win.cc @@ -0,0 +1,31 @@ +#include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" + +namespace l10n_util { + +int GetExtendedStyles() { + return GetTextDirection() == LEFT_TO_RIGHT ? 0 : + WS_EX_LAYOUTRTL | WS_EX_RTLREADING; +} + +int GetExtendedTooltipStyles() { + return GetTextDirection() == LEFT_TO_RIGHT ? 0 : WS_EX_LAYOUTRTL; +} + +void HWNDSetRTLLayout(HWND hwnd) { + DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE); + + // We don't have to do anything if the style is already set for the HWND. + if (!(ex_style & WS_EX_LAYOUTRTL)) { + ex_style |= WS_EX_LAYOUTRTL; + ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style); + + // Right-to-left layout changes are not applied to the window immediately + // so we should make sure a WM_PAINT is sent to the window by invalidating + // the entire window rect. + ::InvalidateRect(hwnd, NULL, true); + } +} + +} // namespace l10n_util + diff --git a/chrome/common/l10n_util_win.h b/chrome/common/l10n_util_win.h new file mode 100644 index 0000000..733cc2b --- /dev/null +++ b/chrome/common/l10n_util_win.h @@ -0,0 +1,28 @@ +#ifndef CHROME_COMMON_L10N_UTIL_WIN_H_ +#define CHROME_COMMON_L10N_UTIL_WIN_H_ + +#include <windows.h> + +namespace l10n_util { + +// Returns the locale-dependent extended window styles. +// This function is used for adding locale-dependent extended window styles +// (e.g. WS_EX_LAYOUTRTL, WS_EX_RTLREADING, etc.) when creating a window. +// Callers should OR this value into their extended style value when creating +// a window. +int GetExtendedStyles(); + +// TODO(xji): +// This is a temporary name, it will eventually replace GetExtendedStyles +int GetExtendedTooltipStyles(); + +// Give an HWND, this function sets the WS_EX_LAYOUTRTL extended style for the +// underlying window. When this style is set, the UI for the window is going to +// be mirrored. This is generally done for the UI of right-to-left languages +// such as Hebrew. +void HWNDSetRTLLayout(HWND hwnd); + +} // namespace l10n_util + +#endif // CHROME_COMMON_L10N_UTIL_WIN_H_ + diff --git a/chrome/views/aero_tooltip_manager.cc b/chrome/views/aero_tooltip_manager.cc index 29f3d66..196cc0a 100644 --- a/chrome/views/aero_tooltip_manager.cc +++ b/chrome/views/aero_tooltip_manager.cc @@ -11,7 +11,7 @@ #include "chrome/views/aero_tooltip_manager.h" #include "base/message_loop.h" -#include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" namespace views { diff --git a/chrome/views/menu.cc b/chrome/views/menu.cc index d50404b..f317718 100644 --- a/chrome/views/menu.cc +++ b/chrome/views/menu.cc @@ -17,6 +17,7 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/stl_util-inl.h" const SkBitmap* Menu::Delegate::kEmptyIcon = 0; diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc index 1490f27..7ecf165 100644 --- a/chrome/views/native_control.cc +++ b/chrome/views/native_control.cc @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/win_util.h" -#include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/notification_service.h" #include "chrome/views/background.h" #include "chrome/views/border.h" diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc index 838e6fa..aefd496 100644 --- a/chrome/views/tabbed_pane.cc +++ b/chrome/views/tabbed_pane.cc @@ -10,7 +10,7 @@ #include "base/logging.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" -#include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/stl_util-inl.h" #include "chrome/common/throb_animation.h" diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc index deeed6e..d0ec3da 100644 --- a/chrome/views/text_field.cc +++ b/chrome/views/text_field.cc @@ -19,6 +19,7 @@ #include "chrome/common/clipboard_service.h" #include "chrome/common/gfx/insets.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/win_util.h" #include "chrome/views/hwnd_view.h" diff --git a/chrome/views/tooltip_manager.cc b/chrome/views/tooltip_manager.cc index 8e7e75f..1de156b 100644 --- a/chrome/views/tooltip_manager.cc +++ b/chrome/views/tooltip_manager.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/message_loop.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/l10n_util_win.h" #include "chrome/common/gfx/text_elider.h" #include "chrome/common/win_util.h" #include "chrome/views/root_view.h" |