[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 08:02:32 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit fba5dc1b01451eca7dad8abdea9c24fd2021025e
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 17 22:32:14 2003 +0000

    	Implement horizontal and vertical border-spacing.  Allow them to be specified individually.
    
            Reviewed by mjs
    
    	------
    
    	Fix the calcWidth method of tables to account for horizontal margins properly.
    
    	Reviewed by john
    
    	------
    
    	Implement border collapsing in tables.
    
    	Reviewed by kocienda
    
            * khtml/css/cssparser.cpp:
            (CSSParser::parseValue):
            * khtml/css/cssproperties.c:
            (hash_prop):
            (findProp):
            * khtml/css/cssproperties.h:
            * khtml/css/cssproperties.in:
            * khtml/css/cssstyleselector.cpp:
            (khtml::CSSStyleSelector::applyRule):
            * khtml/css/cssvalues.c:
            * khtml/css/cssvalues.h:
            * khtml/css/cssvalues.in:
            * khtml/rendering/bidi.cpp:
            (khtml::RenderBlock::layoutInlineChildren):
            * khtml/rendering/render_box.cpp:
            (RenderBox::paintBoxDecorations):
            * khtml/rendering/render_form.cpp:
            (RenderFieldset::paintBorderMinusLegend):
            * khtml/rendering/render_object.cpp:
            (RenderObject::paintBorder):
            (RenderObject::collectBorders):
            * khtml/rendering/render_object.h:
            * khtml/rendering/render_style.cpp:
            (StyleInheritedData::StyleInheritedData):
            (StyleInheritedData::operator==):
            (RenderStyle::diff):
            * khtml/rendering/render_style.h:
            (khtml::):
            (khtml::CollapsedBorderValue::precedence):
            (khtml::CollapsedBorderValue::width):
            (khtml::CollapsedBorderValue::style):
            (khtml::CollapsedBorderValue::exists):
            (khtml::CollapsedBorderValue::color):
            (khtml::CollapsedBorderValue::isTransparent):
            (khtml::CollapsedBorderValue::operator==):
            (khtml::RenderStyle::borderLeft):
            (khtml::RenderStyle::borderRight):
            (khtml::RenderStyle::borderTop):
            (khtml::RenderStyle::borderBottom):
            (khtml::RenderStyle::horizontalBorderSpacing):
            (khtml::RenderStyle::verticalBorderSpacing):
            (khtml::RenderStyle::setHorizontalBorderSpacing):
            (khtml::RenderStyle::setVerticalBorderSpacing):
            * khtml/rendering/render_table.cpp:
            (RenderTable::RenderTable):
            (RenderTable::setStyle):
            (RenderTable::calcWidth):
            (RenderTable::paint):
            (RenderTable::borderLeft):
            (RenderTable::borderRight):
            (RenderTable::borderTop):
            (RenderTable::borderBottom):
            (RenderTable::cellAbove):
            (RenderTable::cellBelow):
            (RenderTable::cellLeft):
            (RenderTable::cellRight):
            (RenderTableSection::setCellWidths):
            (RenderTableSection::calcRowHeight):
            (RenderTableSection::layoutRows):
            (compareBorders):
            (RenderTableCell::collapsedLeftBorder):
            (RenderTableCell::collapsedRightBorder):
            (RenderTableCell::collapsedTopBorder):
            (RenderTableCell::collapsedBottomBorder):
            (RenderTableCell::borderLeft):
            (RenderTableCell::borderRight):
            (RenderTableCell::borderTop):
            (RenderTableCell::borderBottom):
            (collapsedBorderStyle):
            (CollapsedBorder::CollapsedBorder):
            (CollapsedBorders:::count):
            (CollapsedBorders::addBorder):
            (CollapsedBorders::nextBorder):
            (addBorderStyle):
            (RenderTableCell::collectBorders):
            (RenderTableCell::paintCollapsedBorder):
            (RenderTableCell::paintObject):
            (RenderTableCell::paintBoxDecorations):
            * khtml/rendering/render_table.h:
            (khtml::RenderTable::hBorderSpacing):
            (khtml::RenderTable::vBorderSpacing):
            (khtml::RenderTable::bordersPaddingAndSpacing):
            (khtml::RenderTable::currentBorderStyle):
            * khtml/rendering/table_layout.cpp:
            (FixedTableLayout::layout):
            (AutoTableLayout::calcEffectiveWidth):
            (AutoTableLayout::layout):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5200 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index a9a44ea..3ac1f34 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,109 @@
+2003-10-17  David Hyatt  <hyatt at apple.com>
+
+	Implement horizontal and vertical border-spacing.  Allow them to be specified individually.
+
+        Reviewed by mjs
+
+	------
+
+	Fix the calcWidth method of tables to account for horizontal margins properly.
+
+	Reviewed by john
+
+	------
+
+	Implement border collapsing in tables.
+
+	Reviewed by kocienda
+
+        * khtml/css/cssparser.cpp:
+        (CSSParser::parseValue):
+        * khtml/css/cssproperties.c:
+        (hash_prop):
+        (findProp):
+        * khtml/css/cssproperties.h:
+        * khtml/css/cssproperties.in:
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::applyRule):
+        * khtml/css/cssvalues.c:
+        * khtml/css/cssvalues.h:
+        * khtml/css/cssvalues.in:
+        * khtml/rendering/bidi.cpp:
+        (khtml::RenderBlock::layoutInlineChildren):
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::paintBoxDecorations):
+        * khtml/rendering/render_form.cpp:
+        (RenderFieldset::paintBorderMinusLegend):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::paintBorder):
+        (RenderObject::collectBorders):
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_style.cpp:
+        (StyleInheritedData::StyleInheritedData):
+        (StyleInheritedData::operator==):
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        (khtml::):
+        (khtml::CollapsedBorderValue::precedence):
+        (khtml::CollapsedBorderValue::width):
+        (khtml::CollapsedBorderValue::style):
+        (khtml::CollapsedBorderValue::exists):
+        (khtml::CollapsedBorderValue::color):
+        (khtml::CollapsedBorderValue::isTransparent):
+        (khtml::CollapsedBorderValue::operator==):
+        (khtml::RenderStyle::borderLeft):
+        (khtml::RenderStyle::borderRight):
+        (khtml::RenderStyle::borderTop):
+        (khtml::RenderStyle::borderBottom):
+        (khtml::RenderStyle::horizontalBorderSpacing):
+        (khtml::RenderStyle::verticalBorderSpacing):
+        (khtml::RenderStyle::setHorizontalBorderSpacing):
+        (khtml::RenderStyle::setVerticalBorderSpacing):
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::RenderTable):
+        (RenderTable::setStyle):
+        (RenderTable::calcWidth):
+        (RenderTable::paint):
+        (RenderTable::borderLeft):
+        (RenderTable::borderRight):
+        (RenderTable::borderTop):
+        (RenderTable::borderBottom):
+        (RenderTable::cellAbove):
+        (RenderTable::cellBelow):
+        (RenderTable::cellLeft):
+        (RenderTable::cellRight):
+        (RenderTableSection::setCellWidths):
+        (RenderTableSection::calcRowHeight):
+        (RenderTableSection::layoutRows):
+        (compareBorders):
+        (RenderTableCell::collapsedLeftBorder):
+        (RenderTableCell::collapsedRightBorder):
+        (RenderTableCell::collapsedTopBorder):
+        (RenderTableCell::collapsedBottomBorder):
+        (RenderTableCell::borderLeft):
+        (RenderTableCell::borderRight):
+        (RenderTableCell::borderTop):
+        (RenderTableCell::borderBottom):
+        (collapsedBorderStyle):
+        (CollapsedBorder::CollapsedBorder):
+        (CollapsedBorders:::count):
+        (CollapsedBorders::addBorder):
+        (CollapsedBorders::nextBorder):
+        (addBorderStyle):
+        (RenderTableCell::collectBorders):
+        (RenderTableCell::paintCollapsedBorder):
+        (RenderTableCell::paintObject):
+        (RenderTableCell::paintBoxDecorations):
+        * khtml/rendering/render_table.h:
+        (khtml::RenderTable::hBorderSpacing):
+        (khtml::RenderTable::vBorderSpacing):
+        (khtml::RenderTable::bordersPaddingAndSpacing):
+        (khtml::RenderTable::currentBorderStyle):
+        * khtml/rendering/table_layout.cpp:
+        (FixedTableLayout::layout):
+        (AutoTableLayout::calcEffectiveWidth):
+        (AutoTableLayout::layout):
+
 2003-10-16  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a9a44ea..3ac1f34 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,109 @@
+2003-10-17  David Hyatt  <hyatt at apple.com>
+
+	Implement horizontal and vertical border-spacing.  Allow them to be specified individually.
+
+        Reviewed by mjs
+
+	------
+
+	Fix the calcWidth method of tables to account for horizontal margins properly.
+
+	Reviewed by john
+
+	------
+
+	Implement border collapsing in tables.
+
+	Reviewed by kocienda
+
+        * khtml/css/cssparser.cpp:
+        (CSSParser::parseValue):
+        * khtml/css/cssproperties.c:
+        (hash_prop):
+        (findProp):
+        * khtml/css/cssproperties.h:
+        * khtml/css/cssproperties.in:
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::applyRule):
+        * khtml/css/cssvalues.c:
+        * khtml/css/cssvalues.h:
+        * khtml/css/cssvalues.in:
+        * khtml/rendering/bidi.cpp:
+        (khtml::RenderBlock::layoutInlineChildren):
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::paintBoxDecorations):
+        * khtml/rendering/render_form.cpp:
+        (RenderFieldset::paintBorderMinusLegend):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::paintBorder):
+        (RenderObject::collectBorders):
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_style.cpp:
+        (StyleInheritedData::StyleInheritedData):
+        (StyleInheritedData::operator==):
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        (khtml::):
+        (khtml::CollapsedBorderValue::precedence):
+        (khtml::CollapsedBorderValue::width):
+        (khtml::CollapsedBorderValue::style):
+        (khtml::CollapsedBorderValue::exists):
+        (khtml::CollapsedBorderValue::color):
+        (khtml::CollapsedBorderValue::isTransparent):
+        (khtml::CollapsedBorderValue::operator==):
+        (khtml::RenderStyle::borderLeft):
+        (khtml::RenderStyle::borderRight):
+        (khtml::RenderStyle::borderTop):
+        (khtml::RenderStyle::borderBottom):
+        (khtml::RenderStyle::horizontalBorderSpacing):
+        (khtml::RenderStyle::verticalBorderSpacing):
+        (khtml::RenderStyle::setHorizontalBorderSpacing):
+        (khtml::RenderStyle::setVerticalBorderSpacing):
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::RenderTable):
+        (RenderTable::setStyle):
+        (RenderTable::calcWidth):
+        (RenderTable::paint):
+        (RenderTable::borderLeft):
+        (RenderTable::borderRight):
+        (RenderTable::borderTop):
+        (RenderTable::borderBottom):
+        (RenderTable::cellAbove):
+        (RenderTable::cellBelow):
+        (RenderTable::cellLeft):
+        (RenderTable::cellRight):
+        (RenderTableSection::setCellWidths):
+        (RenderTableSection::calcRowHeight):
+        (RenderTableSection::layoutRows):
+        (compareBorders):
+        (RenderTableCell::collapsedLeftBorder):
+        (RenderTableCell::collapsedRightBorder):
+        (RenderTableCell::collapsedTopBorder):
+        (RenderTableCell::collapsedBottomBorder):
+        (RenderTableCell::borderLeft):
+        (RenderTableCell::borderRight):
+        (RenderTableCell::borderTop):
+        (RenderTableCell::borderBottom):
+        (collapsedBorderStyle):
+        (CollapsedBorder::CollapsedBorder):
+        (CollapsedBorders:::count):
+        (CollapsedBorders::addBorder):
+        (CollapsedBorders::nextBorder):
+        (addBorderStyle):
+        (RenderTableCell::collectBorders):
+        (RenderTableCell::paintCollapsedBorder):
+        (RenderTableCell::paintObject):
+        (RenderTableCell::paintBoxDecorations):
+        * khtml/rendering/render_table.h:
+        (khtml::RenderTable::hBorderSpacing):
+        (khtml::RenderTable::vBorderSpacing):
+        (khtml::RenderTable::bordersPaddingAndSpacing):
+        (khtml::RenderTable::currentBorderStyle):
+        * khtml/rendering/table_layout.cpp:
+        (FixedTableLayout::layout):
+        (AutoTableLayout::calcEffectiveWidth):
+        (AutoTableLayout::layout):
+
 2003-10-16  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 27b9250..3919dd4 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -565,7 +565,7 @@ bool CSSParser::parseValue( int propId, bool important )
     case CSS_PROP_BORDER_RIGHT_STYLE:   //   Defined as:    none | hidden | dotted | dashed |
     case CSS_PROP_BORDER_BOTTOM_STYLE:  //   solid | double | groove | ridge | inset | outset
     case CSS_PROP_BORDER_LEFT_STYLE:    ////
-	if (id >= CSS_VAL_NONE && id <= CSS_VAL_RIDGE)
+	if (id >= CSS_VAL_NONE && id <= CSS_VAL_DOUBLE)
 	    valid_primitive = true;
 	break;
 
@@ -688,11 +688,27 @@ bool CSSParser::parseValue( int propId, bool important )
 	valid_primitive = validUnit( value, FPercent|FLength, strict&(!nonCSSHint) );
 	break;
 
