Skip to content

Commit a3047a1

Browse files
committed
Bug 1858562 - Part 2: Replace mIsPIPWindow with a new nsIWidget::mPiPType. r=smaug,win-reviewers,emilio,gstoll
Differential Revision: https://phabricator.services.mozilla.com/D270472
1 parent 1d76186 commit a3047a1

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

widget/InitData.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ enum class TransparencyMode : uint8_t {
7171
// WidgetMessageUtils.h
7272
};
7373

74+
// There are different types of Picture-in-Picture windows on the web
75+
enum class PiPType : uint8_t {
76+
NoPiP,
77+
// https://w3c.github.io/picture-in-picture
78+
MediaPiP
79+
};
80+
7481
// Basic struct for widget initialization data.
7582
// @see Create member function of nsIWidget
7683
struct InitData {
@@ -89,8 +96,7 @@ struct InitData {
8996
// true if the window should support an alpha channel, if available.
9097
bool mHasRemoteContent = false;
9198
bool mAlwaysOnTop = false;
92-
// Whether we're a PictureInPicture window
93-
bool mPIPWindow = false;
99+
PiPType mPiPType = PiPType::NoPiP;
94100
// True if the window is user-resizable.
95101
bool mResizable = false;
96102
bool mIsPrivate = false;

widget/gtk/nsWindow.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ nsWindow::nsWindow()
483483

484484
bool nsWindow::WaylandPipEnabled() const {
485485
#ifdef MOZ_WAYLAND
486-
return mIsPIPWindow &&
486+
return mPiPType == PiPType::MediaPiP &&
487487
StaticPrefs::widget_wayland_experimental_pip_enabled_AtStartup() &&
488488
GdkIsWaylandDisplay() && WaylandDisplayGet()->GetPipShell();
489489
#else
@@ -4455,7 +4455,7 @@ Maybe<GdkWindowEdge> nsWindow::CheckResizerEdge(
44554455
const LayoutDeviceIntPoint& aPoint) {
44564456
// Don't allow resizing maximized/fullscreen windows, nor add extra resizing
44574457
// margins on non PiP windows.
4458-
if (mSizeMode != nsSizeMode_Normal || !mIsPIPWindow) {
4458+
if (mSizeMode != nsSizeMode_Normal || mPiPType != PiPType::MediaPiP) {
44594459
return Nothing();
44604460
}
44614461

@@ -4626,7 +4626,7 @@ void nsWindow::OnMotionNotifyEvent(GdkEventMotion* aEvent) {
46264626
// If we set resize cursor on widget level keep it locked and prevent layout
46274627
// to switch it back to default (by synthetic mouse events for instance)
46284628
// until resize is finished. This affects PIP windows only.
4629-
if (mIsPIPWindow) {
4629+
if (mPiPType == PiPType::MediaPiP) {
46304630
mWidgetCursorLocked = true;
46314631
}
46324632
return;
@@ -5074,9 +5074,9 @@ void nsWindow::OnButtonReleaseEvent(GdkEventButton* aEvent) {
50745074
DispatchContextMenuEventFromMouseEvent(domButton, aEvent, refPoint);
50755075
}
50765076

5077-
// Open window manager menu on PIP window to allow user
5077+
// Open window manager menu on Media PiP window to allow user
50785078
// to place it on top / all workspaces.
5079-
if (mAlwaysOnTop && aEvent->button == 3) {
5079+
if (mPiPType == PiPType::MediaPiP && aEvent->button == 3) {
50805080
TryToShowNativeWindowMenu(aEvent);
50815081
}
50825082
}
@@ -6264,9 +6264,9 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
62646264
mGtkWindowDecoration = GetSystemGtkWindowDecoration();
62656265
}
62666266

6267-
// Don't use transparency for PictureInPicture windows.
6267+
// Don't use transparency for Media PictureInPicture windows.
62686268
bool toplevelNeedsAlphaVisual = false;
6269-
if (mWindowType == WindowType::TopLevel && !mIsPIPWindow) {
6269+
if (mWindowType == WindowType::TopLevel && mPiPType != PiPType::MediaPiP) {
62706270
toplevelNeedsAlphaVisual = IsToplevelWindowTransparent();
62716271
}
62726272

@@ -6310,8 +6310,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
63106310
gtk_window_resize(GTK_WINDOW(mShell), mClientArea.width,
63116311
mClientArea.height);
63126312
}
6313-
if (mIsPIPWindow) {
6314-
LOG(" Is PIP window\n");
6313+
if (mPiPType == PiPType::MediaPiP) {
6314+
LOG(" Is Media PiP window\n");
63156315
gtk_window_set_type_hint(GTK_WINDOW(mShell), GDK_WINDOW_TYPE_HINT_UTILITY);
63166316
} else if (mIsAlert) {
63176317
LOG(" Is alert window\n");
@@ -6622,7 +6622,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
66226622
nullptr);
66236623

66246624
LOG(" nsWindow type %d %s\n", int(mWindowType),
6625-
mIsPIPWindow ? "PIP window" : "");
6625+
mPiPType == PiPType::MediaPiP ? "Media PiP window" : "");
66266626
LOG(" mShell %p (window %p) mContainer %p mGdkWindow %p XID 0x%lx\n", mShell,
66276627
GetToplevelGdkWindow(), mContainer, mGdkWindow, GetX11Window());
66286628

@@ -7226,7 +7226,7 @@ void nsWindow::UpdateOpaqueRegionInternal() {
72267226
}
72277227

72287228
bool nsWindow::IsChromeWindowTitlebar() {
7229-
return mDrawInTitlebar && !mIsPIPWindow &&
7229+
return mDrawInTitlebar && mPiPType != PiPType::MediaPiP &&
72307230
mWindowType == WindowType::TopLevel;
72317231
}
72327232

@@ -7477,7 +7477,7 @@ nsresult nsWindow::MakeFullScreen(bool aFullScreen) {
74777477
mSizeMode != nsSizeMode_Minimized) {
74787478
mLastSizeModeBeforeFullscreen = mSizeMode;
74797479
}
7480-
if (mIsPIPWindow) {
7480+
if (mPiPType == PiPType::MediaPiP) {
74817481
gtk_window_set_type_hint(GTK_WINDOW(mShell), GDK_WINDOW_TYPE_HINT_NORMAL);
74827482
if (gUseAspectRatio) {
74837483
mAspectRatioSaved = mAspectRatio;
@@ -7499,7 +7499,7 @@ nsresult nsWindow::MakeFullScreen(bool aFullScreen) {
74997499

75007500
gtk_window_unfullscreen(GTK_WINDOW(mShell));
75017501

7502-
if (mIsPIPWindow && gUseAspectRatio) {
7502+
if (mPiPType == PiPType::MediaPiP && gUseAspectRatio) {
75037503
mAspectRatio = mAspectRatioSaved;
75047504
// ApplySizeConstraints();
75057505
}
@@ -9020,7 +9020,7 @@ void nsWindow::SetCompositorWidgetDelegate(CompositorWidgetDelegate* delegate) {
90209020
}
90219021

90229022
bool nsWindow::IsAlwaysUndecoratedWindow() const {
9023-
if (mIsPIPWindow || gKioskMode) {
9023+
if (mPiPType == PiPType::MediaPiP || gKioskMode) {
90249024
return true;
90259025
}
90269026
if (mWindowType == WindowType::Dialog &&

widget/nsIWidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ nsIWidget::nsIWidget(BorderStyle aBorderStyle)
313313
mIsFullyOccluded(false),
314314
mNeedFastSnaphot(false),
315315
mCurrentPanGestureBelongsToSwipe(false),
316-
mIsPIPWindow(false) {
316+
mPiPType(PiPType::NoPiP) {
317317
#ifdef NOISY_WIDGET_LEAKS
318318
gNumWidgets++;
319319
printf("WIDGETS+ = %d\n", gNumWidgets);
@@ -458,7 +458,7 @@ void nsIWidget::BaseCreate(nsIWidget* aParent,
458458
mPopupLevel = aInitData.mPopupLevel;
459459
mPopupType = aInitData.mPopupHint;
460460
mHasRemoteContent = aInitData.mHasRemoteContent;
461-
mIsPIPWindow = aInitData.mPIPWindow;
461+
mPiPType = aInitData.mPiPType;
462462

463463
mParent = aParent;
464464
if (mParent) {
@@ -2311,7 +2311,7 @@ WidgetWheelEvent nsIWidget::MayStartSwipeForAPZ(
23112311
WidgetWheelEvent event = aPanInput.ToWidgetEvent(this);
23122312

23132313
// Ignore swipe-to-navigation in PiP window.
2314-
if (mIsPIPWindow) {
2314+
if (mPiPType != PiPType::NoPiP) {
23152315
return event;
23162316
}
23172317

@@ -2357,7 +2357,7 @@ WidgetWheelEvent nsIWidget::MayStartSwipeForAPZ(
23572357

23582358
bool nsIWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput) {
23592359
// Ignore swipe-to-navigation in PiP window.
2360-
if (mIsPIPWindow) {
2360+
if (mPiPType != PiPType::NoPiP) {
23612361
return false;
23622362
}
23632363

widget/nsIWidget.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,8 +1415,6 @@ class nsIWidget : public nsSupportsWeakReference {
14151415
void FreeShutdownObserver();
14161416
void FreeLocalesChangedObserver();
14171417

1418-
bool IsPIPWindow() const { return mIsPIPWindow; };
1419-
14201418
public:
14211419
/**
14221420
* Set the widget's title.
@@ -2441,8 +2439,7 @@ class nsIWidget : public nsSupportsWeakReference {
24412439
// a PANGESTURE_(MAY)START event).
24422440
bool mCurrentPanGestureBelongsToSwipe;
24432441

2444-
// It's PictureInPicture window.
2445-
bool mIsPIPWindow : 1;
2442+
mozilla::widget::PiPType mPiPType;
24462443

24472444
struct InitialZoomConstraints {
24482445
InitialZoomConstraints(const uint32_t& aPresShellID,

widget/windows/nsWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ bool nsWindow::ShouldAssociateWithWinAppSDK() const {
15251525
//
15261526
// TODO(emilio): That might not be true anymore after bug 1993474,
15271527
// consider re-testing and removing that special-case.
1528-
return IsTopLevelWidget() && !mIsPIPWindow;
1528+
return IsTopLevelWidget() && mPiPType == PiPType::NoPiP;
15291529
}
15301530

15311531
bool nsWindow::AssociateWithNativeWindow() {
@@ -2805,7 +2805,7 @@ bool nsWindow::UpdateNonClientMargins(bool aReflowWindow) {
28052805
// frame sizes for left, right and bottom since Windows will automagically
28062806
// position the edges "offscreen" for maximized windows.
28072807
metrics.mOffset.top = metrics.mCaptionHeight;
2808-
} else if (mIsPIPWindow &&
2808+
} else if (mPiPType == PiPType::MediaPiP &&
28092809
!StaticPrefs::widget_windows_pip_decorations_enabled()) {
28102810
metrics.mOffset = metrics.DefaultMargins();
28112811
} else {

xpfe/appshell/nsAppShellService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ nsresult nsAppShellService::JustCreateTopWindow(
522522
nsIWebBrowserChrome::CHROME_STATUSBAR;
523523
if (widgetInitData.mWindowType == widget::WindowType::Dialog &&
524524
((aChromeMask & pipMask) == pipMask) && !(aChromeMask & barMask)) {
525-
widgetInitData.mPIPWindow = true;
525+
widgetInitData.mPiPType = mozilla::widget::PiPType::MediaPiP;
526526
}
527527
#endif
528528

0 commit comments

Comments
 (0)