Bug 1295065 - Fix assertion failure at FragmentOrURL::SetValue after enabling mask-as-shorthand. r=heycam
authorcku <cku@mozilla.com>
Mon, 15 Aug 2016 12:00:03 +0800
changeset 400818 cec1738be04c0e2ec1dfa0b5f174cf8dbf3b8ac3
parent 400817 18afb91eaac8c7b73db0407bcd90a3afe88f14ab
child 400819 3bce29db23296122298437f8a2eeb6043aac378c
push id26289
push userbmo:npancholi@mozilla.com
push dateMon, 15 Aug 2016 22:10:02 +0000
reviewersheycam
bugs1295065
milestone51.0a1
Bug 1295065 - Fix assertion failure at FragmentOrURL::SetValue after enabling mask-as-shorthand. r=heycam MozReview-Commit-ID: AUySGzzqjQo
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1272,25 +1272,23 @@ static void SetStyleImage(nsStyleContext
       break;
     case eCSSUnit_Initial:
     case eCSSUnit_Unset:
     case eCSSUnit_None:
       break;
     case eCSSUnit_URL:
     {
 #ifdef DEBUG
-      nsIDocument* currentDoc = aStyleContext->PresContext()->Document();
-      nsIURI* docURI = currentDoc->GetDocumentURI();
-      nsIURI* imageURI = aValue.GetURLValue();
-      bool isEqualExceptRef = false;
-      imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
+      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() || isEqualExceptRef,
+      NS_ASSERTION(aStyleContext->IsStyleIfVisited() ||
+                   urlData->GetLocalURLFlag(),
                    "unexpected unit; maybe nsCSSValue::Image::Image() failed?");
 #endif
 
       break;
     }
     default:
       MOZ_ASSERT_UNREACHABLE("Unexpected Unit type.");
       break;
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -119,21 +119,23 @@ StyleStructContext::HackilyFindSomeDevic
 static bool AreShadowArraysEqual(nsCSSShadowArray* lhs, nsCSSShadowArray* rhs);
 
 // --------------------
 // FragmentOrURL
 //
 void
 FragmentOrURL::SetValue(const nsCSSValue* aValue)
 {
-  mozilla::css::URLValue *urlVal = aValue->GetURLStructValue();
-  MOZ_ASSERT_IF(urlVal->GetLocalURLFlag(), urlVal->GetURI());
-  mIsLocalRef = urlVal->GetLocalURLFlag();
-
-  mURL = urlVal->GetURI();
+  mozilla::css::URLValueData *urlData = aValue->GetUnit() == eCSSUnit_URL
+    ? static_cast<mozilla::css::URLValueData *>(aValue->GetURLStructValue())
+    : static_cast<mozilla::css::URLValueData *>(aValue->GetImageStructValue());
+  MOZ_ASSERT_IF(urlData->GetLocalURLFlag(), urlData->GetURI());
+  mIsLocalRef = urlData->GetLocalURLFlag();
+
+  mURL = urlData->GetURI();
 
 #ifdef DEBUG
   if (mIsLocalRef) {
     bool hasRef = false;
     mURL->GetHasRef(&hasRef);
     MOZ_ASSERT(hasRef);
   }
 #endif