Bug 1297963 - Part 2: Add URLValueData comparison functions that work OMT. r=emilio
MozReview-Commit-ID: LqcX6jadxnv
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -2673,16 +2673,33 @@ css::URLValueData::URIEquals(const URLVa
// fast path to equality
return (mURI == aOther.mURI ||
(NS_SUCCEEDED(mURI->Equals(aOther.mURI, &eq)) && eq)) &&
(mOriginPrincipal == aOther.mOriginPrincipal ||
self.mOriginPrincipal.get()->Equals(other.mOriginPrincipal.get())) &&
mLocalURLFlag == aOther.mLocalURLFlag;
}
+bool
+css::URLValueData::DefinitelyEqualURIs(const URLValueData& aOther) const
+{
+ return mBaseURI == aOther.mBaseURI &&
+ (mString == aOther.mString ||
+ NS_strcmp(nsCSSValue::GetBufferValue(mString),
+ nsCSSValue::GetBufferValue(aOther.mString)));
+}
+
+bool
+css::URLValueData::DefinitelyEqualURIsAndPrincipal(
+ const URLValueData& aOther) const
+{
+ return mOriginPrincipal == aOther.mOriginPrincipal &&
+ DefinitelyEqualURIs(aOther);
+}
+
nsIURI*
css::URLValueData::GetURI() const
{
MOZ_ASSERT(NS_IsMainThread());
if (!mURIResolved) {
MOZ_ASSERT(!mURI);
nsCOMPtr<nsIURI> newURI;
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -117,16 +117,29 @@ struct URLValueData
// 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;
+ // Returns true iff we know for sure, by comparing the mBaseURI pointer,
+ // the specified url() value mString, and the mLocalURLFlag, that these
+ // two URLValueData objects represent the same computed url() value.
+ //
+ // Doesn't look at mReferrer or mOriginPrincipal.
+ //
+ // Safe to call from any thread.
+ bool DefinitelyEqualURIs(const URLValueData& aOther) const;
+
+ // Smae as DefinitelyEqualURIs but additionally compares the nsIPrincipal
+ // pointers of the two URLValueData objects.
+ bool DefinitelyEqualURIsAndPrincipal(const URLValueData& aOther) const;
+
nsIURI* GetURI() const;
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool GetLocalURLFlag() const { return mLocalURLFlag; }
private:
// mURI stores the lazily resolved URI. This may be null if the URI is