[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:52:07 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 5168fbcb834fe2cccda3044014e3d4a444a8457c
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 22 07:51:25 2002 +0000

    	Ok, this patch does a lot of stuff.  It contains a complete
    	rewrite of the WinIE quirk for handling collapsing margins
    	at the tops and bottoms of table cells.  We match WinIE's
    	behavior for all HTML4 block-level elements.
    
    	This patch also applies a bottom margin to <form> elements,
    	which is what was causing the missing space on livepage.apple.com
    	underneath the textfield on the right.  WinIE and Gecko both
    	put a bottom margin on all forms.
    
    	This patch also updates the collapsing margin code to detect
    	inlines that have been morphed into blocks by KHTML (this is
    	so wrong, don't even get me started, you can't treat an inline
    	as a block, this code is lame, etc. etc.) and to properly ignore
    	their margins completely.  Fixing the code to not morph inlines
    	is another architectural problem that will have to be dealt
    	with (sigh).
    
            * khtml/css/css_valueimpl.h:
            * khtml/css/cssparser.cpp:
            (StyleBaseImpl::parseValue):
            (StyleBaseImpl::parseUnit):
            * khtml/css/cssparser.h:
            * khtml/css/cssstyleselector.cpp:
            * khtml/css/html4.css:
            * khtml/misc/khtmllayout.h:
            * khtml/rendering/render_flow.cpp:
            (RenderFlow::RenderFlow):
            (RenderFlow::layout):
            (RenderFlow::layoutBlockChildren):
            (RenderFlow::addChild):
            * khtml/rendering/render_flow.h:
            * khtml/rendering/render_object.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2406 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index abf6e30..f349661 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,39 @@
+2002-10-22  David Hyatt  <hyatt at apple.com>
+
+	Ok, this patch does a lot of stuff.  It contains a complete
+	rewrite of the WinIE quirk for handling collapsing margins
+	at the tops and bottoms of table cells.  We match WinIE's
+	behavior for all HTML4 block-level elements.
+
+	This patch also applies a bottom margin to <form> elements,
+	which is what was causing the missing space on livepage.apple.com
+	underneath the textfield on the right.  WinIE and Gecko both
+	put a bottom margin on all forms.
+
+	This patch also updates the collapsing margin code to detect
+	inlines that have been morphed into blocks by KHTML (this is 
+	so wrong, don't even get me started, you can't treat an inline
+	as a block, this code is lame, etc. etc.) and to properly ignore
+	their margins completely.  Fixing the code to not morph inlines
+	is another architectural problem that will have to be dealt
+	with (sigh).
+	
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssparser.cpp:
+        (StyleBaseImpl::parseValue):
+        (StyleBaseImpl::parseUnit):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/html4.css:
+        * khtml/misc/khtmllayout.h:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::RenderFlow):
+        (RenderFlow::layout):
+        (RenderFlow::layoutBlockChildren):
+        (RenderFlow::addChild):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_object.h:
+
 2002-10-21  Darin Adler  <darin at apple.com>
 
         * kwq/KWQInputDialog.mm: (QInputDialog::getText): Call the view factory to do the
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index abf6e30..f349661 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,39 @@
+2002-10-22  David Hyatt  <hyatt at apple.com>
+
+	Ok, this patch does a lot of stuff.  It contains a complete
+	rewrite of the WinIE quirk for handling collapsing margins
+	at the tops and bottoms of table cells.  We match WinIE's
+	behavior for all HTML4 block-level elements.
+
+	This patch also applies a bottom margin to <form> elements,
+	which is what was causing the missing space on livepage.apple.com
+	underneath the textfield on the right.  WinIE and Gecko both
+	put a bottom margin on all forms.
+
+	This patch also updates the collapsing margin code to detect
+	inlines that have been morphed into blocks by KHTML (this is 
+	so wrong, don't even get me started, you can't treat an inline
+	as a block, this code is lame, etc. etc.) and to properly ignore
+	their margins completely.  Fixing the code to not morph inlines
+	is another architectural problem that will have to be dealt
+	with (sigh).
+	
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssparser.cpp:
+        (StyleBaseImpl::parseValue):
+        (StyleBaseImpl::parseUnit):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/html4.css:
+        * khtml/misc/khtmllayout.h:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::RenderFlow):
+        (RenderFlow::layout):
+        (RenderFlow::layoutBlockChildren):
+        (RenderFlow::addChild):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_object.h:
+
 2002-10-21  Darin Adler  <darin at apple.com>
 
         * kwq/KWQInputDialog.mm: (QInputDialog::getText): Call the view factory to do the
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index abf6e30..f349661 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,39 @@
+2002-10-22  David Hyatt  <hyatt at apple.com>
+
+	Ok, this patch does a lot of stuff.  It contains a complete
+	rewrite of the WinIE quirk for handling collapsing margins
+	at the tops and bottoms of table cells.  We match WinIE's
+	behavior for all HTML4 block-level elements.
+
+	This patch also applies a bottom margin to <form> elements,
+	which is what was causing the missing space on livepage.apple.com
+	underneath the textfield on the right.  WinIE and Gecko both
+	put a bottom margin on all forms.
+
+	This patch also updates the collapsing margin code to detect
+	inlines that have been morphed into blocks by KHTML (this is 
+	so wrong, don't even get me started, you can't treat an inline
+	as a block, this code is lame, etc. etc.) and to properly ignore
+	their margins completely.  Fixing the code to not morph inlines
+	is another architectural problem that will have to be dealt
+	with (sigh).
+	
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssparser.cpp:
+        (StyleBaseImpl::parseValue):
+        (StyleBaseImpl::parseUnit):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/html4.css:
+        * khtml/misc/khtmllayout.h:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::RenderFlow):
+        (RenderFlow::layout):
+        (RenderFlow::layoutBlockChildren):
+        (RenderFlow::addChild):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_object.h:
+
 2002-10-21  Darin Adler  <darin at apple.com>
 
         * kwq/KWQInputDialog.mm: (QInputDialog::getText): Call the view factory to do the
