| 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 #include <stddef.h> | 6 #include <stddef.h> |
| 7 | 7 |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "base/mac/scoped_objc_class_swizzler.h" | 9 #import "base/mac/scoped_objc_class_swizzler.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 EmulateSendEvent(window_, ns_event); | 375 EmulateSendEvent(window_, ns_event); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void EventGeneratorDelegateMac::OnTouchEvent(ui::TouchEvent* event) { | 378 void EventGeneratorDelegateMac::OnTouchEvent(ui::TouchEvent* event) { |
| 379 NOTREACHED() << "Touchscreen events not supported on Chrome Mac."; | 379 NOTREACHED() << "Touchscreen events not supported on Chrome Mac."; |
| 380 } | 380 } |
| 381 | 381 |
| 382 void EventGeneratorDelegateMac::SetContext(ui::test::EventGenerator* owner, | 382 void EventGeneratorDelegateMac::SetContext(ui::test::EventGenerator* owner, |
| 383 gfx::NativeWindow root_window, | 383 gfx::NativeWindow root_window, |
| 384 gfx::NativeWindow window) { | 384 gfx::NativeWindow window) { |
| 385 // Mac doesn't use a |root_window|. Assume that if a single-argument |
| 386 // constructor was used, it should be the actual |window|. |
| 387 if (!window) |
| 388 window = root_window; |
| 389 |
| 385 swizzle_pressed_.reset(); | 390 swizzle_pressed_.reset(); |
| 386 swizzle_location_.reset(); | 391 swizzle_location_.reset(); |
| 387 swizzle_current_event_.reset(); | 392 swizzle_current_event_.reset(); |
| 388 owner_ = owner; | 393 owner_ = owner; |
| 389 | 394 |
| 390 // Retain the NSWindow (note it can be nil). This matches Cocoa's tendency to | 395 // Retain the NSWindow (note it can be nil). This matches Cocoa's tendency to |
| 391 // have autoreleased objects, or objects still in the event queue, that | 396 // have autoreleased objects, or objects still in the event queue, that |
| 392 // reference the NSWindow. | 397 // reference the NSWindow. |
| 393 window_.reset([window retain]); | 398 window_.reset([window retain]); |
| 394 | 399 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 - (NSEvent*)currentEvent { | 489 - (NSEvent*)currentEvent { |
| 485 if (g_current_event) | 490 if (g_current_event) |
| 486 return g_current_event; | 491 return g_current_event; |
| 487 | 492 |
| 488 // Find the original implementation and invoke it. | 493 // Find the original implementation and invoke it. |
| 489 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); | 494 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); |
| 490 return original(self, _cmd); | 495 return original(self, _cmd); |
| 491 } | 496 } |
| 492 | 497 |
| 493 @end | 498 @end |
| OLD | NEW |