diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-08 01:33:20 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-08 01:33:20 +0000 |
commit | 7ad72fb0ac7aac042bcf900c54e9b0d32de89a6b (patch) | |
tree | 8402901b12594d8b8e45f99e2290b768c2af9d6a | |
parent | 675cf7082cc8c71717f455be83289587f5e6d3f3 (diff) | |
download | chromium_src-7ad72fb0ac7aac042bcf900c54e9b0d32de89a6b.zip chromium_src-7ad72fb0ac7aac042bcf900c54e9b0d32de89a6b.tar.gz chromium_src-7ad72fb0ac7aac042bcf900c54e9b0d32de89a6b.tar.bz2 |
Views Textfield: Handle Ctrl+Shift direction and layout changes.
Implement NativeTextfieldViews::ChangeTextDirectionAndLayoutAlignment.
(already called by Windows IMEs InputMethodWin/InputMethodBridge)
Change the RenderText's directionality and schedule paint.
(no alignment changes are made, as per aharon's suggestion)
Force LTR/RTL directionality modes as indicated, except:
Restore text directionality when indicated == current forced.
(helps manage BiDi layout without getting stuck in forced LTR/RTL)
This behavior is nuanced and I'll gladly consider other suggestions.
Expose RenderText::directionality_mode; clobber bounds on changes.
(for clever directionality handling, and updating cursor bounds)
Fix IMM32Manager::IsCtrlShiftPressed code for odd F-22 behavior.
Pressing F-10 in another app causes F-22 to get stuck 'pressed'?
(without this, textfields could get stuck in forced LTR/RTL mode)
TODO(followup): Fix IME calling on ChromeOS and Linux Aura.
BUG=310313
TEST=Ctrl+[Left-|Right-]Shift changes text in textfields and the omnibox.
R=pkasting@chromium.org,nona@chromium.org,yukawa@chromium.org,aharon@chromium.org
Review URL: https://codereview.chromium.org/60743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233754 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/base/ime/win/imm32_manager.cc | 4 | ||||
-rw-r--r-- | ui/gfx/render_text.cc | 1 | ||||
-rw-r--r-- | ui/gfx/render_text.h | 5 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_views.cc | 13 |
4 files changed, 20 insertions, 3 deletions
diff --git a/ui/base/ime/win/imm32_manager.cc b/ui/base/ime/win/imm32_manager.cc index d418f61..093b010 100644 --- a/ui/base/ime/win/imm32_manager.cc +++ b/ui/base/ime/win/imm32_manager.cc @@ -605,6 +605,10 @@ bool IMM32Manager::IsCtrlShiftPressed(base::i18n::TextDirection* direction) { keystate[VK_CONTROL] = 0; keystate[VK_RCONTROL] = 0; keystate[VK_LCONTROL] = 0; + // Oddly, pressing F10 in another application seemingly breaks all subsequent + // calls to GetKeyboardState regarding the state of the F22 key. Perhaps this + // defect is limited to my keyboard driver, but ignoring F22 should be okay. + keystate[VK_F22] = 0; for (int i = 0; i <= VK_PACKET; ++i) { if (keystate[i] & kKeyDownMask) return false; diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index 4761538..2c062a5 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -626,6 +626,7 @@ void RenderText::SetDirectionalityMode(DirectionalityMode mode) { directionality_mode_ = mode; text_direction_ = base::i18n::UNKNOWN_DIRECTION; + cached_bounds_and_offset_valid_ = false; ResetLayout(); } diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h index 6d998de..09e8e88 100644 --- a/ui/gfx/render_text.h +++ b/ui/gfx/render_text.h @@ -307,8 +307,11 @@ class GFX_EXPORT RenderText { // RenderText. bool GetStyle(TextStyle style) const; - // Set the text directionality mode and get the text direction yielded. + // Set or get the text directionality mode and get the text direction yielded. void SetDirectionalityMode(DirectionalityMode mode); + DirectionalityMode directionality_mode() const { + return directionality_mode_; + } base::i18n::TextDirection GetTextDirection(); // Returns the visual movement direction corresponding to the logical end diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc index 749de28..6d4199a 100644 --- a/ui/views/controls/textfield/native_textfield_views.cc +++ b/ui/views/controls/textfield/native_textfield_views.cc @@ -1090,8 +1090,17 @@ void NativeTextfieldViews::OnInputMethodChanged() { bool NativeTextfieldViews::ChangeTextDirectionAndLayoutAlignment( base::i18n::TextDirection direction) { - NOTIMPLEMENTED(); - return false; + // Restore text directionality mode when the indicated direction matches the + // current forced mode; otherwise, force the mode indicated. This helps users + // manage BiDi text layout without getting stuck in forced LTR or RTL modes. + const gfx::DirectionalityMode mode = direction == base::i18n::RIGHT_TO_LEFT ? + gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR; + if (mode == GetRenderText()->directionality_mode()) + GetRenderText()->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_TEXT); + else + GetRenderText()->SetDirectionalityMode(mode); + SchedulePaint(); + return true; } void NativeTextfieldViews::ExtendSelectionAndDelete( |