Bug 1542454 - Remove support for drawing the window resizer. r=spohl
☠☠ backed out by 73e8dcb8be07 ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Mon, 22 Apr 2019 19:41:41 +0000
changeset 470397 37bd2819d3a7dc23f7661c494486a93f1d1a4977
parent 470396 19f0462bb47a3ae0e301b7ff2723407a9c178c2d
child 470398 88756a3099686f41f7601e3b7de48080a03e292a
push id35905
push userdvarga@mozilla.com
push dateTue, 23 Apr 2019 09:53:27 +0000
treeherdermozilla-central@831918f009f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1542454
milestone68.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 1542454 - Remove support for drawing the window resizer. r=spohl The last version of macOS that put resizers in window corners was 10.6. Differential Revision: https://phabricator.services.mozilla.com/D26401
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -364,17 +364,17 @@ class nsChildView final : public nsBaseW
 
   virtual int32_t RoundsWidgetCoordinatesTo() override;
 
   virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
 
   virtual void* GetNativeData(uint32_t aDataType) override;
   virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
   virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
-  virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
+  virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override { return false; }
 
   static bool ConvertStatus(nsEventStatus aStatus) {
     return aStatus == nsEventStatus_eConsumeNoDefault;
   }
   virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
 
   virtual bool WidgetTypeSupportsAcceleration() override;
   virtual bool ShouldUseOffMainThreadCompositing() override;
@@ -548,17 +548,16 @@ class nsChildView final : public nsBaseW
 
   void ConfigureAPZCTreeManager() override;
   void ConfigureAPZControllerThread() override;
 
   void DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect);
 
   // Overlay drawing functions for OpenGL drawing
   void DrawWindowOverlay(mozilla::layers::GLManager* aManager, LayoutDeviceIntRect aRect);
-  void MaybeDrawResizeIndicator(mozilla::layers::GLManager* aManager);
   void MaybeDrawRoundedCorners(mozilla::layers::GLManager* aManager,
                                const LayoutDeviceIntRect& aRect);
   void MaybeDrawTitlebar(mozilla::layers::GLManager* aManager);
 
   // Redraw the contents of mTitlebarCGContext on the main thread, as
   // determined by mDirtyTitlebarRegion.
   void UpdateTitlebarCGContext();
 
@@ -594,31 +593,28 @@ class nsChildView final : public nsBaseW
   // Protects the view from being teared down while a composition is in
   // progress on the compositor thread.
   mozilla::Mutex mViewTearDownLock;
 
   mozilla::Mutex mEffectsLock;
 
   // May be accessed from any thread, protected
   // by mEffectsLock.
-  bool mShowsResizeIndicator;
-  LayoutDeviceIntRect mResizeIndicatorRect;
   int mDevPixelCornerRadius;
   bool mIsCoveringTitlebar;
   bool mIsFullscreen;
   bool mIsOpaque;
   LayoutDeviceIntRect mTitlebarRect;
 
   // The area of mTitlebarCGContext that needs to be redrawn during the next
   // transaction. Accessed from any thread, protected by mEffectsLock.
   LayoutDeviceIntRegion mUpdatedTitlebarRegion;
   CGContextRef mTitlebarCGContext;
 
   // Compositor thread only
