Bug 1426223 - remove Stylo domain blocklist mechanism. draft
authorJeremy Chen <jeremychen@mozilla.com>
Sat, 27 Jan 2018 17:52:53 +0800
changeset 748036 cd6b3cbc75d9879d9fd82f5fc3bc963616ccab85
parent 748035 b3b4eebc02394894b95e551d94b12bf74ae488c1
push id97052
push userbmo:chenpighead@gmail.com
push dateSat, 27 Jan 2018 13:49:09 +0000
bugs1426223
milestone60.0a1
Bug 1426223 - remove Stylo domain blocklist mechanism. MozReview-Commit-ID: 2Kcla56H3wJ
dom/ipc/ContentPrefs.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
modules/libpref/init/all.js
--- a/dom/ipc/ContentPrefs.cpp
+++ b/dom/ipc/ContentPrefs.cpp
@@ -173,20 +173,16 @@ const char* mozilla::dom::ContentPrefs::
   "layout.css.scoped-style.enabled",
   "layout.css.scroll-behavior.property-enabled",
   "layout.css.scroll-snap.enabled",
 #ifdef MOZ_STYLO
   "layout.css.servo.chrome.enabled",
   "layout.css.servo.enabled",
 #endif
   "layout.css.shape-outside.enabled",
-#ifdef MOZ_STYLO
-  "layout.css.stylo-blocklist.blocked_domains",
-  "layout.css.stylo-blocklist.enabled",
-#endif
   "layout.css.text-align-unsafe-value.enabled",
   "layout.css.text-combine-upright-digits.enabled",
   "layout.css.text-combine-upright.enabled",
   "layout.css.text-justify.enabled",
   "layout.css.touch_action.enabled",
   "layout.css.visited_links_enabled",
   "layout.idle_period.required_quiescent_frames",
   "layout.idle_period.time_limit",
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -125,17 +125,16 @@
 #include "DisplayItemClip.h"
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "prenv.h"
 #include "RetainedDisplayListBuilder.h"
 #include "DisplayListChecker.h"
 #include "TextDrawTarget.h"
 #include "nsDeckFrame.h"
-#include "nsIEffectiveTLDService.h" // for IsInStyloBlocklist
 #include "mozilla/StylePrefs.h"
 #include "mozilla/dom/InspectorFontFace.h"
 
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
 #endif
 
 #include "GeckoProfiler.h"
@@ -192,18 +191,16 @@ typedef nsStyleTransformMatrix::Transfor
 /* static */ uint32_t nsLayoutUtils::sZoomMaxPercent;
 /* static */ uint32_t nsLayoutUtils::sZoomMinPercent;
 /* static */ bool nsLayoutUtils::sInvalidationDebuggingIsEnabled;
 /* static */ bool nsLayoutUtils::sInterruptibleReflowEnabled;
 /* static */ bool nsLayoutUtils::sSVGTransformBoxEnabled;
 /* static */ bool nsLayoutUtils::sTextCombineUprightDigitsEnabled;
 #ifdef MOZ_STYLO
 /* static */ bool nsLayoutUtils::sStyloEnabled;
-/* static */ bool nsLayoutUtils::sStyloBlocklistEnabled;
-/* static */ nsTArray<nsCString>* nsLayoutUtils::sStyloBlocklist = nullptr;
 #endif
 /* static */ uint32_t nsLayoutUtils::sIdlePeriodDeadlineLimit;
 /* static */ uint32_t nsLayoutUtils::sQuiescentFramesBeforeIdlePeriod;
 
 static ViewID sScrollIdCounter = FrameMetrics::START_SCROLL_ID;
 
 typedef nsDataHashtable<nsUint64HashKey, nsIContent*> ContentMap;
 static ContentMap* sContentMap = nullptr;
@@ -8232,34 +8229,16 @@ nsLayoutUtils::Initialize()
   if (PR_GetEnv("STYLO_FORCE_ENABLED")) {
     sStyloEnabled = true;
   } else if (PR_GetEnv("STYLO_FORCE_DISABLED")) {
     sStyloEnabled = false;
   } else {
     Preferences::AddBoolVarCache(&sStyloEnabled,
                                  "layout.css.servo.enabled");
   }
-  // We should only create the blocklist ONCE, and ignore any blocklist
-  // reloads happen. Because otherwise we could have a top level page that
-  // uses Stylo (if its load happens before the blocklist reload) and a
-  // child iframe that uses Gecko (if its load happens after the blocklist
-  // reload). If some page contains both backends, and they try to move
-  // element across backend boundary, it could crash (see bug 1404020).
-  sStyloBlocklistEnabled =
-    Preferences::GetBool("layout.css.stylo-blocklist.enabled");
-  if (sStyloBlocklistEnabled && !sStyloBlocklist) {
-    nsAutoCString blocklist;
-    Preferences::GetCString("layout.css.stylo-blocklist.blocked_domains", blocklist);
-    if (!blocklist.IsEmpty()) {
-      sStyloBlocklist = new nsTArray<nsCString>;
-      for (const nsACString& domainString : blocklist.Split(',')) {
-        sStyloBlocklist->AppendElement(domainString);
-      }
-    }
-  }
 #endif
   Preferences::AddUintVarCache(&sIdlePeriodDeadlineLimit,
                                "layout.idle_period.time_limit",
                                DEFAULT_IDLE_PERIOD_TIME_LIMIT);
   Preferences::AddUintVarCache(&sQuiescentFramesBeforeIdlePeriod,
                                "layout.idle_period.required_quiescent_frames",
                                DEFAULT_QUIESCENT_FRAMES);
 
