Bug 1404243 Part 2 - Change StyleShapeSource::operator==() to use logic in DefinitelyEquals(). draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 29 Sep 2017 14:36:35 +0800
changeset 673200 ef39ecaf85dbc849f8c338b335f3cd43b2e842e2
parent 673199 9f49ba69e091c97ce64502032fd7c3960c22df9e
child 673201 070e993fd42511de5a3ca7b72bc3b07177382a66
push id82495
push userbmo:tlin@mozilla.com
push dateMon, 02 Oct 2017 03:57:39 +0000
bugs1404243
milestone58.0a1
Bug 1404243 Part 2 - Change StyleShapeSource::operator==() to use logic in DefinitelyEquals(). The original operator==() (implemented by EqualsInternal<true>) is not been used. Therefore, I expand EqualsInternal<false> into it, and move it to nsStyleStruct.cpp. Also, use DefinitelyEqualURIs() in nsStyleStruct.cpp in operator==(). MozReview-Commit-ID: HccwKvzQHR
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1070,16 +1070,35 @@ StyleShapeSource::operator=(const StyleS
     ReleaseRef();
     mReferenceBox = StyleGeometryBox::NoBox;
     mType = StyleShapeSourceType::None;
   }
   return *this;
 }
 
 bool
+StyleShapeSource::operator==(const StyleShapeSource& aOther) const
+{
+  if (mType != aOther.mType) {
+    return false;
+  }
+
+  if (mType == StyleShapeSourceType::URL) {
+    return DefinitelyEqualURIs(mURL, aOther.mURL);
+  } else if (mType == StyleShapeSourceType::Shape) {
+    return *mBasicShape == *aOther.mBasicShape &&
+      mReferenceBox == aOther.mReferenceBox;
+  } else if (mType == StyleShapeSourceType::Box) {
+    return mReferenceBox == aOther.mReferenceBox;
+  }
+
+  return true;
+}
+
+bool
 StyleShapeSource::SetURL(css::URLValue* aValue)
 {
   MOZ_ASSERT(aValue);
   ReleaseRef();
   mURL = aValue;
   mURL->AddRef();
   mType = StyleShapeSourceType::URL;
   return true;
@@ -1296,17 +1315,17 @@ nsStyleSVGReset::FinishStyle(nsPresConte
   }
 }
 
 nsChangeHint
 nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aNewData) const
 {
   nsChangeHint hint = nsChangeHint(0);
 
-  if (!mClipPath.DefinitelyEquals(aNewData.mClipPath)) {
+  if (mClipPath != aNewData.mClipPath) {
     hint |= nsChangeHint_UpdateEffects |
             nsChangeHint_RepaintFrame;
     // clip-path changes require that we update the PreEffectsBBoxProperty,
     // which is done during overflow computation.
     hint |= nsChangeHint_UpdateOverflow;
   }
 
   if (mDominantBaseline != aNewData.mDominantBaseline) {
@@ -3649,17 +3668,17 @@ nsStyleDisplay::CalcDifference(const nsS
    * if this does become common perhaps a faster-path might be worth while.
    */
 
   if (mFloat != aNewData.mFloat) {
     // Changing which side we're floating on (float:none was handled above).
     hint |= nsChangeHint_ReflowHintsForFloatAreaChange;
   }
 
-  if (!mShapeOutside.DefinitelyEquals(aNewData.mShapeOutside)) {
+  if (mShapeOutside != aNewData.mShapeOutside) {
     if (aNewData.mFloat != StyleFloat::None) {
       // If we are floating, and our shape-outside property changes, our
       // descendants are not impacted, but our ancestor and siblings are.
       // This is similar to a float-only change, but since the ISize of the
       // float area changes arbitrarily along its block axis, more is required
       // to get the siblings to adjust properly. Hinting overflow change is
       // sufficient to trigger the correct calculation, but may be too
       // heavyweight.
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2449,45 +2449,17 @@ struct StyleShapeSource
 
   ~StyleShapeSource()
   {
     ReleaseRef();
   }
 
   StyleShapeSource& operator=(const StyleShapeSource& aOther);
 
-  bool operator==(const StyleShapeSource& aOther) const
-  {
-    return EqualsInternal<true>(aOther);
-  }
-
-  bool DefinitelyEquals(const StyleShapeSource& aOther) const
-  {
-    return EqualsInternal<false>(aOther);
-  }
-
-  template<bool aPrecise>
-  bool EqualsInternal(const StyleShapeSource& aOther) const
-  {
-    if (mType != aOther.mType) {
-      return false;
-    }
-
-    if (mType == StyleShapeSourceType::URL) {
-      return aPrecise ? mURL->Equals(*aOther.mURL)
-                      : mURL->DefinitelyEqualURIs(*aOther.mURL);
-    } else if (mType == StyleShapeSourceType::Shape) {
-      return *mBasicShape == *aOther.mBasicShape &&
-             mReferenceBox == aOther.mReferenceBox;
-    } else if (mType == StyleShapeSourceType::Box) {
-      return mReferenceBox == aOther.mReferenceBox;
-    }
-
-    return true;
-  }
+  bool operator==(const StyleShapeSource& aOther) const;
 
   bool operator!=(const StyleShapeSource& aOther) const
   {
     return !(*this == aOther);
   }
 
   StyleShapeSourceType GetType() const
   {