Bug 1527412 - Remove swizzling of -[NSView mouseDownCanMoveWindow]. r=spohl
authorMarkus Stange <mstange@themasta.com>
Wed, 13 Feb 2019 11:14:03 +0000
changeset 458922 b09a49ab3635
parent 458921 80265a268c68
child 458923 f6c24d795990
push id35551
push usershindli@mozilla.com
push dateWed, 13 Feb 2019 21:34:09 +0000
treeherdermozilla-central@08f794a4928e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1527412, 476393, 1335191
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527412 - Remove swizzling of -[NSView mouseDownCanMoveWindow]. r=spohl This was added in bug 476393 in order to work around a problem with the Java plug-in. We no longer support that plug-in. The comment also mentions NSTexturedBackgroundWindowMask which we stopped using in bug 1335191. Differential Revision: https://phabricator.services.mozilla.com/D19558
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -135,18 +135,16 @@ CG_EXTERN void CGContextResetClip(CGCont
 typedef CFTypeRef CGSRegionObj;
 CGError CGSNewRegionWithRect(const CGRect* rect, CGSRegionObj* outRegion);
 CGError CGSNewRegionWithRectList(const CGRect* rects, int rectCount, CGSRegionObj* outRegion);
 // defined in nsMenuBarX.mm
 extern NSMenu* sApplicationMenu;  // Application menu shared by all menubars
-static bool gChildViewMethodsSwizzled = false;
 extern nsIArray* gDraggedTransferables;
 ChildView* ChildViewMouseTracker::sLastMouseEventView = nil;
 NSEvent* ChildViewMouseTracker::sLastMouseMoveEvent = nil;
 NSWindow* ChildViewMouseTracker::sWindowUnderMouse = nil;
 NSPoint ChildViewMouseTracker::sLastScrollEventScreenLocation = NSZeroPoint;
@@ -381,23 +379,16 @@ nsresult nsChildView::Create(nsIWidget* 
                              const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData) {
   // Because the hidden window is created outside of an event loop,
   // we need to provide an autorelease pool to avoid leaking cocoa objects
   // (see bug 559075).
   nsAutoreleasePool localPool;
-  // See NSView (MethodSwizzling) below.
-  if (!gChildViewMethodsSwizzled) {
-    nsToolkit::SwizzleMethods([NSView class], @selector(mouseDownCanMoveWindow),
-                              @selector(nsChildView_NSView_mouseDownCanMoveWindow));
-    gChildViewMethodsSwizzled = true;
-  }
   mBounds = aRect;
   // Ensure that the toolkit is created.
   BaseCreate(aParent, aInitData);
   mParentView = nil;
@@ -6096,37 +6087,8 @@ BOOL ChildViewMouseTracker::WindowAccept
     return YES;
   // If we're here then we're dealing with a left click or mouse move on an
   // inactive window or something similar. Ask Gecko what to do.
   return [aView inactiveWindowAcceptsMouseEvent:aEvent];
 #pragma mark -
-@interface NSView (MethodSwizzling)
-- (BOOL)nsChildView_NSView_mouseDownCanMoveWindow;
-@implementation NSView (MethodSwizzling)
-// All top-level browser windows belong to the ToolbarWindow class and have
-// NSTexturedBackgroundWindowMask turned on in their "style" (see particularly
-// [ToolbarWindow initWithContentRect:...] in nsCocoaWindow.mm).  This style
-// normally means the window "may be moved by clicking and dragging anywhere
-// in the window background", but we've suppressed this by giving the
-// ChildView class a mouseDownCanMoveWindow method that always returns NO.
-// Normally a ToolbarWindow's contentView (not a ChildView) returns YES when
-// NSTexturedBackgroundWindowMask is turned on.  But normally this makes no
-// difference.  However, under some (probably very unusual) circumstances
-// (and only on Leopard) it *does* make a difference -- for example it
-// triggers bmo bugs 431902 and 476393.  So here we make sure that a
-// ToolbarWindow's contentView always returns NO from the
-// mouseDownCanMoveWindow method.
-- (BOOL)nsChildView_NSView_mouseDownCanMoveWindow {
-  NSWindow* ourWindow = [self window];
-  NSView* contentView = [ourWindow contentView];
-  if ([ourWindow isKindOfClass:[ToolbarWindow class]] && (self == contentView))
-    return [ourWindow isMovableByWindowBackground];
-  return [self nsChildView_NSView_mouseDownCanMoveWindow];