Bug 1527412 - Make nsChildView::mView a ChildView*, because that's what it is. r=spohl
authorMarkus Stange <mstange@themasta.com>
Wed, 13 Feb 2019 11:14:02 +0000
changeset 458921 80265a268c68
parent 458920 82aa9a03b71d
child 458922 b09a49ab3635
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)
reviewersspohl
bugs1527412
milestone67.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 1527412 - Make nsChildView::mView a ChildView*, because that's what it is. r=spohl Differential Revision: https://phabricator.services.mozilla.com/D19556
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -521,19 +521,16 @@ class nsChildView final : public nsBaseW
   nsresult ResetPrefersReducedMotionOverrideForTest() override;
 
  protected:
   virtual ~nsChildView();
 
   void ReportMoveEvent();
   void ReportSizeEvent();
 
-  // override to create different kinds of child views. Autoreleases, so
-  // caller must retain.
-  virtual NSView* CreateCocoaView(NSRect inFrame);
   void TearDownView();
 
   virtual already_AddRefed<nsIWidget> AllocateChildPopupWidget() override {
     return nsIWidget::CreateTopLevelWindow();
   }
 
   void ConfigureAPZCTreeManager() override;
   void ConfigureAPZControllerThread() override;
@@ -562,17 +559,17 @@ class nsChildView final : public nsBaseW
     uint32_t allowedDirections;
   };
 
   SwipeInfo SendMayStartSwipe(const mozilla::PanGestureInput& aSwipeStartEvent);
   void TrackScrollEventAsSwipe(const mozilla::PanGestureInput& aSwipeStartEvent,
                                uint32_t aAllowedDirections);
 
  protected:
-  NSView<mozView>* mView;  // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG]
+  ChildView* mView;  // my parallel cocoa view, [STRONG]
   RefPtr<mozilla::widget::TextInputHandler> mTextInputHandler;
   InputContext mInputContext;
 
   NSView* mParentView;
   nsIWidget* mParentWidget;
 
 #ifdef ACCESSIBILITY
   // weak ref to this childview's associated mozAccessible for speed reasons
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -414,20 +414,17 @@ nsresult nsChildView::Create(nsIWidget* 
     // window's nsCocoaWindow object.
     mParentView = reinterpret_cast<NSView*>(aNativeParent);
   }
 
   // create our parallel NSView and hook it up to our parent. Recall
   // that NS_NATIVE_WIDGET is the NSView.
   CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mParentView);
   NSRect r = nsCocoaUtils::DevPixelsToCocoaPoints(mBounds, scaleFactor);
-  mView = [(NSView<mozView>*)CreateCocoaView(r) retain];
-  if (!mView) {
-    return NS_ERROR_FAILURE;
-  }
+  mView = [[ChildView alloc] initWithFrame:r geckoChild:this];
 
   // If this view was created in a Gecko view hierarchy, the initial state
   // is hidden.  If the view is attached only to a native NSView but has
   // no Gecko parent (as in embedding), the initial state is visible.
   if (mParentWidget)
     [mView setHidden:YES];
   else
     mVisible = true;
