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

Side by Side Diff: ui/base/test/ui_controls_mac.mm

Issue 1777653002: Prepare ui/ module for compilation with OS X 10.7 deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More compile errors. Created 4 years, 9 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 | « ui/base/layout_mac.mm ('k') | ui/events/cocoa/events_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/test/ui_controls.h" 5 #include "ui/base/test/ui_controls.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "ui/base/cocoa/cocoa_base_utils.h"
13 #include "ui/events/keycodes/keyboard_code_conversion_mac.h" 14 #include "ui/events/keycodes/keyboard_code_conversion_mac.h"
14 #import "ui/events/test/cocoa_test_event_utils.h" 15 #import "ui/events/test/cocoa_test_event_utils.h"
15 16
16 // Implementation details: We use [NSApplication sendEvent:] instead 17 // Implementation details: We use [NSApplication sendEvent:] instead
17 // of [NSApplication postEvent:atStart:] so that the event gets sent 18 // of [NSApplication postEvent:atStart:] so that the event gets sent
18 // immediately. This lets us run the post-event task right 19 // immediately. This lets us run the post-event task right
19 // immediately as well. Unfortunately I cannot subclass NSEvent (it's 20 // immediately as well. Unfortunately I cannot subclass NSEvent (it's
20 // probably a class cluster) to allow other easy answers. For 21 // probably a class cluster) to allow other easy answers. For
21 // example, if I could subclass NSEvent, I could run the Task in it's 22 // example, if I could subclass NSEvent, I could run the Task in it's
22 // dealloc routine (which necessarily happens after the event is 23 // dealloc routine (which necessarily happens after the event is
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { 236 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) {
236 CHECK(g_ui_controls_enabled); 237 CHECK(g_ui_controls_enabled);
237 CGFloat screenHeight = 238 CGFloat screenHeight =
238 [[[NSScreen screens] firstObject] frame].size.height; 239 [[[NSScreen screens] firstObject] frame].size.height;
239 g_mouse_location = NSMakePoint(x, screenHeight - y); // flip! 240 g_mouse_location = NSMakePoint(x, screenHeight - y); // flip!
240 241
241 NSWindow* window = WindowAtCurrentMouseLocation(); 242 NSWindow* window = WindowAtCurrentMouseLocation();
242 243
243 NSPoint pointInWindow = g_mouse_location; 244 NSPoint pointInWindow = g_mouse_location;
244 if (window) 245 if (window)
245 pointInWindow = [window convertScreenToBase:pointInWindow]; 246 pointInWindow = ui::ConvertPointFromScreenToWindow(window, pointInWindow);
246 NSTimeInterval timestamp = TimeIntervalSinceSystemStartup(); 247 NSTimeInterval timestamp = TimeIntervalSinceSystemStartup();
247 248
248 NSEvent* event = 249 NSEvent* event =
249 [NSEvent mouseEventWithType:NSMouseMoved 250 [NSEvent mouseEventWithType:NSMouseMoved
250 location:pointInWindow 251 location:pointInWindow
251 modifierFlags:0 252 modifierFlags:0
252 timestamp:timestamp 253 timestamp:timestamp
253 windowNumber:[window windowNumber] 254 windowNumber:[window windowNumber]
254 context:nil 255 context:nil
255 eventNumber:0 256 eventNumber:0
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 etype = NSRightMouseUp; 298 etype = NSRightMouseUp;
298 } else { 299 } else {
299 etype = NSRightMouseDown; 300 etype = NSRightMouseDown;
300 } 301 }
301 } else { 302 } else {
302 return false; 303 return false;
303 } 304 }
304 NSWindow* window = WindowAtCurrentMouseLocation(); 305 NSWindow* window = WindowAtCurrentMouseLocation();
305 NSPoint pointInWindow = g_mouse_location; 306 NSPoint pointInWindow = g_mouse_location;
306 if (window) 307 if (window)
307 pointInWindow = [window convertScreenToBase:pointInWindow]; 308 pointInWindow = ui::ConvertPointFromScreenToWindow(window, pointInWindow);
308 309
309 NSEvent* event = 310 NSEvent* event =
310 [NSEvent mouseEventWithType:etype 311 [NSEvent mouseEventWithType:etype
311 location:pointInWindow 312 location:pointInWindow
312 modifierFlags:0 313 modifierFlags:0
313 timestamp:TimeIntervalSinceSystemStartup() 314 timestamp:TimeIntervalSinceSystemStartup()
314 windowNumber:[window windowNumber] 315 windowNumber:[window windowNumber]
315 context:nil 316 context:nil
316 eventNumber:0 317 eventNumber:0
317 clickCount:1 318 clickCount:1
(...skipping 16 matching lines...) Expand all
334 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { 335 void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) {
335 base::MessageLoop::current()->PostTask( 336 base::MessageLoop::current()->PostTask(
336 FROM_HERE, base::Bind(&EventQueueWatcher, closure)); 337 FROM_HERE, base::Bind(&EventQueueWatcher, closure));
337 } 338 }
338 339
339 bool IsFullKeyboardAccessEnabled() { 340 bool IsFullKeyboardAccessEnabled() {
340 return [NSApp isFullKeyboardAccessEnabled]; 341 return [NSApp isFullKeyboardAccessEnabled];
341 } 342 }
342 343
343 } // namespace ui_controls 344 } // namespace ui_controls
OLDNEW
« no previous file with comments | « ui/base/layout_mac.mm ('k') | ui/events/cocoa/events_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698