Backed out 2 changesets (bug 1567434) for build bustages at nsWindow.cpp:3587:53. CLOSED TREE
authorBrindusan Cristian <cbrindusan@mozilla.com>
Mon, 05 Aug 2019 12:23:04 +0300
changeset 486158 2d66b2b14eb82a254cf7c21732eb2c2b809ebce9
parent 486157 2d2938a3bee655c0f6ff21c6c0df29d60574183b
child 486159 af78e873d1e8b2715c05b44feaab5a5c95ebd7f6
push id36391
push usermalexandru@mozilla.com
push dateMon, 05 Aug 2019 15:55:27 +0000
treeherdermozilla-central@9c91b33629b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1567434
milestone70.0a1
backs out10925a6df9b39d675c08879b68f21f04675898d2
1cd94e91245cbc8eb5a5b58d99b4141e78195b74
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
Backed out 2 changesets (bug 1567434) for build bustages at nsWindow.cpp:3587:53. CLOSED TREE Backed out changeset 10925a6df9b3 (bug 1567434) Backed out changeset 1cd94e91245c (bug 1567434)
widget/gtk/WindowSurfaceWayland.cpp
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -611,16 +611,18 @@ WindowBackBuffer* WindowSurfaceWayland::
     // There's a chance that scale factor has been changed
     // when buffer size changed
     mWaylandBufferFullScreenDamage = true;
     mNeedScaleFactorUpdate = true;
     return mWaylandBuffer;
   }
 
   if (!aFullScreenUpdate) {
+    NS_WARNING(
+        "We can't create a new Wayland buffer for non-fullscreen updates!");
     return nullptr;
   }
 
   // Front buffer is used by compositor, select or create a new back buffer
   int availableBuffer;
   for (availableBuffer = 0; availableBuffer < BACK_BUFFER_NUM;
        availableBuffer++) {
     if (!mBackupBuffer[availableBuffer]) {
@@ -667,16 +669,18 @@ already_AddRefed<gfx::DrawTarget> Window
     int aWidth, int aHeight, bool aClearBuffer, bool aFullScreenUpdate) {
   WindowBackBuffer* buffer =
       GetWaylandBufferToDraw(aWidth, aHeight, aFullScreenUpdate);
 
   LOGWAYLAND(("%s [%p] Got buffer %p\n", __PRETTY_FUNCTION__, (void*)this,
               (void*)buffer));
 
   if (!buffer) {
+    NS_WARNING(
+        "WindowSurfaceWayland::LockWaylandBuffer(): No buffer available");
     return nullptr;
   }
 
   if (aClearBuffer) {
     buffer->Clear();
   }
 
   return buffer->Lock();
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -396,17 +396,16 @@ nsWindow::nsWindow() {
   mHandleTouchEvent = false;
 #endif
   mIsDragPopup = false;
   mIsX11Display = GDK_IS_X11_DISPLAY(gdk_display_get_default());
 
   mContainer = nullptr;
   mGdkWindow = nullptr;
   mShell = nullptr;
-  mToplevelParentWindow = nullptr;
   mCompositorWidgetDelegate = nullptr;
   mHasMappedToplevel = false;
   mIsFullyObscured = false;
   mRetryPointerGrab = false;
   mWindowType = eWindowType_child;
   mSizeState = nsSizeMode_Normal;
   mLastSizeMode = nsSizeMode_Normal;
   mSizeConstraints.mMaxSize = GetSafeWindowSize(mSizeConstraints.mMaxSize);
@@ -1140,18 +1139,16 @@ bool nsWindow::IsWaylandPopup() {
   return !mIsX11Display && mIsTopLevel && mWindowType == eWindowType_popup;
 }
 
 void nsWindow::HideWaylandTooltips() {
   while (gVisibleWaylandPopupWindows) {
     nsWindow* window =
         static_cast<nsWindow*>(gVisibleWaylandPopupWindows->data);
     if (window->mPopupType != ePopupTypeTooltip) break;
-    LOG(("nsWindow::HideWaylandTooltips [%p] hidding tooltip [%p].\n",
-         (void*)this, window));
     window->HideWaylandWindow();
     gVisibleWaylandPopupWindows = g_list_delete_link(
         gVisibleWaylandPopupWindows, gVisibleWaylandPopupWindows);
   }
 }
 
 void nsWindow::HideWaylandPopupAndAllChildren() {
   if (g_list_find(gVisibleWaylandPopupWindows, this) == nullptr) {
@@ -1170,79 +1167,50 @@ void nsWindow::HideWaylandPopupAndAllChi
   }
 }
 
 // Wayland keeps strong popup window hierarchy. We need to track active
 // (visible) popup windows and make sure we hide popup on the same level
 // before we open another one on that level. It means that every open
 // popup needs to have an unique parent.
 GtkWidget* nsWindow::ConfigureWaylandPopupWindows() {
-  LOG(("nsWindow::ConfigureWaylandPopupWindows [%p]\n", (void*)this));
-
   // Check if we're already configured.
   if (gVisibleWaylandPopupWindows &&
       g_list_find(gVisibleWaylandPopupWindows, this)) {
-    LOG(("...[%p] is already configured.\n", (void*)this));
     return GTK_WIDGET(gtk_window_get_transient_for(GTK_WINDOW(mShell)));
   }
 
   // If we're opening a new window we don't want to attach it to a tooltip
   // as it's short lived temporary window.
   HideWaylandTooltips();
 
-  GtkWindow* parentWidget = mToplevelParentWindow;
+  GtkWindow* parentWidget = nullptr;
   if (gVisibleWaylandPopupWindows) {
-    LOG(("... there's visible active popup [%p]\n",
-         gVisibleWaylandPopupWindows->data));
-
     if (mPopupType == ePopupTypeTooltip) {
-      LOG(("...[%p] is tooltip, parent [%p]\n", (void*)this,
-           gVisibleWaylandPopupWindows->data));
-
       // Attach tooltip window to the latest popup window
       // to have both visible.
       nsWindow* window =
           static_cast<nsWindow*>(gVisibleWaylandPopupWindows->data);
       parentWidget = GTK_WINDOW(window->GetGtkWidget());
     } else {
       nsMenuPopupFrame* menuPopupFrame = nullptr;
       nsIFrame* frame = GetFrame();
       if (frame) {
         menuPopupFrame = do_QueryFrame(frame);
       }
-
       // The popup is not fully created yet (we're called from
       // nsWindow::Create()) or we're toplevel popup without parent.
       // In both cases just use parent which was passed to nsWindow::Create().
       if (!menuPopupFrame) {
-        LOG(("...[%p] menuPopupFrame = null, using given parent widget [%p]\n",
-             (void*)this, parentWidget));
-        return GTK_WIDGET(parentWidget);
+        return GTK_WIDGET(gtk_window_get_transient_for(GTK_WINDOW(mShell)));
       }
 
-      LOG(("...[%p] is %s\n", (void*)this,
-           menuPopupFrame->IsContextMenu() ? "context menu" : "popup"));
-
       nsWindow* parentWindow =
           static_cast<nsWindow*>(menuPopupFrame->GetParentMenuWidget());
-      LOG(("...[%p] GetParentMenuWidget() = %p\n", (void*)this, parentWindow));
-
-      // If the popup is a regular menu but GetParentMenuWidget() returns
-      // nullptr which means it's connected non-menu parent
-      // (bookmark toolbar for instance).
-      // In this case use a parent given at nsWindow::Create().
-      if (!parentWindow && !menuPopupFrame->IsContextMenu()) {
-        parentWindow =
-            get_window_for_gtk_widget(GTK_WIDGET(mToplevelParentWindow));
-      }
-
       if (!parentWindow) {
-        LOG(("...[%p] using active/visible popups as a parent [%p]\n",
-             (void*)this, gVisibleWaylandPopupWindows->data));
-
         // We're toplevel popup menu attached to another menu. Just use our
         // latest popup as a parent.
         parentWindow =
             static_cast<nsWindow*>(gVisibleWaylandPopupWindows->data);
         parentWidget = GTK_WINDOW(parentWindow->GetGtkWidget());
       } else {
         // We're a regular menu in the same frame hierarchy.
         // Close child popups on the same level as we can't have two popups
@@ -1261,65 +1229,59 @@ GtkWidget* nsWindow::ConfigureWaylandPop
         }
         if (lastChildOnTheSameLevel) {
           lastChildOnTheSameLevel->HideWaylandPopupAndAllChildren();
         }
       }
     }
   }
 
-  MOZ_ASSERT(parentWidget, "Missing parent widget for wayland popup!");
   if (parentWidget) {
-    LOG(("...[%p] set parent widget [%p]\n", (void*)this, parentWidget));
     gtk_window_set_transient_for(GTK_WINDOW(mShell), parentWidget);
+  } else {
+    parentWidget = gtk_window_get_transient_for(GTK_WINDOW(mShell));
   }
   gVisibleWaylandPopupWindows =
       g_list_prepend(gVisibleWaylandPopupWindows, this);
   return GTK_WIDGET(parentWidget);
 }
 
 #ifdef DEBUG
 static void NativeMoveResizeWaylandPopupCallback(
     GdkWindow* window, const GdkRectangle* flipped_rect,
     const GdkRectangle* final_rect, gboolean flipped_x, gboolean flipped_y,
-    void* aWindow) {
-  LOG(("%s [%p] flipped %d %d\n", __FUNCTION__, aWindow, flipped_rect->x,
-       flipped_rect->y));
-  LOG(("%s [%p] final %d %d\n", __FUNCTION__, aWindow, final_rect->x,
-       final_rect->y));
+    void* unused) {
+  LOG(("%s flipped %d %d\n", __FUNCTION__, flipped_rect->x, flipped_rect->y));
+  LOG(("%s final %d %d\n", __FUNCTION__, final_rect->x, final_rect->y));
 }
 #endif
 
 void nsWindow::NativeMoveResizeWaylandPopup(GdkPoint* aPosition,
                                             GdkRectangle* aSize) {
   // Available as of GTK 3.24+
   static auto sGdkWindowMoveToRect = (void (*)(
       GdkWindow*, const GdkRectangle*, GdkGravity, GdkGravity, GdkAnchorHints,
       gint, gint))dlsym(RTLD_DEFAULT, "gdk_window_move_to_rect");
 
   // Compositor may be confused by windows with width/height = 0
   // and positioning such windows leads to Bug 1555866.
   if (!AreBoundsSane()) {
-    LOG(("nsWindow::NativeMoveResizeWaylandPopup [%p] Bounds are not sane\n",
-         (void*)this));
     return;
   }
 
   if (aSize) {
     gtk_window_resize(GTK_WINDOW(mShell), aSize->width, aSize->height);
   }
 
   GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(mShell));
 
   // Use standard gtk_window_move() instead of gdk_window_move_to_rect() when:
   // - gdk_window_move_to_rect() is not available
   // - the widget doesn't have a valid GdkWindow
   if (!sGdkWindowMoveToRect || !gdkWindow) {
-    LOG(("nsWindow::NativeMoveResizeWaylandPopup [%p] use gtk_window_move()\n",
-         (void*)this));
     gtk_window_move(GTK_WINDOW(mShell), aPosition->x, aPosition->y);
     return;
   }
 
   GtkWidget* parentWindow = ConfigureWaylandPopupWindows();
   LOG(("nsWindow::NativeMoveResizeWaylandPopup [%p] Set popup parent %p\n",
        (void*)this, parentWindow));
 
@@ -1335,22 +1297,18 @@ void nsWindow::NativeMoveResizeWaylandPo
 
   LOG(("%s [%p] request position %d,%d\n", __FUNCTION__, (void*)this,
        aPosition->x, aPosition->y));
   if (aSize) {
     LOG(("  request size %d,%d\n", aSize->width, aSize->height));
   }
   LOG(("  request result %d %d\n", rect.x, rect.y));
 #ifdef DEBUG
-  if (!g_signal_handler_find(
-          gdkWindow, G_SIGNAL_MATCH_FUNC, 0, 0, nullptr,
-          FuncToGpointer(NativeMoveResizeWaylandPopupCallback), this)) {
-    g_signal_connect(gdkWindow, "moved-to-rect",
-                     G_CALLBACK(NativeMoveResizeWaylandPopupCallback), this);
-  }
+  g_signal_connect(gdkWindow, "moved-to-rect",
+                   G_CALLBACK(NativeMoveResizeWaylandPopupCallback), this);
 #endif
 
   GdkGravity rectAnchor = GDK_GRAVITY_NORTH_WEST;
   GdkGravity menuAnchor = GDK_GRAVITY_NORTH_WEST;
   if (GetTextDirection() == GTK_TEXT_DIR_RTL) {
     rectAnchor = GDK_GRAVITY_NORTH_EAST;
     menuAnchor = GDK_GRAVITY_NORTH_EAST;
   }
@@ -3545,16 +3503,17 @@ nsresult nsWindow::Create(nsIWidget* aPa
   // save our bounds
   mBounds = aRect;
   ConstrainSize(&mBounds.width, &mBounds.height);
 
   // figure out our parent window
   GtkWidget* parentMozContainer = nullptr;
   GtkContainer* parentGtkContainer = nullptr;
   GdkWindow* parentGdkWindow = nullptr;
+  GtkWindow* topLevelParent = nullptr;
   nsWindow* parentnsWindow = nullptr;
   GtkWidget* eventWidget = nullptr;
   bool drawToContainer = false;
   bool needsAlphaVisual =
       (mWindowType == eWindowType_popup && aInitData->mSupportTranslucency);
 
   if (aParent) {
     parentnsWindow = static_cast<nsWindow*>(aParent);
@@ -3570,18 +3529,17 @@ nsresult nsWindow::Create(nsIWidget* aPa
 
   if (parentGdkWindow) {
     // get the widget for the window - it should be a moz container
     parentMozContainer = parentnsWindow->GetMozContainerWidget();
     if (!parentMozContainer) return NS_ERROR_FAILURE;
 
     // get the toplevel window just in case someone needs to use it
     // for setting transients or whatever.
-    mToplevelParentWindow =
-        GTK_WINDOW(gtk_widget_get_toplevel(parentMozContainer));
+    topLevelParent = GTK_WINDOW(gtk_widget_get_toplevel(parentMozContainer));
   }
 
   if (!mIsX11Display) {
     if (mWindowType == eWindowType_child) {
       // eWindowType_child is not supported on Wayland. Just switch to toplevel
       // as a workaround.
       mWindowType = eWindowType_toplevel;
     } else if (mWindowType == eWindowType_popup && !topLevelParent) {
@@ -3714,17 +3672,17 @@ nsresult nsWindow::Create(nsIWidget* aPa
       NativeResize();
 
       if (mWindowType == eWindowType_dialog) {
         SetDefaultIcon();
         gtk_window_set_wmclass(GTK_WINDOW(mShell), "Dialog",
                                gdk_get_program_class());
         gtk_window_set_type_hint(GTK_WINDOW(mShell),
                                  GDK_WINDOW_TYPE_HINT_DIALOG);
-        gtk_window_set_transient_for(GTK_WINDOW(mShell), mToplevelParentWindow);
+        gtk_window_set_transient_for(GTK_WINDOW(mShell), topLevelParent);
       } else if (mWindowType == eWindowType_popup) {
         gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup",
                                gdk_get_program_class());
 
         if (aInitData->mNoAutoHide) {
           // ... but the window manager does not decorate this window,
           // nor provide a separate taskbar icon.
           if (mBorderStyle == eBorderStyle_default) {
@@ -3767,21 +3725,20 @@ nsresult nsWindow::Create(nsIWidget* aPa
               break;
             default:
               gtkTypeHint = GDK_WINDOW_TYPE_HINT_UTILITY;
               break;
           }
         }
         gtk_window_set_type_hint(GTK_WINDOW(mShell), gtkTypeHint);
 
-        if (mToplevelParentWindow) {
+        if (topLevelParent) {
           LOG(("nsWindow::Create [%p] Set popup parent %p\n", (void*)this,
-               mToplevelParentWindow));
-          gtk_window_set_transient_for(GTK_WINDOW(mShell),
-                                       mToplevelParentWindow);
+               topLevelParent));
+          gtk_window_set_transient_for(GTK_WINDOW(mShell), topLevelParent);
         }
 
         // We need realized mShell at NativeMove().
         gtk_widget_realize(mShell);
 
         // With popup windows, we want to control their position, so don't
         // wait for the window manager to place them (which wouldn't
         // happen with override-redirect windows anyway).
@@ -4049,18 +4006,17 @@ nsresult nsWindow::Create(nsIWidget* aPa
     g_signal_connect(eventWidget, "scroll-event", G_CALLBACK(scroll_event_cb),
                      nullptr);
 #if GTK_CHECK_VERSION(3, 4, 0)
     g_signal_connect(eventWidget, "touch-event", G_CALLBACK(touch_event_cb),
                      nullptr);
 #endif
   }
 
-  LOG(("nsWindow [%p] %s\n", (void*)this,
-       mWindowType == eWindowType_toplevel ? "Toplevel" : "Popup"));
+  LOG(("nsWindow [%p]\n", (void*)this));
   if (mShell) {
     LOG(("\tmShell %p mContainer %p mGdkWindow %p 0x%lx\n", mShell, mContainer,
          mGdkWindow, mIsX11Display ? gdk_x11_window_get_xid(mGdkWindow) : 0));
   } else if (mContainer) {
     LOG(("\tmContainer %p mGdkWindow %p\n", mContainer, mGdkWindow));
   } else if (mGdkWindow) {
     LOG(("\tmGdkWindow %p parent %p\n", mGdkWindow,
          gdk_window_get_parent(mGdkWindow)));
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -482,17 +482,16 @@ class nsWindow final : public nsBaseWidg
 #endif
   nsCString mGtkWindowTypeName;
   nsCString mGtkWindowRoleName;
   void RefreshWindowClass();
 
   GtkWidget* mShell;
   MozContainer* mContainer;
   GdkWindow* mGdkWindow;
-  GtkWindow* mToplevelParentWindow;
   bool mWindowShouldStartDragging = false;
   PlatformCompositorWidgetDelegate* mCompositorWidgetDelegate;
 
   uint32_t mHasMappedToplevel : 1, mIsFullyObscured : 1, mRetryPointerGrab : 1;
   nsSizeMode mSizeState;
 
   nsIntPoint mClientOffset;