Skip to content

Commit 7e27cb0

Browse files
committedOct 22, 2024
Bug 1924240 - Simplify nsWindow::IsTopLevelWidget() on Windows. r=win-reviewers,rkraesig
No reason to have a separate member here. Differential Revision: https://phabricator.services.mozilla.com/D225427
1 parent 3210318 commit 7e27cb0

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed
 

‎widget/windows/nsWindow.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
874874

875875
MOZ_DIAGNOSTIC_ASSERT(aInitData->mWindowType != WindowType::Invisible);
876876

877-
mIsTopWidgetWindow = aInitData->mWindowType == WindowType::Dialog ||
878-
aInitData->mWindowType == WindowType::TopLevel;
879877
mBounds = aRect;
880878

881879
// Ensure that the toolkit is created.
@@ -1529,7 +1527,7 @@ nsWindow* nsWindow::GetParentWindow(bool aIncludeOwner) {
15291527
}
15301528

15311529
nsWindow* nsWindow::GetParentWindowBase(bool aIncludeOwner) {
1532-
if (mIsTopWidgetWindow) {
1530+
if (IsTopLevelWidget()) {
15331531
// Must use a flag instead of mWindowType to tell if the window is the
15341532
// owned by the topmost widget, because a child window can be embedded
15351533
// inside a HWND which is not associated with a nsIWidget.
@@ -1960,7 +1958,7 @@ void nsWindow::Move(double aX, double aY) {
19601958
#ifdef DEBUG
19611959
// complain if a window is moved offscreen (legal, but potentially
19621960
// worrisome)
1963-
if (mIsTopWidgetWindow) { // only a problem for top-level windows
1961+
if (IsTopLevelWidget()) { // only a problem for top-level windows
19641962
// Make sure this window is actually on the screen before we move it
19651963
// XXX: Needs multiple monitor support
19661964
HDC dc = ::GetDC(mWnd);
@@ -2267,8 +2265,10 @@ void nsWindow::SuppressAnimation(bool aSuppress) {
22672265
// Position (aX, aY) is specified in Windows screen (logical) pixels,
22682266
// except when using per-monitor DPI, in which case it's device pixels.
22692267
void nsWindow::ConstrainPosition(DesktopIntPoint& aPoint) {
2270-
if (!mIsTopWidgetWindow) // only a problem for top-level windows
2268+
if (!IsTopLevelWidget()) {
2269+
// only a problem for top-level windows
22712270
return;
2271+
}
22722272

22732273
double dpiScale = GetDesktopToDeviceScale().scale;
22742274

@@ -2748,9 +2748,7 @@ bool nsWindow::UpdateNonClientMargins(bool aReflowWindow) {
27482748
}
27492749

27502750
nsresult nsWindow::SetNonClientMargins(const LayoutDeviceIntMargin& margins) {
2751-
if (!mIsTopWidgetWindow || mBorderStyle == BorderStyle::None ||
2752-
margins.top < -1 || margins.bottom < -1 || margins.left < -1 ||
2753-
margins.right < -1) {
2751+
if (!IsTopLevelWidget() || mBorderStyle == BorderStyle::None) {
27542752
return NS_ERROR_INVALID_ARG;
27552753
}
27562754

@@ -5642,7 +5640,7 @@ bool nsWindow::ProcessMessageInternal(UINT msg, WPARAM& wParam, LPARAM& lParam,
56425640
} else {
56435641
sJustGotDeactivate = true;
56445642
}
5645-
if (mIsTopWidgetWindow) {
5643+
if (IsTopLevelWidget()) {
56465644
mLastKeyboardLayout = KeyboardLayout::GetLayout();
56475645
}
56485646
} else {

‎widget/windows/nsWindow.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ class nsWindow final : public nsBaseWidget {
187187
*/
188188
nsWindow* GetParentWindowBase(bool aIncludeOwner);
189189

190-
/*
191-
* Return true if this is a top level widget.
192-
*/
193-
bool IsTopLevelWidget() { return mIsTopWidgetWindow; }
190+
bool IsTopLevelWidget() const {
191+
return mWindowType == WindowType::TopLevel ||
192+
mWindowType == WindowType::Dialog;
193+
}
194194

195195
// nsIWidget interface
196196
using nsBaseWidget::Create; // for Create signature not overridden here
@@ -770,7 +770,6 @@ class nsWindow final : public nsBaseWidget {
770770
mozilla::Maybe<WNDPROC> mPrevWndProc;
771771
IMEContext mDefaultIMC;
772772
HDEVNOTIFY mDeviceNotifyHandle = nullptr;
773-
bool mIsTopWidgetWindow = false;
774773
bool mInDtor = false;
775774
bool mIsVisible = false;
776775
bool mIsCloaked = false;

0 commit comments

Comments
 (0)
Failed to load comments.