Skip to content

Commit

Permalink
Bug 1772432 - Clean up nsWidgetInitData. r=stransky
Browse files Browse the repository at this point in the history
Use inline initializers, remove dead code, use consistent naming.

No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D148209
  • Loading branch information
emilio committed Jun 3, 2022
1 parent e937533 commit b44d1c0
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 57 deletions.
2 changes: 1 addition & 1 deletion layout/xul/nsMenuPopupFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ nsresult nsMenuPopupFrame::CreateWidgetForView(nsView* aView) {
nsWidgetInitData widgetData;
widgetData.mWindowType = eWindowType_popup;
widgetData.mBorderStyle = eBorderStyle_default;
widgetData.clipSiblings = true;
widgetData.mClipSiblings = true;
widgetData.mPopupHint = mPopupType;
widgetData.mNoAutoHide = IsNoAutoHide();

Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/browser/nsWebBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ nsIWidget* nsWebBrowser::EnsureWidget() {
}

nsWidgetInitData widgetInit;
widgetInit.clipChildren = true;
widgetInit.mClipChildren = true;
widgetInit.mWindowType = eWindowType_child;
LayoutDeviceIntRect bounds(0, 0, 0, 0);

Expand Down
4 changes: 2 additions & 2 deletions view/nsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ static int32_t FindNonAutoZIndex(nsView* aView) {
struct DefaultWidgetInitData : public nsWidgetInitData {
DefaultWidgetInitData() : nsWidgetInitData() {
mWindowType = eWindowType_child;
clipChildren = true;
clipSiblings = true;
mClipChildren = true;
mClipSiblings = true;
}
};

Expand Down
5 changes: 1 addition & 4 deletions widget/nsBaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ nsBaseWidget::nsBaseWidget(nsBorderStyle aBorderStyle)
mPopupLevel(ePopupLevelTop),
mPopupType(ePopupTypeAny),
mHasRemoteContent(false),
mFissionWindow(false),
mUpdateCursor(true),
mUseAttachedEvents(false),
mIMEHasFocus(false),
Expand Down Expand Up @@ -414,14 +413,12 @@ nsBaseWidget::~nsBaseWidget() {
//
//-------------------------------------------------------------------------
void nsBaseWidget::BaseCreate(nsIWidget* aParent, nsWidgetInitData* aInitData) {
// keep a reference to the device context
if (nullptr != aInitData) {
if (aInitData) {
mWindowType = aInitData->mWindowType;
mBorderStyle = aInitData->mBorderStyle;
mPopupLevel = aInitData->mPopupLevel;
mPopupType = aInitData->mPopupHint;
mHasRemoteContent = aInitData->mHasRemoteContent;
mFissionWindow = aInitData->mFissionWindow;
}

if (aParent) {
Expand Down
1 change: 0 additions & 1 deletion widget/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
nsPopupType mPopupType;
SizeConstraints mSizeConstraints;
bool mHasRemoteContent;
bool mFissionWindow;

bool mUpdateCursor;
bool mUseAttachedEvents;
Expand Down
62 changes: 19 additions & 43 deletions widget/nsWidgetInitData.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,57 +88,33 @@ enum nsBorderStyle {
*/

struct nsWidgetInitData {
nsWidgetInitData()
: mWindowType(eWindowType_child),
mBorderStyle(eBorderStyle_default),
mPopupHint(ePopupTypePanel),
mPopupLevel(ePopupLevelTop),
mScreenId(0),
clipChildren(false),
clipSiblings(false),
mDropShadow(false),
mRTL(false),
mNoAutoHide(false),
mIsDragPopup(false),
mIsAnimationSuppressed(false),
mSupportTranslucency(false),
mMouseTransparent(false),
mHasRemoteContent(false),
mAlwaysOnTop(false),
mPIPWindow(false),
mFissionWindow(false),
mResizable(false),
mIsPrivate(false) {}
nsWidgetInitData() = default;

nsWindowType mWindowType;
nsBorderStyle mBorderStyle;
nsPopupType mPopupHint;
nsPopupLevel mPopupLevel;
// B2G multi-screen support. Screen ID is for differentiating screens of
// windows, and due to the hardware limitation, it is platform-specific for
// now, which align with the value of display type defined in HWC.
uint32_t mScreenId;
nsWindowType mWindowType = eWindowType_child;
nsBorderStyle mBorderStyle = eBorderStyle_default;
nsPopupType mPopupHint = ePopupTypePanel;
nsPopupLevel mPopupLevel = ePopupLevelTop;
// when painting exclude area occupied by child windows and sibling windows
bool clipChildren, clipSiblings, mDropShadow;
bool mRTL;
bool mNoAutoHide; // true for noautohide panels
bool mIsDragPopup; // true for drag feedback panels
bool mClipChildren = false;
bool mClipSiblings = false;
bool mDropShadow = false;
bool mRTL = false;
bool mNoAutoHide = false; // true for noautohide panels
bool mIsDragPopup = false; // true for drag feedback panels
// true if window creation animation is suppressed, e.g. for session restore
bool mIsAnimationSuppressed;
bool mIsAnimationSuppressed = false;
// true if the window should support an alpha channel, if available.
bool mSupportTranslucency;
bool mSupportTranslucency = false;
// true if the window should be transparent to mouse events. Currently this is
// only valid for eWindowType_popup widgets
bool mMouseTransparent;
bool mHasRemoteContent;
bool mAlwaysOnTop;
bool mMouseTransparent = false;
bool mHasRemoteContent = false;
bool mAlwaysOnTop = false;
// Is PictureInPicture window
bool mPIPWindow;
// True if fission is enabled for this window
bool mFissionWindow;
bool mPIPWindow = false;
// True if the window is user-resizable.
bool mResizable;
bool mIsPrivate;
bool mResizable = false;
bool mIsPrivate = false;
};

#endif // nsWidgetInitData_h__
4 changes: 2 additions & 2 deletions widget/windows/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,12 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
style &= ~0x40000000; // WS_CHILDWINDOW
} else {
// See if the caller wants to explictly set clip children and clip siblings
if (aInitData->clipChildren) {
if (aInitData->mClipChildren) {
style |= WS_CLIPCHILDREN;
} else {
style &= ~WS_CLIPCHILDREN;
}
if (aInitData->clipSiblings) {
if (aInitData->mClipSiblings) {
style |= WS_CLIPSIBLINGS;
}
}
Expand Down
3 changes: 0 additions & 3 deletions xpfe/appshell/nsAppShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,6 @@ nsresult nsAppShellService::JustCreateTopWindow(
if (aChromeMask & nsIWebBrowserChrome::CHROME_ALWAYS_ON_TOP)
widgetInitData.mAlwaysOnTop = true;

if (aChromeMask & nsIWebBrowserChrome::CHROME_FISSION_WINDOW)
widgetInitData.mFissionWindow = true;

if (aChromeMask & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW)
widgetInitData.mHasRemoteContent = true;

Expand Down

0 comments on commit b44d1c0

Please sign in to comment.