Bug 1584492 - Add mPIPWindow to nsWidgetInitData and set it for PIP window on Linux/Gtk, r=mats
authorMartin Stransky <stransky@redhat.com>
Sat, 28 Sep 2019 06:55:41 +0000
changeset 495480 985e7a586265c3b74b695849812c1d658eb2e135
parent 495479 72a8d8c20180a068fd37f0bbf4619963486b0755
child 495481 061544db51260a60ad256877f91d3af0daeb3167
push id36629
push usernerli@mozilla.com
push dateSat, 28 Sep 2019 21:17:35 +0000
treeherdermozilla-central@ca5c8cdce0c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1584492
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1584492 - Add mPIPWindow to nsWidgetInitData and set it for PIP window on Linux/Gtk, r=mats Differential Revision: https://phabricator.services.mozilla.com/D47409
widget/nsWidgetInitData.h
xpfe/appshell/nsAppShellService.cpp
--- a/widget/nsWidgetInitData.h
+++ b/widget/nsWidgetInitData.h
@@ -106,17 +106,18 @@ struct nsWidgetInitData {
         mUnicode(true),
         mRTL(false),
         mNoAutoHide(false),
         mIsDragPopup(false),
         mIsAnimationSuppressed(false),
         mSupportTranslucency(false),
         mMouseTransparent(false),
         mHasRemoteContent(false),
-        mAlwaysOnTop(false) {}
+        mAlwaysOnTop(false),
+        mPIPWindow(false) {}
 
   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.
@@ -132,11 +133,13 @@ struct nsWidgetInitData {
   bool mIsAnimationSuppressed;
   // true if the window should support an alpha channel, if available.
   bool mSupportTranslucency;
   // 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;
+  // Is PictureInPicture window
+  bool mPIPWindow;
 };
 
 #endif  // nsWidgetInitData_h__
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -619,16 +619,31 @@ nsresult nsAppShellService::JustCreateTo
     widgetInitData.mWindowType = eWindowType_popup;
 
   if (aChromeMask & nsIWebBrowserChrome::CHROME_SUPPRESS_ANIMATION)
     widgetInitData.mIsAnimationSuppressed = true;
 
   if (aChromeMask & nsIWebBrowserChrome::CHROME_ALWAYS_ON_TOP)
     widgetInitData.mAlwaysOnTop = true;
 
+#ifdef MOZ_WIDGET_GTK
+  // Linux/Gtk PIP window support. It's Chrome Toplevel window, always on top
+  // and without any bar.
+  uint32_t pipMask = nsIWebBrowserChrome::CHROME_ALWAYS_ON_TOP |
+                     nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
+  uint32_t barMask = nsIWebBrowserChrome::CHROME_MENUBAR |
+                     nsIWebBrowserChrome::CHROME_TOOLBAR |
+                     nsIWebBrowserChrome::CHROME_LOCATIONBAR |
+                     nsIWebBrowserChrome::CHROME_STATUSBAR;
+  if (widgetInitData.mWindowType == eWindowType_toplevel &&
+      ((aChromeMask & pipMask) == pipMask) && !(aChromeMask & barMask)) {
+    widgetInitData.mPIPWindow = true;
+  }
+#endif
+
 #ifdef XP_MACOSX
   // Mac OS X sheet support
   // Adding CHROME_OPENAS_CHROME to sheetMask makes modal windows opened from
   // nsGlobalWindow::ShowModalDialog() be dialogs (not sheets), while modal
   // windows opened from nsPromptService::DoDialog() still are sheets.  This
   // fixes bmo bug 395465 (see nsCocoaWindow::StandardCreate() and
   // nsCocoaWindow::SetModal()).
   uint32_t sheetMask = nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |