Bug 1297963 - Part 2: Add URLValueData comparison functions that work OMT. r=emilio
authorCameron McCormack <cam@mcc.id.au>
Sat, 03 Sep 2016 00:22:47 +1000
changeset 312442 0549f87f0c292b5bc27f2d62cf62cb7ec1ec4cff
parent 312441 d91354854339f34daf412da475bf3293cc75ef76
child 312443 4de2d08774a1ca1fb2b3bd00124acf93a970c3f0
push id20447
push userkwierso@gmail.com
push dateFri, 02 Sep 2016 20:36:44 +0000
treeherderfx-team@969397f22187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1297963
milestone51.0a1
Bug 1297963 - Part 2: Add URLValueData comparison functions that work OMT. r=emilio MozReview-Commit-ID: B3pldGVZFl1
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
--- 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