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 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 } | 1994 } |
1995 | 1995 |
1996 // We're showing a keyword and the user pressed backspace at the beginning | 1996 // We're showing a keyword and the user pressed backspace at the beginning |
1997 // of the text. Delete the selected keyword. | 1997 // of the text. Delete the selected keyword. |
1998 ScopedFreeze freeze(this, GetTextObjectModel()); | 1998 ScopedFreeze freeze(this, GetTextObjectModel()); |
1999 model_->ClearKeyword(GetText()); | 1999 model_->ClearKeyword(GetText()); |
2000 return true; | 2000 return true; |
2001 } | 2001 } |
2002 | 2002 |
2003 case VK_TAB: { | 2003 case VK_TAB: { |
2004 if (model_->is_keyword_hint()) { | 2004 const bool shift_pressed = GetKeyState(VK_SHIFT) < 0; |
| 2005 if (model_->is_keyword_hint() && !shift_pressed) { |
2005 // Accept the keyword. | 2006 // Accept the keyword. |
2006 ScopedFreeze freeze(this, GetTextObjectModel()); | 2007 ScopedFreeze freeze(this, GetTextObjectModel()); |
2007 model_->AcceptKeyword(); | 2008 model_->AcceptKeyword(); |
2008 } else if (!IsCaretAtEnd()) { | |
2009 ScopedFreeze freeze(this, GetTextObjectModel()); | |
2010 OnBeforePossibleChange(); | |
2011 PlaceCaretAt(GetTextLength()); | |
2012 OnAfterPossibleChange(); | |
2013 } else { | 2009 } else { |
2014 model_->CommitSuggestedText(true); | 2010 model_->OnUpOrDownKeyPressed(shift_pressed ? -count : count); |
2015 } | 2011 } |
2016 return true; | 2012 return true; |
2017 } | 2013 } |
2018 | 2014 |
2019 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). | 2015 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). |
2020 // We don't use VK_OEM_PLUS in case the macro isn't defined. | 2016 // We don't use VK_OEM_PLUS in case the macro isn't defined. |
2021 // (e.g., we don't have this symbol in embeded environment). | 2017 // (e.g., we don't have this symbol in embeded environment). |
2022 return true; | 2018 return true; |
2023 | 2019 |
2024 default: | 2020 default: |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 // PosFromChar(i) might return 0 when i is greater than 1. | 2594 // PosFromChar(i) might return 0 when i is greater than 1. |
2599 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2595 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2600 } | 2596 } |
2601 | 2597 |
2602 bool OmniboxViewWin::IsCaretAtEnd() const { | 2598 bool OmniboxViewWin::IsCaretAtEnd() const { |
2603 long length = GetTextLength(); | 2599 long length = GetTextLength(); |
2604 CHARRANGE sel; | 2600 CHARRANGE sel; |
2605 GetSelection(sel); | 2601 GetSelection(sel); |
2606 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2602 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
2607 } | 2603 } |
OLD | NEW |