Bug 1791961 - layout: Fix C++20 -Wambiguous-reversed-operator warnings. r=dholbert

clang is warning that C++20 expects comparison operators to be commutative: `a == b` and `b == a` should resolve to the same comparison operator function. Warnings about the comparison of const and non-const objects can be fixed by making the comparison operator function const.

layout/base/DisplayPortUtils.cpp:120:30 [-Wambiguous-reversed-operator] ISO C++20 considers use of overloaded operator '==' (with operand types 'const mozilla::CSSPoint' (aka 'const PointTyped<mozilla::CSSPixel>') and 'mozilla::CSSPoint' (aka 'PointTyped<mozilla::CSSPixel>')) to be ambiguous despite there being a unique best viable function
...

Depends on D179021

Differential Revision: https://phabricator.services.mozilla.com/D179022
This commit is contained in:
Chris Peterson 2023-05-26 04:51:43 +00:00
Родитель 07f19511ef
Коммит 82e89d15ab
2 изменённых файлов: 14 добавлений и 70 удалений

Просмотреть файл

@ -129,11 +129,11 @@ struct nsCollapsingMargin {
nsCollapsingMargin(const nsCollapsingMargin& aOther) = default;
bool operator==(const nsCollapsingMargin& aOther) {
bool operator==(const nsCollapsingMargin& aOther) const {
return mMostPos == aOther.mMostPos && mMostNeg == aOther.mMostNeg;
}
bool operator!=(const nsCollapsingMargin& aOther) {
bool operator!=(const nsCollapsingMargin& aOther) const {
return !(*this == aOther);
}

Просмотреть файл

@ -710,27 +710,13 @@ class nsLineList_iterator {
return --copy;
}
// Passing by value rather than by reference and reference to const
// to keep AIX happy.
bool operator==(const iterator_self_type aOther) const {
bool operator==(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
MOZ_ASSERT(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) const {
MOZ_ASSERT(mListLink);
MOZ_ASSERT(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent != aOther.mCurrent;
}
bool operator==(const iterator_self_type aOther) {
MOZ_ASSERT(mListLink);
MOZ_ASSERT(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) {
bool operator!=(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
MOZ_ASSERT(mListLink == aOther.mListLink,
"comparing iterators over different lists");
@ -738,7 +724,7 @@ class nsLineList_iterator {
}
#ifdef DEBUG
bool IsInSameList(const iterator_self_type aOther) const {
bool IsInSameList(const iterator_self_type& aOther) const {
return mListLink == aOther.mListLink;
}
#endif
@ -849,27 +835,13 @@ class nsLineList_reverse_iterator {
}
#endif /* !__MWERKS__ */
// Passing by value rather than by reference and reference to const
// to keep AIX happy.
bool operator==(const iterator_self_type aOther) const {
bool operator==(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent != aOther.mCurrent;
}
bool operator==(const iterator_self_type aOther) {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) {
bool operator!=(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
@ -877,7 +849,7 @@ class nsLineList_reverse_iterator {
}
#ifdef DEBUG
bool IsInSameList(const iterator_self_type aOther) const {
bool IsInSameList(const iterator_self_type& aOther) const {
return mListLink == aOther.mListLink;
}
#endif
@ -985,27 +957,13 @@ class nsLineList_const_iterator {
return --copy;
}
// Passing by value rather than by reference and reference to const
// to keep AIX happy.
bool operator==(const iterator_self_type aOther) const {
bool operator==(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent != aOther.mCurrent;
}
bool operator==(const iterator_self_type aOther) {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) {
bool operator!=(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
@ -1013,7 +971,7 @@ class nsLineList_const_iterator {
}
#ifdef DEBUG
bool IsInSameList(const iterator_self_type aOther) const {
bool IsInSameList(const iterator_self_type& aOther) const {
return mListLink == aOther.mListLink;
}
#endif
@ -1111,27 +1069,13 @@ class nsLineList_const_reverse_iterator {
}
#endif /* !__MWERKS__ */
// Passing by value rather than by reference and reference to const
// to keep AIX happy.
bool operator==(const iterator_self_type aOther) const {
bool operator==(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent != aOther.mCurrent;
}
bool operator==(const iterator_self_type aOther) {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
return mCurrent == aOther.mCurrent;
}
bool operator!=(const iterator_self_type aOther) {
bool operator!=(const iterator_self_type& aOther) const {
MOZ_ASSERT(mListLink);
NS_ASSERTION(mListLink == aOther.mListLink,
"comparing iterators over different lists");
@ -1139,7 +1083,7 @@ class nsLineList_const_reverse_iterator {
}
#ifdef DEBUG
bool IsInSameList(const iterator_self_type aOther) const {
bool IsInSameList(const iterator_self_type& aOther) const {
return mListLink == aOther.mListLink;
}
#endif