Bug 1404243 Part 2 - Change StyleShapeSource::operator==() to use logic in DefinitelyEquals(). r=heycam

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

--HG--
extra : rebase_source : f63dac121e13fd9c6dccf7f0c6e870bd75d9e03a
This commit is contained in:
Ting-Yu Lin 2017-09-29 14:36:35 +08:00
parent 5df24bad8e
commit d8c9dae62b
2 changed files with 22 additions and 31 deletions

View File

@ -1074,6 +1074,25 @@ StyleShapeSource::operator=(const StyleShapeSource& aOther)
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)
{
@ -1301,7 +1320,7 @@ 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,
@ -3654,7 +3673,7 @@ nsStyleDisplay::CalcDifference(const nsStyleDisplay& aNewData) const
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.

View File

@ -2454,35 +2454,7 @@ struct StyleShapeSource
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
{