Allow MapRuleInfoInto to map data for multiple structs at the same time. b=240117 r+sr=bzbarsky a=roc
authordbaron@dbaron.org
Mon, 08 Oct 2007 14:58:22 -0700
changeset 6732 f23134c1c5350ad09c74dbf5b2c4e0b860fa9d63
parent 6731 bb398ba44f93f1179cc6d267018936f3ca2d0fb1
child 6733 0a15361b58e2964c098af19c5d2e24d203c771dd
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs240117
milestone1.9a9pre
Allow MapRuleInfoInto to map data for multiple structs at the same time. b=240117 r+sr=bzbarsky a=roc
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLBRElement.cpp
content/html/content/src/nsHTMLBodyElement.cpp
content/html/content/src/nsHTMLFontElement.cpp
content/html/content/src/nsHTMLHRElement.cpp
content/html/content/src/nsHTMLIFrameElement.cpp
content/html/content/src/nsHTMLLIElement.cpp
content/html/content/src/nsHTMLOListElement.cpp
content/html/content/src/nsHTMLPreElement.cpp
content/html/content/src/nsHTMLSharedElement.cpp
content/html/content/src/nsHTMLTableCaptionElement.cpp
content/html/content/src/nsHTMLTableCellElement.cpp
content/html/content/src/nsHTMLTableColElement.cpp
content/html/content/src/nsHTMLTableElement.cpp
content/html/content/src/nsHTMLTableRowElement.cpp
content/html/content/src/nsHTMLTableSectionElement.cpp
layout/style/nsCSSDataBlock.cpp
layout/style/nsHTMLCSSStyleSheet.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsIStyleRule.h
layout/style/nsRuleData.h
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/style/nsStyleStructFwd.h
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -1905,17 +1905,17 @@ nsGenericHTMLElement::ParseScrollingValu
 
 /**
  * Handle attributes common to all html elements
  */
 void
 nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttributes,
                                               nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_UserInterface) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(UserInterface)) {
     nsRuleDataUserInterface *ui = aData->mUserInterfaceData;
     if (ui->mUserModify.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value =
         aAttributes->GetAttr(nsGkAtoms::contenteditable);
       if (value) {
         if (value->Equals(nsGkAtoms::_empty, eCaseMatters) ||
             value->Equals(nsGkAtoms::_true, eIgnoreCase)) {
           ui->mUserModify.SetIntValue(NS_STYLE_USER_MODIFY_READ_WRITE,
@@ -1923,17 +1923,17 @@ nsGenericHTMLElement::MapCommonAttribute
         }
         else {
           ui->mUserModify.SetIntValue(NS_STYLE_USER_MODIFY_READ_ONLY,
                                       eCSSUnit_Enumerated);
         }
       }
     }
   }
-  if (aData->mSID == eStyleStruct_Visibility) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::lang);
     if (value && value->Type() == nsAttrValue::eString) {
       aData->mDisplayData->mLang.SetStringValue(value->GetStringValue(),
                                                 eCSSUnit_String);
     }
   }
 }
 
@@ -2014,27 +2014,30 @@ nsGenericHTMLElement::sScrollingAttribut
   { &nsGkAtoms::scrolling },
   { nsnull }
 };
 
 void
 nsGenericHTMLElement::MapImageAlignAttributeInto(const nsMappedAttributes* aAttributes,
                                                  nsRuleData* aRuleData)
 {
-  if (aRuleData->mSID == eStyleStruct_Display || aRuleData->mSID == eStyleStruct_TextReset) {
+  if (aRuleData->mSIDs & (NS_STYLE_INHERIT_BIT(Display) |
+                          NS_STYLE_INHERIT_BIT(TextReset))) {
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
     if (value && value->Type() == nsAttrValue::eEnum) {
       PRInt32 align = value->GetEnumValue();
-      if (aRuleData->mSID == eStyleStruct_Display && aRuleData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
+      if ((aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) &&
+          aRuleData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
         if (align == NS_STYLE_TEXT_ALIGN_LEFT)
           aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
         else if (align == NS_STYLE_TEXT_ALIGN_RIGHT)
           aRuleData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
       }
-      else if (aRuleData->mSID == eStyleStruct_TextReset && aRuleData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
+      if ((aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) &&
+          aRuleData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
         switch (align) {
         case NS_STYLE_TEXT_ALIGN_LEFT:
         case NS_STYLE_TEXT_ALIGN_RIGHT:
           break;
         default:
           aRuleData->mTextData->mVerticalAlign.SetIntValue(align, eCSSUnit_Enumerated);
           break;
         }
@@ -2042,32 +2045,32 @@ nsGenericHTMLElement::MapImageAlignAttri
     }
   }
 }
 
 void
 nsGenericHTMLElement::MapDivAlignAttributeInto(const nsMappedAttributes* aAttributes,
                                                nsRuleData* aRuleData)
 {
-  if (aRuleData->mSID == eStyleStruct_Text) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aRuleData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
       // align: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
       if (value && value->Type() == nsAttrValue::eEnum)
         aRuleData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 }
 
 
 void
 nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAttributes,
                                                   nsRuleData* aData)
 {
-  if (aData->mSID != eStyleStruct_Margin)
+  if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)))
     return;
 
   const nsAttrValue* value;
 
   // hspace: value
   value = aAttributes->GetAttr(nsGkAtoms::hspace);
   if (value) {
     nsCSSValue hval;
@@ -2103,17 +2106,17 @@ nsGenericHTMLElement::MapImageMarginAttr
     }
   }
 }
 
 void
 nsGenericHTMLElement::MapImageSizeAttributesInto(const nsMappedAttributes* aAttributes,
                                                  nsRuleData* aData)
 {
-  if (aData->mSID != eStyleStruct_Position)
+  if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)))
     return;
 
   // width: value
   if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
     if (value && value->Type() == nsAttrValue::eInteger)
       aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
     else if (value && value->Type() == nsAttrValue::ePercent)
@@ -2129,17 +2132,17 @@ nsGenericHTMLElement::MapImageSizeAttrib
       aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());    
   }
 }
 
 void
 nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAttributes,
                                                   nsRuleData* aData)
 {
-  if (aData->mSID != eStyleStruct_Border)
+  if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)))
     return;
 
   // border: pixels
   const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::border);
   if (!value)
     return;
   
   nscoord val = 0;
