| OLD | NEW |
| 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 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" | 5 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // Ctrl-Alt- or Ctrl-Q). Making this generally efficient would | 255 // Ctrl-Alt- or Ctrl-Q). Making this generally efficient would |
| 256 // probably be a loss, since the input always seems to be a single | 256 // probably be a loss, since the input always seems to be a single |
| 257 // character. | 257 // character. |
| 258 NSRange range = [aString rangeOfCharacterFromSet:forbiddenCharacters_]; | 258 NSRange range = [aString rangeOfCharacterFromSet:forbiddenCharacters_]; |
| 259 while (range.location != NSNotFound) { | 259 while (range.location != NSNotFound) { |
| 260 aString = [aString stringByReplacingCharactersInRange:range withString:@""]; | 260 aString = [aString stringByReplacingCharactersInRange:range withString:@""]; |
| 261 range = [aString rangeOfCharacterFromSet:forbiddenCharacters_]; | 261 range = [aString rangeOfCharacterFromSet:forbiddenCharacters_]; |
| 262 } | 262 } |
| 263 DCHECK_EQ(range.length, 0U); | 263 DCHECK_EQ(range.length, 0U); |
| 264 | 264 |
| 265 // TODO(shess): Beep on empty? I hate beeps, though. | |
| 266 // NOTE: If |aString| is empty, this intentionally replaces the | 265 // NOTE: If |aString| is empty, this intentionally replaces the |
| 267 // selection with empty. This seems consistent with the case where | 266 // selection with empty. This seems consistent with the case where |
| 268 // the input contained a mixture of characters and the string ended | 267 // the input contained a mixture of characters and the string ended |
| 269 // up not empty. | 268 // up not empty. |
| 270 [super insertText:aString]; | 269 [super insertText:aString]; |
| 271 } | 270 } |
| 272 | 271 |
| 273 - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange { | 272 - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange { |
| 274 [super setMarkedText:aString selectedRange:selRange]; | 273 [super setMarkedText:aString selectedRange:selRange]; |
| 275 | 274 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 DCHECK(textStorage); | 308 DCHECK(textStorage); |
| 310 [textStorage setAttributedString:aString]; | 309 [textStorage setAttributedString:aString]; |
| 311 | 310 |
| 312 // The text has been changed programmatically. The observer should know | 311 // The text has been changed programmatically. The observer should know |
| 313 // this change, so setting |textChangedByKeyEvents_| to NO to | 312 // this change, so setting |textChangedByKeyEvents_| to NO to |
| 314 // prevent its OnDidChange() method from being called unnecessarily. | 313 // prevent its OnDidChange() method from being called unnecessarily. |
| 315 textChangedByKeyEvents_ = NO; | 314 textChangedByKeyEvents_ = NO; |
| 316 } | 315 } |
| 317 | 316 |
| 318 @end | 317 @end |
| OLD | NEW |