Bug 610643 - Maximized titlebar background offset should equal the window origin offset for proper placement. r=dao+neil, a=final.
authorJim Mathies <jmathies@mozilla.com>
Mon, 29 Nov 2010 10:19:17 -0600
changeset 58326 6f14ee0618153673f08cc30c9451abd189fa4ba6
parent 58325 ff0e38477a8db97a3f59cf9fc9e7e8c6e7897fa4
child 58327 d9cf761c6af47fd7cccac6f2ce9a1fa875ed387b
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersdao, final
bugs610643
milestone2.0b8pre
Bug 610643 - Maximized titlebar background offset should equal the window origin offset for proper placement. r=dao+neil, a=final.
browser/themes/winstripe/browser/browser.css
widget/src/windows/nsNativeThemeWin.cpp
--- a/browser/themes/winstripe/browser/browser.css
+++ b/browser/themes/winstripe/browser/browser.css
@@ -297,33 +297,24 @@
 #BMB_bookmarkThisPage,
 #appmenu_bookmarkThisPage {
   list-style-image: url("chrome://browser/skin/places/bookmark.png");
   -moz-image-region: rect(0 16px 16px 0);
 }
 
 /* ::::: titlebar ::::: */
 
-#titlebar {
+#main-window[sizemode="normal"] > #titlebar {
   -moz-appearance: -moz-window-titlebar;
-  /* we only need to the middle section, hide the edges of the
-  theme background beyond the window frame. */
-  margin-left: -15px;
-  margin-right: -15px;
 }
 
 #main-window[sizemode="maximized"] > #titlebar {
   -moz-appearance: -moz-window-titlebar-maximized;
 }
 
-#titlebar-content {
-  margin-left: 15px;
-  margin-right: 15px;
-}
-
 @media all and (-moz-windows-classic) {
   #main-window[sizemode="normal"] > #titlebar > #titlebar-content > #appmenu-button-container {
     margin-top: 4px;
   }
 }
 
 #titlebar-buttonbox {
   -moz-appearance: -moz-window-button-box;
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -1192,19 +1192,29 @@ RENDER_AGAIN:
   {
     fprintf (stderr, "xform: %f %f %f %f [%f %f]\n", m.xx, m.yx, m.xy, m.yy, m.x0, m.y0);
     fprintf (stderr, "tr: [%d %d %d %d]\ndr: [%d %d %d %d]\noff: [%f %f]\n",
              tr.x, tr.y, tr.width, tr.height, dr.x, dr.y, dr.width, dr.height,
              offset.x, offset.y);
   }
 #endif
 
-  // For left edge and right edge tabs, we need to adjust the widget
-  // rects and clip rects so that the edges don't get drawn.
-  if (aWidgetType == NS_THEME_TAB) {
+  if (aWidgetType == NS_THEME_WINDOW_TITLEBAR) {
+    // Clip out the left and right corners of the frame, all we want in
+    // is the middle section.
+    widgetRect.left -= GetSystemMetrics(SM_CXFRAME);
+    widgetRect.right += GetSystemMetrics(SM_CXFRAME);
+  } else if (aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED) {
+    // The origin of the window is off screen when maximized and windows
+    // doesn't compensate for this in rendering the background. Push the
+    // top of the bitmap down by SM_CYFRAME so we get the full graphic.
+    widgetRect.top += GetSystemMetrics(SM_CYFRAME);
+  } else if (aWidgetType == NS_THEME_TAB) {
+    // For left edge and right edge tabs, we need to adjust the widget
+    // rects and clip rects so that the edges don't get drawn.
     PRBool isLeft = IsLeftToSelectedTab(aFrame);
     PRBool isRight = !isLeft && IsRightToSelectedTab(aFrame);
 
     if (isLeft || isRight) {
       // HACK ALERT: There appears to be no way to really obtain this value, so we're forced
       // to just use the default value for Luna (which also happens to be correct for
       // all the other skins I've tried).
       PRInt32 edgeSize = 2;
@@ -3289,18 +3299,16 @@ RENDER_AGAIN:
       PRInt32 offset = GetSystemMetrics(SM_CXFRAME);
       rect.bottom -= 1;
 
       // first fill the area to the color of the window background
       FillRect(hdc, &rect, (HBRUSH)(COLOR_3DFACE+1));
 
       // inset the caption area so it doesn't overflow.
       rect.top += offset;
-      rect.left += offset;
-      rect.right -= offset;
       // if enabled, draw a gradient titlebar background, otherwise
       // fill with a solid color.
       BOOL bFlag = TRUE;
       SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bFlag, 0);
       if (!bFlag) {
         if (state == mozilla::widget::themeconst::FS_ACTIVE)
           FillRect(hdc, &rect, (HBRUSH)(COLOR_ACTIVECAPTION+1));
         else
@@ -3332,18 +3340,20 @@ RENDER_AGAIN:
 
         GRADIENT_RECT gRect;
         gRect.UpperLeft  = 0;
         gRect.LowerRight = 1;
         // available on win2k & up
         GradientFill(hdc, vertex, 2, &gRect, 1, GRADIENT_FILL_RECT_H);
       }
 
-      // frame things up with the left, top, and right raised borders.
-      DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_TOP|BF_LEFT|BF_RIGHT);
+      if (aWidgetType == NS_THEME_WINDOW_TITLEBAR) {
+        // frame things up with a top raised border.
+        DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_TOP);
+      }
       break;
     }
 
     case NS_THEME_WINDOW_FRAME_LEFT:
       DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_LEFT);
       break;
 
     case NS_THEME_WINDOW_FRAME_RIGHT: