summaryrefslogtreecommitdiff
path: root/chromium/components/remote_cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/remote_cocoa')
-rw-r--r--chromium/components/remote_cocoa/app_shim/bridged_content_view.mm19
-rw-r--r--chromium/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm17
-rw-r--r--chromium/components/remote_cocoa/app_shim/window_move_loop.mm3
-rw-r--r--chromium/components/remote_cocoa/browser/window.mm1
4 files changed, 33 insertions, 7 deletions
diff --git a/chromium/components/remote_cocoa/app_shim/bridged_content_view.mm b/chromium/components/remote_cocoa/app_shim/bridged_content_view.mm
index 35c4d2778aa..08a03467760 100644
--- a/chromium/components/remote_cocoa/app_shim/bridged_content_view.mm
+++ b/chromium/components/remote_cocoa/app_shim/bridged_content_view.mm
@@ -8,7 +8,6 @@
#import "base/mac/foundation_util.h"
#import "base/mac/mac_util.h"
#import "base/mac/scoped_nsobject.h"
-#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/strings/sys_string_conversions.h"
#import "components/remote_cocoa/app_shim/drag_drop_client.h"
@@ -26,6 +25,7 @@
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
#import "ui/events/keycodes/keyboard_code_conversion_mac.h"
+#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/canvas_paint_mac.h"
#include "ui/gfx/decorated_text.h"
#import "ui/gfx/decorated_text_mac.h"
@@ -277,6 +277,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
NSWindow* source = [theEvent window];
NSWindow* target = [self window];
DCHECK(target);
+ if (ui::PlatformEventSource::ShouldIgnoreNativePlatformEvents())
+ return;
BOOL isScrollEvent = [theEvent type] == NSScrollWheel;
@@ -378,6 +380,15 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
// Generate a synthetic event with the keycode toolkit-views expects.
ui::KeyEvent event(ui::ET_KEY_PRESSED, keyCode, domCode, eventFlags);
+ // If the current event is a key event, assume it's the event that led to this
+ // edit command and attach it. Note that it isn't always the case that the
+ // current event is that key event, especially in tests which use synthetic
+ // key events!
+ if (NSApp.currentEvent.type == NSEventTypeKeyDown ||
+ NSApp.currentEvent.type == NSEventTypeKeyUp) {
+ event.SetNativeEvent(NSApp.currentEvent);
+ }
+
if ([self dispatchKeyEventToMenuController:&event])
return;
@@ -652,11 +663,7 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
remote_cocoa::DragDropClient* client = [self dragDropClient];
- const auto drag_operation =
- client ? client->DragUpdate(sender) : ui::DragDropTypes::DRAG_NONE;
- UMA_HISTOGRAM_BOOLEAN("Event.DragDrop.AcceptDragUpdate",
- drag_operation != ui::DragDropTypes::DRAG_NONE);
- return drag_operation;
+ return client ? client->DragUpdate(sender) : ui::DragDropTypes::DRAG_NONE;
}
- (void)draggingExited:(id<NSDraggingInfo>)sender {
diff --git a/chromium/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm b/chromium/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
index cf88f696a46..69580888047 100644
--- a/chromium/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
+++ b/chromium/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm
@@ -65,6 +65,23 @@
@implementation BrowserNativeWidgetWindow
+// Prevent detached tabs from glitching when the window is partially offscreen.
+// See https://crbug.com/1095717 for details.
+// This is easy to get wrong so scope very tightly to only disallow large
+// vertical jumps.
+- (NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen*)screen {
+ NSRect proposed = [super constrainFrameRect:rect toScreen:screen];
+ // This boils down to: use the small threshold when we're not avoiding a
+ // Dock on the bottom, and the big threshold otherwise.
+ static constexpr CGFloat kBigThreshold = 200;
+ static constexpr CGFloat kSmallThreshold = 50;
+ const CGFloat yDelta = NSMaxY(proposed) - NSMaxY(rect);
+ if (yDelta > kBigThreshold ||
+ (yDelta > kSmallThreshold && NSMinY(proposed) == 0))
+ return rect;
+ return proposed;
+}
+
// NSWindow (PrivateAPI) overrides.
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle {
diff --git a/chromium/components/remote_cocoa/app_shim/window_move_loop.mm b/chromium/components/remote_cocoa/app_shim/window_move_loop.mm
index 7ad1ec93a7c..7654ade58e2 100644
--- a/chromium/components/remote_cocoa/app_shim/window_move_loop.mm
+++ b/chromium/components/remote_cocoa/app_shim/window_move_loop.mm
@@ -100,9 +100,10 @@ bool CocoaWindowMoveLoop::Run() {
if ([event type] == NSLeftMouseDragged) {
const NSPoint mouse_in_screen = [NSEvent mouseLocation];
- const NSRect ns_frame = NSOffsetRect(
+ NSRect ns_frame = NSOffsetRect(
initial_frame, mouse_in_screen.x - initial_mouse_in_screen_.x,
mouse_in_screen.y - initial_mouse_in_screen_.y);
+ ns_frame = [window constrainFrameRect:ns_frame toScreen:window.screen];
[window setFrame:ns_frame display:NO animate:NO];
return event;
diff --git a/chromium/components/remote_cocoa/browser/window.mm b/chromium/components/remote_cocoa/browser/window.mm
index e58b33d5d1e..11e4b8a58d9 100644
--- a/chromium/components/remote_cocoa/browser/window.mm
+++ b/chromium/components/remote_cocoa/browser/window.mm
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include <map>
+#include "base/check.h"
#include "base/no_destructor.h"
namespace remote_cocoa {