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

Unified Diff: ui/events/scoped_target_handler.h

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor ink drop animations (simplify MenuButton) Created 5 years, 1 month 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
Index: ui/events/scoped_target_handler.h
diff --git a/ui/events/scoped_target_handler.h b/ui/events/scoped_target_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..48913b1c8e80e10813999156be1b862805740845
--- /dev/null
+++ b/ui/events/scoped_target_handler.h
@@ -0,0 +1,38 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_SCOPED_TARGET_HANDLER_H_
+#define UI_EVENTS_SCOPED_TARGET_HANDLER_H_
+
+#include "base/macros.h"
+#include "ui/events/events_export.h"
+
+namespace ui {
+
+class EventHandler;
+class EventTarget;
+
bruthig 2015/11/19 16:49:53 Some class level documentation would be useful her
varkha 2015/11/19 23:34:35 Done.
+class EVENTS_EXPORT ScopedTargetHandler {
bruthig 2015/11/19 16:49:53 I envisioned that ScopedTargetHandler (or general
varkha 2015/11/19 23:34:35 Done.
+ public:
+ ScopedTargetHandler(EventTarget* target, EventHandler* handler);
+ virtual ~ScopedTargetHandler();
+
+ EventHandler* original_target_handler() { return original_handler_; }
+
+ private:
+ // An EventTarget that is used to set and restore |original_handler_|.
+ EventTarget* target_;
+
+ // New handler that is set on |target_| for the lifetime of |this|.
+ EventHandler* handler_;
+
+ // An EventHandler that gets restored on |target_| when |this| is destroyed.
+ EventHandler* original_handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_SCOPED_TARGET_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698