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

Unified Diff: webkit/glue/webmenurunner_mac.mm

Issue 9703067: mac: Move EventWithMenuAction() to the only file where it's called. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webmenurunner_mac.h ('k') | webkit/tools/test_shell/mac/test_webview_delegate.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webmenurunner_mac.mm
diff --git a/webkit/glue/webmenurunner_mac.mm b/webkit/glue/webmenurunner_mac.mm
index 01d366e2dcd658cf2464d834da23873ed6c9ac35..2e0f8f1765b0eacf1949f7aab35a3e64a49d3f9f 100644
--- a/webkit/glue/webmenurunner_mac.mm
+++ b/webkit/glue/webmenurunner_mac.mm
@@ -166,61 +166,3 @@ static NSString* NSWritingDirectionAttributeName = @"NSWritingDirection";
}
@end // WebMenuRunner
-
-namespace webkit_glue {
-
-// Helper function for manufacturing input events to send to WebKit.
-NSEvent* EventWithMenuAction(BOOL item_chosen, int window_num,
- int item_height, int selected_index,
- NSRect menu_bounds, NSRect view_bounds) {
- NSEvent* event = nil;
- double event_time = (double)(AbsoluteToDuration(UpTime())) / 1000.0;
-
- if (item_chosen) {
- // Construct a mouse up event to simulate the selection of an appropriate
- // menu item.
- NSPoint click_pos;
- click_pos.x = menu_bounds.size.width / 2;
-
- // This is going to be hard to calculate since the button is painted by
- // WebKit, the menu by Cocoa, and we have to translate the selected_item
- // index to a coordinate that WebKit's PopupMenu expects which uses a
- // different font *and* expects to draw the menu below the button like we do
- // on Windows.
- // The WebKit popup menu thinks it will draw just below the button, so
- // create the click at the offset based on the selected item's index and
- // account for the different coordinate system used by NSView.
- int item_offset = selected_index * item_height + item_height / 2;
- click_pos.y = view_bounds.size.height - item_offset;
- event = [NSEvent mouseEventWithType:NSLeftMouseUp
- location:click_pos
- modifierFlags:0
- timestamp:event_time
- windowNumber:window_num
- context:nil
- eventNumber:0
- clickCount:1
- pressure:1.0];
- } else {
- // Fake an ESC key event (keyCode = 0x1B, from webinputevent_mac.mm) and
- // forward that to WebKit.
- NSPoint key_pos;
- key_pos.x = 0;
- key_pos.y = 0;
- NSString* escape_str = [NSString stringWithFormat:@"%c", 0x1B];
- event = [NSEvent keyEventWithType:NSKeyDown
- location:key_pos
- modifierFlags:0
- timestamp:event_time
- windowNumber:window_num
- context:nil
- characters:@""
- charactersIgnoringModifiers:escape_str
- isARepeat:NO
- keyCode:0x1B];
- }
-
- return event;
-}
-
-} // namespace webkit_glue
« no previous file with comments | « webkit/glue/webmenurunner_mac.h ('k') | webkit/tools/test_shell/mac/test_webview_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698