@@ -2176,17 +2179,17 @@ nsGenericHTMLElement::MapImageBorderAttr
   if (borderColor.mBottom.GetUnit() == eCSSUnit_Null)
     borderColor.mBottom.SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
 }
 
 void
 nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
                                         nsRuleData* aData)
 {
-  if (aData->mSID != eStyleStruct_Background)
+  if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)))
     return;
 
   if (aData->mColorData->mBackImage.GetUnit() == eCSSUnit_Null) {
     // background
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::background);
     if (value && value->Type() == nsAttrValue::eString) {
       const nsString& spec = value->GetStringValue();
       if (!spec.IsEmpty()) {
@@ -2228,17 +2231,17 @@ nsGenericHTMLElement::MapBackgroundInto(
     }
   }
 }
 
 void
 nsGenericHTMLElement::MapBGColorInto(const nsMappedAttributes* aAttributes,
                                      nsRuleData* aData)
 {
-  if (aData->mSID != eStyleStruct_Background)
+  if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)))
     return;
 
   if (aData->mColorData->mBackColor.GetUnit() == eCSSUnit_Null) {
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::bgcolor);
     nscolor color;
     if (value && value->GetColorValue(color)) {
       aData->mColorData->mBackColor.SetColorValue(color);
     }
@@ -2252,17 +2255,17 @@ nsGenericHTMLElement::MapBackgroundAttri
   MapBackgroundInto(aAttributes, aData);
   MapBGColorInto(aAttributes, aData);
 }
 
 void
 nsGenericHTMLElement::MapScrollingAttributeInto(const nsMappedAttributes* aAttributes,
                                                 nsRuleData* aData)
 {
-  if (aData->mSID != eStyleStruct_Display)
+  if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)))
     return;
 
   // scrolling
   nsCSSValue* overflowValues[2] = {
     &aData->mDisplayData->mOverflowX,
     &aData->mDisplayData->mOverflowY,
   };
   for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(overflowValues); ++i) {
--- a/content/html/content/src/nsHTMLBRElement.cpp
+++ b/content/html/content/src/nsHTMLBRElement.cpp
@@ -123,17 +123,17 @@ nsHTMLBRElement::ParseAttribute(PRInt32 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static void
 MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                       nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Display) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
     if (aData->mDisplayData->mClear.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::clear);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mDisplayData->mClear.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 
   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
--- a/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/content/html/content/src/nsHTMLBodyElement.cpp
@@ -133,17 +133,17 @@ BodyRule::~BodyRule()
 {
 }
 
 NS_IMPL_ISUPPORTS1(BodyRule, nsIStyleRule)
 
 NS_IMETHODIMP
 BodyRule::MapRuleInfoInto(nsRuleData* aData)
 {
-  if (!aData || (aData->mSID != eStyleStruct_Margin) || !aData->mMarginData || !mPart)
+  if (!aData || !(aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) || !aData->mMarginData || !mPart)
     return NS_OK; // We only care about margins.
 
   PRInt32 bodyMarginWidth  = -1;
   PRInt32 bodyMarginHeight = -1;
   PRInt32 bodyTopMargin = -1;
   PRInt32 bodyBottomMargin = -1;
   PRInt32 bodyLeftMargin = -1;
   PRInt32 bodyRightMargin = -1;
@@ -476,17 +476,17 @@ nsHTMLBodyElement::UnbindFromTree(PRBool
   }
 
   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);  
 }
 
 static 
 void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Display) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
     // When display if first asked for, go ahead and get our colors set up.
     nsIPresShell *presShell = aData->mPresContext->GetPresShell();
     if (presShell) {
       nsIDocument *doc = presShell->GetDocument();
       if (doc) {
         nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
         if (styleSheet) {
           const nsAttrValue* value;
@@ -505,17 +505,17 @@ void MapAttributesIntoRule(const nsMappe
           if (value && value->GetColorValue(color)) {
             styleSheet->SetVisitedLinkColor(color);
           }
         }
       }
     }
   }
 
-  if (aData->mSID == eStyleStruct_Color) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
     if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
       // color: color
       nscolor color;
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
       if (value && value->GetColorValue(color))
         aData->mColorData->mColor.SetColorValue(color);
     }
   }
