tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a3047a1c85a50f15320dfef85e74bcd5f8f84896
parent 1d7618633a0ed89ba69cc4666b16581e56f2c5da
Author: Vincent Hilla <vhilla@mozilla.com>
Date:   Tue, 16 Dec 2025 18:12:06 +0000

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

Diffstat:
Mwidget/InitData.h | 10++++++++--
Mwidget/gtk/nsWindow.cpp | 28++++++++++++++--------------
Mwidget/nsIWidget.cpp | 8++++----
Mwidget/nsIWidget.h | 5+----
Mwidget/windows/nsWindow.cpp | 4++--
Mxpfe/appshell/nsAppShellService.cpp | 2+-
6 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/widget/InitData.h b/widget/InitData.h @@ -71,6 +71,13 @@ enum class TransparencyMode : uint8_t { // WidgetMessageUtils.h }; +// There are different types of Picture-in-Picture windows on the web +enum class PiPType : uint8_t { + NoPiP, + // https://w3c.github.io/picture-in-picture + MediaPiP +}; + // Basic struct for widget initialization data. // @see Create member function of nsIWidget struct InitData { @@ -89,8 +96,7 @@ struct InitData { // true if the window should support an alpha channel, if available. bool mHasRemoteContent = false; bool mAlwaysOnTop = false; - // Whether we're a PictureInPicture window - bool mPIPWindow = false; + PiPType mPiPType = PiPType::NoPiP; // True if the window is user-resizable. bool mResizable = false; bool mIsPrivate = false; diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp @@ -483,7 +483,7 @@ nsWindow::nsWindow() bool nsWindow::WaylandPipEnabled() const { #ifdef MOZ_WAYLAND - return mIsPIPWindow && + return mPiPType == PiPType::MediaPiP && StaticPrefs::widget_wayland_experimental_pip_enabled_AtStartup() && GdkIsWaylandDisplay() && WaylandDisplayGet()->GetPipShell(); #else @@ -4455,7 +4455,7 @@ Maybe<GdkWindowEdge> nsWindow::CheckResizerEdge( const LayoutDeviceIntPoint& aPoint) { // Don't allow resizing maximized/fullscreen windows, nor add extra resizing // margins on non PiP windows. - if (mSizeMode != nsSizeMode_Normal || !mIsPIPWindow) { + if (mSizeMode != nsSizeMode_Normal || mPiPType != PiPType::MediaPiP) { return Nothing(); } @@ -4626,7 +4626,7 @@ void nsWindow::OnMotionNotifyEvent(GdkEventMotion* aEvent) { // If we set resize cursor on widget level keep it locked and prevent layout // to switch it back to default (by synthetic mouse events for instance) // until resize is finished. This affects PIP windows only. - if (mIsPIPWindow) { + if (mPiPType == PiPType::MediaPiP) { mWidgetCursorLocked = true; } return; @@ -5074,9 +5074,9 @@ void nsWindow::OnButtonReleaseEvent(GdkEventButton* aEvent) { DispatchContextMenuEventFromMouseEvent(domButton, aEvent, refPoint); } - // Open window manager menu on PIP window to allow user + // Open window manager menu on Media PiP window to allow user // to place it on top / all workspaces. - if (mAlwaysOnTop && aEvent->button == 3) { + if (mPiPType == PiPType::MediaPiP && aEvent->button == 3) { TryToShowNativeWindowMenu(aEvent); } } @@ -6264,9 +6264,9 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect, mGtkWindowDecoration = GetSystemGtkWindowDecoration(); } - // Don't use transparency for PictureInPicture windows. + // Don't use transparency for Media PictureInPicture windows. bool toplevelNeedsAlphaVisual = false; - if (mWindowType == WindowType::TopLevel && !mIsPIPWindow) { + if (mWindowType == WindowType::TopLevel && mPiPType != PiPType::MediaPiP) { toplevelNeedsAlphaVisual = IsToplevelWindowTransparent(); } @@ -6310,8 +6310,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect, gtk_window_resize(GTK_WINDOW(mShell), mClientArea.width, mClientArea.height); } - if (mIsPIPWindow) { - LOG(" Is PIP window\n"); + if (mPiPType == PiPType::MediaPiP) { + LOG(" Is Media PiP window\n"); gtk_window_set_type_hint(GTK_WINDOW(mShell), GDK_WINDOW_TYPE_HINT_UTILITY); } else if (mIsAlert) { LOG(" Is alert window\n"); @@ -6622,7 +6622,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect, nullptr); LOG(" nsWindow type %d %s\n", int(mWindowType), - mIsPIPWindow ? "PIP window" : ""); + mPiPType == PiPType::MediaPiP ? "Media PiP window" : ""); LOG(" mShell %p (window %p) mContainer %p mGdkWindow %p XID 0x%lx\n", mShell, GetToplevelGdkWindow(), mContainer, mGdkWindow, GetX11Window()); @@ -7226,7 +7226,7 @@ void nsWindow::UpdateOpaqueRegionInternal() { } bool nsWindow::IsChromeWindowTitlebar() { - return mDrawInTitlebar && !mIsPIPWindow && + return mDrawInTitlebar && mPiPType != PiPType::MediaPiP && mWindowType == WindowType::TopLevel; } @@ -7477,7 +7477,7 @@ nsresult nsWindow::MakeFullScreen(bool aFullScreen) { mSizeMode != nsSizeMode_Minimized) { mLastSizeModeBeforeFullscreen = mSizeMode; } - if (mIsPIPWindow) { + if (mPiPType == PiPType::MediaPiP) { gtk_window_set_type_hint(GTK_WINDOW(mShell), GDK_WINDOW_TYPE_HINT_NORMAL); if (gUseAspectRatio) { mAspectRatioSaved = mAspectRatio; @@ -7499,7 +7499,7 @@ nsresult nsWindow::MakeFullScreen(bool aFullScreen) { gtk_window_unfullscreen(GTK_WINDOW(mShell)); - if (mIsPIPWindow && gUseAspectRatio) { + if (mPiPType == PiPType::MediaPiP && gUseAspectRatio) { mAspectRatio = mAspectRatioSaved; // ApplySizeConstraints(); } @@ -9020,7 +9020,7 @@ void nsWindow::SetCompositorWidgetDelegate(CompositorWidgetDelegate* delegate) { } bool nsWindow::IsAlwaysUndecoratedWindow() const { - if (mIsPIPWindow || gKioskMode) { + if (mPiPType == PiPType::MediaPiP || gKioskMode) { return true; } if (mWindowType == WindowType::Dialog && diff --git a/widget/nsIWidget.cpp b/widget/nsIWidget.cpp @@ -313,7 +313,7 @@ nsIWidget::nsIWidget(BorderStyle aBorderStyle) mIsFullyOccluded(false), mNeedFastSnaphot(false), mCurrentPanGestureBelongsToSwipe(false), - mIsPIPWindow(false) { + mPiPType(PiPType::NoPiP) { #ifdef NOISY_WIDGET_LEAKS gNumWidgets++; printf("WIDGETS+ = %d\n", gNumWidgets); @@ -458,7 +458,7 @@ void nsIWidget::BaseCreate(nsIWidget* aParent, mPopupLevel = aInitData.mPopupLevel; mPopupType = aInitData.mPopupHint; mHasRemoteContent = aInitData.mHasRemoteContent; - mIsPIPWindow = aInitData.mPIPWindow; + mPiPType = aInitData.mPiPType; mParent = aParent; if (mParent) { @@ -2311,7 +2311,7 @@ WidgetWheelEvent nsIWidget::MayStartSwipeForAPZ( WidgetWheelEvent event = aPanInput.ToWidgetEvent(this); // Ignore swipe-to-navigation in PiP window. - if (mIsPIPWindow) { + if (mPiPType != PiPType::NoPiP) { return event; } @@ -2357,7 +2357,7 @@ WidgetWheelEvent nsIWidget::MayStartSwipeForAPZ( bool nsIWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput) { // Ignore swipe-to-navigation in PiP window. - if (mIsPIPWindow) { + if (mPiPType != PiPType::NoPiP) { return false; } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h @@ -1415,8 +1415,6 @@ class nsIWidget : public nsSupportsWeakReference { void FreeShutdownObserver(); void FreeLocalesChangedObserver(); - bool IsPIPWindow() const { return mIsPIPWindow; }; - public: /** * Set the widget's title. @@ -2441,8 +2439,7 @@ class nsIWidget : public nsSupportsWeakReference { // a PANGESTURE_(MAY)START event). bool mCurrentPanGestureBelongsToSwipe; - // It's PictureInPicture window. - bool mIsPIPWindow : 1; + mozilla::widget::PiPType mPiPType; struct InitialZoomConstraints { InitialZoomConstraints(const uint32_t& aPresShellID, diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp @@ -1525,7 +1525,7 @@ bool nsWindow::ShouldAssociateWithWinAppSDK() const { // // TODO(emilio): That might not be true anymore after bug 1993474, // consider re-testing and removing that special-case. - return IsTopLevelWidget() && !mIsPIPWindow; + return IsTopLevelWidget() && mPiPType == PiPType::NoPiP; } bool nsWindow::AssociateWithNativeWindow() { @@ -2805,7 +2805,7 @@ bool nsWindow::UpdateNonClientMargins(bool aReflowWindow) { // frame sizes for left, right and bottom since Windows will automagically // position the edges "offscreen" for maximized windows. metrics.mOffset.top = metrics.mCaptionHeight; - } else if (mIsPIPWindow && + } else if (mPiPType == PiPType::MediaPiP && !StaticPrefs::widget_windows_pip_decorations_enabled()) { metrics.mOffset = metrics.DefaultMargins(); } else { diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp @@ -522,7 +522,7 @@ nsresult nsAppShellService::JustCreateTopWindow( nsIWebBrowserChrome::CHROME_STATUSBAR; if (widgetInitData.mWindowType == widget::WindowType::Dialog && ((aChromeMask & pipMask) == pipMask) && !(aChromeMask & barMask)) { - widgetInitData.mPIPWindow = true; + widgetInitData.mPiPType = mozilla::widget::PiPType::MediaPiP; } #endif