Fix a bug I accidentally introduced in static positioned elements. Add more margin...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2004 02:34:56 +0000 (02:34 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2004 02:34:56 +0000 (02:34 +0000)
        * ChangeLog:
        * khtml/rendering/render_block.cpp:
        (khtml::RenderBlock::layoutBlockChildren):
        * layout-tests/fast/block/margin-collapse/044-expected.txt: Added.
        * layout-tests/fast/block/margin-collapse/044.html: Added.
        * layout-tests/fast/block/margin-collapse/045-expected.txt: Added.
        * layout-tests/fast/block/margin-collapse/045.html: Added.
        * layout-tests/fast/block/margin-collapse/062-expected.txt: Added.
        * layout-tests/fast/block/margin-collapse/062.html: Added.
        * layout-tests/fast/block/margin-collapse/063-expected.txt: Added.
        * layout-tests/fast/block/margin-collapse/063.html: Added.
        * layout-tests/fast/block/positioning/007-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@5968 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/fast/block/margin-collapse/044-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/044.html [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/045-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/045.html [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/062-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/062.html [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/063-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/margin-collapse/063.html [new file with mode: 0644]
LayoutTests/fast/block/positioning/007-expected.txt
WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_block.cpp

diff --git a/LayoutTests/fast/block/margin-collapse/044-expected.txt b/LayoutTests/fast/block/margin-collapse/044-expected.txt
new file mode 100644 (file)
index 0000000..6bee99c
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x68
+  RenderBlock {HTML} at (0,0) size 800x68 [border: (1px solid #C0C0C0)]
+    RenderBody {BODY} at (1,17) size 798x34
+      RenderBlock (floating) {DIV} at (16,0) size 336x34 [bgcolor=#00FFFF]
+        RenderText {TEXT} at (8,8) size 53x18
+          text run at (8,8) width 53: "FLOAT"
+      RenderBlock (anonymous) at (0,0) size 798x0
+        RenderText {TEXT} at (0,0) size 0x0
+      RenderBlock {DIV} at (16,0) size 766x34 [bgcolor=#FFFF00]
+        RenderText {TEXT} at (352,8) size 56x18
+          text run at (352,8) width 56: "BLOCK"
diff --git a/LayoutTests/fast/block/margin-collapse/044.html b/LayoutTests/fast/block/margin-collapse/044.html
new file mode 100644 (file)
index 0000000..b017e83
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>Bug 204831: 1</title>
+  <style type="text/css">
+   * { margin: 0; padding: 0; border: 0; }
+   html { border: solid thin silver; }
+   div { margin: 1em; padding: 0.5em; background: yellow; }
+   .float { width: 20em; margin: 0 1em; float: left; background: aqua; }
+  </style>
+ </head>
+ <body>
+  <div class="float"> FLOAT </div>
+  <div> BLOCK </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/block/margin-collapse/045-expected.txt b/LayoutTests/fast/block/margin-collapse/045-expected.txt
new file mode 100644 (file)
index 0000000..3d037a2
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x86
+  RenderBlock {HTML} at (0,0) size 800x86 [border: (1px solid #C0C0C0)]
+    RenderBody {BODY} at (1,1) size 798x68
+      RenderBlock (floating) {DIV} at (16,0) size 336x34 [bgcolor=#00FFFF]
+        RenderText {TEXT} at (8,8) size 53x18
+          text run at (8,8) width 53: "FLOAT"
+      RenderBlock (anonymous) at (0,0) size 798x0
+        RenderText {TEXT} at (0,0) size 0x0
+      RenderBlock {DIV} at (16,34) size 766x34 [bgcolor=#FFFF00]
+        RenderText {TEXT} at (8,8) size 56x18
+          text run at (8,8) width 56: "BLOCK"
diff --git a/LayoutTests/fast/block/margin-collapse/045.html b/LayoutTests/fast/block/margin-collapse/045.html
new file mode 100644 (file)
index 0000000..0856036
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>Bug 204831: 2</title>
+  <style type="text/css">
+   * { margin: 0; padding: 0; border: 0; }
+   html { border: solid thin silver; }
+   div { margin: 1em; padding: 0.5em; background: yellow; }
+   .float { width: 20em; margin: 0 1em; float: left; background: aqua; }
+   .clear { clear: left }
+  </style>
+ </head>
+ <body>
+  <div class="float"> FLOAT </div>
+  <div class="clear"> BLOCK </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/block/margin-collapse/062-expected.txt b/LayoutTests/fast/block/margin-collapse/062-expected.txt
new file mode 100644 (file)
index 0000000..82579a6
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x46 layerType: background only
+layer at (10,46) size 320x64
+  RenderBlock (positioned) zI: -1 {DIV} at (10,46) size 320x64 [color=#FFFF00] [bgcolor=#FF0000]
+    RenderText zI: -1 {TEXT} at (0,0) size 36x18
+      text run at (0,0) width 36: "FAIL"
+layer at (0,0) size 800x46 layerType: foreground only
+  RenderBlock {HTML} at (0,0) size 800x46
+    RenderBody {BODY} at (10,46) size 780x0
+      RenderBlock {DIV} at (2,0) size 776x0
+        RenderBlock {DIV} at (20,0) size 736x0
+          RenderBlock {DIV} at (0,0) size 736x0
+      RenderBlock (floating) {DIV} at (0,0) size 320x64 [color=#FFFFFF] [bgcolor=#008000]
+        RenderText {TEXT} at (0,0) size 175x18
+          text run at (0,0) width 175: "This block should be green."
+      RenderBlock {DIV} at (50,0) size 680x0
diff --git a/LayoutTests/fast/block/margin-collapse/062.html b/LayoutTests/fast/block/margin-collapse/062.html
new file mode 100644 (file)
index 0000000..a3bf3d0
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+  <title>Margin collapsing with floats before self collapsing children with margins collapsing with parent</title>
+  <style type="text/css">
+   /* This test requires half-decent z-index support */
+   /* Rendering should not not match 061.html! */
+   html { margin: 0; padding: 0; }
+   body { margin: 0 10px; padding: 0; }
+   .a { position: absolute; top: 46px; left: 10px; width: 20em; height: 4em; background: red; color: yellow; z-index: -1; }
+   .b { float: left; width: 20em; height: 4em; background: green; color: white; }
+   .c1 { margin: 2px; }
+   .c2 { margin: -4px 20px; }
+   .c3 { margin: 0 0 14px; }
+   .c4 { margin: 50px; }
+  </style>
+ </head>
+ <body>
+  <div class="c1">
+   <div class="c2">
+    <div class="c3"></div>
+   </div>
+  </div>
+  <div class="a">FAIL</div>
+  <div class="b">This block should be green.</div>
+  <div class="c4"></div>
+ </body>
+</html>
diff --git a/LayoutTests/fast/block/margin-collapse/063-expected.txt b/LayoutTests/fast/block/margin-collapse/063-expected.txt
new file mode 100644 (file)
index 0000000..f881631
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x49 layerType: background only
+layer at (10,13) size 320x64
+  RenderBlock (positioned) zI: -1 {DIV} at (10,13) size 320x64 [color=#FFFF00] [bgcolor=#FF0000]
+    RenderText zI: -1 {TEXT} at (0,0) size 36x18
+      text run at (0,0) width 36: "FAIL"
+layer at (0,0) size 800x49 layerType: foreground only
+  RenderBlock {HTML} at (0,0) size 800x49
+    RenderBody {BODY} at (10,2) size 780x1
+      RenderBlock {DIV} at (2,0) size 776x1
+        RenderBlock {DIV} at (20,11) size 736x0
+          RenderBlock {DIV} at (0,0) size 736x0
+      RenderBlock (floating) {DIV} at (0,11) size 320x64 [color=#FFFFFF] [bgcolor=#008000]
+        RenderText {TEXT} at (0,0) size 175x18
+          text run at (0,0) width 175: "This block should be green."
+      RenderBlock {DIV} at (50,47) size 680x0
diff --git a/LayoutTests/fast/block/margin-collapse/063.html b/LayoutTests/fast/block/margin-collapse/063.html
new file mode 100644 (file)
index 0000000..3a94c47
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+  <title>Margin collapsing with floats before self collapsing children with margins not collapsing with parent</title>
+  <style type="text/css">
+   /* This test requires half-decent z-index support */
+   html { margin: 0; padding: 0; }
+   body { margin: 0 10px; padding: 0; }
+   .a { position: absolute; top: 13px; left: 10px; width: 20em; height: 4em; background: red; color: yellow; z-index: -1; }
+   .b { float: left; width: 20em; height: 4em; background: green; color: white; }
+   .c1 { margin: 2px; padding-top: 1px; } /* prevent collapsing with parent */
+   .c2 { margin: -4px 20px; }
+   .c3 { margin: 0 0 14px; }
+   .c4 { margin: 50px; }
+  </style>
+ </head>
+ <body>
+  <div class="c1">
+   <div class="c2">
+    <div class="c3"></div>
+   </div>
+  </div>
+  <div class="a">FAIL</div>
+  <div class="b">This block should be green.</div>
+  <div class="c4"></div>
+ </body>
+</html>
index e731b2d4dfece364e6420a8c35a85e87d9a0662c..27378a4e86a6a104f7701be5136deb01d91c6746 100644 (file)
@@ -3,5 +3,5 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x116
   RenderBlock {HTML} at (0,0) size 800x116
     RenderBody {BODY} at (8,8) size 784x100
-      RenderBlock zI: 2 {DIV} at (0,0) size 100x100 [bgcolor=#FF0000]
-      RenderBlock zI: 1 {DIV} at (0,0) size 100x100 [bgcolor=#008000]
+      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#FF0000]
+      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
index 76d5213bc29be7db592472379eba6f614f7e6b72..dedbae36f4a80bc94ac3682dfaf5f82776268fd1 100644 (file)
@@ -1,3 +1,32 @@
+2004-01-22  David Hyatt  <hyatt@apple.com>
+
+       Fix a bug I accidentally introduced in static positioned elements.  Add more margin collapsing tests.
+       
+        * ChangeLog:
+        * khtml/rendering/render_block.cpp:
+        (khtml::RenderBlock::layoutBlockChildren):
+        * layout-tests/fast/block/margin-collapse/044-expected.txt: Added.
+        * layout-tests/fast/block/margin-collapse/044.html: Added.
+        * layout-tests/fast/block/margin-collapse/045-expected.txt: Added.
+        * layout-tests/fast/block/margin-collapse/045.html: Added.
+        * layout-tests/fast/block/margin-collapse/062-expected.txt: Added.
+        * layout-tests/fast/block/margin-collapse/062.html: Added.
+        * layout-tests/fast/block/margin-collapse/063-expected.txt: Added.
+        * layout-tests/fast/block/margin-collapse/063.html: Added.
+        * layout-tests/fast/block/positioning/007-expected.txt:
+
+2004-01-22  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        * khtml/rendering/render_block.cpp:
+        (khtml::RenderBlock::layoutBlockChildren):
+        * layout-tests/fast/block/margin-collapse/062-expected.txt: Added.
+        * layout-tests/fast/block/margin-collapse/062.html: Added.
+        * layout-tests/fast/block/margin-collapse/063-expected.txt: Added.
+        * layout-tests/fast/block/margin-collapse/063.html: Added.
+        * layout-tests/fast/block/positioning/007-expected.txt:
+
 2004-01-22  David Hyatt  <hyatt@apple.com>
 
        (1) Implement better XML error handling.
index 719548fee0ff7d2876c75e168ebe191d821c27f3..1cbe61eefd81700f4d8276fa8edf2d61a2cdf47a 100644 (file)
@@ -622,7 +622,19 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
                     child->setStaticX(borderRight()+paddingRight());
             }
             if (child->hasStaticY()) {
-                int marginOffset = (!topMarginContributor || !canCollapseTopWithChildren) ? (prevPosMargin - prevNegMargin) : 0;
+                int marginOffset = 0;
+                bool shouldSynthesizeCollapse = (!topMarginContributor || !canCollapseTopWithChildren);
+                if (shouldSynthesizeCollapse) {
+                    int collapsedTopPos = prevPosMargin;
+                    int collapsedTopNeg = prevNegMargin;
+                    bool posMargin = child->marginTop() >= 0;
+                    if (posMargin && child->marginTop() > collapsedTopPos)
+                        collapsedTopPos = child->marginTop();
+                    else if (!posMargin && child->marginTop() > collapsedTopNeg)
+                        collapsedTopNeg = child->marginTop();
+                    marginOffset += (collapsedTopPos - collapsedTopNeg) - child->marginTop();
+                }
+                
                 int yPosEstimate = m_height + marginOffset;
                 child->setStaticY(yPosEstimate);
             }