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

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

Issue 173343: Reverting 23702. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 #include "app/gfx/font.h" 8 #include "app/gfx/font.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/clipboard.h" 10 #include "base/clipboard.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // One option would seem to be to check for a non-nil field 358 // One option would seem to be to check for a non-nil field
359 // editor, and check it's selected range against its length. 359 // editor, and check it's selected range against its length.
360 model_->StartAutocomplete(false); 360 model_->StartAutocomplete(false);
361 } 361 }
362 362
363 void AutocompleteEditViewMac::ClosePopup() { 363 void AutocompleteEditViewMac::ClosePopup() {
364 popup_view_->GetModel()->StopAutocomplete(); 364 popup_view_->GetModel()->StopAutocomplete();
365 } 365 }
366 366
367 void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { 367 void AutocompleteEditViewMac::SetText(const std::wstring& display_text) {
368 // Exit if an input method is composing text.
369 // NSTextView finishes an ongoing composition when updating the value of an
370 // NSTextField instance. This prevents inputting non-ASCII characters which
371 // need input methods, such as Latin characters, CJK characters, etc.
372 // To prevent updating this NSTextField value while an input method is
373 // composing text, we check whether or not the field editor for this control
374 // has marked text, text being composed by an input method, and return if
375 // the editor has marked text.
376 NSTextView* text_view = static_cast<NSTextView*>([field_ currentEditor]);
377 if (text_view && [text_view hasMarkedText])
378 return;
379
380 NSString* ss = base::SysWideToNSString(display_text); 368 NSString* ss = base::SysWideToNSString(display_text);
381 NSMutableAttributedString* as = 369 NSMutableAttributedString* as =
382 [[[NSMutableAttributedString alloc] initWithString:ss] autorelease]; 370 [[[NSMutableAttributedString alloc] initWithString:ss] autorelease];
383 NSFont* font = ResourceBundle::GetSharedInstance().GetFont( 371 NSFont* font = ResourceBundle::GetSharedInstance().GetFont(
384 ResourceBundle::BaseFont).nativeFont(); 372 ResourceBundle::BaseFont).nativeFont();
385 [as addAttribute:NSFontAttributeName value:font 373 [as addAttribute:NSFontAttributeName value:font
386 range:NSMakeRange(0, [as length])]; 374 range:NSMakeRange(0, [as length])];
387 375
388 url_parse::Parsed parts; 376 url_parse::Parsed parts;
389 AutocompleteInput::Parse(display_text, model_->GetDesiredTLD(), 377 AutocompleteInput::Parse(display_text, model_->GetDesiredTLD(),
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 // prepended and ".com" appended. This calls down to 788 // prepended and ".com" appended. This calls down to
801 // AutocompleteEditModel::OnControlKeyChanged() so that it can change 789 // AutocompleteEditModel::OnControlKeyChanged() so that it can change
802 // the popup to reflect this. See autocomplete_edit.cc 790 // the popup to reflect this. See autocomplete_edit.cc
803 // OnControlKeyChanged() and OnAfterPossibleChange(). 791 // OnControlKeyChanged() and OnAfterPossibleChange().
804 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { 792 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent {
805 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; 793 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0;
806 edit_view_->OnControlKeyChanged(controlFlag); 794 edit_view_->OnControlKeyChanged(controlFlag);
807 } 795 }
808 796
809 @end 797 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698