Bug 1063121 - Dropping out of fullscreen mode without titlebar breaks titlebar/tabs layout. r=jimm, a=lmandel
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 29 Oct 2014 14:19:25 +0000
changeset 225963 f6b893ef9186
parent 225962 de49643707ae
child 225964 dfe08b30f41f
push id4088
push userryanvm@gmail.com
push date2014-11-06 15:24 +0000
treeherdermozilla-beta@dfe08b30f41f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, lmandel
bugs1063121
milestone34.0
Bug 1063121 - Dropping out of fullscreen mode without titlebar breaks titlebar/tabs layout. r=jimm, a=lmandel
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -2283,20 +2283,26 @@ nsWindow::UpdateNonClientMargins(int32_t
 
   return true;
 }
 
 NS_IMETHODIMP
 nsWindow::SetNonClientMargins(nsIntMargin &margins)
 {
   if (!mIsTopWidgetWindow ||
-      mBorderStyle & eBorderStyle_none ||
-      mHideChrome)
+      mBorderStyle & eBorderStyle_none)
     return NS_ERROR_INVALID_ARG;
 
+  if (mHideChrome) {
+    mFutureMarginsOnceChromeShows = margins;
+    mFutureMarginsToUse = true;
+    return NS_OK;
+  }
+  mFutureMarginsToUse = false;
+
   // Request for a reset
   if (margins.top == -1 && margins.left == -1 &&
       margins.right == -1 && margins.bottom == -1) {
     mCustomNonClient = false;
     mNonClientMargins = margins;
     // Force a reflow of content based on the new client
     // dimensions.
     ResetLayout();
@@ -2757,16 +2763,19 @@ NS_IMETHODIMP nsWindow::HideWindowChrome
   else {
     if (!mOldStyle || !mOldExStyle) {
       mOldStyle = ::GetWindowLongPtrW(hwnd, GWL_STYLE);
       mOldExStyle = ::GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
     }
 
     style = mOldStyle;
     exStyle = mOldExStyle;
+    if (mFutureMarginsToUse) {
+      SetNonClientMargins(mFutureMarginsOnceChromeShows);
+    }
   }
 
   VERIFY_WINDOW_STYLE(style);
   ::SetWindowLongPtrW(hwnd, GWL_STYLE, style);
   ::SetWindowLongPtrW(hwnd, GWL_EXSTYLE, exStyle);
 
   return NS_OK;
 }
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -507,16 +507,20 @@ protected:
 
   static uint32_t       sOOPPPluginFocusEvent;
 
   // Non-client margin settings
   // Pre-calculated outward offset applied to default frames
   nsIntMargin           mNonClientOffset;
   // Margins set by the owner
   nsIntMargin           mNonClientMargins;
+  // Margins we'd like to set once chrome is reshown:
+  nsIntMargin           mFutureMarginsOnceChromeShows;
+  // Indicates we need to apply margins once toggling chrome into showing:
+  bool                  mFutureMarginsToUse;
 
   // Indicates custom frames are enabled
   bool                  mCustomNonClient;
   // Cached copy of L&F's resize border  
   int32_t               mHorResizeMargin;
   int32_t               mVertResizeMargin;
   // Height of the caption plus border
   int32_t               mCaptionHeight;