зеркало из https://github.com/mozilla/gecko-dev.git
Bug 577438 Part 1: Add previous sibling to nsIMutationObserver::ContentRemoved. r=sicking
This commit is contained in:
Родитель
bcc5c512e8
Коммит
4caec055d0
|
@ -1250,7 +1250,8 @@ nsDocAccessible::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
|||
|
||||
void
|
||||
nsDocAccessible::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, PRInt32 /* unused */)
|
||||
nsIContent* aChild, PRInt32 /* unused */,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
// It's no needed to invalidate the subtree of the removed element,
|
||||
// because we get notifications directly from content (see
|
||||
|
|
|
@ -45,8 +45,8 @@ class nsIDocument;
|
|||
class nsINode;
|
||||
|
||||
#define NS_IMUTATION_OBSERVER_IID \
|
||||
{0x365d600b, 0x868a, 0x452a, \
|
||||
{0x8d, 0xe8, 0xf4, 0x6f, 0xad, 0x8f, 0xee, 0x53 } }
|
||||
{ 0x85eea794, 0xed8e, 0x4e1b, \
|
||||
{ 0xa1, 0x28, 0xd0, 0x93, 0x00, 0xae, 0x51, 0xaa } }
|
||||
|
||||
/**
|
||||
* Information details about a characterdata change. Basically, we
|
||||
|
@ -259,6 +259,8 @@ public:
|
|||
* @param aChild The child that was removed.
|
||||
* @param aIndexInContainer The index in the container which the child used
|
||||
* to have.
|
||||
* @param aPreviousSibling The previous sibling to the child that was removed.
|
||||
* Can be null if there was no previous sibling.
|
||||
*
|
||||
* @note Callers of this method might not hold a strong reference to the
|
||||
* observer. The observer is responsible for making sure it stays
|
||||
|
@ -269,7 +271,8 @@ public:
|
|||
virtual void ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling) = 0;
|
||||
|
||||
/**
|
||||
* The node is in the process of being destroyed. Calling QI on the node is
|
||||
|
@ -351,7 +354,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutationObserver, NS_IMUTATION_OBSERVER_IID)
|
|||
virtual void ContentRemoved(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer);
|
||||
PRInt32 aIndexInContainer, \
|
||||
nsIContent* aPreviousSibling);
|
||||
|
||||
#define NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED \
|
||||
virtual void NodeWillBeDestroyed(const nsINode* aNode);
|
||||
|
@ -423,7 +427,8 @@ void \
|
|||
_class::ContentRemoved(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer) \
|
||||
PRInt32 aIndexInContainer, \
|
||||
nsIContent* aPreviousSibling) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
|
|
|
@ -750,7 +750,8 @@ void
|
|||
nsContentList::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
// Note that aContainer can be null here if we are removing from
|
||||
// the document itself; any attempted optimizations to this method
|
||||
|
|
|
@ -1907,11 +1907,13 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
|||
for (PRInt32 i = PRInt32(count) - 1; i >= 0; i--) {
|
||||
nsCOMPtr<nsIContent> content = mChildren.ChildAt(i);
|
||||
|
||||
nsIContent* previousSibling = content->GetPreviousSibling();
|
||||
|
||||
if (nsINode::GetFirstChild() == content) {
|
||||
mFirstChild = content->GetNextSibling();
|
||||
}
|
||||
mChildren.RemoveChildAt(i);
|
||||
nsNodeUtils::ContentRemoved(this, content, i);
|
||||
nsNodeUtils::ContentRemoved(this, content, i, previousSibling);
|
||||
content->UnbindFromTree();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3676,6 +3676,8 @@ nsINode::doRemoveChildAt(PRUint32 aIndex, PRBool aNotify,
|
|||
}
|
||||
}
|
||||
|
||||
nsIContent* previousSibling = aKid->GetPreviousSibling();
|
||||
|
||||
if (GetFirstChild() == aKid) {
|
||||
mFirstChild = aKid->GetNextSibling();
|
||||
}
|
||||
|
@ -3683,7 +3685,7 @@ nsINode::doRemoveChildAt(PRUint32 aIndex, PRBool aNotify,
|
|||
aChildArray.RemoveChildAt(aIndex);
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::ContentRemoved(this, aKid, aIndex);
|
||||
nsNodeUtils::ContentRemoved(this, aKid, aIndex, previousSibling);
|
||||
}
|
||||
|
||||
aKid->UnbindFromTree();
|
||||
|
|
|
@ -379,7 +379,8 @@ void nsNodeIterator::ContentInserted(nsIDocument *aDocument,
|
|||
void nsNodeIterator::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent *aContainer,
|
||||
nsIContent *aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent *aPreviousSibling)
|
||||
{
|
||||
nsINode *container = NODE_FROM(aContainer, aDocument);
|
||||
|
||||
|
|
|
@ -167,7 +167,8 @@ nsNodeUtils::ContentInserted(nsINode* aContainer,
|
|||
void
|
||||
nsNodeUtils::ContentRemoved(nsINode* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
NS_PRECONDITION(aContainer->IsNodeOfType(nsINode::eCONTENT) ||
|
||||
aContainer->IsNodeOfType(nsINode::eDOCUMENT),
|
||||
|
@ -185,7 +186,8 @@ nsNodeUtils::ContentRemoved(nsINode* aContainer,
|
|||
}
|
||||
|
||||
IMPL_MUTATION_NOTIFICATION(ContentRemoved, aContainer,
|
||||
(document, container, aChild, aIndexInContainer));
|
||||
(document, container, aChild, aIndexInContainer,
|
||||
aPreviousSibling));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -126,7 +126,8 @@ public:
|
|||
*/
|
||||
static void ContentRemoved(nsINode* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling);
|
||||
/**
|
||||
* Send ParentChainChanged notifications to nsIMutationObservers
|
||||
* @param aContent The piece of content that had its parent changed.
|
||||
|
|
|
@ -315,7 +315,8 @@ void
|
|||
nsRange::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
NS_ASSERTION(mIsPositioned, "shouldn't be notified if not positioned");
|
||||
|
||||
|
|
|
@ -97,20 +97,12 @@ public:
|
|||
virtual nsresult SetStart(nsINode* aParent, PRInt32 aOffset);
|
||||
virtual nsresult SetEnd(nsINode* aParent, PRInt32 aOffset);
|
||||
virtual nsresult CloneRange(nsIRange** aNewRange) const;
|
||||
|
||||
|
||||
// nsIMutationObserver methods
|
||||
virtual void CharacterDataChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
CharacterDataChangeInfo* aChangeInfo);
|
||||
virtual void ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void ParentChainChanged(nsIContent *aContent);
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
|
||||
|
||||
private:
|
||||
// no copy's or assigns
|
||||
|
|
|
@ -458,9 +458,10 @@ nsTextStateManager::ContentInserted(nsIDocument* aDocument,
|
|||
|
||||
void
|
||||
nsTextStateManager::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
PRUint32 offset = 0, childOffset = 1;
|
||||
if (NS_FAILED(nsContentEventHandler::GetFlatTextOffsetOfRange(
|
||||
|
|
|
@ -396,10 +396,11 @@ nsXMLEventsManager::ContentInserted(nsIDocument* aDocument,
|
|||
}
|
||||
|
||||
void
|
||||
nsXMLEventsManager::ContentRemoved(nsIDocument* aDocument,
|
||||
nsXMLEventsManager::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
if (!aChild || !aChild->IsElement())
|
||||
return;
|
||||
|
@ -420,6 +421,6 @@ nsXMLEventsManager::ContentRemoved(nsIDocument* aDocument,
|
|||
|
||||
PRUint32 count = aChild->GetChildCount();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
ContentRemoved(aDocument, aChild, aChild->GetChildAt(i), i);
|
||||
ContentRemoved(aDocument, aChild, aChild->GetChildAt(i), i, aChild->GetPreviousSibling());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,8 @@ void nsHTMLOutputElement::ContentInserted(nsIDocument* aDocument,
|
|||
void nsHTMLOutputElement::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
DescendantsChanged();
|
||||
}
|
||||
|
|
|
@ -220,7 +220,8 @@ void
|
|||
nsHTMLStyleElement::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
ContentChanged(aChild);
|
||||
}
|
||||
|
|
|
@ -976,7 +976,8 @@ void
|
|||
nsHTMLTextAreaElement::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
ContentChanged(aChild);
|
||||
}
|
||||
|
|
|
@ -165,7 +165,8 @@ void
|
|||
nsHTMLTitleElement::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent *aContainer,
|
||||
nsIContent *aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent *aPreviousSibling)
|
||||
{
|
||||
SendTitleChangeEvent(PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -1899,7 +1899,8 @@ void
|
|||
nsAnonDivObserver::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
mTextEditorState->ClearValueCache();
|
||||
}
|
||||
|
|
|
@ -246,7 +246,8 @@ void
|
|||
nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
ContentChanged(aChild);
|
||||
}
|
||||
|
|
|
@ -147,7 +147,8 @@ void
|
|||
nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent *aContainer,
|
||||
nsIContent *aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent *aPreviousSibling)
|
||||
{
|
||||
SendTitleChangeEvent(PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -231,7 +231,8 @@ void
|
|||
nsSVGUseElement::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent *aContainer,
|
||||
nsIContent *aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent *aPreviousSibling)
|
||||
{
|
||||
if (nsContentUtils::IsInSameAnonymousTree(this, aChild)) {
|
||||
TriggerReclone();
|
||||
|
|
|
@ -1622,7 +1622,8 @@ void
|
|||
nsBindingManager::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
if (aContainer && aIndexInContainer != -1 &&
|
||||
(mContentListTable.ops || mAnonymousNodesTable.ops)) {
|
||||
|
|
|
@ -265,7 +265,8 @@ void
|
|||
nsXMLPrettyPrinter::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
MaybeUnhook(aContainer);
|
||||
}
|
||||
|
|
|
@ -278,7 +278,8 @@ void
|
|||
nsXPathResult::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
Invalidate(aContainer);
|
||||
}
|
||||
|
|
|
@ -1258,7 +1258,8 @@ void
|
|||
txMozillaXSLTProcessor::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
mStylesheet = nsnull;
|
||||
}
|
||||
|
|
|
@ -1131,7 +1131,8 @@ void
|
|||
nsXULDocument::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
NS_ASSERTION(aDocument == this, "unexpected doc");
|
||||
|
||||
|
|
|
@ -1141,7 +1141,8 @@ void
|
|||
nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
if (mRoot && nsContentUtils::ContentIsDescendantOf(mRoot, aChild)) {
|
||||
nsRefPtr<nsXULTemplateBuilder> kungFuDeathGrip(this);
|
||||
|
|
|
@ -819,7 +819,8 @@ void
|
|||
nsSHEntry::ContentRemoved(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
DocumentMutated();
|
||||
}
|
||||
|
|
|
@ -257,7 +257,8 @@ nsHTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
|
|||
docObserver->BeginUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
|
||||
docObserver->ContentRemoved(content->GetCurrentDoc(),
|
||||
aParentContent, content, -1);
|
||||
aParentContent, content, -1,
|
||||
content->GetPreviousSibling());
|
||||
if (document)
|
||||
docObserver->EndUpdate(document, UPDATE_CONTENT_MODEL);
|
||||
}
|
||||
|
|
|
@ -3870,7 +3870,8 @@ nsHTMLEditor::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
|||
|
||||
void
|
||||
nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, PRInt32 aIndexInContainer)
|
||||
nsIContent* aChild, PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
if (SameCOMIdentity(aChild, mRootElement)) {
|
||||
ResetRootElementAndEventTarget();
|
||||
|
|
|
@ -5045,7 +5045,8 @@ void
|
|||
PresShell::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved");
|
||||
NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
|
||||
|
|
|
@ -960,7 +960,8 @@ void
|
|||
nsImageMap::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
MaybeUpdateAreas(aContainer);
|
||||
}
|
||||
|
|
|
@ -912,7 +912,9 @@ inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
|||
}
|
||||
|
||||
void
|
||||
inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer)
|
||||
inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
if (!mTree)
|
||||
return;
|
||||
|
|
|
@ -216,7 +216,8 @@ void
|
|||
nsSVGRenderingObserver::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent *aContainer,
|
||||
nsIContent *aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent *aPreviousSibling)
|
||||
{
|
||||
DoUpdate();
|
||||
}
|
||||
|
|
|
@ -1076,9 +1076,10 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument,
|
|||
|
||||
void
|
||||
nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
NS_ASSERTION(aChild, "null ptr");
|
||||
|
||||
|
|
|
@ -161,7 +161,8 @@ void nsMenuGroupOwnerX::AttributeChanged(nsIDocument * aDocument,
|
|||
void nsMenuGroupOwnerX::ContentRemoved(nsIDocument * aDocument,
|
||||
nsIContent * aContainer,
|
||||
nsIContent * aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
PRInt32 aIndexInContainer,
|
||||
nsIContent * aPreviousSibling)
|
||||
{
|
||||
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
|
||||
nsChangeObserver* obs = LookupContentChangeObserver(aContainer);
|
||||
|
|
Загрузка…
Ссылка в новой задаче