Fix for shrink-to-fit computation for positioned elements

David Hyatt hyatt at apple.com
Wed Oct 8 19:47:38 CEST 2003


This patch fixes the DHTML menus at the top of

http://www.peterwhitecycles.com/alize.asp

The shrink-to-fit computation was wrong and did not match what is 
mentioned in the CSS2.1 specification.  I changed the code to match the 
spec, and that fixed the bug.

-------------- next part --------------
Index: khtml/rendering/render_box.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_box.cpp,v
retrieving revision 1.86
diff -u -p -r1.86 khtml/rendering/render_box.cpp
--- khtml/rendering/render_box.cpp	2003/10/09 00:45:35	1.86
+++ khtml/rendering/render_box.cpp	2003/10/09 01:17:50
@@ -1155,7 +1155,9 @@ void RenderBox::calcAbsoluteHorizontal()
         //1. solve left & width.
         if (l==AUTO && w==AUTO && r!=AUTO)
         {
-            w = QMIN(m_maxWidth-pab, cw - ( r + ml + mr + pab));
+            // From section 10.3.7 of the CSS2.1 specification.
+            // "The shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width)."
+            w = QMIN(m_maxWidth-pab, QMAX(m_minWidth-pab, cw - ( r + ml + mr + pab)));
             l = cw - ( r + w + ml + mr + pab);
         }
         else
@@ -1180,7 +1182,9 @@ void RenderBox::calcAbsoluteHorizontal()
         //3. solve width & right.
         if (l!=AUTO && w==AUTO && r==AUTO)
         {
-            w = QMIN(m_maxWidth-pab, cw - ( l + ml + mr + pab));
+            // From section 10.3.7 of the CSS2.1 specification.
+            // "The shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width)."
+            w = QMIN(m_maxWidth-pab, QMAX(m_minWidth-pab, cw - ( l + ml + mr + pab)));
             r = cw - ( l + w + ml + mr + pab);
         }
         else
-------------- next part --------------


dave
(hyatt at apple.com)


More information about the Khtml-devel mailing list