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

Side by Side 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: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/animation/ink_drop_host_view.h" 5 #include "ui/views/animation/ink_drop_host_view.h"
6 6
7 #include "ui/events/event.h" 7 #include "ui/events/event.h"
8 #include "ui/events/scoped_target_handler.h" 8 #include "ui/events/scoped_target_handler.h"
9 #include "ui/gfx/color_palette.h" 9 #include "ui/gfx/color_palette.h"
10 #include "ui/gfx/geometry/size_conversions.h" 10 #include "ui/gfx/geometry/size_conversions.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 // static 36 // static
37 const int InkDropHostView::kInkDropSmallCornerRadius = 2; 37 const int InkDropHostView::kInkDropSmallCornerRadius = 2;
38 38
39 // An EventHandler that is guaranteed to be invoked and is not prone to 39 // An EventHandler that is guaranteed to be invoked and is not prone to
40 // InkDropHostView descendents who do not call 40 // InkDropHostView descendents who do not call
41 // InkDropHostView::OnGestureEvent(). 41 // InkDropHostView::OnGestureEvent().
42 // Only one instance of this class can exist at any given time. Make sure to
43 // delete the old one, if any, *before* instantiating a new one.
sadrul 2016/06/26 03:51:31 You mean only one instance can exist *for a partic
mohsen 2016/06/27 18:59:10 Right. Updated the comment.
42 // 44 //
43 // TODO(bruthig): Consider getting rid of this class. 45 // TODO(bruthig): Consider getting rid of this class.
44 class InkDropHostView::InkDropGestureHandler : public ui::EventHandler { 46 class InkDropHostView::InkDropGestureHandler : public ui::EventHandler {
45 public: 47 public:
46 InkDropGestureHandler(InkDropHostView* host_view, InkDrop* ink_drop) 48 InkDropGestureHandler(InkDropHostView* host_view, InkDrop* ink_drop)
47 : target_handler_(new ui::ScopedTargetHandler(host_view, this)), 49 : target_handler_(new ui::ScopedTargetHandler(host_view, this)),
48 host_view_(host_view), 50 host_view_(host_view),
49 ink_drop_(ink_drop) {} 51 ink_drop_(ink_drop) {}
50 52
51 ~InkDropGestureHandler() override {} 53 ~InkDropGestureHandler() override {}
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 SkColor InkDropHostView::GetInkDropBaseColor() const { 216 SkColor InkDropHostView::GetInkDropBaseColor() const {
215 NOTREACHED(); 217 NOTREACHED();
216 return gfx::kPlaceholderColor; 218 return gfx::kPlaceholderColor;
217 } 219 }
218 220
219 bool InkDropHostView::ShouldShowInkDropForFocus() const { 221 bool InkDropHostView::ShouldShowInkDropForFocus() const {
220 return false; 222 return false;
221 } 223 }
222 224
223 void InkDropHostView::SetHasInkDrop(bool has_an_ink_drop) { 225 void InkDropHostView::SetHasInkDrop(bool has_an_ink_drop) {
226 gesture_handler_.reset();
224 if (has_an_ink_drop) { 227 if (has_an_ink_drop) {
225 ink_drop_.reset(new InkDropImpl(this)); 228 ink_drop_.reset(new InkDropImpl(this));
226 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get())); 229 gesture_handler_.reset(new InkDropGestureHandler(this, ink_drop_.get()));
sadrul 2016/06/26 03:51:31 Add a comment here that any existing InkDropGestur
mohsen 2016/06/27 18:59:10 Yes, Added SetInkDrop().
227 } else { 230 } else {
228 gesture_handler_.reset();
229 ink_drop_.reset(new InkDropStub()); 231 ink_drop_.reset(new InkDropStub());
230 } 232 }
231 } 233 }
232 234
233 } // namespace views 235 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698