OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "ui/base/l10n/l10n_util_win.h" | 61 #include "ui/base/l10n/l10n_util_win.h" |
62 #include "ui/base/win/mouse_wheel_util.h" | 62 #include "ui/base/win/mouse_wheel_util.h" |
63 #include "ui/gfx/canvas.h" | 63 #include "ui/gfx/canvas.h" |
64 #include "ui/gfx/image/image.h" | 64 #include "ui/gfx/image/image.h" |
65 #include "ui/views/button_drag_utils.h" | 65 #include "ui/views/button_drag_utils.h" |
66 #include "ui/views/controls/menu/menu_item_view.h" | 66 #include "ui/views/controls/menu/menu_item_view.h" |
67 #include "ui/views/controls/menu/menu_model_adapter.h" | 67 #include "ui/views/controls/menu/menu_model_adapter.h" |
68 #include "ui/views/controls/menu/menu_runner.h" | 68 #include "ui/views/controls/menu/menu_runner.h" |
69 #include "ui/views/controls/textfield/native_textfield_win.h" | 69 #include "ui/views/controls/textfield/native_textfield_win.h" |
70 #include "ui/views/widget/widget.h" | 70 #include "ui/views/widget/widget.h" |
| 71 #include "win8/util/win8_util.h" |
71 | 72 |
72 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 73 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
73 | 74 |
74 using content::UserMetricsAction; | 75 using content::UserMetricsAction; |
75 using content::WebContents; | 76 using content::WebContents; |
76 | 77 |
77 namespace { | 78 namespace { |
78 | 79 |
79 const char kAutocompleteEditStateKey[] = "AutocompleteEditState"; | 80 const char kAutocompleteEditStateKey[] = "AutocompleteEditState"; |
80 | 81 |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 // than in OnXButtonDown() since in many scenarios OnSetFocus() will be | 1736 // than in OnXButtonDown() since in many scenarios OnSetFocus() will be |
1736 // reached before OnXButtonDown(), preventing us from detecting this properly | 1737 // reached before OnXButtonDown(), preventing us from detecting this properly |
1737 // there. Also in those cases, we need to already know in OnSetFocus() that | 1738 // there. Also in those cases, we need to already know in OnSetFocus() that |
1738 // we should not restore the saved selection. | 1739 // we should not restore the saved selection. |
1739 if (!model()->has_focus() && | 1740 if (!model()->has_focus() && |
1740 ((mouse_message == WM_LBUTTONDOWN || mouse_message == WM_RBUTTONDOWN)) && | 1741 ((mouse_message == WM_LBUTTONDOWN || mouse_message == WM_RBUTTONDOWN)) && |
1741 (result == MA_ACTIVATE)) { | 1742 (result == MA_ACTIVATE)) { |
1742 if (gaining_focus_) { | 1743 if (gaining_focus_) { |
1743 // On Windows 8 in metro mode, we get two WM_MOUSEACTIVATE messages when | 1744 // On Windows 8 in metro mode, we get two WM_MOUSEACTIVATE messages when |
1744 // we click on the omnibox with the mouse. | 1745 // we click on the omnibox with the mouse. |
1745 DCHECK(base::win::IsMetroProcess()); | 1746 DCHECK(win8::IsSingleWindowMetroMode()); |
1746 return result; | 1747 return result; |
1747 } | 1748 } |
1748 gaining_focus_.reset(new ScopedFreeze(this, GetTextObjectModel())); | 1749 gaining_focus_.reset(new ScopedFreeze(this, GetTextObjectModel())); |
1749 // NOTE: Despite |mouse_message| being WM_XBUTTONDOWN here, we're not | 1750 // NOTE: Despite |mouse_message| being WM_XBUTTONDOWN here, we're not |
1750 // guaranteed to call OnXButtonDown() later! Specifically, if this is the | 1751 // guaranteed to call OnXButtonDown() later! Specifically, if this is the |
1751 // second click of a double click, we'll reach here but later call | 1752 // second click of a double click, we'll reach here but later call |
1752 // OnXButtonDblClk(). Make sure |gaining_focus_| gets reset both places, | 1753 // OnXButtonDblClk(). Make sure |gaining_focus_| gets reset both places, |
1753 // or we'll have visual glitchiness and then DCHECK failures. | 1754 // or we'll have visual glitchiness and then DCHECK failures. |
1754 | 1755 |
1755 // Don't restore saved selection, it will just screw up our interaction | 1756 // Don't restore saved selection, it will just screw up our interaction |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2747 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2747 } | 2748 } |
2748 | 2749 |
2749 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2750 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2750 // Use font_.GetStringWidth() instead of | 2751 // Use font_.GetStringWidth() instead of |
2751 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2752 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2752 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2753 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
2753 // PosFromChar(i) might return 0 when i is greater than 1. | 2754 // PosFromChar(i) might return 0 when i is greater than 1. |
2754 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2755 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2755 } | 2756 } |
OLD | NEW |