| 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 "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 // and other methods to provide positive knowledge that a delete | 484 // and other methods to provide positive knowledge that a delete |
| 485 // occured, rather than intuiting it from context. Consider whether | 485 // occured, rather than intuiting it from context. Consider whether |
| 486 // that would be a stronger approach. | 486 // that would be a stronger approach. |
| 487 const bool just_deleted_text = | 487 const bool just_deleted_text = |
| 488 (length < text_before_change_.length() && | 488 (length < text_before_change_.length() && |
| 489 new_selection.location <= selection_before_change_.location); | 489 new_selection.location <= selection_before_change_.location); |
| 490 | 490 |
| 491 const bool something_changed = model_->OnAfterPossibleChange(new_text, | 491 const bool something_changed = model_->OnAfterPossibleChange(new_text, |
| 492 selection_differs, text_differs, just_deleted_text, at_end_of_edit); | 492 selection_differs, text_differs, just_deleted_text, at_end_of_edit); |
| 493 | 493 |
| 494 // Restyle if the user changed something. | 494 // Restyle in case the user changed something. |
| 495 // TODO(shess): Does this need to diver deeper to avoid flashing? | 495 // TODO(shess): I believe there are multiple-redraw cases, here. |
| 496 // For instance, if the user types "/" after the hostname, will it | 496 // Linux watches for something_changed && text_differs, but that |
| 497 // show as HostTextColor() for an instant before being replaced by | 497 // fails for us in case you copy the URL and paste the identical URL |
| 498 // BaseTextColor(). This could probably be done by subclassing the | 498 // back (we'll lose the styling). |
| 499 // cell and intercepting draw requests so that we draw the right | 499 EmphasizeURLComponents(); |
| 500 // thing every time. | |
| 501 // NOTE(shess): That kind of thing would also help with when the | |
| 502 // flashing from when the user's typing replaces the selection which | |
| 503 // is then re-created with the new autocomplete results. | |
| 504 if (something_changed) { | |
| 505 // TODO(shess) I believe that this call is needless duplication of | |
| 506 // effort. As best I can tell, something_changed can only be true | |
| 507 // if |model_| called UpdatePopup(), which then updated us. But | |
| 508 // the state involved seems substantial. | |
| 509 EmphasizeURLComponents(); | |
| 510 } | |
| 511 | 500 |
| 512 return something_changed; | 501 return something_changed; |
| 513 } | 502 } |
| 514 | 503 |
| 515 void AutocompleteEditViewMac::OnUpOrDownKeyPressed(bool up, bool by_page) { | 504 void AutocompleteEditViewMac::OnUpOrDownKeyPressed(bool up, bool by_page) { |
| 516 // We should only arrive here when the field is focussed. | 505 // We should only arrive here when the field is focussed. |
| 517 DCHECK(IsFirstResponder()); | 506 DCHECK(IsFirstResponder()); |
| 518 | 507 |
| 519 const int count = by_page ? model_->result().size() : 1; | 508 const int count = by_page ? model_->result().size() : 1; |
| 520 model_->OnUpOrDownKeyPressed(up ? -count : count); | 509 model_->OnUpOrDownKeyPressed(up ? -count : count); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 // TODO(shess): Figure out where the selection belongs. On GTK, | 628 // TODO(shess): Figure out where the selection belongs. On GTK, |
| 640 // it's set to the start of the text. | 629 // it's set to the start of the text. |
| 641 } | 630 } |
| 642 | 631 |
| 643 // Signal that we've lost focus when the window resigns key. | 632 // Signal that we've lost focus when the window resigns key. |
| 644 - (void)windowDidResignKey:(NSNotification*)notification { | 633 - (void)windowDidResignKey:(NSNotification*)notification { |
| 645 edit_view_->OnDidResignKey(); | 634 edit_view_->OnDidResignKey(); |
| 646 } | 635 } |
| 647 | 636 |
| 648 @end | 637 @end |
| OLD | NEW |