Bug 1402094 - Blacklist about:reader from using stylo. r?bholley draft
authorXidorn Quan <me@upsuper.org>
Thu, 28 Sep 2017 16:19:45 +1000
changeset 671756 8dd9f4c584b0a3fb2d151ca279d7d908bae0a8f5
parent 670174 843a6354a5b238cfc2a05e4a29fb91acc17d3646
child 733601 026319ab5abafc5491bbfa0c7d69c579ad7b7b33
push id82027
push userxquan@mozilla.com
push dateThu, 28 Sep 2017 07:39:26 +0000
reviewersbholley
bugs1402094
milestone58.0a1
Bug 1402094 - Blacklist about:reader from using stylo. r?bholley MozReview-Commit-ID: 6cG1x1tcOwn
dom/base/nsDocument.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -13484,16 +13484,39 @@ nsIDocument::ReportHasScrollLinkedEffect
   }
   mHasScrollLinkedEffect = true;
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("Async Pan/Zoom"),
                                   this, nsContentUtils::eLAYOUT_PROPERTIES,
                                   "ScrollLinkedEffectFound2");
 }
 
+#ifdef MOZ_STYLO
+// URL-based blacklist for stylo.
+static bool
+ShouldUseGeckoBackend(nsIURI* aDocumentURI)
+{
+  if (!aDocumentURI) {
+    return false;
+  }
+  bool isScheme = false;
+  if (NS_SUCCEEDED(aDocumentURI->SchemeIs("about", &isScheme))) {
+    nsAutoCString path;
+    aDocumentURI->GetFilePath(path);
+    // about:reader requires support of :scope pseudo-class so we have
+    // to use Gecko backend for now. See bug 1402094.
+    // This should be fixed by bug 1204818.
+    if (path.EqualsLiteral("reader")) {
+      return true;
+    }
+  }
+  return false;
+}
+#endif // MOZ_STYLO
+
 void
 nsIDocument::UpdateStyleBackendType()
 {
   MOZ_ASSERT(mStyleBackendType == StyleBackendType::None,
              "no need to call UpdateStyleBackendType now");
 
   // Assume Gecko by default.
   mStyleBackendType = StyleBackendType::Gecko;
@@ -13502,17 +13525,17 @@ nsIDocument::UpdateStyleBackendType()
   if (nsLayoutUtils::StyloEnabled()) {
     // Disable stylo only for system principal. Other principals 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.
     // Note that, since tests can have XUL support, we still need to
     // explicitly exclude XUL documents here.
     if (!nsContentUtils::IsSystemPrincipal(NodePrincipal()) &&
-        !IsXULDocument()) {
+        !IsXULDocument() && !ShouldUseGeckoBackend(mDocumentURI)) {
       mStyleBackendType = StyleBackendType::Servo;
     }
   }
 #endif
 }
 
 /**
  * Retrieves the classification of the Flash plugins in the document based on