From 7b398483f56fcbe4a84dc3eee6f80d1ec96c925a Mon Sep 17 00:00:00 2001
From: "ben@chromium.org"
 <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Thu, 3 Feb 2011 20:29:13 +0000
Subject: Switch to using FocusEvent for focus change notifications.

I also removed ViewStorage usage for now. Jay described generally the kind of cases where this might be useful but I have not encountered them yet in my current testing. I will reintroduce this code if it becomes necessary.

Note that I have not yet verified that this works. That comes next.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6368083

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73655 0039d316-1c4b-4281-b951-d872f2087c98
---
 ui/views/events/event.cc       |  2 +-
 ui/views/events/event.h        |  3 ++-
 ui/views/events/focus_event.cc | 19 ++++++++++++++++
 ui/views/events/focus_event.h  | 51 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 ui/views/events/focus_event.cc
 create mode 100644 ui/views/events/focus_event.h

(limited to 'ui/views/events')

diff --git a/ui/views/events/event.cc b/ui/views/events/event.cc
index f1d04b9..a6da13b 100644
--- a/ui/views/events/event.cc
+++ b/ui/views/events/event.cc
@@ -54,4 +54,4 @@ MouseEvent::MouseEvent(const MouseEvent& other, View* source, View* target)
     : LocatedEvent(other, source, target) {
 }
 
-}  // namespace views
+}  // namespace ui
diff --git a/ui/views/events/event.h b/ui/views/events/event.h
index d8ad17f..c3cbce0 100644
--- a/ui/views/events/event.h
+++ b/ui/views/events/event.h
@@ -30,7 +30,8 @@ class Event {
                    ET_KEY_PRESSED,
                    ET_KEY_RELEASED,
                    ET_MOUSEWHEEL,
-                   ET_DROP_TARGET_EVENT };
+                   ET_DROP_TARGET_EVENT,
+                   ET_FOCUS_CHANGE };
 
   // Event flags currently supported.  Although this is a "views"
   // file, this header is used on non-views platforms (e.g. OSX).  For
diff --git a/ui/views/events/focus_event.cc b/ui/views/events/focus_event.cc
new file mode 100644
index 0000000..4a05999
--- /dev/null
+++ b/ui/views/events/focus_event.cc
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 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.
+
+#include "ui/views/events/focus_event.h"
+
+namespace ui {
+
+////////////////////////////////////////////////////////////////////////////////
+// FocusEvent, public:
+
+FocusEvent::FocusEvent(Type type, Reason reason, TraversalDirection direction)
+    : type_(type),
+      reason_(reason),
+      direction_(direction),
+      Event(ET_FOCUS_CHANGE, 0) {
+}
+
+}  // namespace ui
diff --git a/ui/views/events/focus_event.h b/ui/views/events/focus_event.h
new file mode 100644
index 0000000..377c3f7
--- /dev/null
+++ b/ui/views/events/focus_event.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 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_VIEWS_EVENTS_FOCUS_EVENT_H_
+#define UI_VIEWS_EVENTS_FOCUS_EVENT_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "ui/views/events/event.h"
+
+namespace ui {
+
+class FocusEvent : public Event {
+ public:
+  enum Type {
+    TYPE_FOCUS_IN,      // Target View did gain focus
+    TYPE_FOCUS_OUT      // Target View will lose focus
+  };
+
+  enum Reason {
+    REASON_TRAVERSAL,   // Focus change occurred because of a tab-traversal
+    REASON_RESTORE,     // Focus was restored (e.g. window activation).
+    REASON_DIRECT       // Focus was directly set (e.g. with mouse click).
+  };
+
+  enum TraversalDirection {
+    DIRECTION_NONE,
+    DIRECTION_FORWARD,
+    DIRECTION_REVERSE
+  };
+
+  FocusEvent(Type type,
+             Reason reason,
+             TraversalDirection direction);
+
+  Type type() const { return type_; }
+  Reason reason() const { return reason_; }
+  TraversalDirection direction() const { return direction_; }
+
+ private:
+  Type type_;
+  Reason reason_;
+  TraversalDirection direction_;
+
+  DISALLOW_COPY_AND_ASSIGN(FocusEvent);
+};
+
+}  // namespace ui
+
+#endif  // UI_VIEWS_EVENTS_FOCUS_EVENT_H_
-- 
cgit v1.1