зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1645382 - Remove unnecessary arguments from NS_OBSERVER_ARRAY_NOTIFY_* macros. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D79485
This commit is contained in:
Родитель
298981065e
Коммит
0735ecafd8
|
@ -514,8 +514,7 @@ class Document : public nsINode,
|
|||
|
||||
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
|
||||
do { \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \
|
||||
func_, params_); \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, func_, params_); \
|
||||
/* FIXME(emilio): Apparently we can keep observing from the BFCache? That \
|
||||
looks bogus. */ \
|
||||
if (PresShell* presShell = GetObservingPresShell()) { \
|
||||
|
|
|
@ -58,74 +58,73 @@ enum class IsRemoveNotification {
|
|||
|
||||
// This macro expects the ownerDocument of content_ to be in scope as
|
||||
// |Document* doc|
|
||||
#define IMPL_MUTATION_NOTIFICATION(func_, content_, params_, remove_) \
|
||||
PR_BEGIN_MACRO \
|
||||
bool needsEnterLeave = doc->MayHaveDOMMutationObservers(); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::EnterMutationHandling(); \
|
||||
} \
|
||||
nsINode* node = content_; \
|
||||
COMPOSED_DOC_DECL \
|
||||
NS_ASSERTION(node->OwnerDoc() == doc, "Bogus document"); \
|
||||
if (remove_ == IsRemoveNotification::Yes && node->GetComposedDoc()) { \
|
||||
if (PresShell* presShell = doc->GetObservingPresShell()) { \
|
||||
presShell->func_ params_; \
|
||||
} \
|
||||
} \
|
||||
CALL_BINDING_MANAGER(func_, params_); \
|
||||
nsINode* last; \
|
||||
do { \
|
||||
nsINode::nsSlots* slots = node->GetExistingSlots(); \
|
||||
if (slots && !slots->mMutationObservers.IsEmpty()) { \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(slots->mMutationObservers, \
|
||||
nsIMutationObserver, func_, params_); \
|
||||
} \
|
||||
last = node; \
|
||||
if (ShadowRoot* shadow = ShadowRoot::FromNode(node)) { \
|
||||
node = shadow->GetHost(); \
|
||||
} else { \
|
||||
node = node->GetParentNode(); \
|
||||
} \
|
||||
} while (node); \
|
||||
/* Whitelist NativeAnonymousChildListChange removal notifications from \
|
||||
* the assertion since it runs from UnbindFromTree, and thus we don't \
|
||||
* reach the document, but doesn't matter. */ \
|
||||
MOZ_ASSERT((last == doc) == wasInComposedDoc || \
|
||||
(remove_ == IsRemoveNotification::Yes && \
|
||||
!strcmp(#func_, "NativeAnonymousChildListChange"))); \
|
||||
if (remove_ == IsRemoveNotification::No && last == doc) { \
|
||||
if (PresShell* presShell = doc->GetObservingPresShell()) { \
|
||||
presShell->func_ params_; \
|
||||
} \
|
||||
} \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::LeaveMutationHandling(); \
|
||||
} \
|
||||
#define IMPL_MUTATION_NOTIFICATION(func_, content_, params_, remove_) \
|
||||
PR_BEGIN_MACRO \
|
||||
bool needsEnterLeave = doc->MayHaveDOMMutationObservers(); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::EnterMutationHandling(); \
|
||||
} \
|
||||
nsINode* node = content_; \
|
||||
COMPOSED_DOC_DECL \
|
||||
NS_ASSERTION(node->OwnerDoc() == doc, "Bogus document"); \
|
||||
if (remove_ == IsRemoveNotification::Yes && node->GetComposedDoc()) { \
|
||||
if (PresShell* presShell = doc->GetObservingPresShell()) { \
|
||||
presShell->func_ params_; \
|
||||
} \
|
||||
} \
|
||||
CALL_BINDING_MANAGER(func_, params_); \
|
||||
nsINode* last; \
|
||||
do { \
|
||||
nsINode::nsSlots* slots = node->GetExistingSlots(); \
|
||||
if (slots && !slots->mMutationObservers.IsEmpty()) { \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(slots->mMutationObservers, func_, \
|
||||
params_); \
|
||||
} \
|
||||
last = node; \
|
||||
if (ShadowRoot* shadow = ShadowRoot::FromNode(node)) { \
|
||||
node = shadow->GetHost(); \
|
||||
} else { \
|
||||
node = node->GetParentNode(); \
|
||||
} \
|
||||
} while (node); \
|
||||
/* Whitelist NativeAnonymousChildListChange removal notifications from \
|
||||
* the assertion since it runs from UnbindFromTree, and thus we don't \
|
||||
* reach the document, but doesn't matter. */ \
|
||||
MOZ_ASSERT((last == doc) == wasInComposedDoc || \
|
||||
(remove_ == IsRemoveNotification::Yes && \
|
||||
!strcmp(#func_, "NativeAnonymousChildListChange"))); \
|
||||
if (remove_ == IsRemoveNotification::No && last == doc) { \
|
||||
if (PresShell* presShell = doc->GetObservingPresShell()) { \
|
||||
presShell->func_ params_; \
|
||||
} \
|
||||
} \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::LeaveMutationHandling(); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#define IMPL_ANIMATION_NOTIFICATION(func_, content_, params_) \
|
||||
PR_BEGIN_MACRO \
|
||||
bool needsEnterLeave = doc->MayHaveDOMMutationObservers(); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::EnterMutationHandling(); \
|
||||
} \
|
||||
nsINode* node = content_; \
|
||||
do { \
|
||||
nsINode::nsSlots* slots = node->GetExistingSlots(); \
|
||||
if (slots && !slots->mMutationObservers.IsEmpty()) { \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS_WITH_QI( \
|
||||
slots->mMutationObservers, nsIMutationObserver, \
|
||||
nsIAnimationObserver, func_, params_); \
|
||||
} \
|
||||
if (ShadowRoot* shadow = ShadowRoot::FromNode(node)) { \
|
||||
node = shadow->GetHost(); \
|
||||
} else { \
|
||||
node = node->GetParentNode(); \
|
||||
} \
|
||||
} while (node); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::LeaveMutationHandling(); \
|
||||
} \
|
||||
#define IMPL_ANIMATION_NOTIFICATION(func_, content_, params_) \
|
||||
PR_BEGIN_MACRO \
|
||||
bool needsEnterLeave = doc->MayHaveDOMMutationObservers(); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::EnterMutationHandling(); \
|
||||
} \
|
||||
nsINode* node = content_; \
|
||||
do { \
|
||||
nsINode::nsSlots* slots = node->GetExistingSlots(); \
|
||||
if (slots && !slots->mMutationObservers.IsEmpty()) { \
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS_WITH_QI( \
|
||||
slots->mMutationObservers, nsIAnimationObserver, func_, params_); \
|
||||
} \
|
||||
if (ShadowRoot* shadow = ShadowRoot::FromNode(node)) { \
|
||||
node = shadow->GetHost(); \
|
||||
} else { \
|
||||
node = node->GetParentNode(); \
|
||||
} \
|
||||
} while (node); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::LeaveMutationHandling(); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -122,7 +122,6 @@ class MutationObservers {
|
|||
nsINode::nsSlots* slots = aContent->GetExistingSlots();
|
||||
if (slots && !slots->mMutationObservers.IsEmpty()) {
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(slots->mMutationObservers,
|
||||
nsIMutationObserver,
|
||||
ParentChainChanged, (aContent));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -624,7 +624,6 @@ void nsINode::LastRelease() {
|
|||
if (slots) {
|
||||
if (!slots->mMutationObservers.IsEmpty()) {
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(slots->mMutationObservers,
|
||||
nsIMutationObserver,
|
||||
NodeWillBeDestroyed, (this));
|
||||
}
|
||||
|
||||
|
|
|
@ -533,8 +533,7 @@ void Performance::RemoveObserver(PerformanceObserver* aObserver) {
|
|||
|
||||
void Performance::NotifyObservers() {
|
||||
mPendingNotificationObserversTask = false;
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, PerformanceObserver,
|
||||
Notify, ());
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, Notify, ());
|
||||
}
|
||||
|
||||
void Performance::CancelNotificationObservers() {
|
||||
|
@ -610,8 +609,8 @@ void Performance::QueueEntry(PerformanceEntry* aEntry) {
|
|||
return;
|
||||
}
|
||||
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(
|
||||
interestedObservers, PerformanceObserver, QueueEntry, (aEntry));
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(interestedObservers, QueueEntry,
|
||||
(aEntry));
|
||||
|
||||
QueueNotificationObserversTask();
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ nsDocLoader::Stop(void) {
|
|||
MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
|
||||
("DocLoader:%p: Stop() called\n", this));
|
||||
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, nsDocLoader, Stop, ());
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, Stop, ());
|
||||
|
||||
if (mLoadGroup) rv = mLoadGroup->Cancel(NS_BINDING_ABORTED);
|
||||
|
||||
|
@ -1543,7 +1543,7 @@ NS_IMETHODIMP nsDocLoader::SetPriority(int32_t aPriority) {
|
|||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mLoadGroup);
|
||||
if (p) p->SetPriority(aPriority);
|
||||
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, nsDocLoader, SetPriority,
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, SetPriority,
|
||||
(aPriority));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1556,8 +1556,8 @@ NS_IMETHODIMP nsDocLoader::AdjustPriority(int32_t aDelta) {
|
|||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mLoadGroup);
|
||||
if (p) p->AdjustPriority(aDelta);
|
||||
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, nsDocLoader,
|
||||
AdjustPriority, (aDelta));
|
||||
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mChildList, AdjustPriority,
|
||||
(aDelta));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -541,34 +541,31 @@ inline void ImplCycleCollectionTraverse(
|
|||
}
|
||||
}
|
||||
|
||||
// XXXbz I wish I didn't have to pass in the observer type, but I
|
||||
// don't see a way to get it out of array_.
|
||||
// Note that this macro only works if the array holds pointers to XPCOM objects.
|
||||
#define NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(array_, obstype_, func_, \
|
||||
params_) \
|
||||
do { \
|
||||
for (RefPtr<obstype_> obs_ : array_.ForwardRange()) { \
|
||||
obs_->func_ params_; \
|
||||
} \
|
||||
#define NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(array_, func_, params_) \
|
||||
do { \
|
||||
for (RefPtr obs_ : array_.ForwardRange()) { \
|
||||
obs_->func_ params_; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Note that this macro only works if the array holds pointers to XPCOM objects.
|
||||
#define NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(array_, obstype_, func_, params_) \
|
||||
do { \
|
||||
for (obstype_ * obs_ : array_.ForwardRange()) { \
|
||||
obs_->func_ params_; \
|
||||
} \
|
||||
#define NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(array_, func_, params_) \
|
||||
do { \
|
||||
for (auto* obs_ : array_.ForwardRange()) { \
|
||||
obs_->func_ params_; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS_WITH_QI(array_, basetype_, \
|
||||
obstype_, func_, params_) \
|
||||
do { \
|
||||
for (basetype_ * obsbase_ : array_.ForwardRange()) { \
|
||||
nsCOMPtr<obstype_> obs_ = do_QueryInterface(obsbase_); \
|
||||
if (obs_) { \
|
||||
obs_->func_ params_; \
|
||||
} \
|
||||
} \
|
||||
#define NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS_WITH_QI(array_, obstype_, func_, \
|
||||
params_) \
|
||||
do { \
|
||||
for (auto* obsbase_ : array_.ForwardRange()) { \
|
||||
nsCOMPtr<obstype_> obs_ = do_QueryInterface(obsbase_); \
|
||||
if (obs_) { \
|
||||
obs_->func_ params_; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif // nsTObserverArray_h___
|
||||
|
|
Загрузка…
Ссылка в новой задаче