Bug 1292930: Handle the case of having unresolved URIs in nsStyleDisplay::mBinding. r?heycam
This handles the case of the URIs not being resolved.
MozReview-Commit-ID: ExYsFbeaYWo
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -2633,16 +2633,26 @@ css::URLValueData::operator==(const URLV
(mURI && aOther.mURI &&
NS_SUCCEEDED(mURI->Equals(aOther.mURI, &eq)) &&
eq)) &&
(mOriginPrincipal == aOther.mOriginPrincipal ||
self.mOriginPrincipal.get()->Equals(other.mOriginPrincipal.get()));
}
bool
+css::URLValueData::MaybeUnresolvedURIEquals(const URLValueData& aOther) const
+{
+ if (!mURIResolved || !aOther.mURIResolved) {
+ return false;
+ }
+
+ return URIEquals(aOther);
+}
+
+bool
css::URLValueData::URIEquals(const URLValueData& aOther) const
{
MOZ_ASSERT(mURIResolved && aOther.mURIResolved,
"How do you know the URIs aren't null?");
bool eq;
// Cast away const so we can call nsIPrincipal::Equals.
auto& self = *const_cast<URLValueData*>(this);
auto& other = const_cast<URLValueData&>(aOther);
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -112,16 +112,20 @@ struct URLValueData
bool operator==(const URLValueData& aOther) const;
// URIEquals only compares URIs and principals (unlike operator==, which
// also compares the original strings). URIEquals also assumes that the
// mURI member of both URL objects is non-null. Do NOT call this method
// unless you're sure this is the case.
bool URIEquals(const URLValueData& aOther) const;
+ // Pretty much like URIEquals, but allows comparing unresolved URIs (returning
+ // false in that case).
+ bool MaybeUnresolvedURIEquals(const URLValueData& aOther) const;
+
nsIURI* GetURI() const;
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool GetLocalURLFlag() const { return mLocalURLFlag; }
private:
// If mURIResolved is false, mURI stores the base URI.
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -58,17 +58,17 @@ EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
NS_SUCCEEDED(aURI1->Equals(aURI2, &eq)) && // not equal on fail
eq);
}
static bool
EqualURIs(mozilla::css::URLValue *aURI1, mozilla::css::URLValue *aURI2)
{
return aURI1 == aURI2 || // handle null==null, and optimize
- (aURI1 && aURI2 && aURI1->URIEquals(*aURI2));
+ (aURI1 && aURI2 && aURI1->MaybeUnresolvedURIEquals(*aURI2));
}
static
bool EqualURIs(const FragmentOrURL* aURI1, const FragmentOrURL* aURI2)
{
return aURI1 == aURI2 || // handle null==null, and optimize
(aURI1 && aURI2 && *aURI1 == *aURI2);
}