Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 6602070: Port autocomplete_edit_view_browsertest.cc to Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrimarySelection test. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autocomplete/autocomplete_edit_view_mac.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "app/mac/nsimage_cache.h" 9 #include "app/mac/nsimage_cache.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 return 0; 739 return 0;
740 } 740 }
741 741
742 bool AutocompleteEditViewMac::IsImeComposing() const { 742 bool AutocompleteEditViewMac::IsImeComposing() const {
743 return [(NSTextView*)[field_ currentEditor] hasMarkedText]; 743 return [(NSTextView*)[field_ currentEditor] hasMarkedText];
744 } 744 }
745 745
746 void AutocompleteEditViewMac::OnDidBeginEditing() { 746 void AutocompleteEditViewMac::OnDidBeginEditing() {
747 // We should only arrive here when the field is focussed. 747 // We should only arrive here when the field is focussed.
748 DCHECK([field_ currentEditor]); 748 DCHECK([field_ currentEditor]);
749 }
749 750
751 void AutocompleteEditViewMac::OnBeforeChange() {
750 // Capture the current state. 752 // Capture the current state.
751 OnBeforePossibleChange(); 753 OnBeforePossibleChange();
752 } 754 }
753 755
754 void AutocompleteEditViewMac::OnDidChange() { 756 void AutocompleteEditViewMac::OnDidChange() {
755 // Figure out what changed and notify the model_. 757 // Figure out what changed and notify the model_.
756 OnAfterPossibleChange(); 758 OnAfterPossibleChange();
757
758 // Then capture the new state.
759 OnBeforePossibleChange();
760 } 759 }
761 760
762 void AutocompleteEditViewMac::OnDidEndEditing() { 761 void AutocompleteEditViewMac::OnDidEndEditing() {
763 ClosePopup(); 762 ClosePopup();
764 } 763 }
765 764
766 bool AutocompleteEditViewMac::OnDoCommandBySelector(SEL cmd) { 765 bool AutocompleteEditViewMac::OnDoCommandBySelector(SEL cmd) {
767 // We should only arrive here when the field is focussed. 766 // We should only arrive here when the field is focussed.
768 DCHECK(IsFirstResponder()); 767 DCHECK(IsFirstResponder());
769 768
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (cmd == @selector(deleteForward:)) { 879 if (cmd == @selector(deleteForward:)) {
881 const NSUInteger modifiers = [[NSApp currentEvent] modifierFlags]; 880 const NSUInteger modifiers = [[NSApp currentEvent] modifierFlags];
882 if ((modifiers & NSShiftKeyMask) != 0) { 881 if ((modifiers & NSShiftKeyMask) != 0) {
883 if (model_->popup_model()->IsOpen()) { 882 if (model_->popup_model()->IsOpen()) {
884 model_->popup_model()->TryDeletingCurrentItem(); 883 model_->popup_model()->TryDeletingCurrentItem();
885 return true; 884 return true;
886 } 885 }
887 } 886 }
888 } 887 }
889 888
890 // Capture the state before the operation changes the content.
891 // TODO(shess): Determine if this is always redundent WRT the call
892 // in -controlTextDidChange:.
893 OnBeforePossibleChange();
894 return false; 889 return false;
895 } 890 }
896 891
897 void AutocompleteEditViewMac::OnSetFocus(bool control_down) { 892 void AutocompleteEditViewMac::OnSetFocus(bool control_down) {
898 model_->OnSetFocus(control_down); 893 model_->OnSetFocus(control_down);
899 controller_->OnSetFocus(); 894 controller_->OnSetFocus();
900 } 895 }
901 896
902 void AutocompleteEditViewMac::OnKillFocus() { 897 void AutocompleteEditViewMac::OnKillFocus() {
903 // Tell the model to reset itself. 898 // Tell the model to reset itself.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1112
1118 void AutocompleteEditViewMac::PlaceCaretAt(NSUInteger pos) { 1113 void AutocompleteEditViewMac::PlaceCaretAt(NSUInteger pos) {
1119 DCHECK(pos <= GetTextLength()); 1114 DCHECK(pos <= GetTextLength());
1120 SetSelectedRange(NSMakeRange(pos, pos)); 1115 SetSelectedRange(NSMakeRange(pos, pos));
1121 } 1116 }
1122 1117
1123 bool AutocompleteEditViewMac::IsCaretAtEnd() const { 1118 bool AutocompleteEditViewMac::IsCaretAtEnd() const {
1124 const NSRange selection = GetSelectedRange(); 1119 const NSRange selection = GetSelectedRange();
1125 return selection.length == 0 && selection.location == GetTextLength(); 1120 return selection.length == 0 && selection.location == GetTextLength();
1126 } 1121 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.h ('k') | chrome/browser/autocomplete/autocomplete_popup_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698