OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1025 // Update the paste state as appropriate: if we're just finishing a paste | 1025 // Update the paste state as appropriate: if we're just finishing a paste |
1026 // that replaced all the text, preserve that information; otherwise, if we've | 1026 // that replaced all the text, preserve that information; otherwise, if we've |
1027 // made some other edit, clear paste tracking. | 1027 // made some other edit, clear paste tracking. |
1028 if (paste_state_ == PASTING) | 1028 if (paste_state_ == PASTING) |
1029 paste_state_ = PASTED; | 1029 paste_state_ = PASTED; |
1030 else if (text_differs) | 1030 else if (text_differs) |
1031 paste_state_ = NONE; | 1031 paste_state_ = NONE; |
1032 | 1032 |
1033 if (text_differs || selection_differs) { | 1033 if (text_differs || selection_differs) { |
1034 // Record current focus state for this input if we haven't already. | 1034 // Record current focus state for this input if we haven't already. |
1035 DCHECK_NE(OMNIBOX_FOCUS_NONE, focus_state_); | |
Peter Kasting
2013/08/12 18:58:15
You should comment about Linux' dumb behavior here
samarth
2013/08/12 19:13:40
Added comment and crbug.com/271590. I'll fix Linu
| |
1036 if (focus_source_ == INVALID) { | 1035 if (focus_source_ == INVALID) { |
1037 focus_source_ = (focus_state_ == OMNIBOX_FOCUS_VISIBLE) ? | 1036 focus_source_ = (focus_state_ == OMNIBOX_FOCUS_INVISIBLE) ? |
1038 OMNIBOX : FAKEBOX; | 1037 FAKEBOX : OMNIBOX; |
1039 } | 1038 } |
1040 | 1039 |
1041 // Restore caret visibility whenever the user changes text or selection in | 1040 // Restore caret visibility whenever the user changes text or selection in |
1042 // the omnibox. | 1041 // the omnibox. |
1043 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_TYPING); | 1042 SetFocusState(OMNIBOX_FOCUS_VISIBLE, OMNIBOX_FOCUS_CHANGE_TYPING); |
1044 } | 1043 } |
1045 | 1044 |
1046 // Modifying the selection counts as accepting the autocompleted text. | 1045 // Modifying the selection counts as accepting the autocompleted text. |
1047 const bool user_text_changed = | 1046 const bool user_text_changed = |
1048 text_differs || (selection_differs && !inline_autocomplete_text_.empty()); | 1047 text_differs || (selection_differs && !inline_autocomplete_text_.empty()); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 instant->OmniboxFocusChanged(state, reason, NULL); | 1320 instant->OmniboxFocusChanged(state, reason, NULL); |
1322 | 1321 |
1323 // Update state and notify view if the omnibox has focus and the caret | 1322 // Update state and notify view if the omnibox has focus and the caret |
1324 // visibility changed. | 1323 // visibility changed. |
1325 const bool was_caret_visible = is_caret_visible(); | 1324 const bool was_caret_visible = is_caret_visible(); |
1326 focus_state_ = state; | 1325 focus_state_ = state; |
1327 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1326 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1328 is_caret_visible() != was_caret_visible) | 1327 is_caret_visible() != was_caret_visible) |
1329 view_->ApplyCaretVisibility(); | 1328 view_->ApplyCaretVisibility(); |
1330 } | 1329 } |
OLD | NEW |