summaryrefslogtreecommitdiffstats
path: root/revert-562138.patch
blob: cc97d005054f2885b3179ee501d5c92a25de4077 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
See https://bugzilla.mozilla.org/show_bug.cgi?id=562138#c8

# HG changeset patch
# User Markus Stange <mstange@themasta.com>
# Date 1296111298 -3600
# Node ID 433f39574cd72d30e47e6500fad52a0398753367
# Parent  f948c56cb86f83354f0bd9d579cd51167464b4f2
Backed out changeset f948c56cb86f (bug 562138 part 2) because it depends on changeset 44c42d8b8d08 which is going to be backed out.

diff --git a/widget/src/cocoa/nsCocoaWindow.h b/widget/src/cocoa/nsCocoaWindow.h
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -291,17 +291,16 @@ public:
     NS_IMETHOD ResetInputState();
     
     NS_IMETHOD BeginSecureKeyboardInput();
     NS_IMETHOD EndSecureKeyboardInput();
 
     static void UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut);
 
     void SetPopupWindowLevel();
-    PRBool IsVisible();
 
     PRBool IsChildInFailingLeftClickThrough(NSView *aChild);
     PRBool ShouldFocusPlugin();
 
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent);
 protected:
 
   nsresult             CreateNativeWindow(const NSRect &aRect,
@@ -335,14 +334,13 @@ protected:
   PRInt32              mShadowStyle;
   NSUInteger           mWindowFilter;
 
   PRPackedBool         mWindowMadeHere; // true if we created the window, false for embedding
   PRPackedBool         mSheetNeedsShow; // if this is a sheet, are we waiting to be shown?
                                         // this is used for sibling sheet contention only
   PRPackedBool         mFullScreen;
   PRPackedBool         mModal;
-  PRPackedBool         mIsShowing;      // PR_TRUE during a Show(PR_TRUE) call.
 
   PRInt32              mNumModalDescendents;
 };
 
 #endif // nsCocoaWindow_h_
diff --git a/widget/src/cocoa/nsCocoaWindow.mm b/widget/src/cocoa/nsCocoaWindow.mm
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -143,17 +143,16 @@ nsCocoaWindow::nsCocoaWindow()
 , mSheetWindowParent(nil)
 , mPopupContentView(nil)
 , mShadowStyle(NS_STYLE_WINDOW_SHADOW_DEFAULT)
 , mWindowFilter(0)
 , mWindowMadeHere(PR_FALSE)
 , mSheetNeedsShow(PR_FALSE)
 , mFullScreen(PR_FALSE)
 , mModal(PR_FALSE)
-, mIsShowing(PR_FALSE)
 , mNumModalDescendents(0)
 {
 
 }
 
 void nsCocoaWindow::DestroyNativeWindow()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@@ -528,30 +527,24 @@ void* nsCocoaWindow::GetNativeData(PRUin
       break;
   }
 
   return retVal;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
