зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1673837 - Part 1: Create nsDOMMutationEnterLeave RAII class r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D95352
This commit is contained in:
Родитель
95066793fc
Коммит
f34f7cb3e7
|
@ -60,10 +60,7 @@ enum class IsRemoveNotification {
|
|||
// |Document* doc|
|
||||
#define IMPL_MUTATION_NOTIFICATION(func_, content_, params_, remove_) \
|
||||
PR_BEGIN_MACRO \
|
||||
bool needsEnterLeave = doc->MayHaveDOMMutationObservers(); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::EnterMutationHandling(); \
|
||||
} \
|
||||
nsDOMMutationEnterLeave enterLeave(doc); \
|
||||
nsINode* node = content_; \
|
||||
COMPOSED_DOC_DECL \
|
||||
NS_ASSERTION(node->OwnerDoc() == doc, "Bogus document"); \
|
||||
|
@ -98,17 +95,11 @@ enum class IsRemoveNotification {
|
|||
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(); \
|
||||
} \
|
||||
nsDOMMutationEnterLeave enterLeave(doc); \
|
||||
nsINode* node = content_; \
|
||||
do { \
|
||||
nsINode::nsSlots* slots = node->GetExistingSlots(); \
|
||||
|
@ -122,9 +113,6 @@ enum class IsRemoveNotification {
|
|||
node = node->GetParentNode(); \
|
||||
} \
|
||||
} while (node); \
|
||||
if (needsEnterLeave) { \
|
||||
nsDOMMutationObserver::LeaveMutationHandling(); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -875,4 +875,22 @@ inline nsDOMMutationObserver* nsMutationReceiverBase::Observer() {
|
|||
: static_cast<nsDOMMutationObserver*>(mObserver);
|
||||
}
|
||||
|
||||
class MOZ_RAII nsDOMMutationEnterLeave {
|
||||
public:
|
||||
explicit nsDOMMutationEnterLeave(mozilla::dom::Document* aDoc)
|
||||
: mNeeded(aDoc->MayHaveDOMMutationObservers()) {
|
||||
if (mNeeded) {
|
||||
nsDOMMutationObserver::EnterMutationHandling();
|
||||
}
|
||||
}
|
||||
~nsDOMMutationEnterLeave() {
|
||||
if (mNeeded) {
|
||||
nsDOMMutationObserver::LeaveMutationHandling();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const bool mNeeded;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче