зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1697737 - pt 1. Remove NOTIFY_LISTENERS_CANCELABLE r=nika
This macro was used in two places to do the same thing. We can remove this over-generalisation and have clearer code. Differential Revision: https://phabricator.services.mozilla.com/D107804
This commit is contained in:
Родитель
f8db81665d
Коммит
abe4c7e882
|
@ -137,22 +137,6 @@ extern mozilla::LazyLogModule gSHIPBFCacheLog;
|
|||
#define NOTIFY_LISTENERS(method, args) \
|
||||
ITERATE_LISTENERS(listener->method args;);
|
||||
|
||||
// Calls a given method on all registered session history listeners.
|
||||
// Listeners may return 'false' to cancel an action so make sure that we
|
||||
// set the return value to 'false' if one of the listeners wants to cancel.
|
||||
#define NOTIFY_LISTENERS_CANCELABLE(method, retval, args) \
|
||||
PR_BEGIN_MACRO { \
|
||||
bool canceled = false; \
|
||||
(retval) = true; \
|
||||
ITERATE_LISTENERS(if (NS_SUCCEEDED(listener->method args) && !(retval)) { \
|
||||
canceled = true; \
|
||||
}); \
|
||||
if (canceled) { \
|
||||
(retval) = false; \
|
||||
} \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
class MOZ_STACK_CLASS SHistoryChangeNotifier {
|
||||
public:
|
||||
explicit SHistoryChangeNotifier(nsSHistory* aHistory) {
|
||||
|
@ -1149,9 +1133,24 @@ nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Calls OnHistoryReload on all registered session history listeners.
|
||||
// Listeners may return 'false' to cancel an action so make sure that we
|
||||
// set the return value to 'false' if one of the listeners wants to cancel.
|
||||
NS_IMETHODIMP
|
||||
nsSHistory::NotifyOnHistoryReload(bool* aCanReload) {
|
||||
NOTIFY_LISTENERS_CANCELABLE(OnHistoryReload, *aCanReload, (aCanReload));
|
||||
*aCanReload = true;
|
||||
|
||||
for (const nsWeakPtr& weakPtr : mListeners.EndLimitedRange()) {
|
||||
nsCOMPtr<nsISHistoryListener> listener = do_QueryReferent(weakPtr);
|
||||
if (listener) {
|
||||
bool retval = true;
|
||||
|
||||
if (NS_SUCCEEDED(listener->OnHistoryReload(&retval)) && !retval) {
|
||||
*aCanReload = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1413,7 +1412,7 @@ nsresult nsSHistory::Reload(uint32_t aReloadFlags,
|
|||
// is public. So send the reload notifications with the
|
||||
// nsIWebNavigation flags.
|
||||
bool canNavigate = true;
|
||||
NOTIFY_LISTENERS_CANCELABLE(OnHistoryReload, canNavigate, (&canNavigate));
|
||||
MOZ_ALWAYS_SUCCEEDS(NotifyOnHistoryReload(&canNavigate));
|
||||
if (!canNavigate) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче