Bug 1496823 - Remove setNeedsPendingDisplay infrastructure. r=spohl
authorMarkus Stange <mstange@themasta.com>
Wed, 17 Oct 2018 20:43:23 +0000
changeset 500292 34f52a304c5251541685810ab2fb2e0a508d7508
parent 500291 a87fc8375ec28730643ba38f36a253e0ab5942c8
child 500293 959084361b1580b3dd586b6e229e21274cc83556
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1496823
milestone64.0a1
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 1496823 - Remove setNeedsPendingDisplay infrastructure. r=spohl Many years ago, Gecko would sometimes call nsChildView::Invalidate during drawRect:. This is no longer the case: Widget invalidations now only happen outside of drawRect, usually from a refresh tick or from viewWillDraw. Differential Revision: https://phabricator.services.mozilla.com/D7922
widget/cocoa/mozView.h
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/mozView.h
+++ b/widget/cocoa/mozView.h
@@ -29,21 +29,16 @@ class TextInputHandler;
 - (void)uninstallTextInputHandler;
 
   // access the nsIWidget associated with this view. DOES NOT ADDREF.
 - (nsIWidget*)widget;
 
   // return a context menu for this view
 - (NSMenu*)contextMenu;
 
-  // Allows callers to do a delayed invalidate (e.g., if an invalidate
-  // happens during drawing)
-- (void)setNeedsPendingDisplay;
-- (void)setNeedsPendingDisplayInRect:(NSRect)invalidRect;
-
   // called when our corresponding Gecko view goes away
 - (void)widgetDestroyed;
 
 - (BOOL)isDragInProgress;
 
   // Checks whether the view is first responder or not
 - (BOOL)isFirstResponder;
 
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -142,21 +142,16 @@ class WidgetRenderingContext;
   NSEvent* mLastKeyDownEvent;
 
   // Whether the last mouse down event was blocked from Gecko.
   BOOL mBlockedLastMouseDown;
 
   // when acceptsFirstMouse: is called, we store the event here (strong)
   NSEvent* mClickThroughMouseDownEvent;
 
-  // rects that were invalidated during a draw, so have pending drawing
-  NSMutableArray* mPendingDirtyRects;
-  BOOL mPendingFullDisplay;
-  BOOL mPendingDisplay;
-
   // WheelStart/Stop events should always come in pairs. This BOOL records the
   // last received event so that, when we receive one of the events, we make sure
   // to send its pair event first, in case we didn't yet for any reason.
   BOOL mExpectingWheelStop;
 
   // Set to YES when our GL surface has been updated and we need to call
   // updateGLContext before we composite.
   BOOL mNeedsGLUpdate;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -177,18 +177,16 @@ static NSMutableDictionary* sNativeKeyEv
 - (void) convertCocoaMouseEvent:(NSEvent*)aMouseEvent
                    toGeckoEvent:(WidgetInputEvent*)outGeckoEvent;
 - (void) convertCocoaTabletPointerEvent:(NSEvent*)aMouseEvent
                            toGeckoEvent:(WidgetMouseEvent*)outGeckoEvent;
 - (NSMenu*)contextMenu;
 
 - (BOOL)isRectObscuredBySubview:(NSRect)inRect;
 
