OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | |
6 | |
7 #import <AppKit/AppKit.h> | 5 #import <AppKit/AppKit.h> |
8 | 6 |
9 #include "base/logging.h" | 7 #include "base/logging.h" |
10 #include "webkit/glue/plugins/plugin_instance.h" | 8 #include "build/build_config.h" |
| 9 #include "webkit/plugins/npapi/plugin_instance.h" |
11 | 10 |
12 // When C++ exceptions are disabled, the C++ library defines |try| and | 11 // When C++ exceptions are disabled, the C++ library defines |try| and |
13 // |catch| so as to allow exception-expecting C++ code to build properly when | 12 // |catch| so as to allow exception-expecting C++ code to build properly when |
14 // language support for exceptions is not present. These macros interfere | 13 // language support for exceptions is not present. These macros interfere |
15 // with the use of |@try| and |@catch| in Objective-C files such as this one. | 14 // with the use of |@try| and |@catch| in Objective-C files such as this one. |
16 // Undefine these macros here, after everything has been #included, since | 15 // Undefine these macros here, after everything has been #included, since |
17 // there will be no C++ uses and only Objective-C uses from this point on. | 16 // there will be no C++ uses and only Objective-C uses from this point on. |
18 #undef try | 17 #undef try |
19 #undef catch | 18 #undef catch |
20 | 19 |
21 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 | 20 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 |
22 @interface NSMenu (SnowLeopardMenuPopUpDeclaration) | 21 @interface NSMenu (SnowLeopardMenuPopUpDeclaration) |
23 - (BOOL)popUpMenuPositioningItem:(NSMenuItem*)item | 22 - (BOOL)popUpMenuPositioningItem:(NSMenuItem*)item |
24 atLocation:(NSPoint)location | 23 atLocation:(NSPoint)location |
25 inView:(NSView*)view; | 24 inView:(NSView*)view; |
26 @end | 25 @end |
27 #endif | 26 #endif |
28 | 27 |
| 28 namespace webkit { |
| 29 namespace npapi { |
| 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 // Returns an autoreleased NSEvent constructed from the given np_event, | 33 // Returns an autoreleased NSEvent constructed from the given np_event, |
32 // targeting the given window. | 34 // targeting the given window. |
33 NSEvent* NSEventForNPCocoaEvent(NPCocoaEvent* np_event, NSWindow* window) { | 35 NSEvent* NSEventForNPCocoaEvent(NPCocoaEvent* np_event, NSWindow* window) { |
34 bool mouse_down = 1; | 36 bool mouse_down = 1; |
35 switch (np_event->type) { | 37 switch (np_event->type) { |
36 case NPCocoaEventMouseDown: | 38 case NPCocoaEventMouseDown: |
37 mouse_down = 1; | 39 mouse_down = 1; |
38 break; | 40 break; |
(...skipping 30 matching lines...) Expand all Loading... |
69 windowNumber:[window windowNumber] | 71 windowNumber:[window windowNumber] |
70 context:[NSGraphicsContext currentContext] | 72 context:[NSGraphicsContext currentContext] |
71 eventNumber:0 | 73 eventNumber:0 |
72 clickCount:click_count | 74 clickCount:click_count |
73 pressure:1.0]; | 75 pressure:1.0]; |
74 return event; | 76 return event; |
75 } | 77 } |
76 | 78 |
77 } // namespace | 79 } // namespace |
78 | 80 |
79 namespace NPAPI { | |
80 | |
81 NPError PluginInstance::PopUpContextMenu(NPMenu* menu) { | 81 NPError PluginInstance::PopUpContextMenu(NPMenu* menu) { |
82 if (!currently_handled_event_) | 82 if (!currently_handled_event_) |
83 return NPERR_GENERIC_ERROR; | 83 return NPERR_GENERIC_ERROR; |
84 | 84 |
85 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); | 85 CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); |
86 NSPoint screen_point = NSMakePoint( | 86 NSPoint screen_point = NSMakePoint( |
87 plugin_origin_.x() + currently_handled_event_->data.mouse.pluginX, | 87 plugin_origin_.x() + currently_handled_event_->data.mouse.pluginX, |
88 plugin_origin_.y() + currently_handled_event_->data.mouse.pluginY); | 88 plugin_origin_.y() + currently_handled_event_->data.mouse.pluginY); |
89 // Plugin offsets are upper-left based, so flip vertically for Cocoa. | 89 // Plugin offsets are upper-left based, so flip vertically for Cocoa. |
90 screen_point.y = main_display_bounds.size.height - screen_point.y; | 90 screen_point.y = main_display_bounds.size.height - screen_point.y; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 [window release]; | 123 [window release]; |
124 } | 124 } |
125 @catch (NSException* e) { | 125 @catch (NSException* e) { |
126 NSLog(@"Caught exception while cleaning up in PopUpContextMenu: %@", e); | 126 NSLog(@"Caught exception while cleaning up in PopUpContextMenu: %@", e); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 return return_val; | 130 return return_val; |
131 } | 131 } |
132 | 132 |
133 } // namespace NPAPI | 133 } // namespace npapi |
| 134 } // namespace webkit |
OLD | NEW |