OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <locale> | 8 #include <locale> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include <richedit.h> | 11 #include <richedit.h> |
12 #include <textserv.h> | 12 #include <textserv.h> |
13 | 13 |
14 #include "app/keyboard_codes.h" | |
15 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
16 #include "app/l10n_util_win.h" | 15 #include "app/l10n_util_win.h" |
17 #include "app/win/drag_source.h" | 16 #include "app/win/drag_source.h" |
18 #include "app/win/drop_target.h" | 17 #include "app/win/drop_target.h" |
19 #include "app/win/iat_patch_function.h" | 18 #include "app/win/iat_patch_function.h" |
20 #include "app/win/win_util.h" | 19 #include "app/win/win_util.h" |
21 #include "base/auto_reset.h" | 20 #include "base/auto_reset.h" |
22 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
23 #include "base/i18n/rtl.h" | 22 #include "base/i18n/rtl.h" |
24 #include "base/lazy_instance.h" | 23 #include "base/lazy_instance.h" |
(...skipping 18 matching lines...) Expand all Loading... |
43 #include "googleurl/src/url_util.h" | 42 #include "googleurl/src/url_util.h" |
44 #include "gfx/canvas.h" | 43 #include "gfx/canvas.h" |
45 #include "gfx/canvas_skia.h" | 44 #include "gfx/canvas_skia.h" |
46 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
47 #include "net/base/escape.h" | 46 #include "net/base/escape.h" |
48 #include "skia/ext/skia_utils_win.h" | 47 #include "skia/ext/skia_utils_win.h" |
49 #include "ui/base/clipboard/clipboard.h" | 48 #include "ui/base/clipboard/clipboard.h" |
50 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 49 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
51 #include "ui/base/dragdrop/os_exchange_data.h" | 50 #include "ui/base/dragdrop/os_exchange_data.h" |
52 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 51 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
| 52 #include "ui/base/keycodes/keyboard_codes.h" |
53 #include "views/drag_utils.h" | 53 #include "views/drag_utils.h" |
54 #include "views/focus/focus_util_win.h" | 54 #include "views/focus/focus_util_win.h" |
55 #include "views/widget/widget.h" | 55 #include "views/widget/widget.h" |
56 | 56 |
57 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 57 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
58 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. | 58 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. |
59 | 59 |
60 /////////////////////////////////////////////////////////////////////////////// | 60 /////////////////////////////////////////////////////////////////////////////// |
61 // AutocompleteEditModel | 61 // AutocompleteEditModel |
62 | 62 |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 return true; | 933 return true; |
934 } | 934 } |
935 | 935 |
936 void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { | 936 void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { |
937 if (CanPasteAndGo(text)) | 937 if (CanPasteAndGo(text)) |
938 model_->PasteAndGo(); | 938 model_->PasteAndGo(); |
939 } | 939 } |
940 | 940 |
941 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( | 941 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( |
942 const views::KeyEvent& e) { | 942 const views::KeyEvent& e) { |
943 app::KeyboardCode key = e.GetKeyCode(); | 943 ui::KeyboardCode key = e.GetKeyCode(); |
944 // We don't process ALT + numpad digit as accelerators, they are used for | 944 // We don't process ALT + numpad digit as accelerators, they are used for |
945 // entering special characters. We do translate alt-home. | 945 // entering special characters. We do translate alt-home. |
946 if (e.IsAltDown() && (key != app::VKEY_HOME) && | 946 if (e.IsAltDown() && (key != ui::VKEY_HOME) && |
947 app::win::IsNumPadDigit(key, e.IsExtendedKey())) | 947 app::win::IsNumPadDigit(key, e.IsExtendedKey())) |
948 return true; | 948 return true; |
949 | 949 |
950 // Skip accelerators for key combinations omnibox wants to crack. This list | 950 // Skip accelerators for key combinations omnibox wants to crack. This list |
951 // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt | 951 // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt |
952 // with above in LocationBarView::SkipDefaultKeyEventProcessing). | 952 // with above in LocationBarView::SkipDefaultKeyEventProcessing). |
953 // | 953 // |
954 // We cannot return true for all keys because we still need to handle some | 954 // We cannot return true for all keys because we still need to handle some |
955 // accelerators (e.g., F5 for reload the page should work even when the | 955 // accelerators (e.g., F5 for reload the page should work even when the |
956 // Omnibox gets focused). | 956 // Omnibox gets focused). |
957 switch (key) { | 957 switch (key) { |
958 case app::VKEY_ESCAPE: { | 958 case ui::VKEY_ESCAPE: { |
959 ScopedFreeze freeze(this, GetTextObjectModel()); | 959 ScopedFreeze freeze(this, GetTextObjectModel()); |
960 return model_->OnEscapeKeyPressed(); | 960 return model_->OnEscapeKeyPressed(); |
961 } | 961 } |
962 | 962 |
963 case app::VKEY_RETURN: | 963 case ui::VKEY_RETURN: |
964 return true; | 964 return true; |
965 | 965 |
966 case app::VKEY_UP: | 966 case ui::VKEY_UP: |
967 case app::VKEY_DOWN: | 967 case ui::VKEY_DOWN: |
968 return !e.IsAltDown(); | 968 return !e.IsAltDown(); |
969 | 969 |
970 case app::VKEY_DELETE: | 970 case ui::VKEY_DELETE: |
971 case app::VKEY_INSERT: | 971 case ui::VKEY_INSERT: |
972 return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); | 972 return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); |
973 | 973 |
974 case app::VKEY_X: | 974 case ui::VKEY_X: |
975 case app::VKEY_V: | 975 case ui::VKEY_V: |
976 return !e.IsAltDown() && e.IsControlDown(); | 976 return !e.IsAltDown() && e.IsControlDown(); |
977 | 977 |
978 case app::VKEY_BACK: | 978 case ui::VKEY_BACK: |
979 case app::VKEY_OEM_PLUS: | 979 case ui::VKEY_OEM_PLUS: |
980 return true; | 980 return true; |
981 | 981 |
982 default: | 982 default: |
983 return false; | 983 return false; |
984 } | 984 } |
985 } | 985 } |
986 | 986 |
987 void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, | 987 void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, |
988 UINT flags, | 988 UINT flags, |
989 const CPoint& screen_point) { | 989 const CPoint& screen_point) { |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 return 0; | 1828 return 0; |
1829 } | 1829 } |
1830 | 1830 |
1831 void AutocompleteEditViewWin::HandleKeystroke(UINT message, | 1831 void AutocompleteEditViewWin::HandleKeystroke(UINT message, |
1832 TCHAR key, | 1832 TCHAR key, |
1833 UINT repeat_count, | 1833 UINT repeat_count, |
1834 UINT flags) { | 1834 UINT flags) { |
1835 ScopedFreeze freeze(this, GetTextObjectModel()); | 1835 ScopedFreeze freeze(this, GetTextObjectModel()); |
1836 OnBeforePossibleChange(); | 1836 OnBeforePossibleChange(); |
1837 | 1837 |
1838 if (key == app::VKEY_HOME || key == app::VKEY_END) { | 1838 if (key == ui::VKEY_HOME || key == ui::VKEY_END) { |
1839 // DefWindowProc() might reset the keyboard layout when it receives a | 1839 // DefWindowProc() might reset the keyboard layout when it receives a |
1840 // keydown event for VKEY_HOME or VKEY_END. When the window was created | 1840 // keydown event for VKEY_HOME or VKEY_END. When the window was created |
1841 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, | 1841 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, |
1842 // if the input text is pure LTR text, the layout changes to the first RTL | 1842 // if the input text is pure LTR text, the layout changes to the first RTL |
1843 // keyboard layout in keyboard layout queue; if the input text is | 1843 // keyboard layout in keyboard layout queue; if the input text is |
1844 // bidirectional text, the layout changes to the keyboard layout of the | 1844 // bidirectional text, the layout changes to the keyboard layout of the |
1845 // first RTL character in input text. When the window was created without | 1845 // first RTL character in input text. When the window was created without |
1846 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if the | 1846 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if the |
1847 // input text is pure RTL text, the layout changes to English; if the input | 1847 // input text is pure RTL text, the layout changes to English; if the input |
1848 // text is bidirectional text, the layout changes to the keyboard layout of | 1848 // text is bidirectional text, the layout changes to the keyboard layout of |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 | 2610 |
2611 bool AutocompleteEditViewWin::IsImeComposing() const { | 2611 bool AutocompleteEditViewWin::IsImeComposing() const { |
2612 bool ime_composing = false; | 2612 bool ime_composing = false; |
2613 HIMC context = ImmGetContext(m_hWnd); | 2613 HIMC context = ImmGetContext(m_hWnd); |
2614 if (context) { | 2614 if (context) { |
2615 ime_composing = !!ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0); | 2615 ime_composing = !!ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0); |
2616 ImmReleaseContext(m_hWnd, context); | 2616 ImmReleaseContext(m_hWnd, context); |
2617 } | 2617 } |
2618 return ime_composing; | 2618 return ime_composing; |
2619 } | 2619 } |
OLD | NEW |