OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 virtual bool IsSelectAll() { | 66 virtual bool IsSelectAll() { |
67 NOTIMPLEMENTED(); | 67 NOTIMPLEMENTED(); |
68 return false; | 68 return false; |
69 } | 69 } |
70 | 70 |
71 virtual void SelectAll(bool reversed); | 71 virtual void SelectAll(bool reversed); |
72 virtual void RevertAll(); | 72 virtual void RevertAll(); |
73 virtual void UpdatePopup(); | 73 virtual void UpdatePopup(); |
74 virtual void ClosePopup(); | 74 virtual void ClosePopup(); |
75 void UpdateAndStyleText(const std::wstring& display_text, | |
76 size_t user_text_length); | |
77 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, | 75 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, |
78 bool save_original_selection); | 76 bool save_original_selection); |
79 virtual bool OnInlineAutocompleteTextMaybeChanged( | 77 virtual bool OnInlineAutocompleteTextMaybeChanged( |
80 const std::wstring& display_text, size_t user_text_length); | 78 const std::wstring& display_text, size_t user_text_length); |
81 virtual void OnRevertTemporaryText(); | 79 virtual void OnRevertTemporaryText(); |
82 virtual void OnBeforePossibleChange(); | 80 virtual void OnBeforePossibleChange(); |
83 virtual bool OnAfterPossibleChange(); | 81 virtual bool OnAfterPossibleChange(); |
84 | 82 |
85 // Helper functions which forward to our private: model_. | 83 // Helper functions which forward to our private: model_. |
86 void OnUpOrDownKeyPressed(bool up, bool by_page); | 84 void OnUpOrDownKeyPressed(bool up, bool by_page); |
87 void OnEscapeKeyPressed(); | 85 void OnEscapeKeyPressed(); |
88 void OnSetFocus(bool f); | 86 void OnSetFocus(bool f); |
89 void OnKillFocus(); | 87 void OnKillFocus(); |
90 void AcceptInput(WindowOpenDisposition disposition, bool for_drop); | 88 void AcceptInput(WindowOpenDisposition disposition, bool for_drop); |
91 | 89 |
92 // Helper for LocationBarBridge. | 90 // Helper for LocationBarBridge. |
93 void FocusLocation(); | 91 void FocusLocation(); |
94 | 92 |
95 private: | 93 private: |
96 // Returns the field's currently selected range. Only valid if the | 94 // Returns the field's currently selected range. Only valid if the |
97 // field has focus. | 95 // field has focus. |
98 NSRange GetSelectedRange() const; | 96 NSRange GetSelectedRange() const; |
99 | 97 |
| 98 // Grab focus if needed and set the selection to |range|. |
| 99 void SetSelectedRange(const NSRange range); |
| 100 |
| 101 // Update the field with |display_text| and highlight the host and |
| 102 // scheme (if it's an URL or URL-fragment). |
| 103 void UpdateAndStyleText(const std::wstring& display_text); |
| 104 |
100 scoped_ptr<AutocompleteEditModel> model_; | 105 scoped_ptr<AutocompleteEditModel> model_; |
101 scoped_ptr<AutocompletePopupViewMac> popup_view_; | 106 scoped_ptr<AutocompletePopupViewMac> popup_view_; |
102 | 107 |
103 AutocompleteEditController* controller_; | 108 AutocompleteEditController* controller_; |
104 ToolbarModel* toolbar_model_; | 109 ToolbarModel* toolbar_model_; |
105 | 110 |
106 // The object that handles additional command functionality exposed on the | 111 // The object that handles additional command functionality exposed on the |
107 // edit, such as invoking the keyword editor. | 112 // edit, such as invoking the keyword editor. |
108 CommandUpdater* command_updater_; | 113 CommandUpdater* command_updater_; |
109 | 114 |
110 NSTextField* field_; // owned by tab controller | 115 NSTextField* field_; // owned by tab controller |
111 | 116 |
112 // Objective-C object to bridge field_ delegate calls to C++. | 117 // Objective-C object to bridge field_ delegate calls to C++. |
113 scoped_nsobject<AutocompleteEditHelper> edit_helper_; | 118 scoped_nsobject<AutocompleteEditHelper> edit_helper_; |
114 | 119 |
| 120 // Text and selection at the point where the user started using the |
| 121 // arrows to move around in the popup. |
| 122 NSRange saved_temporary_selection_; |
115 std::wstring saved_temporary_text_; | 123 std::wstring saved_temporary_text_; |
116 | 124 |
117 // Tracking state before and after a possible change for reporting | 125 // Tracking state before and after a possible change for reporting |
118 // to model_. | 126 // to model_. |
119 NSRange selection_before_change_; | 127 NSRange selection_before_change_; |
120 std::wstring text_before_change_; | 128 std::wstring text_before_change_; |
121 | 129 |
122 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); | 130 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); |
123 }; | 131 }; |
124 | 132 |
125 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 133 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
OLD | NEW |