Bug 1431000 - Introduce nsINode::InsertChildBefore, r=catalinb

This commit is contained in:
Andrea Marchesini
2018-01-25 15:59:42 +01:00
parent eee774394a
commit d7fcfacf9a
21 changed files with 212 additions and 1 deletions

View File

@@ -139,6 +139,39 @@ HTMLFieldSetElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission)
return NS_OK;
}
nsresult
HTMLFieldSetElement::InsertChildBefore(nsIContent* aChild,
nsIContent* aBeforeThis,
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.
int32_t index = aBeforeThis ? ComputeIndexOf(aBeforeThis) : GetChildCount();
if (index <= ComputeIndexOf(mFirstLegend)) {
mFirstLegend = aChild;
firstLegendHasChanged = true;
}
}
}
nsresult rv =
nsGenericHTMLFormElement::InsertChildBefore(aChild, aBeforeThis, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (firstLegendHasChanged) {
NotifyElementsForFirstLegendChange(aNotify);
}
return rv;
}
nsresult
HTMLFieldSetElement::InsertChildAt_Deprecated(nsIContent* aChild,
uint32_t aIndex,