for safari: variable alias problem

Dirk Mueller mueller@kde.org
Tue, 4 Feb 2003 09:43:29 +0100


--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi, 

khtmllayout violated the variable aliasing rules of C++. appended is the 
diff, you definitely want to merge this. 

it changes its API a little bit, you might have to adjust some more parts of 
the code. 



-- 
Dirk (received 188 mails today)

--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="khtmllayout.diff"

--- khtmllayout.h	8 Jan 2003 17:17:33 -0000	1.19
+++ khtmllayout.h	4 Feb 2003 08:37:29 -0000	1.20
@@ -43,31 +43,26 @@ namespace khtml
     enum LengthType { Variable = 0, Relative, Percent, Fixed, Static };
     struct Length
     {
-	Length() { *((Q_UINT32 *)this) = 0; }
-        Length(LengthType t) : value(0), type(t), quirk (0) { }
-        Length(int v, LengthType t, bool q=false) : value(v), type(t), quirk(q) {}
-        Length(const Length &o)
-	    { *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); }
-
-        Length& operator=(const Length& o)
-            { *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); return *this; }
+	Length() : _length(0) {}
+        Length(LengthType t) { l.value = 0; l.type = t; l.quirk = 0; }
+        Length(int v, LengthType t, bool q=false) 
+        {  l.value = v; l.type = t; l.quirk = q; }
         bool operator==(const Length& o) const
-            { return *((Q_UINT32 *)this) == *((Q_UINT32 *)&o); }
+        { return _length == o._length; }
         bool operator!=(const Length& o) const
-            { return *((Q_UINT32 *)this) != *((Q_UINT32 *)&o); }
-
+        { return _length != o._length; }
 
 	/*
 	 * works only for Fixed and Percent, returns -1 otherwise
 	 */
 	int width(int maxWidth) const
 	    {
-		switch(type)
+		switch(l.type)
 		{
 		case Fixed:
-		    return value;
+		    return l.value;
 		case Percent:
-		    return maxWidth*value/100;
+		    return maxWidth*l.value/100;
 		case Variable:
 		    return maxWidth;
 		default:
@@ -79,36 +74,36 @@ namespace khtml
 	 */
 	int minWidth(int maxWidth) const
 	    {
-		switch(type)
+		switch(l.type)
 		{
 		case Fixed:
-		    return value;
+		    return l.value;
 		case Percent:
-		    return maxWidth*value/100;
+		    return maxWidth*l.value/100;
 		case Variable:
 		default:
 		    return 0;
 		}
 	    }
-        bool isVariable() const { return (type == Variable); }
-        bool isRelative() const { return (type == Relative); }
-        bool isPercent() const { return (type == Percent); }
-        bool isFixed() const { return (type == Fixed); }
-        bool isStatic() const { return (type == Static); }
+        bool isVariable() const { return (l.type == Variable); }
+        bool isRelative() const { return (l.type == Relative); }
+        bool isPercent() const { return (l.type == Percent); }
+        bool isFixed() const { return (l.type == Fixed); }
+        bool isStatic() const { return (l.type == Static); }
+
+        int value() const { return l.value; }
+        LengthType type() const { return l.type; }
 
+        union {
+            struct {
         int value : 28;
         LengthType type : 3;
         int quirk : 1;
+            } l;
+            Q_UINT32 _length;
+        };
     };
 
 };
-
-#ifdef __GNUC__
-#if __GNUC__ < 3 // stupid stl_relops.h
-inline bool operator!=(khtml::LengthType __x, khtml::LengthType __y) {
-  return !(__x == __y);
-}
-#endif
-#endif
 
 #endif
? misc/khtmllayout.h-simple
? misc/l
? misc/test.S
? misc/test.cc
Index: rendering/render_body.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_body.cpp,v
retrieving revision 1.20.2.2
diff -u -3 -d -p -r1.20.2.2 render_body.cpp
--- rendering/render_body.cpp	13 Jan 2003 22:04:48 -0000	1.20.2.2
+++ rendering/render_body.cpp	4 Feb 2003 08:14:06 -0000
@@ -107,9 +107,9 @@ int RenderBody::availableHeight() const
     int h = RenderFlow::availableHeight();
 
     if( style()->marginTop().isFixed() )
-        h  -= style()->marginTop().value;
+        h  -= style()->marginTop().value();
     if( style()->marginBottom().isFixed() )
-        h -= style()->marginBottom().value;
+        h -= style()->marginBottom().value();
 
     return kMax(0, h);
 }
Index: rendering/render_box.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_box.cpp,v
retrieving revision 1.183.2.5
diff -u -3 -d -p -r1.183.2.5 render_box.cpp
--- rendering/render_box.cpp	13 Jan 2003 22:04:49 -0000	1.183.2.5
+++ rendering/render_box.cpp	4 Feb 2003 08:14:07 -0000
@@ -467,7 +467,7 @@ void RenderBox::calcWidth()
 
             return;
         }
