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