Bug 568825 - Fix -moz-appearance: progresschunk overflows on the bottom on Windows. r=jimm
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 04 May 2011 16:55:12 +0200
changeset 69151 65a4097a0d955199b4f62177bb726eab39a25fb7
parent 69150 a48aa0f63d90c0b9b8aed61fb49c0967dab055b9
child 69152 f8ab655d503c95e9e8ae00d3b7ef7b16dea95622
push id19876
push usermlamouri@mozilla.com
push dateMon, 09 May 2011 12:22:00 +0000
treeherdermozilla-central@ea4a5a20e081 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs568825
milestone6.0a1
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
Bug 568825 - Fix -moz-appearance: progresschunk overflows on the bottom on Windows. r=jimm
layout/reftests/native-theme/progress-nobar.html
layout/reftests/native-theme/progress-overflow-ref.html
layout/reftests/native-theme/progress-overflow-small.html
layout/reftests/native-theme/progress-overflow.html
layout/reftests/native-theme/reftest.list
widget/src/windows/nsNativeThemeWin.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/native-theme/progress-nobar.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <div style="-moz-appearance: progressbar; width:180px; height:6px;">
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/native-theme/progress-overflow-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <div style="overflow: hidden; -moz-appearance: progressbar; width:180px; height:40px;">
+      <div style="-moz-appearance: progresschunk; width:50%; height:100%;">
+      </div>
+    </div>
+  </body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/native-theme/progress-overflow-small.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <div style="-moz-appearance: progressbar; width:180px; height:6px;">
+      <div style="-moz-appearance: progresschunk; width:50%; height:100%;">
+      </div>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/native-theme/progress-overflow.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <div style="-moz-appearance: progressbar; width:180px; height:40px;">
+      <div style="-moz-appearance: progresschunk; width:50%; height:100%;">
+      </div>
+    </div>
+  </body>
+</html>
--- a/layout/reftests/native-theme/reftest.list
+++ b/layout/reftests/native-theme/reftest.list
@@ -59,8 +59,11 @@ skip-if(gtk2Widget) random-if(d2d) == re
 
 # Windows-only, depends on native scrollbar metrics
 skip-if(!winWidget) == scroll-thumb-minimum-size-notheme.html scroll-thumb-minimum-size-notheme-ref.html
 # skip-if(!winWidget) == scroll-thumb-minimum-size-theme.html scroll-thumb-minimum-size-theme-ref.html # Bug 512206
 
 == border-radius.html border-radius-ref.html
 
 == checkbox-dynamic-1.html checkbox-dynamic-1-ref.html
+
+== progress-overflow.html progress-overflow-ref.html
+fails-if(cocoaWidget) != progress-overflow-small.html progress-nobar.html
--- a/widget/src/windows/nsNativeThemeWin.cpp
+++ b/widget/src/windows/nsNativeThemeWin.cpp
@@ -338,16 +338,23 @@ static CaptionButtonPadding buttonData[3
   { 
     { { 1, 2, 0, 2 }, { 0, 2, 1, 2 }, { 1, 2, 2, 2 } }
   },
   { 
     { { 0, 2, 0, 2 }, { 0, 2, 1, 2 }, { 1, 2, 2, 2 } }
   }
 };
 
+/**
+ * Progress bar related constants.
+ */
+// PP_CHUNK is overflowing on the bottom for no appearant reasons.
+// This is a fix around this issue.
+static const PRInt32 kProgressDeterminedXPOverflow = 11;
+
 // Adds "hot" caption button padding to minimum widget size.
 static void AddPaddingRect(nsIntSize* aSize, CaptionButton button) {
   if (!aSize)
     return;
   RECT offset;
   if (!nsUXThemeData::IsAppThemed())
     offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
   else if (nsWindow::GetWindowsVersion() == WINXP_VERSION)
@@ -1284,16 +1291,18 @@ RENDER_AGAIN:
     OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_MINIMIZE);
   }
   else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MAXIMIZE ||
            aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) {
     OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_RESTORE);
   }
   else if (aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE) {
     OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_CLOSE);
+  } else if (aWidgetType == NS_THEME_PROGRESSBAR_CHUNK) {
+    widgetRect.bottom -= kProgressDeterminedXPOverflow;
   }
 
   // widgetRect is the bounding box for a widget, yet the scale track is only
   // a small portion of this size, so the edges of the scale need to be
   // adjusted to the real size of the track.
   if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
       aWidgetType == NS_THEME_SCALE_VERTICAL) {
     RECT contentRect;