Backed out changesets b1d798dd3579, 2ffed1cedd42, and e8ff1d96126d (bug 1070710) for OSX bustage. a=backout
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 29 Jul 2016 19:41:50 -0400
changeset 342163 1a2331a741876542f14ad82f4c5264d70f98c832
parent 342162 de2e1b678ebdf59843d0438cedf893cc8e3df132
child 342164 d7fb39af63f4890e51788fdacd9e1105a1ef3957
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1070710
milestone49.0a2
backs outb1d798dd3579b91b05942393fd469b9c6edf51d3
2ffed1cedd425769b6368f70aaf3383ae741abdb
e8ff1d96126d516b4325bbd13dfe3b75402d737a
Backed out changesets b1d798dd3579, 2ffed1cedd42, and e8ff1d96126d (bug 1070710) for OSX bustage. a=backout
widget/cocoa/VibrancyManager.h
widget/cocoa/VibrancyManager.mm
widget/cocoa/ViewRegion.h
widget/cocoa/ViewRegion.mm
widget/cocoa/moz.build
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/VibrancyManager.h
+++ b/widget/cocoa/VibrancyManager.h
@@ -6,17 +6,16 @@
 
 #ifndef VibrancyManager_h
 #define VibrancyManager_h
 
 #include "mozilla/Assertions.h"
 #include "nsClassHashtable.h"
 #include "nsRegion.h"
 #include "nsTArray.h"
-#include "ViewRegion.h"
 
 #import <Foundation/NSGeometry.h>
 
 @class NSColor;
 @class NSView;
 class nsChildView;
 
 namespace mozilla {
@@ -97,20 +96,27 @@ public:
 
   /**
    * Check whether the operating system supports vibrancy at all.
    * You may only create a VibrancyManager instance if this returns true.
    * @return Whether VibrancyManager can be used on this OS.
    */
   static bool SystemSupportsVibrancy();
 
+  // The following are only public because otherwise ClearVibrantRegionFunc
+  // can't see them.
+  struct VibrantRegion {
+    LayoutDeviceIntRegion region;
+    nsTArray<NSView*> effectViews;
+  };
+  void ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const;
+
 protected:
-  void ClearVibrantRegion(const LayoutDeviceIntRegion& aVibrantRegion) const;
-  NSView* CreateEffectView(VibrancyType aType);
+  NSView* CreateEffectView(VibrancyType aType, NSRect aRect);
 
   const nsChildView& mCoordinateConverter;
   NSView* mContainerView;
-  nsClassHashtable<nsUint32HashKey, ViewRegion> mVibrantRegions;
+  nsClassHashtable<nsUint32HashKey, VibrantRegion> mVibrantRegions;
 };
 
 } // namespace mozilla
 
 #endif // VibrancyManager_h
--- a/widget/cocoa/VibrancyManager.mm
+++ b/widget/cocoa/VibrancyManager.mm
@@ -10,35 +10,75 @@
 
 using namespace mozilla;
 
 void
 VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
                                      const LayoutDeviceIntRegion& aRegion)
 {
   auto& vr = *mVibrantRegions.LookupOrAdd(uint32_t(aType));
-  vr.UpdateRegion(aRegion, mCoordinateConverter, mContainerView, ^() {
-    return this->CreateEffectView(aType);
-  });
+  if (vr.region == aRegion) {
+    return;
+  }
+
+  // We need to construct the required region using as many EffectViews
+  // as necessary. We try to update the geometry of existing views if
+  // possible, or create new ones or remove old ones if the number of
+  // rects in the region has changed.
+
+  nsTArray<NSView*> viewsToRecycle;
+  vr.effectViews.SwapElements(viewsToRecycle);
+  // vr.effectViews is now empty.
+
+  size_t i = 0;
+  for (auto iter = aRegion.RectIter();
+       !iter.Done() || i < viewsToRecycle.Length();
+       i++) {
+    if (!iter.Done()) {
+      NSView* view = nil;
+      NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(iter.Get());
+      if (i < viewsToRecycle.Length()) {
+        view = viewsToRecycle[i];
+        [view setFrame:rect];
+        [view setNeedsDisplay:YES];
+      } else {
+        view = CreateEffectView(aType, rect);
+        [mContainerView addSubview:view];
+
+        // Now that the view is in the view hierarchy, it'll be kept alive by
+        // its superview, so we can drop our reference.
+        [view release];
+      }
+      vr.effectViews.AppendElement(view);
+      iter.Next();
+    } else {
+      // Our new region is made of less rects than the old region, so we can
+      // remove this view. We only have a weak reference to it, so removing it
+      // from the view hierarchy will release it.
+      [viewsToRecycle[i] removeFromSuperview];
+    }
+  }
+
+  vr.region = aRegion;
 }
 
 void
 VibrancyManager::ClearVibrantAreas() const
 {
   for (auto iter = mVibrantRegions.ConstIter(); !iter.Done(); iter.Next()) {
-    ClearVibrantRegion(iter.UserData()->Region());
+    ClearVibrantRegion(*iter.UserData());
   }
 }
 
 void
