Bug 444237 - "Crash with -moz-box-shadow: -moz-initial on input" [p=ventnor.bugzilla@gmail.com (Michael Ventnor) r+sr=dbaron]
authorMichael Ventnor <ventnor.bugzilla@gmail.com>
Sat, 12 Jul 2008 03:52:32 -0500
changeset 15842 31f5da857994a4ba91afe90777cad532ab37fa0b
parent 15840 cdc93a0afd5e93d4b836d0e01e85c71f0d31795f
child 15843 b07c8fd4bd2659e5f4be9887324ee89d227fee4f
push idunknown
push userunknown
push dateunknown
bugs444237
milestone1.9.1a1pre
Bug 444237 - "Crash with -moz-box-shadow: -moz-initial on input" [p=ventnor.bugzilla@gmail.com (Michael Ventnor) r+sr=dbaron]
layout/style/crashtests/444237-1.html
layout/style/crashtests/crashtests.list
layout/style/nsRuleNode.cpp
new file mode 100644
--- /dev/null
+++ b/layout/style/crashtests/444237-1.html
@@ -0,0 +1,1 @@
+<input style="-moz-box-shadow: -moz-initial;">
--- a/layout/style/crashtests/crashtests.list
+++ b/layout/style/crashtests/crashtests.list
@@ -8,9 +8,10 @@ load 383979-2.html
 load 386939-1.html
 load 391034-1.xhtml
 load 397022-1.html
 load 399289-1.svg
 load 404470-1.html
 load 411603-1.html
 load 413274-1.xhtml
 load 437170-1.html
+load 444237-1.html
 load 444848-1.html 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1205,16 +1205,20 @@ nsRuleNode::GetColorData(nsStyleContext*
 
 const void*
 nsRuleNode::GetBackgroundData(nsStyleContext* aContext)
 {
   nsRuleDataColor colorData; // Declare a struct with null CSS values.
   nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Background), mPresContext, aContext);
   ruleData.mColorData = &colorData;
 
+  // If any members need to be set to null here, they must also be set to
+  // null in HasAuthorSpecifiedRules (look at mBoxShadow in GetBorderData
+  // and HasAuthorSpecifiedRules).
+
   return WalkRuleTree(eStyleStruct_Background, aContext, &ruleData, &colorData);
 }
 
 const void*
 nsRuleNode::GetMarginData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
   nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Margin), mPresContext, aContext);
@@ -1226,27 +1230,33 @@ nsRuleNode::GetMarginData(nsStyleContext
 const void*
 nsRuleNode::GetBorderData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
   nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Border), mPresContext, aContext);
   ruleData.mMarginData = &marginData;
 
   const void* res = WalkRuleTree(eStyleStruct_Border, aContext, &ruleData, &marginData);
-  marginData.mBoxShadow = nsnull; // We are sharing with some style rule.  It really owns the data.
+  // We are sharing with some style rule.  It really owns the data.
+  // This nulling must also happen in HasAuthorSpecifiedRules.
+  marginData.mBoxShadow = nsnull;
   return res;
 }
 
 const void*
 nsRuleNode::GetPaddingData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
   nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Padding), mPresContext, aContext);
   ruleData.mMarginData = &marginData;
 
+  // If any members need to be set to null here, they must also be set to
+  // null in HasAuthorSpecifiedRules (look at mBoxShadow in GetBorderData
+  // and HasAuthorSpecifiedRules).
+
   return WalkRuleTree(eStyleStruct_Padding, aContext, &ruleData, &marginData);
 }
 
 const void*
 nsRuleNode::GetOutlineData(nsStyleContext* aContext)
 {
   nsRuleDataMargin marginData; // Declare a struct with null CSS values.
   nsRuleData ruleData(NS_STYLE_INHERIT_BIT(Outline), mPresContext, aContext);
@@ -5334,16 +5344,21 @@ nsRuleNode::HasAuthorSpecifiedRules(nsSt
   // user-important or UA-important declarations.
   for (nsRuleNode* ruleNode = aStyleContext->GetRuleNode(); ruleNode;
        ruleNode = ruleNode->GetParent()) {
     nsIStyleRule *rule = ruleNode->GetRule();
     if (rule) {
       ruleData.mLevel = ruleNode->GetLevel();
       ruleData.mIsImportantRule = ruleNode->IsImportantRule();
       rule->MapRuleInfoInto(&ruleData);
+      // Do the same nulling out as in GetBorderData, GetBackgroundData
+      // or GetPaddingData.
+      // We are sharing with some style rule.  It really owns the data.
+      marginData.mBoxShadow = nsnull;
+
       if (ruleData.mLevel == nsStyleSet::eAgentSheet ||
           ruleData.mLevel == nsStyleSet::eUserSheet) {
         // This is a rule whose effect we want to ignore, so if any of
         // the properties we care about were set, set them to the dummy
         // value that they'll never otherwise get.
         for (PRUint32 i = 0; i < nValues; ++i)
           if (values[i]->GetUnit() != eCSSUnit_Null)
             values[i]->SetDummyValue();