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

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

Issue 246009: [Mac] Support undo in the omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | chrome/browser/cocoa/autocomplete_text_field.h » ('j') | 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 8
9 #include "app/clipboard/clipboard.h" 9 #include "app/clipboard/clipboard.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 void AutocompleteEditViewMac::RevertAll() { 350 void AutocompleteEditViewMac::RevertAll() {
351 ClosePopup(); 351 ClosePopup();
352 model_->Revert(); 352 model_->Revert();
353 353
354 // TODO(shess): This should be a no-op, the results from GetText() 354 // TODO(shess): This should be a no-op, the results from GetText()
355 // could only get there via UpdateAndStyleText() in the first place. 355 // could only get there via UpdateAndStyleText() in the first place.
356 // Dig into where this code can be called from and see if this line 356 // Dig into where this code can be called from and see if this line
357 // can be removed. 357 // can be removed.
358 EmphasizeURLComponents(); 358 EmphasizeURLComponents();
359 controller_->OnChanged(); 359 controller_->OnChanged();
360 [field_ clearUndoChain];
360 } 361 }
361 362
362 void AutocompleteEditViewMac::UpdatePopup() { 363 void AutocompleteEditViewMac::UpdatePopup() {
363 model_->SetInputInProgress(true); 364 model_->SetInputInProgress(true);
364 if (!model_->has_focus()) 365 if (!model_->has_focus())
365 return; 366 return;
366 367
367 // TODO(shess): 368 // TODO(shess):
368 // Shouldn't inline autocomplete when the caret/selection isn't at 369 // Shouldn't inline autocomplete when the caret/selection isn't at
369 // the end of the text. 370 // the end of the text.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 void AutocompleteEditViewMac::OnTemporaryTextMaybeChanged( 472 void AutocompleteEditViewMac::OnTemporaryTextMaybeChanged(
472 const std::wstring& display_text, bool save_original_selection) { 473 const std::wstring& display_text, bool save_original_selection) {
473 // TODO(shess): I believe this is for when the user arrows around 474 // TODO(shess): I believe this is for when the user arrows around
474 // the popup, will be restored if they hit escape. Figure out if 475 // the popup, will be restored if they hit escape. Figure out if
475 // that is for certain it. 476 // that is for certain it.
476 if (save_original_selection) 477 if (save_original_selection)
477 saved_temporary_selection_ = GetSelectedRange(); 478 saved_temporary_selection_ = GetSelectedRange();
478 479
479 SetWindowTextAndCaretPos(display_text, display_text.size()); 480 SetWindowTextAndCaretPos(display_text, display_text.size());
480 controller_->OnChanged(); 481 controller_->OnChanged();
482 [field_ clearUndoChain];
481 } 483 }
482 484
483 bool AutocompleteEditViewMac::OnInlineAutocompleteTextMaybeChanged( 485 bool AutocompleteEditViewMac::OnInlineAutocompleteTextMaybeChanged(
484 const std::wstring& display_text, size_t user_text_length) { 486 const std::wstring& display_text, size_t user_text_length) {
485 // TODO(shess): Make sure that this actually works. The round trip 487 // TODO(shess): Make sure that this actually works. The round trip
486 // to native form and back may mean that it's the same but not the 488 // to native form and back may mean that it's the same but not the
487 // same. 489 // same.
488 if (display_text == GetText()) { 490 if (display_text == GetText()) {
489 return false; 491 return false;
490 } 492 }
491 493
492 DCHECK_LE(user_text_length, display_text.size()); 494 DCHECK_LE(user_text_length, display_text.size());
493 const NSRange range = NSMakeRange(user_text_length, display_text.size()); 495 const NSRange range = NSMakeRange(user_text_length, display_text.size());
494 SetTextAndSelectedRange(display_text, range); 496 SetTextAndSelectedRange(display_text, range);
495 controller_->OnChanged(); 497 controller_->OnChanged();
498 [field_ clearUndoChain];
496 499
497 return true; 500 return true;
498 } 501 }
499 502
500 void AutocompleteEditViewMac::OnRevertTemporaryText() { 503 void AutocompleteEditViewMac::OnRevertTemporaryText() {
501 SetSelectedRange(saved_temporary_selection_); 504 SetSelectedRange(saved_temporary_selection_);
502 } 505 }
503 506
504 bool AutocompleteEditViewMac::IsFirstResponder() const { 507 bool AutocompleteEditViewMac::IsFirstResponder() const {
505 return [field_ currentEditor] != nil ? true : false; 508 return [field_ currentEditor] != nil ? true : false;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 // TODO(shess): Figure out where the selection belongs. On GTK, 890 // TODO(shess): Figure out where the selection belongs. On GTK,
888 // it's set to the start of the text. 891 // it's set to the start of the text.
889 } 892 }
890 893
891 // Signal that we've lost focus when the window resigns key. 894 // Signal that we've lost focus when the window resigns key.
892 - (void)windowDidResignKey:(NSNotification*)notification { 895 - (void)windowDidResignKey:(NSNotification*)notification {
893 edit_view_->OnDidResignKey(); 896 edit_view_->OnDidResignKey();
894 } 897 }
895 898
896 @end 899 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698