-    case CSS_PROP_BORDER_SPACING:
-	// ### should be able to have two values
-	valid_primitive = ( validUnit( value, FLength|FNonNeg, strict&(!nonCSSHint) ) );
-	break;
-
+    case CSS_PROP_BORDER_SPACING: {
+        const int properties[2] = { CSS_PROP__KHTML_HORIZONTAL_BORDER_SPACING,
+                                    CSS_PROP__KHTML_VERTICAL_BORDER_SPACING };
+        int num = valueList->numValues;
+        if (num == 1) {
+            if (!parseValue(properties[0], important)) return false;
+            CSSValueImpl* value = parsedProperties[numParsedProperties-1]->value();
+            addProperty(properties[1], value, important);
+            return true;
+        }
+        else if (num == 2) {
+            if (!parseValue(properties[0], important)) return false;
+            if (!parseValue(properties[1], important)) return false;
+            return true;
+        }
+        return false;
+    }
+    case CSS_PROP__KHTML_HORIZONTAL_BORDER_SPACING:
+    case CSS_PROP__KHTML_VERTICAL_BORDER_SPACING:
+        valid_primitive = validUnit(value, FLength|FNonNeg, strict&(!nonCSSHint));
+        break;
     case CSS_PROP_SCROLLBAR_FACE_COLOR:         // IE5.5
     case CSS_PROP_SCROLLBAR_SHADOW_COLOR:       // IE5.5
     case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:    // IE5.5
diff --git a/WebCore/khtml/css/cssproperties.c b/WebCore/khtml/css/cssproperties.c
index f7a80d9..41f4efa 100644
--- a/WebCore/khtml/css/cssproperties.c
+++ b/WebCore/khtml/css/cssproperties.c
@@ -7,7 +7,7 @@ struct props {
     const char *name;
     int id;
 };
