зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1089417 patch 4 - Define equality operators on nsMediaQueryResultCacheKey and the types it contains. r=heycam
This is needed for the equality comparison in nsCSSRuleProcessor::MediumFeaturesChanged in patch 8.
This commit is contained in:
Родитель
9beeb100fc
Коммит
afa637c492
|
@ -37,7 +37,16 @@ struct nsMediaExpression {
|
|||
|
||||
// aActualValue must be obtained from mFeature->mGetter
|
||||
bool Matches(nsPresContext* aPresContext,
|
||||
const nsCSSValue& aActualValue) const;
|
||||
const nsCSSValue& aActualValue) const;
|
||||
|
||||
bool operator==(const nsMediaExpression& aOther) const {
|
||||
return mFeature == aOther.mFeature && // pointer equality fine (atom-like)
|
||||
mRange == aOther.mRange &&
|
||||
mValue == aOther.mValue;
|
||||
}
|
||||
bool operator!=(const nsMediaExpression& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -73,6 +82,18 @@ public:
|
|||
void AddExpression(const nsMediaExpression* aExpression,
|
||||
bool aExpressionMatches);
|
||||
bool Matches(nsPresContext* aPresContext) const;
|
||||
|
||||
/**
|
||||
* An operator== that implements list equality, which isn't quite as
|
||||
* good as set equality, but catches the trivial equality cases.
|
||||
*/
|
||||
bool operator==(const nsMediaQueryResultCacheKey& aOther) const {
|
||||
return mMedium == aOther.mMedium &&
|
||||
mFeatureCache == aOther.mFeatureCache;
|
||||
}
|
||||
bool operator!=(const nsMediaQueryResultCacheKey& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
private:
|
||||
struct ExpressionEntry {
|
||||
// FIXME: if we were better at maintaining invariants about clearing
|
||||
|
@ -80,10 +101,26 @@ private:
|
|||
// nsMediaExpression*| instead.
|
||||
nsMediaExpression mExpression;
|
||||
bool mExpressionMatches;
|
||||
|
||||
bool operator==(const ExpressionEntry& aOther) const {
|
||||
return mExpression == aOther.mExpression &&
|
||||
mExpressionMatches == aOther.mExpressionMatches;
|
||||
}
|
||||
bool operator!=(const ExpressionEntry& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
};
|
||||
struct FeatureEntry {
|
||||
const nsMediaFeature *mFeature;
|
||||
InfallibleTArray<ExpressionEntry> mExpressions;
|
||||
|
||||
bool operator==(const FeatureEntry& aOther) const {
|
||||
return mFeature == aOther.mFeature &&
|
||||
mExpressions == aOther.mExpressions;
|
||||
}
|
||||
bool operator!=(const FeatureEntry& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
};
|
||||
nsCOMPtr<nsIAtom> mMedium;
|
||||
nsTArray<FeatureEntry> mFeatureCache;
|
||||
|
|
Загрузка…
Ссылка в новой задаче