Bug 1426234 part 1. Fix preexisting bug where disabling prefetch/preload would turn off HTTP Link headers for stylesheets. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 21 Dec 2017 16:43:24 -0500
changeset 397177 fca3912d10770f4720ab286013ad650370860ac2
parent 397176 ea133532d0535f40717f177e9eef93b1ed39c77e
child 397178 2569ef6ea5260dcefdae96fa8892229809cf5082
push id98488
push userbzbarsky@mozilla.com
push dateThu, 21 Dec 2017 21:44:07 +0000
treeherdermozilla-inbound@55bd77a4e5bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1426234
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1426234 part 1. Fix preexisting bug where disabling prefetch/preload would turn off HTTP Link headers for stylesheets. r=mystor MozReview-Commit-ID: 6FcW21tODIZ
dom/base/nsContentSink.cpp
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -717,41 +717,39 @@ nsContentSink::ProcessLink(const nsAStri
   // The link relation may apply to a different resource, specified
   // in the anchor parameter. For the link relations supported so far,
   // we simply abort if the link applies to a resource different to the
   // one we've loaded
   if (!LinkContextIsOurDocument(aAnchor)) {
     return NS_OK;
   }
 
-  if (!nsContentUtils::PrefetchPreloadEnabled(mDocShell)) {
-    return NS_OK;
-  }
-
-  // prefetch href if relation is "next" or "prefetch"
-  if ((linkTypes & nsStyleLinkElement::eNEXT) ||
-      (linkTypes & nsStyleLinkElement::ePREFETCH) ||
-      (linkTypes & nsStyleLinkElement::ePRELOAD)) {
-    PrefetchPreloadHref(aHref, mDocument, linkTypes, aAs, aType, aMedia);
-  }
+  if (nsContentUtils::PrefetchPreloadEnabled(mDocShell)) {
+    // prefetch href if relation is "next" or "prefetch"
+    if ((linkTypes & nsStyleLinkElement::eNEXT) ||
+        (linkTypes & nsStyleLinkElement::ePREFETCH) ||
+        (linkTypes & nsStyleLinkElement::ePRELOAD)) {
+      PrefetchPreloadHref(aHref, mDocument, linkTypes, aAs, aType, aMedia);
+    }
 
-  if (linkTypes & nsStyleLinkElement::ePRERENDER) {
-    nsCOMPtr<nsIURI> href;
-    nsresult rv = NS_NewURI(getter_AddRefs(href), aHref);
-    if (NS_SUCCEEDED(rv)) {
-      mDocument->PrerenderHref(href);
+    if (linkTypes & nsStyleLinkElement::ePRERENDER) {
+      nsCOMPtr<nsIURI> href;
+      nsresult rv = NS_NewURI(getter_AddRefs(href), aHref);
+      if (NS_SUCCEEDED(rv)) {
+        mDocument->PrerenderHref(href);
+      }
     }
-  }
 
-  if (!aHref.IsEmpty() && (linkTypes & nsStyleLinkElement::eDNS_PREFETCH)) {
-    PrefetchDNS(aHref);
-  }
+    if (!aHref.IsEmpty() && (linkTypes & nsStyleLinkElement::eDNS_PREFETCH)) {
+      PrefetchDNS(aHref);
+    }
 
-  if (!aHref.IsEmpty() && (linkTypes & nsStyleLinkElement::ePRECONNECT)) {
-    Preconnect(aHref, aCrossOrigin);
+    if (!aHref.IsEmpty() && (linkTypes & nsStyleLinkElement::ePRECONNECT)) {
+      Preconnect(aHref, aCrossOrigin);
+    }
   }
 
   // is it a stylesheet link?
   if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
     return NS_OK;
   }
 
   bool isAlternate = linkTypes & nsStyleLinkElement::eALTERNATE;