diff --git a/WebCore/khtml/css/css_valueimpl.h b/WebCore/khtml/css/css_valueimpl.h
index a080ba1..4040272 100644
--- a/WebCore/khtml/css/css_valueimpl.h
+++ b/WebCore/khtml/css/css_valueimpl.h
@@ -210,6 +210,8 @@ public:
     virtual bool parseString( const DOMString &string, bool = false);
     virtual DOM::DOMString cssText() const;
 
+    virtual bool isQuirkValue() { return false; }
+    
 protected:
     int m_type;
     union {
@@ -222,6 +224,21 @@ protected:
     } m_value;
 };
 
+// This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
+// The basic idea is that a stylesheet can use the value _qem (for quirky em) instead of em
+// in a stylesheet.  When the quirky value is used, if you're in quirks mode, the margin will
+// collapse away inside a table cell.
+class CSSQuirkPrimitiveValueImpl : public CSSPrimitiveValueImpl
+{
+public:
+    CSSQuirkPrimitiveValueImpl(float num, CSSPrimitiveValue::UnitTypes type)
+      :CSSPrimitiveValueImpl(num, type) {}
+    
+    virtual ~CSSQuirkPrimitiveValueImpl() {}
+    
+    virtual bool isQuirkValue() { return true; }
+};
+
 class CounterImpl : public khtml::Shared<CounterImpl> {
 public:
     CounterImpl() { }
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 01576b7..ec38f6c 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -1806,7 +1806,14 @@ bool StyleBaseImpl::parseValue( const QChar *curP, const QChar *endP, int propId
 	  if (cssval && cssval->id == CSS_VAL_AUTO) {
             parsedValue = new CSSPrimitiveValueImpl(cssval->id);
 	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH | PERCENT );
+            // Deal with a quirk case.  We allow a special quirk unit, _qem, to 
+            // denote a margin that is allowed to collapse away in quirks mode
+            // when at the top/bottom of a reflow root like a body, td, or th.
+            // This is a WinIE quirk. -dwh
+            if (propId == CSS_PROP_MARGIN_TOP || propId == CSS_PROP_MARGIN_BOTTOM)
+                parsedValue = parseUnit(curP, endP, LENGTH | PERCENT | COLLAPSIBLE);
+            else
+                parsedValue = parseUnit(curP, endP, LENGTH | PERCENT);
 	  }
 	  break;
 	}