-/* maximum key range = 855, duplicates = 0 */
+/* maximum key range = 1178, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -21,38 +21,50 @@ hash_prop (register const char *str, register unsigned int len)
 {
   static const unsigned short asso_values[] =
     {
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860,   0, 860, 860, 860, 860,
-      860,   0, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860,  25,  35,   0,
-        0,   0, 160,   0,  30,   0,   0, 100,   0, 135,
-      158,   0,  10,   5,   0,  20,   0, 110,  15, 220,
-       95, 210,  10, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860, 860, 860, 860, 860,
-      860, 860, 860, 860, 860, 860
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185,    0, 1185, 1185, 1185, 1185,
+      1185,    0, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185,   15,   10,    0,
+         0,    0,  228,   35,    0,    0,    0,    0,  160,   40,
+         0,    0,   40,    5,    0,   45,    0,  250,   20,  180,
+       120,  210,   20, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185,
+      1185, 1185, 1185, 1185, 1185, 1185
     };
   register int hval = len;
 
   switch (hval)
     {
       default:
+      case 32:
+        hval += asso_values[(unsigned char)str[31]];
+      case 31:
+        hval += asso_values[(unsigned char)str[30]];
+      case 30:
+        hval += asso_values[(unsigned char)str[29]];
+      case 29:
+        hval += asso_values[(unsigned char)str[28]];
+      case 28:
+        hval += asso_values[(unsigned char)str[27]];
+      case 27:
+        hval += asso_values[(unsigned char)str[26]];
       case 26:
         hval += asso_values[(unsigned char)str[25]];
       case 25:
@@ -118,226 +130,261 @@ findProp (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 121,
+      TOTAL_KEYWORDS = 123,
       MIN_WORD_LENGTH = 3,
-      MAX_WORD_LENGTH = 26,
-      MIN_HASH_VALUE = 5,
-      MAX_HASH_VALUE = 859
+      MAX_WORD_LENGTH = 32,
+      MIN_HASH_VALUE = 7,
+      MAX_HASH_VALUE = 1184
     };
 
   static const struct props wordlist_prop[] =
     {
-      {"color", CSS_PROP_COLOR},
-      {"top", CSS_PROP_TOP},
-      {"clip", CSS_PROP_CLIP},
-      {"clear", CSS_PROP_CLEAR},
-      {"size", CSS_PROP_SIZE},
-      {"right", CSS_PROP_RIGHT},
-      {"page", CSS_PROP_PAGE},
+      {"content", CSS_PROP_CONTENT},
+      {"direction", CSS_PROP_DIRECTION},
       {"border", CSS_PROP_BORDER},
-      {"border-color", CSS_PROP_BORDER_COLOR},
-      {"border-top", CSS_PROP_BORDER_TOP},
-      {"border-top-color", CSS_PROP_BORDER_TOP_COLOR},
+      {"right", CSS_PROP_RIGHT},
       {"height", CSS_PROP_HEIGHT},
-      {"border-right", CSS_PROP_BORDER_RIGHT},
-      {"border-right-color", CSS_PROP_BORDER_RIGHT_COLOR},
-      {"border-collapse", CSS_PROP_BORDER_COLLAPSE},
-      {"scrollbar-3dlight-color", CSS_PROP_SCROLLBAR_3DLIGHT_COLOR},
-      {"cursor", CSS_PROP_CURSOR},
-      {"quotes", CSS_PROP_QUOTES},
-      {"left", CSS_PROP_LEFT},
-      {"direction", CSS_PROP_DIRECTION},
+      {"top", CSS_PROP_TOP},
       {"bottom", CSS_PROP_BOTTOM},
-      {"float", CSS_PROP_FLOAT},
-      {"scrollbar-highlight-color", CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR},
+      {"border-right", CSS_PROP_BORDER_RIGHT},
+      {"border-top", CSS_PROP_BORDER_TOP},
+      {"size", CSS_PROP_SIZE},
+      {"border-bottom", CSS_PROP_BORDER_BOTTOM},
+      {"min-height", CSS_PROP_MIN_HEIGHT},
       {"position", CSS_PROP_POSITION},
+      {"page", CSS_PROP_PAGE},
+      {"margin", CSS_PROP_MARGIN},
       {"padding", CSS_PROP_PADDING},
-      {"border-left", CSS_PROP_BORDER_LEFT},
-      {"border-left-color", CSS_PROP_BORDER_LEFT_COLOR},
-      {"padding-top", CSS_PROP_PADDING_TOP},
-      {"border-bottom", CSS_PROP_BORDER_BOTTOM},
-      {"border-bottom-color", CSS_PROP_BORDER_BOTTOM_COLOR},
+      {"orphans", CSS_PROP_ORPHANS},
       {"caption-side", CSS_PROP_CAPTION_SIDE},
-      {"scrollbar-track-color", CSS_PROP_SCROLLBAR_TRACK_COLOR},
-      {"letter-spacing", CSS_PROP_LETTER_SPACING},
-      {"line-height", CSS_PROP_LINE_HEIGHT},
+      {"text-indent", CSS_PROP_TEXT_INDENT},
+      {"margin-right", CSS_PROP_MARGIN_RIGHT},
       {"padding-right", CSS_PROP_PADDING_RIGHT},
-      {"vertical-align", CSS_PROP_VERTICAL_ALIGN},
-      {"orphans", CSS_PROP_ORPHANS},
-      {"width", CSS_PROP_WIDTH},
-      {"list-style", CSS_PROP_LIST_STYLE},
-      {"border-spacing", CSS_PROP_BORDER_SPACING},
+      {"margin-top", CSS_PROP_MARGIN_TOP},
+      {"padding-top", CSS_PROP_PADDING_TOP},
       {"z-index", CSS_PROP_Z_INDEX},
-      {"display", CSS_PROP_DISPLAY},
-      {"outline", CSS_PROP_OUTLINE},
-      {"border-style", CSS_PROP_BORDER_STYLE},
-      {"outline-color", CSS_PROP_OUTLINE_COLOR},
-      {"scrollbar-face-color", CSS_PROP_SCROLLBAR_FACE_COLOR},
-      {"text-align", CSS_PROP_TEXT_ALIGN},
-      {"visibility", CSS_PROP_VISIBILITY},
-      {"border-top-style", CSS_PROP_BORDER_TOP_STYLE},
       {"text-decoration", CSS_PROP_TEXT_DECORATION},
+      {"margin-bottom", CSS_PROP_MARGIN_BOTTOM},
+      {"padding-bottom", CSS_PROP_PADDING_BOTTOM},
+      {"border-spacing", CSS_PROP_BORDER_SPACING},
+      {"color", CSS_PROP_COLOR},
+      {"page-break-inside", CSS_PROP_PAGE_BREAK_INSIDE},
+      {"clear", CSS_PROP_CLEAR},
+      {"border-color", CSS_PROP_BORDER_COLOR},
+      {"width", CSS_PROP_WIDTH},
       {"border-width", CSS_PROP_BORDER_WIDTH},
-      {"text-decoration-color", CSS_PROP_TEXT_DECORATION_COLOR},
-      {"counter-reset", CSS_PROP_COUNTER_RESET},
+      {"clip", CSS_PROP_CLIP},
+      {"line-height", CSS_PROP_LINE_HEIGHT},
+      {"max-height", CSS_PROP_MAX_HEIGHT},
+      {"border-right-color", CSS_PROP_BORDER_RIGHT_COLOR},
+      {"border-top-color", CSS_PROP_BORDER_TOP_COLOR},
+      {"min-width", CSS_PROP_MIN_WIDTH},
+      {"font", CSS_PROP_FONT},
+      {"border-bottom-color", CSS_PROP_BORDER_BOTTOM_COLOR},
+      {"border-right-width", CSS_PROP_BORDER_RIGHT_WIDTH},
       {"border-top-width", CSS_PROP_BORDER_TOP_WIDTH},
-      {"border-right-style", CSS_PROP_BORDER_RIGHT_STYLE},
+      {"border-bottom-width", CSS_PROP_BORDER_BOTTOM_WIDTH},
       {"unicode-bidi", CSS_PROP_UNICODE_BIDI},
+      {"font-stretch", CSS_PROP_FONT_STRETCH},
+      {"font-variant", CSS_PROP_FONT_VARIANT},
       {"white-space", CSS_PROP_WHITE_SPACE},
-      {"font", CSS_PROP_FONT},
-      {"content", CSS_PROP_CONTENT},
-      {"margin", CSS_PROP_MARGIN},
-      {"max-height", CSS_PROP_MAX_HEIGHT},
-      {"border-right-width", CSS_PROP_BORDER_RIGHT_WIDTH},
-      {"margin-top", CSS_PROP_MARGIN_TOP},
-      {"scrollbar-arrow-color", CSS_PROP_SCROLLBAR_ARROW_COLOR},
+      {"cursor", CSS_PROP_CURSOR},
       {"font-size", CSS_PROP_FONT_SIZE},
-      {"margin-right", CSS_PROP_MARGIN_RIGHT},
-      {"min-height", CSS_PROP_MIN_HEIGHT},
-      {"padding-left", CSS_PROP_PADDING_LEFT},
-      {"padding-bottom", CSS_PROP_PADDING_BOTTOM},
-      {"font-stretch", CSS_PROP_FONT_STRETCH},
-      {"empty-cells", CSS_PROP_EMPTY_CELLS},
-      {"page-break-inside", CSS_PROP_PAGE_BREAK_INSIDE},
-      {"page-break-after", CSS_PROP_PAGE_BREAK_AFTER},
-      {"scrollbar-shadow-color", CSS_PROP_SCROLLBAR_SHADOW_COLOR},
-      {"text-shadow", CSS_PROP_TEXT_SHADOW},
-      {"overflow", CSS_PROP_OVERFLOW},
-      {"page-break-before", CSS_PROP_PAGE_BREAK_BEFORE},
-      {"table-layout", CSS_PROP_TABLE_LAYOUT},
-      {"text-indent", CSS_PROP_TEXT_INDENT},
-      {"list-style-image", CSS_PROP_LIST_STYLE_IMAGE},
+      {"quotes", CSS_PROP_QUOTES},
+      {"counter-increment", CSS_PROP_COUNTER_INCREMENT},
+      {"counter-reset", CSS_PROP_COUNTER_RESET},
+      {"letter-spacing", CSS_PROP_LETTER_SPACING},
+      {"text-decoration-color", CSS_PROP_TEXT_DECORATION_COLOR},
       {"background", CSS_PROP_BACKGROUND},
-      {"border-left-style", CSS_PROP_BORDER_LEFT_STYLE},
-      {"background-color", CSS_PROP_BACKGROUND_COLOR},
       {"word-spacing", CSS_PROP_WORD_SPACING},
-      {"border-bottom-style", CSS_PROP_BORDER_BOTTOM_STYLE},
-      {"list-style-position", CSS_PROP_LIST_STYLE_POSITION},
-      {"border-left-width", CSS_PROP_BORDER_LEFT_WIDTH},
-      {"widows", CSS_PROP_WIDOWS},
-      {"border-bottom-width", CSS_PROP_BORDER_BOTTOM_WIDTH},
-      {"background-repeat", CSS_PROP_BACKGROUND_REPEAT},
-      {"list-style-type", CSS_PROP_LIST_STYLE_TYPE},
-      {"margin-left", CSS_PROP_MARGIN_LEFT},
-      {"margin-bottom", CSS_PROP_MARGIN_BOTTOM},
-      {"outline-style", CSS_PROP_OUTLINE_STYLE},
-      {"max-width", CSS_PROP_MAX_WIDTH},
-      {"font-size-adjust", CSS_PROP_FONT_SIZE_ADJUST},
-      {"-khtml-opacity", CSS_PROP__KHTML_OPACITY},
-      {"scrollbar-darkshadow-color", CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR},
-      {"outline-width", CSS_PROP_OUTLINE_WIDTH},
-      {"-khtml-box-pack", CSS_PROP__KHTML_BOX_PACK},
-      {"min-width", CSS_PROP_MIN_WIDTH},
-      {"font-variant", CSS_PROP_FONT_VARIANT},
-      {"font-style", CSS_PROP_FONT_STYLE},
+      {"text-align", CSS_PROP_TEXT_ALIGN},
       {"-khtml-box-orient", CSS_PROP__KHTML_BOX_ORIENT},
       {"-khtml-box-direction", CSS_PROP__KHTML_BOX_DIRECTION},
+      {"max-width", CSS_PROP_MAX_WIDTH},
+      {"page-break-before", CSS_PROP_PAGE_BREAK_BEFORE},
+      {"text-shadow", CSS_PROP_TEXT_SHADOW},
+      {"page-break-after", CSS_PROP_PAGE_BREAK_AFTER},
+      {"background-repeat", CSS_PROP_BACKGROUND_REPEAT},
+      {"left", CSS_PROP_LEFT},
+      {"-khtml-box-pack", CSS_PROP__KHTML_BOX_PACK},
+      {"background-attachment", CSS_PROP_BACKGROUND_ATTACHMENT},
+      {"float", CSS_PROP_FLOAT},
+      {"border-left", CSS_PROP_BORDER_LEFT},
+      {"widows", CSS_PROP_WIDOWS},
+      {"background-position", CSS_PROP_BACKGROUND_POSITION},
+      {"background-image", CSS_PROP_BACKGROUND_IMAGE},
+      {"outline", CSS_PROP_OUTLINE},
+      {"vertical-align", CSS_PROP_VERTICAL_ALIGN},
+      {"border-style", CSS_PROP_BORDER_STYLE},
+      {"border-collapse", CSS_PROP_BORDER_COLLAPSE},
       {"font-weight", CSS_PROP_FONT_WEIGHT},
+      {"visibility", CSS_PROP_VISIBILITY},
+      {"text-transform", CSS_PROP_TEXT_TRANSFORM},
+      {"display", CSS_PROP_DISPLAY},
+      {"border-right-style", CSS_PROP_BORDER_RIGHT_STYLE},
+      {"-khtml-opacity", CSS_PROP__KHTML_OPACITY},
+      {"border-top-style", CSS_PROP_BORDER_TOP_STYLE},
+      {"background-color", CSS_PROP_BACKGROUND_COLOR},
+      {"margin-left", CSS_PROP_MARGIN_LEFT},
+      {"padding-left", CSS_PROP_PADDING_LEFT},
+      {"border-bottom-style", CSS_PROP_BORDER_BOTTOM_STYLE},
+      {"background-position-x", CSS_PROP_BACKGROUND_POSITION_X},
       {"-khtml-box-lines", CSS_PROP__KHTML_BOX_LINES},
       {"-khtml-box-align", CSS_PROP__KHTML_BOX_ALIGN},
-      {"background-image", CSS_PROP_BACKGROUND_IMAGE},
-      {"text-transform", CSS_PROP_TEXT_TRANSFORM},
       {"marker-offset", CSS_PROP_MARKER_OFFSET},
-      {"background-position", CSS_PROP_BACKGROUND_POSITION},
+      {"-khtml-vertical-border-spacing", CSS_PROP__KHTML_VERTICAL_BORDER_SPACING},
+      {"-khtml-horizontal-border-spacing", CSS_PROP__KHTML_HORIZONTAL_BORDER_SPACING},
+      {"border-left-color", CSS_PROP_BORDER_LEFT_COLOR},
+      {"outline-color", CSS_PROP_OUTLINE_COLOR},
+      {"scrollbar-track-color", CSS_PROP_SCROLLBAR_TRACK_COLOR},
+      {"border-left-width", CSS_PROP_BORDER_LEFT_WIDTH},
+      {"overflow", CSS_PROP_OVERFLOW},
+      {"outline-width", CSS_PROP_OUTLINE_WIDTH},
+      {"font-size-adjust", CSS_PROP_FONT_SIZE_ADJUST},
+      {"background-position-y", CSS_PROP_BACKGROUND_POSITION_Y},
+      {"list-style", CSS_PROP_LIST_STYLE},
+      {"font-style", CSS_PROP_FONT_STYLE},
+      {"empty-cells", CSS_PROP_EMPTY_CELLS},
+      {"list-style-position", CSS_PROP_LIST_STYLE_POSITION},
+      {"list-style-image", CSS_PROP_LIST_STYLE_IMAGE},
+      {"scrollbar-arrow-color", CSS_PROP_SCROLLBAR_ARROW_COLOR},
+      {"scrollbar-3dlight-color", CSS_PROP_SCROLLBAR_3DLIGHT_COLOR},
+      {"scrollbar-highlight-color", CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR},
+      {"scrollbar-shadow-color", CSS_PROP_SCROLLBAR_SHADOW_COLOR},
+      {"scrollbar-face-color", CSS_PROP_SCROLLBAR_FACE_COLOR},
+      {"-khtml-flow-mode", CSS_PROP__KHTML_FLOW_MODE},
+      {"border-left-style", CSS_PROP_BORDER_LEFT_STYLE},
+      {"scrollbar-darkshadow-color", CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR},
+      {"table-layout", CSS_PROP_TABLE_LAYOUT},
+      {"outline-style", CSS_PROP_OUTLINE_STYLE},
       {"-khtml-box-flex", CSS_PROP__KHTML_BOX_FLEX},
       {"-khtml-box-ordinal-group", CSS_PROP__KHTML_BOX_ORDINAL_GROUP},
-      {"background-position-x", CSS_PROP_BACKGROUND_POSITION_X},
-      {"counter-increment", CSS_PROP_COUNTER_INCREMENT},
-      {"-khtml-box-flex-group", CSS_PROP__KHTML_BOX_FLEX_GROUP},
-      {"-khtml-flow-mode", CSS_PROP__KHTML_FLOW_MODE},
-      {"background-attachment", CSS_PROP_BACKGROUND_ATTACHMENT},
-      {"background-position-y", CSS_PROP_BACKGROUND_POSITION_Y},
-      {"font-family", CSS_PROP_FONT_FAMILY}
+      {"list-style-type", CSS_PROP_LIST_STYLE_TYPE},
+      {"font-family", CSS_PROP_FONT_FAMILY},
+      {"-khtml-box-flex-group", CSS_PROP__KHTML_BOX_FLEX_GROUP}
     };
 
   static const signed char lookup[] =
     {
-       -1,  -1,  -1,  -1,  -1,   0,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,   1,   2,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,  -1,   1,
+       -1,  -1,  -1,  -1,  -1,  -1,   2,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+        3,   4,  -1,   5,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,   6,   7,  -1,  -1,
+        8,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   9,
+       -1,  -1,  -1,  10,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  11,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  12,  13,  -1,  14,  15,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  16,  -1,  -1,
+       -1,  -1,  17,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  18,  -1,  -1,  -1,  -1,  -1,  19,  20,  -1,
+       21,  22,  -1,  -1,  -1,  -1,  -1,  23,  -1,  -1,
+       24,  -1,  -1,  25,  26,  -1,  -1,  -1,  -1,  27,
+       -1,  -1,  -1,  -1,  -1,  28,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  29,  -1,  -1,
+       30,  -1,  31,  -1,  -1,  32,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  33,  -1,  34,  -1,  35,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       36,  -1,  -1,  37,  -1,  -1,  38,  -1,  -1,  39,
+       -1,  -1,  40,  -1,  -1,  -1,  -1,  -1,  -1,  41,
+       -1,  -1,  -1,  42,  -1,  -1,  43,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  44,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  45,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  46,  -1,  -1,  -1,  -1,
+       47,  48,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  49,  50,  -1,  -1,  -1,  51,  52,  53,  54,
+       -1,  -1,  -1,  -1,  -1,  -1,  55,  -1,  -1,  -1,
+       56,  -1,  -1,  -1,  -1,  -1,  -1,  57,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       58,  -1,  -1,  -1,  -1,  -1,  -1,  59,  -1,  -1,
+       60,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  61,  -1,  -1,  -1,  -1,  -1,
+       62,  63,  -1,  -1,  64,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  65,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  66,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       67,  68,  -1,  -1,  -1,  -1,  -1,  -1,  69,  70,
+       -1,  71,  -1,  -1,  72,  -1,  73,  74,  -1,  75,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  76,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  77,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  78,  79,  -1,  -1,  -1,  -1,
+       -1,  -1,  80,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  81,  82,  83,
+       -1,  84,  -1,  -1,  -1,  -1,  85,  -1,  -1,  86,
+       87,  -1,  -1,  -1,  88,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  89,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  90,  -1,  -1,  -1,  -1,  91,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  92,
+       93,  -1,  94,  -1,  -1,  95,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  96,  -1,  -1,  97,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  98,  99,  -1,  -1,  -1,
+       -1,  -1,  -1, 100,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 101,
+       -1,  -1,  -1,  -1,  -1,  -1, 102,  -1,  -1,  -1,
+      103,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1, 104,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 105,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1, 106,  -1, 107,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 108,  -1, 109,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1, 110,  -1,  -1,  -1,  -1,
+       -1,  -1, 111, 112,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1, 113,  -1,  -1,  -1,  -1,  -1,
+      114, 115, 116,  -1,  -1,  -1,  -1,  -1, 117,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1, 118, 119,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1, 120,  -1,  -1,  -1,  -1,
+       -1,  -1, 121,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-        3,  -1,  -1,  -1,   4,   5,  -1,  -1,  -1,   6,
-       -1,   7,  -1,  -1,  -1,  -1,  -1,   8,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,   9,  -1,  -1,  -1,  -1,
-       -1,  10,  -1,  -1,  -1,  -1,  11,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  12,  -1,  -1,
-       -1,  -1,  -1,  13,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  14,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  15,  -1,  -1,  16,  -1,  -1,  -1,
-       -1,  17,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  18,  -1,  -1,  19,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  20,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       21,  -1,  -1,  -1,  -1,  22,  23,  -1,  -1,  -1,
-       24,  -1,  -1,  -1,  -1,  -1,  25,  -1,  -1,  -1,
-       -1,  -1,  26,  -1,  27,  -1,  -1,  -1,  28,  -1,
-       -1,  -1,  -1,  -1,  29,  30,  31,  32,  -1,  33,
-       -1,  -1,  -1,  -1,  -1,  -1,  34,  35,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       36,  -1,  -1,  -1,  -1,  37,  -1,  -1,  -1,  -1,
-       38,  -1,  39,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       40,  -1,  41,  -1,  -1,  42,  -1,  43,  -1,  -1,
-       -1,  44,  -1,  -1,  -1,  45,  -1,  -1,  46,  -1,
-       47,  48,  -1,  49,  -1,  -1,  -1,  50,  -1,  51,
-       -1,  52,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  53,  -1,  54,  -1,  55,  56,  -1,  -1,  -1,
-       -1,  -1,  57,  58,  59,  60,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  61,  -1,  -1,  -1,  -1,  62,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  63,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  64,  -1,  -1,
-       65,  -1,  -1,  66,  -1,  67,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  68,  -1,  -1,
-       69,  -1,  -1,  -1,  -1,  -1,  70,  -1,  -1,  -1,
-       71,  -1,  -1,  -1,  -1,  -1,  72,  73,  -1,  -1,
-       -1,  74,  -1,  75,  -1,  -1,  -1,  76,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  77,  -1,  -1,
-       -1,  -1,  78,  -1,  -1,  -1,  79,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  80,  -1,
-       -1,  -1,  81,  -1,  82,  83,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  84,  -1,  -1,  85,  -1,  -1,
-       -1,  -1,  86,  -1,  -1,  -1,  87,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  88,  -1,  -1,  -1,  -1,  -1,
-       89,  -1,  -1,  -1,  -1,  90,  -1,  -1,  -1,  91,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  92,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  93,  -1,  -1,  94,  -1,  -1,  -1,  -1,  95,
-       -1,  -1,  -1,  -1,  96,  -1,  97,  -1,  -1,  -1,
-       -1,  98,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  99,  -1,  -1,  -1,  -1,
-       -1,  -1, 100, 101,  -1,  -1,  -1,  -1, 102,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-      103,  -1,  -1, 104,  -1,  -1,  -1,  -1,  -1, 105,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 106,
-       -1,  -1,  -1,  -1, 107,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1, 108,  -1,  -1, 109,  -1,  -1,
-       -1,  -1,  -1, 110,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1, 111,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1, 112,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1, 113,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1, 114,  -1,  -1,  -1, 115,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1, 116,  -1,  -1,  -1,  -1, 117,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1, 118,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1, 119,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 120
+       -1,  -1,  -1,  -1, 122
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -370,6 +417,8 @@ static const char * const propertyList[] = {
 "background-position-y", 
 "border-collapse", 
 "border-spacing", 
+"-khtml-horizontal-border-spacing", 
+"-khtml-vertical-border-spacing", 
 "border-top-color", 
 "border-right-color", 
 "border-bottom-color", 
diff --git a/WebCore/khtml/css/cssproperties.h b/WebCore/khtml/css/cssproperties.h
index d21b5b8..04b6fc6 100644
--- a/WebCore/khtml/css/cssproperties.h
+++ b/WebCore/khtml/css/cssproperties.h
@@ -16,120 +16,122 @@
 #define CSS_PROP_BACKGROUND_POSITION_Y 7
 #define CSS_PROP_BORDER_COLLAPSE 8
 #define CSS_PROP_BORDER_SPACING 9
-#define CSS_PROP_BORDER_TOP_COLOR 10
-#define CSS_PROP_BORDER_RIGHT_COLOR 11
-#define CSS_PROP_BORDER_BOTTOM_COLOR 12
-#define CSS_PROP_BORDER_LEFT_COLOR 13
-#define CSS_PROP_BORDER_TOP_STYLE 14
-#define CSS_PROP_BORDER_RIGHT_STYLE 15
-#define CSS_PROP_BORDER_BOTTOM_STYLE 16
-#define CSS_PROP_BORDER_LEFT_STYLE 17
-#define CSS_PROP_BORDER_TOP_WIDTH 18
-#define CSS_PROP_BORDER_RIGHT_WIDTH 19
-#define CSS_PROP_BORDER_BOTTOM_WIDTH 20
-#define CSS_PROP_BORDER_LEFT_WIDTH 21
-#define CSS_PROP_BOTTOM 22
-#define CSS_PROP__KHTML_BOX_ALIGN 23
-#define CSS_PROP__KHTML_BOX_DIRECTION 24
-#define CSS_PROP__KHTML_BOX_FLEX 25
-#define CSS_PROP__KHTML_BOX_FLEX_GROUP 26
-#define CSS_PROP__KHTML_BOX_LINES 27
-#define CSS_PROP__KHTML_BOX_ORDINAL_GROUP 28
-#define CSS_PROP__KHTML_BOX_ORIENT 29
-#define CSS_PROP__KHTML_BOX_PACK 30
-#define CSS_PROP_CAPTION_SIDE 31
-#define CSS_PROP_CLEAR 32
-#define CSS_PROP_CLIP 33
-#define CSS_PROP_COLOR 34
-#define CSS_PROP_CONTENT 35
-#define CSS_PROP_COUNTER_INCREMENT 36
-#define CSS_PROP_COUNTER_RESET 37
-#define CSS_PROP_CURSOR 38
-#define CSS_PROP_DIRECTION 39
-#define CSS_PROP_DISPLAY 40
-#define CSS_PROP_EMPTY_CELLS 41
-#define CSS_PROP_FLOAT 42
-#define CSS_PROP_FONT_FAMILY 43
-#define CSS_PROP_FONT_SIZE 44
-#define CSS_PROP_FONT_SIZE_ADJUST 45
-#define CSS_PROP_FONT_STRETCH 46
-#define CSS_PROP_FONT_STYLE 47
-#define CSS_PROP_FONT_VARIANT 48
-#define CSS_PROP_FONT_WEIGHT 49
-#define CSS_PROP_HEIGHT 50
-#define CSS_PROP_LEFT 51
-#define CSS_PROP_LETTER_SPACING 52
-#define CSS_PROP_LINE_HEIGHT 53
-#define CSS_PROP_LIST_STYLE_IMAGE 54
-#define CSS_PROP_LIST_STYLE_POSITION 55
-#define CSS_PROP_LIST_STYLE_TYPE 56
-#define CSS_PROP_MARGIN_TOP 57
-#define CSS_PROP_MARGIN_RIGHT 58
-#define CSS_PROP_MARGIN_BOTTOM 59
-#define CSS_PROP_MARGIN_LEFT 60
-#define CSS_PROP_MARKER_OFFSET 61
-#define CSS_PROP_MAX_HEIGHT 62
-#define CSS_PROP_MAX_WIDTH 63
-#define CSS_PROP_MIN_HEIGHT 64
-#define CSS_PROP_MIN_WIDTH 65
-#define CSS_PROP__KHTML_OPACITY 66
-#define CSS_PROP_ORPHANS 67
-#define CSS_PROP_OUTLINE_COLOR 68
-#define CSS_PROP_OUTLINE_STYLE 69
-#define CSS_PROP_OUTLINE_WIDTH 70
-#define CSS_PROP_OVERFLOW 71
-#define CSS_PROP_PADDING_TOP 72
-#define CSS_PROP_PADDING_RIGHT 73
-#define CSS_PROP_PADDING_BOTTOM 74
-#define CSS_PROP_PADDING_LEFT 75
-#define CSS_PROP_PAGE 76
-#define CSS_PROP_PAGE_BREAK_AFTER 77
-#define CSS_PROP_PAGE_BREAK_BEFORE 78
-#define CSS_PROP_PAGE_BREAK_INSIDE 79
-#define CSS_PROP_POSITION 80
-#define CSS_PROP_QUOTES 81
-#define CSS_PROP_RIGHT 82
-#define CSS_PROP_SIZE 83
-#define CSS_PROP_TABLE_LAYOUT 84
-#define CSS_PROP_TEXT_ALIGN 85
-#define CSS_PROP_TEXT_DECORATION 86
-#define CSS_PROP_TEXT_DECORATION_COLOR 87
-#define CSS_PROP_TEXT_INDENT 88
-#define CSS_PROP_TEXT_SHADOW 89
-#define CSS_PROP_TEXT_TRANSFORM 90
-#define CSS_PROP_TOP 91
-#define CSS_PROP_UNICODE_BIDI 92
-#define CSS_PROP_VERTICAL_ALIGN 93
-#define CSS_PROP_VISIBILITY 94
-#define CSS_PROP_WHITE_SPACE 95
-#define CSS_PROP_WIDOWS 96
-#define CSS_PROP_WIDTH 97
-#define CSS_PROP_WORD_SPACING 98
-#define CSS_PROP_Z_INDEX 99
-#define CSS_PROP_BACKGROUND 100
-#define CSS_PROP_BORDER 101
-#define CSS_PROP_BORDER_COLOR 102
-#define CSS_PROP_BORDER_STYLE 103
-#define CSS_PROP_BORDER_TOP 104
-#define CSS_PROP_BORDER_RIGHT 105
-#define CSS_PROP_BORDER_BOTTOM 106
-#define CSS_PROP_BORDER_LEFT 107
-#define CSS_PROP_BORDER_WIDTH 108
-#define CSS_PROP_FONT 109
-#define CSS_PROP_LIST_STYLE 110
-#define CSS_PROP_MARGIN 111
-#define CSS_PROP_OUTLINE 112
-#define CSS_PROP_PADDING 113
-#define CSS_PROP_SCROLLBAR_FACE_COLOR 114
-#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 115
-#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 116
-#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 117
-#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 118
-#define CSS_PROP_SCROLLBAR_TRACK_COLOR 119
-#define CSS_PROP_SCROLLBAR_ARROW_COLOR 120
-#define CSS_PROP__KHTML_FLOW_MODE 121
+#define CSS_PROP__KHTML_HORIZONTAL_BORDER_SPACING 10
+#define CSS_PROP__KHTML_VERTICAL_BORDER_SPACING 11
+#define CSS_PROP_BORDER_TOP_COLOR 12
+#define CSS_PROP_BORDER_RIGHT_COLOR 13
+#define CSS_PROP_BORDER_BOTTOM_COLOR 14
+#define CSS_PROP_BORDER_LEFT_COLOR 15
+#define CSS_PROP_BORDER_TOP_STYLE 16
+#define CSS_PROP_BORDER_RIGHT_STYLE 17
+#define CSS_PROP_BORDER_BOTTOM_STYLE 18
+#define CSS_PROP_BORDER_LEFT_STYLE 19
+#define CSS_PROP_BORDER_TOP_WIDTH 20
+#define CSS_PROP_BORDER_RIGHT_WIDTH 21
+#define CSS_PROP_BORDER_BOTTOM_WIDTH 22
+#define CSS_PROP_BORDER_LEFT_WIDTH 23
+#define CSS_PROP_BOTTOM 24
+#define CSS_PROP__KHTML_BOX_ALIGN 25
+#define CSS_PROP__KHTML_BOX_DIRECTION 26
+#define CSS_PROP__KHTML_BOX_FLEX 27
+#define CSS_PROP__KHTML_BOX_FLEX_GROUP 28
+#define CSS_PROP__KHTML_BOX_LINES 29
+#define CSS_PROP__KHTML_BOX_ORDINAL_GROUP 30
+#define CSS_PROP__KHTML_BOX_ORIENT 31
+#define CSS_PROP__KHTML_BOX_PACK 32
+#define CSS_PROP_CAPTION_SIDE 33
+#define CSS_PROP_CLEAR 34
+#define CSS_PROP_CLIP 35
+#define CSS_PROP_COLOR 36
+#define CSS_PROP_CONTENT 37
+#define CSS_PROP_COUNTER_INCREMENT 38
+#define CSS_PROP_COUNTER_RESET 39
+#define CSS_PROP_CURSOR 40
+#define CSS_PROP_DIRECTION 41
+#define CSS_PROP_DISPLAY 42
+#define CSS_PROP_EMPTY_CELLS 43
+#define CSS_PROP_FLOAT 44
+#define CSS_PROP_FONT_FAMILY 45
+#define CSS_PROP_FONT_SIZE 46
+#define CSS_PROP_FONT_SIZE_ADJUST 47
+#define CSS_PROP_FONT_STRETCH 48
+#define CSS_PROP_FONT_STYLE 49
+#define CSS_PROP_FONT_VARIANT 50
+#define CSS_PROP_FONT_WEIGHT 51
+#define CSS_PROP_HEIGHT 52
+#define CSS_PROP_LEFT 53
+#define CSS_PROP_LETTER_SPACING 54
+#define CSS_PROP_LINE_HEIGHT 55
+#define CSS_PROP_LIST_STYLE_IMAGE 56
+#define CSS_PROP_LIST_STYLE_POSITION 57
+#define CSS_PROP_LIST_STYLE_TYPE 58
+#define CSS_PROP_MARGIN_TOP 59
+#define CSS_PROP_MARGIN_RIGHT 60
+#define CSS_PROP_MARGIN_BOTTOM 61
+#define CSS_PROP_MARGIN_LEFT 62
+#define CSS_PROP_MARKER_OFFSET 63
+#define CSS_PROP_MAX_HEIGHT 64
+#define CSS_PROP_MAX_WIDTH 65
+#define CSS_PROP_MIN_HEIGHT 66
+#define CSS_PROP_MIN_WIDTH 67
+#define CSS_PROP__KHTML_OPACITY 68
+#define CSS_PROP_ORPHANS 69
+#define CSS_PROP_OUTLINE_COLOR 70
+#define CSS_PROP_OUTLINE_STYLE 71
+#define CSS_PROP_OUTLINE_WIDTH 72
+#define CSS_PROP_OVERFLOW 73
+#define CSS_PROP_PADDING_TOP 74
+#define CSS_PROP_PADDING_RIGHT 75
+#define CSS_PROP_PADDING_BOTTOM 76
+#define CSS_PROP_PADDING_LEFT 77
+#define CSS_PROP_PAGE 78
+#define CSS_PROP_PAGE_BREAK_AFTER 79
+#define CSS_PROP_PAGE_BREAK_BEFORE 80
+#define CSS_PROP_PAGE_BREAK_INSIDE 81
+#define CSS_PROP_POSITION 82
+#define CSS_PROP_QUOTES 83
+#define CSS_PROP_RIGHT 84
+#define CSS_PROP_SIZE 85
+#define CSS_PROP_TABLE_LAYOUT 86
+#define CSS_PROP_TEXT_ALIGN 87
+#define CSS_PROP_TEXT_DECORATION 88
+#define CSS_PROP_TEXT_DECORATION_COLOR 89
+#define CSS_PROP_TEXT_INDENT 90
+#define CSS_PROP_TEXT_SHADOW 91
+#define CSS_PROP_TEXT_TRANSFORM 92
+#define CSS_PROP_TOP 93
+#define CSS_PROP_UNICODE_BIDI 94
+#define CSS_PROP_VERTICAL_ALIGN 95
+#define CSS_PROP_VISIBILITY 96
+#define CSS_PROP_WHITE_SPACE 97
+#define CSS_PROP_WIDOWS 98
+#define CSS_PROP_WIDTH 99
+#define CSS_PROP_WORD_SPACING 100
+#define CSS_PROP_Z_INDEX 101
+#define CSS_PROP_BACKGROUND 102
+#define CSS_PROP_BORDER 103
+#define CSS_PROP_BORDER_COLOR 104
+#define CSS_PROP_BORDER_STYLE 105
+#define CSS_PROP_BORDER_TOP 106
+#define CSS_PROP_BORDER_RIGHT 107
+#define CSS_PROP_BORDER_BOTTOM 108
+#define CSS_PROP_BORDER_LEFT 109
+#define CSS_PROP_BORDER_WIDTH 110
+#define CSS_PROP_FONT 111
+#define CSS_PROP_LIST_STYLE 112
+#define CSS_PROP_MARGIN 113
+#define CSS_PROP_OUTLINE 114
+#define CSS_PROP_PADDING 115
+#define CSS_PROP_SCROLLBAR_FACE_COLOR 116
+#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 117
+#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 118
+#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 119
+#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 120
+#define CSS_PROP_SCROLLBAR_TRACK_COLOR 121
+#define CSS_PROP_SCROLLBAR_ARROW_COLOR 122
+#define CSS_PROP__KHTML_FLOW_MODE 123
 
 #define CSS_PROP_MAX CSS_PROP_Z_INDEX
-#define CSS_PROP_TOTAL 122
+#define CSS_PROP_TOTAL 124
 #endif
 
diff --git a/WebCore/khtml/css/cssproperties.in b/WebCore/khtml/css/cssproperties.in
index 0de3ee9..9e0725b 100644
--- a/WebCore/khtml/css/cssproperties.in
+++ b/WebCore/khtml/css/cssproperties.in
@@ -24,6 +24,8 @@ background-position-y
 
 border-collapse
 border-spacing
+-khtml-horizontal-border-spacing
+-khtml-vertical-border-spacing
 border-top-color
 border-right-color
 border-bottom-color
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 57d5c99..730a70d 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -1762,7 +1762,21 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
     }
 
     case CSS_PROP_EMPTY_CELLS:
+    {
+        if (value->cssValueType() == CSSValue::CSS_INHERIT)
+        {
+            if(!parentNode) return;
+            style->setEmptyCells(parentStyle->emptyCells());
+            break;
+        }
+        if (!primitiveValue) break;
+        int id = primitiveValue->getIdent();
+        if (id == CSS_VAL_SHOW)
+            style->setEmptyCells(SHOW);
+        else if (id == CSS_VAL_HIDE)
+            style->setEmptyCells(HIDE);
         break;
+    }
     case CSS_PROP_FLOAT:
     {
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
@@ -2143,15 +2157,24 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
       style->setBackgroundYPosition(l);
       break;
       }
-    case CSS_PROP_BORDER_SPACING:
-        {
-        if(!primitiveValue) break;
-        short spacing = 0;
-        spacing =  primitiveValue->computeLength(style, paintDeviceMetrics);
-        style->setBorderSpacing(spacing);
+    case CSS_PROP_BORDER_SPACING: {
+        if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
+        style->setHorizontalBorderSpacing(parentStyle->horizontalBorderSpacing());
+        style->setVerticalBorderSpacing(parentStyle->verticalBorderSpacing());
         break;
-        }
-        // CSS2BorderSpacing
+    }
+    case CSS_PROP__KHTML_HORIZONTAL_BORDER_SPACING: {
+        if (!primitiveValue) break;
+        short spacing =  primitiveValue->computeLength(style, paintDeviceMetrics);
+        style->setHorizontalBorderSpacing(spacing);
+        break;
+    }
+    case CSS_PROP__KHTML_VERTICAL_BORDER_SPACING: {
+        if (!primitiveValue) break;
+        short spacing =  primitiveValue->computeLength(style, paintDeviceMetrics);
+        style->setVerticalBorderSpacing(spacing);
+        break;
+    }
     case CSS_PROP_CURSOR:
         // CSS2Cursor
         if(value->cssValueType() == CSSValue::CSS_INHERIT) {
diff --git a/WebCore/khtml/css/cssvalues.c b/WebCore/khtml/css/cssvalues.c
index 237be3f..2957b25 100644
--- a/WebCore/khtml/css/cssvalues.c
+++ b/WebCore/khtml/css/cssvalues.c
@@ -620,14 +620,14 @@ static const char * const valueList[] = {
 "inherit", 
 "none", 
 "hidden", 
-"dotted", 
-"dashed", 
-"double", 
-"solid", 
-"outset", 
 "inset", 
 "groove", 
 "ridge", 
+"outset", 
+"dotted", 
+"dashed", 
+"solid", 
+"double", 
 "caption", 
 "icon", 
 "menu", 
diff --git a/WebCore/khtml/css/cssvalues.h b/WebCore/khtml/css/cssvalues.h
index 6afc366..804f1f4 100644
--- a/WebCore/khtml/css/cssvalues.h
+++ b/WebCore/khtml/css/cssvalues.h
@@ -12,14 +12,14 @@ DOM::DOMString getValueName(unsigned short id);
 #define CSS_VAL_INHERIT 1
 #define CSS_VAL_NONE 2
 #define CSS_VAL_HIDDEN 3
-#define CSS_VAL_DOTTED 4
-#define CSS_VAL_DASHED 5
-#define CSS_VAL_DOUBLE 6
-#define CSS_VAL_SOLID 7
-#define CSS_VAL_OUTSET 8
-#define CSS_VAL_INSET 9
-#define CSS_VAL_GROOVE 10
-#define CSS_VAL_RIDGE 11
+#define CSS_VAL_INSET 4
+#define CSS_VAL_GROOVE 5
+#define CSS_VAL_RIDGE 6
+#define CSS_VAL_OUTSET 7
+#define CSS_VAL_DOTTED 8
+#define CSS_VAL_DASHED 9
+#define CSS_VAL_SOLID 10
+#define CSS_VAL_DOUBLE 11
 #define CSS_VAL_CAPTION 12
 #define CSS_VAL_ICON 13
 #define CSS_VAL_MENU 14
diff --git a/WebCore/khtml/css/cssvalues.in b/WebCore/khtml/css/cssvalues.in
index ad506b7..4b60fbc 100644
--- a/WebCore/khtml/css/cssvalues.in
+++ b/WebCore/khtml/css/cssvalues.in
@@ -17,14 +17,14 @@ inherit
 # CSS_PROP_BORDER_LEFT_STYLE
 none
 hidden
-dotted
-dashed
-double
-solid
-outset
 inset
 groove
 ridge
+outset
+dotted
+dashed
+solid
+double
 #
 # CSS_PROP_FONT:
 #
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index 807bc62..65ac67f 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -1282,8 +1282,8 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren)
 #if BIDI_DEBUG > 1 || defined( DEBUG_LINEBREAKS )
     kdDebug(6041) << " ------- bidi start " << this << " -------" << endl;
 #endif
-    int toAdd = style()->borderBottomWidth();
-    m_height = style()->borderTopWidth();
+    int toAdd = borderBottom();
+    m_height = borderTop();
 
     m_height += paddingTop();
     toAdd += paddingBottom();
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index 478a0ea..dfff36a 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -291,7 +291,8 @@ void RenderBox::paintBoxDecorations(QPainter *p,int _x, int _y,
     // since the root could be inline and wrapped in an anonymous block.
     if (!isBody()
         || element()->getDocument()->documentElement()->renderer()->style()->backgroundColor().isValid()
-        || element()->getDocument()->documentElement()->renderer()->style()->backgroundImage())        	paintBackground(p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
+        || element()->getDocument()->documentElement()->renderer()->style()->backgroundImage())
+        paintBackground(p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
    
     if (style()->hasBorder())
         paintBorder(p, _tx, _ty, w, h, style());
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 540fb7f..fec69c9 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -680,15 +680,15 @@ void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w
 
     if(render_t) {
         drawBorder(p, _tx, _ty, _tx + lx, _ty +  style->borderTopWidth(), BSTop, tc, style->color(), ts,
-                   (render_l && ls<=DOUBLE?style->borderLeftWidth():0), 0);
+                   (render_l && (ls == DOTTED || ls == DASHED || ls == DOUBLE)?style->borderLeftWidth():0), 0);
         drawBorder(p, _tx+lx+lw, _ty, _tx + w, _ty +  style->borderTopWidth(), BSTop, tc, style->color(), ts,
-                   0, (render_r && rs<=DOUBLE?style->borderRightWidth():0));
+                   0, (render_r && (rs == DOTTED || rs == DASHED || rs == DOUBLE)?style->borderRightWidth():0));
     }
 
     if(render_b)
         drawBorder(p, _tx, _ty + h - style->borderBottomWidth(), _tx + w, _ty + h, BSBottom, bc, style->color(), bs,
-                   (render_l && ls<=DOUBLE?style->borderLeftWidth():0),
-                   (render_r && rs<=DOUBLE?style->borderRightWidth():0));
+                   (render_l && (ls == DOTTED || ls == DASHED || ls == DOUBLE)?style->borderLeftWidth():0),
+                   (render_r && (rs == DOTTED || rs == DASHED || rs == DOUBLE)?style->borderRightWidth():0));
 
     if(render_l)
     {
@@ -696,12 +696,12 @@ void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w
 
         bool ignore_top =
             (tc == lc) &&
-            (ls <= OUTSET) &&
+            (ls >= OUTSET) &&
             (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
 
         bool ignore_bottom =
             (bc == lc) &&
-            (ls <= OUTSET) &&
+            (ls >= OUTSET) &&
             (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
 
         drawBorder(p, _tx, _ty, _tx + style->borderLeftWidth(), _ty + h, BSLeft, lc, style->color(), ls,
@@ -715,12 +715,12 @@ void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w
 
         bool ignore_top =
             (tc == rc) &&
-            (rs <= SOLID || rs == INSET) &&
+            (rs >= DOTTED || rs == INSET) &&
             (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
 
         bool ignore_bottom =
             (bc == rc) &&
-            (rs <= SOLID || rs == INSET) &&
+            (rs >= DOTTED || rs == INSET) &&
             (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
 
         drawBorder(p, _tx + w - style->borderRightWidth(), _ty, _tx + w, _ty + h, BSRight, rc, style->color(), rs,
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index dc97737..2cbf297 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -811,12 +811,12 @@ void RenderObject::paintBorder(QPainter *p, int _tx, int _ty, int w, int h, cons
     if(render_t) {
         bool ignore_left =
             (tc == lc) && (tt == lt) &&
-            (ts <= OUTSET) &&
+            (ts >= OUTSET) &&
             (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET);
 
         bool ignore_right =
             (tc == rc) && (tt == rt) &&
-            (ts <= OUTSET) &&
+            (ts >= OUTSET) &&
             (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET);
         
         drawBorder(p, _tx, _ty, _tx + w, _ty +  style->borderTopWidth(), BSTop, tc, style->color(), ts,
@@ -827,12 +827,12 @@ void RenderObject::paintBorder(QPainter *p, int _tx, int _ty, int w, int h, cons
     if(render_b) {
         bool ignore_left =
         (bc == lc) && (bt == lt) &&
-        (bs <= OUTSET) &&
+        (bs >= OUTSET) &&
         (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET);
 
         bool ignore_right =
             (bc == rc) && (bt == rt) &&
-            (bs <= OUTSET) &&
+            (bs >= OUTSET) &&
             (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET);
         
         drawBorder(p, _tx, _ty + h - style->borderBottomWidth(), _tx + w, _ty + h, BSBottom, bc, style->color(), bs,
@@ -844,12 +844,12 @@ void RenderObject::paintBorder(QPainter *p, int _tx, int _ty, int w, int h, cons
     {
 	bool ignore_top =
 	  (tc == lc) && (tt == lt) &&
-	  (ls <= OUTSET) &&
+	  (ls >= OUTSET) &&
 	  (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
 
 	bool ignore_bottom =
 	  (bc == lc) && (bt == lt) &&
-	  (ls <= OUTSET) &&
+	  (ls >= OUTSET) &&
 	  (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
 
         drawBorder(p, _tx, _ty, _tx + style->borderLeftWidth(), _ty + h, BSLeft, lc, style->color(), ls,
@@ -861,12 +861,12 @@ void RenderObject::paintBorder(QPainter *p, int _tx, int _ty, int w, int h, cons
     {
 	bool ignore_top =
 	  (tc == rc) && (tt == rt) &&
-	  (rs <= SOLID || rs == INSET) &&
+	  (rs >= DOTTED || rs == INSET) &&
 	  (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
 
 	bool ignore_bottom =
 	  (bc == rc) && (bt == rt) &&
-	  (rs <= SOLID || rs == INSET) &&
+	  (rs >= DOTTED || rs == INSET) &&
 	  (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
 
         drawBorder(p, _tx + w - style->borderRightWidth(), _ty, _tx + w, _ty + h, BSRight, rc, style->color(), rs,
@@ -1791,6 +1791,12 @@ void RenderObject::updateWidgetPositions()
 }
 #endif
 
+void RenderObject::collectBorders(QPtrList<CollapsedBorderValue>& borderStyles)
+{
+    for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
+        curr->collectBorders(borderStyles);
+}
+    
 QChar RenderObject::backslashAsCurrencySymbol() const
 {
 #if !APPLE_CHANGES
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index bc8b8da..8d4f55c 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -71,7 +71,8 @@ typedef enum {
     PaintActionChildBackgrounds,
     PaintActionFloat,
     PaintActionForeground,
-    PaintActionSelection
+    PaintActionSelection,
+    PaintActionCollapsedTableBorders
 } PaintAction;
 
 typedef enum {
@@ -100,6 +101,7 @@ namespace khtml {
     class RenderLayer;
     class InlineBox;
     class InlineFlowBox;
+    class CollapsedBorderValue;
 
 /**
  * Base Class for all rendering tree objects.
@@ -578,6 +580,9 @@ public:
 
     virtual void setTable(RenderTable*) {};
 
+    // Used by collapsed border tables.
+    virtual void collectBorders(QPtrList<CollapsedBorderValue>& borderStyles);
+
     // Repaint the entire object.  Called when, e.g., the color of a border changes, or when a border
     // style changes.
     void repaint(bool immediate = false);
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 5e65f12..9f55d77 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -207,7 +207,8 @@ bool StyleCSS3InheritedData::shadowDataEquivalent(const StyleCSS3InheritedData&
 
 StyleInheritedData::StyleInheritedData()
     : indent( Fixed ), line_height( -100, Percent ), style_image( 0 ),
-      cursor_image( 0 ), font(), color( Qt::black ), border_spacing( 0 )
+      cursor_image( 0 ), font(), color( Qt::black ), 
+      horizontal_border_spacing( 0 ), vertical_border_spacing( 0 )
 {
 }
 
@@ -220,7 +221,8 @@ StyleInheritedData::StyleInheritedData(const StyleInheritedData& o )
       indent( o.indent ), line_height( o.line_height ), style_image( o.style_image ),
       cursor_image( o.cursor_image ), font( o.font ),
       color( o.color ),
-      border_spacing( o.border_spacing )
+      horizontal_border_spacing( o.horizontal_border_spacing ),
+      vertical_border_spacing( o.vertical_border_spacing )
 {
 }
 
@@ -229,11 +231,12 @@ bool StyleInheritedData::operator==(const StyleInheritedData& o) const
     return
 	indent == o.indent &&
 	line_height == o.line_height &&
-	border_spacing == o.border_spacing &&
 	style_image == o.style_image &&
 	cursor_image == o.cursor_image &&
 	font == o.font &&
-	color == o.color;
+	color == o.color &&
+        horizontal_border_spacing == o.horizontal_border_spacing &&
+        vertical_border_spacing == o.vertical_border_spacing;
 
     // doesn't work because structs are not packed
     //return memcmp(this, &o, sizeof(*this))==0;
@@ -428,7 +431,8 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
         !(inherited->style_image == other->inherited->style_image) ||
         !(inherited->cursor_image == other->inherited->cursor_image) ||
         !(inherited->font == other->inherited->font) ||
-        !(inherited->border_spacing == other->inherited->border_spacing) ||
+        !(inherited->horizontal_border_spacing == other->inherited->horizontal_border_spacing) ||
+        !(inherited->vertical_border_spacing == other->inherited->vertical_border_spacing) ||
         !(inherited_flags._box_direction == other->inherited_flags._box_direction) ||
         !(inherited_flags._visuallyOrdered == other->inherited_flags._visuallyOrdered) ||
         !(inherited_flags._htmlHacks == other->inherited_flags._htmlHacks) ||
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index e5e9ac0..41ebb6a 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -184,10 +184,10 @@ enum EFloat {
 //------------------------------------------------
 // Border attributes. Not inherited.
 
-
+// These have been defined in the order of their precedence for border-collapsing. Do
+// not change this order!
 enum EBorderStyle {
-    BNONE, BHIDDEN, DOTTED, DASHED, DOUBLE, SOLID,
-    OUTSET, INSET, GROOVE, RIDGE
+    BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE
 };
 
 
@@ -222,6 +222,30 @@ public:
 
 };
 
+enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };
+
+struct CollapsedBorderValue
+{
+    CollapsedBorderValue() :border(0), precedence(BOFF) {}
+    CollapsedBorderValue(const BorderValue* b, EBorderPrecedence p) :border(b), precedence(p) {}
+    
+    int width() const { return border ? border->width : 0; }
+    EBorderStyle style() const { return border ? border->style : BHIDDEN; }
+    bool exists() const { return border; }
+    QColor color() const { return border ? border->color : QColor(); }
+    bool isTransparent() const { return border ? border->transparent : true; }
+    
+    bool operator==(const CollapsedBorderValue& o) const
+    {
+        if (!border) return !o.border;
+        if (!o.border) return false;
+        return *border == *o.border && precedence == o.precedence;
+    }
+    
+    const BorderValue* border;
+    EBorderPrecedence precedence;    
+};
+
 class BorderData : public Shared<BorderData>
 {
 public:
@@ -515,7 +539,8 @@ public:
     khtml::Font font;
     QColor color;
     
-    short border_spacing;
+    short horizontal_border_spacing;
+    short vertical_border_spacing;
 };
 
 
@@ -799,6 +824,11 @@ public:
     Length  	minHeight() const { return box->min_height; }
     Length  	maxHeight() const { return box->max_height; }
 
+    const BorderValue& borderLeft() const { return surround->border.left; }
+    const BorderValue& borderRight() const { return surround->border.right; }
+    const BorderValue& borderTop() const { return surround->border.top; }
+    const BorderValue& borderBottom() const { return surround->border.bottom; }
+    
     unsigned short  borderLeftWidth() const
     { if( surround->border.left.style == BNONE) return 0; return surround->border.left.width; }
     EBorderStyle    borderLeftStyle() const { return surround->border.left.style; }
@@ -875,7 +905,8 @@ public:
 
     // returns true for collapsing borders, false for separate borders
     bool borderCollapse() const { return inherited_flags._border_collapse; }
-    short borderSpacing() const { return inherited->border_spacing; }
+    short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
+    short verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
     EEmptyCell emptyCells() const { return inherited_flags._empty_cells; }
     ECaptionSide captionSide() const { return inherited_flags._caption_side; }
 
@@ -1017,7 +1048,8 @@ public:
     void setBackgroundYPosition(Length v) {  SET_VAR(background,y_position,v) }
 
     void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; }
-    void setBorderSpacing(short v) { SET_VAR(inherited,border_spacing,v) }
+    void setHorizontalBorderSpacing(short v) { SET_VAR(inherited,horizontal_border_spacing,v) }
+    void setVerticalBorderSpacing(short v) { SET_VAR(inherited,vertical_border_spacing,v) }
     void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
     void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
 
diff --git a/WebCore/khtml/rendering/render_table.cpp b/WebCore/khtml/rendering/render_table.cpp
index 283d563..6b5d74d 100644
--- a/WebCore/khtml/rendering/render_table.cpp
+++ b/WebCore/khtml/rendering/render_table.cpp
@@ -55,11 +55,13 @@ RenderTable::RenderTable(DOM::NodeImpl* node)
     tCaption = 0;
     head = foot = firstBody = 0;
     tableLayout = 0;
-
+    m_currentBorder = 0;
+    
     rules = None;
     frame = Void;
     has_col_elems = false;
-    spacing = 0;
+    hspacing = 0;
+    vspacing = 0;
     padding = 0;
     needSectionRecalc = false;
     padding = 0;
@@ -89,8 +91,9 @@ void RenderTable::setStyle(RenderStyle *_style)
     setReplaced(style()->display()==INLINE_TABLE);
 
     // In the collapsed border model, there is no cell spacing.
-    spacing = collapseBorders() ? 0 : style()->borderSpacing();
-    columnPos[0] = spacing;
+    hspacing = collapseBorders() ? 0 : style()->horizontalBorderSpacing();
+    vspacing = collapseBorders() ? 0 : style()->verticalBorderSpacing();
+    columnPos[0] = hspacing;
 
     if ( !tableLayout || style()->tableLayout() != oldTableLayout ) {
 	delete tableLayout;
@@ -105,6 +108,10 @@ void RenderTable::setStyle(RenderStyle *_style)
 	} else
 	    tableLayout = new AutoTableLayout(this);
     }
+    
+    // The table never paints its border if it collapses.  It lets the cells do the painting.
+    if (collapseBorders())
+        setShouldPaintBackgroundOrBorder(false);
 }
 
 void RenderTable::addChild(RenderObject *child, RenderObject *beforeChild)
@@ -188,26 +195,36 @@ void RenderTable::calcWidth()
     int availableWidth = cb->contentWidth();
 
     LengthType widthType = style()->width().type;
-    if(widthType > Relative && style()->width().value > 0) {
+    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;
-	//kdDebug( 6040 ) << "1 width=" << m_width << " minWidth=" << m_minWidth << " availableWidth=" << availableWidth << " " << endl;
-    } else {
-        m_width = KMIN(short( availableWidth ),m_maxWidth);
     }
-
-    // restrict width to what we really have in case we flow around floats
-    if (style()->width().isVariable() && style()->flowAroundFloats()) {
-	availableWidth = cb->lineWidth( m_y );
-	m_width = QMIN( availableWidth, m_width );
+    else {
+        // An auto width table should shrink to fit within the line width if necessary in order to 
+        // avoid overlapping floats.
+        if (style()->flowAroundFloats())
+            availableWidth = cb->lineWidth( m_y );
+        
+        // Subtract out any fixed margins from our available width for auto width tables.
+        int marginTotal = 0;
+        if (style()->marginLeft().type != Variable)
+            marginTotal += style()->marginLeft().width(availableWidth);
+        if (style()->marginRight().type != Variable)
+            marginTotal += style()->marginRight().width(availableWidth);
+            
+        // Subtract out our margins to get the available content width.
+        int availContentWidth = KMAX(0, availableWidth - marginTotal);
+        
+        // Ensure we aren't bigger than our max width or smaller than our min width.
+        m_width = KMIN(short(availContentWidth),m_maxWidth);
     }
+    
+    m_width = KMAX(m_width, m_minWidth);
 
-    m_width = KMAX (m_width, m_minWidth);
-
-    m_marginRight=0;
-    m_marginLeft=0;
-
+    // Finally, with our true width determined, compute our margins for real.
+    m_marginRight = 0;
+    m_marginLeft = 0;
     calcHorizontalMargins(style()->marginLeft(),style()->marginRight(),availableWidth);
 }
 
@@ -417,9 +434,8 @@ void RenderTable::paint( QPainter *p, int _x, int _y,
 #endif
 
     if ((paintAction == PaintActionElementBackground || paintAction == PaintActionChildBackground)
-        && style()->visibility() == VISIBLE) {
+        && shouldPaintBackgroundOrBorder() && style()->visibility() == VISIBLE)
         paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
-    }
 
     // We're done.  We don't bother painting any children.
     if (paintAction == PaintActionElementBackground)
@@ -435,6 +451,24 @@ void RenderTable::paint( QPainter *p, int _x, int _y,
 	child = child->nextSibling();
     }
 
+    if (collapseBorders() && 
+        (paintAction == PaintActionElementBackground || paintAction == PaintActionChildBackground)
+        && style()->visibility() == VISIBLE) {
+        // Collect all the unique border styles that we want to paint in a sorted list.  Once we
+        // have all the styles sorted, we then do individual passes, painting each style of border
+        // from lowest precedence to highest precedence.
+        QPtrList<CollapsedBorderValue> borderStyles;
+        borderStyles.setAutoDelete(true);
+        collectBorders(borderStyles);
+        for (uint i = 0; i < borderStyles.count(); i++) {
+            m_currentBorder = borderStyles.at(i);
+            for (child = firstChild(); child; child = child->nextSibling()) {
+                if (child->isTableSection())
+                    child->paint(p, _x, _y, _w, _h, _tx, _ty, PaintActionCollapsedTableBorders);
+            }
+        }
+    }
+        
 #ifdef BOX_DEBUG
     outlineBox(p, _tx, _ty, "blue");
 #endif
@@ -641,30 +675,70 @@ RenderObject* RenderTable::removeChildNode(RenderObject* child)
     return RenderContainer::removeChildNode( child );
 }
 
-#if APPLE_CHANGES
-RenderTableCell* RenderTable::cellAbove(RenderTableCell* cell) const
+int RenderTable::borderLeft() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderLeft();
+}
+    
+int RenderTable::borderRight() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderRight();
+}
+
+int RenderTable::borderTop() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderTop();
+}
+
+int RenderTable::borderBottom() const
+{
+    if (collapseBorders()) {
+        // FIXME: For strict mode, returning 0 is correct, since the table border half spills into the margin,
+        // but I'm working to get this changed.  For now, follow the spec.
+        return 0;
+    }
+    return RenderBlock::borderBottom();
+}
+
+RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const
 {
     // Find the section and row to look in
     int r = cell->row();
-    RenderTableSection *section;
-    int rAbove = 0;
+    RenderTableSection* section = 0;
+    int rAbove = -1;
     if (r > 0) {
         // cell is not in the first row, so use the above row in its own section
         section = cell->section();
         rAbove = r-1;
     } else {
         // cell is at top of a section, use last row in previous section
-        RenderObject *prevSection = cell->section()->previousSibling();
-        while (prevSection && !prevSection->isTableSection()) {
-            prevSection = prevSection->previousSibling();
-        }
-        section = static_cast<RenderTableSection *>(prevSection);
-        if (section) {
-            rAbove = section->numRows()-1;
+        for (RenderObject *prevSection = cell->section()->previousSibling();
+             prevSection && rAbove < 0;
+             prevSection = prevSection->previousSibling()) {
+            if (prevSection->isTableSection()) {
+                section = static_cast<RenderTableSection *>(prevSection);
+                if (section->numRows() > 0)
+                    rAbove = section->numRows()-1;
+            }
         }
     }
 
-    // Look up the cell in the section's grid, which required effective col index
+    // Look up the cell in the section's grid, which requires effective col index
     if (section && rAbove >= 0) {
         int effCol = colToEffCol(cell->col());
         RenderTableCell* aboveCell;
@@ -678,7 +752,69 @@ RenderTableCell* RenderTable::cellAbove(RenderTableCell* cell) const
         return 0;
     }
 }
-#endif
+
+RenderTableCell* RenderTable::cellBelow(const RenderTableCell* cell) const
+{
+    // Find the section and row to look in
+    int r = cell->row() + cell->rowSpan() - 1;
+    RenderTableSection* section = 0;
+    int rBelow = -1;
+    if (r < cell->section()->numRows()-1) {
+        // The cell is not in the last row, so use the next row in the section.
+        section = cell->section();
+        rBelow= r+1;
+    } else {
+        // The cell is at the bottom of a section. Use the first row in the next section.
+        for (RenderObject* nextSection = cell->section()->nextSibling();
+             nextSection && rBelow < 0;
+             nextSection = nextSection->nextSibling()) 
+        {
+            if (nextSection->isTableSection()) {
+                section = static_cast<RenderTableSection *>(nextSection);
+                if (section->numRows() > 0)
+                    rBelow = 0;
+            }
+        }
+    }
+    
+    // Look up the cell in the section's grid, which requires effective col index
+    if (section && rBelow >= 0) {
+        int effCol = colToEffCol(cell->col());
+        RenderTableCell* belowCell;
+        // If we hit a colspan back up to a real cell.
+        do {
+            belowCell = section->cellAt(rBelow, effCol);
+            effCol--;
+        } while (belowCell == (RenderTableCell *)-1 && effCol >=0);
+        return (belowCell == (RenderTableCell *)-1) ? 0 : belowCell;
+    } else {
+        return 0;
+    }    
+}
+
+RenderTableCell* RenderTable::cellLeft(const RenderTableCell* cell) const
+{
+    RenderTableSection* section = cell->section();
+    int effCol = colToEffCol(cell->col());
+    if (effCol == 0)
+        return 0;
+    
+    // If we hit a colspan back up to a real cell.
+    RenderTableCell* prevCell;
+    do {
+        prevCell = section->cellAt(cell->row(), effCol-1);
+        effCol--;
+    } while (prevCell == (RenderTableCell *)-1 && effCol >=0);
+    return (prevCell == (RenderTableCell *)-1) ? 0 : prevCell;
+}
+
+RenderTableCell* RenderTable::cellRight(const RenderTableCell* cell) const
+{
+    int effCol = colToEffCol(cell->col());
+    if (effCol == numEffCols()-1)
+        return 0;
+    return cell->section()->cellAt(cell->row(), effCol+1);
+}
 
 #ifndef NDEBUG
 void RenderTable::dump(QTextStream *stream, QString ind) const
@@ -940,7 +1076,7 @@ void RenderTableSection::setCellWidths()
 		cspan -= table()->columns[endCol].span;
 		endCol++;
 	    }
-	    int w = columnPos[endCol] - columnPos[j] - table()->cellSpacing();
+	    int w = columnPos[endCol] - columnPos[j] - table()->hBorderSpacing();
 #ifdef DEBUG_LAYOUT
 	    kdDebug( 6040 ) << "setting width of cell " << cell << " " << cell->row() << "/" << cell->col() << " to " << w << " colspan=" << cell->colSpan() << " start=" << j << " end=" << endCol << endl;
 #endif
@@ -960,7 +1096,7 @@ void RenderTableSection::calcRowHeight()
     RenderTableCell *cell;
 
     int totalRows = grid.size();
-    int spacing = table()->cellSpacing();
+    int spacing = table()->vBorderSpacing();
 
     rowPos.resize( totalRows + 1 );
     rowPos[0] = spacing;
@@ -972,7 +1108,7 @@ void RenderTableSection::calcRowHeight()
 	int bdesc = 0;
 // 	qDebug("height of row %d is %d/%d", r, grid[r].height.value, grid[r].height.type );
 	int ch = grid[r].height.minWidth( 0 );
-	int pos = rowPos[ r+1 ] + ch + table()->cellSpacing();
+	int pos = rowPos[ r+1 ] + ch + spacing;
 
 	if ( pos > rowPos[r+1] )
 	    rowPos[r+1] = pos;
@@ -991,11 +1127,15 @@ void RenderTableSection::calcRowHeight()
 	    if ( ( indx = r - cell->rowSpan() + 1 ) < 0 )
 		indx = 0;
 
-	    ch = cell->style()->height().width(0);
+            // Explicit heights use the border box in quirks mode.  In strict mode do the right
+            // thing and actually add in the border and padding.
+	    ch = cell->style()->height().width(0) + 
+                (cell->style()->htmlHacks() ? 0 : (cell->paddingTop() + cell->paddingBottom() +
+                                                   cell->borderTop() + cell->borderBottom()));
 	    if (cell->height() > ch)
 		ch = cell->height();
 
-	    pos = rowPos[ indx ] + ch + table()->cellSpacing();
+            pos = rowPos[ indx ] + ch + spacing;
 
 	    if ( pos > rowPos[r+1] )
 		rowPos[r+1] = pos;
@@ -1019,7 +1159,7 @@ void RenderTableSection::calcRowHeight()
 	//do we have baseline aligned elements?
 	if (baseline) {
 	    // increase rowheight if baseline requires
-	    int bRowPos = baseline + bdesc  + table()->cellSpacing() ; // + 2*padding
+	    int bRowPos = baseline + bdesc  + spacing ; // + 2*padding
 	    if (rowPos[r+1]<bRowPos)
 		rowPos[r+1]=bRowPos;
 
@@ -1037,8 +1177,9 @@ int RenderTableSection::layoutRows( int toAdd )
     int rHeight;
     int rindx;
     int totalRows = grid.size();
-    int spacing = table()->cellSpacing();
-
+    int hspacing = table()->hBorderSpacing();
+    int vspacing = table()->vBorderSpacing();
+    
     if (toAdd && totalRows && (rowPos[totalRows] || !nextSibling())) {
 
 	int totalHeight = rowPos[totalRows] + toAdd;
@@ -1103,7 +1244,7 @@ int RenderTableSection::layoutRows( int toAdd )
         }
     }
 
-    int leftOffset = spacing;
+    int leftOffset = hspacing;
 
     int nEffCols = table()->numEffCols();
     for ( int r = 0; r < totalRows; r++ )
@@ -1121,7 +1262,7 @@ int RenderTableSection::layoutRows( int toAdd )
             if ( ( rindx = r-cell->rowSpan()+1 ) < 0 )
                 rindx = 0;
 
-            rHeight = rowPos[r+1] - rowPos[rindx] - spacing;
+            rHeight = rowPos[r+1] - rowPos[rindx] - vspacing;
             
             // Force percent height children to lay themselves out again.
             // This will cause, e.g., textareas to grow to
@@ -1568,6 +1709,313 @@ void RenderTableCell::setStyle( RenderStyle *style )
     }
 }
 
+// The following rules apply for resolving conflicts and figuring out which border
+// to use.
+// (1) Borders with the 'border-style' of 'hidden' take precedence over all other conflicting 
+// borders. Any border with this value suppresses all borders at this location.
+// (2) Borders with a style of 'none' have the lowest priority. Only if the border properties of all 
+// the elements meeting at this edge are 'none' will the border be omitted (but note that 'none' is 
+// the default value for the border style.)
+// (3) If none of the styles are 'hidden' and at least one of them is not 'none', then narrow borders 
+// are discarded in favor of wider ones. If several have the same 'border-width' then styles are preferred 
+// in this order: 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', and the lowest: 'inset'.
+// (4) If border styles differ only in color, then a style set on a cell wins over one on a row, 
+// which wins over a row group, column, column group and, lastly, table. It is undefined which color 
+// is used when two elements of the same type disagree.
+static const CollapsedBorderValue compareBorders(const CollapsedBorderValue& border1, 
+                                                 const CollapsedBorderValue& border2)
+{
+    // Sanity check the values passed in.  If either is null, return the other.
+    if (!border2.exists()) return border1;
+    if (!border1.exists()) return border2;
+    
+    // Rule #1 above.
+    if (border1.style() == BHIDDEN || border2.style() == BHIDDEN)
+        return CollapsedBorderValue(); // No border should exist at this location.
+    
+    // Rule #2 above.  A style of 'none' has lowest priority and always loses to any other border.
+    if (border2.style() == BNONE) return border1;
+    if (border1.style() == BNONE) return border2;
+    
+    // The first part of rule #3 above. Wider borders win.
+    if (border1.width() != border2.width())
+        return border1.width() > border2.width() ? border1 : border2;
+    
+    // The borders have equal width.  Sort by border style.
+    if (border1.style() != border2.style())
+        return border1.style() > border2.style() ? border1 : border2;
+    
+    // The border have the same width and style.  Rely on precedence (cell over row over row group, etc.)
+    return border1.precedence >= border2.precedence ? border1 : border2;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedLeftBorder() const
+{
+    // For border left, we need to check, in order of precedence:
+    // (1) Our left border.
+    CollapsedBorderValue result(&style()->borderLeft(), BCELL);
+    
+    // (2) The previous cell's right border.
+    RenderTableCell* prevCell = table()->cellLeft(this);
+    if (prevCell) {
+        result = compareBorders(result, CollapsedBorderValue(&prevCell->style()->borderRight(), BCELL));
+        if (!result.exists()) return result;
+    }
+    else if (col() == 0) {
+        // (3) Our row's left border.
+        result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderLeft(), BROW));
+        if (!result.exists()) return result;
+        
+        // (4) Our row group's left border.
+        result = compareBorders(result, CollapsedBorderValue(&section()->style()->borderLeft(), BROWGROUP));
+        if (!result.exists()) return result;
+    }
+    
+    // (5) Our column's left border.
+    RenderTableCol* colElt = table()->colElement(col());
+    if (colElt) {
+        result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderLeft(), BCOL));
+        if (!result.exists()) return result;
+    }
+    
+    // (6) The previous column's right border.
+    if (col() > 0) {
+        colElt = table()->colElement(col()-1);
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderRight(), BCOL));
+            if (!result.exists()) return result;
+        }
+    }
+    
+    if (col() == 0) {
+        // (7) The table's left border.
+        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderLeft(), BTABLE));
+        if (!result.exists()) return result;
+    }
+    
+    return result;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedRightBorder() const
+{
+    RenderTable* tableElt = table();
+    bool inLastColumn = false;
+    int effCol = tableElt->colToEffCol(col());
+    if (effCol == tableElt->numEffCols()-1)
+        inLastColumn = true;
+    
+    // For border right, we need to check, in order of precedence:
+    // (1) Our right border.
+    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderRight(), BCELL);
+    
+    // (2) The next cell's left border.
+    if (!inLastColumn) {
+        RenderTableCell* nextCell = tableElt->cellRight(this);
+        if (nextCell) {
+            result = compareBorders(result, CollapsedBorderValue(&nextCell->style()->borderLeft(), BCELL));
+            if (!result.exists()) return result;
+        }
+    }
+    else {
+        // (3) Our row's right border.
+        result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderRight(), BROW));
+        if (!result.exists()) return result;
+        
+        // (4) Our row group's right border.
+        result = compareBorders(result, CollapsedBorderValue(&section()->style()->borderRight(), BROWGROUP));
+        if (!result.exists()) return result;
+    }
+    
+    // (5) Our column's right border.
+    RenderTableCol* colElt = table()->colElement(col());
+    if (colElt) {
+        result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderRight(), BCOL));
+        if (!result.exists()) return result;
+    }
+    
+    // (6) The next column's left border.
+    if (!inLastColumn) {
+        colElt = tableElt->colElement(col()+1);
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderLeft(), BCOL));
+            if (!result.exists()) return result;
+        }
+    }
+    else {
+        // (7) The table's right border.
+        result = compareBorders(result, CollapsedBorderValue(&tableElt->style()->borderRight(), BTABLE));
+        if (!result.exists()) return result;
+    }
+    
+    return result;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedTopBorder() const
+{
+    // For border top, we need to check, in order of precedence:
+    // (1) Our top border.
+    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderTop(), BCELL);
+    
+    RenderTableCell* prevCell = table()->cellAbove(this);
+    if (prevCell) {
+        // (2) A previous cell's bottom border.
+        result = compareBorders(result, CollapsedBorderValue(&prevCell->style()->borderBottom(), BCELL));
+        if (!result.exists()) return result;
+    }
+    
+    // (3) Our row's top border.
+    result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderTop(), BROW));
+    if (!result.exists()) return result;
+    
+    // (4) The previous row's bottom border.
+    if (prevCell) {
+        RenderObject* prevRow = 0;
+        if (prevCell->section() == section())
+            prevRow = parent()->previousSibling();
+        else
+            prevRow = prevCell->section()->lastChild();
+    
+        if (prevRow) {
+            result = compareBorders(result, CollapsedBorderValue(&prevRow->style()->borderBottom(), BROW));
+            if (!result.exists()) return result;
+        }
+    }
+    
+    // Now check row groups.
+    RenderObject* currSection = parent()->parent();
+    if (row() == 0) {
+        // (5) Our row group's top border.
+        result = compareBorders(result, CollapsedBorderValue(&currSection->style()->borderTop(), BROWGROUP));
+        if (!result.exists()) return result;
+        
+        // (6) Previous row group's bottom border.
+        for (currSection = currSection->previousSibling(); currSection;
+             currSection = currSection->previousSibling()) {
+            if (currSection->isTableSection()) {
+                RenderTableSection* section = static_cast<RenderTableSection*>(currSection);
+                result = compareBorders(result, CollapsedBorderValue(&section->style()->borderBottom(), BROWGROUP));
+                if (!result.exists()) return result;
+            }
+        }
+    }
+    
+    if (!currSection) {
+        // (8) Our column's top border.
+        RenderTableCol* colElt = table()->colElement(col());
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderTop(), BCOL));
+            if (!result.exists()) return result;
+        }
+        
+        // (9) The table's top border.
+        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderTop(), BTABLE));
+        if (!result.exists()) return result;
+    }
+    
+    return result;
+}
+
+CollapsedBorderValue RenderTableCell::collapsedBottomBorder() const
+{
+    // For border top, we need to check, in order of precedence:
+    // (1) Our bottom border.
+    CollapsedBorderValue result = CollapsedBorderValue(&style()->borderBottom(), BCELL);
+    
+    RenderTableCell* nextCell = table()->cellBelow(this);
+    if (nextCell) {
+        // (2) A following cell's top border.
+        result = compareBorders(result, CollapsedBorderValue(&nextCell->style()->borderTop(), BCELL));
+        if (!result.exists()) return result;
+    }
+    
+    // (3) Our row's bottom border. (FIXME: Deal with rowspan!)
+    result = compareBorders(result, CollapsedBorderValue(&parent()->style()->borderBottom(), BROW));
+    if (!result.exists()) return result;
+    
+    // (4) The next row's top border.
+    if (nextCell) {
+        result = compareBorders(result, CollapsedBorderValue(&nextCell->parent()->style()->borderTop(), BROW));
+        if (!result.exists()) return result;
+    }
+    
+    // Now check row groups.
+    RenderObject* currSection = parent()->parent();
+    if (row()+rowSpan() >= static_cast<RenderTableSection*>(currSection)->numRows()) {
+        // (5) Our row group's bottom border.
+        result = compareBorders(result, CollapsedBorderValue(&currSection->style()->borderBottom(), BROWGROUP));
+        if (!result.exists()) return result;
+        
+        // (6) Following row group's top border.
+        for (currSection = currSection->nextSibling(); currSection;
+             currSection = currSection->nextSibling()) {
+            if (currSection->isTableSection()) {
+                RenderTableSection* section = static_cast<RenderTableSection*>(currSection);
+                result = compareBorders(result, CollapsedBorderValue(&section->style()->borderTop(), BROWGROUP));
+                if (!result.exists()) return result;
+            }
+        }
+    }
+    
+    if (!currSection) {
+        // (8) Our column's bottom border.
+        RenderTableCol* colElt = table()->colElement(col());
+        if (colElt) {
+            result = compareBorders(result, CollapsedBorderValue(&colElt->style()->borderBottom(), BCOL));
+            if (!result.exists()) return result;
+        }
+        
+        // (9) The table's bottom border.
+        result = compareBorders(result, CollapsedBorderValue(&table()->style()->borderBottom(), BTABLE));
+        if (!result.exists()) return result;
+    }
+    
+    return result;    
+}
+
+int RenderTableCell::borderLeft() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedLeftBorder();
+        if (border.exists())
+            return int(border.width()/2.0+0.5); // Give the extra pixel to top and left.
+        return 0;
+    }
+    return RenderBlock::borderLeft();
+}
+    
+int RenderTableCell::borderRight() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedRightBorder();
+        if (border.exists())
+            return border.width()/2;
+        return 0;
+    }
+    return RenderBlock::borderRight();
+}
+
+int RenderTableCell::borderTop() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedTopBorder();
+        if (border.exists())
+            return int(border.width()/2.0+0.5); // Give the extra pixel to top and left.
+        return 0;
+    }
+    return RenderBlock::borderTop();
+}
+
+int RenderTableCell::borderBottom() const
+{
+    if (table()->collapseBorders()) {
+        CollapsedBorderValue border = collapsedBottomBorder();
+        if (border.exists())
+            return border.width()/2;
+        return 0;
+    }
+    return RenderBlock::borderBottom();
+}
+
 #ifdef BOX_DEBUG
 #include <qpainter.h>
 
@@ -1603,10 +2051,168 @@ void RenderTableCell::paint(QPainter *p, int _x, int _y,
 #endif
 }
 
+static EBorderStyle collapsedBorderStyle(EBorderStyle style)
+{
+    if (style == OUTSET)
+        style = GROOVE;
+    else if (style == INSET)
+        style = RIDGE;
+    return style;
+}
+
+struct CollapsedBorder {
+    CollapsedBorder(){}
+    
+    CollapsedBorderValue border;
+    RenderObject::BorderSide side;
+    bool shouldPaint;
+    int x1;
+    int y1;
+    int x2;
+    int y2;
+    EBorderStyle style;
+};
+
+class CollapsedBorders
+{
+public:
+    CollapsedBorders(int i) :count(0) {}
+    
+    void addBorder(const CollapsedBorderValue& b, RenderObject::BorderSide s, bool paint, 
+                   int _x1, int _y1, int _x2, int _y2,
+                   EBorderStyle _style)
+    {
+        if (b.exists() && paint) {
+            borders[count].border = b;
+            borders[count].side = s;
+            borders[count].shouldPaint = paint;
+            borders[count].x1 = _x1;
+            borders[count].x2 = _x2;
+            borders[count].y1 = _y1;
+            borders[count].y2 = _y2;
+            borders[count].style = _style;
+            count++;
+        }
+    }
+
+    CollapsedBorder* nextBorder() {
+        for (int i = 0; i < count; i++) {
+            if (borders[i].border.exists() && borders[i].shouldPaint) {
+                borders[i].shouldPaint = false;
+                return &borders[i];
+            }
+        }
+        
+        return 0;
+    }
+    
+    CollapsedBorder borders[4];
+    int count;
+};
+
+static void addBorderStyle(QPtrList<CollapsedBorderValue>& borderStyles, CollapsedBorderValue borderValue)
+{
+    if (!borderValue.exists())
+        return;
+    
+    uint count = borderStyles.count();
+    if (count == 0)
+        borderStyles.append(new CollapsedBorderValue(borderValue));
+    else {
+        for (uint i = 0; i < count; i++) {
+            CollapsedBorderValue* b = borderStyles.at(i);
+            if (*b == borderValue)
+                return;
+            CollapsedBorderValue result = compareBorders(*b, borderValue);
+            if (result == *b) {
+                borderStyles.insert(i, new CollapsedBorderValue(borderValue));
+                return;
+            }
+        }
+        
+        borderStyles.append(new CollapsedBorderValue(borderValue));
+    }
+}
+
+void RenderTableCell::collectBorders(QPtrList<CollapsedBorderValue>& borderStyles)
+{
+    addBorderStyle(borderStyles, collapsedLeftBorder());
+    addBorderStyle(borderStyles, collapsedRightBorder());
+    addBorderStyle(borderStyles, collapsedTopBorder());
+    addBorderStyle(borderStyles, collapsedBottomBorder());
+}
+
+void RenderTableCell::paintCollapsedBorder(QPainter* p, int _tx, int _ty, int w, int h)
+{
+    if (!table()->currentBorderStyle())
+        return;
+    
+    CollapsedBorderValue leftVal = collapsedLeftBorder();
+    CollapsedBorderValue rightVal = collapsedRightBorder();
+    CollapsedBorderValue topVal = collapsedTopBorder();
+    CollapsedBorderValue bottomVal = collapsedBottomBorder();
+     
+    // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location.
+    int topWidth = topVal.width();
+    int bottomWidth = bottomVal.width();
+    int leftWidth = leftVal.width();
+    int rightWidth = rightVal.width();
+    
+    _tx -= leftWidth/2;
+    _ty -= topWidth/2;
+    w += leftWidth/2 + int(rightWidth/2.0+0.5);
+    h += topWidth/2 + int(bottomWidth/2.0+0.5);
+    
+    bool tt = topVal.isTransparent();
+    bool bt = bottomVal.isTransparent();
+    bool rt = rightVal.isTransparent();
+    bool lt = leftVal.isTransparent();
+    
+    EBorderStyle ts = collapsedBorderStyle(topVal.style());
+    EBorderStyle bs = collapsedBorderStyle(bottomVal.style());
+    EBorderStyle ls = collapsedBorderStyle(leftVal.style());
+    EBorderStyle rs = collapsedBorderStyle(rightVal.style());
+    
+    bool render_t = ts > BHIDDEN && !tt;
+    bool render_l = ls > BHIDDEN && !lt;
+    bool render_r = rs > BHIDDEN && !rt;
+    bool render_b = bs > BHIDDEN && !bt;
+
+    // We never paint diagonals at the joins.  We simply let the border with the highest
+    // precedence paint on top of borders with lower precedence.  
+    CollapsedBorders borders(4);
+    borders.addBorder(topVal, BSTop, render_t, _tx, _ty, _tx + w, _ty + topWidth, ts);
+    borders.addBorder(bottomVal, BSBottom, render_b, _tx, _ty + h - bottomWidth, _tx + w, _ty + h, bs);
+    borders.addBorder(leftVal, BSLeft, render_l, _tx, _ty, _tx + leftWidth, _ty + h, ls);
+    borders.addBorder(rightVal, BSRight, render_r, _tx + w - rightWidth, _ty, _tx + w, _ty + h, rs);
+    
+    for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
+        if (border->border == *table()->currentBorderStyle())
+            drawBorder(p, border->x1, border->y1, border->x2, border->y2, border->side, 
+                       border->border.color(), style()->color(), border->style, 0, 0);
+    }
+}
+
+void RenderTableCell::paintObject(QPainter* p, int _x, int _y, int _w, int _h,
+                                  int _tx, int _ty, PaintAction paintAction)
+{
+    if (paintAction == PaintActionCollapsedTableBorders && style()->visibility() == VISIBLE) {
+        int w = width();
+        int h = height() + borderTopExtra() + borderBottomExtra();
+        _ty -= borderTopExtra();
+        paintCollapsedBorder(p, _tx, _ty, w, h);
+    }
+    else
+        RenderBlock::paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+}
 
 void RenderTableCell::paintBoxDecorations(QPainter *p,int, int _y,
-                                       int, int _h, int _tx, int _ty)
+                                          int, int _h, int _tx, int _ty)
 {
+    RenderTable* tableElt = table();
+    if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
+        return;
+    
     int w = width();
     int h = height() + borderTopExtra() + borderBottomExtra();
     _ty -= borderTopExtra();
@@ -1657,7 +2263,7 @@ void RenderTableCell::paintBoxDecorations(QPainter *p,int, int _y,
     if ( bg || c.isValid() )
 	paintBackground(p, c, bg, my, mh, _tx, _ty, w, h);
 
-    if(style()->hasBorder())
+    if (style()->hasBorder() && !tableElt->collapseBorders())
         paintBorder(p, _tx, _ty, w, h, style());
 }
 
diff --git a/WebCore/khtml/rendering/render_table.h b/WebCore/khtml/rendering/render_table.h
index c51a3c8..19203cc 100644
--- a/WebCore/khtml/rendering/render_table.h
+++ b/WebCore/khtml/rendering/render_table.h
@@ -84,10 +84,15 @@ public:
     int getColumnPos(int col) const
         { return columnPos[col]; }
 
-    int cellSpacing() const { return spacing; }
+    int hBorderSpacing() const { return hspacing; }
+    int vBorderSpacing() const { return vspacing; }
     
     bool collapseBorders() const { return style()->borderCollapse(); }
-        
+    int borderLeft() const;
+    int borderRight() const;
+    int borderTop() const;
+    int borderBottom() const;
+    
     Rules getRules() const { return rules; }
 
     const QColor &bgColor() const { return style()->backgroundColor(); }
@@ -152,7 +157,7 @@ public:
 
     int bordersPaddingAndSpacing() const {
 	return borderLeft() + borderRight() + 
-               (collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols()+1) * cellSpacing()));
+               (collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols()+1) * hBorderSpacing()));
     }
 
     RenderTableCol *colElement( int col );
@@ -160,10 +165,14 @@ public:
     void setNeedSectionRecalc() { needSectionRecalc = true; }
 
     virtual RenderObject* removeChildNode(RenderObject* child);
-#if APPLE_CHANGES
-    virtual RenderTableCell* cellAbove(RenderTableCell* cell) const;
-#endif
 
+    RenderTableCell* cellAbove(const RenderTableCell* cell) const;
+    RenderTableCell* cellBelow(const RenderTableCell* cell) const;
+    RenderTableCell* cellLeft(const RenderTableCell* cell) const;
+    RenderTableCell* cellRight(const RenderTableCell* cell) const;
+ 
+    CollapsedBorderValue* currentBorderStyle() { return m_currentBorder; }
+    
 protected:
 
     void recalcSections();
@@ -178,13 +187,17 @@ protected:
 
     TableLayout *tableLayout;
 
+    CollapsedBorderValue* m_currentBorder;
+    
     Frame frame                 : 4;
     Rules rules                 : 4;
 
     bool has_col_elems		: 1;
-    uint spacing                : 11;
-    uint padding		: 11;
+    uint padding		: 22;
     uint needSectionRecalc	: 1;
+    
+    short hspacing;
+    short vspacing;
 };
 
 // -------------------------------------------------------------------------
@@ -326,6 +339,17 @@ public:
     virtual void setWidth( int width );
     virtual void setStyle( RenderStyle *style );
 
+    int borderLeft() const;
+    int borderRight() const;
+    int borderTop() const;
+    int borderBottom() const;
+
+    CollapsedBorderValue collapsedLeftBorder() const;
+    CollapsedBorderValue collapsedRightBorder() const;
+    CollapsedBorderValue collapsedTopBorder() const;
+    CollapsedBorderValue collapsedBottomBorder() const;
+    virtual void collectBorders(QPtrList<CollapsedBorderValue>& borderStyles);
+
     virtual void updateFromElement();
 
     virtual void layout();
@@ -339,6 +363,8 @@ public:
     virtual void paint( QPainter* p, int x, int y,
                         int w, int h, int tx, int ty, PaintAction paintAction);
 
+    void paintCollapsedBorder(QPainter* p, int x, int y, int w, int h);
+    
     virtual void close();
 
     // lie position to outside observers
@@ -359,6 +385,9 @@ public:
     virtual void dump(QTextStream *stream, QString ind = "") const;
 #endif
 
+    virtual void paintObject(QPainter *, int x, int y, int w, int h,
+                             int tx, int ty, PaintAction paintAction);
+    
 protected:
     virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
                                      int _w, int _h, int _tx, int _ty);
diff --git a/WebCore/khtml/rendering/table_layout.cpp b/WebCore/khtml/rendering/table_layout.cpp
index 91cc48d..55a0fe3 100644
--- a/WebCore/khtml/rendering/table_layout.cpp
+++ b/WebCore/khtml/rendering/table_layout.cpp
@@ -345,13 +345,13 @@ void FixedTableLayout::layout()
     }
     
     int pos = 0;
-    int spacing = table->cellSpacing();
+    int hspacing = table->hBorderSpacing();
     for ( int i = 0; i < nEffCols; i++ ) {
 #ifdef DEBUG_LAYOUT
 	qDebug("col %d: %d (width %d)", i, pos, calcWidth[i] );
 #endif
 	table->columnPos[i] = pos;
-	pos += calcWidth[i] + spacing;
+	pos += calcWidth[i] + hspacing;
     }
     table->columnPos[table->columnPos.size()-1] = pos;
 }
@@ -631,7 +631,7 @@ int AutoTableLayout::calcEffectiveWidth()
     int tMaxWidth = 0;
 
     unsigned int nEffCols = layoutStruct.size();
-    int spacing = table->cellSpacing();
+    int hspacing = table->hBorderSpacing();
 #ifdef DEBUG_LAYOUT
     qDebug("AutoTableLayout::calcEffectiveWidth for %d cols", nEffCols );
 #endif
@@ -653,8 +653,8 @@ int AutoTableLayout::calcEffectiveWidth()
 
 	int col = table->colToEffCol( cell->col() );
 	unsigned int lastCol = col;
-	int cMinWidth = cell->minWidth() + spacing;
-	int cMaxWidth = cell->maxWidth() + spacing;
+	int cMinWidth = cell->minWidth() + hspacing;
+	int cMaxWidth = cell->maxWidth() + hspacing;
 	int totalPercent = 0;
 	int minWidth = 0;
 	int maxWidth = 0;
@@ -703,8 +703,8 @@ int AutoTableLayout::calcEffectiveWidth()
 	    minWidth += layoutStruct[lastCol].effMinWidth;
 	    maxWidth += layoutStruct[lastCol].effMaxWidth;
 	    lastCol++;
-	    cMinWidth -= spacing;
-	    cMaxWidth -= spacing;
+	    cMinWidth -= hspacing;
+	    cMaxWidth -= hspacing;
 	}
 #ifdef DEBUG_LAYOUT
 	qDebug("    colspan cell %p at effCol %d, span %d, type %d, value %d cmin=%d min=%d fixedwidth=%d", cell, col, cSpan, w.type, w.value, cMinWidth, minWidth, fixedWidth );
@@ -770,6 +770,8 @@ int AutoTableLayout::calcEffectiveWidth()
 #endif
 		int maxw = maxWidth;
                 int minw = minWidth;
+                
+                // Give min to variable first, to fixed second, and to others third.
                 for ( unsigned int pos = col; maxw > 0 && pos < lastCol; pos++ ) {
 		    if ( layoutStruct[pos].width.type == Fixed && haveVariable && fixedWidth <= cMinWidth ) {
 			int w = QMAX( layoutStruct[pos].effMinWidth, layoutStruct[pos].width.value );
@@ -1158,7 +1160,7 @@ void AutoTableLayout::layout()
 	qDebug("col %d: %d (width %d)", i, pos, layoutStruct[i].calcWidth );
 #endif
 	table->columnPos[i] = pos;
-	pos += layoutStruct[i].calcWidth + table->cellSpacing();
+	pos += layoutStruct[i].calcWidth + table->hBorderSpacing();
     }
     table->columnPos[table->columnPos.size()-1] = pos;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list