@@ -447,26 +444,16 @@ nsresult nsChildView::Create(nsIWidget* 
 
   mPluginFocused = false;
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-// Creates the appropriate child view. Override to create something other than
-// our |ChildView| object. Autoreleases, so caller must retain.
-NSView* nsChildView::CreateCocoaView(NSRect inFrame) {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  return [[[ChildView alloc] initWithFrame:inFrame geckoChild:this] autorelease];
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
 void nsChildView::TearDownView() {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mView) return;
 
   NSWindow* win = [mView window];
   NSResponder* responder = [win firstResponder];
 
@@ -1521,17 +1508,17 @@ nsresult nsChildView::StartPluginIME(con
   // obtain the NSEvent* we pass to InterpretKeyEvent().  This works fine in
   // non-e10s mode.  But in e10s mode TextInputHandler::HandleKeyDownEvent()
   // has already returned, so the relevant KeyEventState* (and its NSEvent*)
   // is already out of scope.  Furthermore we don't *need* to use it.
   // StartPluginIME() is only ever called to start a new IME session when none
   // currently exists.  So nested IME should never reach here, and so it should
   // be fine to use the last key-down event received by -[ChildView keyDown:]
   // (as we currently do).
-  ctiPanel->InterpretKeyEvent([(ChildView*)mView lastKeyDownEvent], aCommitted);
+  ctiPanel->InterpretKeyEvent([mView lastKeyDownEvent], aCommitted);
 
   return NS_OK;
 }
 
 void nsChildView::SetPluginFocused(bool& aFocused) {
   if (aFocused == mPluginFocused) {
     return;
   }
@@ -1714,17 +1701,17 @@ NSView<mozView>* nsChildView::GetEditorV
   return editorView;
 }
 
 #pragma mark -
 
 void nsChildView::CreateCompositor() {
   nsBaseWidget::CreateCompositor();
   if (mCompositorBridgeChild) {
-    [(ChildView*)mView setUsingOMTCompositor:true];
+    [mView setUsingOMTCompositor:true];
   }
 }
 
 void nsChildView::ConfigureAPZCTreeManager() { nsBaseWidget::ConfigureAPZCTreeManager(); }
 
 void nsChildView::ConfigureAPZControllerThread() { nsBaseWidget::ConfigureAPZControllerThread(); }
 
 LayoutDeviceIntRect nsChildView::RectContainingTitlebarControls() {
@@ -1749,20 +1736,20 @@ LayoutDeviceIntRect nsChildView::RectCon
 
 void nsChildView::PrepareWindowEffects() {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   bool canBeOpaque;
   {
     MutexAutoLock lock(mEffectsLock);
     mShowsResizeIndicator = ShowsResizeIndicator(&mResizeIndicatorRect);
-    mHasRoundedBottomCorners = [(ChildView*)mView hasRoundedBottomCorners];
-    CGFloat cornerRadius = [(ChildView*)mView cornerRadius];
+    mHasRoundedBottomCorners = [mView hasRoundedBottomCorners];
+    CGFloat cornerRadius = [mView cornerRadius];
     mDevPixelCornerRadius = cornerRadius * BackingScaleFactor();
-    mIsCoveringTitlebar = [(ChildView*)mView isCoveringTitlebar];
+    mIsCoveringTitlebar = [mView isCoveringTitlebar];
     NSInteger styleMask = [[mView window] styleMask];
     bool wasFullscreen = mIsFullscreen;
     nsCocoaWindow* windowWidget = GetXULWindowWidget();
     mIsFullscreen =
         (styleMask & NSFullScreenWindowMask) || (windowWidget && windowWidget->InFullScreenMode());
 
     canBeOpaque = mIsFullscreen && wasFullscreen;
     if (canBeOpaque && VibrancyManager::SystemSupportsVibrancy()) {
@@ -1772,17 +1759,17 @@ void nsChildView::PrepareWindowEffects()
       mTitlebarRect = RectContainingTitlebarControls();
       UpdateTitlebarCGContext();
     }
   }
 
   // If we've just transitioned into or out of full screen then update the opacity on our GLContext.
   if (canBeOpaque != mIsOpaque) {
     mIsOpaque = canBeOpaque;
-    [(ChildView*)mView setGLOpaque:canBeOpaque];
+    [mView setGLOpaque:canBeOpaque];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 void nsChildView::CleanupWindowEffects() {
   mResizerImage = nullptr;
   mCornerMaskImage = nullptr;
@@ -1838,31 +1825,31 @@ bool nsChildView::PreRender(WidgetRender
 
   // The lock makes sure that we don't attempt to tear down the view while
   // compositing. That would make us unable to call postRender on it when the
   // composition is done, thus keeping the GL context locked forever.
   mViewTearDownLock.Lock();
 
   NSOpenGLContext* glContext = GLContextCGL::Cast(gl)->GetNSOpenGLContext();
 
-  if (![(ChildView*)mView preRender:glContext]) {
+  if (![mView preRender:glContext]) {
     mViewTearDownLock.Unlock();
     return false;
   }
   return true;
 }
 
 void nsChildView::PostRender(WidgetRenderingContext* aContext) {
   UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
   gl::GLContext* gl = manager ? manager->gl() : aContext->mGL;
   if (!gl) {
     return;
   }
   NSOpenGLContext* glContext = GLContextCGL::Cast(gl)->GetNSOpenGLContext();
-  [(ChildView*)mView postRender:glContext];
+  [mView postRender:glContext];
   mViewTearDownLock.Unlock();
 }
 
 void nsChildView::DrawWindowOverlay(WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
   mozilla::UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
   if (manager) {
     DrawWindowOverlay(manager.get(), aRect);
   }
@@ -2456,31 +2443,31 @@ bool nsChildView::InitCompositor(Composi
     }
 
     return !!mGLPresenter;
   }
   return true;
 }
 
 void nsChildView::DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect) {
-  if (![(ChildView*)mView preRender:mGLPresenter->GetNSOpenGLContext()]) {
+  if (![mView preRender:mGLPresenter->GetNSOpenGLContext()]) {
     return;
   }
   mGLPresenter->BeginFrame(aRenderRect.Size());
 
   // Draw the result from the basic compositor.
   mBasicCompositorImage->Draw(mGLPresenter.get(), LayoutDeviceIntPoint(0, 0));
 
   // DrawWindowOverlay doesn't do anything for non-GL, so it didn't paint
   // anything during the basic compositor transaction. Draw the overlay now.
   DrawWindowOverlay(mGLPresenter.get(), aRenderRect);
 
   mGLPresenter->EndFrame();
 
-  [(ChildView*)mView postRender:mGLPresenter->GetNSOpenGLContext()];
+  [mView postRender:mGLPresenter->GetNSOpenGLContext()];
 }
 
 @interface NonDraggableView : NSView
 @end
 
 @implementation NonDraggableView
 - (BOOL)mouseDownCanMoveWindow {
   return NO;