--- a/content/html/content/src/nsHTMLFontElement.cpp
+++ b/content/html/content/src/nsHTMLFontElement.cpp
@@ -165,17 +165,17 @@ nsHTMLFontElement::ParseAttribute(PRInt3
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static void
 MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                       nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Font) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
     nsRuleDataFont& font = *(aData->mFontData);
     
     // face: string list
     if (font.mFamily.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
       if (value && value->Type() == nsAttrValue::eString &&
           !value->IsEmptyString()) {
         font.mFamily.SetStringValue(value->GetStringValue(), eCSSUnit_String);
@@ -209,27 +209,27 @@ MapAttributesIntoRule(const nsMappedAttr
 
     // fontWeight: int
     if (font.mWeight.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::fontWeight);
       if (value && value->Type() == nsAttrValue::eInteger) // +/-
         font.mWeight.SetIntValue(value->GetIntegerValue(), eCSSUnit_Integer);
     }
   }
-  else if (aData->mSID == eStyleStruct_Color) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
     if (aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
       // color: color
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
       nscolor color;
       if (value && value->GetColorValue(color)) {
         aData->mColorData->mColor.SetColorValue(color);
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_TextReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
     // Make <a><font color="red">text</font></a> give the text a red underline
     // in quirks mode.  The NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL flag only
     // affects quirks mode rendering.
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
     nscolor color;
     if (value && value->GetColorValue(color)) {
       nsCSSValue& decoration = aData->mTextData->mDecoration;
       PRInt32 newValue = NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL;
--- a/content/html/content/src/nsHTMLHRElement.cpp
+++ b/content/html/content/src/nsHTMLHRElement.cpp
@@ -151,26 +151,26 @@ MapAttributesIntoRule(const nsMappedAttr
                       nsRuleData* aData)
 {
   PRBool noshade = PR_FALSE;
 
   const nsAttrValue* colorValue = aAttributes->GetAttr(nsGkAtoms::color);
   nscolor color;
   PRBool colorIsSet = colorValue && colorValue->GetColorValue(color);
 
-  if (aData->mSID == eStyleStruct_Position ||
-      aData->mSID == eStyleStruct_Border) {
+  if (aData->mSIDs & (NS_STYLE_INHERIT_BIT(Position) |
+                      NS_STYLE_INHERIT_BIT(Border))) {
     if (colorIsSet) {
       noshade = PR_TRUE;
     } else {
       noshade = !!aAttributes->GetAttr(nsGkAtoms::noshade);
     }
   }
 
-  if (aData->mSID == eStyleStruct_Margin) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) {
     // align: enum
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
     if (value && value->Type() == nsAttrValue::eEnum) {
       // Map align attribute into auto side margins
       nsCSSRect& margin = aData->mMarginData->mMargin;
       switch (value->GetEnumValue()) {
       case NS_STYLE_TEXT_ALIGN_LEFT:
         if (margin.mLeft.GetUnit() == eCSSUnit_Null)
@@ -188,17 +188,17 @@ MapAttributesIntoRule(const nsMappedAttr
         if (margin.mLeft.GetUnit() == eCSSUnit_Null)
           margin.mLeft.SetAutoValue();
         if (margin.mRight.GetUnit() == eCSSUnit_Null)
           margin.mRight.SetAutoValue();
         break;
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     // width: integer, percent
     if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
       if (value && value->Type() == nsAttrValue::eInteger) {
         aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
       } else if (value && value->Type() == nsAttrValue::ePercent) {
         aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
       }
@@ -216,17 +216,17 @@ MapAttributesIntoRule(const nsMappedAttr
         // removing all but the top border.
         const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
         if (value && value->Type() == nsAttrValue::eInteger) {
           aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
         } // else use default value from html.css
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Border && noshade) { // if not noshade, border styles are dealt with by html.css
+  if ((aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) && noshade) { // if not noshade, border styles are dealt with by html.css
     // size: integer
     // if a size is set, use half of it per side, otherwise, use 1px per side
     float sizePerSide;
     PRBool allSides = PR_TRUE;
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
     if (value && value->Type() == nsAttrValue::eInteger) {
       sizePerSide = (float)value->GetIntegerValue() / 2.0f;
       if (sizePerSide < 1.0f) {
@@ -286,17 +286,17 @@ MapAttributesIntoRule(const nsMappedAttr
       if (borderRadius.mBottom.GetUnit() == eCSSUnit_Null) {
         borderRadius.mBottom.SetPercentValue(1.0f);
       }
       if (borderRadius.mLeft.GetUnit() == eCSSUnit_Null) {
         borderRadius.mLeft.SetPercentValue(1.0f);
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Color) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
     // color: a color
     // (we got the color attribute earlier)
     if (colorIsSet &&
         aData->mColorData->mColor.GetUnit() == eCSSUnit_Null) {
       aData->mColorData->mColor.SetColorValue(color);
     }
   }
 
--- a/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -155,17 +155,17 @@ nsHTMLIFrameElement::ParseAttribute(PRIn
   return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
                                                    aValue, aResult);
 }
 
 static void
 MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                       nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Border) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     // frameborder: 0 | 1 (| NO | YES in quirks mode)
     // If frameborder is 0 or No, set border to 0
     // else leave it as the value set in html.css
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder);
     if (value && value->Type() == nsAttrValue::eEnum) {
       PRInt32 frameborder = value->GetEnumValue();
       if (NS_STYLE_FRAME_0 == frameborder ||
           NS_STYLE_FRAME_NO == frameborder ||
@@ -176,17 +176,17 @@ MapAttributesIntoRule(const nsMappedAttr
           aData->mMarginData->mBorderWidth.mRight.SetFloatValue(0.0f, eCSSUnit_Pixel);
         if (aData->mMarginData->mBorderWidth.mTop.GetUnit() == eCSSUnit_Null)
           aData->mMarginData->mBorderWidth.mTop.SetFloatValue(0.0f, eCSSUnit_Pixel);
         if (aData->mMarginData->mBorderWidth.mBottom.GetUnit() == eCSSUnit_Null)
           aData->mMarginData->mBorderWidth.mBottom.SetFloatValue(0.0f, eCSSUnit_Pixel);
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     // width: value
     if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
       if (value && value->Type() == nsAttrValue::eInteger)
         aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
       else if (value && value->Type() == nsAttrValue::ePercent)
         aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
     }
--- a/content/html/content/src/nsHTMLLIElement.cpp
+++ b/content/html/content/src/nsHTMLLIElement.cpp
@@ -142,17 +142,17 @@ nsHTMLLIElement::ParseAttribute(PRInt32 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static void
 MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                       nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_List) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
     if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
       // type: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 
--- a/content/html/content/src/nsHTMLOListElement.cpp
+++ b/content/html/content/src/nsHTMLOListElement.cpp
@@ -169,17 +169,17 @@ nsHTMLSharedListElement::ParseAttribute(
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static void
 MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_List) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
     if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
       // type: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
       if (value) {
         if (value->Type() == nsAttrValue::eEnum)
           aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
         else
           aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eCSSUnit_Enumerated);
--- a/content/html/content/src/nsHTMLPreElement.cpp
+++ b/content/html/content/src/nsHTMLPreElement.cpp
@@ -128,36 +128,36 @@ nsHTMLPreElement::ParseAttribute(PRInt32
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static void
 MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                       nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Font) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
     // variable
     if (aAttributes->GetAttr(nsGkAtoms::variable))
       aData->mFontData->mFamily.SetStringValue(NS_LITERAL_STRING("serif"),
                                                eCSSUnit_String);
   }
-  else if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
       // width: int (html4 attribute == nav4 cols)
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
       if (!value || value->Type() != nsAttrValue::eInteger) {
         // cols: int (nav4 attribute)
         value = aAttributes->GetAttr(nsGkAtoms::cols);
       }
 
       if (value && value->Type() == nsAttrValue::eInteger)
         aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
     }
   }
-  else if (aData->mSID == eStyleStruct_Text) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
       // wrap: empty
       if (aAttributes->GetAttr(nsGkAtoms::wrap))
         aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated);
 
       // width: int (html4 attribute == nav4 cols)
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
       if (!value || value->Type() != nsAttrValue::eInteger) {
--- a/content/html/content/src/nsHTMLSharedElement.cpp
+++ b/content/html/content/src/nsHTMLSharedElement.cpp
@@ -234,17 +234,17 @@ nsHTMLSharedElement::ParseAttribute(PRIn
 
 static void
 SpacerMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                             nsRuleData* aData)
 {
   nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aData);
   nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
 
-  if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     const nsStyleDisplay* display = aData->mStyleContext->GetStyleDisplay();
 
     PRBool typeIsBlock = (display->mDisplay == NS_STYLE_DISPLAY_BLOCK);
 
     if (typeIsBlock) {
       // width: value
       if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
         const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
@@ -275,17 +275,18 @@ SpacerMapAttributesIntoRule(const nsMapp
       if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
         const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
         if (value && value->Type() == nsAttrValue::eInteger)
           aData->mPositionData->
             mWidth.SetFloatValue((float)value->GetIntegerValue(),
                                  eCSSUnit_Pixel);
       }
     }
-  } else if (aData->mSID == eStyleStruct_Display) {
+  }
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
     if (value && value->Type() == nsAttrValue::eEnum) {
       PRInt32 align = value->GetEnumValue();
       if (aData->mDisplayData->mFloat.GetUnit() == eCSSUnit_Null) {
         if (align == NS_STYLE_TEXT_ALIGN_LEFT)
           aData->mDisplayData->mFloat.SetIntValue(NS_STYLE_FLOAT_LEFT,
                                                   eCSSUnit_Enumerated);
         else if (align == NS_STYLE_TEXT_ALIGN_RIGHT)
@@ -313,17 +314,17 @@ SpacerMapAttributesIntoRule(const nsMapp
 
   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
 }
 
 static void
 DirectoryMenuMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                                nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_List) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
     if (aData->mListData->mType.GetUnit() == eCSSUnit_Null) {
       // type: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
       if (value) {
         if (value->Type() == nsAttrValue::eEnum) {
           aData->mListData->mType.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
         } else {
           aData->mListData->mType.SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
--- a/content/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/content/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -127,17 +127,17 @@ nsHTMLTableCaptionElement::ParseAttribut
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static 
 void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_TableBorder) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) {
     if (aData->mTableData->mCaptionSide.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTableData->mCaptionSide.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 
   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
--- a/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -325,17 +325,17 @@ nsHTMLTableCellElement::ParseAttribute(P
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static 
 void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                            nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     // width: value
     if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
       if (value && value->Type() == nsAttrValue::eInteger) {
         if (value->GetIntegerValue() > 0)
           aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); 
         // else 0 implies auto for compatibility.
       }
@@ -356,17 +356,17 @@ void MapAttributesIntoRule(const nsMappe
       }
       else if (value && value->Type() == nsAttrValue::ePercent) {
         if (value->GetPercentValue() > 0.0f)
           aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
         // else 0 implies auto for compatibility
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Text) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
       // align: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
 
     if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
@@ -375,17 +375,17 @@ void MapAttributesIntoRule(const nsMappe
         // See if our width is not a integer width.
         const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
         nsCompatibility mode = aData->mPresContext->CompatibilityMode();
         if (!value || value->Type() != nsAttrValue::eInteger || eCompatibility_NavQuirks != mode)
           aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_TextReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
     if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
       // valign: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
   
--- a/content/html/content/src/nsHTMLTableColElement.cpp
+++ b/content/html/content/src/nsHTMLTableColElement.cpp
@@ -143,17 +143,17 @@ nsHTMLTableColElement::ParseAttribute(PR
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static 
 void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Position &&
+  if ((aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) &&
       aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
     // width
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
     if (value) {
       switch (value->Type()) {
       case nsAttrValue::ePercent: {
         aData->mPositionData->mWidth.SetPercentValue(value->GetPercentValue());
         break;
@@ -162,41 +162,41 @@ void MapAttributesIntoRule(const nsMappe
         aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
         break;
       }
       default:
         break;
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Text) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
       // align: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
-  else if (aData->mSID == eStyleStruct_TextReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
     if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
       // valign: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 
   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
 }
 
 static 
 void ColMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
                               nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Table && 
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table) && 
       aData->mTableData->mSpan.GetUnit() == eCSSUnit_Null) {
     // span: int
     const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
     if (value && value->Type() == nsAttrValue::eInteger)
       aData->mTableData->mSpan.SetIntValue(value->GetIntegerValue(),
                                            eCSSUnit_Integer);
   }
 
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -1125,17 +1125,17 @@ MapAttributesIntoRule(const nsMappedAttr
   // nsIStyleRule contract, since it's the same style rule object doing
   // the mapping in two different ways.  It's also incorrect since it's
   // testing the display type of the style context rather than checking
   // which *element* it's matching (style rules should not stop matching
   // when the display type is changed).
 
   nsCompatibility mode = aData->mPresContext->CompatibilityMode();
 
-  if (aData->mSID == eStyleStruct_TableBorder) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
     if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
       // cellspacing 
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing);
       if (value && value->Type() == nsAttrValue::eInteger) {
         if (aData->mTableData->mBorderSpacing.mXValue.GetUnit() == eCSSUnit_Null)
           aData->mTableData->mBorderSpacing.mXValue.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
         if (aData->mTableData->mBorderSpacing.mYValue.GetUnit() == eCSSUnit_Null)
@@ -1145,17 +1145,17 @@ MapAttributesIntoRule(const nsMappedAttr
         // in quirks mode, treat a % cellspacing value a pixel value.
         if (aData->mTableData->mBorderSpacing.mXValue.GetUnit() == eCSSUnit_Null)
           aData->mTableData->mBorderSpacing.mXValue.SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
         if (aData->mTableData->mBorderSpacing.mYValue.GetUnit() == eCSSUnit_Null)
           aData->mTableData->mBorderSpacing.mYValue.SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel);
       }
     }
   } 
-  else if (aData->mSID == eStyleStruct_Table) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
     if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
       MapTableBorderInto(aAttributes, aData, 0);
 
       const nsAttrValue* value;
       // layout
       if (aData->mTableData->mLayout.GetUnit() == eCSSUnit_Null) {
         value = aAttributes->GetAttr(nsGkAtoms::layout);
@@ -1173,17 +1173,17 @@ MapAttributesIntoRule(const nsMappedAttr
       }
 
       // rules
       value = aAttributes->GetAttr(nsGkAtoms::rules);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTableData->mRules.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
-  else if (aData->mSID == eStyleStruct_Margin) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
   
     if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
       // align; Check for enumerated type (it may be another type if
       // illegal)
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
 
       if (value && value->Type() == nsAttrValue::eEnum) {
@@ -1218,17 +1218,17 @@ MapAttributesIntoRule(const nsMappedAttr
           if (margin.mTop.GetUnit() == eCSSUnit_Null)
             margin.mTop.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); 
           if (margin.mBottom.GetUnit() == eCSSUnit_Null)
             margin.mBottom.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); 
         }
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Padding) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Padding)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
     if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
       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.
@@ -1253,17 +1253,17 @@ MapAttributesIntoRule(const nsMappedAttr
           if (aData->mMarginData->mPadding.mTop.GetUnit() == eCSSUnit_Null)
             aData->mMarginData->mPadding.mTop = padVal;
           if (aData->mMarginData->mPadding.mBottom.GetUnit() == eCSSUnit_Null)
             aData->mMarginData->mPadding.mBottom = padVal;
         }
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
   
     if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
       // width: value
       if (aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
         const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
         if (value && value->Type() == nsAttrValue::eInteger) 
           aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
@@ -1276,23 +1276,23 @@ MapAttributesIntoRule(const nsMappedAttr
         const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
         if (value && value->Type() == nsAttrValue::eInteger) 
           aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
         else if (value && value->Type() == nsAttrValue::ePercent)
           aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue()); 
       }
     }
   }
-  else if (aData->mSID == eStyleStruct_Visibility) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
   
     if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL)
       nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
   }
-  else if (aData->mSID == eStyleStruct_Border) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     const nsStyleTableBorder* tableStyle = aData->mStyleContext->GetStyleTableBorder();
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
     if (readDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) {
       if (NS_STYLE_BORDER_SEPARATE == tableStyle->mBorderCollapse) {
         // Set the cell's border from the table in the separate border
         // model. If there is a border on the table, then the mapping to
         // rules=all will take care of borders in the collapsing model.
         // But if rules="none", we don't want to do this.
@@ -1355,17 +1355,17 @@ MapAttributesIntoRule(const nsMappedAttr
         if (aData->mMarginData->mBorderColor.mBottom.GetUnit() == eCSSUnit_Null)
           aData->mMarginData->mBorderColor.mBottom.SetColorValue(color);
       }
 
       // border and frame
       MapTableBorderInto(aAttributes, aData, borderStyle);
     }
   }
-  else if (aData->mSID == eStyleStruct_Background) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)) {
     const nsStyleDisplay* readDisplay = aData->mStyleContext->GetStyleDisplay();
   
     if (readDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL)
       nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
   }
 }
 
 NS_IMETHODIMP_(PRBool)
--- a/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -393,35 +393,35 @@ nsHTMLTableRowElement::ParseAttribute(PR
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static 
 void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     // height: value
     if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
       if (value && value->Type() == nsAttrValue::eInteger)
         aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
       else if (value && value->Type() == nsAttrValue::ePercent)
         aData->mPositionData->mHeight.SetPercentValue(value->GetPercentValue());
     }
   }
-  else if (aData->mSID == eStyleStruct_Text) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
       // align: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
-  else if (aData->mSID == eStyleStruct_TextReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
     if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
       // valign: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 
--- a/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -263,33 +263,33 @@ nsHTMLTableSectionElement::ParseAttribut
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 static 
 void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
 {
-  if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     // height: value
     if (aData->mPositionData->mHeight.GetUnit() == eCSSUnit_Null) {
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
       if (value && value->Type() == nsAttrValue::eInteger)
         aData->mPositionData->mHeight.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);   
     }
   }
-  else if (aData->mSID == eStyleStruct_Text) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
       // align: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mTextAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
-  else if (aData->mSID == eStyleStruct_TextReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
     if (aData->mTextData->mVerticalAlign.GetUnit() == eCSSUnit_Null) {
       // valign: enum
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
       if (value && value->Type() == nsAttrValue::eEnum)
         aData->mTextData->mVerticalAlign.SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     }
   }
 
--- a/layout/style/nsCSSDataBlock.cpp
+++ b/layout/style/nsCSSDataBlock.cpp
@@ -180,30 +180,31 @@ ShouldIgnoreColors(nsRuleData *aRuleData
            aRuleData->mLevel != nsStyleSet::eUserSheet &&
            !presContext->GetCachedBoolPref(kPresContext_UseDocumentColors) &&
            !presContext->IsChrome();
 }
 
 nsresult
 nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
 {
-    // If we have no data for this struct, then return immediately.
+    // If we have no data for these structs, then return immediately.
     // This optimization should make us return most of the time, so we
     // have to worry much less (although still some) about the speed of
     // the rest of the function.
-    if (!(nsCachedStyleData::GetBitForSID(aRuleData->mSID) & mStyleBits))
+    if (!(aRuleData->mSIDs & mStyleBits))
         return NS_OK;
 
     const char* cursor = Block();
     const char* cursor_end = BlockEnd();
     while (cursor < cursor_end) {
         nsCSSProperty iProp = PropertyAtCursor(cursor);
         NS_ASSERTION(0 <= iProp && iProp < eCSSProperty_COUNT_no_shorthands,
                      "out of range");
-        if (nsCSSProps::kSIDTable[iProp] == aRuleData->mSID) {
+        if (nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]) &
+            aRuleData->mSIDs) {
             void *prop =
                 nsCSSExpandedDataBlock::RuleDataPropertyAt(aRuleData, iProp);
             switch (nsCSSProps::kTypeTable[iProp]) {
                 case eCSSType_Value: {
                     nsCSSValue* target = static_cast<nsCSSValue*>(prop);
                     if (target->GetUnit() == eCSSUnit_Null) {
                         const nsCSSValue *val = ValueAtCursor(cursor);
                         NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
--- a/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -139,32 +139,32 @@ void
 CSSDisablePropsRule::CommonMapRuleInfoInto(nsRuleData* aData)
 {
   /*
    * Common code for disabling the properties that apply neither to
    * :first-letter nor to :first-line.
    */
 
   // Disable 'unicode-bidi'.
-  if (aData->mSID == eStyleStruct_TextReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
     nsCSSValue normal(eCSSUnit_Normal);
     aData->mTextData->mUnicodeBidi = normal;
   }
 
   // NOTE: 'text-align', 'text-indent', and 'white-space' should not be
   // handled by the frames so we don't need to bother.
 
   // Disable everything in the nsRuleDataDisplay struct except 'float'.
-  if (aData->mSID == eStyleStruct_Visibility) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
     nsCSSValue inherit(eCSSUnit_Inherit);
     aData->mDisplayData->mVisibility = inherit;
     aData->mDisplayData->mDirection = inherit;
   }
 
-  if (aData->mSID == eStyleStruct_Display) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
     nsCSSValue none(eCSSUnit_None);
     aData->mDisplayData->mAppearance = none;
 
     nsCSSValue autovalue(eCSSUnit_Auto);
     aData->mDisplayData->mClip.mTop = autovalue;
     aData->mDisplayData->mClip.mRight = autovalue;
     aData->mDisplayData->mClip.mBottom = autovalue;
     aData->mDisplayData->mClip.mLeft = autovalue;
@@ -190,17 +190,17 @@ CSSDisablePropsRule::CommonMapRuleInfoIn
     // they only apply to blocks (assuming we implement them correctly).
   }
 
   // NOTE:  We'll never do anything with what's in nsCSSList,
   // nsCSSTable, nsCSSBreaks, nsCSSPage, nsCSSAural, nsCSSXUL, or
   // nsCSSSVG, so don't bother.
 
   // Disable everything in the position struct.
-  if (aData->mSID == eStyleStruct_Position) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
     nsCSSValue autovalue(eCSSUnit_Auto);
     nsCSSValue none(eCSSUnit_None);
     nsCSSValue zero(0.0f, eCSSUnit_Point);
     aData->mPositionData->mOffset.mTop = autovalue;
     aData->mPositionData->mOffset.mRight = autovalue;
     aData->mPositionData->mOffset.mBottom = autovalue;
     aData->mPositionData->mOffset.mLeft = autovalue;
     aData->mPositionData->mWidth = autovalue;
@@ -210,50 +210,50 @@ CSSDisablePropsRule::CommonMapRuleInfoIn
     aData->mPositionData->mMinHeight = zero;
     aData->mPositionData->mMaxHeight = none;
     nsCSSValue content(NS_STYLE_BOX_SIZING_CONTENT, eCSSUnit_Enumerated);
     aData->mPositionData->mBoxSizing = content;
     aData->mPositionData->mZIndex = autovalue;
   }
 
   // Disable everything in the Content struct.
-  if (aData->mSID == eStyleStruct_Content) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Content)) {
     // Don't bother resetting 'content'.
 
     aData->mContentData->mCounterIncrement = &mNoneCounter;
     aData->mContentData->mCounterReset = &mNoneCounter;
 
     nsCSSValue autovalue(eCSSUnit_Auto);
     aData->mContentData->mMarkerOffset = autovalue;
   }
 
-  if (aData->mSID == eStyleStruct_Quotes) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Quotes)) {
     aData->mContentData->mQuotes = &mInheritQuotes;
   }
 
   // Disable everything in the UserInterface struct.
-  if (aData->mSID == eStyleStruct_UserInterface) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(UserInterface)) {
     nsCSSValue inherit(eCSSUnit_Inherit);
     aData->mUserInterfaceData->mUserInput = inherit;
     aData->mUserInterfaceData->mUserModify = inherit;
     aData->mUserInterfaceData->mUserFocus = inherit;
     aData->mUserInterfaceData->mCursor = &mInheritList;
   }
 
-  if (aData->mSID == eStyleStruct_UIReset) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(UIReset)) {
     nsCSSValue autovalue(eCSSUnit_Auto);
     nsCSSValue none(eCSSUnit_None);
     // Don't bother with '-moz-force-broken-image-icon' since it's only
     // half a property.
     // Don't bother with '-moz-user-select' because there's no way to
     // specify the initial value.
   }
 
   // Disable all outline properties.
