зеркало из https://github.com/mozilla/gecko-dev.git
Bug 484988 - Make HTML5 parser-performed removals notify but not fire mutation events
This commit is contained in:
Родитель
604f0b133c
Коммит
5f070d1f64
|
@ -436,10 +436,13 @@ public:
|
|||
* @param aNotify whether to notify the document (current document for
|
||||
* nsIContent, and |this| for nsIDocument) that the remove has
|
||||
* occurred
|
||||
* @param aMutationEvent whether to fire a mutation event
|
||||
*
|
||||
* Note: If there is no child at aIndex, this method will simply do nothing.
|
||||
*/
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify) = 0;
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex,
|
||||
PRBool aNotify,
|
||||
PRBool aMutationEvent = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Get a property associated with this node.
|
||||
|
|
|
@ -699,8 +699,9 @@ nsDOMAttribute::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on attribute child removal.");
|
||||
if (aIndex != 0 || !mChild) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
|
|
|
@ -3258,8 +3258,9 @@ nsDocument::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on document child removal.");
|
||||
nsCOMPtr<nsIContent> oldKid = GetChildAt(aIndex);
|
||||
if (!oldKid) {
|
||||
return NS_OK;
|
||||
|
@ -3271,7 +3272,8 @@ nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
|||
}
|
||||
|
||||
nsresult rv = nsGenericElement::doRemoveChildAt(aIndex, aNotify, oldKid,
|
||||
nsnull, this, mChildren);
|
||||
nsnull, this, mChildren,
|
||||
aMutationEvent);
|
||||
mCachedRootContent = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -808,7 +808,7 @@ public:
|
|||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
|
|
|
@ -759,7 +759,7 @@ nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsGenericDOMDataNode::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public:
|
|||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
|
|
|
@ -3315,14 +3315,14 @@ nsGenericElement::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
|
||||
NS_ASSERTION(oldKid == GetChildAt(aIndex), "Unexpected child in RemoveChildAt");
|
||||
|
||||
if (oldKid) {
|
||||
return doRemoveChildAt(aIndex, aNotify, oldKid, this, GetCurrentDoc(),
|
||||
mAttrsAndChildren);
|
||||
mAttrsAndChildren, aMutationEvent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3333,7 +3333,8 @@ nsresult
|
|||
nsGenericElement::doRemoveChildAt(PRUint32 aIndex, PRBool aNotify,
|
||||
nsIContent* aKid, nsIContent* aParent,
|
||||
nsIDocument* aDocument,
|
||||
nsAttrAndChildArray& aChildArray)
|
||||
nsAttrAndChildArray& aChildArray,
|
||||
PRBool aMutationEvent)
|
||||
{
|
||||
NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
|
||||
NS_PRECONDITION(!aParent || aParent->GetCurrentDoc() == aDocument,
|
||||
|
@ -3369,6 +3370,7 @@ nsGenericElement::doRemoveChildAt(PRUint32 aIndex, PRBool aNotify,
|
|||
|
||||
mozAutoSubtreeModified subtree(nsnull, nsnull);
|
||||
if (aNotify &&
|
||||
aMutationEvent &&
|
||||
nsContentUtils::HasMutationListeners(aKid,
|
||||
NS_EVENT_BITS_MUTATION_NODEREMOVED, container)) {
|
||||
mozAutoRemovableBlockerRemover blockerRemover;
|
||||
|
|
|
@ -353,7 +353,7 @@ public:
|
|||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
|
@ -657,7 +657,8 @@ public:
|
|||
static nsresult doRemoveChildAt(PRUint32 aIndex, PRBool aNotify,
|
||||
nsIContent* aKid, nsIContent* aParent,
|
||||
nsIDocument* aDocument,
|
||||
nsAttrAndChildArray& aChildArray);
|
||||
nsAttrAndChildArray& aChildArray,
|
||||
PRBool aMutationEvent);
|
||||
|
||||
/**
|
||||
* Helper methods for implementing querySelector/querySelectorAll
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
// nsGenericElement
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
|
||||
// nsIContent
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
|
@ -185,10 +185,11 @@ nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLOptGroupElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsHTMLOptGroupElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutation events on optgroup child removal.");
|
||||
nsSafeOptionListMutation safeMutation(GetSelect(), this, nsnull, aIndex);
|
||||
nsresult rv = nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
|
||||
nsresult rv = nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify, aMutationEvent);
|
||||
if (NS_FAILED(rv)) {
|
||||
safeMutation.MutationFailed();
|
||||
}
|
||||
|
|
|
@ -208,10 +208,11 @@ nsHTMLSelectElement::InsertChildAt(nsIContent* aKid,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLSelectElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsHTMLSelectElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on select child removal.");
|
||||
nsSafeOptionListMutation safeMutation(this, this, nsnull, aIndex);
|
||||
nsresult rv = nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify);
|
||||
nsresult rv = nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify, aMutationEvent);
|
||||
if (NS_FAILED(rv)) {
|
||||
safeMutation.MutationFailed();
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ public:
|
|||
virtual PRBool IsHTMLFocusable(PRBool *aIsFocusable, PRInt32 *aTabIndex);
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
|
||||
// Overriden nsIFormControl methods
|
||||
NS_IMETHOD_(PRInt32) GetType() const { return NS_FORM_SELECT; }
|
||||
|
|
|
@ -70,7 +70,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeBuilder* aBuilder)
|
|||
if (parent) {
|
||||
PRUint32 pos = parent->IndexOf(mNode);
|
||||
NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
|
||||
rv = parent->RemoveChildAt(pos, PR_TRUE);
|
||||
rv = parent->RemoveChildAt(pos, PR_TRUE, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// nsNodeUtils::ContentRemoved(parent, mNode, pos);
|
||||
}
|
||||
|
|
|
@ -119,9 +119,10 @@ nsSVGSwitchElement::InsertChildAt(nsIContent* aKid,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsSVGSwitchElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsSVGSwitchElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
nsresult rv = nsSVGSwitchElementBase::RemoveChildAt(aIndex, aNotify);
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on switch child removal.");
|
||||
nsresult rv = nsSVGSwitchElementBase::RemoveChildAt(aIndex, aNotify, aMutationEvent);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
MaybeInvalidate();
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
// nsINode
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
|
|
|
@ -264,12 +264,13 @@ nsXTFElementWrapper::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXTFElementWrapper::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsXTFElementWrapper::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on xtf child removal.");
|
||||
nsresult rv;
|
||||
if (mNotificationMask & nsIXTFElement::NOTIFY_WILL_REMOVE_CHILD)
|
||||
GetXTFElement()->WillRemoveChild(aIndex);
|
||||
rv = nsXTFElementWrapperBase::RemoveChildAt(aIndex, aNotify);
|
||||
rv = nsXTFElementWrapperBase::RemoveChildAt(aIndex, aNotify, aMutationEvent);
|
||||
if (mNotificationMask & nsIXTFElement::NOTIFY_CHILD_REMOVED)
|
||||
GetXTFElement()->ChildRemoved(aIndex);
|
||||
return rv;
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
PRBool aNullParent = PR_TRUE);
|
||||
nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
nsIAtom *GetIDAttributeName() const;
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom* aPrefix, const nsAString& aValue,
|
||||
|
|
|
@ -890,8 +890,9 @@ nsXULElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
|
||||
{
|
||||
NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on XUL child removal.");
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
|
||||
if (!oldKid) {
|
||||
|
@ -958,7 +959,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
|||
}
|
||||
}
|
||||
|
||||
rv = nsGenericElement::RemoveChildAt(aIndex, aNotify);
|
||||
rv = nsGenericElement::RemoveChildAt(aIndex, aNotify, aMutationEvent);
|
||||
|
||||
if (newCurrentIndex == -2)
|
||||
controlElement->SetCurrentItem(nsnull);
|
||||
|
|
|
@ -513,7 +513,7 @@ public:
|
|||
nsIContent* aBindingParent,
|
||||
PRBool aCompileEventHandlers);
|
||||
virtual void UnbindFromTree(PRBool aDeep, PRBool aNullParent);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent = PR_TRUE);
|
||||
virtual nsIAtom *GetIDAttributeName() const;
|
||||
virtual nsIAtom *GetClassAttributeName() const;
|
||||
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
|
|
Загрузка…
Ссылка в новой задаче