| 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/ui/views/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_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 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 } | 2045 } |
| 2046 | 2046 |
| 2047 // We're showing a keyword and the user pressed backspace at the beginning | 2047 // We're showing a keyword and the user pressed backspace at the beginning |
| 2048 // of the text. Delete the selected keyword. | 2048 // of the text. Delete the selected keyword. |
| 2049 ScopedFreeze freeze(this, GetTextObjectModel()); | 2049 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 2050 model_->ClearKeyword(GetText()); | 2050 model_->ClearKeyword(GetText()); |
| 2051 return true; | 2051 return true; |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 case VK_TAB: { | 2054 case VK_TAB: { |
| 2055 if (model_->is_keyword_hint()) { | 2055 const bool shift_pressed = GetKeyState(VK_SHIFT) < 0; |
| 2056 if (model_->is_keyword_hint() && !shift_pressed) { |
| 2056 // Accept the keyword. | 2057 // Accept the keyword. |
| 2057 ScopedFreeze freeze(this, GetTextObjectModel()); | 2058 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 2058 model_->AcceptKeyword(); | 2059 model_->AcceptKeyword(); |
| 2059 } else if (!IsCaretAtEnd()) { | 2060 } else if (shift_pressed && |
| 2060 ScopedFreeze freeze(this, GetTextObjectModel()); | 2061 model_->popup_model()->selected_line_state() == |
| 2061 OnBeforePossibleChange(); | 2062 AutocompletePopupModel::KEYWORD) { |
| 2062 PlaceCaretAt(GetTextLength()); | 2063 model_->ClearKeyword(GetText()); |
| 2063 OnAfterPossibleChange(); | |
| 2064 } else { | 2064 } else { |
| 2065 model_->CommitSuggestedText(true); | 2065 model_->OnUpOrDownKeyPressed(shift_pressed ? -count : count); |
| 2066 } | 2066 } |
| 2067 return true; | 2067 return true; |
| 2068 } | 2068 } |
| 2069 | 2069 |
| 2070 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). | 2070 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). |
| 2071 // We don't use VK_OEM_PLUS in case the macro isn't defined. | 2071 // We don't use VK_OEM_PLUS in case the macro isn't defined. |
| 2072 // (e.g., we don't have this symbol in embeded environment). | 2072 // (e.g., we don't have this symbol in embeded environment). |
| 2073 return true; | 2073 return true; |
| 2074 | 2074 |
| 2075 default: | 2075 default: |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2652 // PosFromChar(i) might return 0 when i is greater than 1. | 2652 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2653 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2653 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2654 } | 2654 } |
| 2655 | 2655 |
| 2656 bool OmniboxViewWin::IsCaretAtEnd() const { | 2656 bool OmniboxViewWin::IsCaretAtEnd() const { |
| 2657 long length = GetTextLength(); | 2657 long length = GetTextLength(); |
| 2658 CHARRANGE sel; | 2658 CHARRANGE sel; |
| 2659 GetSelection(sel); | 2659 GetSelection(sel); |
| 2660 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2660 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
| 2661 } | 2661 } |
| OLD | NEW |