Bug 1469385 - Remove InsertChildAt_Deprecated and RemoveChildAt_Deprecated, r=bz,smaug

This commit is contained in:
catalin.badea392@gmail.com 2018-06-19 12:21:18 +03:00
Родитель be768be9d5
Коммит 9c36800bd7
24 изменённых файлов: 38 добавлений и 501 удалений

Просмотреть файл

@ -289,18 +289,6 @@ Attr::InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
nsresult
Attr::InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
void
Attr::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
}
void void
Attr::RemoveChildNode(nsIContent* aKid, bool aNotify) Attr::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -63,9 +63,6 @@ public:
virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override; virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
bool aPreallocateChildren) const override; bool aPreallocateChildren) const override;

Просмотреть файл

@ -634,19 +634,6 @@ CharacterData::InsertChildBefore(nsIContent* aKid,
return NS_OK; return NS_OK;
} }
nsresult
CharacterData::InsertChildAt_Deprecated(nsIContent* aKid,
uint32_t aIndex,
bool aNotify)
{
return NS_OK;
}
void
CharacterData::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
}
void void
CharacterData::RemoveChildNode(nsIContent* aKid, bool aNotify) CharacterData::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -105,9 +105,6 @@ public:
virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override; virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
virtual void GetTextContentInternal(nsAString& aTextContent, virtual void GetTextContentInternal(nsAString& aTextContent,
OOMReporter& aError) override OOMReporter& aError) override

Просмотреть файл

@ -1225,27 +1225,6 @@ FragmentOrElement::InsertChildBefore(nsIContent* aKid,
return doInsertChildAt(aKid, index, aNotify, mAttrsAndChildren); return doInsertChildAt(aKid, index, aNotify, mAttrsAndChildren);
} }
nsresult
FragmentOrElement::InsertChildAt_Deprecated(nsIContent* aKid,
uint32_t aIndex,
bool aNotify)
{
MOZ_ASSERT(aKid, "null ptr");
return doInsertChildAt(aKid, aIndex, aNotify, mAttrsAndChildren);
}
void
FragmentOrElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
NS_ASSERTION(oldKid == GetChildAt_Deprecated(aIndex), "Unexpected child in RemoveChildAt_Deprecated");
if (oldKid) {
doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren);
}
}
void void
FragmentOrElement::RemoveChildNode(nsIContent* aKid, bool aNotify) FragmentOrElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -98,9 +98,6 @@ public:
virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override; virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
virtual void GetTextContentInternal(nsAString& aTextContent, virtual void GetTextContentInternal(nsAString& aTextContent,
mozilla::OOMReporter& aError) override; mozilla::OOMReporter& aError) override;

Просмотреть файл

@ -4109,46 +4109,6 @@ nsIDocument::InsertChildBefore(nsIContent* aKid,
return doInsertChildAt(aKid, index, aNotify, mChildren); return doInsertChildAt(aKid, index, aNotify, mChildren);
} }
nsresult
nsIDocument::InsertChildAt_Deprecated(nsIContent* aKid,
uint32_t aIndex,
bool aNotify)
{
if (aKid->IsElement() && GetRootElement()) {
NS_WARNING("Inserting root element when we already have one");
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
}
return doInsertChildAt(aKid, aIndex, aNotify, mChildren);
}
void
nsIDocument::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
nsCOMPtr<nsIContent> oldKid = GetChildAt_Deprecated(aIndex);
if (!oldKid) {
return;
}
if (oldKid->IsElement()) {
// Destroy the link map up front before we mess with the child list.
DestroyElementMaps();
}
// Preemptively clear mCachedRootElement, since we may be about to remove it
// from our child list, and we don't want to return this maybe-obsolete value
// from any GetRootElement() calls that happen inside of doRemoveChildAt().
// (NOTE: for this to be useful, doRemoveChildAt() must NOT trigger any
// GetRootElement() calls until after it's removed the child from mChildren.
// Any call before that point would restore this soon-to-be-obsolete cached
// answer, and our clearing here would be fruitless.)
mCachedRootElement = nullptr;
doRemoveChildAt(aIndex, aNotify, oldKid, mChildren);
MOZ_ASSERT(mCachedRootElement != oldKid,
"Stale pointer in mCachedRootElement, after we tried to clear it "
"(maybe somebody called GetRootElement() too early?)");
}
void void
nsIDocument::RemoveChildNode(nsIContent* aKid, bool aNotify) nsIDocument::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -548,9 +548,6 @@ public:
nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) final;
void RemoveChildNode(nsIContent* aKid, bool aNotify) final; void RemoveChildNode(nsIContent* aKid, bool aNotify) final;
nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo,
nsINode **aResult, nsINode **aResult,

