mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1596317 - Split out CallState from nsGlobalWindowInner. r=smaug
We do want to use it for nsContentUtils::CallOnAllRemoteChildren and SubDocEnumFunc since `boolean` is quite confusing whether we still need to enumerate further children or not, actually nsContentUtils::CallOnAllRemoteChildren stops in case of `true`, whereas SubDocEnumFunc stops on `false` Differential Revision: https://phabricator.services.mozilla.com/D57435 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
aec08b91cc
commit
14e41fda7b
23
dom/base/CallState.h
Normal file
23
dom/base/CallState.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_CallState_h
|
||||
#define mozilla_CallState_h
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// An enum class to be used for returned value of callback functions. If Stop
|
||||
// is returned from the callback function, caller stops calling further
|
||||
// children. If Continue is returned then caller will keep calling further
|
||||
// children.
|
||||
enum class CallState {
|
||||
Continue,
|
||||
Stop,
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_CallSate_h
|
@ -121,6 +121,7 @@ if CONFIG['MOZ_WEBRTC']:
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'CallState.h',
|
||||
'ContentIterator.h',
|
||||
'CORSMode.h',
|
||||
'FlushType.h',
|
||||
|
@ -2262,8 +2262,7 @@ bool nsGlobalWindowInner::HasOpenerForInitialContentBrowser() {
|
||||
FORWARD_TO_OUTER(HasOpenerForInitialContentBrowser, (), false);
|
||||
}
|
||||
|
||||
nsGlobalWindowInner::CallState
|
||||
nsGlobalWindowInner::ShouldReportForServiceWorkerScopeInternal(
|
||||
CallState nsGlobalWindowInner::ShouldReportForServiceWorkerScopeInternal(
|
||||
const nsACString& aScope, bool* aResultOut) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aResultOut);
|
||||
|
||||
@ -5342,8 +5341,7 @@ void nsGlobalWindowInner::SyncStateFromParentWindow() {
|
||||
}
|
||||
|
||||
template <typename Method, typename... Args>
|
||||
nsGlobalWindowInner::CallState nsGlobalWindowInner::CallOnChildren(
|
||||
Method aMethod, Args&... aArgs) {
|
||||
CallState nsGlobalWindowInner::CallOnChildren(Method aMethod, Args&... aArgs) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(IsCurrentInnerWindow());
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/CallState.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
@ -1033,36 +1034,25 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||
bool IsPopupSpamWindow();
|
||||
|
||||
private:
|
||||
// A type that methods called by CallOnChildren can return. If Stop
|
||||
// is returned then CallOnChildren will stop calling further children.
|
||||
// If Continue is returned then CallOnChildren will keep calling further
|
||||
// children.
|
||||
enum class CallState {
|
||||
Continue,
|
||||
Stop,
|
||||
};
|
||||
|
||||
// Call the given method on the immediate children of this window. The
|
||||
// CallState returned by the last child method invocation is returned or
|
||||
// CallState::Continue if the method returns void.
|
||||
template <typename Method, typename... Args>
|
||||
CallState CallOnChildren(Method aMethod, Args&... aArgs);
|
||||
mozilla::CallState CallOnChildren(Method aMethod, Args&... aArgs);
|
||||
|
||||
// Helper to convert a void returning child method into an implicit
|
||||
// CallState::Continue value.
|
||||
template <typename Return, typename Method, typename... Args>
|
||||
typename std::enable_if<std::is_void<Return>::value,
|
||||
nsGlobalWindowInner::CallState>::type
|
||||
typename std::enable_if<std::is_void<Return>::value, mozilla::CallState>::type
|
||||
CallChild(nsGlobalWindowInner* aWindow, Method aMethod, Args&... aArgs) {
|
||||
(aWindow->*aMethod)(aArgs...);
|
||||
return nsGlobalWindowInner::CallState::Continue;
|
||||
return mozilla::CallState::Continue;
|
||||
}
|
||||
|
||||
// Helper that passes through the CallState value from a child method.
|
||||
template <typename Return, typename Method, typename... Args>
|
||||
typename std::enable_if<
|
||||
std::is_same<Return, nsGlobalWindowInner::CallState>::value,
|
||||
nsGlobalWindowInner::CallState>::type
|
||||
typename std::enable_if<std::is_same<Return, mozilla::CallState>::value,
|
||||
mozilla::CallState>::type
|
||||
CallChild(nsGlobalWindowInner* aWindow, Method aMethod, Args&... aArgs) {
|
||||
return (aWindow->*aMethod)(aArgs...);
|
||||
}
|
||||
@ -1070,8 +1060,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
||||
void FreezeInternal();
|
||||
void ThawInternal();
|
||||
|
||||
CallState ShouldReportForServiceWorkerScopeInternal(const nsACString& aScope,
|
||||
bool* aResultOut);
|
||||
mozilla::CallState ShouldReportForServiceWorkerScopeInternal(
|
||||
const nsACString& aScope, bool* aResultOut);
|
||||
|
||||
public:
|
||||
// Timeout Functions
|
||||
|
Loading…
Reference in New Issue
Block a user