-  if (aData->mSID == eStyleStruct_Outline) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Outline)) {
     nsCSSValue none(NS_STYLE_BORDER_STYLE_NONE, eCSSUnit_Enumerated);
     aData->mMarginData->mOutlineStyle = none;
   }
 
 }
 
 NS_IMETHODIMP
 CSSFirstLineRule::MapRuleInfoInto(nsRuleData* aData)
@@ -266,40 +266,40 @@ CSSFirstLineRule::MapRuleInfoInto(nsRule
    *
    * We also allow 'text-shadow', which was listed in CSS2 (where the
    * property existed).
    */
 
   CommonMapRuleInfoInto(aData);
 
   // Disable 'float'.
-  if (aData->mSID == eStyleStruct_Display) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
     nsCSSValue none(eCSSUnit_None);
     aData->mDisplayData->mFloat = none;
   }
 
   // Disable border properties, margin properties, and padding
   // properties.
-  if (aData->mSID == eStyleStruct_Border) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     nsCSSValue none(NS_STYLE_BORDER_STYLE_NONE, eCSSUnit_Enumerated);
     aData->mMarginData->mBorderStyle.mTop = none;
     aData->mMarginData->mBorderStyle.mRight = none;
     aData->mMarginData->mBorderStyle.mBottom = none;
     aData->mMarginData->mBorderStyle.mLeft = none;
   }
 