-- (void)processPendingRedraws;
-
 - (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext;
 - (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect;
 - (BOOL)isUsingMainThreadOpenGL;
 - (BOOL)isUsingOpenGL;
 - (void)drawUsingOpenGL;
 - (void)drawUsingOpenGLCallback;
 
 - (BOOL)hasRoundedBottomCorners;
@@ -1405,24 +1403,17 @@ nsChildView::Invalidate(const LayoutDevi
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mView || !mVisible)
     return;
 
   NS_ASSERTION(GetLayerManager()->GetBackendType() != LayersBackend::LAYERS_CLIENT,
                "Shouldn't need to invalidate with accelerated OMTC layers!");
 
-  if ([NSView focusView]) {
-    // if a view is focussed (i.e. being drawn), then postpone the invalidate so that we
-    // don't lose it.
-    [mView setNeedsPendingDisplayInRect:DevPixelsToCocoaPoints(aRect)];
-  }
-  else {
-    [mView setNeedsDisplayInRect:DevPixelsToCocoaPoints(aRect)];
-  }
+  [mView setNeedsDisplayInRect:DevPixelsToCocoaPoints(aRect)];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 bool
 nsChildView::WidgetTypeSupportsAcceleration()
 {
   // We need to enable acceleration in popups which contain remote layer
@@ -3326,17 +3317,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
 // initWithFrame:geckoChild:
 - (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if ((self = [super initWithFrame:inFrame])) {
     mGeckoChild = inChild;
-    mPendingDisplay = NO;
     mBlockedLastMouseDown = NO;
     mExpectingWheelStop = NO;
 
     mLastMouseDownEvent = nil;
     mLastKeyDownEvent = nil;
     mClickThroughMouseDownEvent = nil;
     mDragService = nullptr;
 
@@ -3485,17 +3475,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (void)dealloc
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   [mGLContext release];
-  [mPendingDirtyRects release];
   [mLastMouseDownEvent release];
   [mLastKeyDownEvent release];
   [mClickThroughMouseDownEvent release];
   CGImageRelease(mTopLeftCornerMask);
   ChildViewMouseTracker::OnDestroyView(self);
 
   [[NSNotificationCenter defaultCenter] removeObserver:self];
   [[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
@@ -3540,66 +3529,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
       nsIPresShell* presShell = listener->GetPresShell();
       if (presShell) {
         presShell->ReconstructFrames();
       }
     }
   }
 }
 
-- (void)setNeedsPendingDisplay
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  mPendingFullDisplay = YES;
-  if (!mPendingDisplay) {
-    [self performSelector:@selector(processPendingRedraws) withObject:nil afterDelay:0];
-    mPendingDisplay = YES;
-  }
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-- (void)setNeedsPendingDisplayInRect:(NSRect)invalidRect
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  if (!mPendingDirtyRects)
-    mPendingDirtyRects = [[NSMutableArray alloc] initWithCapacity:1];
-  [mPendingDirtyRects addObject:[NSValue valueWithRect:invalidRect]];
-  if (!mPendingDisplay) {
-    [self performSelector:@selector(processPendingRedraws) withObject:nil afterDelay:0];
-    mPendingDisplay = YES;
-  }
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-// Clears the queue of any pending invalides
-- (void)processPendingRedraws
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  if (mPendingFullDisplay) {
-    [self setNeedsDisplay:YES];
-  }
-  else if (mPendingDirtyRects) {
-    unsigned int count = [mPendingDirtyRects count];
-    for (unsigned int i = 0; i < count; ++i) {
-      [self setNeedsDisplayInRect:[[mPendingDirtyRects objectAtIndex:i] rectValue]];
-    }
-  }
-  mPendingFullDisplay = NO;
-  mPendingDisplay = NO;
-  [mPendingDirtyRects release];
-  mPendingDirtyRects = nil;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
 - (void)setNeedsDisplayInRect:(NSRect)aRect
 {
   if (![self isUsingOpenGL]) {
     [super setNeedsDisplayInRect:aRect];
     return;
   }
 
   if ([[self window] isVisible] && [self isUsingMainThreadOpenGL]) {
@@ -3658,35 +3597,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
     // inactive because at that point we've already been made active.
     // Unfortunately, acceptsFirstMouse is called for PopupWindows even when
     // their parent window is active, so ignore this on them for now.
     mClickThroughMouseDownEvent = [aEvent retain];
   }
   return YES;
 }
 
-- (void)scrollRect:(NSRect)aRect by:(NSSize)offset
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  // Update any pending dirty rects to reflect the new scroll position
-  if (mPendingDirtyRects) {
-    unsigned int count = [mPendingDirtyRects count];
-    for (unsigned int i = 0; i < count; ++i) {
-      NSRect oldRect = [[mPendingDirtyRects objectAtIndex:i] rectValue];
-      NSRect newRect = NSOffsetRect(oldRect, offset.width, offset.height);
-      [mPendingDirtyRects replaceObjectAtIndex:i
-                                    withObject:[NSValue valueWithRect:newRect]];
-    }
-  }
-  [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;
 }