summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 19:40:11 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 19:40:11 +0000
commit557c772943a7257f3c90cbe811c5ec1b7902a3ba (patch)
tree73d3e1463cb6d8d080a97192b546acc1272b49dc /chrome/browser/autocomplete/autocomplete_edit_view_mac.h
parent29e87d6b41b1b6179d239b488be1d94ea7833c65 (diff)
downloadchromium_src-557c772943a7257f3c90cbe811c5ec1b7902a3ba.zip
chromium_src-557c772943a7257f3c90cbe811c5ec1b7902a3ba.tar.gz
chromium_src-557c772943a7257f3c90cbe811c5ec1b7902a3ba.tar.bz2
Overhaul omnibox focus detection on Mac.
Rather than aiming to detect acquisition and loss of focus in |field_|, just acknowledge that there are cases where |field_| has focus but |model_| doesn't know. If |field_| has focus but no editing has been done, then |model_| will take no action, so this is reasonable. Window resigning key just closes the popup, and doesn't affect |model_| focus. Thus, there is no need to deal with acquiring focus when the window becomes key again, and we can live fine within the constraints of -*DidBeginEditing: and -*ShouldEndEditing:. Added checks for |field_| being focussed in all the relevant places. http://crbug.com/12338 Review URL: http://codereview.chromium.org/113746 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_mac.h')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
index e8d00fb..aec861c 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
@@ -80,13 +80,22 @@ class AutocompleteEditViewMac : public AutocompleteEditView {
virtual void OnBeforePossibleChange();
virtual bool OnAfterPossibleChange();
- // Helper functions which forward to |model_|, for use from
- // AutocompleteEditHelper Objective-C class.
+ // Helper functions for use from AutocompleteEditHelper Objective-C
+ // class.
void OnUpOrDownKeyPressed(bool up, bool by_page);
void OnEscapeKeyPressed();
- // Only forwards to |model_| if the field_ has focus.
- void OnSetFocus(bool f);
- void OnKillFocus();
+
+ // Called when editing begins in the field, and before the results
+ // of any editing are communicated to |model_|.
+ void OnWillBeginEditing();
+
+ // Called when editing ends in the field.
+ void OnDidEndEditing();
+
+ // Called when the window |field_| is in loses key to clean up
+ // visual state (such as closing the popup).
+ void OnDidResignKey();
+
void AcceptInput(WindowOpenDisposition disposition, bool for_drop);
// Helper for LocationBarBridge.
@@ -97,6 +106,11 @@ class AutocompleteEditViewMac : public AutocompleteEditView {
// field has focus.
NSRange GetSelectedRange() const;
+ // Returns true if |field_| is first-responder in the window. Used
+ // in various DCHECKS to make sure code is running in appropriate
+ // situations.
+ bool IsFirstResponder() const;
+
// Grab focus if needed and set the selection to |range|.
void SetSelectedRange(const NSRange range);