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 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
6 | 6 |
7 #include "app/gfx/font.h" | 7 #include "app/gfx/font.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/clipboard.h" | 9 #include "base/clipboard.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 // One option would seem to be to check for a non-nil field | 355 // One option would seem to be to check for a non-nil field |
356 // editor, and check it's selected range against its length. | 356 // editor, and check it's selected range against its length. |
357 model_->StartAutocomplete(false); | 357 model_->StartAutocomplete(false); |
358 } | 358 } |
359 | 359 |
360 void AutocompleteEditViewMac::ClosePopup() { | 360 void AutocompleteEditViewMac::ClosePopup() { |
361 popup_view_->GetModel()->StopAutocomplete(); | 361 popup_view_->GetModel()->StopAutocomplete(); |
362 } | 362 } |
363 | 363 |
364 void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { | 364 void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { |
365 // Exit if an input method is composing text. | |
rohitrao (ping after 24h)
2009/08/18 21:42:35
Is this guaranteed to be called again once the tex
Hironori Bono
2009/08/19 05:23:38
Yes. This function is called when this NSTextField
| |
366 // NSTextView finishes an ongoing composition when updating the value of an | |
367 // NSTextField instance. This prevents inputting non-ASCII characters which | |
368 // need input methods, such as Latin characters, CJK characters, etc. | |
369 // To prevent updating this NSTextField value while an input method is | |
370 // composing text, we check whether or not the field editor for this control | |
371 // has marked text, text being composed by an input method, and return if | |
372 // the editor has marked text. | |
373 NSTextView* text_view = static_cast<NSTextView*>([field_ currentEditor]); | |
374 if (text_view && [text_view hasMarkedText]) | |
375 return; | |
376 | |
365 NSString* ss = base::SysWideToNSString(display_text); | 377 NSString* ss = base::SysWideToNSString(display_text); |
366 NSMutableAttributedString* as = | 378 NSMutableAttributedString* as = |
367 [[[NSMutableAttributedString alloc] initWithString:ss] autorelease]; | 379 [[[NSMutableAttributedString alloc] initWithString:ss] autorelease]; |
368 NSFont* font = ResourceBundle::GetSharedInstance().GetFont( | 380 NSFont* font = ResourceBundle::GetSharedInstance().GetFont( |
369 ResourceBundle::BaseFont).nativeFont(); | 381 ResourceBundle::BaseFont).nativeFont(); |
370 [as addAttribute:NSFontAttributeName value:font | 382 [as addAttribute:NSFontAttributeName value:font |
371 range:NSMakeRange(0, [as length])]; | 383 range:NSMakeRange(0, [as length])]; |
372 | 384 |
373 url_parse::Parsed parts; | 385 url_parse::Parsed parts; |
374 AutocompleteInput::Parse(display_text, model_->GetDesiredTLD(), | 386 AutocompleteInput::Parse(display_text, model_->GetDesiredTLD(), |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 // prepended and ".com" appended. This calls down to | 761 // prepended and ".com" appended. This calls down to |
750 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 762 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
751 // the popup to reflect this. See autocomplete_edit.cc | 763 // the popup to reflect this. See autocomplete_edit.cc |
752 // OnControlKeyChanged() and OnAfterPossibleChange(). | 764 // OnControlKeyChanged() and OnAfterPossibleChange(). |
753 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 765 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
754 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 766 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
755 edit_view_->OnControlKeyChanged(controlFlag); | 767 edit_view_->OnControlKeyChanged(controlFlag); |
756 } | 768 } |
757 | 769 |
758 @end | 770 @end |
OLD | NEW |