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

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

Issue 194056: Fix text and selection's save/restore issue of omnibox when displaying tempor... (Closed) Base URL: svn://svn.chromium.org/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
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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } else { 444 } else {
445 SetText(GetText()); 445 SetText(GetText());
446 } 446 }
447 } 447 }
448 448
449 void AutocompleteEditViewMac::OnTemporaryTextMaybeChanged( 449 void AutocompleteEditViewMac::OnTemporaryTextMaybeChanged(
450 const std::wstring& display_text, bool save_original_selection) { 450 const std::wstring& display_text, bool save_original_selection) {
451 // TODO(shess): I believe this is for when the user arrows around 451 // TODO(shess): I believe this is for when the user arrows around
452 // the popup, will be restored if they hit escape. Figure out if 452 // the popup, will be restored if they hit escape. Figure out if
453 // that is for certain it. 453 // that is for certain it.
454 if (save_original_selection) { 454 if (save_original_selection)
455 saved_temporary_selection_ = GetSelectedRange(); 455 saved_temporary_selection_ = GetSelectedRange();
456 saved_temporary_text_ = GetText();
457 }
458 456
459 SetWindowTextAndCaretPos(display_text, display_text.size()); 457 SetWindowTextAndCaretPos(display_text, display_text.size());
460 controller_->OnChanged(); 458 controller_->OnChanged();
461 } 459 }
462 460
463 bool AutocompleteEditViewMac::OnInlineAutocompleteTextMaybeChanged( 461 bool AutocompleteEditViewMac::OnInlineAutocompleteTextMaybeChanged(
464 const std::wstring& display_text, size_t user_text_length) { 462 const std::wstring& display_text, size_t user_text_length) {
465 // TODO(shess): Make sure that this actually works. The round trip 463 // TODO(shess): Make sure that this actually works. The round trip
466 // to native form and back may mean that it's the same but not the 464 // to native form and back may mean that it's the same but not the
467 // same. 465 // same.
468 if (display_text == GetText()) { 466 if (display_text == GetText()) {
469 return false; 467 return false;
470 } 468 }
471 469
472 DCHECK_LE(user_text_length, display_text.size()); 470 DCHECK_LE(user_text_length, display_text.size());
473 const NSRange range = NSMakeRange(user_text_length, display_text.size()); 471 const NSRange range = NSMakeRange(user_text_length, display_text.size());
474 SetTextAndSelectedRange(display_text, range); 472 SetTextAndSelectedRange(display_text, range);
475 controller_->OnChanged(); 473 controller_->OnChanged();
476 474
477 return true; 475 return true;
478 } 476 }
479 477
480 void AutocompleteEditViewMac::OnRevertTemporaryText() { 478 void AutocompleteEditViewMac::OnRevertTemporaryText() {
481 SetTextAndSelectedRange(saved_temporary_text_, saved_temporary_selection_); 479 SetSelectedRange(saved_temporary_selection_);
482 saved_temporary_text_.clear();
483 } 480 }
484 481
485 bool AutocompleteEditViewMac::IsFirstResponder() const { 482 bool AutocompleteEditViewMac::IsFirstResponder() const {
486 return [field_ currentEditor] != nil ? true : false; 483 return [field_ currentEditor] != nil ? true : false;
487 } 484 }
488 485
489 void AutocompleteEditViewMac::OnBeforePossibleChange() { 486 void AutocompleteEditViewMac::OnBeforePossibleChange() {
490 // We should only arrive here when the field is focussed. 487 // We should only arrive here when the field is focussed.
491 DCHECK(IsFirstResponder()); 488 DCHECK(IsFirstResponder());
492 489
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 // prepended and ".com" appended. This calls down to 844 // prepended and ".com" appended. This calls down to
848 // AutocompleteEditModel::OnControlKeyChanged() so that it can change 845 // AutocompleteEditModel::OnControlKeyChanged() so that it can change
849 // the popup to reflect this. See autocomplete_edit.cc 846 // the popup to reflect this. See autocomplete_edit.cc
850 // OnControlKeyChanged() and OnAfterPossibleChange(). 847 // OnControlKeyChanged() and OnAfterPossibleChange().
851 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { 848 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent {
852 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; 849 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0;
853 edit_view_->OnControlKeyChanged(controlFlag); 850 edit_view_->OnControlKeyChanged(controlFlag);
854 } 851 }
855 852
856 @end 853 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698