Bug 1406274 - Re-enable stylo in about:reader. r?xidorn
Remove the about:reader check for <style scoped>, too, since that is no
longer needed.
MozReview-Commit-ID: Zomjn1WDvp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -13150,17 +13150,17 @@ nsIDocument::UpdateStyleBackendType()
MOZ_ASSERT(mStyleBackendType == StyleBackendType::None,
"no need to call UpdateStyleBackendType now");
// Assume Gecko by default.
mStyleBackendType = StyleBackendType::Gecko;
#ifdef MOZ_STYLO
if (nsLayoutUtils::StyloEnabled() &&
- nsLayoutUtils::ShouldUseStylo(mDocumentURI, NodePrincipal())) {
+ nsLayoutUtils::ShouldUseStylo(NodePrincipal())) {
mStyleBackendType = StyleBackendType::Servo;
}
#endif
}
void
nsIDocument::SetUserHasInteracted(bool aUserHasInteracted)
{
@@ -13814,40 +13814,21 @@ nsDocument::IsThirdParty()
return mIsThirdParty.value();
}
// Fall-through. Document is not a Third-Party Document.
mIsThirdParty.emplace(false);
return mIsThirdParty.value();
}
-static bool
-IsAboutReader(nsIURI* aURI)
-{
- if (!aURI) {
- return false;
- }
-
- nsCString spec;
- aURI->GetSpec(spec);
-
- // Reader mode URLs look like about:reader?[...].
- return StringBeginsWith(spec, NS_LITERAL_CSTRING("about:reader"));
-}
-
bool
nsIDocument::IsScopedStyleEnabled()
{
if (mIsScopedStyleEnabled == eScopedStyle_Unknown) {
- // We allow <style scoped> in about:reader pages since on Android
- // we use it to inject some in-page UI. (We currently don't
- // support styling about:reader pages in stylo anyway, so for
- // now it's OK to enable it here.)
mIsScopedStyleEnabled = nsContentUtils::IsChromeDoc(this) ||
- IsAboutReader(mDocumentURI) ||
nsContentUtils::IsScopedStylePrefEnabled()
? eScopedStyle_Enabled
: eScopedStyle_Disabled;
}
return mIsScopedStyleEnabled == eScopedStyle_Enabled;
}
void
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -2264,17 +2264,17 @@ nsXULPrototypeElement::SetAttrAt(uint32_
mNodeInfo->NodeInfoManager()->DocumentPrincipal();
// XXX Get correct Base URI (need GetBaseURI on *prototype* element)
// TODO: If we implement Content Security Policy for chrome documents
// as has been discussed, the CSP should be checked here to see if
// inline styles are allowed to be applied.
RefPtr<DeclarationBlock> declaration;
if (nsLayoutUtils::StyloEnabled() &&
- nsLayoutUtils::ShouldUseStylo(aDocumentURI, principal)) {
+ nsLayoutUtils::ShouldUseStylo(principal)) {
RefPtr<URLExtraData> data =
new URLExtraData(aDocumentURI, aDocumentURI, principal);
declaration = ServoDeclarationBlock::FromCssText(
aValue, data, eCompatibility_FullStandards, nullptr);
} else {
nsCSSParser parser;
declaration = parser.ParseStyleAttribute(aValue, aDocumentURI,
aDocumentURI, principal);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8276,40 +8276,26 @@ nsLayoutUtils::Shutdown()
// so the cached initial quotes array doesn't appear to be a leak
nsStyleList::Shutdown();
}
#ifdef MOZ_STYLO
/* static */
bool
-nsLayoutUtils::ShouldUseStylo(nsIURI* aDocumentURI, nsIPrincipal* aPrincipal)
+nsLayoutUtils::ShouldUseStylo(nsIPrincipal* aPrincipal)
{
// Disable stylo for system principal because XUL hasn't been fully
// supported. Other principal aren't able to use XUL by default, and
// the back door to enable XUL is mostly just for testing, which means
// they don't matter, and we shouldn't respect them at the same time.
if (!StyloChromeEnabled() &&
nsContentUtils::IsSystemPrincipal(aPrincipal)) {
return false;
}
- // Check any internal page which we need to explicitly blacklist.
- if (aDocumentURI) {
- bool isAbout = false;
- if (NS_SUCCEEDED(aDocumentURI->SchemeIs("about", &isAbout)) && isAbout) {
- nsAutoCString path;
- aDocumentURI->GetFilePath(path);
- // 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 */
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2577,20 +2577,19 @@ public:
return sInvalidationDebuggingIsEnabled || getenv("MOZ_DUMP_INVALIDATION") != 0;
}
static void Initialize();
static void Shutdown();
#ifdef MOZ_STYLO
/**
- * Return whether stylo should be used for a given document URI and
- * principal.
+ * Return whether stylo should be used for a given document principal.
*/
- static bool ShouldUseStylo(nsIURI* aDocumentURI, nsIPrincipal* aPrincipal);
+ 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.
*/
@@ -2605,17 +2604,17 @@ public:
/**
* Remove aBlockedDomain from the existing stylo blocklist, i.e., sStyloBlocklist.
* This function is exposed to nsDOMWindowUtils and only for testing purpose.
* So, NEVER use this in any other cases.
*/
static void RemoveFromStyloBlocklist(const nsACString& aBlockedDomain);
#else
- static bool ShouldUseStylo(nsIURI* aDocumentURI, nsIPrincipal* aPrincipal) {
+ static bool ShouldUseStylo(nsIPrincipal* aPrincipal) {
return false;
}
#endif
/**
* Register an imgIRequest object with a refresh driver.
*
* @param aPresContext The nsPresContext whose refresh driver we want to