Bug 1377144 - Allow <scoped style> in about:reader documents. draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 10 Jul 2017 15:09:14 +0800
changeset 606040 58bf376d3fb8b7f7b02e6293a48a9766ec4ea162
parent 606039 39f796c2d332f502369ad4750501867680878ae7
child 636651 4013e1f33b68cf3fa6f66ce6f8d32851446a1fe6
push id67578
push userbmo:cam@mcc.id.au
push dateMon, 10 Jul 2017 07:09:36 +0000
bugs1377144
milestone55.0
Bug 1377144 - Allow <scoped style> in about:reader documents. MozReview-Commit-ID: A5MAtRZNKIR
dom/base/nsDocument.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -13476,19 +13476,34 @@ 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) {
     mIsScopedStyleEnabled = nsContentUtils::IsChromeDoc(this) ||
+                            IsAboutReader(mDocumentURI) ||
                             nsContentUtils::IsScopedStylePrefEnabled()
                               ? eScopedStyle_Enabled
                               : eScopedStyle_Disabled;
   }
   return mIsScopedStyleEnabled == eScopedStyle_Enabled;
 }