Bug 1295065 - Fix assertion failure at FragmentOrURL::SetValue after enabling mask-as-shorthand.
MozReview-Commit-ID: AUySGzzqjQo
--- 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