OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/controls/text_field.h" | 5 #include "chrome/views/controls/text_field.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <atlcrack.h> | 9 #include <atlcrack.h> |
10 #include <atlctrls.h> | 10 #include <atlctrls.h> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 void SetBackgroundColor(COLORREF bg_color); | 66 void SetBackgroundColor(COLORREF bg_color); |
67 | 67 |
68 // CWindowImpl | 68 // CWindowImpl |
69 BEGIN_MSG_MAP(Edit) | 69 BEGIN_MSG_MAP(Edit) |
70 MSG_WM_CHAR(OnChar) | 70 MSG_WM_CHAR(OnChar) |
71 MSG_WM_CONTEXTMENU(OnContextMenu) | 71 MSG_WM_CONTEXTMENU(OnContextMenu) |
72 MSG_WM_COPY(OnCopy) | 72 MSG_WM_COPY(OnCopy) |
73 MSG_WM_CREATE(OnCreate) | 73 MSG_WM_CREATE(OnCreate) |
74 MSG_WM_CUT(OnCut) | 74 MSG_WM_CUT(OnCut) |
75 MSG_WM_DESTROY(OnDestroy) | 75 MSG_WM_DESTROY(OnDestroy) |
| 76 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnImeChar) |
76 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition) | 77 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition) |
77 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) | 78 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) |
78 MSG_WM_KEYDOWN(OnKeyDown) | 79 MSG_WM_KEYDOWN(OnKeyDown) |
79 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) | 80 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) |
80 MSG_WM_LBUTTONDOWN(OnLButtonDown) | 81 MSG_WM_LBUTTONDOWN(OnLButtonDown) |
81 MSG_WM_LBUTTONUP(OnLButtonUp) | 82 MSG_WM_LBUTTONUP(OnLButtonUp) |
82 MSG_WM_MBUTTONDOWN(OnNonLButtonDown) | 83 MSG_WM_MBUTTONDOWN(OnNonLButtonDown) |
83 MSG_WM_MOUSEMOVE(OnMouseMove) | 84 MSG_WM_MOUSEMOVE(OnMouseMove) |
84 MSG_WM_MOUSELEAVE(OnMouseLeave) | 85 MSG_WM_MOUSELEAVE(OnMouseLeave) |
85 MSG_WM_NCCALCSIZE(OnNCCalcSize) | 86 MSG_WM_NCCALCSIZE(OnNCCalcSize) |
(...skipping 28 matching lines...) Expand all Loading... |
114 DISALLOW_EVIL_CONSTRUCTORS(ScopedFreeze); | 115 DISALLOW_EVIL_CONSTRUCTORS(ScopedFreeze); |
115 }; | 116 }; |
116 | 117 |
117 // message handlers | 118 // message handlers |
118 void OnChar(TCHAR key, UINT repeat_count, UINT flags); | 119 void OnChar(TCHAR key, UINT repeat_count, UINT flags); |
119 void OnContextMenu(HWND window, const CPoint& point); | 120 void OnContextMenu(HWND window, const CPoint& point); |
120 void OnCopy(); | 121 void OnCopy(); |
121 LRESULT OnCreate(CREATESTRUCT* create_struct); | 122 LRESULT OnCreate(CREATESTRUCT* create_struct); |
122 void OnCut(); | 123 void OnCut(); |
123 void OnDestroy(); | 124 void OnDestroy(); |
| 125 LRESULT OnImeChar(UINT message, WPARAM wparam, LPARAM lparam); |
124 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); | 126 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); |
125 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); | 127 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); |
126 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); | 128 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); |
127 void OnLButtonDblClk(UINT keys, const CPoint& point); | 129 void OnLButtonDblClk(UINT keys, const CPoint& point); |
128 void OnLButtonDown(UINT keys, const CPoint& point); | 130 void OnLButtonDown(UINT keys, const CPoint& point); |
129 void OnLButtonUp(UINT keys, const CPoint& point); | 131 void OnLButtonUp(UINT keys, const CPoint& point); |
130 void OnMouseLeave(); | 132 void OnMouseLeave(); |
131 void OnMouseMove(UINT keys, const CPoint& point); | 133 void OnMouseMove(UINT keys, const CPoint& point); |
132 int OnNCCalcSize(BOOL w_param, LPARAM l_param); | 134 int OnNCCalcSize(BOOL w_param, LPARAM l_param); |
133 void OnNCPaint(HRGN region); | 135 void OnNCPaint(HRGN region); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 434 |
433 // This replace selection will have no effect (even on the undo stack) if the | 435 // This replace selection will have no effect (even on the undo stack) if the |
434 // current selection is empty. | 436 // current selection is empty. |
435 ReplaceSel(L"", true); | 437 ReplaceSel(L"", true); |
436 } | 438 } |
437 | 439 |
438 void TextField::Edit::OnDestroy() { | 440 void TextField::Edit::OnDestroy() { |
439 TRACK_HWND_DESTRUCTION(m_hWnd); | 441 TRACK_HWND_DESTRUCTION(m_hWnd); |
440 } | 442 } |
441 | 443 |
| 444 LRESULT TextField::Edit::OnImeChar(UINT message, WPARAM wparam, LPARAM lparam) { |
| 445 // http://crbug.com/7707: a rich-edit control may crash when it receives a |
| 446 // WM_IME_CHAR message while it is processing a WM_IME_COMPOSITION message. |
| 447 // Since view controls don't need WM_IME_CHAR messages, we prevent WM_IME_CHAR |
| 448 // messages from being dispatched to view controls via the CallWindowProc() |
| 449 // call. |
| 450 return 0; |
| 451 } |
| 452 |
442 LRESULT TextField::Edit::OnImeStartComposition(UINT message, | 453 LRESULT TextField::Edit::OnImeStartComposition(UINT message, |
443 WPARAM wparam, | 454 WPARAM wparam, |
444 LPARAM lparam) { | 455 LPARAM lparam) { |
445 // Users may press alt+shift or control+shift keys to change their keyboard | 456 // Users may press alt+shift or control+shift keys to change their keyboard |
446 // layouts. So, we retrieve the input locale identifier everytime we start | 457 // layouts. So, we retrieve the input locale identifier everytime we start |
447 // an IME composition. | 458 // an IME composition. |
448 int language_id = PRIMARYLANGID(GetKeyboardLayout(0)); | 459 int language_id = PRIMARYLANGID(GetKeyboardLayout(0)); |
449 ime_discard_composition_ = | 460 ime_discard_composition_ = |
450 language_id == LANG_JAPANESE || language_id == LANG_CHINESE; | 461 language_id == LANG_JAPANESE || language_id == LANG_CHINESE; |
451 ime_composition_start_ = 0; | 462 ime_composition_start_ = 0; |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 | 1126 |
1116 COLORREF bg_color; | 1127 COLORREF bg_color; |
1117 if (!use_default_background_color_) | 1128 if (!use_default_background_color_) |
1118 bg_color = skia::SkColorToCOLORREF(background_color_); | 1129 bg_color = skia::SkColorToCOLORREF(background_color_); |
1119 else | 1130 else |
1120 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); | 1131 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); |
1121 edit_->SetBackgroundColor(bg_color); | 1132 edit_->SetBackgroundColor(bg_color); |
1122 } | 1133 } |
1123 | 1134 |
1124 } // namespace views | 1135 } // namespace views |
OLD | NEW |