зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1593222: part 9) Move non-animation notification methods from `nsNodeUtils` to `MutationObservers`. r=smaug
The remaining notification methods are moved in a separate commit. The files are renamed to `MutationObservers.*` in a follow-up commit. Depends on D51824 Differential Revision: https://phabricator.services.mozilla.com/D51825 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
80f7994283
Коммит
ba0285f534
|
@ -247,7 +247,7 @@ nsresult CharacterData::SetTextInternal(
|
|||
if (aNotify) {
|
||||
CharacterDataChangeInfo info = {aOffset == textLength, aOffset, endOffset,
|
||||
aLength, aDetails};
|
||||
nsNodeUtils::CharacterDataWillChange(this, info);
|
||||
MutationObservers::NotifyCharacterDataWillChange(this, info);
|
||||
}
|
||||
|
||||
Directionality oldDir = eDir_NotSet;
|
||||
|
@ -326,7 +326,7 @@ nsresult CharacterData::SetTextInternal(
|
|||
if (aNotify) {
|
||||
CharacterDataChangeInfo info = {aOffset == textLength, aOffset, endOffset,
|
||||
aLength, aDetails};
|
||||
nsNodeUtils::CharacterDataChanged(this, info);
|
||||
MutationObservers::NotifyCharacterDataChanged(this, info);
|
||||
|
||||
if (haveMutationListeners) {
|
||||
InternalMutationEvent mutation(true, eLegacyCharacterDataModified);
|
||||
|
@ -484,9 +484,9 @@ nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
SetSubtreeRootPointer(aParent.SubtreeRoot());
|
||||
}
|
||||
|
||||
nsNodeUtils::ParentChainChanged(this);
|
||||
MutationObservers::NotifyParentChainChanged(this);
|
||||
if (!hadParent && IsRootOfNativeAnonymousSubtree()) {
|
||||
nsNodeUtils::NativeAnonymousChildListChange(this, false);
|
||||
MutationObservers::NotifyNativeAnonymousChildListChange(this, false);
|
||||
}
|
||||
|
||||
UpdateEditableState(false);
|
||||
|
@ -521,7 +521,7 @@ void CharacterData::UnbindFromTree(bool aNullParent) {
|
|||
|
||||
if (aNullParent) {
|
||||
if (IsRootOfNativeAnonymousSubtree()) {
|
||||
nsNodeUtils::NativeAnonymousChildListChange(this, true);
|
||||
MutationObservers::NotifyNativeAnonymousChildListChange(this, true);
|
||||
}
|
||||
if (GetParent()) {
|
||||
NS_RELEASE(mParent);
|
||||
|
@ -561,7 +561,7 @@ void CharacterData::UnbindFromTree(bool aNullParent) {
|
|||
}
|
||||
}
|
||||
|
||||
nsNodeUtils::ParentChainChanged(this);
|
||||
MutationObservers::NotifyParentChainChanged(this);
|
||||
|
||||
#if defined(ACCESSIBILITY) && defined(DEBUG)
|
||||
MOZ_ASSERT(!GetAccService() || !GetAccService()->HasAccessible(this),
|
||||
|
|
|
@ -2330,7 +2330,7 @@ void Document::DisconnectNodeTree() {
|
|||
// now-stale value.
|
||||
mCachedRootElement = nullptr;
|
||||
}
|
||||
nsNodeUtils::ContentRemoved(this, content, previousSibling);
|
||||
MutationObservers::NotifyContentRemoved(this, content, previousSibling);
|
||||
content->UnbindFromTree();
|
||||
}
|
||||
MOZ_ASSERT(!mCachedRootElement,
|
||||
|
|
|
@ -1627,9 +1627,9 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
}
|
||||
}
|
||||
|
||||
nsNodeUtils::ParentChainChanged(this);
|
||||
MutationObservers::NotifyParentChainChanged(this);
|
||||
if (!hadParent && IsRootOfNativeAnonymousSubtree()) {
|
||||
nsNodeUtils::NativeAnonymousChildListChange(this, false);
|
||||
MutationObservers::NotifyNativeAnonymousChildListChange(this, false);
|
||||
}
|
||||
|
||||
// Ensure we only run this once, in the case we move the ShadowRoot around.
|
||||
|
@ -1769,7 +1769,7 @@ void Element::UnbindFromTree(bool aNullParent) {
|
|||
|
||||
if (aNullParent) {
|
||||
if (IsRootOfNativeAnonymousSubtree()) {
|
||||
nsNodeUtils::NativeAnonymousChildListChange(this, true);
|
||||
MutationObservers::NotifyNativeAnonymousChildListChange(this, true);
|
||||
}
|
||||
|
||||
if (GetParent()) {
|
||||
|
@ -1909,7 +1909,7 @@ void Element::UnbindFromTree(bool aNullParent) {
|
|||
child->UnbindFromTree(false);
|
||||
}
|
||||
|
||||
nsNodeUtils::ParentChainChanged(this);
|
||||
MutationObservers::NotifyParentChainChanged(this);
|
||||
|
||||
// Unbind children of shadow root.
|
||||
if (ShadowRoot* shadowRoot = GetShadowRoot()) {
|
||||
|
@ -2236,7 +2236,8 @@ bool Element::OnlyNotifySameValueSet(int32_t aNamespaceID, nsAtom* aName,
|
|||
}
|
||||
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
nsNodeUtils::AttributeSetToCurrentValue(this, aNamespaceID, aName);
|
||||
MutationObservers::NotifyAttributeSetToCurrentValue(this, aNamespaceID,
|
||||
aName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2285,7 +2286,8 @@ nsresult Element::SetAttr(int32_t aNamespaceID, nsAtom* aName, nsAtom* aPrefix,
|
|||
}
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType);
|
||||
MutationObservers::NotifyAttributeWillChange(this, aNamespaceID, aName,
|
||||
modType);
|
||||
}
|
||||
|
||||
// Hold a script blocker while calling ParseAttribute since that can call
|
||||
|
@ -2331,7 +2333,8 @@ nsresult Element::SetParsedAttr(int32_t aNamespaceID, nsAtom* aName,
|
|||
}
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType);
|
||||
MutationObservers::NotifyAttributeWillChange(this, aNamespaceID, aName,
|
||||
modType);
|
||||
}
|
||||
|
||||
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
|
||||
|
@ -2467,7 +2470,7 @@ nsresult Element::SetAttrAndNotify(
|
|||
// Don't pass aOldValue to AttributeChanged since it may not be reliable.
|
||||
// Callers only compute aOldValue under certain conditions which may not
|
||||
// be triggered by all nsIMutationObservers.
|
||||
nsNodeUtils::AttributeChanged(
|
||||
MutationObservers::NotifyAttributeChanged(
|
||||
this, aNamespaceID, aName, aModType,
|
||||
aParsedValue.StoresOwnData() ? &aParsedValue : nullptr);
|
||||
}
|
||||
|
@ -2672,8 +2675,8 @@ nsresult Element::UnsetAttr(int32_t aNameSpaceID, nsAtom* aName, bool aNotify) {
|
|||
mozAutoDocUpdate updateBatch(document, aNotify);
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeWillChange(this, aNameSpaceID, aName,
|
||||
MutationEvent_Binding::REMOVAL);
|
||||
MutationObservers::NotifyAttributeWillChange(
|
||||
this, aNameSpaceID, aName, MutationEvent_Binding::REMOVAL);
|
||||
}
|
||||
|
||||
nsresult rv = BeforeSetAttr(aNameSpaceID, aName, nullptr, aNotify);
|
||||
|
@ -2750,8 +2753,8 @@ nsresult Element::UnsetAttr(int32_t aNameSpaceID, nsAtom* aName, bool aNotify) {
|
|||
if (aNotify) {
|
||||
// We can always pass oldValue here since there is no new value which could
|
||||
// have corrupted it.
|
||||
nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName,
|
||||
MutationEvent_Binding::REMOVAL, &oldValue);
|
||||
MutationObservers::NotifyAttributeChanged(
|
||||
this, aNameSpaceID, aName, MutationEvent_Binding::REMOVAL, &oldValue);
|
||||
}
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::dir) {
|
||||
|
|
|
@ -1200,7 +1200,7 @@ void nsContentSink::NotifyAppend(nsIContent* aContainer, uint32_t aStartIndex) {
|
|||
//
|
||||
// Note that aContainer->OwnerDoc() may not be mDocument.
|
||||
MOZ_AUTO_DOC_UPDATE(aContainer->OwnerDoc(), true);
|
||||
nsNodeUtils::ContentAppended(
|
||||
MutationObservers::NotifyContentAppended(
|
||||
aContainer, aContainer->GetChildAt_Deprecated(aStartIndex));
|
||||
mLastNotificationTime = PR_Now();
|
||||
}
|
||||
|
|
|
@ -1390,9 +1390,9 @@ nsresult nsINode::InsertChildBefore(nsIContent* aKid,
|
|||
// Note that we always want to call ContentInserted when things are added
|
||||
// as kids to documents
|
||||
if (parent && !aChildToInsertBefore) {
|
||||
nsNodeUtils::ContentAppended(parent, aKid);
|
||||
MutationObservers::NotifyContentAppended(parent, aKid);
|
||||
} else {
|
||||
nsNodeUtils::ContentInserted(this, aKid);
|
||||
MutationObservers::NotifyContentInserted(this, aKid);
|
||||
}
|
||||
|
||||
if (nsContentUtils::HasMutationListeners(
|
||||
|
@ -1901,7 +1901,7 @@ void nsINode::RemoveChildNode(nsIContent* aKid, bool aNotify) {
|
|||
InvalidateChildNodes();
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::ContentRemoved(this, aKid, previousSibling);
|
||||
MutationObservers::NotifyContentRemoved(this, aKid, previousSibling);
|
||||
}
|
||||
|
||||
aKid->UnbindFromTree();
|
||||
|
@ -2444,8 +2444,8 @@ nsINode* nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
|||
if (aError.Failed()) {
|
||||
// Make sure to notify on any children that we did succeed to insert
|
||||
if (appending && i != 0) {
|
||||
nsNodeUtils::ContentAppended(static_cast<nsIContent*>(this),
|
||||
firstInsertedContent);
|
||||
MutationObservers::NotifyContentAppended(
|
||||
static_cast<nsIContent*>(this), firstInsertedContent);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2457,8 +2457,8 @@ nsINode* nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
|||
|
||||
// Notify and fire mutation events when appending
|
||||
if (appending) {
|
||||
nsNodeUtils::ContentAppended(static_cast<nsIContent*>(this),
|
||||
firstInsertedContent);
|
||||
MutationObservers::NotifyContentAppended(static_cast<nsIContent*>(this),
|
||||
firstInsertedContent);
|
||||
if (mutationBatch) {
|
||||
mutationBatch->NodesAdded();
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ class DOMQuad;
|
|||
class DOMRectReadOnly;
|
||||
class Element;
|
||||
class EventHandlerNonNull;
|
||||
class MutationObservers;
|
||||
template <typename T>
|
||||
class Optional;
|
||||
class OwningNodeOrString;
|
||||
|
@ -356,6 +357,7 @@ class nsINode : public mozilla::dom::EventTarget {
|
|||
void AddSizeOfIncludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const;
|
||||
|
||||
friend class nsNodeUtils;
|
||||
friend class mozilla::dom::MutationObservers;
|
||||
friend class nsNodeWeakReference;
|
||||
friend class nsNodeSupportsWeakRefTearoff;
|
||||
friend class AttrArray;
|
||||
|
|
|
@ -136,32 +136,37 @@ enum class IsRemoveNotification {
|
|||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
void nsNodeUtils::CharacterDataWillChange(
|
||||
namespace mozilla {
|
||||
void MutationObservers::NotifyCharacterDataWillChange(
|
||||
nsIContent* aContent, const CharacterDataChangeInfo& aInfo) {
|
||||
Document* doc = aContent->OwnerDoc();
|
||||
IMPL_MUTATION_NOTIFICATION(CharacterDataWillChange, aContent,
|
||||
(aContent, aInfo), IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::CharacterDataChanged(nsIContent* aContent,
|
||||
const CharacterDataChangeInfo& aInfo) {
|
||||
void MutationObservers::NotifyCharacterDataChanged(
|
||||
nsIContent* aContent, const CharacterDataChangeInfo& aInfo) {
|
||||
Document* doc = aContent->OwnerDoc();
|
||||
doc->Changed();
|
||||
IMPL_MUTATION_NOTIFICATION(CharacterDataChanged, aContent, (aContent, aInfo),
|
||||
IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::AttributeWillChange(Element* aElement, int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute, int32_t aModType) {
|
||||
void MutationObservers::NotifyAttributeWillChange(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute,
|
||||
int32_t aModType) {
|
||||
Document* doc = aElement->OwnerDoc();
|
||||
IMPL_MUTATION_NOTIFICATION(AttributeWillChange, aElement,
|
||||
(aElement, aNameSpaceID, aAttribute, aModType),
|
||||
IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute, int32_t aModType,
|
||||
const nsAttrValue* aOldValue) {
|
||||
void MutationObservers::NotifyAttributeChanged(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute,
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue) {
|
||||
Document* doc = aElement->OwnerDoc();
|
||||
doc->Changed();
|
||||
IMPL_MUTATION_NOTIFICATION(
|
||||
|
@ -170,25 +175,25 @@ void nsNodeUtils::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
|
|||
IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::AttributeSetToCurrentValue(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute) {
|
||||
void MutationObservers::NotifyAttributeSetToCurrentValue(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute) {
|
||||
Document* doc = aElement->OwnerDoc();
|
||||
IMPL_MUTATION_NOTIFICATION(AttributeSetToCurrentValue, aElement,
|
||||
(aElement, aNameSpaceID, aAttribute),
|
||||
IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::ContentAppended(nsIContent* aContainer,
|
||||
nsIContent* aFirstNewContent) {
|
||||
void MutationObservers::NotifyContentAppended(nsIContent* aContainer,
|
||||
nsIContent* aFirstNewContent) {
|
||||
Document* doc = aContainer->OwnerDoc();
|
||||
doc->Changed();
|
||||
IMPL_MUTATION_NOTIFICATION(ContentAppended, aContainer, (aFirstNewContent),
|
||||
IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::NativeAnonymousChildListChange(nsIContent* aContent,
|
||||
bool aIsRemove) {
|
||||
void MutationObservers::NotifyNativeAnonymousChildListChange(
|
||||
nsIContent* aContent, bool aIsRemove) {
|
||||
Document* doc = aContent->OwnerDoc();
|
||||
auto isRemove =
|
||||
aIsRemove ? IsRemoveNotification::Yes : IsRemoveNotification::No;
|
||||
|
@ -196,7 +201,8 @@ void nsNodeUtils::NativeAnonymousChildListChange(nsIContent* aContent,
|
|||
(aContent, aIsRemove), isRemove);
|
||||
}
|
||||
|
||||
void nsNodeUtils::ContentInserted(nsINode* aContainer, nsIContent* aChild) {
|
||||
void MutationObservers::NotifyContentInserted(nsINode* aContainer,
|
||||
nsIContent* aChild) {
|
||||
MOZ_ASSERT(aContainer->IsContent() || aContainer->IsDocument(),
|
||||
"container must be an nsIContent or an Document");
|
||||
Document* doc = aContainer->OwnerDoc();
|
||||
|
@ -205,8 +211,9 @@ void nsNodeUtils::ContentInserted(nsINode* aContainer, nsIContent* aChild) {
|
|||
IsRemoveNotification::No);
|
||||
}
|
||||
|
||||
void nsNodeUtils::ContentRemoved(nsINode* aContainer, nsIContent* aChild,
|
||||
nsIContent* aPreviousSibling) {
|
||||
void MutationObservers::NotifyContentRemoved(nsINode* aContainer,
|
||||
nsIContent* aChild,
|
||||
nsIContent* aPreviousSibling) {
|
||||
MOZ_ASSERT(aContainer->IsContent() || aContainer->IsDocument(),
|
||||
"container must be an nsIContent or an Document");
|
||||
Document* doc = aContainer->OwnerDoc();
|
||||
|
@ -217,6 +224,7 @@ void nsNodeUtils::ContentRemoved(nsINode* aContainer, nsIContent* aChild,
|
|||
(aChild, aPreviousSibling),
|
||||
IsRemoveNotification::Yes);
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
||||
void nsNodeUtils::AnimationMutated(
|
||||
dom::Animation* aAnimation, AnimationMutationType aMutatedType) {
|
||||
|
|
|
@ -19,10 +19,8 @@ namespace mozilla {
|
|||
struct NonOwningAnimationTarget;
|
||||
namespace dom {
|
||||
class Animation;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsNodeUtils {
|
||||
class MutationObservers {
|
||||
public:
|
||||
/**
|
||||
* Send CharacterDataWillChange notifications to nsIMutationObservers.
|
||||
|
@ -30,8 +28,8 @@ class nsNodeUtils {
|
|||
* @param aInfo Struct with information details about the change
|
||||
* @see nsIMutationObserver::CharacterDataWillChange
|
||||
*/
|
||||
static void CharacterDataWillChange(nsIContent* aContent,
|
||||
const CharacterDataChangeInfo&);
|
||||
static void NotifyCharacterDataWillChange(nsIContent* aContent,
|
||||
const CharacterDataChangeInfo&);
|
||||
|
||||
/**
|
||||
* Send CharacterDataChanged notifications to nsIMutationObservers.
|
||||
|
@ -39,8 +37,8 @@ class nsNodeUtils {
|
|||
* @param aInfo Struct with information details about the change
|
||||
* @see nsIMutationObserver::CharacterDataChanged
|
||||
*/
|
||||
static void CharacterDataChanged(nsIContent* aContent,
|
||||
const CharacterDataChangeInfo&);
|
||||
static void NotifyCharacterDataChanged(nsIContent* aContent,
|
||||
const CharacterDataChangeInfo&);
|
||||
|
||||
/**
|
||||
* Send AttributeWillChange notifications to nsIMutationObservers.
|
||||
|
@ -52,9 +50,9 @@ class nsNodeUtils {
|
|||
* preparsed it!!!
|
||||
* @see nsIMutationObserver::AttributeWillChange
|
||||
*/
|
||||
static void AttributeWillChange(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID, nsAtom* aAttribute,
|
||||
int32_t aModType);
|
||||
static void NotifyAttributeWillChange(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute, int32_t aModType);
|
||||
|
||||
/**
|
||||
* Send AttributeChanged notifications to nsIMutationObservers.
|
||||
|
@ -66,9 +64,10 @@ class nsNodeUtils {
|
|||
* that value, otherwise null
|
||||
* @see nsIMutationObserver::AttributeChanged
|
||||
*/
|
||||
static void AttributeChanged(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID, nsAtom* aAttribute,
|
||||
int32_t aModType, const nsAttrValue* aOldValue);
|
||||
static void NotifyAttributeChanged(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID, nsAtom* aAttribute,
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue);
|
||||
|
||||
/**
|
||||
* Send AttributeSetToCurrentValue notifications to nsIMutationObservers.
|
||||
|
@ -77,9 +76,9 @@ class nsNodeUtils {
|
|||
* @param aAttribute Local-name of the attribute
|
||||
* @see nsIMutationObserver::AttributeSetToCurrentValue
|
||||
*/
|
||||
static void AttributeSetToCurrentValue(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute);
|
||||
static void NotifyAttributeSetToCurrentValue(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute);
|
||||
|
||||
/**
|
||||
* Send ContentAppended notifications to nsIMutationObservers
|
||||
|
@ -87,8 +86,8 @@ class nsNodeUtils {
|
|||
* @param aFirstNewContent First new child
|
||||
* @see nsIMutationObserver::ContentAppended
|
||||
*/
|
||||
static void ContentAppended(nsIContent* aContainer,
|
||||
nsIContent* aFirstNewContent);
|
||||
static void NotifyContentAppended(nsIContent* aContainer,
|
||||
nsIContent* aFirstNewContent);
|
||||
|
||||
/**
|
||||
* Send NativeAnonymousChildList notifications to nsIMutationObservers
|
||||
|
@ -96,8 +95,8 @@ class nsNodeUtils {
|
|||
* @param aIsRemove True if it's a removal, false if an addition
|
||||
* @see nsIMutationObserver::NativeAnonymousChildListChange
|
||||
*/
|
||||
static void NativeAnonymousChildListChange(nsIContent* aContent,
|
||||
bool aIsRemove);
|
||||
static void NotifyNativeAnonymousChildListChange(nsIContent* aContent,
|
||||
bool aIsRemove);
|
||||
|
||||
/**
|
||||
* Send ContentInserted notifications to nsIMutationObservers
|
||||
|
@ -105,7 +104,7 @@ class nsNodeUtils {
|
|||
* @param aChild Newly inserted child
|
||||
* @see nsIMutationObserver::ContentInserted
|
||||
*/
|
||||
static void ContentInserted(nsINode* aContainer, nsIContent* aChild);
|
||||
static void NotifyContentInserted(nsINode* aContainer, nsIContent* aChild);
|
||||
/**
|
||||
* Send ContentRemoved notifications to nsIMutationObservers
|
||||
* @param aContainer Node from which child was removed
|
||||
|
@ -113,14 +112,15 @@ class nsNodeUtils {
|
|||
* @param aPreviousSibling Previous sibling of the removed child
|
||||
* @see nsIMutationObserver::ContentRemoved
|
||||
*/
|
||||
static void ContentRemoved(nsINode* aContainer, nsIContent* aChild,
|
||||
nsIContent* aPreviousSibling);
|
||||
static void NotifyContentRemoved(nsINode* aContainer, nsIContent* aChild,
|
||||
nsIContent* aPreviousSibling);
|
||||
|
||||
/**
|
||||
* Send ParentChainChanged notifications to nsIMutationObservers
|
||||
* @param aContent The piece of content that had its parent changed.
|
||||
* @see nsIMutationObserver::ParentChainChanged
|
||||
*/
|
||||
static inline void ParentChainChanged(nsIContent* aContent) {
|
||||
static inline void NotifyParentChainChanged(nsIContent* aContent) {
|
||||
nsINode::nsSlots* slots = aContent->GetExistingSlots();
|
||||
if (slots && !slots->mMutationObservers.IsEmpty()) {
|
||||
NS_OBSERVER_AUTO_ARRAY_NOTIFY_OBSERVERS(slots->mMutationObservers,
|
||||
|
@ -128,7 +128,12 @@ class nsNodeUtils {
|
|||
ParentChainChanged, (aContent));
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsNodeUtils {
|
||||
public:
|
||||
/**
|
||||
* Notify that an animation is added/changed/removed.
|
||||
* @param aAnimation The animation we added/changed/removed.
|
||||
|
|
|
@ -96,8 +96,8 @@ void nsStyledElement::InlineStyleDeclarationWillChange(
|
|||
aData.mModType =
|
||||
modification ? static_cast<uint8_t>(MutationEvent_Binding::MODIFICATION)
|
||||
: static_cast<uint8_t>(MutationEvent_Binding::ADDITION);
|
||||
nsNodeUtils::AttributeWillChange(this, kNameSpaceID_None, nsGkAtoms::style,
|
||||
aData.mModType);
|
||||
MutationObservers::NotifyAttributeWillChange(
|
||||
this, kNameSpaceID_None, nsGkAtoms::style, aData.mModType);
|
||||
|
||||
// XXXsmaug In order to make attribute handling more consistent, consider to
|
||||
// call BeforeSetAttr and pass kCallAfterSetAttr to
|
||||
|
|
|
@ -872,7 +872,8 @@ void HTMLContentSink::NotifyInsert(nsIContent* aContent,
|
|||
// Note that aContent->OwnerDoc() may be different to mDocument already.
|
||||
MOZ_AUTO_DOC_UPDATE(aContent ? aContent->OwnerDoc() : mDocument.get(),
|
||||
true);
|
||||
nsNodeUtils::ContentInserted(NODE_FROM(aContent, mDocument), aChildContent);
|
||||
MutationObservers::NotifyContentInserted(NODE_FROM(aContent, mDocument),
|
||||
aChildContent);
|
||||
mLastNotificationTime = PR_Now();
|
||||
}
|
||||
|
||||
|
|
|
@ -1291,7 +1291,8 @@ nsAttrValue SVGElement::WillChangeValue(nsAtom* aName) {
|
|||
uint8_t modType =
|
||||
attrValue ? static_cast<uint8_t>(MutationEvent_Binding::MODIFICATION)
|
||||
: static_cast<uint8_t>(MutationEvent_Binding::ADDITION);
|
||||
nsNodeUtils::AttributeWillChange(this, kNameSpaceID_None, aName, modType);
|
||||
MutationObservers::NotifyAttributeWillChange(this, kNameSpaceID_None, aName,
|
||||
modType);
|
||||
|
||||
// This is not strictly correct--the attribute value parameter for
|
||||
// BeforeSetAttr should reflect the value that *will* be set but that implies
|
||||
|
@ -2040,13 +2041,13 @@ void SVGElement::DidAnimateTransformList(int32_t aModType) {
|
|||
nsAtom* transformAttr = GetTransformListAttrName();
|
||||
frame->AttributeChanged(kNameSpaceID_None, transformAttr, aModType);
|
||||
// When script changes the 'transform' attribute, Element::SetAttrAndNotify
|
||||
// will call nsNodeUtils::AttributeChanged, under which
|
||||
// will call MutationObservers::NotifyAttributeChanged, under which
|
||||
// SVGTransformableElement::GetAttributeChangeHint will be called and an
|
||||
// appropriate change event posted to update our frame's overflow rects.
|
||||
// The SetAttrAndNotify doesn't happen for transform changes caused by
|
||||
// 'animateTransform' though (and sending out the mutation events that
|
||||
// nsNodeUtils::AttributeChanged dispatches would be inappropriate
|
||||
// anyway), so we need to post the change event ourself.
|
||||
// MutationObservers::NotifyAttributeChanged dispatches would be
|
||||
// inappropriate anyway), so we need to post the change event ourself.
|
||||
nsChangeHint changeHint = GetAttributeChangeHint(transformAttr, aModType);
|
||||
if (changeHint) {
|
||||
nsLayoutUtils::PostRestyleEvent(this, RestyleHint{0}, changeHint);
|
||||
|
|
|
@ -369,7 +369,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) {
|
|||
NS_ASSERTION(mDocument->ComputeIndexOf(rootElement) != -1,
|
||||
"rootElement not in doc?");
|
||||
mDocument->BeginUpdate();
|
||||
nsNodeUtils::ContentInserted(mDocument, rootElement);
|
||||
MutationObservers::NotifyContentInserted(mDocument, rootElement);
|
||||
mDocument->EndUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -218,12 +218,12 @@ nsresult nsHtml5TreeOperation::AppendTextToTextNode(
|
|||
MOZ_ASSERT(aBuilder->IsInDocUpdate());
|
||||
uint32_t oldLength = aTextNode->TextLength();
|
||||
CharacterDataChangeInfo info = {true, oldLength, oldLength, aLength};
|
||||
nsNodeUtils::CharacterDataWillChange(aTextNode, info);
|
||||
MutationObservers::NotifyCharacterDataWillChange(aTextNode, info);
|
||||
|
||||
nsresult rv = aTextNode->AppendText(aBuffer, aLength, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsNodeUtils::CharacterDataChanged(aTextNode, info);
|
||||
MutationObservers::NotifyCharacterDataChanged(aTextNode, info);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ nsresult nsHtml5TreeOperation::Append(nsIContent* aNode, nsIContent* aParent,
|
|||
rv = aParent->AppendChildTo(aNode, false);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aNode->SetParserHasNotified();
|
||||
nsNodeUtils::ContentAppended(aParent, aNode);
|
||||
MutationObservers::NotifyContentAppended(aParent, aNode);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ nsresult nsHtml5TreeOperation::AppendToDocument(
|
|||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aNode->SetParserHasNotified();
|
||||
nsNodeUtils::ContentInserted(doc, aNode);
|
||||
MutationObservers::NotifyContentInserted(doc, aNode);
|
||||
|
||||
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
||||
"Someone forgot to block scripts");
|
||||
|
@ -329,7 +329,7 @@ nsresult nsHtml5TreeOperation::AppendChildrenToNewParent(
|
|||
didAppend = true;
|
||||
}
|
||||
if (didAppend) {
|
||||
nsNodeUtils::ContentAppended(aParent, aParent->GetLastChild());
|
||||
MutationObservers::NotifyContentAppended(aParent, aParent->GetLastChild());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ nsresult nsHtml5TreeOperation::FosterParent(nsIContent* aNode,
|
|||
|
||||
nsresult rv = foster->InsertChildBefore(aNode, aTable, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsNodeUtils::ContentInserted(foster, aNode);
|
||||
MutationObservers::NotifyContentInserted(foster, aNode);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,7 @@ nsresult nsHtml5TreeOperation::FosterParentText(
|
|||
|
||||
rv = foster->InsertChildBefore(text, aTable, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsNodeUtils::ContentInserted(foster, text);
|
||||
MutationObservers::NotifyContentInserted(foster, text);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче