From 8d7d5e5ea586b4104c38f5e42a36bb4f30290bfe Mon Sep 17 00:00:00 2001 From: Jeremy Chen Date: Sat, 27 Jan 2018 17:52:53 +0800 Subject: [PATCH] Bug 1426223 - remove Stylo domain blocklist mechanism. r=xidorn MozReview-Commit-ID: 2Kcla56H3wJ --- dom/ipc/ContentPrefs.cpp | 4 --- layout/base/nsLayoutUtils.cpp | 65 ++--------------------------------- layout/base/nsLayoutUtils.h | 11 ------ modules/libpref/init/all.js | 3 -- 4 files changed, 2 insertions(+), 81 deletions(-) diff --git a/dom/ipc/ContentPrefs.cpp b/dom/ipc/ContentPrefs.cpp index 45e9f505e05d..a5dbfed1a37d 100644 --- a/dom/ipc/ContentPrefs.cpp +++ b/dom/ipc/ContentPrefs.cpp @@ -178,10 +178,6 @@ const char* mozilla::dom::ContentPrefs::gEarlyPrefs[] = { "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", diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 7d154cc312a7..3c4012e26752 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -129,7 +129,6 @@ #include "DisplayListChecker.h" #include "TextDrawTarget.h" #include "nsDeckFrame.h" -#include "nsIEffectiveTLDService.h" // for IsInStyloBlocklist #include "mozilla/StylePrefs.h" #include "mozilla/dom/InspectorFontFace.h" @@ -196,8 +195,6 @@ typedef nsStyleTransformMatrix::TransformReferenceBox TransformReferenceBox; /* static */ bool nsLayoutUtils::sTextCombineUprightDigitsEnabled; #ifdef MOZ_STYLO /* static */ bool nsLayoutUtils::sStyloEnabled; -/* static */ bool nsLayoutUtils::sStyloBlocklistEnabled; -/* static */ nsTArray* nsLayoutUtils::sStyloBlocklist = nullptr; #endif /* static */ uint32_t nsLayoutUtils::sIdlePeriodDeadlineLimit; /* static */ uint32_t nsLayoutUtils::sQuiescentFramesBeforeIdlePeriod; @@ -8231,24 +8228,6 @@ nsLayoutUtils::Initialize() 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; - for (const nsACString& domainString : blocklist.Split(',')) { - sStyloBlocklist->AppendElement(domainString); - } - } - } #endif Preferences::AddUintVarCache(&sIdlePeriodDeadlineLimit, "layout.idle_period.time_limit", @@ -8271,13 +8250,7 @@ nsLayoutUtils::Shutdown() 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); } @@ -8300,44 +8273,10 @@ nsLayoutUtils::ShouldUseStylo(nsIPrincipal* aPrincipal) nsContentUtils::IsSystemPrincipal(aPrincipal)) { 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 codebaseURI; - aPrincipal->GetURI(getter_AddRefs(codebaseURI)); - if (!codebaseURI) { - return false; - } - - nsCOMPtr 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() diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index b851a6c56ea6..2f844ce6fe18 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -2585,15 +2585,6 @@ public: * Return whether stylo should be used for a given document principal. */ static bool ShouldUseStylo(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(nsIPrincipal* aPrincipal) { return false; @@ -3119,8 +3110,6 @@ private: static bool sTextCombineUprightDigitsEnabled; #ifdef MOZ_STYLO static bool sStyloEnabled; - static bool sStyloBlocklistEnabled; - static nsTArray* sStyloBlocklist; #endif static uint32_t sIdlePeriodDeadlineLimit; static uint32_t sQuiescentFramesBeforeIdlePeriod; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 19e05cf6c111..b7cac0ac8578 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -5804,9 +5804,6 @@ 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