Bug 724352 - Don't add vertical margin to scrollable overflow here, it's already done during reflow and we don't need it for UpdateOverflow yet (and we need to account for margin-collapsing when we do). r=roc, a=akeybl
authorMats Palmgren <matspal@gmail.com>
Thu, 05 Apr 2012 16:30:21 +0200
changeset 92075 e33ea234ae5124b97c73bdebf6470cca888a47a9
parent 92074 3afc314d0de322dd6371393a2a8c65c5f5297f73
child 92076 40e45c33965ce343ed8db00e90826f3308e27efd
push idunknown
push userunknown
push dateunknown
reviewersroc, akeybl
bugs724352
milestone13.0a2
Bug 724352 - Don't add vertical margin to scrollable overflow here, it's already done during reflow and we don't need it for UpdateOverflow yet (and we need to account for margin-collapsing when we do). r=roc, a=akeybl
layout/generic/nsFrame.cpp
layout/reftests/margin-collapsing/reftest.list
layout/reftests/margin-collapsing/scrollable-horizontal-margin-ref.html
layout/reftests/margin-collapsing/scrollable-horizontal-margin.html
layout/reftests/margin-collapsing/scrollable-vertical-margin-ref.html
layout/reftests/margin-collapsing/scrollable-vertical-margin.html
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -6717,16 +6717,25 @@ nsIFrame::FinishAndStoreOverflow(nsOverf
       o.UnionRectEdges(o, bounds);
     }
 
     if (!nsLayoutUtils::IsPopup(this)) {
       // Include margin in scrollable overflow.
       // XXX In theory this should consider margin collapsing
       nsRect marginBounds(bounds);
       nsMargin margin = GetUsedMargin();
+
+      // Bug 724352 - vertical scrollable overflow only matters for
+      // scroll frames which are block margin roots and has already
+      // accumulated child vertical margins during reflow.  We need
+      // to revisit this when using UpdateOverflow for non-transform
+      // style changes (bug 719177).
+      margin.top = 0;
+      margin.bottom = 0;
+
       ApplySkipSides(margin);
       marginBounds.SaturatingInflate(margin);
       nsRect& so = aOverflowAreas.ScrollableOverflow();
       so.SaturatingUnionRectEdges(so, marginBounds);
     }
   }
 
   // Note that NS_STYLE_OVERFLOW_CLIP doesn't clip the frame background,
--- a/layout/reftests/margin-collapsing/reftest.list
+++ b/layout/reftests/margin-collapsing/reftest.list
@@ -319,8 +319,10 @@ fails == block-clear-7g-left.html block-
 != block-zero-min-height-2e.html block-zero-min-height-2-noref.html
 != block-zero-min-height-2f.html block-zero-min-height-2-noref.html
 == block-zero-min-height-3a.html block-zero-min-height-3-ref.html
 == block-zero-min-height-3b.html block-zero-min-height-3-ref.html
 == block-zero-min-height-3c.html block-zero-min-height-3-ref.html
 == block-zero-min-height-3d.html block-zero-min-height-3-ref.html
 == block-percent-1.html block-percent-1-ref.html
 == dynamic-add-text-1.html dynamic-add-text-1-ref.html # Bug 467321
+== scrollable-vertical-margin.html scrollable-vertical-margin-ref.html
+== scrollable-horizontal-margin.html scrollable-horizontal-margin-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/margin-collapsing/scrollable-horizontal-margin-ref.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Testcase for bug 724352</title>
+    <style type="text/css">
+
+        html,body {
+            color:black; background-color:white; font-size:16px; padding:0; margin:0;
+        }
+	
+x1,x2,x3,x4,x5,x6 { display:block; }
+x2 { overflow:auto; width:100px; background:grey; }
+x4 { width: 70px; }
+x3 { width: 70px; padding: 0 20px; }
+    </style>
+</head>
+<body>
+
+<x1><x2 style="height:50px;">
+  <x3><x4 style="height:20px; background:lime; "></x4></x3>
+</x2>
+
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/margin-collapsing/scrollable-horizontal-margin.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Testcase for bug 724352</title>
+    <style type="text/css">
+
+        html,body {
+            color:black; background-color:white; font-size:16px; padding:0; margin:0;
+        }
+	
+x1,x2,x3,x4,x5,x6 { display:block; }
+x2 { overflow:auto; width:100px; background:grey; }
+x4 { width: 70px; margin: 0 20px; }
+    </style>
+</head>
+<body>
+
+<x1><x2 style="height:50px;">
+  <x4 style="height:20px; background:lime; "></x4>
+</x2>
+
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/margin-collapsing/scrollable-vertical-margin-ref.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Testcase for bug 724352</title>
+    <style type="text/css">
+
+        html,body {
+            color:black; background-color:white; font-size:16px; padding:0; margin:0;
+        }
+	
+x1,x2,x3,x4,x5,x6 { display:block; }
+x7 {display:block; height:20px;background:lime;}
+    </style>
+</head>
+<body>
+
+<x1><x2 style="overflow:auto; background:grey; height:50px;">
+  <x3><x4 style="padding:20px 0 10px 0; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:70px;">
+  <x3 style="padding-bottom:30px"><x4 style="padding-top:20px; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:60px;">
+  <x3 style="padding-bottom:10px"><x4 style="padding-top:20px; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:50px;">
+  <x3 style="padding-bottom:10px"><x4 style="padding-top:20px; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:60px;">
+  <x3><x4 style="padding:20px 0; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:60px;">
+  <x3><x4 style="padding:20px 0; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:50px;">
+  <x3><x4 style="padding:10px 0 20px 0; height:20px;"><x7></x7></x4></x3>
+</x2>
+<x6 style="padding-top:10px">x</x6></x1>
+
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/margin-collapsing/scrollable-vertical-margin.html
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML>
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Testcase for bug 724352</title>
+    <style type="text/css">
+
+        html,body {
+            color:black; background-color:white; font-size:16px; padding:0; margin:0;
+        }
+	
+x1,x2,x3,x4,x5,x6 { display:block; }
+    </style>
+</head>
+<body>
+
+<x1><x2 style="overflow:auto; background:grey; height:50px;">
+  <x3 style="margin-bottom:-10px"><x4 style="margin:20px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:70px;">
+  <x3 style="margin-bottom:30px"><x4 style="margin:20px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:60px;">
+  <x3 style="margin-bottom:10px"><x4 style="margin:20px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:50px;">
+  <x3 style="margin-bottom:20px"><x4 style="margin:20px 0 -10px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:60px;">
+  <x3 style="margin-bottom:20px"><x4 style="margin:20px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:60px;">
+  <x3 style="margin-top:20px"><x4 style="margin:20px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+
+<x1><x2 style="overflow:auto; background:grey; height:50px;">
+  <x3 style="margin-top:-10px"><x4 style="margin:20px 0; height:20px; background:lime; "></x4></x3>
+</x2>
+<x6 style="margin-top:10px">x</x6></x1>
+
+
+</body>
+</html>