-PRBool
-nsCocoaWindow::IsVisible()
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
-
-  return [mWindow isVisible] || mSheetNeedsShow || mIsShowing;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(PR_FALSE);
-}
-
 NS_IMETHODIMP nsCocoaWindow::IsVisible(PRBool & aState)
 {
-  aState = IsVisible();
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
+  aState = ([mWindow isVisible] || mSheetNeedsShow);
   return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsCocoaWindow::SetModal(PRBool aState)
 {
   // This is used during startup (outside the event loop) when creating
   // the add-ons compatibility checking dialog and the profile manager UI;
   // therefore, it needs to provide an autorelease pool to avoid cocoa
   // objects leaking.
@@ -626,42 +619,29 @@ NS_IMETHODIMP nsCocoaWindow::SetModal(PR
 
 // Hide or show this window
 NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   // We need to re-execute sometimes in order to bring already-visible
   // windows forward.
-  if (!bState && !IsVisible())
+  if (!mSheetNeedsShow && !bState && ![mWindow isVisible])
     return NS_OK;
 
   nsIWidget* parentWidget = mParent;
   nsCOMPtr<nsPIWidgetCocoa> piParentWidget(do_QueryInterface(parentWidget));
   NSWindow* nativeParentWindow = (parentWidget) ?
     (NSWindow*)parentWidget->GetNativeData(NS_NATIVE_WINDOW) : nil;
 
   if (bState && !mBounds.IsEmpty()) {
-    // IsVisible can be entered from inside this method, for example through
-    // synchronous painting. Unfortunately, at that point [mWindow isVisible]
-    // still returns NO, so we use mIsShowing to tell us that we should return
-    // true from IsVisible anyway.
-    mIsShowing = PR_TRUE;
-
-    if (mPopupContentView) {
-      // Ensure our content view is visible. We never need to hide it.
-      mPopupContentView->Show(PR_TRUE);
-    }
-
     if (mWindowType == eWindowType_sheet) {
       // bail if no parent window (its basically what we do in Carbon)
-      if (!nativeParentWindow || !piParentWidget) {
-        mIsShowing = PR_FALSE;
+      if (!nativeParentWindow || !piParentWidget)
         return NS_ERROR_FAILURE;
-      }
 
       NSWindow* topNonSheetWindow = nativeParentWindow;
       
       // If this sheet is the child of another sheet, hide the parent so that
       // this sheet can be displayed. Leave the parent mSheetNeedsShow alone,
       // that is only used to handle sibling sheet contention. The parent will
       // return once there are no more child sheets.
       PRBool parentIsSheet = PR_FALSE;
@@ -744,17 +724,16 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
     }
     else {
       [mWindow setAcceptsMouseMovedEvents:YES];
       NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK;
       [mWindow makeKeyAndOrderFront:nil];
       NS_OBJC_END_TRY_LOGONLY_BLOCK;
       SendSetZLevelEvent();
     }
-    mIsShowing = PR_FALSE;
   }
   else {
     // roll up any popups if a top-level window is going away
     if (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog)
       RollUpPopups();
 
     // now get rid of the window/sheet
     if (mWindowType == eWindowType_sheet) {
@@ -850,16 +829,19 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
       if ([mWindow isKindOfClass:[PopupWindow class]] &&
           [(PopupWindow*) mWindow isContextMenu]) {
         [[NSDistributedNotificationCenter defaultCenter]
           postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification"
                         object:@"org.mozilla.gecko.PopupWindow"];
       }
     }
   }
+  
+  if (mPopupContentView)
+      mPopupContentView->Show(bState);
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 struct ShadowParams {
   float standardDeviation;


# HG changeset patch
# User Markus Stange <mstange@themasta.com>
# Date 1296111382 -3600
# Node ID 2cfc443d28ee87835e17b665d41be3a6fb0dca23
# Parent  44c42d8b8d087ed22c02ffe90f7d23f84ee8abbb
Backed out changeset 44c42d8b8d08 (bug 562138 part 1) because it caused bug 627824 and bug 628861.

diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -433,63 +433,51 @@ nsIntRect nsIView::CalcWidgetBounds(nsWi
 void nsView::DoResetWidgetBounds(PRBool aMoveOnly,
                                  PRBool aInvalidateChangedSize) {
   // The geometry of a root view's widget is controlled externally,
   // NOT by sizing or positioning the view
   if (mViewManager->GetRootView() == this) {
     return;
   }
   
-  NS_PRECONDITION(mWindow, "Why was this called??");
-
   nsIntRect curBounds;
   mWindow->GetBounds(curBounds);
 
   nsWindowType type;
   mWindow->GetWindowType(type);
 
   if (curBounds.IsEmpty() && mDimBounds.IsEmpty() && type == eWindowType_popup) {
     // Don't manipulate empty popup widgets. For example there's no point
     // moving hidden comboboxes around, or doing X server roundtrips
     // to compute their true screen position. This could mean that WidgetToScreen
     // operations on these widgets don't return up-to-date values, but popup
     // positions aren't reliable anyway because of correction to be on or off-screen.
     return;
   }
 
+  NS_PRECONDITION(mWindow, "Why was this called??");
+
   nsIntRect newBounds = CalcWidgetBounds(type);
 
   PRBool changedPos = curBounds.TopLeft() != newBounds.TopLeft();
   PRBool changedSize = curBounds.Size() != newBounds.Size();
 
-  PRBool curVisibility;
-  mWindow->IsVisible(curVisibility);
-  PRBool newVisibility = IsEffectivelyVisible();
-
-  if (curVisibility && !newVisibility) {
-    mWindow->Show(PR_FALSE);
-  }
-
   // Child views are never attached to top level widgets, this is safe.
   if (changedPos) {
     if (changedSize && !aMoveOnly) {
       mWindow->Resize(newBounds.x, newBounds.y, newBounds.width, newBounds.height,
                       aInvalidateChangedSize);
     } else {
       mWindow->Move(newBounds.x, newBounds.y);
     }
   } else {
     if (changedSize && !aMoveOnly) {
       mWindow->Resize(newBounds.width, newBounds.height, aInvalidateChangedSize);
     } // else do nothing!
   }
-
-  if (!curVisibility && newVisibility) {
-    mWindow->Show(PR_TRUE);
-  }
 }
 
 void nsView::SetDimensions(const nsRect& aRect, PRBool aPaint, PRBool aResizeWidget)
 {
   nsRect dims = aRect;
   dims.MoveBy(mPosX, mPosY);
 
   // Don't use nsRect's operator== here, since it returns true when
@@ -511,17 +499,23 @@ void nsView::NotifyEffectiveVisibilityCh
 {
   if (!aEffectivelyVisible)
   {
     DropMouseGrabbing();
   }
 
   if (nsnull != mWindow)
   {
-    ResetWidgetBounds(PR_FALSE, PR_TRUE, PR_FALSE);
+    if (aEffectivelyVisible)
+    {
+      DoResetWidgetBounds(PR_FALSE, PR_TRUE);
+      mWindow->Show(PR_TRUE);
+    }
+    else
+      mWindow->Show(PR_FALSE);
   }
 
   for (nsView* child = mFirstChild; child; child = child->mNextSibling) {
     if (child->mVis == nsViewVisibility_kHide) {
       // It was effectively hidden and still is
       continue;
     }
     // Our child is visible if we are