summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-21 20:10:53 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-21 20:10:53 +0000
commit82b0f03294d4a9ee705cddf4a157572ea91512e9 (patch)
tree4abc976a4e61a171a01daeb2e7ce5a0b71438bef
parentc637b3c057964957d9e836975fb2eba59885f2ca (diff)
downloadchromium_src-82b0f03294d4a9ee705cddf4a157572ea91512e9.zip
chromium_src-82b0f03294d4a9ee705cddf4a157572ea91512e9.tar.gz
chromium_src-82b0f03294d4a9ee705cddf4a157572ea91512e9.tar.bz2
Fix for issue 24888
Richedit seems to have a default paragraph format which will be used when the last paragraph in the document is deleted. (e.g. when SetWindowText is called, or when user manually deletes everything). When this happens, richedit also automatically set keyboard layout to match the default paragraph format. Unfortunately, fix for issue 11683 does not help for this scenario. The default paragraph format seems could only be set when user switches keyboard layout with an empty richedit. The fix in this CL works around the problem by setting richedit's text to empty before it forward the reading order change hotkey (ctrl+shift/shift+ctrl). BUG=24888 TEST=Verify this CL fixes issue 24888 that LTR/RTL reading order is preserved when user selects suggestions/changes tabs after changing keyboard layout with non-empty text in Omnibox. Review URL: http://codereview.chromium.org/294013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29695 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index b3a7ecc..864645e 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -1304,6 +1304,30 @@ void AutocompleteEditViewWin::OnKeyUp(TCHAR key,
if (key == VK_CONTROL)
model_->OnControlKeyChanged(false);
+ // On systems with RTL input languages, ctrl+shift toggles the reading order
+ // (depending on which shift key is pressed). But by default the CRichEditCtrl
+ // only changes the current reading order, and as soon as the user deletes all
+ // the text, or we call SetWindowText(), it reverts to the "default" order.
+ // To work around this, if the user hits ctrl+shift, we pass it to
+ // DefWindowProc() while the edit is empty, which toggles the default reading
+ // order; then we restore the user's input.
+ if (((key == VK_CONTROL) && (GetKeyState(VK_SHIFT) < 0)) ||
+ ((key == VK_SHIFT) && (GetKeyState(VK_CONTROL) < 0))) {
+ ScopedFreeze freeze(this, GetTextObjectModel());
+
+ std::wstring saved_text(GetText());
+ CHARRANGE saved_sel;
+ GetSelection(saved_sel);
+
+ SetWindowText(L"");
+
+ DefWindowProc(WM_KEYUP, key, MAKELPARAM(repeat_count, flags));
+
+ SetWindowText(saved_text.c_str());
+ SetSelectionRange(saved_sel);
+ return;
+ }
+
SetMsgHandled(false);
}