Bug 725977 - Update table cellpadding / cellspacing to spec; r=bz
authorMs2ger <ms2ger@gmail.com>
Tue, 21 Feb 2012 10:34:01 +0100
changeset 88722 93e2945d9f7381e121aa3d7d7102e92eb35fcdd3
parent 88721 be559203ece8240bce40448a1d101bc1e353ab2d
child 88723 254285dbf95469aeb902d422d12e2def71d77eee
push id975
push userffxbld
push dateTue, 13 Mar 2012 21:39:16 +0000
treeherdermozilla-aurora@99faebf9dc36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs725977
milestone13.0a1
Bug 725977 - Update table cellpadding / cellspacing to spec; r=bz
content/html/content/src/nsHTMLTableElement.cpp
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -896,17 +896,17 @@ nsHTMLTableElement::ParseAttribute(PRInt
                                    nsIAtom* aAttribute,
                                    const nsAString& aValue,
                                    nsAttrValue& aResult)
 {
   /* ignore summary, just a string */
   if (aNamespaceID == kNameSpaceID_None) {
     if (aAttribute == nsGkAtoms::cellspacing ||
         aAttribute == nsGkAtoms::cellpadding) {
-      return aResult.ParseSpecialIntValue(aValue);
+      return aResult.ParseNonNegativeIntValue(aValue);
     }
     if (aAttribute == nsGkAtoms::cols ||
         aAttribute == nsGkAtoms::border) {
       return aResult.ParseIntWithBounds(aValue, 0);
     }
     if (aAttribute == nsGkAtoms::height) {
       return aResult.ParseSpecialIntValue(aValue);
     }
@@ -966,29 +966,20 @@ MapAttributesIntoRule(const nsMappedAttr
 
   nsPresContext* presContext = aData->mPresContext;
   nsCompatibility mode = presContext->CompatibilityMode();
 
   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) {
     // cellspacing
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing);
     nsCSSValue* borderSpacing = aData->ValueForBorderSpacing();
-    if (value && value->Type() == nsAttrValue::eInteger) {
-      if (borderSpacing->GetUnit() == eCSSUnit_Null) {
-        borderSpacing->
-          SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
-      }
-    }
-    else if (value && value->Type() == nsAttrValue::ePercent &&
-             eCompatibility_NavQuirks == mode) {
-      // in quirks mode, treat a % cellspacing value a pixel value.
-      if (borderSpacing->GetUnit() == eCSSUnit_Null) {
-        borderSpacing->
-         SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
-      }
+    if (value && value->Type() == nsAttrValue::eInteger &&
+        borderSpacing->GetUnit() == eCSSUnit_Null) {
+      borderSpacing->
+        SetFloatValue(float(value->GetIntegerValue()), eCSSUnit_Pixel);
     }
   }
   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) {
     const nsAttrValue* value;
     // layout
     nsCSSValue* tableLayout = aData->ValueForTableLayout();
     if (tableLayout->GetUnit() == eCSSUnit_Null) {
       value = aAttributes->GetAttr(nsGkAtoms::layout);
@@ -1154,49 +1145,39 @@ nsHTMLTableElement::GetAttributeMappingF
 }
 
 static void
 MapInheritedTableAttributesIntoRule(const nsMappedAttributes* aAttributes,
                                     nsRuleData* aData)
 {
   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Padding)) {
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellpadding);
-    if (value) {
-      nsAttrValue::ValueType valueType = value->Type();
-      if (valueType == nsAttrValue::eInteger ||
-          valueType == nsAttrValue::ePercent) {
-        // We have cellpadding.  This will override our padding values if we
-        // don't have any set.
-        nsCSSValue padVal;
-        if (valueType == nsAttrValue::eInteger)
-          padVal.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
-        else {
-          // when we support % cellpadding in standard mode, uncomment the
-          // following
-          float pctVal = value->GetPercentValue();
-          //if (eCompatibility_NavQuirks == mode) {
-          // in quirks mode treat a pct cellpadding value as a pixel value
-          padVal.SetFloatValue(100.0f * pctVal, eCSSUnit_Pixel);
-          //}
-          //else {
-          //  padVal.SetPercentValue(pctVal);
-          //}
-        }
-        nsCSSValue* paddingLeft = aData->ValueForPaddingLeftValue();
-        if (paddingLeft->GetUnit() == eCSSUnit_Null)
-          *paddingLeft = padVal;
-        nsCSSValue* paddingRight = aData->ValueForPaddingRightValue();
-        if (paddingRight->GetUnit() == eCSSUnit_Null)
-          *paddingRight = padVal;
-        nsCSSValue* paddingTop = aData->ValueForPaddingTop();
-        if (paddingTop->GetUnit() == eCSSUnit_Null)
-          *paddingTop = padVal;
-        nsCSSValue* paddingBottom = aData->ValueForPaddingBottom();
-        if (paddingBottom->GetUnit() == eCSSUnit_Null)
-          *paddingBottom = padVal;
+    if (value && value->Type() == nsAttrValue::eInteger) {
+      // We have cellpadding.  This will override our padding values if we
+      // don't have any set.
+      nsCSSValue padVal(float(value->GetIntegerValue()), eCSSUnit_Pixel);
+
+      nsCSSValue* paddingLeft = aData->ValueForPaddingLeftValue();
+      if (paddingLeft->GetUnit() == eCSSUnit_Null) {
+        *paddingLeft = padVal;
+      }
+
+      nsCSSValue* paddingRight = aData->ValueForPaddingRightValue();
+      if (paddingRight->GetUnit() == eCSSUnit_Null) {
+        *paddingRight = padVal;
+      }
+
+      nsCSSValue* paddingTop = aData->ValueForPaddingTop();
+      if (paddingTop->GetUnit() == eCSSUnit_Null) {
+        *paddingTop = padVal;
+      }
+
+      nsCSSValue* paddingBottom = aData->ValueForPaddingBottom();
+      if (paddingBottom->GetUnit() == eCSSUnit_Null) {
+        *paddingBottom = padVal;
       }
     }
   }
 }
 
 nsMappedAttributes*
 nsHTMLTableElement::GetAttributesMappedForCell()
 {