mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1484306 Part 4 - Use FunctionTypeTraits to yield better error message if aPredicate's signature is wrong. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D3684
This commit is contained in:
parent
4e52c71be9
commit
f90c2a2950
@ -10,6 +10,7 @@
|
||||
#include <stdio.h> /* for FILE* */
|
||||
#include "nsDebug.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/FunctionTypeTraits.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/ReverseIterator.h"
|
||||
|
||||
@ -241,6 +242,14 @@ public:
|
||||
*/
|
||||
template<typename Predicate>
|
||||
nsFrameList Split(Predicate&& aPredicate) {
|
||||
static_assert(
|
||||
std::is_same<typename mozilla::FunctionTypeTraits<Predicate>::ReturnType,
|
||||
bool>::value &&
|
||||
mozilla::FunctionTypeTraits<Predicate>::arity == 1 &&
|
||||
std::is_same<typename mozilla::FunctionTypeTraits<Predicate>::template ParameterType<0>,
|
||||
nsIFrame*>::value,
|
||||
"aPredicate should be of this function signature: bool(nsIFrame*)");
|
||||
|
||||
FrameLinkEnumerator link(*this);
|
||||
link.Find(aPredicate);
|
||||
return ExtractHead(link);
|
||||
|
@ -4777,6 +4777,14 @@ template<typename Predicate>
|
||||
inline void
|
||||
nsFrameList::FrameLinkEnumerator::Find(Predicate&& aPredicate)
|
||||
{
|
||||
static_assert(
|
||||
std::is_same<typename mozilla::FunctionTypeTraits<Predicate>::ReturnType,
|
||||
bool>::value &&
|
||||
mozilla::FunctionTypeTraits<Predicate>::arity == 1 &&
|
||||
std::is_same<typename mozilla::FunctionTypeTraits<Predicate>::template ParameterType<0>,
|
||||
nsIFrame*>::value,
|
||||
"aPredicate should be of this function signature: bool(nsIFrame*)");
|
||||
|
||||
for (; !AtEnd(); Next()) {
|
||||
if (aPredicate(mFrame)) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user