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

Unified Diff: ui/views/animation/ink_drop_host_view.cc

Issue 2096003002: Fix crash when InkDropHostView::SetHasInkDrop() is called multiple times (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_host_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_host_view.cc
diff --git a/ui/views/animation/ink_drop_host_view.cc b/ui/views/animation/ink_drop_host_view.cc
index e6b1e424155d41e75056cdf1744fc2e7e2684fcc..cf58f1b5443ee544f3741638b1d8230254de03b9 100644
--- a/ui/views/animation/ink_drop_host_view.cc
+++ b/ui/views/animation/ink_drop_host_view.cc
@@ -38,7 +38,8 @@ const int InkDropHostView::kInkDropSmallCornerRadius = 2;
// An EventHandler that is guaranteed to be invoked and is not prone to
// InkDropHostView descendents who do not call
-// InkDropHostView::OnGestureEvent().
+// InkDropHostView::OnGestureEvent(). Only one instance of this class can exist
+// at any given time for each ink drop host view.
//
// TODO(bruthig): Consider getting rid of this class.
class InkDropHostView::InkDropGestureHandler : public ui::EventHandler {
@@ -50,6 +51,8 @@ class InkDropHostView::InkDropGestureHandler : public ui::EventHandler {
~InkDropGestureHandler() override {}
+ void SetInkDrop(InkDrop* ink_drop) { ink_drop_ = ink_drop; }
+
// ui::EventHandler:
void OnGestureEvent(ui::GestureEvent* event) override {
InkDropState current_ink_drop_state = ink_drop_->GetTargetInkDropState();
@@ -223,7 +226,10 @@ bool InkDropHostView::ShouldShowInkDropForFocus() const {
void InkDropHostView::SetHasInkDrop(bool has_an_ink_drop) {
if (has_an_ink_drop) {
ink_drop_.reset(new InkDropImpl(this));
- gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get()));
+ if (!gesture_handler_)
+ gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get()));
+ else
+ gesture_handler_->SetInkDrop(ink_drop_.get());
} else {
gesture_handler_.reset();
ink_drop_.reset(new InkDropStub());
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_host_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698