Bug 1259889 Part 2 - Load html.css lazily for pref changes. draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 01 Apr 2016 21:11:11 +0800
changeset 346571 732b17a044551b89c28eed31dfb7901aa431546a
parent 346570 3d660ede7f7694ddef20b54bbd7df7e7c45bbc2f
child 517482 9e884f9a721ffc00e0cdfe4a3b50849b53dc3417
push id14418
push usertlin@mozilla.com
push dateFri, 01 Apr 2016 13:12:11 +0000
bugs1259889
milestone48.0a1
Bug 1259889 Part 2 - Load html.css lazily for pref changes. We need to re-evaluate html.css whenever "dom.details_element.enabled" is changed to make the disclosure triangle for summary elements show up. Reftests for details and summary will need the a live pref to work. MozReview-Commit-ID: 9SN1fQBuwA7
layout/style/nsLayoutStylesheetCache.cpp
layout/style/res/html.css
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -129,16 +129,21 @@ nsLayoutStylesheetCache::UASheet()
   }
 
   return mUASheet;
 }
 
 StyleSheetHandle
 nsLayoutStylesheetCache::HTMLSheet()
 {
+  if (!mHTMLSheet) {
+    LoadSheetURL("resource://gre-resources/html.css",
+                 mHTMLSheet, eAgentSheetFeatures);
+  }
+
   return mHTMLSheet;
 }
 
 StyleSheetHandle
 nsLayoutStylesheetCache::MinimalXULSheet()
 {
   return mMinimalXULSheet;
 }
@@ -314,18 +319,16 @@ nsLayoutStylesheetCache::nsLayoutStylesh
   }
 
   InitFromProfile();
 
   // And make sure that we load our UA sheets.  No need to do this
   // per-profile, since they're profile-invariant.
   LoadSheetURL("resource://gre-resources/counterstyles.css",
                mCounterStylesSheet, eAgentSheetFeatures);
-  LoadSheetURL("resource://gre-resources/html.css",
-               mHTMLSheet, eAgentSheetFeatures);
   LoadSheetURL("chrome://global/content/minimal-xul.css",
                mMinimalXULSheet, eAgentSheetFeatures);
   LoadSheetURL("resource://gre-resources/quirk.css",
                mQuirkSheet, eAgentSheetFeatures);
   LoadSheetURL("resource://gre/res/svg.css",
                mSVGSheet, eAgentSheetFeatures);
   LoadSheetURL("chrome://global/content/xul.css",
                mXULSheet, eAgentSheetFeatures);
@@ -370,16 +373,18 @@ nsLayoutStylesheetCache::For(StyleBacken
     // For each pref that controls a CSS feature that a UA style sheet depends
     // on (such as a pref that enables a property that a UA style sheet uses),
     // register DependentPrefChanged as a callback to ensure that the relevant
     // style sheets will be re-parsed.
     // Preferences::RegisterCallback(&DependentPrefChanged,
     //                               "layout.css.example-pref.enabled");
     Preferences::RegisterCallback(&DependentPrefChanged,
                                   "layout.css.grid.enabled");
+    Preferences::RegisterCallback(&DependentPrefChanged,
+                                  "dom.details_element.enabled");
   }
 
   return cache;
 }
 
 void
 nsLayoutStylesheetCache::InitFromProfile()
 {
@@ -813,16 +818,17 @@ nsLayoutStylesheetCache::DependentPrefCh
   // then setting our cached sheet pointer to null.  This will only work for
   // sheets that are loaded lazily.
 
 #define INVALIDATE(sheet_) \
   InvalidateSheet(gStyleCache_Gecko ? &gStyleCache_Gecko->sheet_ : nullptr, \
                   gStyleCache_Servo ? &gStyleCache_Servo->sheet_ : nullptr);
 
   INVALIDATE(mUASheet);  // for layout.css.grid.enabled
+  INVALIDATE(mHTMLSheet); // for dom.details_element.enabled
 
 #undef INVALIDATE
 }
 
 /* static */ void
 nsLayoutStylesheetCache::InvalidatePreferenceSheets()
 {
   if (gStyleCache_Gecko) {
--- a/layout/style/res/html.css
+++ b/layout/style/res/html.css
@@ -766,23 +766,25 @@ audio:not([controls]) {
 }
 
 video > .caption-box {
   position: relative;
   overflow: hidden;
 }
 
 /* details & summary */
+/* Need to revert Bug 1259889 Part 2 when removing details preference. */
+@supports -moz-bool-pref("dom.details_element.enabled") {
+  details > summary::-moz-list-bullet {
+    list-style-type: disclosure-closed;
+  }
 
-details > summary::-moz-list-bullet {
-  list-style-type: disclosure-closed;
-}
-
-details[open] > summary::-moz-list-bullet {
-  list-style-type: disclosure-open;
+  details[open] > summary::-moz-list-bullet {
+    list-style-type: disclosure-open;
+  }
 }
 
 /* emulation of non-standard HTML <marquee> tag */
 marquee {
   inline-size: -moz-available;
   display: inline-block;
   vertical-align: text-bottom;
   text-align: start;