Bug 1202940 part 1 - Move html.css and ua.css back to be loaded in constructor of nsLayoutStylesheetCache. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Tue, 01 Dec 2015 09:39:37 +1100
changeset 274788 facc049f03419f47f32cec8f7c45a5336dc332b6
parent 274787 88256698e1a57062e15432206904e4d3d75a32be
child 274789 17a33fbe0c031193d1ed1ab7b07959a21ac18ce1
push id29739
push usercbook@mozilla.com
push dateTue, 01 Dec 2015 14:26:30 +0000
treeherdermozilla-central@974fe614d529 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1202940
milestone45.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 1202940 part 1 - Move html.css and ua.css back to be loaded in constructor of nsLayoutStylesheetCache. r=dbaron DependentPrefChanged and InvalidateSheet are no longer used anywhere, but it is probably better to keep them as-is, since we may need them again in the future.
layout/style/nsLayoutStylesheetCache.cpp
modules/libpref/init/all.js
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -123,35 +123,23 @@ nsLayoutStylesheetCache::UserChromeSheet
   EnsureGlobal();
   return gStyleCache->mUserChromeSheet;
 }
 
 CSSStyleSheet*
 nsLayoutStylesheetCache::UASheet()
 {
   EnsureGlobal();
-
-  if (!gStyleCache->mUASheet) {
-    LoadSheetURL("resource://gre-resources/ua.css",
-                 gStyleCache->mUASheet, eAgentSheetFeatures);
-  }
-
   return gStyleCache->mUASheet;
 }
 
 CSSStyleSheet*
 nsLayoutStylesheetCache::HTMLSheet()
 {
   EnsureGlobal();
-
-  if (!gStyleCache->mHTMLSheet) {
-    LoadSheetURL("resource://gre-resources/html.css",
-                 gStyleCache->mHTMLSheet, eAgentSheetFeatures);
-  }
-
   return gStyleCache->mHTMLSheet;
 }
 
 CSSStyleSheet*
 nsLayoutStylesheetCache::MinimalXULSheet()
 {
   EnsureGlobal();
   return gStyleCache->mMinimalXULSheet;
@@ -358,22 +346,26 @@ 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("resource://gre-resources/ua.css",
+               mUASheet, eAgentSheetFeatures);
   LoadSheetURL("chrome://global/content/xul.css",
                mXULSheet, eAgentSheetFeatures);
 
   // The remaining sheets are created on-demand do to their use being rarer
   // (which helps save memory for Firefox OS apps) or because they need to
   // be re-loadable in DependentPrefChanged.
 }
 
@@ -402,18 +394,18 @@ nsLayoutStylesheetCache::EnsureGlobal()
 
   Preferences::AddBoolVarCache(&sNumberControlEnabled, NUMBER_CONTROL_PREF,
                                true);
 
   // 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.ruby.enabled");
+  // Preferences::RegisterCallback(&DependentPrefChanged,
+  //                               "layout.css.example-pref.enabled");
 }
 
 void
 nsLayoutStylesheetCache::InitFromProfile()
 {
   nsCOMPtr<nsIXULRuntime> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
   if (appInfo) {
     bool inSafeMode = false;
@@ -806,20 +798,17 @@ nsLayoutStylesheetCache::InvalidateSheet
 nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData)
 {
   MOZ_ASSERT(gStyleCache, "pref changed after shutdown?");
 
   // Cause any UA style sheets whose parsing depends on the value of prefs
   // to be re-parsed by dropping the sheet from gCSSLoader's cache then
   // setting our cached sheet pointer to null.  This will only work for sheets
   // that are loaded lazily.
-
-  // for layout.css.ruby.enabled
-  InvalidateSheet(gStyleCache->mUASheet);
-  InvalidateSheet(gStyleCache->mHTMLSheet);
+  // InvalidateSheet(gStyleCache->mSomeLazilyLoadedSheet);
 }
 
 /* static */ void
 nsLayoutStylesheetCache::InvalidatePreferenceSheets()
 {
   if (!gStyleCache) {
     return;
   }
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2380,21 +2380,16 @@ pref("layout.css.grid.enabled", true);
 
 // Is support for CSS "grid-template-{columns,rows}: subgrid X" enabled?
 pref("layout.css.grid-template-subgrid-value.enabled", false);
 
 // Is support for CSS contain enabled?
 pref("layout.css.contain.enabled", false);
 
 // Is support for CSS Ruby enabled?
-//
-// When this pref is removed, make sure that the pref callback registration
-// in nsLayoutStylesheetCache::EnsureGlobal and the invalidation of
-// mUASheet in nsLayoutStylesheetCache::DependentPrefChanged (if it's not
-// otherwise needed) are removed.
 pref("layout.css.ruby.enabled", true);
 
 // Is support for CSS display:contents enabled?
 pref("layout.css.display-contents.enabled", true);
 
 // Is support for CSS box-decoration-break enabled?
 pref("layout.css.box-decoration-break.enabled", true);