WeightEnumData  weight(styleRule->GetWeight()); data->mRules->EnumerateForwards(FindEndOfWeight, &weight);  data->mRules->InsertElementAt(styleRule, weight.mIndex);
PRInt32 weight = styleRule->GetWeight(); nsWeightKey key(weight); nsCOMPtr<nsISupportsArray> rules(dont_AddRef( NS_STATIC_CAST(nsISupportsArray*, data->mRuleArrays.Get(&key)))); if (!rules) { NS_NewISupportsArray(getter_AddRefs(rules)); if (!rules) return PR_FALSE; data->mRuleArrays.Put(&key, rules); } rules->AppendElement(styleRule);
InsertRuleByWeight(nsISupports* aRule, void* aData){  nsICSSRule* rule = (nsICSSRule*)aRule;  CascadeEnumData* data = (CascadeEnumData*)aData;  PRInt32 type;  rule->GetType(type);  if (nsICSSRule::STYLE_RULE == type) {    nsICSSStyleRule* styleRule = (nsICSSStyleRule*)rule;    WeightEnumData  weight(styleRule->GetWeight());    data->mRules->EnumerateForwards(FindEndOfWeight, &weight);    data->mRules->InsertElementAt(styleRule, weight.mIndex);  }  else if (nsICSSRule::MEDIA_RULE == type) {    nsICSSMediaRule* mediaRule = (nsICSSMediaRule*)rule;    if (NS_OK == mediaRule->UseForMedium(data->mMedium)) {      mediaRule->EnumerateRulesForwards(InsertRuleByWeight, aData);    }  }  return PR_TRUE;}