 Chromium Code Reviews
 Chromium Code Reviews Issue 104573003:
  Make ComboboxListener work around being deleted from OnSelectedIndexChanged().  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 104573003:
  Make ComboboxListener work around being deleted from OnSelectedIndexChanged().  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" | 
| 6 | 6 | 
| 7 #include "base/logging.h" | 7 #include "base/logging.h" | 
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" | 
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" | 
| 10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" | 
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 dropdown_open_ = false; | 461 dropdown_open_ = false; | 
| 462 closed_time_ = base::Time::Now(); | 462 closed_time_ = base::Time::Now(); | 
| 463 | 463 | 
| 464 // Need to explicitly clear mouse handler so that events get sent | 464 // Need to explicitly clear mouse handler so that events get sent | 
| 465 // properly after the menu finishes running. If we don't do this, then | 465 // properly after the menu finishes running. If we don't do this, then | 
| 466 // the first click to other parts of the UI is eaten. | 466 // the first click to other parts of the UI is eaten. | 
| 467 SetMouseHandler(NULL); | 467 SetMouseHandler(NULL); | 
| 468 } | 468 } | 
| 469 | 469 | 
| 470 void Combobox::OnSelectionChanged() { | 470 void Combobox::OnSelectionChanged() { | 
| 471 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_VALUE_CHANGED, false); | |
| 472 SchedulePaint(); | |
| 471 if (listener_) | 473 if (listener_) | 
| 472 listener_->OnSelectedIndexChanged(this); | 474 listener_->OnSelectedIndexChanged(this); | 
| 473 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_VALUE_CHANGED, false); | |
| 474 SchedulePaint(); | |
| 475 } | 475 } | 
| 
sky
2013/12/05 04:07:30
Add a comment here that this may be deleted.
 
Dan Beam
2013/12/05 17:05:33
Done.
 | |
| 476 | 476 | 
| 477 int Combobox::MenuCommandToIndex(int menu_command_id) const { | 477 int Combobox::MenuCommandToIndex(int menu_command_id) const { | 
| 478 // (note that the id received is offset by kFirstMenuItemId) | 478 // (note that the id received is offset by kFirstMenuItemId) | 
| 479 // Revert menu ID offset to map back to combobox model. | 479 // Revert menu ID offset to map back to combobox model. | 
| 480 int index = menu_command_id - kFirstMenuItemId; | 480 int index = menu_command_id - kFirstMenuItemId; | 
| 481 DCHECK_LT(index, model()->GetItemCount()); | 481 DCHECK_LT(index, model()->GetItemCount()); | 
| 482 return index; | 482 return index; | 
| 483 } | 483 } | 
| 484 | 484 | 
| 485 } // namespace views | 485 } // namespace views | 
| OLD | NEW |