Bug 1763023 - Push nsBaseWidget::mSizeMode into child classes r=handyman

This member is no longer used on Windows, and having it in the
base class doesn't provide a real abstraction anyway since
the child classes will break if anything about it is changed.

Differential Revision: https://phabricator.services.mozilla.com/D145132
This commit is contained in:
Chris Martin 2022-05-02 14:06:17 +00:00
parent fef480449a
commit 80881746de
18 changed files with 37 additions and 20 deletions

View File

@ -66,6 +66,10 @@ class MockWidget : public nsBaseWidget {
virtual void Enable(bool aState) override {}
virtual bool IsEnabled() const override { return true; }
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override { mSizeMode = aMode; }
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override {}
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override {}
virtual nsresult SetTitle(const nsAString& title) override { return NS_OK; }
@ -83,6 +87,8 @@ class MockWidget : public nsBaseWidget {
private:
~MockWidget() = default;
nsSizeMode mSizeMode = nsSizeMode_Normal;
int mCompWidth;
int mCompHeight;
};

View File

@ -86,6 +86,7 @@ PuppetWidget::PuppetWidget(BrowserChild* aBrowserChild)
mDefaultScale(-1),
mEnabled(false),
mVisible(false),
mSizeMode(nsSizeMode_Normal),
mNeedIMEStateInit(false),
mIgnoreCompositionEvents(false) {
// Setting 'Unknown' means "not yet cached".

View File

@ -114,6 +114,9 @@ class PuppetWidget : public nsBaseWidget,
virtual void Enable(bool aState) override { mEnabled = aState; }
virtual bool IsEnabled() const override { return mEnabled; }
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override { mSizeMode = aMode; }
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
@ -398,6 +401,8 @@ class PuppetWidget : public nsBaseWidget,
bool mVisible;
private:
nsSizeMode mSizeMode;
bool mNeedIMEStateInit;
// When remote process requests to commit/cancel a composition, the
// composition may have already been committed in the main process. In such

View File

@ -1787,6 +1787,7 @@ nsWindow::nsWindow()
mIsVisible(false),
mParent(nullptr),
mDynamicToolbarMaxHeight(0),
mSizeMode(nsSizeMode_Normal),
mIsFullScreen(false),
mCompositorWidgetDelegate(nullptr) {}
@ -2110,7 +2111,7 @@ void nsWindow::SetSizeMode(nsSizeMode aMode) {
return;
}
nsBaseWidget::SetSizeMode(aMode);
mSizeMode = aMode;
switch (aMode) {
case nsSizeMode_Minimized:

View File

@ -150,6 +150,7 @@ class nsWindow final : public nsBaseWidget {
virtual void Resize(double aX, double aY, double aWidth, double aHeight,
bool aRepaint) override;
void SetZIndex(int32_t aZIndex) override;
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override;
virtual void Enable(bool aState) override;
virtual bool IsEnabled() const override;
@ -255,6 +256,7 @@ class nsWindow final : public nsBaseWidget {
mozilla::ScreenIntCoord mDynamicToolbarMaxHeight;
mozilla::ScreenIntMargin mSafeAreaInsets;
nsSizeMode mSizeMode;
bool mIsFullScreen;
bool UseExternalCompositingSurface() const override { return true; }

View File

@ -308,6 +308,10 @@ class nsChildView final : public nsBaseWidget {
virtual void Enable(bool aState) override;
virtual bool IsEnabled() const override;
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override { mSizeMode = aMode; }
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
virtual LayoutDeviceIntRect GetBounds() override;
virtual LayoutDeviceIntRect GetClientBounds() override;
@ -554,6 +558,7 @@ class nsChildView final : public nsBaseWidget {
mutable CGFloat mBackingScaleFactor;
bool mVisible;
nsSizeMode mSizeMode;
bool mDrawing;
bool mIsDispatchPaint; // Is a paint event being dispatched

View File

@ -222,6 +222,7 @@ nsChildView::nsChildView()
mCompositingLock("ChildViewCompositing"),
mBackingScaleFactor(0.0),
mVisible(false),
mSizeMode(nsSizeMode_Normal),
mDrawing(false),
mIsDispatchPaint(false) {}

View File

@ -256,6 +256,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual void ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) override;
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
virtual void Move(double aX, double aY) override;
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override;
virtual void GetWorkspaceID(nsAString& workspaceID) override;
virtual void MoveToWorkspace(const nsAString& workspaceID) override;
@ -404,6 +405,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
bool mWindowMadeHere; // true if we created the window, false for embedding
bool mSheetNeedsShow; // if this is a sheet, are we waiting to be shown?
// this is used for sibling sheet contention only
nsSizeMode mSizeMode;
bool mInFullScreenMode;
bool mInFullScreenTransition; // true from the request to enter/exit fullscreen
// (MakeFullScreen() call) to EnteredFullScreen()

View File

@ -136,6 +136,7 @@ nsCocoaWindow::nsCocoaWindow()
mAnimationType(nsIWidget::eGenericWindowAnimation),
mWindowMadeHere(false),
mSheetNeedsShow(false),
mSizeMode(nsSizeMode_Normal),
mInFullScreenMode(false),
mInFullScreenTransition(false),
mIgnoreOcclusionCount(0),

View File

@ -2457,7 +2457,7 @@ void nsWindow::SetSizeMode(nsSizeMode aMode) {
LOG("nsWindow::SetSizeMode %d\n", aMode);
// Save the requested state.
nsBaseWidget::SetSizeMode(aMode);
mSizeMode = aMode;
// return if there's no shell or our current state is the same as
// the mode we were just set to.

View File

@ -161,6 +161,7 @@ class nsWindow final : public nsBaseWidget {
bool IsEnabled() const override;
void SetZIndex(int32_t aZIndex) override;
nsSizeMode SizeMode() override { return mSizeMode; }
void SetSizeMode(nsSizeMode aMode) override;
void GetWorkspaceID(nsAString& workspaceID) override;
void MoveToWorkspace(const nsAString& workspaceID) override;
@ -526,6 +527,7 @@ class nsWindow final : public nsBaseWidget {
// in some reasonable time when page content is not updated.
int mCompositorPauseTimeoutID = 0;
nsSizeMode mSizeMode = nsSizeMode_Normal;
nsSizeMode mSizeState = nsSizeMode_Normal;
float mAspectRatio = 0.0f;
float mAspectRatioSaved = 0.0f;

View File

@ -71,6 +71,7 @@ HeadlessWidget::HeadlessWidget()
mDestroyed(false),
mTopLevel(nullptr),
mCompositorWidget(nullptr),
mSizeMode(nsSizeMode_Normal),
mLastSizeMode(nsSizeMode_Normal),
mEffectiveSizeMode(nsSizeMode_Normal),
mRestoreBounds(0, 0, 0, 0) {
@ -300,7 +301,7 @@ void HeadlessWidget::SetSizeMode(nsSizeMode aMode) {
return;
}
nsBaseWidget::SetSizeMode(aMode);
mSizeMode = aMode;
// Normally in real widget backends a window event would be triggered that
// would cause the window manager to handle resizing the window. In headless

View File

@ -70,6 +70,7 @@ class HeadlessWidget : public nsBaseWidget {
virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
virtual void Resize(double aX, double aY, double aWidth, double aHeight,
bool aRepaint) override;
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override;
virtual nsresult MakeFullScreen(bool aFullScreen) override;
virtual void Enable(bool aState) override;
@ -141,6 +142,7 @@ class HeadlessWidget : public nsBaseWidget {
bool mDestroyed;
nsIWidget* mTopLevel;
HeadlessCompositorWidget* mCompositorWidget;
nsSizeMode mSizeMode;
// The size mode before entering fullscreen mode.
nsSizeMode mLastSizeMode;
// The last size mode set while the window was visible.

View File

@ -142,7 +142,6 @@ nsBaseWidget::nsBaseWidget(nsBorderStyle aBorderStyle)
mBorderStyle(aBorderStyle),
mBounds(0, 0, 0, 0),
mOriginalBounds(nullptr),
mSizeMode(nsSizeMode_Normal),
mIsTiled(false),
mPopupLevel(ePopupLevelTop),
mPopupType(ePopupTypeAny),
@ -691,18 +690,6 @@ void nsBaseWidget::SetZIndex(int32_t aZIndex) {
}
}
//-------------------------------------------------------------------------
//
// Maximize, minimize or restore the window. The BaseWidget implementation
// merely stores the state.
//
//-------------------------------------------------------------------------
void nsBaseWidget::SetSizeMode(nsSizeMode aMode) {
MOZ_ASSERT(aMode == nsSizeMode_Normal || aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized || aMode == nsSizeMode_Fullscreen);
mSizeMode = aMode;
}
void nsBaseWidget::GetWorkspaceID(nsAString& workspaceID) {
workspaceID.Truncate();
}

View File

@ -182,8 +182,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget* aWidget,
bool aActivate) override {}
void SetSizeMode(nsSizeMode aMode) override;
nsSizeMode SizeMode() override { return mSizeMode; }
void GetWorkspaceID(nsAString& workspaceID) override;
void MoveToWorkspace(const nsAString& workspaceID) override;
bool IsTiled() const override { return mIsTiled; }
@ -719,7 +717,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
nsBorderStyle mBorderStyle;
LayoutDeviceIntRect mBounds;
LayoutDeviceIntRect* mOriginalBounds;
nsSizeMode mSizeMode;
bool mIsTiled;
nsPopupLevel mPopupLevel;
nsPopupType mPopupType;

View File

@ -30,6 +30,7 @@ class MockWinWidget : public nsBaseWidget {
HWND GetWnd() { return mWnd; }
nsSizeMode SizeMode() override;
void SetSizeMode(nsSizeMode aMode) override {}
void* GetNativeData(uint32_t aDataType) override { return nullptr; }

View File

@ -42,6 +42,7 @@ class nsWindow final : public nsBaseWidget {
virtual void* GetNativeData(uint32_t aDataType) override;
virtual void Move(double aX, double aY) override;
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual void SetSizeMode(nsSizeMode aMode) override;
void EnteredFullScreen(bool aFullScreen);
virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
@ -94,6 +95,7 @@ class nsWindow final : public nsBaseWidget {
ChildView* mNativeView;
bool mVisible;
nsSizeMode mSizeMode;
nsTArray<nsWindow*> mChildren;
nsWindow* mParent;
InputContext mInputContext;

View File

@ -378,7 +378,8 @@ class nsAutoRetainUIKitObject {
}
@end
nsWindow::nsWindow() : mNativeView(nullptr), mVisible(false), mParent(nullptr) {}
nsWindow::nsWindow()
: mNativeView(nullptr), mVisible(false), mSizeMode(nsSizeMode_Normal), mParent(nullptr) {}
nsWindow::~nsWindow() {
[mNativeView widgetDestroyed]; // Safe if mNativeView is nil.