summaryrefslogtreecommitdiff
path: root/mozilla-1562827.patch
blob: 497133cf27d9634f5254ccdb895ea11ddba41b1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
diff -up firefox-69.0/widget/gtk/nsWindow.cpp.mozilla-1562827 firefox-69.0/widget/gtk/nsWindow.cpp
--- firefox-69.0/widget/gtk/nsWindow.cpp.mozilla-1562827	2019-09-02 15:16:15.031528276 +0200
+++ firefox-69.0/widget/gtk/nsWindow.cpp	2019-09-02 15:16:15.037528254 +0200
@@ -818,7 +818,6 @@ void nsWindow::SetParent(nsIWidget* aNew
   if (mParent) {
     mParent->RemoveChild(this);
   }
-
   mParent = aNewParent;
 
   GtkWidget* oldContainer = GetMozContainerWidget();
@@ -830,88 +829,73 @@ void nsWindow::SetParent(nsIWidget* aNew
     return;
   }
 
+  nsWindow* newParent = static_cast<nsWindow*>(aNewParent);
+  GdkWindow* newParentWindow = nullptr;
+  GtkWidget* newContainer = nullptr;
   if (aNewParent) {
     aNewParent->AddChild(this);
-    ReparentNativeWidget(aNewParent);
+    newParentWindow = newParent->mGdkWindow;
+    newContainer = newParent->GetMozContainerWidget();
   } else {
     // aNewParent is nullptr, but reparent to a hidden window to avoid
     // destroying the GdkWindow and its descendants.
     // An invisible container widget is needed to hold descendant
     // GtkWidgets.
-    GtkWidget* newContainer = EnsureInvisibleContainer();
-    GdkWindow* newParentWindow = gtk_widget_get_window(newContainer);
-    ReparentNativeWidgetInternal(aNewParent, newContainer, newParentWindow,
-                                 oldContainer);
-  }
-}
-
-bool nsWindow::WidgetTypeSupportsAcceleration() { return !IsSmallPopup(); }
-
-void nsWindow::ReparentNativeWidget(nsIWidget* aNewParent) {
-  MOZ_ASSERT(aNewParent, "null widget");
-  NS_ASSERTION(!mIsDestroyed, "");
-  NS_ASSERTION(!static_cast<nsWindow*>(aNewParent)->mIsDestroyed, "");
-
-  GtkWidget* oldContainer = GetMozContainerWidget();
-  if (!oldContainer) {
-    // The GdkWindows have been destroyed so there is nothing else to
-    // reparent.
-    MOZ_ASSERT(gdk_window_is_destroyed(mGdkWindow),
-               "live GdkWindow with no widget");
-    return;
+    newContainer = EnsureInvisibleContainer();
+    newParentWindow = gtk_widget_get_window(newContainer);
   }
-  MOZ_ASSERT(!gdk_window_is_destroyed(mGdkWindow),
-             "destroyed GdkWindow with widget");
 
-  auto* newParent = static_cast<nsWindow*>(aNewParent);
-  GdkWindow* newParentWindow = newParent->mGdkWindow;
-  GtkWidget* newContainer = newParent->GetMozContainerWidget();
-  GtkWindow* shell = GTK_WINDOW(mShell);
-
-  if (shell && gtk_window_get_transient_for(shell)) {
-    GtkWindow* topLevelParent =
-        GTK_WINDOW(gtk_widget_get_toplevel(newContainer));
-    gtk_window_set_transient_for(shell, topLevelParent);
-  }
-
-  ReparentNativeWidgetInternal(aNewParent, newContainer, newParentWindow,
-                               oldContainer);
-}
-
-void nsWindow::ReparentNativeWidgetInternal(nsIWidget* aNewParent,
-                                            GtkWidget* aNewContainer,
-                                            GdkWindow* aNewParentWindow,
-                                            GtkWidget* aOldContainer) {
-  if (!aNewContainer) {
+  if (!newContainer) {
     // The new parent GdkWindow has been destroyed.
-    MOZ_ASSERT(!aNewParentWindow || gdk_window_is_destroyed(aNewParentWindow),
+    MOZ_ASSERT(!newParentWindow || gdk_window_is_destroyed(newParentWindow),
                "live GdkWindow with no widget");
     Destroy();
   } else {
-    if (aNewContainer != aOldContainer) {
-      MOZ_ASSERT(!gdk_window_is_destroyed(aNewParentWindow),
+    if (newContainer != oldContainer) {
+      MOZ_ASSERT(!gdk_window_is_destroyed(newParentWindow),
                  "destroyed GdkWindow with widget");
-      SetWidgetForHierarchy(mGdkWindow, aOldContainer, aNewContainer);
+      SetWidgetForHierarchy(mGdkWindow, oldContainer, newContainer);
 
-      if (aOldContainer == gInvisibleContainer) {
+      if (oldContainer == gInvisibleContainer) {
         CheckDestroyInvisibleContainer();
       }
     }
 
-    if (!mIsTopLevel) {
-      gdk_window_reparent(mGdkWindow, aNewParentWindow,
-                          DevicePixelsToGdkCoordRoundDown(mBounds.x),
-                          DevicePixelsToGdkCoordRoundDown(mBounds.y));
-    }
+    gdk_window_reparent(mGdkWindow, newParentWindow,
+                        DevicePixelsToGdkCoordRoundDown(mBounds.x),
+                        DevicePixelsToGdkCoordRoundDown(mBounds.y));
+    mToplevelParentWindow = GTK_WINDOW(gtk_widget_get_toplevel(newContainer));
   }
 
-  auto* newParent = static_cast<nsWindow*>(aNewParent);
   bool parentHasMappedToplevel = newParent && newParent->mHasMappedToplevel;
   if (mHasMappedToplevel != parentHasMappedToplevel) {
     SetHasMappedToplevel(parentHasMappedToplevel);
   }
 }
 
+bool nsWindow::WidgetTypeSupportsAcceleration() { return !IsSmallPopup(); }
+
+void nsWindow::ReparentNativeWidget(nsIWidget* aNewParent) {
+  MOZ_ASSERT(aNewParent, "null widget");
+  MOZ_ASSERT(!mIsDestroyed, "");
+  MOZ_ASSERT(!static_cast<nsWindow*>(aNewParent)->mIsDestroyed, "");
+  MOZ_ASSERT(!gdk_window_is_destroyed(mGdkWindow),
+             "destroyed GdkWindow with widget");
+
+  MOZ_ASSERT(
+      !mParent,
+      "nsWindow::ReparentNativeWidget() works on toplevel windows only.");
+
+  auto* newParent = static_cast<nsWindow*>(aNewParent);
+  GtkWindow* newParentWidget = GTK_WINDOW(newParent->GetGtkWidget());
+  GtkWindow* shell = GTK_WINDOW(mShell);
+
+  if (shell && gtk_window_get_transient_for(shell)) {
+    gtk_window_set_transient_for(shell, newParentWidget);
+    mToplevelParentWindow = newParentWidget;
+  }
+}
+
 void nsWindow::SetModal(bool aModal) {
   LOG(("nsWindow::SetModal [%p] %d\n", (void*)this, aModal));
   if (mIsDestroyed) return;
diff -up firefox-69.0/widget/gtk/nsWindow.h.mozilla-1562827 firefox-69.0/widget/gtk/nsWindow.h
bgstack15