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

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 1494433003: Fixes a crash when InkDropDelegate gets destroyed after its InkDropHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes a crash when InkDropDelegate gets destroyed after its InkDropHost (delegate owned by a leaf c… Created 5 years 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
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/views.gyp » ('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) 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/button/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 !strcmp(classname, LabelButton::kViewClassName) || 49 !strcmp(classname, LabelButton::kViewClassName) ||
50 !strcmp(classname, RadioButton::kViewClassName) || 50 !strcmp(classname, RadioButton::kViewClassName) ||
51 !strcmp(classname, MenuButton::kViewClassName)) { 51 !strcmp(classname, MenuButton::kViewClassName)) {
52 return static_cast<CustomButton*>(view); 52 return static_cast<CustomButton*>(view);
53 } 53 }
54 } 54 }
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 CustomButton::~CustomButton() { 58 CustomButton::~CustomButton() {
59 // InkDropDelegate needs to be destroyed by now since it may need to call
60 // methods on |this| via InkDropHost.
61 DCHECK(!ink_drop_delegate_);
59 } 62 }
60 63
61 void CustomButton::SetState(ButtonState state) { 64 void CustomButton::SetState(ButtonState state) {
62 if (state == state_) 65 if (state == state_)
63 return; 66 return;
64 67
65 if (animate_on_state_change_ && 68 if (animate_on_state_change_ &&
66 (!is_throbbing_ || !hover_animation_->is_animating())) { 69 (!is_throbbing_ || !hover_animation_->is_animating())) {
67 is_throbbing_ = false; 70 is_throbbing_ = false;
68 if ((state_ == STATE_HOVERED) && (state == STATE_NORMAL)) { 71 if ((state_ == STATE_HOVERED) && (state == STATE_NORMAL)) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 //////////////////////////////////////////////////////////////////////////////// 334 ////////////////////////////////////////////////////////////////////////////////
332 // CustomButton, protected: 335 // CustomButton, protected:
333 336
334 CustomButton::CustomButton(ButtonListener* listener) 337 CustomButton::CustomButton(ButtonListener* listener)
335 : Button(listener), 338 : Button(listener),
336 state_(STATE_NORMAL), 339 state_(STATE_NORMAL),
337 animate_on_state_change_(true), 340 animate_on_state_change_(true),
338 is_throbbing_(false), 341 is_throbbing_(false),
339 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), 342 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON),
340 request_focus_on_press_(true), 343 request_focus_on_press_(true),
344 ink_drop_delegate_(nullptr),
341 notify_action_(NOTIFY_ON_RELEASE) { 345 notify_action_(NOTIFY_ON_RELEASE) {
342 hover_animation_.reset(new gfx::ThrobAnimation(this)); 346 hover_animation_.reset(new gfx::ThrobAnimation(this));
343 hover_animation_->SetSlideDuration(kHoverFadeDurationMs); 347 hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
344 } 348 }
345 349
346 void CustomButton::StateChanged() { 350 void CustomButton::StateChanged() {
347 } 351 }
348 352
349 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { 353 bool CustomButton::IsTriggerableEvent(const ui::Event& event) {
350 return event.type() == ui::ET_GESTURE_TAP_DOWN || 354 return event.type() == ui::ET_GESTURE_TAP_DOWN ||
(...skipping 23 matching lines...) Expand all
374 aura::client::GetCaptureClient(root_window); 378 aura::client::GetCaptureClient(root_window);
375 aura::Window* capture_window = 379 aura::Window* capture_window =
376 capture_client ? capture_client->GetGlobalCaptureWindow() : nullptr; 380 capture_client ? capture_client->GetGlobalCaptureWindow() : nullptr;
377 check_mouse_position = !capture_window || capture_window == root_window; 381 check_mouse_position = !capture_window || capture_window == root_window;
378 } 382 }
379 #endif 383 #endif
380 384
381 return check_mouse_position && IsMouseHovered(); 385 return check_mouse_position && IsMouseHovered();
382 } 386 }
383 387
384 void CustomButton::SetInkDropDelegate(
385 scoped_ptr<InkDropDelegate> ink_drop_delegate) {
386 ink_drop_delegate_ = ink_drop_delegate.Pass();
387 }
388
389 //////////////////////////////////////////////////////////////////////////////// 388 ////////////////////////////////////////////////////////////////////////////////
390 // CustomButton, View overrides (protected): 389 // CustomButton, View overrides (protected):
391 390
392 void CustomButton::OnBoundsChanged(const gfx::Rect& previous_bounds) { 391 void CustomButton::OnBoundsChanged(const gfx::Rect& previous_bounds) {
393 Button::OnBoundsChanged(previous_bounds); 392 Button::OnBoundsChanged(previous_bounds);
394 if (ink_drop_delegate_) 393 if (ink_drop_delegate_)
395 ink_drop_delegate_->OnLayout(); 394 ink_drop_delegate_->OnLayout();
396 } 395 }
397 396
398 void CustomButton::ViewHierarchyChanged( 397 void CustomButton::ViewHierarchyChanged(
(...skipping 11 matching lines...) Expand all
410 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); 409 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget();
411 } 410 }
412 411
413 bool CustomButton::FocusInChildWidget() const { 412 bool CustomButton::FocusInChildWidget() const {
414 return GetWidget() && 413 return GetWidget() &&
415 GetWidget()->GetRootView()->Contains( 414 GetWidget()->GetRootView()->Contains(
416 GetFocusManager()->GetFocusedView()); 415 GetFocusManager()->GetFocusedView());
417 } 416 }
418 417
419 } // namespace views 418 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698