-  if (aData->mSID == eStyleStruct_Margin) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) {
     nsCSSValue zero(0.0f, eCSSUnit_Point);
     aData->mMarginData->mMargin.mTop = zero;
     aData->mMarginData->mMargin.mRight = zero;
     aData->mMarginData->mMargin.mBottom = zero;
     aData->mMarginData->mMargin.mLeft = zero;
   }
 
-  if (aData->mSID == eStyleStruct_Padding) {
+  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Padding)) {
     nsCSSValue zero(0.0f, eCSSUnit_Point);
     aData->mMarginData->mPadding.mTop = zero;
     aData->mMarginData->mPadding.mRight = zero;
     aData->mMarginData->mPadding.mBottom = zero;
     aData->mMarginData->mPadding.mLeft = zero;
   }
 
   return NS_OK;
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -70,17 +70,17 @@
 #include "nsRuleData.h"
 #include "nsContentErrors.h"
 
 NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::HTMLColorRule, nsIStyleRule)
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData->mSID == eStyleStruct_Color) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
     if (aRuleData->mColorData->mColor.GetUnit() == eCSSUnit_Null)
       aRuleData->mColorData->mColor = nsCSSValue(mColor);
   }
   return NS_OK;
 }
 
 #ifdef DEBUG
 NS_IMETHODIMP