@@ -2573,12 +2580,39 @@ StyleBaseImpl::parseUnit(const QChar * curP, const QChar *endP, int allowedUnits
     CSSPrimitiveValue::UnitTypes type = CSSPrimitiveValue::CSS_UNKNOWN;
     StyleBaseImpl::Units unit = StyleBaseImpl::UNKNOWN;
 
+    bool collapsible = false;
+    
     switch(split->latin1())
     {
     case '%':
         type = CSSPrimitiveValue::CSS_PERCENTAGE;
         unit =StyleBaseImpl:: PERCENT;
         break;
+    case '_':
+        if (!(allowedUnits & COLLAPSIBLE))
+            break;
+        split++;
+        if (split > endP) break;
+        switch (split->latin1()) {
+        case 'q':
+            split++;
+            if (split > endP) break;
+            switch (split->latin1()) {
+            case 'e':
+                split++;
+                if(split > endP) break;
+                switch(split->latin1())
+                {
+                    case 'm':
+                        type = CSSPrimitiveValue::CSS_EMS;
+                        unit = StyleBaseImpl::LENGTH;
+                        collapsible = true;
+                        break;
+                }
+            }
+            break;
+        }
+        break;
     case 'e':
         split++;
         if(split > endP) break;
@@ -2677,6 +2711,8 @@ StyleBaseImpl::parseUnit(const QChar * curP, const QChar *endP, int allowedUnits
 #ifdef CSS_DEBUG
         kdDebug( 6080 ) << "found allowed number " << value << ", unit " << type << endl;
 #endif
+        if (collapsible)
+            return new CSSQuirkPrimitiveValueImpl(value, type);
         return new CSSPrimitiveValueImpl(value, type);
     }
 
diff --git a/WebCore/khtml/css/cssparser.h b/WebCore/khtml/css/cssparser.h
index d0d05c4..113b585 100644
--- a/WebCore/khtml/css/cssparser.h
+++ b/WebCore/khtml/css/cssparser.h
@@ -187,7 +187,8 @@ public:
 	    ANGLE     = 0x0010,
 	    TIME      = 0x0020,
 	    FREQUENCY = 0x0040,
-	    NONNEGATIVE = 0x0080
+	    NONNEGATIVE = 0x0080,
+        COLLAPSIBLE = 0x010
 	};
 
 	/* called by parseValue, parses numbers+units */
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 20490da..1e4ce0a 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -761,7 +761,11 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
         // elements for the moment
 	const QString& value = sel->value.string();
 //	kdDebug() << "CSSOrderedRule::pseudo " << value << endl;
-	if(value == "first-child") {
+	if (value == "empty") {
+        if (!e->firstChild())
+            return true;
+	}
+	else if(value == "first-child") {
 	    // first-child matches the first child that is an element!
 	    DOM::NodeImpl *n = e->parentNode()->firstChild();
 	    while( n && !n->isElementNode() )
@@ -2122,7 +2126,9 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         } else if(primitiveValue && !apply) {
             int type = primitiveValue->primitiveType();
             if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
-                l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
+                // Handle our quirky margin units if we have them.
+                l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed, 
+                           primitiveValue->isQuirkValue());
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
                 l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
             else
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index 8d47830..ef09c80 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -60,7 +60,7 @@ script {
 
 p {
 	display: block;
-	margin: 1.0em 0px;
+	margin: 1.0_qem 0px;
 }
 
 div {
@@ -83,8 +83,8 @@ address {
       
 blockquote {
 	display: block;
-	margin: 1em 40px;
-        -konq-flow-mode: -konq-around-floats
+	margin: 1_qem 40px 1em 40px;
+    -konq-flow-mode: -konq-around-floats
 }
 
 Q        {
@@ -153,41 +153,41 @@ embed {
 H1 { 
 	display: block;
 	font-size: 1.7em; 
-	margin: .67em auto;
+	margin: .67__qem auto .67em auto;
 	font-weight: bolder;
 }
       
 H2 { 
 	display: block;
 	font-size: 1.4em; 
-	margin: .83em auto;
+	margin: .83_qem auto .87em auto;
 	font-weight: bolder;
 }
       
 H3 { 
 	display: block;
 	font-size: 1.17em; 
-	margin: 1em auto;
+	margin: 1_qem auto 1em auto;
 	font-weight: bolder;
 }
       
 H4 {
 	display: block;
-	margin: 1.0em auto;
+	margin: 1.0_qem auto 1.0em auto;
 	font-weight: bolder;
 }
 
 H5 { 
 	display: block;
 	font-size: .83em; 
-	margin: 1.67em auto;
+	margin: 1.67_qem auto 1.67em auto;
 	font-weight: bolder;
 }
 
 H6 { 
 	display: block;
 	font-size: .67em; 
-	margin: 2.33em auto;
+	margin: 2.33_qem auto 2.33em auto;
 	font-weight: bolder;
 }
 
@@ -290,7 +290,7 @@ TD[align="left"] > HR { margin-left: 0px; margin-right: auto; }
 UL, MENU, DIR {
         display: block;
         list-style-type: disc;
-        margin: 1em 0;
+        margin: 1_qem 0 1em 0;
         padding-left: 40px;
         -konq-flow-mode: -konq-around-floats
 }
@@ -298,7 +298,7 @@ UL, MENU, DIR {
 OL {
         display: block;
         list-style-type: decimal;
-        margin: 1em 0;
+        margin: 1_qem 0 1em 0;
         padding-left: 40px;
         -konq-flow-mode: -konq-around-floats
 }
@@ -328,8 +328,8 @@ DD {
 
 DL {
 	display: block;
-	margin: 1em 0;
-        -konq-flow-mode: -konq-around-floats
+	margin: 1_qem 0 1em 0;
+    -konq-flow-mode: -konq-around-floats
 } 
 
 DT {
@@ -371,6 +371,7 @@ LI > DIV {
 
 FORM {
 	display: block;
+    margin: 0 0 1em 0;
 }
 
 FIELDSET {
@@ -556,14 +557,16 @@ marquee {
         display: none;
 }
 
-
-/* Give floated images margins of 3px */
-img[align="left"] {
-	margin-right: 3px;
-}
-
-img[align="right"] {
-	margin-left: 3px;
+ at konq-quirks
+{
+    /* Give floated images margins of 3px */
+    img[align="left"] {
+        margin-right: 3px;
+    }
+    
+    img[align="right"] {
+        margin-left: 3px;
+    }
 }
 
 /* noscript is handled internally, as it depends on the html settings */
diff --git a/WebCore/khtml/misc/khtmllayout.h b/WebCore/khtml/misc/khtmllayout.h
index abe8c7a..872f03f 100644
--- a/WebCore/khtml/misc/khtmllayout.h
+++ b/WebCore/khtml/misc/khtmllayout.h
@@ -45,8 +45,8 @@ namespace khtml
     struct Length
     {
 	Length() { *((Q_UINT32 *)this) = 0; }
-        Length(LengthType t) { type = t; value = 0; }
-        Length(int v, LengthType t) : value(v), type(t) {}
+        Length(LengthType t) { type = t; value = 0; quirk = false; }
+        Length(int v, LengthType t, bool q=false) : value(v), type(t), quirk(q) {}
         Length(const Length &o)
 	    { *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); }
 
@@ -97,8 +97,9 @@ namespace khtml
         bool isFixed() const { return (type == Fixed); }
         bool isStatic() const { return (type == Static); }
 
-        int value : 29;
+        int value : 28;
         LengthType type : 3;
+        bool quirk : 1;
     };
 
 };
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index 0ced634..70b3e36 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -54,6 +54,7 @@ RenderFlow::RenderFlow(DOM::NodeImpl* node)
     specialObjects = 0;
     
     m_maxTopPosMargin = m_maxTopNegMargin = m_maxBottomPosMargin = m_maxBottomNegMargin = 0;
+    m_topMarginQuirk = m_bottomMarginQuirk = false;
 }
 
 void RenderFlow::setStyle(RenderStyle *_style)
@@ -241,6 +242,9 @@ void RenderFlow::layout()
             m_maxBottomPosMargin = m_marginBottom;
         else
             m_maxBottomNegMargin = -m_marginBottom;
+            
+        m_topMarginQuirk = style()->marginTop().quirk;
+        m_bottomMarginQuirk = style()->marginBottom().quirk;
     }
     
     // A quirk that has become an unfortunate standard.  Positioned elements, floating elements
@@ -363,11 +367,6 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
     // self-collapsing blocks.
     bool topMarginContributor = true;
     
-    // The last non-collapsed child we encountered.      
-    // We will avoid throwing away the bottom margins if the last non-collapsed child encountered is
-    // an H1-H6 element. -dwh
-    RenderObject* lastNonCollapsedChild = 0;
-    
     // These flags track the previous maximal positive and negative margins.
     int prevPosMargin = maxTopMargin(true);
     int prevNegMargin = maxTopMargin(false);
@@ -379,6 +378,11 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
     int oldPosMargin = prevPosMargin;
     int oldNegMargin = prevNegMargin;
     
+    bool topChildQuirk = false;
+    bool bottomChildQuirk = false;
+    
+    bool strictMode = (element()->getDocument()->parseMode() == DocumentImpl::Strict);
+    
     //kdDebug() << "RenderFlow::layoutBlockChildren " << prevMargin << endl;
 
     // take care in case we inherited floats
@@ -446,16 +450,37 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
             int posTop = child->maxTopMargin(true);
             int negTop = child->maxTopMargin(false);
             
+            // XXX A hack we have to put in to deal with the fact
+            // that KHTML incorrectly morphs inlines with blocks
+            // inside them into blocks themselves.
+            if (child->style()->display() == INLINE)
+                posTop = negTop = 0;
+                
+            // See if the top margin is quirky. We only care if this child has
+            // margins that will collapse with us.
+            bool topQuirk = (posTop-negTop) != 0 ? child->isTopMarginQuirk() : false;
+            
             if (canCollapseWithChildren && topMarginContributor && !clearOccurred) {
                 // This child is collapsing with the top of the
                 // block.  If it has larger margin values, then we need to update
                 // our own maximal values.
                 if (posTop > m_maxTopPosMargin)
                     m_maxTopPosMargin = posTop;
+                
                 if (negTop > m_maxTopNegMargin)
                     m_maxTopNegMargin = negTop;
+                 
+                // The minute any of the margins involved isn't a quirk, don't
+                // collapse it away, even if the margin is smaller (www.webreference.com
+                // has an example of this, a <dt> with 0.8em author-specified inside
+                // a <dl> inside a <td>.
+                if (!topQuirk)
+                    m_topMarginQuirk = false;
             }
             
+            if (isTableCell() && topMarginContributor)
+                topChildQuirk = topQuirk;
+            
             int ypos = m_height;
             if (child->isSelfCollapsingBlock()) {
                 // This child has no height.  Update our previous pos and neg
@@ -473,11 +498,10 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
                     ypos = m_height + prevPosMargin - prevNegMargin;
             }
             else {
-                lastNonCollapsedChild = child;
                 if (!topMarginContributor || 
-                     (!canCollapseWithChildren && 
-                      (element()->getDocument()->parseMode() == DocumentImpl::Strict ||
-                        !isTableCell()))) {
+                    (!canCollapseWithChildren 
+                       && (strictMode || !isTableCell() || !topChildQuirk)
+                    )) {
                     // We're collapsing with a previous sibling's margins and not
                     // with the top of the block.
                     int absPos = prevPosMargin > posTop ? prevPosMargin : posTop;
@@ -488,6 +512,15 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
                 }
                 prevPosMargin = child->maxBottomMargin(true);
                 prevNegMargin = child->maxBottomMargin(false);
+                
+                // XXX A hack we have to put in to deal with the fact
+                // that KHTML incorrectly morphs inlines with blocks
+                // inside them into blocks themselves.
+                if (child->style()->display() == INLINE)
+                    prevPosMargin = prevNegMargin = 0;
+                
+                bottomChildQuirk = 
+                  (prevPosMargin-prevNegMargin) != 0 ? child->isBottomMarginQuirk() : false;
             }
             child->setPos(child->xPos(), ypos);
         }
@@ -570,23 +603,11 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
     if (canCollapseWithChildren && !autoHeight)
         canCollapseWithChildren = false;
     
-    // XXX This is a gross hack. Basically if the last child is marginless, we will (in quirks
-    // mode) allow the collapsed bottom margin to be added to the table cell.  This is a sleazy
-    // way of keeping <td><p>Foo</p></td> from showing a bottom margin but still allowing
-    // <td><font><h3>Foo</h3></font></td> to show a bottom margin.  
-    // A better fix (since we only cared about H1-H6 in the first place would be to recur
-    // into the last non-collapsed children until you don't find one any more, and if that
-    // innermost child was an H1-H6, use it. -dwh
-    int marginBottom = -1;
-    if (lastNonCollapsedChild)
-        marginBottom = lastNonCollapsedChild->marginBottom();
-    
     // If we can't collapse with children then go ahead and add in the bottom margins.
-    if (!canCollapseWithChildren && !topMarginContributor &&
-        (element()->getDocument()->parseMode() == DocumentImpl::Strict ||
-         !isTableCell() || (lastNonCollapsedChild && lastNonCollapsedChild->element() &&
-           lastNonCollapsedChild->element()->id() >= ID_H1 && 
-           lastNonCollapsedChild->element()->id() <= ID_H6) || (marginBottom == 0)))
+    if (!topMarginContributor && 
+        (!canCollapseWithChildren 
+            && (strictMode || !isTableCell() || !bottomChildQuirk)
+        ))
         m_height += prevPosMargin - prevNegMargin;
         
     m_height += toAdd;
@@ -601,8 +622,12 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
         // with our children.
         if (prevPosMargin > m_maxBottomPosMargin)
             m_maxBottomPosMargin = prevPosMargin;
+        
         if (prevNegMargin > m_maxBottomNegMargin)
             m_maxBottomNegMargin = prevNegMargin;
+           
+        if (!bottomChildQuirk)
+            m_bottomMarginQuirk = false;
     }
     
     setLayouted();
@@ -1620,16 +1645,19 @@ void RenderFlow::addChild(RenderObject *newChild, RenderObject *beforeChild)
 
     if(!newChild->isInline()) // block child
     {
+        // XXX This is all just completely wrong and is going to have to be
+        // rewritten. -dwh
+        
         // If we are inline ourselves and have become block, we have to make sure our parent
         // makes the necessary adjustments so that all of its other children are moved into
         // anonymous block boxes where necessary
         if (style()->display() == INLINE)
         {
             setInline(false); // inline can't contain blocks
-	    RenderObject *p = parent();
+            RenderObject *p = parent();
             if (p && p->isFlow() && p->childrenInline() ) {
                 static_cast<RenderFlow*>(p)->makeChildrenNonInline();
-		madeBoxesNonInline = true;
+                madeBoxesNonInline = true;
             }
         }
     }
diff --git a/WebCore/khtml/rendering/render_flow.h b/WebCore/khtml/rendering/render_flow.h
index 5e58706..aa94341 100644
--- a/WebCore/khtml/rendering/render_flow.h
+++ b/WebCore/khtml/rendering/render_flow.h
@@ -133,6 +133,8 @@ public:
     BidiIterator findNextLineBreak(BidiIterator &start);
 
     virtual bool isSelfCollapsingBlock() const { return m_height == 0; }
+    virtual bool isTopMarginQuirk() const { return m_topMarginQuirk; }
+    virtual bool isBottomMarginQuirk() const { return m_bottomMarginQuirk; }
     
     virtual short maxTopMargin(bool positive) const {
         if (positive)
@@ -199,6 +201,8 @@ private:
     short m_maxTopNegMargin;
     short m_maxBottomPosMargin;
     short m_maxBottomNegMargin;
+    bool m_topMarginQuirk;
+    bool m_bottomMarginQuirk;
 };
 
     
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 1e25d24..55c6169 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -346,7 +346,7 @@ public:
     virtual int offsetTop() const;
     virtual RenderObject* offsetParent() const;
     
-    // The following four functions are used to implement collapsing margins.
+    // The following seven functions are used to implement collapsing margins.
     // All objects know their maximal positive and negative margins.  The
     // formula for computing a collapsed margin is |maxPosMargin|-|maxNegmargin|.
     // For a non-collapsing, e.g., a leaf element, this formula will simply return
@@ -357,6 +357,8 @@ public:
         { return maxTopMargin(true)-maxTopMargin(false); }
     virtual short collapsedMarginBottom() const 
         { return maxBottomMargin(true)-maxBottomMargin(false); }
+    virtual bool isTopMarginQuirk() const { return false; }
+    virtual bool isBottomMarginQuirk() const { return false; }
     virtual short maxTopMargin(bool positive) const {
         if (positive)
             if (marginTop() > 0)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list