Bug 1169440 patch 1 - Add bitwise operators to nsChangeHint. r=heycam

I'm fed up with having to use the NS_*Hint functions, and I also have
trouble reading/writing some of them since I don't remember the order of
parameters.

(At some point I think we should convert existing callers, but I don't
plan to do that here.)
This commit is contained in:
L. David Baron 2015-06-20 21:54:15 -07:00
Родитель 38328fd6ab
Коммит 1cc4969746
2 изменённых файлов: 45 добавлений и 1 удалений

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

@ -148,7 +148,8 @@ SyncViewsAndInvalidateDescendants(nsIFrame* aFrame,
{
NS_PRECONDITION(gInApplyRenderingChangeToTree,
"should only be called within ApplyRenderingChangeToTree");
NS_ASSERTION(aChange == (aChange & (nsChangeHint_RepaintFrame |
NS_ASSERTION(nsChangeHint_size_t(aChange) ==
(aChange & (nsChangeHint_RepaintFrame |
nsChangeHint_SyncFrameView |
nsChangeHint_UpdateOpacityLayer |
nsChangeHint_SchedulePaint)),

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

@ -210,6 +210,49 @@ inline bool NS_IsHintSubset(nsChangeHint aSubset, nsChangeHint aSuperSet) {
return (aSubset & aSuperSet) == aSubset;
}
// The functions below need an integral type to cast to to avoid
// infinite recursion.
typedef decltype(nsChangeHint(0) + nsChangeHint(0)) nsChangeHint_size_t;
inline nsChangeHint MOZ_CONSTEXPR
operator|(nsChangeHint aLeft, nsChangeHint aRight)
{
return nsChangeHint(nsChangeHint_size_t(aLeft) | nsChangeHint_size_t(aRight));
}
inline nsChangeHint MOZ_CONSTEXPR
operator&(nsChangeHint aLeft, nsChangeHint aRight)
{
return nsChangeHint(nsChangeHint_size_t(aLeft) & nsChangeHint_size_t(aRight));
}
inline nsChangeHint& operator|=(nsChangeHint& aLeft, nsChangeHint aRight)
{
return aLeft = aLeft | aRight;
}
inline nsChangeHint& operator&=(nsChangeHint& aLeft, nsChangeHint aRight)
{
return aLeft = aLeft & aRight;
}
inline nsChangeHint MOZ_CONSTEXPR
operator~(nsChangeHint aArg)
{
return nsChangeHint(~nsChangeHint_size_t(aArg));
}
inline nsChangeHint MOZ_CONSTEXPR
operator^(nsChangeHint aLeft, nsChangeHint aRight)
{
return nsChangeHint(nsChangeHint_size_t(aLeft) ^ nsChangeHint_size_t(aRight));
}
inline nsChangeHint operator^=(nsChangeHint& aLeft, nsChangeHint aRight)
{
return aLeft = aLeft ^ aRight;
}
/**
* We have an optimization when processing change hints which prevents
* us from visiting the descendants of a node when a hint on that node