Bug 1296250 - Part 1. Correct the condition of an assertion in SetStyleImage. r=heycam
authorcku <cku@mozilla.com>
Thu, 18 Aug 2016 17:44:00 +0800
changeset 309948 5d17d3db2b52839af7900d68b385bfbff97df7d4
parent 309947 905fb4a53386c76d931e4a04a31d03739a00a1ff
child 309949 20885c842fd32bde80566eacf5e8ad04ae0723bd
push id31501
push usercku@mozilla.com
push dateThu, 18 Aug 2016 16:09:19 +0000
treeherderautoland@20885c842fd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1296250
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 1296250 - Part 1. Correct the condition of an assertion in SetStyleImage. r=heycam MozReview-Commit-ID: YKxbUTbjIc
layout/style/nsRuleNode.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1273,23 +1273,42 @@ static void SetStyleImage(nsStyleContext
       break;
     case eCSSUnit_Initial:
     case eCSSUnit_Unset:
     case eCSSUnit_None:
       break;
     case eCSSUnit_URL:
     {
 #ifdef DEBUG
-      mozilla::css::URLValueData *urlData = aValue.GetURLStructValue();
-
-      // Either we have eCSSUnit_URL values for if-visited style contexts,
-      // which we can safely treat like 'none', or aValue refers to an
-      // in-document resource. Otherwise this is an unexpected unit.
-      NS_ASSERTION(aStyleContext->IsStyleIfVisited() ||
-                   urlData->GetLocalURLFlag(),
+      // eCSSUnit_URL is expected only if
+      // 1. we have eCSSUnit_URL values for if-visited style contexts, which
+      //    we can safely treat like 'none'.
+      // 2. aValue is a local-ref URL, e.g. url(#foo).
+      // 3. aValue is a not a local-ref URL, but it refers to an element in
+      //    the current document. For example, the url of the current document
+      //    is "http://foo.html" and aValue is url(http://foo.html#foo).
+      //
+      // We skip image download in TryToStartImageLoadOnValue under #2 and #3,
+      // and that's part of reasons we get eCSSUnit_URL instead of
+      // eCSSUnit_Image here.
+
+      // Check #2.
+      bool isLocalRef = aValue.GetURLStructValue()->GetLocalURLFlag();
+
+      // Check #3.
+      bool isEqualExceptRef = false;
+      if (!isLocalRef) {
+        nsIDocument* currentDoc = aStyleContext->PresContext()->Document();
+        nsIURI* docURI = currentDoc->GetDocumentURI();
+        nsIURI* imageURI = aValue.GetURLValue();
+        imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
+      }
+
+      NS_ASSERTION(aStyleContext->IsStyleIfVisited() || isEqualExceptRef ||
+                   isLocalRef,
                    "unexpected unit; maybe nsCSSValue::Image::Image() failed?");
 #endif
 
       break;
     }
     default:
       MOZ_ASSERT_UNREACHABLE("Unexpected Unit type.");
       break;