Bug 1334330 - Part 10: stylo: Use GenericSpecifiedValue abstraction for <body>; r?emilio draft
authorManish Goregaokar <manishearth@gmail.com>
Thu, 26 Jan 2017 16:51:01 -0800
changeset 480665 bdf7251100c9455bd23bd7eb3337f21106c35dcb
parent 480664 89debdadc27470674fc910ff91bf8e72db05ab9f
child 480666 195024e0108c3b80a346f8dcdac88887b8c6748b
push id44619
push userbmo:manishearth@gmail.com
push dateWed, 08 Feb 2017 19:34:01 +0000
reviewersemilio
bugs1334330
milestone54.0a1
Bug 1334330 - Part 10: stylo: Use GenericSpecifiedValue abstraction for <body>; r?emilio MozReview-Commit-ID: 8yGWs2uOjES
dom/html/HTMLBodyElement.cpp
--- a/dom/html/HTMLBodyElement.cpp
+++ b/dom/html/HTMLBodyElement.cpp
@@ -355,22 +355,21 @@ HTMLBodyElement::UnbindFromTree(bool aDe
     mContentStyleRule = nullptr;
   }
 
   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);  
 }
 
 void
 HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
-                                       GenericSpecifiedValues* aGenericData)
+                                       GenericSpecifiedValues* aData)
 {
-  nsRuleData* aData = aGenericData->AsRuleData();
-  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
+  if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
     // When display if first asked for, go ahead and get our colors set up.
-    nsIPresShell *presShell = aData->mPresContext->GetPresShell();
+    nsIPresShell *presShell = aData->PresContext()->GetPresShell();
     if (presShell) {
       nsIDocument *doc = presShell->GetDocument();
       if (doc) {
         nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
         if (styleSheet) {
           const nsAttrValue* value;
           nscolor color;
           value = aAttributes->GetAttr(nsGkAtoms::link);
@@ -387,30 +386,29 @@ HTMLBodyElement::MapAttributesIntoRule(c
           if (value && value->GetColorValue(color)) {
             styleSheet->SetVisitedLinkColor(color);
           }
         }
       }
     }
   }
 
-  if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
-    nsCSSValue *colorValue = aData->ValueForColor();
-    if (colorValue->GetUnit() == eCSSUnit_Null &&
-        aData->mPresContext->UseDocumentColors()) {
+  if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Color))) {
+    if (!aData->PropertyIsSet(eCSSProperty_color) &&
+        aData->PresContext()->UseDocumentColors()) {
       // color: color
       nscolor color;
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
       if (value && value->GetColorValue(color))
-        colorValue->SetColorValue(color);
+        aData->SetColorValue(eCSSProperty_color, color);
     }
   }
 
-  nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aGenericData);
-  nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aGenericData);
+  nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
+  nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
 }
 
 nsMapRuleToAttributesFunc
 HTMLBodyElement::GetAttributeMappingFunction() const
 {
   return &MapAttributesIntoRule;
 }