Просмотреть файл

@ -533,7 +533,7 @@ nsINode::GetNodeValueInternal(nsAString& aNodeValue)
nsINode* nsINode*
nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError) nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError)
{ {
if (IsCharacterData()) { if (!aOldChild.IsContent()) {
// aOldChild can't be one of our children. // aOldChild can't be one of our children.
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR); aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
return nullptr; return nullptr;
@ -543,14 +543,16 @@ nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError)
nsContentUtils::MaybeFireNodeRemoved(&aOldChild, this); nsContentUtils::MaybeFireNodeRemoved(&aOldChild, this);
} }
int32_t index = ComputeIndexOf(&aOldChild); // Check again, we may not be the child's parent anymore.
if (index == -1) { // Can be triggered by dom/base/crashtests/293388-1.html
if (aOldChild.AsContent()->IsRootOfAnonymousSubtree() ||
aOldChild.GetParentNode() != this) {
// aOldChild isn't one of our children. // aOldChild isn't one of our children.
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR); aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
return nullptr; return nullptr;
} }
RemoveChildAt_Deprecated(index, true); RemoveChildNode(aOldChild.AsContent(), true);
return &aOldChild; return &aOldChild;
} }
@ -640,7 +642,7 @@ nsINode::Normalize()
"Should always have a parent unless " "Should always have a parent unless "
"mutation events messed us up"); "mutation events messed us up");
if (parent) { if (parent) {
parent->RemoveChildAt_Deprecated(parent->ComputeIndexOf(node), true); parent->RemoveChildNode(node, true);
} }
} }
} }
@ -1997,11 +1999,12 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
} }
// Record the node to insert before, if any // Record the node to insert before, if any
nsINode* nodeToInsertBefore; nsIContent* nodeToInsertBefore;
if (aReplace) { if (aReplace) {
nodeToInsertBefore = aRefChild->GetNextSibling(); nodeToInsertBefore = aRefChild->GetNextSibling();
} else { } else {
nodeToInsertBefore = aRefChild; // Since aRefChild is our child, it must be an nsIContent object.
nodeToInsertBefore = aRefChild ? aRefChild->AsContent() : nullptr;
} }
if (nodeToInsertBefore == aNewChild) { if (nodeToInsertBefore == aNewChild) {
// We're going to remove aNewChild from its parent, so use its next sibling // We're going to remove aNewChild from its parent, so use its next sibling
@ -2015,14 +2018,6 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
nsIContent* newContent = aNewChild->AsContent(); nsIContent* newContent = aNewChild->AsContent();
nsCOMPtr<nsINode> oldParent = newContent->GetParentNode(); nsCOMPtr<nsINode> oldParent = newContent->GetParentNode();
if (oldParent) { if (oldParent) {
int32_t removeIndex = oldParent->ComputeIndexOf(newContent);
if (removeIndex < 0) {
// newContent is anonymous. We can't deal with this, so just bail
NS_ERROR("How come our flags didn't catch this?");
aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
// Hold a strong ref to nodeToInsertBefore across the removal of newContent // Hold a strong ref to nodeToInsertBefore across the removal of newContent
nsCOMPtr<nsINode> kungFuDeathGrip = nodeToInsertBefore; nsCOMPtr<nsINode> kungFuDeathGrip = nodeToInsertBefore;
@ -2034,11 +2029,14 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
{ {
mozAutoDocUpdate batch(newContent->GetComposedDoc(), true); mozAutoDocUpdate batch(newContent->GetComposedDoc(), true);
nsAutoMutationBatch mb(oldParent, true, true); nsAutoMutationBatch mb(oldParent, true, true);
oldParent->RemoveChildAt_Deprecated(removeIndex, true); // ScriptBlocker ensures previous and next stay alive.
nsIContent* previous = aNewChild->GetPreviousSibling();
nsIContent* next = aNewChild->GetNextSibling();
oldParent->RemoveChildNode(aNewChild->AsContent(), true);
if (nsAutoMutationBatch::GetCurrentBatch() == &mb) { if (nsAutoMutationBatch::GetCurrentBatch() == &mb) {
mb.RemovalDone(); mb.RemovalDone();
mb.SetPrevSibling(oldParent->GetChildAt_Deprecated(removeIndex - 1)); mb.SetPrevSibling(previous);
mb.SetNextSibling(oldParent->GetChildAt_Deprecated(removeIndex)); mb.SetNextSibling(next);
} }
} }
@ -2077,7 +2075,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
if (aReplace) { if (aReplace) {
nodeToInsertBefore = aRefChild->GetNextSibling(); nodeToInsertBefore = aRefChild->GetNextSibling();
} else { } else {
nodeToInsertBefore = aRefChild; nodeToInsertBefore = aRefChild ? aRefChild->AsContent() : nullptr;
} }
} }
} }
@ -2112,8 +2110,8 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
mozAutoDocUpdate batch(newContent->GetComposedDoc(), true); mozAutoDocUpdate batch(newContent->GetComposedDoc(), true);
nsAutoMutationBatch mb(newContent, false, true); nsAutoMutationBatch mb(newContent, false, true);
for (uint32_t i = count; i > 0;) { while (newContent->HasChildren()) {
newContent->RemoveChildAt_Deprecated(--i, true); newContent->RemoveChildNode(newContent->GetLastChild(), true);
} }
} }
@ -2151,7 +2149,8 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
if (aReplace) { if (aReplace) {
nodeToInsertBefore = aRefChild->GetNextSibling(); nodeToInsertBefore = aRefChild->GetNextSibling();
} else { } else {
nodeToInsertBefore = aRefChild; // If aRefChild has 'this' as a parent, it must be an nsIContent.
nodeToInsertBefore = aRefChild ? aRefChild->AsContent() : nullptr;
} }
// And verify that newContent is still allowed as our child. Sadly, we // And verify that newContent is still allowed as our child. Sadly, we
@ -2182,23 +2181,6 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
mozAutoDocUpdate batch(GetComposedDoc(), true); mozAutoDocUpdate batch(GetComposedDoc(), true);
nsAutoMutationBatch mb; nsAutoMutationBatch mb;
// Figure out which index we want to insert at. Note that we use
// nodeToInsertBefore to determine this, because it's possible that
// aRefChild == aNewChild, in which case we just removed it from the
// parent list.
int32_t insPos;
if (nodeToInsertBefore) {
insPos = ComputeIndexOf(nodeToInsertBefore);
if (insPos < 0) {
// XXXbz How the heck would _that_ happen, exactly?
aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
return nullptr;
}
}
else {
insPos = GetChildCount();
}
// If we're replacing and we haven't removed aRefChild yet, do so now // If we're replacing and we haven't removed aRefChild yet, do so now
if (aReplace && aRefChild != aNewChild) { if (aReplace && aRefChild != aNewChild) {
mb.Init(this, true, true); mb.Init(this, true, true);
@ -2208,11 +2190,11 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
NS_ASSERTION(aRefChild->GetNextSibling() == nodeToInsertBefore, NS_ASSERTION(aRefChild->GetNextSibling() == nodeToInsertBefore,
"Unexpected nodeToInsertBefore"); "Unexpected nodeToInsertBefore");
// An since nodeToInsertBefore is at index insPos, we want to remove nsIContent* toBeRemoved = nodeToInsertBefore ?
// at the previous index. nodeToInsertBefore->GetPreviousSibling() : GetLastChild();
NS_ASSERTION(insPos >= 1, "insPos too small"); MOZ_ASSERT(toBeRemoved);
RemoveChildAt_Deprecated(insPos-1, true);
--insPos; RemoveChildNode(toBeRemoved, true);
} }
// Move new child over to our document if needed. Do this after removing // Move new child over to our document if needed. Do this after removing
@ -2246,8 +2228,9 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
nsAutoMutationBatch* mutationBatch = nsAutoMutationBatch::GetCurrentBatch(); nsAutoMutationBatch* mutationBatch = nsAutoMutationBatch::GetCurrentBatch();
if (mutationBatch) { if (mutationBatch) {
mutationBatch->RemovalDone(); mutationBatch->RemovalDone();
mutationBatch->SetPrevSibling(GetChildAt_Deprecated(insPos - 1)); mutationBatch->SetPrevSibling(nodeToInsertBefore ?
mutationBatch->SetNextSibling(GetChildAt_Deprecated(insPos)); nodeToInsertBefore->GetPreviousSibling() : GetLastChild());
mutationBatch->SetNextSibling(nodeToInsertBefore);
} }
uint32_t count = fragChildren->Length(); uint32_t count = fragChildren->Length();
@ -2255,16 +2238,16 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
return result; return result;
} }
bool appending = !IsDocument() && uint32_t(insPos) == GetChildCount(); bool appending = !IsDocument() && !nodeToInsertBefore;
nsIContent* firstInsertedContent = fragChildren->ElementAt(0); nsIContent* firstInsertedContent = fragChildren->ElementAt(0);
// Iterate through the fragment's children, and insert them in the new // Iterate through the fragment's children, and insert them in the new
// parent // parent
for (uint32_t i = 0; i < count; ++i, ++insPos) { for (uint32_t i = 0; i < count; ++i) {
// XXXbz how come no reparenting here? That seems odd... // XXXbz how come no reparenting here? That seems odd...
// Insert the child. // Insert the child.
aError = InsertChildAt_Deprecated(fragChildren->ElementAt(i), insPos, aError = InsertChildBefore(fragChildren->ElementAt(i), nodeToInsertBefore,
!appending); !appending);
if (aError.Failed()) { if (aError.Failed()) {
// Make sure to notify on any children that we did succeed to insert // Make sure to notify on any children that we did succeed to insert
if (appending && i != 0) { if (appending && i != 0) {
@ -2300,13 +2283,13 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
// We need to reparent here for nodes for which the parent of their // We need to reparent here for nodes for which the parent of their
// wrapper is not the wrapper for their ownerDocument (XUL elements, // wrapper is not the wrapper for their ownerDocument (XUL elements,
// form controls, ...). Also applies in the fragment code above. // form controls, ...). Also applies in the fragment code above.
if (nsAutoMutationBatch::GetCurrentBatch() == &mb) { if (nsAutoMutationBatch::GetCurrentBatch() == &mb) {
mb.RemovalDone(); mb.RemovalDone();
mb.SetPrevSibling(GetChildAt_Deprecated(insPos - 1)); mb.SetPrevSibling(nodeToInsertBefore ?
mb.SetNextSibling(GetChildAt_Deprecated(insPos)); nodeToInsertBefore->GetPreviousSibling() : GetLastChild());
mb.SetNextSibling(nodeToInsertBefore);
} }
aError = InsertChildAt_Deprecated(newContent, insPos, true); aError = InsertChildBefore(newContent, nodeToInsertBefore, true);
if (aError.Failed()) { if (aError.Failed()) {
return nullptr; return nullptr;
} }

Просмотреть файл

@ -821,29 +821,6 @@ public:
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) = 0; bool aNotify) = 0;
/**
* Insert a content node at a particular index. This method handles calling
* BindToTree on the child appropriately.
*
* @param aKid the content to insert
* @param aIndex the index it is being inserted at (the index it will have
* after it is inserted)
* @param aNotify whether to notify the document (current document for
* nsIContent, and |this| for nsIDocument) that the insert has
* occurred
*
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
* than one element node as a child of a document. Doing this will also
* assert -- you shouldn't be doing it! Check with
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
* one constraint, this doesn't do any checking on whether aKid is a valid
* child of |this|.
*
* @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
*/
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) = 0;
/** /**
* Append a content node to the end of the child list. This method handles * Append a content node to the end of the child list. This method handles
* calling BindToTree on the child appropriately. * calling BindToTree on the child appropriately.
@ -864,25 +841,9 @@ public:
*/ */
nsresult AppendChildTo(nsIContent* aKid, bool aNotify) nsresult AppendChildTo(nsIContent* aKid, bool aNotify)
{ {
return InsertChildAt_Deprecated(aKid, GetChildCount(), aNotify); return InsertChildBefore(aKid, nullptr, aNotify);
} }
/**
* NOTE: this function is going to be removed soon (hopefully!) Don't use it
* in new code.
*
* Remove a child from this node. This method handles calling UnbindFromTree
* on the child appropriately.
*
* @param aIndex the index of the child to remove
* @param aNotify whether to notify the document (current document for
* nsIContent, and |this| for nsIDocument) that the remove has
* occurred
*
* Note: If there is no child at aIndex, this method will simply do nothing.
*/
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) = 0;
/** /**
* Remove a child from this node. This method handles calling UnbindFromTree * Remove a child from this node. This method handles calling UnbindFromTree
* on the child appropriately. * on the child appropriately.

Просмотреть файл

@ -171,64 +171,6 @@ HTMLFieldSetElement::InsertChildBefore(nsIContent* aChild,
return rv; return rv;
} }
nsresult
HTMLFieldSetElement::InsertChildAt_Deprecated(nsIContent* aChild,
uint32_t aIndex,
bool aNotify)
{
bool firstLegendHasChanged = false;
if (aChild->IsHTMLElement(nsGkAtoms::legend)) {
if (!mFirstLegend) {
mFirstLegend = aChild;
// We do not want to notify the first time mFirstElement is set.
} else {
// If mFirstLegend is before aIndex, we do not change it.
// Otherwise, mFirstLegend is now aChild.
if (int32_t(aIndex) <= ComputeIndexOf(mFirstLegend)) {
mFirstLegend = aChild;
firstLegendHasChanged = true;
}
}
}
nsresult rv =
nsGenericHTMLFormElement::InsertChildAt_Deprecated(aChild, aIndex, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (firstLegendHasChanged) {
NotifyElementsForFirstLegendChange(aNotify);
}
return rv;
}
void
HTMLFieldSetElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
bool firstLegendHasChanged = false;
if (mFirstLegend && (GetChildAt_Deprecated(aIndex) == mFirstLegend)) {
// If we are removing the first legend we have to found another one.
nsIContent* child = mFirstLegend->GetNextSibling();
mFirstLegend = nullptr;
firstLegendHasChanged = true;
for (; child; child = child->GetNextSibling()) {
if (child->IsHTMLElement(nsGkAtoms::legend)) {
mFirstLegend = child;
break;
}
}
}
nsGenericHTMLFormElement::RemoveChildAt_Deprecated(aIndex, aNotify);
if (firstLegendHasChanged) {
NotifyElementsForFirstLegendChange(aNotify);
}
}
void void
HTMLFieldSetElement::RemoveChildNode(nsIContent* aKid, bool aNotify) HTMLFieldSetElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -42,9 +42,6 @@ public:
virtual nsresult InsertChildBefore(nsIContent* aChild, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aChild, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aChild, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
// nsIFormControl // nsIFormControl

Просмотреть файл

@ -86,28 +86,6 @@ HTMLOptGroupElement::InsertChildBefore(nsIContent* aKid,
return rv; return rv;
} }
nsresult
HTMLOptGroupElement::InsertChildAt_Deprecated(nsIContent* aKid,
uint32_t aIndex,
bool aNotify)
{
SafeOptionListMutation safeMutation(GetSelect(), this, aKid, aIndex, aNotify);
nsresult rv = nsGenericHTMLElement::InsertChildAt_Deprecated(aKid, aIndex,
aNotify);
if (NS_FAILED(rv)) {
safeMutation.MutationFailed();
}
return rv;
}
void
HTMLOptGroupElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, aIndex,
aNotify);
nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
}
void void
HTMLOptGroupElement::RemoveChildNode(nsIContent* aKid, bool aNotify) HTMLOptGroupElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -28,9 +28,6 @@ public:
// nsINode // nsINode
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
// nsIContent // nsIContent

Просмотреть файл

@ -30,32 +30,6 @@ HTMLPictureElement::~HTMLPictureElement()
NS_IMPL_ELEMENT_CLONE(HTMLPictureElement) NS_IMPL_ELEMENT_CLONE(HTMLPictureElement)
void
HTMLPictureElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
nsCOMPtr<nsIContent> child = GetChildAt_Deprecated(aIndex);
if (child && child->IsHTMLElement(nsGkAtoms::img)) {
HTMLImageElement* img = HTMLImageElement::FromNode(child);
if (img) {
img->PictureSourceRemoved(child->AsContent());
}
} else if (child && child->IsHTMLElement(nsGkAtoms::source)) {
// Find all img siblings after this <source> to notify them of its demise
nsCOMPtr<nsIContent> nextSibling = child->GetNextSibling();
if (nextSibling && nextSibling->GetParentNode() == this) {
do {
HTMLImageElement* img = HTMLImageElement::FromNode(nextSibling);
if (img) {
img->PictureSourceRemoved(child->AsContent());
}
} while ( (nextSibling = nextSibling->GetNextSibling()) );
}
}
nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
}
void void
HTMLPictureElement::RemoveChildNode(nsIContent* aKid, bool aNotify) HTMLPictureElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {
@ -111,35 +85,6 @@ HTMLPictureElement::InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
return rv; return rv;
} }
nsresult
HTMLPictureElement::InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex, bool aNotify)
{
nsresult rv = nsGenericHTMLElement::InsertChildAt_Deprecated(aKid, aIndex, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(aKid, rv);
if (aKid->IsHTMLElement(nsGkAtoms::img)) {
HTMLImageElement* img = HTMLImageElement::FromNode(aKid);
if (img) {
img->PictureSourceAdded(aKid->AsContent());
}
} else if (aKid->IsHTMLElement(nsGkAtoms::source)) {
// Find all img siblings after this <source> to notify them of its insertion
nsCOMPtr<nsIContent> nextSibling = aKid->GetNextSibling();
if (nextSibling && nextSibling->GetParentNode() == this) {
do {
HTMLImageElement* img = HTMLImageElement::FromNode(nextSibling);
if (img) {
img->PictureSourceAdded(aKid->AsContent());
}
} while ( (nextSibling = nextSibling->GetNextSibling()) );
}
}
return rv;
}
JSObject* JSObject*
HTMLPictureElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) HTMLPictureElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{ {

Просмотреть файл

@ -23,12 +23,9 @@ public:
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult, virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
bool aPreallocateChildren) const override; bool aPreallocateChildren) const override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
protected: protected:
virtual ~HTMLPictureElement(); virtual ~HTMLPictureElement();

Просмотреть файл

@ -217,28 +217,6 @@ HTMLSelectElement::InsertChildBefore(nsIContent* aKid,
return rv; return rv;
} }
nsresult
HTMLSelectElement::InsertChildAt_Deprecated(nsIContent* aKid,
uint32_t aIndex,
bool aNotify)
{
SafeOptionListMutation safeMutation(this, this, aKid, aIndex, aNotify);
nsresult rv =
nsGenericHTMLFormElementWithState::InsertChildAt_Deprecated(aKid, aIndex,
aNotify);
if (NS_FAILED(rv)) {
safeMutation.MutationFailed();
}
return rv;
}
void
HTMLSelectElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
SafeOptionListMutation safeMutation(this, this, nullptr, aIndex, aNotify);
nsGenericHTMLFormElementWithState::RemoveChildAt_Deprecated(aIndex, aNotify);
}
void void
HTMLSelectElement::RemoveChildNode(nsIContent* aKid, bool aNotify) HTMLSelectElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -247,9 +247,6 @@ public:
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) override; virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) override;
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
// Overriden nsIFormControl methods // Overriden nsIFormControl methods

Просмотреть файл

@ -50,23 +50,6 @@ SVGDocument::InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
return XMLDocument::InsertChildBefore(aKid, aBeforeThis, aNotify); return XMLDocument::InsertChildBefore(aKid, aBeforeThis, aNotify);
} }
nsresult
SVGDocument::InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify)
{
if (aKid->IsElement() && !aKid->IsSVGElement()) {
// We can get here when well formed XML with a non-SVG root element is
// served with the SVG MIME type, for example. In that case we need to load
// the non-SVG UA sheets or else we can get bugs like bug 1016145. Note
// that we have to do this _before_ the
// XMLDocument::InsertChildAt_Deprecated call, since that can try to
// construct frames, and we need to have the sheets loaded by then.
EnsureNonSVGUserAgentStyleSheetsLoaded();
}
return XMLDocument::InsertChildAt_Deprecated(aKid, aIndex, aNotify);
}
nsresult nsresult
SVGDocument::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, SVGDocument::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
bool aPreallocateChildren) const bool aPreallocateChildren) const

Просмотреть файл

@ -35,8 +35,6 @@ public:
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
bool aPreallocateChildren) const override; bool aPreallocateChildren) const override;

Просмотреть файл

@ -93,26 +93,6 @@ SVGSwitchElement::InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
return rv; return rv;
} }
nsresult
SVGSwitchElement::InsertChildAt_Deprecated(nsIContent* aKid,
uint32_t aIndex,
bool aNotify)
{
nsresult rv = SVGSwitchElementBase::InsertChildAt_Deprecated(aKid, aIndex,
aNotify);
if (NS_SUCCEEDED(rv)) {
MaybeInvalidate();
}
return rv;
}
void
SVGSwitchElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
SVGSwitchElementBase::RemoveChildAt_Deprecated(aIndex, aNotify);
MaybeInvalidate();
}
void void
SVGSwitchElement::RemoveChildNode(nsIContent* aKid, bool aNotify) SVGSwitchElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -42,9 +42,6 @@ public:
// nsINode // nsINode
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis, virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
bool aNotify) override; bool aNotify) override;
virtual nsresult InsertChildAt_Deprecated(nsIContent* aKid, uint32_t aIndex,
bool aNotify) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
// nsIContent // nsIContent

Просмотреть файл

@ -827,103 +827,6 @@ nsXULElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsStyledElement::UnbindFromTree(aDeep, aNullParent); nsStyledElement::UnbindFromTree(aDeep, aNullParent);
} }
void
nsXULElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
{
nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
if (!oldKid) {
return;
}
// On the removal of a <treeitem>, <treechildren>, or <treecell> element,
// the possibility exists that some of the items in the removed subtree
// are selected (and therefore need to be deselected). We need to account for this.
nsCOMPtr<nsIDOMXULMultiSelectControlElement> controlElement;
nsCOMPtr<nsIListBoxObject> listBox;
bool fireSelectionHandler = false;
// -1 = do nothing, -2 = null out current item
// anything else = index to re-set as current
int32_t newCurrentIndex = -1;
if (oldKid->NodeInfo()->Equals(nsGkAtoms::listitem, kNameSpaceID_XUL)) {
// This is the nasty case. We have (potentially) a slew of selected items
// and cells going away.
// First, retrieve the tree.
// Check first whether this element IS the tree
controlElement = do_QueryObject(this);
// If it's not, look at our parent
if (!controlElement)
GetParentTree(getter_AddRefs(controlElement));
nsCOMPtr<nsIContent> controlContent(do_QueryInterface(controlElement));
RefPtr<nsXULElement> xulElement = FromNodeOrNull(controlContent);
if (xulElement) {
// Iterate over all of the items and find out if they are contained inside
// the removed subtree.
int32_t length;
controlElement->GetSelectedCount(&length);
for (int32_t i = 0; i < length; i++) {
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
controlElement->MultiGetSelectedItem(i, getter_AddRefs(item));
nsCOMPtr<nsINode> node = do_QueryInterface(item);
if (node == oldKid &&
NS_SUCCEEDED(controlElement->RemoveItemFromSelection(item))) {
length--;
i--;
fireSelectionHandler = true;
}
}
nsCOMPtr<nsIDOMXULSelectControlItemElement> curItem;
controlElement->GetCurrentItem(getter_AddRefs(curItem));
nsCOMPtr<nsIContent> curNode = do_QueryInterface(curItem);
if (curNode && nsContentUtils::ContentIsDescendantOf(curNode, oldKid)) {
// Current item going away
nsCOMPtr<nsIBoxObject> box = xulElement->GetBoxObject(IgnoreErrors());
listBox = do_QueryInterface(box);
if (listBox) {
listBox->GetIndexOfItem(oldKid->AsElement(), &newCurrentIndex);
}
// If any of this fails, we'll just set the current item to null
if (newCurrentIndex == -1)
newCurrentIndex = -2;
}
}
}
nsStyledElement::RemoveChildAt_Deprecated(aIndex, aNotify);
if (newCurrentIndex == -2) {
controlElement->SetCurrentItem(nullptr);
} else if (newCurrentIndex > -1) {
// Make sure the index is still valid
int32_t treeRows;
listBox->GetRowCount(&treeRows);
if (treeRows > 0) {
newCurrentIndex = std::min((treeRows - 1), newCurrentIndex);
RefPtr<Element> newCurrentItem;
listBox->GetItemAtIndex(newCurrentIndex, getter_AddRefs(newCurrentItem));
nsCOMPtr<nsIDOMXULSelectControlItemElement> xulCurItem = do_QueryInterface(newCurrentItem);
if (xulCurItem)
controlElement->SetCurrentItem(xulCurItem);
} else {
controlElement->SetCurrentItem(nullptr);
}
}
nsIDocument* doc;
if (fireSelectionHandler && (doc = GetComposedDoc())) {
nsContentUtils::DispatchTrustedEvent(doc,
static_cast<nsIContent*>(this),
NS_LITERAL_STRING("select"),
false,
true);
}
}
void void
nsXULElement::RemoveChildNode(nsIContent* aKid, bool aNotify) nsXULElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
{ {

Просмотреть файл

@ -368,7 +368,6 @@ public:
nsIContent* aBindingParent, nsIContent* aBindingParent,
bool aCompileEventHandlers) override; bool aCompileEventHandlers) override;
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override; virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override; virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
virtual void DestroyContent() override; virtual void DestroyContent() override;