Bug 1291457 - Remove shadow invalidation code. r?spohl draft
authorMarkus Stange <mstange@themasta.com>
Tue, 02 Aug 2016 16:39:06 -0400
changeset 596319 22122bd4d655493a6613c0b485180b71272c68f2
parent 596318 b3230ef8f20431374801d58f7d81baa2f96ff59e
child 633910 20952cb8109a0533396ca5fc8bc31b81604f9f35
push id64578
push userbmo:mstange@themasta.com
push dateMon, 19 Jun 2017 04:32:23 +0000
reviewersspohl
bugs1291457
milestone56.0a1
Bug 1291457 - Remove shadow invalidation code. r?spohl Invalidating a window's shadow is really slow and leads to flickering. Now that arrow panels don't change their contents during the panel opening animation any more, their shape stays the same after the first paint, so we don't need the shadow invalidation functionality for them any more. And as far as I know, we don't use transparent popups with changing shapes anywhere else. The system still computes the shadow for the first paint of the window (which happens during the orderFront call), and it updates the shadow whenever the window resizes. But not when its size stays the same and only what we draw in the content is updated. MozReview-Commit-ID: 138PjbrSFrc
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3762,22 +3762,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
 }
 
 // The display system has told us that a portion of our view is dirty. Tell
 // gecko to paint it
 - (void)drawRect:(NSRect)aRect
 {
   CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   [self drawRect:aRect inContext:cgContext];
-
-  // If we're a transparent window and our contents have changed, we need
-  // to make sure the shadow is updated to the new contents.
-  if ([[self window] isKindOfClass:[BaseWindow class]]) {
-    [(BaseWindow*)[self window] deferredInvalidateShadow];
-  }
 }
 
 - (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext
 {
   if (!mGeckoChild || !mGeckoChild->IsVisible())
     return;
 
 #ifdef DEBUG_UPDATE
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -36,19 +36,16 @@ typedef struct _nsCocoaWindowList {
 @interface BaseWindow : NSWindow
 {
   // Data Storage
   NSMutableDictionary* mState;
   BOOL mDrawsIntoWindowFrame;
   NSColor* mActiveTitlebarColor;
   NSColor* mInactiveTitlebarColor;
 
-  // Shadow
-  BOOL mScheduledShadowInvalidation;
-
   // Invalidation disabling
   BOOL mDisabledNeedsDisplay;
 
   // DPI cache. Getting the physical screen size (CGDisplayScreenSize)
   // is ridiculously slow, so we cache it in the toplevel window for all
   // descendants to use.
   float mDPI;
 
@@ -64,18 +61,16 @@ typedef struct _nsCocoaWindowList {
 
 - (void)importState:(NSDictionary*)aState;
 - (NSMutableDictionary*)exportState;
 - (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
 - (BOOL)drawsContentsIntoWindowFrame;
 - (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
 - (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive;
 
-- (void)deferredInvalidateShadow;
-- (void)invalidateShadow;
 - (float)getDPI;
 
 - (void)mouseEntered:(NSEvent*)aEvent;
 - (void)mouseExited:(NSEvent*)aEvent;
 - (void)mouseMoved:(NSEvent*)aEvent;
 - (void)updateTrackingArea;
 - (NSView*)trackingAreaView;
 
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2995,17 +2995,16 @@ static NSMutableSet *gSwizzledFrameViewC
 
 - (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)aBufferingType defer:(BOOL)aFlag
 {
   mDrawsIntoWindowFrame = NO;
   [super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag];
   mState = nil;
   mActiveTitlebarColor = nil;
   mInactiveTitlebarColor = nil;
-  mScheduledShadowInvalidation = NO;
   mDisabledNeedsDisplay = NO;
   mDPI = GetDPI(self);
   mTrackingArea = nil;
   mDirtyRect = NSZeroRect;
   mBeingShown = NO;
   mDrawTitle = NO;
   mBrightTitlebarForeground = NO;
   mUseMenuStyle = NO;
@@ -3145,31 +3144,16 @@ static const NSString* kStateCollectionB
   }
 }
 
 - (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive
 {
   return aActive ? mActiveTitlebarColor : mInactiveTitlebarColor;
 }
 
-- (void)deferredInvalidateShadow
-{
-  if (mScheduledShadowInvalidation || [self isOpaque] || ![self hasShadow])
-    return;
-
-  [self performSelector:@selector(invalidateShadow) withObject:nil afterDelay:0];
-  mScheduledShadowInvalidation = YES;
-}
-
-- (void)invalidateShadow
-{
-  [super invalidateShadow];
-  mScheduledShadowInvalidation = NO;
-}
-
 - (float)getDPI
 {
   return mDPI;
 }
 
 - (NSView*)trackingAreaView
 {
   NSView* contentView = [self contentView];