Bug 1259889 Part 2 - Load html.css lazily for pref changes. r=heycam
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 01 Apr 2016 21:11:11 +0800
changeset 291469 30aaf3805b5682774b3053528c3e675c73967b0b
parent 291468 6559f99e1805147da0fb0c56e52a09397d36cc3b
child 291470 ffcc3708103af5c20a727bee63ef1b302a1f59b7
child 291476 9bd90088875399347b05d87c67d3709e31539dcd
push id74580
push usertlin@mozilla.com
push dateMon, 04 Apr 2016 03:59:09 +0000
treeherdermozilla-inbound@30aaf3805b56 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1259889
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1259889 Part 2 - Load html.css lazily for pref changes. r=heycam 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;