Bug 1291283 - Use URLValueData::GetLocalURLFlag() to identify local-ref URI. r=dholbert
authorcku <cku@mozilla.com>
Thu, 04 Aug 2016 23:50:22 +0800
changeset 308187 2eafd00d43790e42fb5801dfe5be4498579c25c5
parent 308186 0f1333d8cf910d0679bc8a7b6d6673d9bd92ba7b
child 308188 31c69994270f3e26a1fac3661d4a40496bf90283
push id31088
push usercku@mozilla.com
push dateFri, 05 Aug 2016 04:58:02 +0000
treeherderautoland@2eafd00d4379 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1291283
milestone51.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 1291283 - Use URLValueData::GetLocalURLFlag() to identify local-ref URI. r=dholbert MozReview-Commit-ID: 2tXEGMhPCkn
layout/style/nsCSSDataBlock.cpp
--- a/layout/style/nsCSSDataBlock.cpp
+++ b/layout/style/nsCSSDataBlock.cpp
@@ -64,19 +64,34 @@ TryToStartImageLoadOnValue(const nsCSSVa
 #ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
     // The 'mask-image' property accepts local reference URIs.
     // For example,
     //   mask-image: url(#mask_id); // refer to a SVG mask element, whose id is
     //                              // "mask_id", in the current document.
     // For such 'mask-image' values (pointing to an in-document element),
     // there is no need to trigger image download.
     if (aProperty == eCSSProperty_mask_image) {
-      nsIURI* docURI = aDocument->GetDocumentURI();
+      // Filter out all fragment URLs.
+      // Since nsCSSValue::GetURLStructValue runs much faster than
+      // nsIURI::EqualsExceptRef bellow, we get performance gain by this
+      // early return.
+      URLValue* urlValue = aValue.GetURLStructValue();
+      if (urlValue->GetLocalURLFlag()) {
+        return;
+      }
+
+      // Even though urlValue is not a fragment URL, it might still refer to
+      // an internal resource.
+      // For example, aDocument base URL is "http://foo/index.html" and
+      // intentionally references a mask-image at
+      // url(http://foo/index.html#mask) which still refers to a resource in
+      // aDocument.
       nsIURI* imageURI = aValue.GetURLValue();
       if (imageURI) {
+        nsIURI* docURI = aDocument->GetDocumentURI();
         bool isEqualExceptRef = false;
         nsresult  rv = imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
         if (NS_SUCCEEDED(rv) && isEqualExceptRef) {
           return;
         }
       }
     }
 #endif