@@ -8272,23 +8251,17 @@ nsLayoutUtils::Initialize()
 /* static */
 void
 nsLayoutUtils::Shutdown()
 {
   if (sContentMap) {
     delete sContentMap;
     sContentMap = nullptr;
   }
-#ifdef MOZ_STYLO
-  if (sStyloBlocklist) {
-    sStyloBlocklist->Clear();
-    delete sStyloBlocklist;
-    sStyloBlocklist = nullptr;
-  }
-#endif
+
   for (auto& callback : kPrefCallbacks) {
     Preferences::UnregisterCallback(callback.func, callback.name);
   }
   nsComputedDOMStyle::UnregisterPrefChangeCallbacks();
 
   // so the cached initial quotes array doesn't appear to be a leak
   nsStyleList::Shutdown();
 }
@@ -8315,56 +8288,22 @@ nsLayoutUtils::ShouldUseStylo(nsIURI* aD
       // about:reader requires support of scoped style, so we have to
       // use Gecko backend for now. See bug 1402094.
       // This should be fixed by bug 1204818.
       if (path.EqualsLiteral("reader")) {
         return false;
       }
     }
   }
-  // Check the stylo block list.
-  if (IsInStyloBlocklist(aPrincipal)) {
-    return false;
-  }
+
   return true;
 }
 
 /* static */
 bool
-nsLayoutUtils::IsInStyloBlocklist(nsIPrincipal* aPrincipal)
-{
-  if (!sStyloBlocklist) {
-    return false;
-  }
-
-  // Note that a non-codebase principal (eg the system principal) will return
-  // a null URI.
-  nsCOMPtr<nsIURI> codebaseURI;
-  aPrincipal->GetURI(getter_AddRefs(codebaseURI));
-  if (!codebaseURI) {
-    return false;
-  }
-
-  nsCOMPtr<nsIEffectiveTLDService> tldService =
-    do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(tldService, false);
-
-  // Check if a document's eTLD+1 domain belongs to one of the stylo blocklist.
-  nsAutoCString baseDomain;
-  NS_SUCCEEDED(tldService->GetBaseDomain(codebaseURI, 0, baseDomain));
-  for (const nsCString& domains : *sStyloBlocklist) {
-    if (baseDomain.Equals(domains)) {
-      return true;
-    }
-  }
-  return false;
-}
-
-/* static */
-bool
 nsLayoutUtils::StyloChromeEnabled()
 {
   static bool sInitialized = false;
   static bool sEnabled = false;
   if (!sInitialized) {
     // We intentionally don't allow dynamic toggling of this pref
     // because it is rather risky to mix style backend in XUL.
     sEnabled = Preferences::GetBool("layout.css.servo.chrome.enabled");
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2581,25 +2581,16 @@ public:
   static void Shutdown();
 
 #ifdef MOZ_STYLO
   /**
    * Return whether stylo should be used for a given document URI and
    * principal.
    */
   static bool ShouldUseStylo(nsIURI* aDocumentURI, nsIPrincipal* aPrincipal);
-
-  /**
-   * Principal-based blocklist for stylo.
-   * Check if aPrincipal is blocked by stylo's blocklist and should fallback to
-   * use Gecko's style backend. Note that using a document's principal rather
-   * than the document URI will let us piggy-back off the existing principal
-   * relationships and symmetries.
-   */
-  static bool IsInStyloBlocklist(nsIPrincipal* aPrincipal);
 #else
   static bool ShouldUseStylo(nsIURI* aDocumentURI, nsIPrincipal* aPrincipal) {
     return false;
   }
 #endif
 
   /**
    * Register an imgIRequest object with a refresh driver.
@@ -3115,18 +3106,16 @@ private:
   static uint32_t sZoomMaxPercent;
   static uint32_t sZoomMinPercent;
   static bool sInvalidationDebuggingIsEnabled;
   static bool sInterruptibleReflowEnabled;
   static bool sSVGTransformBoxEnabled;
   static bool sTextCombineUprightDigitsEnabled;
 #ifdef MOZ_STYLO
   static bool sStyloEnabled;
-  static bool sStyloBlocklistEnabled;
-  static nsTArray<nsCString>* sStyloBlocklist;
 #endif
   static uint32_t sIdlePeriodDeadlineLimit;
   static uint32_t sQuiescentFramesBeforeIdlePeriod;
 
   /**
    * Helper function for LogTestDataForPaint().
    */
   static void DoLogTestDataForPaint(mozilla::layers::LayerManager* aManager,
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5799,19 +5799,16 @@ pref("dom.webkitBlink.dirPicker.enabled"
 pref("dom.webkitBlink.filesystem.enabled", true);
 #endif
 
 pref("media.block-autoplay-until-in-foreground", true);
 
 // Is Stylo CSS support built and enabled?
 // Only define these prefs if Stylo support is actually built in.
 #ifdef MOZ_STYLO
-// XXX: We should flip this pref to true once the blocked_domains is non-empty.
-pref("layout.css.stylo-blocklist.enabled", false);
-pref("layout.css.stylo-blocklist.blocked_domains", "");
 #ifdef MOZ_STYLO_ENABLE
 pref("layout.css.servo.enabled", true);
 #else
 pref("layout.css.servo.enabled", false);
 #endif
 // Whether Stylo is enabled for chrome document?
 // If Stylo is not enabled, this pref doesn't take any effect.
 // Note that this pref is only read once when requested. Changing it