| 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/cocoa/omnibox/omnibox_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, | 135 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
| 136 ToolbarModel* toolbar_model, | 136 ToolbarModel* toolbar_model, |
| 137 Profile* profile, | 137 Profile* profile, |
| 138 CommandUpdater* command_updater, | 138 CommandUpdater* command_updater, |
| 139 AutocompleteTextField* field) | 139 AutocompleteTextField* field) |
| 140 : OmniboxView(profile, controller, toolbar_model, command_updater), | 140 : OmniboxView(profile, controller, toolbar_model, command_updater), |
| 141 popup_view_(new OmniboxPopupViewMac(this, model(), field)), | 141 popup_view_(new OmniboxPopupViewMac(this, model(), field)), |
| 142 field_(field), | 142 field_(field), |
| 143 saved_temporary_selection_(NSMakeRange(0, 0)), |
| 144 selection_before_change_(NSMakeRange(0, 0)), |
| 145 marked_range_before_change_(NSMakeRange(0, 0)), |
| 143 delete_was_pressed_(false), | 146 delete_was_pressed_(false), |
| 144 delete_at_end_pressed_(false) { | 147 delete_at_end_pressed_(false) { |
| 145 [field_ setObserver:this]; | 148 [field_ setObserver:this]; |
| 146 | 149 |
| 147 // Needed so that editing doesn't lose the styling. | 150 // Needed so that editing doesn't lose the styling. |
| 148 [field_ setAllowsEditingTextAttributes:YES]; | 151 [field_ setAllowsEditingTextAttributes:YES]; |
| 149 | 152 |
| 150 // Get the appropriate line height for the font that we use. | 153 // Get the appropriate line height for the font that we use. |
| 151 base::scoped_nsobject<NSLayoutManager> layoutManager( | 154 base::scoped_nsobject<NSLayoutManager> layoutManager( |
| 152 [[NSLayoutManager alloc] init]); | 155 [[NSLayoutManager alloc] init]); |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 | 961 |
| 959 NSUInteger OmniboxViewMac::GetTextLength() const { | 962 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 960 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 963 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 961 [[field_ stringValue] length]; | 964 [[field_ stringValue] length]; |
| 962 } | 965 } |
| 963 | 966 |
| 964 bool OmniboxViewMac::IsCaretAtEnd() const { | 967 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 965 const NSRange selection = GetSelectedRange(); | 968 const NSRange selection = GetSelectedRange(); |
| 966 return NSMaxRange(selection) == GetTextLength(); | 969 return NSMaxRange(selection) == GetTextLength(); |
| 967 } | 970 } |
| OLD | NEW |