mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1228876. Correctly ignore nested optgroups even if an optgroup is inserted into another, existing, optgroup. r=mats
This commit is contained in:
parent
98859029bb
commit
df52e48e20
@ -225,18 +225,17 @@ HTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
|
||||
int32_t aDepth,
|
||||
bool aNotify)
|
||||
{
|
||||
MOZ_ASSERT(aDepth == 0 || aDepth == 1);
|
||||
int32_t insertIndex = aListIndex;
|
||||
|
||||
HTMLOptionElement* optElement = HTMLOptionElement::FromContent(aOptions);
|
||||
if (optElement) {
|
||||
mOptions->InsertOptionAt(optElement, insertIndex);
|
||||
insertIndex++;
|
||||
} else {
|
||||
} else if (aDepth == 0) {
|
||||
// If it's at the top level, then we just found out there are non-options
|
||||
// at the top level, which will throw off the insert count
|
||||
if (aDepth == 0) {
|
||||
mNonOptionChildren++;
|
||||
}
|
||||
mNonOptionChildren++;
|
||||
|
||||
// Deal with optgroups
|
||||
if (aOptions->IsHTMLElement(nsGkAtoms::optgroup)) {
|
||||
@ -252,7 +251,7 @@ HTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // else ignore even if optgroup; we want to ignore nested optgroups.
|
||||
|
||||
// Deal with the selected list
|
||||
if (insertIndex - aListIndex) {
|
||||
@ -307,6 +306,7 @@ HTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
|
||||
int32_t aDepth,
|
||||
bool aNotify)
|
||||
{
|
||||
MOZ_ASSERT(aDepth == 0 || aDepth == 1);
|
||||
int32_t numRemoved = 0;
|
||||
|
||||
HTMLOptionElement* optElement = HTMLOptionElement::FromContent(aOptions);
|
||||
@ -317,11 +317,9 @@ HTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
|
||||
}
|
||||
mOptions->RemoveOptionAt(aListIndex);
|
||||
numRemoved++;
|
||||
} else {
|
||||
} else if (aDepth == 0) {
|
||||
// Yay, one less artifact at the top level.
|
||||
if (aDepth == 0) {
|
||||
mNonOptionChildren--;
|
||||
}
|
||||
mNonOptionChildren--;
|
||||
|
||||
// Recurse down deeper for options
|
||||
if (mOptGroupCount && aOptions->IsHTMLElement(nsGkAtoms::optgroup)) {
|
||||
@ -341,7 +339,7 @@ HTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // else don't check for an optgroup; we want to ignore nested optgroups
|
||||
|
||||
if (numRemoved) {
|
||||
// Tell the widget we removed the options
|
||||
|
21
dom/html/crashtests/1228876.html
Normal file
21
dom/html/crashtests/1228876.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
|
||||
function boom()
|
||||
{
|
||||
var a = document.createElement("select");
|
||||
var f = document.createElement("optgroup");
|
||||
var g = document.createElement("optgroup");
|
||||
a.appendChild(f);
|
||||
g.appendChild(document.createElement("option"));
|
||||
f.appendChild(g);
|
||||
a.appendChild(document.createElement("option"));
|
||||
document.body.appendChild(a);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="boom();"></body>
|
||||
</html>
|
@ -73,4 +73,5 @@ load 903106.html
|
||||
load 916322-1.html
|
||||
load 916322-2.html
|
||||
load 1032654.html
|
||||
pref(dom.image.srcset.enabled,true) load 1141260.html
|
||||
pref(dom.image.srcset.enabled,true) load 1141260.html
|
||||
load 1228876.html
|
||||
|
Loading…
Reference in New Issue
Block a user