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

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 322893005: MacViews: Add WidgetEventGenerator to abstract platform-specific event generation for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No inheritance Created 6 years, 5 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
Index: ui/views/cocoa/bridged_content_view.mm
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm
index 1f2ef37586b69e889e95eb39a0d0449ed9532cfb..473adaa1fd77b46e29a9674e7e49a4e7bc1ceab9 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -11,9 +11,14 @@
#include "ui/gfx/canvas_paint_mac.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
@interface BridgedContentView ()
+// Translates the location of |theEvent| to toolkit-views coordinates and passes
+// the event to NativeWidgetMac for handling.
+- (void)handleMouseEvent:(NSEvent*)theEvent;
+
// Execute a command on the currently focused TextInputClient.
// |commandId| should be a resource ID from ui_strings.grd.
- (void)doCommandByID:(int)commandId;
@@ -44,6 +49,14 @@
// BridgedContentView private implementation.
+- (void)handleMouseEvent:(NSEvent*)theEvent {
+ if (!hostedView_)
+ return;
+
+ ui::MouseEvent event(theEvent);
+ hostedView_->GetWidget()->OnMouseEvent(&event);
+}
+
- (void)doCommandByID:(int)commandId {
if (textInputClient_ && textInputClient_->IsEditingCommandEnabled(commandId))
textInputClient_->ExecuteEditingCommand(commandId);
@@ -51,6 +64,10 @@
// NSView implementation.
+- (BOOL)acceptsFirstResponder {
+ return YES;
+}
+
- (void)setFrameSize:(NSSize)newSize {
[super setFrameSize:newSize];
if (!hostedView_)
@@ -67,6 +84,8 @@
hostedView_->Paint(&canvas, views::CullSet());
}
+// NSResponder implementation.
+
- (void)keyDown:(NSEvent*)theEvent {
if (textInputClient_)
[self interpretKeyEvents:@[ theEvent ]];
@@ -74,6 +93,55 @@
[super keyDown:theEvent];
}
+- (void)mouseDown:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)rightMouseDown:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)otherMouseDown:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)mouseUp:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)rightMouseUp:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)otherMouseUp:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)mouseDragged:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)rightMouseDragged:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)otherMouseDragged:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)mouseMoved:(NSEvent*)theEvent {
+ // Note: mouseEntered: and mouseExited: are not handled separately.
+ // |hostedView_| is responsible for converting the move events into entered
+ // and exited events for the view heirarchy.
+ // TODO(tapted): Install/uninstall tracking areas when required so that the
+ // NSView will receive these events outside of tests.
+ [self handleMouseEvent:theEvent];
+}
+
+- (void)scrollWheel:(NSEvent*)theEvent {
+ [self handleMouseEvent:theEvent];
+}
+
- (void)deleteBackward:(id)sender {
[self doCommandByID:IDS_DELETE_BACKWARD];
}

Powered by Google App Engine
This is Rietveld 408576698