| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
| 8 #import "base/mac/scoped_objc_class_swizzler.h" | 8 #import "base/mac/scoped_objc_class_swizzler.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "ui/events/event_processor.h" | 10 #include "ui/events/event_processor.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // Implementation of ui::test::EventGeneratorDelegate for Mac. Everything | 217 // Implementation of ui::test::EventGeneratorDelegate for Mac. Everything |
| 218 // defined inline is just a stub. Interesting overrides are defined below the | 218 // defined inline is just a stub. Interesting overrides are defined below the |
| 219 // class. | 219 // class. |
| 220 class EventGeneratorDelegateMac : public ui::EventTarget, | 220 class EventGeneratorDelegateMac : public ui::EventTarget, |
| 221 public ui::EventSource, | 221 public ui::EventSource, |
| 222 public ui::EventProcessor, | 222 public ui::EventProcessor, |
| 223 public ui::EventTargeter, | 223 public ui::EventTargeter, |
| 224 public ui::test::EventGeneratorDelegate { | 224 public ui::test::EventGeneratorDelegate { |
| 225 public: | 225 public: |
| 226 static EventGeneratorDelegateMac* GetInstance() { | 226 static EventGeneratorDelegateMac* GetInstance() { |
| 227 return Singleton<EventGeneratorDelegateMac>::get(); | 227 return base::Singleton<EventGeneratorDelegateMac>::get(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 IMP CurrentEventMethod() { | 230 IMP CurrentEventMethod() { |
| 231 return swizzle_current_event_->GetOriginalImplementation(); | 231 return swizzle_current_event_->GetOriginalImplementation(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 NSWindow* window() { return window_.get(); } | 234 NSWindow* window() { return window_.get(); } |
| 235 ui::test::EventGenerator* owner() { return owner_; } | 235 ui::test::EventGenerator* owner() { return owner_; } |
| 236 | 236 |
| 237 // Overridden from ui::EventTarget: | 237 // Overridden from ui::EventTarget: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 gfx::Point CenterOfWindow(gfx::NativeWindow window) const override; | 278 gfx::Point CenterOfWindow(gfx::NativeWindow window) const override; |
| 279 | 279 |
| 280 void ConvertPointFromTarget(const ui::EventTarget* target, | 280 void ConvertPointFromTarget(const ui::EventTarget* target, |
| 281 gfx::Point* point) const override {} | 281 gfx::Point* point) const override {} |
| 282 void ConvertPointToTarget(const ui::EventTarget* target, | 282 void ConvertPointToTarget(const ui::EventTarget* target, |
| 283 gfx::Point* point) const override {} | 283 gfx::Point* point) const override {} |
| 284 void ConvertPointFromHost(const ui::EventTarget* hosted_target, | 284 void ConvertPointFromHost(const ui::EventTarget* hosted_target, |
| 285 gfx::Point* point) const override {} | 285 gfx::Point* point) const override {} |
| 286 | 286 |
| 287 private: | 287 private: |
| 288 friend struct DefaultSingletonTraits<EventGeneratorDelegateMac>; | 288 friend struct base::DefaultSingletonTraits<EventGeneratorDelegateMac>; |
| 289 | 289 |
| 290 EventGeneratorDelegateMac(); | 290 EventGeneratorDelegateMac(); |
| 291 ~EventGeneratorDelegateMac() override; | 291 ~EventGeneratorDelegateMac() override; |
| 292 | 292 |
| 293 ui::test::EventGenerator* owner_; | 293 ui::test::EventGenerator* owner_; |
| 294 base::scoped_nsobject<NSWindow> window_; | 294 base::scoped_nsobject<NSWindow> window_; |
| 295 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzle_pressed_; | 295 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzle_pressed_; |
| 296 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzle_location_; | 296 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzle_location_; |
| 297 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzle_current_event_; | 297 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzle_current_event_; |
| 298 base::scoped_nsobject<NSMenu> fake_menu_; | 298 base::scoped_nsobject<NSMenu> fake_menu_; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 - (NSEvent*)currentEvent { | 473 - (NSEvent*)currentEvent { |
| 474 if (g_current_event) | 474 if (g_current_event) |
| 475 return g_current_event; | 475 return g_current_event; |
| 476 | 476 |
| 477 // Find the original implementation and invoke it. | 477 // Find the original implementation and invoke it. |
| 478 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); | 478 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); |
| 479 return original(self, _cmd); | 479 return original(self, _cmd); |
| 480 } | 480 } |
| 481 | 481 |
| 482 @end | 482 @end |
| OLD | NEW |