@@ -121,17 +121,17 @@ static void PostResolveCallback(nsStyleS
                               ? NS_STYLE_TEXT_ALIGN_CENTER : parentAlign;
     }
   }
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData && aRuleData->mSID == eStyleStruct_Text) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     aRuleData->mCanStoreInRuleTree = PR_FALSE;
     aRuleData->mPostResolveCallback = &PostResolveCallback;
   }
   return NS_OK;
 }
 
 static void 
 ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct, 
@@ -207,17 +207,17 @@ static void TbodyPostResolveCallback(nsS
                                NS_STYLE_TABLE_RULES_GROUPS, NS_STYLE_TABLE_RULES_ROWS);
   ::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_BOTTOM, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
                                NS_STYLE_TABLE_RULES_GROUPS, NS_STYLE_TABLE_RULES_ROWS);
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData && aRuleData->mSID == eStyleStruct_Border) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     aRuleData->mCanStoreInRuleTree = PR_FALSE;
     aRuleData->mPostResolveCallback = &TbodyPostResolveCallback;
   }
   return NS_OK;
 }
 // -----------------------------------------------------------
 
 static void RowPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleData)
@@ -226,17 +226,17 @@ static void RowPostResolveCallback(nsSty
                                NS_STYLE_TABLE_RULES_ROWS, NS_STYLE_TABLE_RULES_ROWS);
   ::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_BOTTOM, PR_FALSE, NS_STYLE_TABLE_RULES_ALL,
                                NS_STYLE_TABLE_RULES_ROWS, NS_STYLE_TABLE_RULES_ROWS);
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData && aRuleData->mSID == eStyleStruct_Border) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     aRuleData->mCanStoreInRuleTree = PR_FALSE;
     aRuleData->mPostResolveCallback = &RowPostResolveCallback;
   }
   return NS_OK;
 }
 
 static void ColgroupPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleData)
 {
@@ -244,17 +244,17 @@ static void ColgroupPostResolveCallback(
                                NS_STYLE_TABLE_RULES_GROUPS, NS_STYLE_TABLE_RULES_COLS);
   ::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_RIGHT, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
                                NS_STYLE_TABLE_RULES_GROUPS, NS_STYLE_TABLE_RULES_COLS);
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData && aRuleData->mSID == eStyleStruct_Border) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     aRuleData->mCanStoreInRuleTree = PR_FALSE;
     aRuleData->mPostResolveCallback = &ColgroupPostResolveCallback;
   }
   return NS_OK;
 }
 
 static void ColPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleData)
 {
@@ -273,27 +273,27 @@ static void UngroupedColPostResolveCallb
                                NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
   ::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_RIGHT, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
                                NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::TableColRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData && aRuleData->mSID == eStyleStruct_Border) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     aRuleData->mCanStoreInRuleTree = PR_FALSE;
     aRuleData->mPostResolveCallback = &ColPostResolveCallback;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::TableUngroupedColRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