-  mozilla::UniquePtr<mozilla::widget::RectTextureImage> mResizerImage;
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mCornerMaskImage;
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mTitlebarImage;
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mBasicCompositorImage;
 
   // Main thread + webrender only
   mozilla::Maybe<mozilla::wr::ImageKey> mTitlebarImageKey;
   mozilla::gfx::IntSize mTitlebarImageSize;
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -317,17 +317,16 @@ struct SwipeEventQueue {
 
 nsChildView::nsChildView()
     : nsBaseWidget(),
       mView(nullptr),
       mParentView(nil),
       mParentWidget(nullptr),
       mViewTearDownLock("ChildViewTearDown"),
       mEffectsLock("WidgetEffects"),
-      mShowsResizeIndicator(false),
       mDevPixelCornerRadius{0},
       mIsCoveringTitlebar(false),
       mIsFullscreen(false),
       mIsOpaque(false),
       mTitlebarCGContext(nullptr),
       mBackingScaleFactor(0.0),
       mVisible(false),
       mDrawing(false),
@@ -905,37 +904,16 @@ void nsChildView::Resize(double aX, doub
     ReportMoveEvent();
     if (mOnDestroyCalled) return;
   }
   if (isResizing) ReportSizeEvent();
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-static const int32_t resizeIndicatorWidth = 15;
-static const int32_t resizeIndicatorHeight = 15;
-bool nsChildView::ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) {
-  NSView *topLevelView = mView, *superView = nil;
-  while ((superView = [topLevelView superview])) topLevelView = superView;
-
-  if (![[topLevelView window] showsResizeIndicator] ||
-      !([[topLevelView window] styleMask] & NSResizableWindowMask))
-    return false;
-
-  if (aResizerRect) {
-    NSSize bounds = [topLevelView bounds].size;
-    NSPoint corner = NSMakePoint(bounds.width, [topLevelView isFlipped] ? bounds.height : 0);
-    corner = [topLevelView convertPoint:corner toView:mView];
-    aResizerRect->SetRect(NSToIntRound(corner.x) - resizeIndicatorWidth,
-                          NSToIntRound(corner.y) - resizeIndicatorHeight, resizeIndicatorWidth,
-                          resizeIndicatorHeight);
-  }
-  return true;
-}
-
 nsresult nsChildView::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
                                                int32_t aNativeKeyCode, uint32_t aModifierFlags,
                                                const nsAString& aCharacters,
                                                const nsAString& aUnmodifiedCharacters,
                                                nsIObserver* aObserver) {
   AutoObserverNotifier notifier(aObserver, "keyevent");
   return mTextInputHandler->SynthesizeNativeKeyEvent(
       aNativeKeyboardLayout, aNativeKeyCode, aModifierFlags, aCharacters, aUnmodifiedCharacters);
@@ -1728,17 +1706,16 @@ LayoutDeviceIntRect nsChildView::RectCon
 }
 
 void nsChildView::PrepareWindowEffects() {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   bool canBeOpaque;
   {
     MutexAutoLock lock(mEffectsLock);
-    mShowsResizeIndicator = ShowsResizeIndicator(&mResizeIndicatorRect);
     CGFloat cornerRadius = [mView cornerRadius];
     mDevPixelCornerRadius = cornerRadius * BackingScaleFactor();
     mIsCoveringTitlebar = [mView isCoveringTitlebar];
     NSInteger styleMask = [[mView window] styleMask];
     bool wasFullscreen = mIsFullscreen;
     nsCocoaWindow* windowWidget = GetXULWindowWidget();
     mIsFullscreen =
         (styleMask & NSFullScreenWindowMask) || (windowWidget && windowWidget->InFullScreenMode());
@@ -1758,17 +1735,16 @@ void nsChildView::PrepareWindowEffects()
     mIsOpaque = canBeOpaque;
     [mView setGLOpaque:canBeOpaque];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 void nsChildView::CleanupWindowEffects() {
-  mResizerImage = nullptr;
   mCornerMaskImage = nullptr;
   mTitlebarImage = nullptr;
 }
 
 void nsChildView::AddWindowOverlayWebRenderCommands(layers::WebRenderBridgeChild* aWrBridge,
                                                     wr::DisplayListBuilder& aBuilder,
                                                     wr::IpcResourceUpdateQueue& aResources) {
   PrepareWindowEffects();
@@ -1847,80 +1823,25 @@ void nsChildView::DrawWindowOverlay(Widg
   }
 }
 
 void nsChildView::DrawWindowOverlay(GLManager* aManager, LayoutDeviceIntRect aRect) {
   GLContext* gl = aManager->gl();
   ScopedGLState scopedScissorTestState(gl, LOCAL_GL_SCISSOR_TEST, false);
 
   MaybeDrawTitlebar(aManager);
-  MaybeDrawResizeIndicator(aManager);
   MaybeDrawRoundedCorners(aManager, aRect);
 }
 
 static void ClearRegion(gfx::DrawTarget* aDT, LayoutDeviceIntRegion aRegion) {
   gfxUtils::ClipToRegion(aDT, aRegion.ToUnknownRegion());
   aDT->ClearRect(gfx::Rect(0, 0, aDT->GetSize().width, aDT->GetSize().height));
   aDT->PopClip();
 }
 
-static void DrawResizer(CGContextRef aCtx) {
-  CGContextSetShouldAntialias(aCtx, false);
-  CGPoint points[6];
-  points[0] = CGPointMake(13.0f, 4.0f);
-  points[1] = CGPointMake(3.0f, 14.0f);
-  points[2] = CGPointMake(13.0f, 8.0f);
-  points[3] = CGPointMake(7.0f, 14.0f);
-  points[4] = CGPointMake(13.0f, 12.0f);
-  points[5] = CGPointMake(11.0f, 14.0f);
-  CGContextSetRGBStrokeColor(aCtx, 0.00f, 0.00f, 0.00f, 0.15f);
-  CGContextStrokeLineSegments(aCtx, points, 6);
-
-  points[0] = CGPointMake(13.0f, 5.0f);
-  points[1] = CGPointMake(4.0f, 14.0f);
-  points[2] = CGPointMake(13.0f, 9.0f);
-  points[3] = CGPointMake(8.0f, 14.0f);
-  points[4] = CGPointMake(13.0f, 13.0f);
-  points[5] = CGPointMake(12.0f, 14.0f);
-  CGContextSetRGBStrokeColor(aCtx, 0.13f, 0.13f, 0.13f, 0.54f);
-  CGContextStrokeLineSegments(aCtx, points, 6);
-
-  points[0] = CGPointMake(13.0f, 6.0f);
-  points[1] = CGPointMake(5.0f, 14.0f);
-  points[2] = CGPointMake(13.0f, 10.0f);
-  points[3] = CGPointMake(9.0f, 14.0f);
-  points[5] = CGPointMake(13.0f, 13.9f);
-  points[4] = CGPointMake(13.0f, 14.0f);
-  CGContextSetRGBStrokeColor(aCtx, 0.84f, 0.84f, 0.84f, 0.55f);
-  CGContextStrokeLineSegments(aCtx, points, 6);
-}
-
-void nsChildView::MaybeDrawResizeIndicator(GLManager* aManager) {
-  MutexAutoLock lock(mEffectsLock);
-  if (!mShowsResizeIndicator) {
-    return;
-  }
-
-  if (!mResizerImage) {
-    mResizerImage = MakeUnique<RectTextureImage>();
-  }
-
-  LayoutDeviceIntSize size = mResizeIndicatorRect.Size();
-  mResizerImage->UpdateIfNeeded(
-      size, LayoutDeviceIntRegion(),
-      ^(gfx::DrawTarget* drawTarget, const LayoutDeviceIntRegion& updateRegion) {
-        ClearRegion(drawTarget, updateRegion);
-        gfx::BorrowedCGContext borrow(drawTarget);
-        DrawResizer(borrow.cg);
-        borrow.Finish();
-      });
-
-  mResizerImage->Draw(aManager, mResizeIndicatorRect.TopLeft());
-}
-
 static CGContextRef CreateCGContext(const LayoutDeviceIntSize& aSize) {
   CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
   CGContextRef ctx = CGBitmapContextCreate(
       NULL, aSize.width, aSize.height, 8 /* bitsPerComponent */, aSize.width * 4, cs,
       kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
   CGColorSpaceRelease(cs);
 
   CGContextTranslateCTM(ctx, 0, aSize.height);
@@ -2412,17 +2333,16 @@ already_AddRefed<gfx::DrawTarget> nsChil
 void nsChildView::EndRemoteDrawing() {
   mBasicCompositorImage->EndUpdate();
   DoRemoteComposition(mBounds);
 }
 
 void nsChildView::CleanupRemoteDrawing() {
   mBasicCompositorImage = nullptr;
   mCornerMaskImage = nullptr;
-  mResizerImage = nullptr;
   mTitlebarImage = nullptr;
   mGLPresenter = nullptr;
 }
 
 bool nsChildView::InitCompositor(Compositor* aCompositor) {
   if (aCompositor->GetBackendType() == LayersBackend::LAYERS_BASIC) {
     if (!mGLPresenter) {
       mGLPresenter = GLPresenter::CreateForWindow(this);