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 |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "chrome/browser/search_engines/template_url_model.h" | 33 #include "chrome/browser/search_engines/template_url_model.h" |
34 #include "chrome/browser/tab_contents/tab_contents.h" | 34 #include "chrome/browser/tab_contents/tab_contents.h" |
35 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 35 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
36 #include "chrome/common/notification_service.h" | 36 #include "chrome/common/notification_service.h" |
37 #include "googleurl/src/url_util.h" | 37 #include "googleurl/src/url_util.h" |
38 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
39 #include "net/base/escape.h" | 39 #include "net/base/escape.h" |
40 #include "skia/ext/skia_utils_win.h" | 40 #include "skia/ext/skia_utils_win.h" |
41 #include "ui/base/clipboard/clipboard.h" | 41 #include "ui/base/clipboard/clipboard.h" |
42 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 42 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
43 #include "ui/base/dragdrop/drag_drop_types.h" | |
43 #include "ui/base/dragdrop/drag_source.h" | 44 #include "ui/base/dragdrop/drag_source.h" |
44 #include "ui/base/dragdrop/drop_target.h" | 45 #include "ui/base/dragdrop/drop_target.h" |
45 #include "ui/base/dragdrop/os_exchange_data.h" | 46 #include "ui/base/dragdrop/os_exchange_data.h" |
46 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 47 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
47 #include "ui/base/keycodes/keyboard_codes.h" | 48 #include "ui/base/keycodes/keyboard_codes.h" |
48 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
49 #include "ui/base/l10n/l10n_util_win.h" | 50 #include "ui/base/l10n/l10n_util_win.h" |
50 #include "ui/gfx/canvas.h" | 51 #include "ui/gfx/canvas.h" |
51 #include "ui/gfx/canvas_skia.h" | 52 #include "ui/gfx/canvas_skia.h" |
52 #include "views/controls/textfield/native_textfield_win.h" | 53 #include "views/controls/textfield/native_textfield_win.h" |
53 #include "views/drag_utils.h" | 54 #include "views/drag_utils.h" |
54 #include "views/events/event_utils_win.h" | 55 #include "views/events/event_utils_win.h" |
55 #include "views/focus/focus_util_win.h" | 56 #include "views/focus/focus_util_win.h" |
56 #include "views/widget/widget.h" | 57 #include "views/widget/widget.h" |
57 | 58 |
58 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 59 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
59 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. | 60 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. |
60 | 61 |
61 /////////////////////////////////////////////////////////////////////////////// | 62 /////////////////////////////////////////////////////////////////////////////// |
62 // AutocompleteEditModel | 63 // AutocompleteEditModel |
63 | 64 |
64 namespace { | 65 namespace { |
65 | 66 |
67 // A helper method for determining a valid DROPEFFECT given the allowed | |
68 // DROPEFFECTS. We prefer copy over link. | |
69 DWORD CopyOrLinkDropEffect(DWORD effect) { | |
70 if (effect & DROPEFFECT_COPY) | |
71 return DROPEFFECT_COPY; | |
72 if (effect & DROPEFFECT_LINK) | |
73 return DROPEFFECT_LINK; | |
74 return DROPEFFECT_NONE; | |
75 } | |
76 | |
77 // A helper method for determining a valid drag operation given the allowed | |
78 // operation. We prefer copy over link. | |
79 int CopyOrLinkDragOperation(int drag_operation) { | |
80 if (drag_operation & ui::DragDropTypes::DRAG_COPY) | |
81 return ui::DragDropTypes::DRAG_COPY; | |
82 if (drag_operation & ui::DragDropTypes::DRAG_LINK) | |
83 return ui::DragDropTypes::DRAG_LINK; | |
84 return ui::DragDropTypes::DRAG_NONE; | |
85 } | |
86 | |
87 // The AutocompleteEditState struct contains enough information about the | |
88 // AutocompleteEditModel and AutocompleteEditViewWin to save/restore a user's | |
89 // typing, caret position, etc. across tab changes. We explicitly don't | |
90 // preserve things like whether the popup was open as this might be weird. | |
91 struct AutocompleteEditState { | |
92 AutocompleteEditState(const AutocompleteEditModel::State model_state, | |
93 const AutocompleteEditViewWin::State view_state) | |
94 : model_state(model_state), | |
95 view_state(view_state) { | |
96 } | |
97 | |
98 const AutocompleteEditModel::State model_state; | |
99 const AutocompleteEditViewWin::State view_state; | |
100 }; | |
101 | |
102 // Returns true if the current point is far enough from the origin that it | |
103 // would be considered a drag. | |
104 bool IsDrag(const POINT& origin, const POINT& current) { | |
sky
2011/02/15 19:05:50
Use views::View::ExeceededDragThreshold instead
Roger Tawa OOO till Jul 10th
2011/02/15 19:50:07
Done.
| |
105 // The CXDRAG and CYDRAG system metrics describe the width and height of a | |
106 // rectangle around the origin position, inside of which motion is not | |
107 // considered a drag. | |
108 return (abs(current.x - origin.x) > (GetSystemMetrics(SM_CXDRAG) / 2)) || | |
109 (abs(current.y - origin.y) > (GetSystemMetrics(SM_CYDRAG) / 2)); | |
110 } | |
111 | |
112 } // namespace | |
113 | |
66 // EditDropTarget is the IDropTarget implementation installed on | 114 // EditDropTarget is the IDropTarget implementation installed on |
67 // AutocompleteEditViewWin. EditDropTarget prefers URL over plain text. A drop | 115 // AutocompleteEditViewWin. EditDropTarget prefers URL over plain text. A drop |
68 // of a URL replaces all the text of the edit and navigates immediately to the | 116 // of a URL replaces all the text of the edit and navigates immediately to the |
69 // URL. A drop of plain text from the same edit either copies or moves the | 117 // URL. A drop of plain text from the same edit either copies or moves the |
70 // selected text, and a drop of plain text from a source other than the edit | 118 // selected text, and a drop of plain text from a source other than the edit |
71 // does a paste and go. | 119 // does a paste and go. |
72 class EditDropTarget : public ui::DropTarget { | 120 class AutocompleteEditViewWin::EditDropTarget : public ui::DropTarget { |
73 public: | 121 public: |
74 explicit EditDropTarget(AutocompleteEditViewWin* edit); | 122 explicit EditDropTarget(AutocompleteEditViewWin* edit); |
75 | 123 |
76 protected: | 124 protected: |
77 virtual DWORD OnDragEnter(IDataObject* data_object, | 125 virtual DWORD OnDragEnter(IDataObject* data_object, |
78 DWORD key_state, | 126 DWORD key_state, |
79 POINT cursor_position, | 127 POINT cursor_position, |
80 DWORD effect); | 128 DWORD effect); |
81 virtual DWORD OnDragOver(IDataObject* data_object, | 129 virtual DWORD OnDragOver(IDataObject* data_object, |
82 DWORD key_state, | 130 DWORD key_state, |
(...skipping 19 matching lines...) Expand all Loading... | |
102 // If true, the drag session contains a URL. | 150 // If true, the drag session contains a URL. |
103 bool drag_has_url_; | 151 bool drag_has_url_; |
104 | 152 |
105 // If true, the drag session contains a string. If drag_has_url_ is true, | 153 // If true, the drag session contains a string. If drag_has_url_ is true, |
106 // this is false regardless of whether the clipboard has a string. | 154 // this is false regardless of whether the clipboard has a string. |
107 bool drag_has_string_; | 155 bool drag_has_string_; |
108 | 156 |
109 DISALLOW_COPY_AND_ASSIGN(EditDropTarget); | 157 DISALLOW_COPY_AND_ASSIGN(EditDropTarget); |
110 }; | 158 }; |
111 | 159 |
112 // A helper method for determining a valid DROPEFFECT given the allowed | 160 AutocompleteEditViewWin::EditDropTarget::EditDropTarget( |
113 // DROPEFFECTS. We prefer copy over link. | 161 AutocompleteEditViewWin* edit) |
114 DWORD CopyOrLinkDropEffect(DWORD effect) { | |
115 if (effect & DROPEFFECT_COPY) | |
116 return DROPEFFECT_COPY; | |
117 if (effect & DROPEFFECT_LINK) | |
118 return DROPEFFECT_LINK; | |
119 return DROPEFFECT_NONE; | |
120 } | |
121 | |
122 EditDropTarget::EditDropTarget(AutocompleteEditViewWin* edit) | |
123 : ui::DropTarget(edit->m_hWnd), | 162 : ui::DropTarget(edit->m_hWnd), |
124 edit_(edit), | 163 edit_(edit), |
125 drag_has_url_(false), | 164 drag_has_url_(false), |
126 drag_has_string_(false) { | 165 drag_has_string_(false) { |
127 } | 166 } |
128 | 167 |
129 DWORD EditDropTarget::OnDragEnter(IDataObject* data_object, | 168 DWORD AutocompleteEditViewWin::EditDropTarget::OnDragEnter( |
130 DWORD key_state, | 169 IDataObject* data_object, |
131 POINT cursor_position, | 170 DWORD key_state, |
132 DWORD effect) { | 171 POINT cursor_position, |
172 DWORD effect) { | |
133 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); | 173 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); |
134 drag_has_url_ = os_data.HasURL(); | 174 drag_has_url_ = os_data.HasURL(); |
135 drag_has_string_ = !drag_has_url_ && os_data.HasString(); | 175 drag_has_string_ = !drag_has_url_ && os_data.HasString(); |
136 if (drag_has_url_) { | 176 if (drag_has_url_) { |
137 if (edit_->in_drag()) { | 177 if (edit_->in_drag()) { |
138 // The edit we're associated with originated the drag. No point in | 178 // The edit we're associated with originated the drag. No point in |
139 // allowing the user to drop back on us. | 179 // allowing the user to drop back on us. |
140 drag_has_url_ = false; | 180 drag_has_url_ = false; |
141 } | 181 } |
142 // NOTE: it would be nice to visually show all the text is going to | 182 // NOTE: it would be nice to visually show all the text is going to |
143 // be replaced by selecting all, but this caused painting problems. In | 183 // be replaced by selecting all, but this caused painting problems. In |
144 // particular the flashing caret would appear outside the edit! For now | 184 // particular the flashing caret would appear outside the edit! For now |
145 // we stick with no visual indicator other than that shown own the mouse | 185 // we stick with no visual indicator other than that shown own the mouse |
146 // cursor. | 186 // cursor. |
147 } | 187 } |
148 return OnDragOver(data_object, key_state, cursor_position, effect); | 188 return OnDragOver(data_object, key_state, cursor_position, effect); |
149 } | 189 } |
150 | 190 |
151 DWORD EditDropTarget::OnDragOver(IDataObject* data_object, | 191 DWORD AutocompleteEditViewWin::EditDropTarget::OnDragOver( |
152 DWORD key_state, | 192 IDataObject* data_object, |
153 POINT cursor_position, | 193 DWORD key_state, |
154 DWORD effect) { | 194 POINT cursor_position, |
195 DWORD effect) { | |
155 if (drag_has_url_) | 196 if (drag_has_url_) |
156 return CopyOrLinkDropEffect(effect); | 197 return CopyOrLinkDropEffect(effect); |
157 | 198 |
158 if (drag_has_string_) { | 199 if (drag_has_string_) { |
159 UpdateDropHighlightPosition(cursor_position); | 200 UpdateDropHighlightPosition(cursor_position); |
160 if (edit_->drop_highlight_position() == -1 && edit_->in_drag()) | 201 if (edit_->drop_highlight_position() == -1 && edit_->in_drag()) |
161 return DROPEFFECT_NONE; | 202 return DROPEFFECT_NONE; |
162 if (edit_->in_drag()) { | 203 if (edit_->in_drag()) { |
163 // The edit we're associated with originated the drag. Do the normal drag | 204 // The edit we're associated with originated the drag. Do the normal drag |
164 // behavior. | 205 // behavior. |
165 DCHECK((effect & DROPEFFECT_COPY) && (effect & DROPEFFECT_MOVE)); | 206 DCHECK((effect & DROPEFFECT_COPY) && (effect & DROPEFFECT_MOVE)); |
166 return (key_state & MK_CONTROL) ? DROPEFFECT_COPY : DROPEFFECT_MOVE; | 207 return (key_state & MK_CONTROL) ? DROPEFFECT_COPY : DROPEFFECT_MOVE; |
167 } | 208 } |
168 // Our edit didn't originate the drag, only allow link or copy. | 209 // Our edit didn't originate the drag, only allow link or copy. |
169 return CopyOrLinkDropEffect(effect); | 210 return CopyOrLinkDropEffect(effect); |
170 } | 211 } |
171 | 212 |
172 return DROPEFFECT_NONE; | 213 return DROPEFFECT_NONE; |
173 } | 214 } |
174 | 215 |
175 void EditDropTarget::OnDragLeave(IDataObject* data_object) { | 216 void AutocompleteEditViewWin::EditDropTarget::OnDragLeave( |
217 IDataObject* data_object) { | |
176 ResetDropHighlights(); | 218 ResetDropHighlights(); |
177 } | 219 } |
178 | 220 |
179 DWORD EditDropTarget::OnDrop(IDataObject* data_object, | 221 DWORD AutocompleteEditViewWin::EditDropTarget::OnDrop( |
180 DWORD key_state, | 222 IDataObject* data_object, |
181 POINT cursor_position, | 223 DWORD key_state, |
182 DWORD effect) { | 224 POINT cursor_position, |
225 DWORD effect) { | |
226 effect = OnDragOver(data_object, key_state, cursor_position, effect); | |
227 | |
228 // OnDragOver() always returns only one effect type. We create the event | |
sky
2011/02/15 19:05:50
Nuke this comment, it isn't useful.
Roger Tawa OOO till Jul 10th
2011/02/15 19:50:07
Done.
| |
229 // with this effect so that it too only has one drag type. | |
183 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); | 230 ui::OSExchangeData os_data(new ui::OSExchangeDataProviderWin(data_object)); |
231 views::DropTargetEvent event(os_data, cursor_position.x, cursor_position.y, | |
232 ui::DragDropTypes::DropEffectToDragOperation(effect)); | |
184 | 233 |
185 if (drag_has_url_) { | 234 int drag_operation = edit_->OnPerformDropImpl(event, edit_->in_drag()); |
186 GURL url; | |
187 string16 title; | |
188 if (os_data.GetURLAndTitle(&url, &title)) { | |
189 edit_->SetUserText(UTF8ToWide(url.spec())); | |
190 edit_->model()->AcceptInput(CURRENT_TAB, true); | |
191 return CopyOrLinkDropEffect(effect); | |
192 } | |
193 } else if (drag_has_string_) { | |
194 int string_drop_position = edit_->drop_highlight_position(); | |
195 string16 text; | |
196 if ((string_drop_position != -1 || !edit_->in_drag()) && | |
197 os_data.GetString(&text)) { | |
198 DCHECK(string_drop_position == -1 || | |
199 ((string_drop_position >= 0) && | |
200 (string_drop_position <= edit_->GetTextLength()))); | |
201 const DWORD drop_operation = | |
202 OnDragOver(data_object, key_state, cursor_position, effect); | |
203 if (edit_->in_drag()) { | |
204 if (drop_operation == DROPEFFECT_MOVE) | |
205 edit_->MoveSelectedText(string_drop_position); | |
206 else | |
207 edit_->InsertText(string_drop_position, text); | |
208 } else { | |
209 edit_->PasteAndGo(CollapseWhitespace(text, true)); | |
210 } | |
211 ResetDropHighlights(); | |
212 return drop_operation; | |
213 } | |
214 } | |
215 | 235 |
216 ResetDropHighlights(); | 236 if (!drag_has_url_) |
237 ResetDropHighlights(); | |
217 | 238 |
218 return DROPEFFECT_NONE; | 239 return ui::DragDropTypes::DragOperationToDropEffect(drag_operation); |
219 } | 240 } |
220 | 241 |
221 void EditDropTarget::UpdateDropHighlightPosition( | 242 void AutocompleteEditViewWin::EditDropTarget::UpdateDropHighlightPosition( |
222 const POINT& cursor_screen_position) { | 243 const POINT& cursor_screen_position) { |
223 if (drag_has_string_) { | 244 if (drag_has_string_) { |
224 POINT client_position = cursor_screen_position; | 245 POINT client_position = cursor_screen_position; |
225 ScreenToClient(edit_->m_hWnd, &client_position); | 246 ::ScreenToClient(edit_->m_hWnd, &client_position); |
226 int drop_position = edit_->CharFromPos(client_position); | 247 int drop_position = edit_->CharFromPos(client_position); |
227 if (edit_->in_drag()) { | 248 if (edit_->in_drag()) { |
228 // Our edit originated the drag, don't allow a drop if over the selected | 249 // Our edit originated the drag, don't allow a drop if over the selected |
229 // region. | 250 // region. |
230 LONG sel_start, sel_end; | 251 LONG sel_start, sel_end; |
231 edit_->GetSel(sel_start, sel_end); | 252 edit_->GetSel(sel_start, sel_end); |
232 if ((sel_start != sel_end) && (drop_position >= sel_start) && | 253 if ((sel_start != sel_end) && (drop_position >= sel_start) && |
233 (drop_position <= sel_end)) | 254 (drop_position <= sel_end)) |
234 drop_position = -1; | 255 drop_position = -1; |
235 } else { | 256 } else { |
236 // A drop from a source other than the edit replaces all the text, so | 257 // A drop from a source other than the edit replaces all the text, so |
237 // we don't show the drop location. See comment in OnDragEnter as to why | 258 // we don't show the drop location. See comment in OnDragEnter as to why |
238 // we don't try and select all here. | 259 // we don't try and select all here. |
239 drop_position = -1; | 260 drop_position = -1; |
240 } | 261 } |
241 edit_->SetDropHighlightPosition(drop_position); | 262 edit_->SetDropHighlightPosition(drop_position); |
242 } | 263 } |
243 } | 264 } |
244 | 265 |
245 void EditDropTarget::ResetDropHighlights() { | 266 void AutocompleteEditViewWin::EditDropTarget::ResetDropHighlights() { |
246 if (drag_has_string_) | 267 if (drag_has_string_) |
247 edit_->SetDropHighlightPosition(-1); | 268 edit_->SetDropHighlightPosition(-1); |
248 } | 269 } |
249 | 270 |
250 // The AutocompleteEditState struct contains enough information about the | |
251 // AutocompleteEditModel and AutocompleteEditViewWin to save/restore a user's | |
252 // typing, caret position, etc. across tab changes. We explicitly don't | |
253 // preserve things like whether the popup was open as this might be weird. | |
254 struct AutocompleteEditState { | |
255 AutocompleteEditState(const AutocompleteEditModel::State model_state, | |
256 const AutocompleteEditViewWin::State view_state) | |
257 : model_state(model_state), | |
258 view_state(view_state) { | |
259 } | |
260 | |
261 const AutocompleteEditModel::State model_state; | |
262 const AutocompleteEditViewWin::State view_state; | |
263 }; | |
264 | |
265 // Returns true if the current point is far enough from the origin that it | |
266 // would be considered a drag. | |
267 bool IsDrag(const POINT& origin, const POINT& current) { | |
268 // The CXDRAG and CYDRAG system metrics describe the width and height of a | |
269 // rectangle around the origin position, inside of which motion is not | |
270 // considered a drag. | |
271 return (abs(current.x - origin.x) > (GetSystemMetrics(SM_CXDRAG) / 2)) || | |
272 (abs(current.y - origin.y) > (GetSystemMetrics(SM_CYDRAG) / 2)); | |
273 } | |
274 | |
275 } // namespace | |
276 | 271 |
277 /////////////////////////////////////////////////////////////////////////////// | 272 /////////////////////////////////////////////////////////////////////////////// |
278 // Helper classes | 273 // Helper classes |
279 | 274 |
280 AutocompleteEditViewWin::ScopedFreeze::ScopedFreeze( | 275 AutocompleteEditViewWin::ScopedFreeze::ScopedFreeze( |
281 AutocompleteEditViewWin* edit, | 276 AutocompleteEditViewWin* edit, |
282 ITextDocument* text_object_model) | 277 ITextDocument* text_object_model) |
283 : edit_(edit), | 278 : edit_(edit), |
284 text_object_model_(text_object_model) { | 279 text_object_model_(text_object_model) { |
285 // Freeze the screen. | 280 // Freeze the screen. |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 } | 951 } |
957 | 952 |
958 views::View* AutocompleteEditViewWin::AddToView(views::View* parent) { | 953 views::View* AutocompleteEditViewWin::AddToView(views::View* parent) { |
959 views::NativeViewHost* host = new views::NativeViewHost; | 954 views::NativeViewHost* host = new views::NativeViewHost; |
960 parent->AddChildView(host); | 955 parent->AddChildView(host); |
961 host->set_focus_view(parent); | 956 host->set_focus_view(parent); |
962 host->Attach(GetNativeView()); | 957 host->Attach(GetNativeView()); |
963 return host; | 958 return host; |
964 } | 959 } |
965 | 960 |
961 int AutocompleteEditViewWin::OnPerformDrop( | |
962 const views::DropTargetEvent& event) { | |
963 return OnPerformDropImpl(event, false); | |
964 } | |
965 | |
966 int AutocompleteEditViewWin::OnPerformDropImpl( | |
967 const views::DropTargetEvent& event, | |
968 bool in_drag) { | |
969 const ui::OSExchangeData& data = event.data(); | |
970 | |
971 if (data.HasURL()) { | |
972 GURL url; | |
973 string16 title; | |
974 if (data.GetURLAndTitle(&url, &title)) { | |
975 SetUserText(UTF8ToWide(url.spec())); | |
976 model()->AcceptInput(CURRENT_TAB, true); | |
977 return CopyOrLinkDragOperation(event.source_operations()); | |
978 } | |
979 } else if (data.HasString()) { | |
980 int string_drop_position = drop_highlight_position(); | |
981 string16 text; | |
982 if ((string_drop_position != -1 || !in_drag) && data.GetString(&text)) { | |
983 DCHECK(string_drop_position == -1 || | |
984 ((string_drop_position >= 0) && | |
985 (string_drop_position <= GetTextLength()))); | |
986 if (in_drag) { | |
987 if (event.source_operations()== ui::DragDropTypes::DRAG_MOVE) | |
988 MoveSelectedText(string_drop_position); | |
989 else | |
990 InsertText(string_drop_position, text); | |
991 } else { | |
992 PasteAndGo(CollapseWhitespace(text, true)); | |
993 } | |
994 return CopyOrLinkDragOperation(event.source_operations()); | |
995 } | |
996 } | |
997 | |
998 return ui::DragDropTypes::DRAG_NONE; | |
999 } | |
1000 | |
966 void AutocompleteEditViewWin::PasteAndGo(const string16& text) { | 1001 void AutocompleteEditViewWin::PasteAndGo(const string16& text) { |
967 if (CanPasteAndGo(text)) | 1002 if (CanPasteAndGo(text)) |
968 model_->PasteAndGo(); | 1003 model_->PasteAndGo(); |
969 } | 1004 } |
970 | 1005 |
971 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( | 1006 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( |
972 const views::KeyEvent& e) { | 1007 const views::KeyEvent& e) { |
973 ui::KeyboardCode key = e.key_code(); | 1008 ui::KeyboardCode key = e.key_code(); |
974 // We don't process ALT + numpad digit as accelerators, they are used for | 1009 // We don't process ALT + numpad digit as accelerators, they are used for |
975 // entering special characters. We do translate alt-home. | 1010 // entering special characters. We do translate alt-home. |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2583 // PosFromChar(i) might return 0 when i is greater than 1. | 2618 // PosFromChar(i) might return 0 when i is greater than 1. |
2584 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2619 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2585 } | 2620 } |
2586 | 2621 |
2587 bool AutocompleteEditViewWin::IsCaretAtEnd() const { | 2622 bool AutocompleteEditViewWin::IsCaretAtEnd() const { |
2588 long length = GetTextLength(); | 2623 long length = GetTextLength(); |
2589 CHARRANGE sel; | 2624 CHARRANGE sel; |
2590 GetSelection(sel); | 2625 GetSelection(sel); |
2591 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2626 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
2592 } | 2627 } |
OLD | NEW |