-  if (aRuleData && aRuleData->mSID == eStyleStruct_Border) {
+  if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
     aRuleData->mCanStoreInRuleTree = PR_FALSE;
     aRuleData->mPostResolveCallback = &UngroupedColPostResolveCallback;
   }
   return NS_OK;
 }
 // -----------------------------------------------------------
 
 struct MappedAttrTableEntry : public PLDHashEntryHdr {
--- a/layout/style/nsIStyleRule.h
+++ b/layout/style/nsIStyleRule.h
@@ -89,17 +89,18 @@ struct nsRuleData;
 
 class nsIStyleRule : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID)
 
   /**
    * |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic
    * data represented by the rule that:
-   *   + are relevant for |aRuleData->mSID| (the style struct ID)
+   *   + are relevant for any structs in |aRuleData->mSIDs| (style
+   *     struct ID bits)
    *   + are not already filled into the data struct
    * into the appropriate data struct in |aRuleData|.  It is important
    * that only empty data are filled in, since the rule tree is walked
    * from highest priority rule to least, so that the walk can stop if
    * all needed data are found.  Thus overwriting non-empty data will
    * break CSS cascading rules.
    */
   NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData)=0;
--- a/layout/style/nsRuleData.h
+++ b/layout/style/nsRuleData.h
@@ -49,17 +49,17 @@
 class nsPresContext;
 class nsStyleContext;
 
 struct nsRuleData;
 typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
 
 struct nsRuleData
 {
-  nsStyleStructID mSID;
+  PRUint32 mSIDs;
   PRPackedBool mCanStoreInRuleTree;
   PRPackedBool mIsImportantRule;
   PRUint8 mLevel; // an nsStyleSet::sheetType
   nsPresContext* mPresContext;
   nsStyleContext* mStyleContext;
   nsPostResolveFunc mPostResolveCallback;
   nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures!
   nsRuleDataDisplay* mDisplayData;
@@ -74,18 +74,18 @@ struct nsRuleData
   nsRuleDataXUL* mXULData;
 
 #ifdef MOZ_SVG
   nsRuleDataSVG* mSVGData;
 #endif
 
   nsRuleDataColumn* mColumnData;
 
-  nsRuleData(const nsStyleStructID& aSID, nsPresContext* aContext, nsStyleContext* aStyleContext) 
-    :mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
+  nsRuleData(PRUint32 aSIDs, nsPresContext* aContext, nsStyleContext* aStyleContext) 
+    :mSIDs(aSIDs), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
      mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull), 
      mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
      mUserInterfaceData(nsnull), mColumnData(nsnull)
   {
     mCanStoreInRuleTree = PR_TRUE;
     mXULData = nsnull;
 #ifdef MOZ_SVG
     mSVGData = nsnull;
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1066,250 +1066,250 @@ nsRuleNode::CheckSpecifiedProperties(con
 
   return result;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetDisplayData(nsStyleContext* aContext)
 {
   nsRuleDataDisplay displayData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Display, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Display), mPresContext, aContext);
   ruleData.mDisplayData = &displayData;
 
   return WalkRuleTree(eStyleStruct_Display, aContext, &ruleData, &displayData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetVisibilityData(nsStyleContext* aContext)
 {
   nsRuleDataDisplay displayData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Visibility, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Visibility), mPresContext, aContext);
   ruleData.mDisplayData = &displayData;
 
   return WalkRuleTree(eStyleStruct_Visibility, aContext, &ruleData, &displayData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetTextData(nsStyleContext* aContext)
 {
   nsRuleDataText textData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Text, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Text), mPresContext, aContext);
   ruleData.mTextData = &textData;
 
   return WalkRuleTree(eStyleStruct_Text, aContext, &ruleData, &textData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetTextResetData(nsStyleContext* aContext)
 {
   nsRuleDataText textData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_TextReset, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(TextReset), mPresContext, aContext);
   ruleData.mTextData = &textData;
 
   const nsStyleStruct* res = WalkRuleTree(eStyleStruct_TextReset, aContext, &ruleData, &textData);
   textData.mTextShadow = nsnull; // We are sharing with some style rule.  It really owns the data.
   return res;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetUserInterfaceData(nsStyleContext* aContext)
 {
   nsRuleDataUserInterface uiData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_UserInterface, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(UserInterface), mPresContext, aContext);
   ruleData.mUserInterfaceData = &uiData;
 
   const nsStyleStruct* res = WalkRuleTree(eStyleStruct_UserInterface, aContext, &ruleData, &uiData);
   uiData.mCursor = nsnull; // We are sharing with some style rule.  It really owns the data.
   return res;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetUIResetData(nsStyleContext* aContext)
 {
   nsRuleDataUserInterface uiData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_UIReset, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(UIReset), mPresContext, aContext);
   ruleData.mUserInterfaceData = &uiData;
 
   const nsStyleStruct* res = WalkRuleTree(eStyleStruct_UIReset, aContext, &ruleData, &uiData);
   return res;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetFontData(nsStyleContext* aContext)
 {
   nsRuleDataFont fontData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Font, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Font), mPresContext, aContext);
   ruleData.mFontData = &fontData;
 
   return WalkRuleTree(eStyleStruct_Font, aContext, &ruleData, &fontData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetColorData(nsStyleContext* aContext)
 {
   nsRuleDataColor colorData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Color, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Color), mPresContext, aContext);
   ruleData.mColorData = &colorData;
 
   return WalkRuleTree(eStyleStruct_Color, aContext, &ruleData, &colorData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetBackgroundData(nsStyleContext* aContext)
 {
   nsRuleDataColor colorData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Background, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Background), mPresContext, aContext);
   ruleData.mColorData = &colorData;
 
   return WalkRuleTree(eStyleStruct_Background, aContext, &ruleData, &colorData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetMarginData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Margin, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Margin), mPresContext, aContext);
   ruleData.mMarginData = &marginData;
 
   return WalkRuleTree(eStyleStruct_Margin, aContext, &ruleData, &marginData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetBorderData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Border, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Border), mPresContext, aContext);
   ruleData.mMarginData = &marginData;
 
   return WalkRuleTree(eStyleStruct_Border, aContext, &ruleData, &marginData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetPaddingData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Padding, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Padding), mPresContext, aContext);
   ruleData.mMarginData = &marginData;
 
   return WalkRuleTree(eStyleStruct_Padding, aContext, &ruleData, &marginData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetOutlineData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Outline, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Outline), mPresContext, aContext);
   ruleData.mMarginData = &marginData;
 
   return WalkRuleTree(eStyleStruct_Outline, aContext, &ruleData, &marginData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetListData(nsStyleContext* aContext)
 {
   nsRuleDataList listData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_List, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(List), mPresContext, aContext);
   ruleData.mListData = &listData;
 
   return WalkRuleTree(eStyleStruct_List, aContext, &ruleData, &listData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetPositionData(nsStyleContext* aContext)
 {
   nsRuleDataPosition posData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Position, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Position), mPresContext, aContext);
   ruleData.mPositionData = &posData;
 
   return WalkRuleTree(eStyleStruct_Position, aContext, &ruleData, &posData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetTableData(nsStyleContext* aContext)
 {
   nsRuleDataTable tableData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Table, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Table), mPresContext, aContext);
   ruleData.mTableData = &tableData;
 
   return WalkRuleTree(eStyleStruct_Table, aContext, &ruleData, &tableData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetTableBorderData(nsStyleContext* aContext)
 {
   nsRuleDataTable tableData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_TableBorder, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(TableBorder), mPresContext, aContext);
   ruleData.mTableData = &tableData;
 
   return WalkRuleTree(eStyleStruct_TableBorder, aContext, &ruleData, &tableData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetContentData(nsStyleContext* aContext)
 {
   nsRuleDataContent contentData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Content, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Content), mPresContext, aContext);
   ruleData.mContentData = &contentData;
 
   const nsStyleStruct* res = WalkRuleTree(eStyleStruct_Content, aContext, &ruleData, &contentData);
   contentData.mCounterIncrement = contentData.mCounterReset = nsnull;
   contentData.mContent = nsnull; // We are sharing with some style rule.  It really owns the data.
   return res;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetQuotesData(nsStyleContext* aContext)
 {
   nsRuleDataContent contentData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Quotes, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Quotes), mPresContext, aContext);
   ruleData.mContentData = &contentData;
 
   const nsStyleStruct* res = WalkRuleTree(eStyleStruct_Quotes, aContext, &ruleData, &contentData);
   contentData.mQuotes = nsnull; // We are sharing with some style rule.  It really owns the data.
   return res;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetXULData(nsStyleContext* aContext)
 {
   nsRuleDataXUL xulData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_XUL, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(XUL), mPresContext, aContext);
   ruleData.mXULData = &xulData;
 
   return WalkRuleTree(eStyleStruct_XUL, aContext, &ruleData, &xulData);
 }
 
 const nsStyleStruct*
 nsRuleNode::GetColumnData(nsStyleContext* aContext)
 {
   nsRuleDataColumn columnData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_Column, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Column), mPresContext, aContext);
   ruleData.mColumnData = &columnData;
 
   return WalkRuleTree(eStyleStruct_Column, aContext, &ruleData, &columnData);
 }
 
 #ifdef MOZ_SVG
 const nsStyleStruct*
 nsRuleNode::GetSVGData(nsStyleContext* aContext)
 {
   nsRuleDataSVG svgData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_SVG, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(SVG), mPresContext, aContext);
   ruleData.mSVGData = &svgData;
 
   const nsStyleStruct *res = WalkRuleTree(eStyleStruct_SVG, aContext, &ruleData, &svgData);
   svgData.mStrokeDasharray = nsnull; // We are sharing with some style rule.  It really owns the data.
   return res;
 }
 
 const nsStyleStruct*
 nsRuleNode::GetSVGResetData(nsStyleContext* aContext)
 {
   nsRuleDataSVG svgData; // Declare a struct with null CSS values.
-  nsRuleData ruleData(eStyleStruct_SVGReset, mPresContext, aContext);
+  nsRuleData ruleData(NS_STYLE_INHERIT_BIT(SVGReset), mPresContext, aContext);
   ruleData.mSVGData = &svgData;
 
   return WalkRuleTree(eStyleStruct_SVGReset, aContext, &ruleData, &svgData);
 }
 #endif
 
 const nsStyleStruct*
 nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