-VibrancyManager::ClearVibrantRegion(const LayoutDeviceIntRegion& aVibrantRegion) const
+VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const
 {
   [[NSColor clearColor] set];
 
-  for (auto iter = aVibrantRegion.RectIter(); !iter.Done(); iter.Next()) {
+  for (auto iter = aVibrantRegion.region.RectIter(); !iter.Done(); iter.Next()) {
     NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(iter.Get()));
   }
 }
 
 @interface NSView(CurrentFillColor)
 - (NSColor*)_currentFillColor;
 @end
 
@@ -53,38 +93,42 @@ AdjustedColor(NSColor* aFillColor, Vibra
     return [NSColor colorWithDeviceWhite:0.96 alpha:1.0];
   }
   return aFillColor;
 }
 
 NSColor*
 VibrancyManager::VibrancyFillColorForType(VibrancyType aType)
 {
-  NSView* view = mVibrantRegions.LookupOrAdd(uint32_t(aType))->GetAnyView();
+  const nsTArray<NSView*>& views =
+    mVibrantRegions.LookupOrAdd(uint32_t(aType))->effectViews;
 
-  if (view && [view respondsToSelector:@selector(_currentFillColor)]) {
+  if (!views.IsEmpty() &&
+      [views[0] respondsToSelector:@selector(_currentFillColor)]) {
     // -[NSVisualEffectView _currentFillColor] is the color that our view
     // would draw during its drawRect implementation, if we hadn't
     // disabled that.
-    return AdjustedColor([view _currentFillColor], aType);
+    return AdjustedColor([views[0] _currentFillColor], aType);
   }
   return [NSColor whiteColor];
 }
 
 @interface NSView(FontSmoothingBackgroundColor)
 - (NSColor*)fontSmoothingBackgroundColor;
 @end
 
 NSColor*
 VibrancyManager::VibrancyFontSmoothingBackgroundColorForType(VibrancyType aType)
 {
-  NSView* view = mVibrantRegions.LookupOrAdd(uint32_t(aType))->GetAnyView();
+  const nsTArray<NSView*>& views =
+    mVibrantRegions.LookupOrAdd(uint32_t(aType))->effectViews;
 
-  if (view && [view respondsToSelector:@selector(fontSmoothingBackgroundColor)]) {
-    return [view fontSmoothingBackgroundColor];
+  if (!views.IsEmpty() &&
+      [views[0] respondsToSelector:@selector(fontSmoothingBackgroundColor)]) {
+    return [views[0] fontSmoothingBackgroundColor];
   }
   return [NSColor clearColor];
 }
 
 static void
 DrawRectNothing(id self, SEL _cmd, NSRect aRect)
 {
   // The super implementation would clear the background.
@@ -204,24 +248,24 @@ enum {
 
 @interface NSView(NSVisualEffectViewMethods)
 - (void)setState:(NSUInteger)state;
 - (void)setMaterial:(NSUInteger)material;
 - (void)setEmphasized:(BOOL)emphasized;
 @end
 
 NSView*
-VibrancyManager::CreateEffectView(VibrancyType aType)
+VibrancyManager::CreateEffectView(VibrancyType aType, NSRect aRect)
 {
   static Class EffectViewClassWithoutForegroundVibrancy = CreateEffectViewClass(NO);
   static Class EffectViewClassWithForegroundVibrancy = CreateEffectViewClass(YES);
 
   Class EffectViewClass = HasVibrantForeground(aType)
     ? EffectViewClassWithForegroundVibrancy : EffectViewClassWithoutForegroundVibrancy;
-  NSView* effectView = [[EffectViewClass alloc] initWithFrame:NSZeroRect];
+  NSView* effectView = [[EffectViewClass alloc] initWithFrame:aRect];
   [effectView performSelector:@selector(setAppearance:)
                    withObject:AppearanceForVibrancyType(aType)];
   [effectView setState:VisualEffectStateForVibrancyType(aType)];
 
   BOOL canUseElCapitanMaterials = nsCocoaFeatures::OnElCapitanOrLater();
   if (aType == VibrancyType::MENU) {
     // Before 10.11 there is no material that perfectly matches the menu
     // look. Of all available material types, NSVisualEffectMaterialTitlebar
deleted file mode 100644
--- a/widget/cocoa/ViewRegion.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef ViewRegion_h
-#define ViewRegion_h
-
-#include "Units.h"
-#include "nsTArray.h"
-
-@class NSView;
-
-namespace mozilla {
-
-/**
- * Manages a set of NSViews to cover a LayoutDeviceIntRegion.
- */
-class ViewRegion {
-public:
-  ~ViewRegion();
-
-  mozilla::LayoutDeviceIntRegion Region() { return mRegion; }
-
-  /**
-   * Update the region.
-   * @param aRegion  The new region.
-   * @param aCoordinateConverter  The nsChildView to use for converting
-   *   LayoutDeviceIntRect device pixel coordinates into Cocoa NSRect coordinates.
-   * @param aContainerView  The view that's going to be the superview of the
-   *   NSViews which will be created for this region.
-   * @param aViewCreationCallback  A block that instantiates new NSViews.
-   * @return  Whether or not the region changed.
-   */
-  bool UpdateRegion(const mozilla::LayoutDeviceIntRegion& aRegion,
-                    const nsChildView& aCoordinateConverter,
-                    NSView* aContainerView,
-                    NSView* (^aViewCreationCallback)());
-
-  /**
-   * Return an NSView from the region, if there is any.
-   */
-  NSView* GetAnyView() { return mViews.Length() > 0 ? mViews[0] : nil; }
-
-private:
-  mozilla::LayoutDeviceIntRegion mRegion;
-  nsTArray<NSView*> mViews;
-};
-
-} // namespace mozilla
-
-#endif // ViewRegion_h
deleted file mode 100644
--- a/widget/cocoa/ViewRegion.mm
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "ViewRegion.h"
-#import <Cocoa/Cocoa.h>
-
-using namespace mozilla;
-
-ViewRegion::~ViewRegion()
-{
-  for (size_t i = 0; i < mViews.Length(); i++) {
-    [mViews[i] removeFromSuperview];
-  }
-}
-
-bool
-ViewRegion::UpdateRegion(const LayoutDeviceIntRegion& aRegion,
-                         const nsChildView& aCoordinateConverter,
-                         NSView* aContainerView,
-                         NSView* (^aViewCreationCallback)())
-{
-  if (mRegion == aRegion) {
-    return false;
-  }
-
-  // We need to construct the required region using as many EffectViews
-  // as necessary. We try to update the geometry of existing views if
-  // possible, or create new ones or remove old ones if the number of
-  // rects in the region has changed.
-
-  nsTArray<NSView*> viewsToRecycle;
-  mViews.SwapElements(viewsToRecycle);
-  // The mViews array is now empty.
-
-  size_t i = 0;
-  for (auto iter = aRegion.RectIter();
-       !iter.Done() || i < viewsToRecycle.Length();
-       i++) {
-    if (!iter.Done()) {
-      NSView* view = nil;
-      NSRect rect = aCoordinateConverter.DevPixelsToCocoaPoints(iter.Get());
-      if (i < viewsToRecycle.Length()) {
-        view = viewsToRecycle[i];
-      } else {
-        view = aViewCreationCallback();
-        [aContainerView addSubview:view];
-
-        // Now that the view is in the view hierarchy, it'll be kept alive by
-        // its superview, so we can drop our reference.
-        [view release];
-      }
-      if (!NSEqualRects(rect, [view frame])) {
-        [view setFrame:rect];
-      }
-      [view setNeedsDisplay:YES];
-      mViews.AppendElement(view);
-      iter.Next();
-    } else {
-      // Our new region is made of fewer rects than the old region, so we can
-      // remove this view. We only have a weak reference to it, so removing it
-      // from the view hierarchy will release it.
-      [viewsToRecycle[i] removeFromSuperview];
-    }
-  }
-
-  mRegion = aRegion;
-  return true;
-}
--- a/widget/cocoa/moz.build
+++ b/widget/cocoa/moz.build
@@ -53,17 +53,16 @@ UNIFIED_SOURCES += [
     'nsSystemStatusBarCocoa.mm',
     'nsToolkit.mm',
     'nsWidgetFactory.mm',
     'nsWindowMap.mm',
     'OSXNotificationCenter.mm',
     'SwipeTracker.mm',
     'TextInputHandler.mm',
     'VibrancyManager.mm',
-    'ViewRegion.mm',
     'WidgetTraceEvent.mm',
 ]
 
 # These files cannot be built in unified mode because they cause symbol conflicts
 SOURCES += [
     'nsChildView.mm',
     'nsClipboard.mm',
     'nsCocoaDebugUtils.mm',
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -23,17 +23,16 @@
 #include "GLContextTypes.h"
 #include "mozilla/Mutex.h"
 #include "nsRegion.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsString.h"
 #include "nsIDragService.h"
-#include "ViewRegion.h"
 
 #import <Carbon/Carbon.h>
 #import <Cocoa/Cocoa.h>
 #import <AppKit/NSOpenGL.h>
 
 class nsChildView;
 class nsCocoaWindow;
 
@@ -500,17 +499,17 @@ public:
   virtual bool PreRender(LayerManagerComposite* aManager) override;
   virtual void PostRender(LayerManagerComposite* aManager) override;
   virtual void DrawWindowOverlay(LayerManagerComposite* aManager,
                                  LayoutDeviceIntRect aRect) override;
 
   virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
 
   virtual void UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion) override;
-  LayoutDeviceIntRegion GetNonDraggableRegion() { return mNonDraggableRegion.Region(); }
+  const LayoutDeviceIntRegion& GetDraggableRegion() { return mDraggableRegion; }
 
   virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) override;
 
   virtual void LookUpDictionary(
                  const nsAString& aText,
                  const nsTArray<mozilla::FontRange>& aFontRangeArray,
                  const bool aIsVertical,
                  const LayoutDeviceIntPoint& aPoint) override;
@@ -666,17 +665,17 @@ protected:
   mozilla::UniquePtr<RectTextureImage> mCornerMaskImage;
   mozilla::UniquePtr<RectTextureImage> mTitlebarImage;
   mozilla::UniquePtr<RectTextureImage> mBasicCompositorImage;
 
   // The area of mTitlebarCGContext that has changed and needs to be
   // uploaded to to mTitlebarImage. Main thread only.
   nsIntRegion           mDirtyTitlebarRegion;
 
-  mozilla::ViewRegion   mNonDraggableRegion;
+  LayoutDeviceIntRegion mDraggableRegion;
 
   // Cached value of [mView backingScaleFactor], to avoid sending two obj-c
   // messages (respondsToSelector, backingScaleFactor) every time we need to
   // use it.
   // ** We'll need to reinitialize this if the backing resolution changes. **
   mutable CGFloat       mBackingScaleFactor;
 
   bool                  mVisible;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2783,51 +2783,22 @@ nsChildView::DoRemoteComposition(const L
   // anything during the basic compositor transaction. Draw the overlay now.
   DrawWindowOverlay(mGLPresenter, aRenderRect);
 
   mGLPresenter->EndFrame();
 
   [(ChildView*)mView postRender:mGLPresenter->GetNSOpenGLContext()];
 }
 
-@interface NonDraggableView : NSView
-@end
-
-@implementation NonDraggableView
-- (BOOL)mouseDownCanMoveWindow { return NO; }
-- (NSView*)hitTest:(NSPoint)aPoint { return nil; }
-@end
-
 void
 nsChildView::UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion)
 {
-  // mView returns YES from mouseDownCanMoveWindow, so we need to put NSViews
-  // that return NO from mouseDownCanMoveWindow in the places that shouldn't
-  // be draggable. We can't do it the other way round because returning
-  // YES from mouseDownCanMoveWindow doesn't have any effect if there's a
-  // superview that returns NO.
-  LayoutDeviceIntRegion nonDraggable;
-  nonDraggable.Sub(LayoutDeviceIntRect(0, 0, mBounds.width, mBounds.height), aRegion);
-
-  __block bool changed = false;
-
-  // Suppress calls to setNeedsDisplay during NSView geometry changes.
-  ManipulateViewWithoutNeedingDisplay(mView, ^() {
-    changed = mNonDraggableRegion.UpdateRegion(nonDraggable, *this, mView, ^() {
-      return [[NonDraggableView alloc] initWithFrame:NSZeroRect];
-    });
-  });
-
-  if (changed) {
-    // Trigger an update to the window server. This will call
-    // mouseDownCanMoveWindow.
-    // Doing this manually is only necessary because we're suppressing
-    // setNeedsDisplay calls above.
-    [[mView window] setMovableByWindowBackground:NO];
-    [[mView window] setMovableByWindowBackground:YES];
+  if (mDraggableRegion != aRegion) {
+    mDraggableRegion = aRegion;
+    [(ChildView*)mView updateWindowDraggableState];
   }
 }
 
 void
 nsChildView::ReportSwipeStarted(uint64_t aInputBlockId,
                                 bool aStartSwipe)
 {
   if (mSwipeEventQueue && mSwipeEventQueue->inputBlockId == aInputBlockId) {
@@ -3739,20 +3710,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
   }
   [super scrollRect:aRect by:offset];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (BOOL)mouseDownCanMoveWindow
 {
-  // Return YES so that parts of this view can be draggable. The non-draggable
-  // parts will be covered by NSViews that return NO from
-  // mouseDownCanMoveWindow and thus override draggability from the inside.
-  // These views are assembled in nsChildView::UpdateWindowDraggingRegion.
+  // Return YES so that _regionForOpaqueDescendants gets called, where the
+  // actual draggable region will be assembled.
   return YES;
 }
 
 -(void)updateGLContext
 {
   [mGLContext setView:self];
   [mGLContext update];
 }
@@ -4714,17 +4683,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
   // This might destroy our widget (and null out mGeckoChild).
   bool defaultPrevented =
     (mGeckoChild->DispatchInputEvent(&geckoEvent) == nsEventStatus_eConsumeNoDefault);
 
   // Check to see if we are double-clicking in the titlebar.
   CGFloat locationInTitlebar = [[self window] frame].size.height - [theEvent locationInWindow].y;
   LayoutDeviceIntPoint pos = geckoEvent.mRefPoint;
   if (!defaultPrevented && [theEvent clickCount] == 2 &&
-      !mGeckoChild->GetNonDraggableRegion().Contains(pos.x, pos.y) &&
+      mGeckoChild->GetDraggableRegion().Contains(pos.x, pos.y) &&
       [[self window] isKindOfClass:[ToolbarWindow class]] &&
       (locationInTitlebar < [(ToolbarWindow*)[self window] titlebarHeight] ||
        locationInTitlebar < [(ToolbarWindow*)[self window] unifiedToolbarHeight])) {
     if ([self shouldZoomOnDoubleClick]) {
       [[self window] performZoom:nil];
     } else if ([self shouldMinimizeOnTitlebarDoubleClick]) {
       NSButton *minimizeButton = [[self window] standardWindowButton:NSWindowMiniaturizeButton];
       [minimizeButton performClick:self];
@@ -4749,16 +4718,85 @@ NSEvent* gLastDragMouseDownEvent = nil;
   event.mRefPoint = mGeckoChild->CocoaPointsToDevPixels(localEventLocation);
 
   event.mExitFrom = aExitFrom;
 
   nsEventStatus status; // ignored
   mGeckoChild->DispatchEvent(&event, status);
 }
 
+- (void)updateWindowDraggableState
+{
+  // Trigger update to the window server.
+  [[self window] setMovableByWindowBackground:NO];
+  [[self window] setMovableByWindowBackground:YES];
+}
+
+// aRect is in view coordinates relative to this NSView.
+- (CGRect)convertToFlippedWindowCoordinates:(NSRect)aRect
+{
+  // First, convert the rect to regular window coordinates...
+  NSRect inWindowCoords = [self convertRect:aRect toView:nil];
+  // ... and then flip it again because window coordinates have their origin
+  // in the bottom left corner, and we need it to be in the top left corner.
+  inWindowCoords.origin.y = [[self window] frame].size.height - NSMaxY(inWindowCoords);
+  return NSRectToCGRect(inWindowCoords);
+}
+
+static CGSRegionObj
+NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion,
+                       CGRect (^aRectConverter)(const LayoutDeviceIntRect&))
+{
+  nsTArray<CGRect> rects;
+  for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
+    rects.AppendElement(aRectConverter(iter.Get()));
+  }
+
+  CGSRegionObj region;
+  CGSNewRegionWithRectList(rects.Elements(), rects.Length(), &region);
+  return region;
+}
+
+// This function is called with forMove:YES to calculate the draggable region
+// of the window which will be submitted to the window server. Window dragging
+// is handled on the window server without calling back into our process, so it
+// also works while our app is unresponsive.
+- (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect forMove:(BOOL)aForMove
+{
+  if (!aForMove || !mGeckoChild) {
+    return [super _regionForOpaqueDescendants:aRect forMove:aForMove];
+  }
+
+  LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
+
+  LayoutDeviceIntRegion opaqueRegion;
+  opaqueRegion.Sub(boundingRect, mGeckoChild->GetDraggableRegion());
+
+  return NewCGSRegionFromRegion(opaqueRegion, ^(const LayoutDeviceIntRect& r) {
+    return [self convertToFlippedWindowCoordinates:mGeckoChild->DevPixelsToCocoaPoints(r)];
+  });
+}
+
+// Starting with 10.10, in addition to the traditional
+// -[NSView _regionForOpaqueDescendants:forMove:] method, there's a new form with
+// an additional forUnderTitlebar argument, which is sometimes called instead of
+// the old form. We need to override the new variant as well.
+- (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect
+                                    forMove:(BOOL)aForMove
+                           forUnderTitlebar:(BOOL)aForUnderTitlebar
+{
+  if (!aForMove || !mGeckoChild) {
+    return [super _regionForOpaqueDescendants:aRect
+                                      forMove:aForMove
+                             forUnderTitlebar:aForUnderTitlebar];
+  }
+
+  return [self _regionForOpaqueDescendants:aRect forMove:aForMove];
+}
+
 - (void)handleMouseMoved:(NSEvent*)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mGeckoChild)
     return;
   if (mTextInputHandler->OnHandleEvent(theEvent)) {
     return;