-        else if (w.type == Variable)
+        else if (w.isVariable())
         {
 //          kdDebug( 6040 ) << "variable" << endl;
             m_marginLeft = ml.minWidth(cw);
@@ -515,20 +515,19 @@ void RenderBox::calcHorizontalMargins(co
     }
     else
     {
-        if ( (ml.type == Variable && mr.type == Variable) ||
-             (!(ml.type == Variable) &&
-                containingBlock()->style()->textAlign() == KONQ_CENTER) )
+        if ( (ml.isVariable() && mr.isVariable()) ||
+             (!ml.isVariable() && containingBlock()->style()->textAlign() == KONQ_CENTER ) )
         {
             m_marginLeft = (cw - m_width)/2;
             if (m_marginLeft<0) m_marginLeft=0;
             m_marginRight = cw - m_width - m_marginLeft;
         }
-        else if (mr.type == Variable)
+        else if (mr.isVariable())
         {
             m_marginLeft = ml.width(cw);
             m_marginRight = cw - m_width - m_marginLeft;
         }
-        else if (ml.type == Variable)
+        else if (ml.isVariable())
         {
             m_marginRight = mr.width(cw);
             m_marginLeft = cw - m_width - m_marginRight;
@@ -572,11 +571,11 @@ void RenderBox::calcHeight()
         {
             int fh=-1;
             if (h.isFixed())
-                fh = h.value + borderTop() + paddingTop() + borderBottom() + paddingBottom();
+                fh = h.value() + borderTop() + paddingTop() + borderBottom() + paddingBottom();
             else if (h.isPercent()) {
                 Length ch = containingBlock()->style()->height();
                 if (ch.isFixed())
-                    fh = h.width(ch.value) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
+                    fh = h.width(ch.value()) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
             }
             if (fh!=-1)
             {
@@ -593,9 +592,9 @@ short RenderBox::calcReplacedWidth() con
 {
     Length w = style()->width();
 
-    switch( w.type ) {
+    switch( w.type() ) {
     case Fixed:
-        return w.value;
+        return w.value();
     case Percent:
     {
         const int cw = containingBlockWidth();
@@ -611,11 +610,11 @@ short RenderBox::calcReplacedWidth() con
 int RenderBox::calcReplacedHeight() const
 {
     const Length& h = style()->height();
-    switch( h.type ) {
+    switch( h.type() ) {
     case Percent:
         return availableHeight();
     case Fixed:
-        return h.value;
+        return h.value();
     default:
         return intrinsicHeight();
     };
@@ -626,7 +625,7 @@ int RenderBox::availableHeight() const
     Length h = style()->height();
 
     if (h.isFixed())
-        return h.value;
+        return h.value();
 
     if (isRoot())
         return static_cast<const RenderRoot*>(this)->viewportHeight();
@@ -820,7 +819,7 @@ void RenderBox::calcAbsoluteVertical()
 
     Length hl = cb->style()->height();
     if (hl.isFixed())
-        ch = hl.value + cb->paddingTop() + cb->paddingBottom()
+        ch = hl.value() + cb->paddingTop() + cb->paddingBottom()
 	     + cb->borderTop() + cb->borderBottom();
     else if (cb->isHtml())
         ch = cb->availableHeight();
Index: rendering/render_flow.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_flow.cpp,v
retrieving revision 1.309.2.6
diff -u -3 -d -p -r1.309.2.6 render_flow.cpp
--- rendering/render_flow.cpp	13 Jan 2003 22:04:49 -0000	1.309.2.6
+++ rendering/render_flow.cpp	4 Feb 2003 08:14:07 -0000
@@ -1147,12 +1147,12 @@ void RenderFlow::calcMinMaxWidth()
             if( !child->isBR() ) {
                 RenderStyle* cstyle = child->style();
                 int margins = 0;
-		LengthType type = cstyle->marginLeft().type;
+		LengthType type = cstyle->marginLeft().type();
                 if ( type != Variable )
-                    margins += (type == Fixed ? cstyle->marginLeft().value : child->marginLeft());
-		type = cstyle->marginRight().type;
+                    margins += (type == Fixed ? cstyle->marginLeft().value() : child->marginLeft());
+		type = cstyle->marginRight().type();
                 if ( type != Variable )
-                    margins += (type == Fixed ? cstyle->marginRight().value : child->marginRight());
+                    margins += (type == Fixed ? cstyle->marginRight().value() : child->marginRight());
                 int childMin = child->minWidth() + margins;
                 int childMax = child->maxWidth() + margins;
 // 		qDebug("child min=%d, max=%d, currentMin=%d, inlineMin=%d",  childMin,  childMax, currentMin, inlineMin );
@@ -1222,14 +1222,14 @@ void RenderFlow::calcMinMaxWidth()
 
             if (style()->textAlign() == KONQ_CENTER)
             {
-                if (ml.type==Fixed) margin+=ml.value;
-                if (mr.type==Fixed) margin+=mr.value;
+                if (ml.isFixed()) margin+=ml.value();
+                if (mr.isFixed()) margin+=mr.value();
             }
             else
             {
-                if (!(ml.type==Variable) && !(mr.type==Variable))
+                if (!ml.isVariable() && !mr.isVariable())
                 {
-                    if (!(child->style()->width().type==Variable))
+                    if (!(child->style()->width().isVariable()))
                     {
                         if (child->style()->direction()==LTR)
                             margin = child->marginLeft();
@@ -1240,9 +1240,9 @@ void RenderFlow::calcMinMaxWidth()
                         margin = child->marginLeft()+child->marginRight();
 
                 }
-                else if (!(ml.type == Variable))
+                else if (!ml.isVariable())
                     margin = child->marginLeft();
-                else if (!(mr.type == Variable))
+                else if (!mr.isVariable())
                     margin = child->marginRight();
             }
 
@@ -1260,8 +1260,8 @@ void RenderFlow::calcMinMaxWidth()
     }
     if(m_maxWidth < m_minWidth) m_maxWidth = m_minWidth;
 
-    if (style()->width().isFixed() && style()->width().value > 0)
-        m_maxWidth = KMAX(m_minWidth,short(style()->width().value));
+    if (style()->width().isFixed() && style()->width().value() > 0)
+        m_maxWidth = KMAX(m_minWidth,short(style()->width().value()));
 
     int toAdd = 0;
     toAdd = borderLeft() + borderRight() + paddingLeft() + paddingRight();
Index: rendering/render_frames.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_frames.cpp,v
retrieving revision 1.144.2.2
diff -u -3 -d -p -r1.144.2.2 render_frames.cpp
--- rendering/render_frames.cpp	17 Jan 2003 10:02:31 -0000	1.144.2.2
+++ rendering/render_frames.cpp	4 Feb 2003 08:14:08 -0000
@@ -153,12 +153,12 @@ void RenderFrameSet::layout( )
             // percentage ones and distribute remaining over relative
             for(int i = 0; i< gridLen; ++i)
                 if (grid[i].isFixed()) {
-                    gridLayout[i] = kMin(grid[i].value > 0 ? grid[i].value : 0, remainingLen[k]);
+                    gridLayout[i] = kMin(grid[i].value() > 0 ? grid[i].value() : 0, remainingLen[k]);
                     remainingLen[k] -= gridLayout[i];
                     totalFixed += gridLayout[i];
                 }
                 else if(grid[i].isRelative()) {
-                    totalRelative += grid[i].value > 1 ? grid[i].value : 1;
+                    totalRelative += grid[i].value() > 1 ? grid[i].value() : 1;
                     countRelative++;
                 }
 
@@ -166,7 +166,7 @@ void RenderFrameSet::layout( )
                 if(grid[i].isPercent()) {
                     gridLayout[i] = kMin(kMax(grid[i].width(availableLen[k]), 0), remainingLen[k]);
                     remainingLen[k] -= gridLayout[i];
-                    totalPercent += grid[i].value;
+                    totalPercent += grid[i].value();
                     countPercent++;
                 }
 
@@ -176,7 +176,7 @@ void RenderFrameSet::layout( )
                 int remaining = remainingLen[k];
                 for (int i = 0; i < gridLen; ++i)
                     if (grid[i].isRelative()) {
-                        gridLayout[i] = ((grid[i].value > 1 ? grid[i].value : 1) * remaining) / totalRelative;
+                        gridLayout[i] = ((grid[i].value() > 1 ? grid[i].value() : 1) * remaining) / totalRelative;
                         remainingLen[k] -= gridLayout[i];
                     }
             }
@@ -187,8 +187,8 @@ void RenderFrameSet::layout( )
                 int total = countPercent ? totalPercent : totalFixed;
                 if (!total) total = 1;
                 for (int i = 0; i < gridLen; ++i)
-                    if (grid[i].type == distributeType) {
-                        int toAdd = (remainingLen[k] * grid[i].value) / total;
+                    if (grid[i].type() == distributeType) {
+                        int toAdd = (remainingLen[k] * grid[i].value()) / total;
                         gridLayout[i] += toAdd;
                     }
             }
Index: rendering/render_html.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_html.cpp,v
retrieving revision 1.24.4.1
diff -u -3 -d -p -r1.24.4.1 render_html.cpp
--- rendering/render_html.cpp	10 Jan 2003 18:01:37 -0000	1.24.4.1
+++ rendering/render_html.cpp	4 Feb 2003 08:14:08 -0000
@@ -115,8 +115,8 @@ void RenderHtml::layout()
     //kdDebug(0) << renderName() << " height = " << m_height << endl;
     int lp = lowestPosition();
     // margins of Html element can only be fixed, right?
-    int margins  = style()->marginTop().isFixed() ? style()->marginTop().value : 0;
-        margins += style()->marginBottom().isFixed() ? style()->marginBottom().value : 0;
+    int margins  = style()->marginTop().isFixed() ? style()->marginTop().value() : 0;
+        margins += style()->marginBottom().isFixed() ? style()->marginBottom().value() : 0;
 
     if( m_height + margins < lp )
 	m_height = lp - margins;
Index: rendering/render_image.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_image.cpp,v
retrieving revision 1.100.2.2
diff -u -3 -d -p -r1.100.2.2 render_image.cpp
--- rendering/render_image.cpp	13 Jan 2003 22:04:49 -0000	1.100.2.2
+++ rendering/render_image.cpp	4 Feb 2003 08:14:08 -0000
@@ -395,7 +395,7 @@ short RenderImage::calcReplacedWidth() c
     if (w.isVariable()) {
         const Length h = style()->height();
         if ( m_intrinsicHeight > 0 && ( h.isPercent() || h.isFixed() ) )
-            return ( ( h.isPercent() ? calcReplacedHeight() : h.value )*intrinsicWidth() ) / m_intrinsicHeight;
+            return ( ( h.isPercent() ? calcReplacedHeight() : h.value() )*intrinsicWidth() ) / m_intrinsicHeight;
     }
 
     return RenderReplaced::calcReplacedWidth();
@@ -408,7 +408,7 @@ int RenderImage::calcReplacedHeight() co
     if (h.isVariable()) {
         const Length w = style()->width();
         if( m_intrinsicWidth > 0 && ( w.isFixed() || w.isPercent() ))
-            return (( w.isPercent() ? calcReplacedWidth() : w.value ) * intrinsicHeight()) / m_intrinsicWidth;
+            return (( w.isPercent() ? calcReplacedWidth() : w.value() ) * intrinsicHeight()) / m_intrinsicWidth;
 
     }
 
Index: rendering/render_object.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_object.cpp,v
retrieving revision 1.195.2.1
diff -u -3 -d -p -r1.195.2.1 render_object.cpp
--- rendering/render_object.cpp	10 Jan 2003 18:01:37 -0000	1.195.2.1
+++ rendering/render_object.cpp	4 Feb 2003 08:14:08 -0000
@@ -983,14 +983,14 @@ short RenderObject::lineHeight( bool fir
         lh = style()->lineHeight();
 
     // its "unset", choose nice default
-    if ( lh.value < 0 )
+    if ( lh.value() < 0 )
         return style()->fontMetrics().lineSpacing();
 
     if ( lh.isPercent() )
         return lh.minWidth( style()->font().pixelSize() );
 
     // its fixed
-    return lh.value;
+    return lh.value();
 }
 
 short RenderObject::baselinePosition( bool firstLine ) const
Index: rendering/render_root.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_root.cpp,v
retrieving revision 1.116.2.1
diff -u -3 -d -p -r1.116.2.1 render_root.cpp
--- rendering/render_root.cpp	10 Jan 2003 18:01:37 -0000	1.116.2.1
+++ rendering/render_root.cpp	4 Feb 2003 08:14:09 -0000
@@ -69,13 +69,13 @@ void RenderRoot::calcWidth()
 
     // exception: m_width is already known and set in layout()
 
-    if (style()->marginLeft().type==Fixed)
-        m_marginLeft = style()->marginLeft().value;
+    if (style()->marginLeft().isFixed())
+        m_marginLeft = style()->marginLeft().value();
     else
         m_marginLeft = 0;
 
-    if (style()->marginRight().type==Fixed)
-        m_marginRight = style()->marginRight().value;
+    if (style()->marginRight().isFixed())
+        m_marginRight = style()->marginRight().value();
     else
         m_marginRight = 0;
 }
Index: rendering/render_style.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_style.h,v
retrieving revision 1.78
diff -u -3 -d -p -r1.78 render_style.h
--- rendering/render_style.h	24 Oct 2002 01:53:45 -0000	1.78
+++ rendering/render_style.h	4 Feb 2003 08:14:10 -0000
@@ -166,7 +166,7 @@ struct LengthBox
     }
 
 
-    bool nonZero() const { return left.value!=0 || right.value!=0 || top.value!=0 || bottom.value!=0; }
+    bool nonZero() const { return left.value() || right.value() || top.value() || bottom.value(); }
 };
 
 
Index: rendering/render_table.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_table.cpp,v
retrieving revision 1.215.2.4
diff -u -3 -d -p -r1.215.2.4 render_table.cpp
--- rendering/render_table.cpp	10 Jan 2003 18:01:37 -0000	1.215.2.4
+++ rendering/render_table.cpp	4 Feb 2003 08:14:10 -0000
@@ -181,8 +181,8 @@ void RenderTable::calcWidth()
     RenderObject *cb = containingBlock();
     int availableWidth = cb->contentWidth();
 
-    LengthType widthType = style()->width().type;
-    if(widthType > Relative && style()->width().value > 0) {
+    LengthType widthType = style()->width().type();
+    if(widthType > Relative && style()->width().value() > 0) {
 	// Percent or fixed table
         m_width = style()->width().minWidth( availableWidth );
         if(m_minWidth > m_width) m_width = m_minWidth;
@@ -194,7 +194,7 @@ void RenderTable::calcWidth()
     // restrict width to what we really have in case we flow around floats
     if ( style()->flowAroundFloats() && cb->isFlow() ) {
 	availableWidth = static_cast<RenderFlow *>(cb)->lineWidth( m_y );
-	m_width = QMIN( availableWidth, m_width );
+	m_width = KMIN( short( availableWidth ), m_width );
     }
 
     m_width = KMAX (m_width, m_minWidth);
@@ -257,11 +257,11 @@ void RenderTable::layout()
     Length h = style()->height();
     int th=0;
     if (h.isFixed())
-        th = h.value;
+        th = h.value();
     else if (h.isPercent()) {
         Length ch = containingBlock()->style()->height();
         if (ch.isFixed())
-            th = h.width(ch.value);
+            th = h.width(ch.value());
         else {
             // check we or not inside a table
             RenderObject* ro = parent();
@@ -712,7 +712,7 @@ void RenderTableSection::addChild(Render
 
     if (!beforeChild) {
         grid[cRow].height = child->style()->height();
-        if ( grid[cRow].height.type == Relative )
+        if ( grid[cRow].height.isRelative() )
             grid[cRow].height = Length();
     }
 
@@ -778,17 +778,17 @@ void RenderTableSection::addCell( Render
     if ( rSpan == 1 ) {
 	// we ignore height settings on rowspan cells
 	Length height = cell->style()->height();
-	if ( height.value > 0 || (height.type == Relative && height.value >= 0) ) {
+	if ( height.value() > 0 || (height.isRelative() && height.value() >= 0) ) {
 	    Length cRowHeight = grid[cRow].height;
-	    switch( height.type ) {
+	    switch( height.type() ) {
 	    case Percent:
-		if ( !(cRowHeight.type == Percent) ||
-		     ( cRowHeight.type == Percent && cRowHeight.value < height.value ) )
+		if ( !cRowHeight.isPercent() ||
+		     (cRowHeight.isPercent() && cRowHeight.value() < height.value() ) )
 		    grid[cRow].height = height;
 		     break;
 	    case Fixed:
-		if ( cRowHeight.type < Percent ||
-		     ( cRowHeight.type == Fixed && cRowHeight.value < height.value ) )
+		if ( cRowHeight.type() < Percent ||
+		     ( cRowHeight.isFixed() && cRowHeight.value() < height.value() ) )
 		    grid[cRow].height = height;
 		break;
 	    case Relative:
@@ -971,10 +971,10 @@ int RenderTableSection::layoutRows( int 
 	int totalPercent = 0;
 	int numVariable = 0;
 	for ( int r = 0; r < totalRows; r++ ) {
-	    if ( grid[r].height.type == Variable )
+	    if ( grid[r].height.isVariable() )
 		numVariable++;
-	    else if ( grid[r].height.type == Percent )
-		totalPercent += grid[r].height.value;
+	    else if ( grid[r].height.isPercent() )
+		totalPercent += grid[r].height.value();
 	}
 	if ( totalPercent ) {
 // 	    qDebug("distributing %d over percent rows totalPercent=%d", dh,  totalPercent );
@@ -984,11 +984,11 @@ int RenderTableSection::layoutRows( int 
 		totalPercent = 100;
 	    int rh = rowPos[1]-rowPos[0];
 	    for ( int r = 0; r < totalRows; r++ ) {
-		if ( totalPercent > 0 && grid[r].height.type == Percent ) {
-		    int toAdd = QMIN( dh, (totalHeight * grid[r].height.value / 100)-rh );
+		if ( totalPercent > 0 && grid[r].height.isPercent() ) {
+		    int toAdd = QMIN( dh, (totalHeight * grid[r].height.value() / 100)-rh );
 		    add += toAdd;
 		    dh -= toAdd;
-		    totalPercent -= grid[r].height.value;
+		    totalPercent -= grid[r].height.value();
 // 		    qDebug( "adding %d to row %d", toAdd, r );
 		}
 		if ( r < totalRows-1 )
@@ -1001,7 +1001,7 @@ int RenderTableSection::layoutRows( int 
 // 	    qDebug("distributing %d over variable rows numVariable=%d", dh,  numVariable );
 	    int add = 0;
 	    for ( int r = 0; r < totalRows; r++ ) {
-		if ( numVariable > 0 && grid[r].height.type == Variable ) {
+		if ( numVariable > 0 && grid[r].height.isVariable() ) {
 		    int toAdd = dh/numVariable;
 		    add += toAdd;
 		    dh -= toAdd;
Index: rendering/table_layout.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/table_layout.cpp,v
retrieving revision 1.24.2.1
diff -u -3 -d -p -r1.24.2.1 table_layout.cpp
--- rendering/table_layout.cpp	13 Jan 2003 22:04:49 -0000	1.24.2.1
+++ rendering/table_layout.cpp	4 Feb 2003 08:14:10 -0000
@@ -116,9 +116,9 @@ int FixedTableLayout::calcWidthArray( in
 		if ( w.isVariable() )
 		    w = grpWidth;
 		int effWidth = 0;
-		if ( w.type == Fixed && w.value > 0 ) {
-                    effWidth = w.value;
-		    effWidth = QMIN( effWidth, 32760 );
+		if ( w.isFixed() && w.value() > 0 ) {
+                    effWidth = w.value();
+		    effWidth = KMIN( effWidth, 32760 );
 		}
 #ifdef DEBUG_LAYOUT
 		qDebug("    col element: effCol=%d, span=%d: %d w=%d type=%d",
@@ -134,8 +134,8 @@ int FixedTableLayout::calcWidthArray( in
 			width[nEffCols-1] = Length();
 		    }
 		    int eSpan = table->spanOfEffCol( cCol+i );
-		    if ( (w.type == Fixed || w.type == Percent) && w.value > 0 ) {
-			width[cCol+i] = Length( w.value * eSpan, w.type );
+		    if ( (w.isFixed() || w.isPercent()) && w.value() > 0 ) {
+			width[cCol+i] = Length( w.value() * eSpan, w.type() );
 			usedWidth += effWidth * eSpan;
 #ifdef DEBUG_LAYOUT
 			qDebug("    setting effCol %d (span=%d) to width %d(type=%d)",
@@ -180,9 +180,9 @@ int FixedTableLayout::calcWidthArray( in
 		Length w = cell->style()->width();
 		int span = cell->colSpan();
 		int effWidth = 0;
-		if ( (w.type == Fixed || w.type == Percent) && w.value > 0 ) {
-                    effWidth = w.value;
-		    effWidth = QMIN( effWidth, 32760 );
+		if ( (w.isFixed() || w.isPercent()) && w.value() > 0 ) {
+                    effWidth = w.value();
+		    effWidth = kMin( effWidth, 32760 );
 		}
 #ifdef DEBUG_LAYOUT
 		qDebug("    table cell: effCol=%d, span=%d: %d",  cCol, span, effWidth);
@@ -193,8 +193,8 @@ int FixedTableLayout::calcWidthArray( in
 		    Q_ASSERT( cCol + i < nEffCols );
 		    int eSpan = table->spanOfEffCol( cCol+i );
 		    // only set if no col element has already set it.
-		    if ( width[cCol+i].type == Variable && w.type != Variable ) {
-			width[cCol+i] = Length( w.value*eSpan, w.type );
+		    if ( width[cCol+i].isVariable() && !w.isVariable() ) {
+			width[cCol+i] = Length( w.value()*eSpan, w.type() );
 			usedWidth += effWidth*eSpan;
 #ifdef DEBUG_LAYOUT
 			qDebug("    setting effCol %d (span=%d) to width %d(type=%d)",
@@ -236,7 +236,7 @@ void FixedTableLayout::calcMinMaxWidth()
     int bs = table->bordersAndSpacing();
     table->m_minWidth = 0;
     table->m_maxWidth = 0;
-    short tableWidth = table->style()->width().type == Fixed ? table->style()->width().value - bs : 0;
+    short tableWidth = table->style()->width().isFixed() ? table->style()->width().value() - bs : 0;
 
     table->m_minWidth = calcWidthArray( tableWidth );
     table->m_minWidth += bs;
@@ -246,7 +246,7 @@ void FixedTableLayout::calcMinMaxWidth()
     if ( !tableWidth ) {
 	bool haveNonFixed = false;
 	for ( unsigned int i = 0; i < width.size(); i++ ) {
-	    if ( !(width[i].type == Fixed) ) {
+	    if ( !width[i].isFixed() ) {
 		haveNonFixed = true;
 		break;
 	    }
@@ -275,9 +275,9 @@ void FixedTableLayout::layout()
 
     // first assign  fixed width
     for ( int i = 0; i < nEffCols; i++ ) {
-	if ( width[i].type == Fixed ) {
-	    calcWidth[i] = width[i].value;
-	    available -= width[i].value;
+	if ( width[i].isFixed() ) {
+	    calcWidth[i] = width[i].value();
+	    available -= width[i].value();
 	}
     }
 
@@ -285,8 +285,8 @@ void FixedTableLayout::layout()
     if ( available > 0 ) {
 	int totalPercent = 0;
 	for ( int i = 0; i < nEffCols; i++ )
-	    if ( width[i].type == Percent )
-		totalPercent += width[i].value;
+	    if ( width[i].isPercent() )
+		totalPercent += width[i].value();
 
 	// calculate how much to distribute to percent cells.
 	int base = tableWidth * totalPercent / 100;
@@ -299,8 +299,8 @@ void FixedTableLayout::layout()
     qDebug("FixedTableLayout::layout: assigning percent width, base=%d, totalPercent=%d", base, totalPercent);
 #endif
         for ( int i = 0; available > 0 && i < nEffCols; i++ ) {
-            if ( width[i].type == Percent ) {
-                int w = base * width[i].value / totalPercent;
+            if ( width[i].isPercent() ) {
+                int w = base * width[i].value() / totalPercent;
                 available -= w;
                 calcWidth[i] = w;
             }
@@ -311,11 +311,11 @@ void FixedTableLayout::layout()
     if ( available > 0 ) {
 	int totalVariable = 0;
 	for ( int i = 0; i < nEffCols; i++ )
-	    if ( width[i].type == Variable )
+	    if ( width[i].isVariable() )
 		totalVariable++;
 
         for ( int i = 0; available > 0 && i < nEffCols; i++ ) {
-            if ( width[i].type == Variable ) {
+            if ( width[i].isVariable() ) {
                 int w = available / totalVariable;
                 available -= w;
                 calcWidth[i] = w;
@@ -391,37 +391,33 @@ void AutoTableLayout::recalcColumn( int 
 		    }
 
 		    Length w = cell->style()->width();
-		    if ( w.value > 32760 )
-			w.value = 32760;
-		    if ( w.value < 0 )
-			w.value = 0;
-		    switch( w.type ) {
+                    w.l.value = kMin( 32767, kMax( 0, w.value() ) );
+		    switch( w.type() ) {
 		    case Fixed:
 			// ignore width=0
-			if ( w.value > 0 && (int)l.width.type != Percent ) {
+			if ( w.value() > 0 && !l.width.isPercent() ) {
                             // ### we should use box'es paddings here I guess.
-                            int wval = w.value + table->cellPadding() * 2;
-			    if ( l.width.type == Fixed ) {
+                            int wval = w.value() + table->cellPadding() * 2;
+			    if ( l.width.isFixed() ) {
                                 // Nav/IE weirdness
-				if ((wval > l.width.value) ||
-				    ((l.width.value == wval) && (maxContributor == cell))) {
-				    l.width.value = wval;
+				if ((wval > l.width.value()) ||
+				    ((l.width.value() == wval) && (maxContributor == cell))) {
+				    l.width.l.value = wval;
 				    fixedContributor = cell;
 				}
 			    } else {
-                                l.width.type = Fixed;
-				l.width.value = wval;
+                                l.width = Length( wval, Fixed );
 				fixedContributor = cell;
 			    }
 			}
 			break;
 		    case Percent:
                         hasPercent = true;
-                        if ( w.value > 0 && (l.width.type != Percent || w.value > l.width.value ) )
+                        if ( w.value() > 0 && (!l.width.isPercent() || w.value() > l.width.value() ) )
                             l.width = w;
 			break;
 		    case Relative:
-			if ( w.type == Variable || (w.type == Relative && w.value > l.width.value ) )
+			if ( w.isVariable() || (w.isRelative() && w.value() > l.width.value() ) )
 				l.width = w;
 		    default:
 			break;
@@ -437,9 +433,9 @@ void AutoTableLayout::recalcColumn( int 
     }
 
     // Nav/IE weirdness
-    if ( l.width.type == Fixed ) {
+    if ( l.width.isFixed() ) {
 	if ( table->style()->htmlHacks()
-	     && (l.maxWidth > l.width.value) && (fixedContributor != maxContributor)) {
+	     && (l.maxWidth > l.width.value()) && (fixedContributor != maxContributor)) {
 	    l.width = Length();
 	    fixedContributor = 0;
 	}
@@ -478,18 +474,18 @@ void AutoTableLayout::fullRecalc()
 		Length w = col->style()->width();
 		if ( w.isVariable() )
 		    w = grpWidth;
-		if ( (w.type == Fixed && w.value == 0) ||
-		     (w.type == Percent && w.value == 0) )
+		if ( (w.isFixed() && w.value() == 0) ||
+		     (w.isPercent() && w.value() == 0) )
 		    w = Length();
 		int cEffCol = table->colToEffCol( cCol );
 #ifdef DEBUG_LAYOUT
 		qDebug("    col element %d (eff=%d): Length=%d(%d), span=%d, effColSpan=%d",  cCol, cEffCol, w.value, w.type, span, table->spanOfEffCol(cEffCol ) );
 #endif
-		if ( (int)w.type != Variable && span == 1 && cEffCol < nEffCols ) {
+		if ( !w.isVariable() && span == 1 && cEffCol < nEffCols ) {
 		    if ( table->spanOfEffCol( cEffCol ) == 1 ) {
 			layoutStruct[cEffCol].width = w;
-                        if (w.isFixed() && layoutStruct[cEffCol].maxWidth < w.value)
-                            layoutStruct[cEffCol].maxWidth = w.value;
+                        if (w.isFixed() && layoutStruct[cEffCol].maxWidth < w.value())
+                            layoutStruct[cEffCol].maxWidth = w.value();
                     }
 		}
 		cCol += span;
@@ -530,8 +526,8 @@ void AutoTableLayout::calcMinMaxWidth()
     for ( unsigned int i = 0; i < layoutStruct.size(); i++ ) {
 	minWidth += layoutStruct[i].effMinWidth;
 	maxWidth += layoutStruct[i].effMaxWidth;
-	if ( layoutStruct[i].effWidth.type == Percent ) {
-	    int pw = ( layoutStruct[i].effMaxWidth * 100) / layoutStruct[i].effWidth.value;
+	if ( layoutStruct[i].effWidth.isPercent() ) {
+	    int pw = ( layoutStruct[i].effMaxWidth * 100) / layoutStruct[i].effWidth.value();
 	    maxPercent = kMax( pw,  maxPercent );
 	} else {
 	    maxNonPercent += layoutStruct[i].effMaxWidth;
@@ -551,8 +547,8 @@ void AutoTableLayout::calcMinMaxWidth()
     maxWidth += bs;
 
     Length tw = table->style()->width();
-    if ( tw.isFixed() && tw.value > 0 ) {
-	minWidth = kMax( minWidth, int( tw.value ) );
+    if ( tw.isFixed() && tw.value() > 0 ) {
+	minWidth = kMax( minWidth, int( tw.value() ) );
 	maxWidth = minWidth;
     }
 
@@ -589,7 +585,7 @@ int AutoTableLayout::calcEffectiveWidth(
 	int span = cell->colSpan();
 
 	Length w = cell->style()->width();
-	if ( !(w.type == Relative) && w.value == 0 )
+	if ( !w.isRelative() && w.value() == 0 )
 	    w = Length(); // make it Variable
 
 	int col = table->colToEffCol( cell->col() );
@@ -607,14 +603,14 @@ int AutoTableLayout::calcEffectiveWidth(
 	int cSpan = span;
 #endif
 	while ( lastCol < nEffCols && span > 0 ) {
-	    switch( layoutStruct[lastCol].width.type ) {
+	    switch( layoutStruct[lastCol].width.type() ) {
 	    case Percent:
-		totalPercent += layoutStruct[lastCol].width.value;
+		totalPercent += layoutStruct[lastCol].width.value();
 		allColsAreFixed = false;
 		break;
 	    case Fixed:
-                if (layoutStruct[lastCol].width.value > 0) {
-                    fixedWidth += layoutStruct[lastCol].width.value;
+                if (layoutStruct[lastCol].width.value() > 0) {
+                    fixedWidth += layoutStruct[lastCol].width.value();
                     allColsArePercent = false;
                     // IE resets effWidth to Variable here, but this breaks the konqueror about page and seems to be some bad
                     // legacy behaviour anyway. mozilla doesn't do this so I decided we don't neither.
@@ -641,27 +637,27 @@ int AutoTableLayout::calcEffectiveWidth(
 #endif
 
 	// adjust table max width if needed
-	if ( w.type == Percent ) {
-	    if ( totalPercent > w.value || allColsArePercent ) {
+	if ( w.isPercent() ) {
+	    if ( totalPercent > w.value() || allColsArePercent ) {
 		// can't satify this condition, treat as variable
 		w = Length();
 	    } else {
 		int spanMax = QMAX( maxWidth, cMaxWidth );
 #ifdef DEBUG_LAYOUT
-		qDebug("    adjusting tMaxWidth (%d): spanMax=%d, value=%d, totalPercent=%d", tMaxWidth, spanMax, w.value, totalPercent );
+		qDebug("    adjusting tMaxWidth (%d): spanMax=%d, value=%d, totalPercent=%d", tMaxWidth, spanMax, w.value(), totalPercent );
 #endif
-		tMaxWidth = QMAX( tMaxWidth, spanMax * 100 / w.value );
+		tMaxWidth = QMAX( tMaxWidth, spanMax * 100 / w.value() );
 
 		// all non percent columns in the span get percent vlaues to sum up correctly.
-		int percentMissing = w.value - totalPercent;
+		int percentMissing = w.value() - totalPercent;
 		int totalWidth = 0;
 		for ( unsigned int pos = col; pos < lastCol; pos++ ) {
-		    if ( !(layoutStruct[pos].width.type == Percent ) )
+		    if ( !(layoutStruct[pos].width.isPercent() ) )
 			totalWidth += layoutStruct[pos].effMaxWidth;
 		}
 
 		for ( unsigned int pos = col; pos < lastCol && totalWidth > 0; pos++ ) {
-		    if ( !(layoutStruct[pos].width.type == Percent ) ) {
+		    if ( !(layoutStruct[pos].width.isPercent() ) ) {
 			int percent = percentMissing * layoutStruct[pos].effMaxWidth / totalWidth;
 #ifdef DEBUG_LAYOUT
 			qDebug("   col %d: setting percent value %d effMaxWidth=%d totalWidth=%d", pos, percent, layoutStruct[pos].effMaxWidth, totalWidth );
@@ -685,11 +681,11 @@ int AutoTableLayout::calcEffectiveWidth(
 		qDebug("extending minWidth of cols %d-%d to %dpx currentMin=%d accroding to fixed sum %d", col, lastCol-1, cMinWidth, minWidth, fixedWidth );
 #endif
 		for ( unsigned int pos = col; fixedWidth > 0 && pos < lastCol; pos++ ) {
-		    int w = QMAX( layoutStruct[pos].effMinWidth, cMinWidth * layoutStruct[pos].width.value / fixedWidth );
+		    int w = QMAX( layoutStruct[pos].effMinWidth, cMinWidth * layoutStruct[pos].width.value() / fixedWidth );
 #ifdef DEBUG_LAYOUT
 		    qDebug("   col %d: min=%d, effMin=%d, new=%d", pos, layoutStruct[pos].effMinWidth, layoutStruct[pos].effMinWidth, w );
 #endif
-		    fixedWidth -= layoutStruct[pos].width.value;
+		    fixedWidth -= layoutStruct[pos].width.value();
 		    cMinWidth -= w;
 		    layoutStruct[pos].effMinWidth = w;
 		}
@@ -702,9 +698,9 @@ int AutoTableLayout::calcEffectiveWidth(
 		for ( unsigned int pos = col; minWidth > 0 && pos < lastCol; pos++ ) {
 
 		    int w;
-		    if ( layoutStruct[pos].width.type == Fixed && haveVariable && fixedWidth <= cMinWidth ) {
-			w = QMAX( layoutStruct[pos].effMinWidth, layoutStruct[pos].width.value );
-			fixedWidth -= layoutStruct[pos].width.value;
+		    if ( layoutStruct[pos].width.isFixed() && haveVariable && fixedWidth <= cMinWidth ) {
+			w = QMAX( layoutStruct[pos].effMinWidth, layoutStruct[pos].width.value() );
+			fixedWidth -= layoutStruct[pos].width.value();
 		    } else {
 			w = QMAX( layoutStruct[pos].effMinWidth, cMinWidth * layoutStruct[pos].effMaxWidth / maxw );
 		    }
@@ -717,7 +713,7 @@ int AutoTableLayout::calcEffectiveWidth(
 		}
 	    }
 	}
-	if ( !(w.type == Percent ) ) {
+	if ( !w.isPercent() ) {
 	    if ( cMaxWidth > maxWidth ) {
 #ifdef DEBUG_LAYOUT
 		qDebug("extending maxWidth of cols %d-%d to %dpx", col, lastCol-1, cMaxWidth );
@@ -817,14 +813,14 @@ void AutoTableLayout::layout()
 	layoutStruct[i].calcWidth = w;
 	available -= w;
 	Length& width = layoutStruct[i].effWidth;
-        switch( width.type) {
+        switch( width.type()) {
         case Percent:
 	    havePercent = true;
-	    totalPercent += width.value;
+	    totalPercent += width.value();
             break;
         case Relative:
 	    haveRelative = true;
-	    totalRelative += width.value;
+	    totalRelative += width.value();
             break;
         case Fixed:
             numFixed++;
@@ -842,10 +838,10 @@ void AutoTableLayout::layout()
     // then allocate width to fixed cols
     if ( available > 0 ) {
 	for ( int i = 0; i < nEffCols; ++i ) {
-	    Length &width = layoutStruct[i].effWidth;
-	    if ( width.type == Fixed && width.value > layoutStruct[i].calcWidth ) {
-		available += layoutStruct[i].calcWidth - width.value;
-		layoutStruct[i].calcWidth = width.value;
+	    Length w = layoutStruct[i].effWidth;
+	    if ( w.isFixed() && w.value() > layoutStruct[i].calcWidth ) {
+		available += layoutStruct[i].calcWidth - w.value();
+		layoutStruct[i].calcWidth = w.value();
             }
 	}
     }
@@ -856,8 +852,8 @@ void AutoTableLayout::layout()
     // then allocate width to percent cols
     if ( available > 0 && havePercent ) {
 	for ( int i = 0; i < nEffCols; i++ ) {
-	    Length &width = layoutStruct[i].effWidth;
-	    if ( width.type == Percent ) {
+	    Length width = layoutStruct[i].effWidth;
+	    if ( width.isPercent() ) {
                 int w = kMax ( int( layoutStruct[i].effMinWidth ), width.minWidth( tableWidth ) );
 		available += layoutStruct[i].calcWidth - w;
 		layoutStruct[i].calcWidth = w;
@@ -867,7 +863,7 @@ void AutoTableLayout::layout()
 	    // remove overallocated space from the last columns
 	    int excess = tableWidth*(totalPercent-100)/100;
 	    for ( int i = nEffCols-1; i >= 0; i-- ) {
-		if ( layoutStruct[i].effWidth.type == Percent ) {
+		if ( layoutStruct[i].effWidth.isPercent() ) {
 		    int w = layoutStruct[i].calcWidth;
 		    int reduction = kMin( w,  excess );
 		    // the lines below might look inconsistent, but that's the way it's handled in mozilla
@@ -888,9 +884,9 @@ void AutoTableLayout::layout()
     if ( available > 0 ) {
 	for ( int i = 0; i < nEffCols; i++ ) {
 	    Length &width = layoutStruct[i].effWidth;
-	    if ( width.type == Relative && width.value != 0 ) {
+	    if ( width.isRelative() && width.value() ) {
 		// width=0* gets effMinWidth.
-		int w = width.value*tableWidth/totalRelative;
+		int w = width.value()*tableWidth/totalRelative;
 		available += layoutStruct[i].calcWidth - w;
 		layoutStruct[i].calcWidth = w;
 	    }
@@ -903,7 +899,7 @@ void AutoTableLayout::layout()
  	//qDebug("redistributing %dpx to %d variable columns. totalVariable=%d",  available,  numVariable,  totalVariable );
 	for ( int i = 0; i < nEffCols; i++ ) {
 	    Length &width = layoutStruct[i].effWidth;
-	    if ( width.type == Variable && totalVariable != 0 ) {
+	    if ( width.isVariable() && totalVariable != 0 ) {
 		int w = kMax( int ( layoutStruct[i].calcWidth ),
                               available * layoutStruct[i].effMaxWidth / totalVariable );
 		available -= w;
@@ -940,9 +936,9 @@ void AutoTableLayout::layout()
         for ( int i = 0; i < nEffCols; i++ ) {
             Length &width = layoutStruct[i].effWidth;
             if ( width.isPercent() ) {
-                int w = available * width.value / totalPercent;
+                int w = available * width.value() / totalPercent;
                 available -= w;
-                totalPercent -= width.value;
+                totalPercent -= width.value();
                 layoutStruct[i].calcWidth += w;
                 if (!available || !totalPercent) break;
             }
@@ -1005,8 +1001,8 @@ void AutoTableLayout::calcPercentages() 
 {
     total_percent = 0;
     for ( unsigned int i = 0; i < layoutStruct.size(); i++ ) {
-	if ( layoutStruct[i].width.type == Percent )
-	    total_percent += layoutStruct[i].width.value;
+	if ( layoutStruct[i].width.isPercent() )
+	    total_percent += layoutStruct[i].width.value();
     }
     percentagesDirty = false;
 }
Index: misc/loader.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/misc/loader.h,v
retrieving revision 1.48.2.1
diff -u -3 -d -p -r1.48.2.1 loader.h
--- misc/loader.h	19 Jan 2003 16:22:37 -0000	1.48.2.1
+++ misc/loader.h	4 Feb 2003 08:14:10 -0000
@@ -64,7 +64,7 @@ namespace DOM
 {
     class CSSStyleSheetImpl;
     class DocumentImpl;
-};
+}
 
 namespace khtml
 {
@@ -518,6 +518,6 @@ namespace khtml
         static unsigned long s_ulRefCnt;
     };
 
-};
+} // namespace
 
 #endif
Index: misc/loader_jpeg.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/misc/loader_jpeg.h,v
retrieving revision 1.1
diff -u -3 -d -p -r1.1 loader_jpeg.h
--- misc/loader_jpeg.h	26 Jul 2000 17:17:16 -0000	1.1
+++ misc/loader_jpeg.h	4 Feb 2003 08:14:10 -0000
@@ -42,7 +42,7 @@ namespace khtml
         const char* formatName() const;
     };
 
-};
+}
 
 
 // -----------------------------------------------------------------------------

--9amGYk9869ThD9tj--