@@ -2222,17 +2222,17 @@ nsRuleNode::SetGenericFont(nsPresContext
   aFont->mSize = parentFont.mSize;
 
   PRBool dummy;
   PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
   
   for (PRInt32 i = contextPath.Count() - 1; i >= 0; --i) {
     nsStyleContext* context = (nsStyleContext*)contextPath[i];
     nsRuleDataFont fontData; // Declare a struct with null CSS values.
-    nsRuleData ruleData(eStyleStruct_Font, aPresContext, context);
+    nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Font), aPresContext, context);
     ruleData.mFontData = &fontData;
 
     // Trimmed down version of ::WalkRuleTree() to re-apply the style rules
     // Note that we *do* need to do this for our own data, since what is
     // in |fontData| in ComputeFontData is only for the rules below
     // aStartStruct.
     for (nsRuleNode* ruleNode = context->GetRuleNode(); ruleNode;
          ruleNode = ruleNode->GetParent()) {
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -56,16 +56,21 @@
 #include "nsIPresShell.h"
 #include "nsIFrame.h"
 #include "nsHTMLReflowState.h"
 #include "prenv.h"
 
 #include "nsBidiUtils.h"
 
 #include "imgIRequest.h"
+#include "prlog.h"
+
+// Make sure we have enough bits in NS_STYLE_INHERIT_MASK.
+PR_STATIC_ASSERT((((1 << nsStyleStructID_Length) - 1) &
+                  ~(NS_STYLE_INHERIT_MASK)) == 0);
 
 inline PRBool IsFixedUnit(nsStyleUnit aUnit, PRBool aEnumOK)
 {
   return PRBool((aUnit == eStyleUnit_Coord) || 
                 (aEnumOK && (aUnit == eStyleUnit_Enumerated)));
 }
 
 static PRBool EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -64,17 +64,17 @@
 
 class nsIFrame;
 class imgIRequest;
 
 // Includes nsStyleStructID.
 #include "nsStyleStructFwd.h"
 
 // Bits for each struct.
-#define NS_STYLE_INHERIT_BIT(sid_)        (1 << PRInt32(eStyleStruct_##sid_))
+// NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h
 #define NS_STYLE_INHERIT_MASK             0x00ffffff
 
 // Additional bits for nsStyleContext's mBits:
 // A bit to test whether or not we have any text decorations.
 #define NS_STYLE_HAS_TEXT_DECORATIONS     0x01000000
 
 // Additional bits for nsRuleNode's mDependentBits:
 #define NS_RULE_NODE_GC_MARK              0x02000000
--- a/layout/style/nsStyleStructFwd.h
+++ b/layout/style/nsStyleStructFwd.h
@@ -57,9 +57,12 @@ enum nsStyleStructID {
 #undef STYLE_STRUCT
 
 nsStyleStructID_Length /* one past the end; length of 0-based list */
 
 };
 
 struct nsStyleStruct;
 
+// A bit corresponding to each struct ID
+#define NS_STYLE_INHERIT_BIT(sid_)        (1 << PRInt32(eStyleStruct_##sid_))
+
 #endif /* nsStyleStructFwd_h_ */