Bug 595606 - "ASSERTION: no common ancestor at all" when removing a subtree with more than one id pointed by @form. r=jst a=blocking

--HG--
rename : content/base/crashtests/595606.html => content/base/crashtests/595606-1.html
This commit is contained in:
Mounir Lamouri 2010-10-13 12:52:45 +02:00
Родитель 4c168517e3
Коммит 012d37c93a
7 изменённых файлов: 49 добавлений и 18 удалений

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

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html class="reftest-wait">
<body onload="
document.body.removeChild(document.getElementById('x'));
document.documentElement.removeAttribute('class');">
<div id="x">
<form id="a">
<select></select>
</form>
<form id="a">
<select></select>
</form>
</div>
<select form="a"></select>
</body>
</html>

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

@ -71,4 +71,5 @@ load 564114.html
load 565125-1.html
load 582601.html
load 575462.svg
load 595606.html
load 595606-1.html
load 595606-2.html

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

@ -235,24 +235,9 @@ nsStyledElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
void
nsStyledElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
{
nsIDocument* doc = nsnull;
if (HasFlag(NODE_HAS_ID)) {
doc = GetCurrentDoc();
}
RemoveFromIdTable();
nsStyledElementBase::UnbindFromTree(aDeep, aNullParent);
// If we had a document (and an id), we should now inform the document that
// we are no longer a valid id.
// This is done _after_ the call to UnbindFromTree to make sure that id are
// removed from the inner-most elements to the top-most.
if (doc) {
nsIAtom* id = DoGetID();
if (id) {
doc->RemoveFromIdTable(this, id);
}
}
}

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

@ -1046,7 +1046,16 @@ CompareFormControlPosition(nsGenericHTMLFormElement *aControl1,
// If we pass aForm, we are assuming both controls are form descendants which
// is not always the case. This function should work but maybe slower.
// However, checking if both elements are form descendants may be slow too...
// TODO: remove the prevent asserts fix, see bug 598468.
#ifdef DEBUG
nsLayoutUtils::gPreventAssertInCompareTreePosition = true;
PRInt32 rVal = nsLayoutUtils::CompareTreePosition(aControl1, aControl2, aForm);
nsLayoutUtils::gPreventAssertInCompareTreePosition = false;
return rVal;
#else // DEBUG
return nsLayoutUtils::CompareTreePosition(aControl1, aControl2, aForm);
#endif // DEBUG
}
#ifdef DEBUG
@ -1061,6 +1070,10 @@ static void
AssertDocumentOrder(const nsTArray<nsGenericHTMLFormElement*>& aControls,
nsIContent* aForm)
{
// TODO: remove the return statement with bug 598468.
// This is done to prevent asserts in some edge cases.
return;
// Only iterate if aControls is not empty, since otherwise
// |aControls.Length() - 1| will be a very large unsigned number... not what
// we want here.

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

@ -113,6 +113,11 @@ using namespace mozilla::layers;
using namespace mozilla::dom;
namespace css = mozilla::css;
#ifdef DEBUG
// TODO: remove, see bug 598468.
bool nsLayoutUtils::gPreventAssertInCompareTreePosition = false;
#endif // DEBUG
typedef gfxPattern::GraphicsFilter GraphicsFilter;
/**
@ -524,7 +529,11 @@ nsLayoutUtils::DoCompareTreePosition(nsIContent* aContent1,
// content1Ancestor != content2Ancestor, so they must be siblings with the same parent
nsINode* parent = content1Ancestor->GetNodeParent();
NS_ASSERTION(parent, "no common ancestor at all???");
#ifdef DEBUG
// TODO: remove the uglyness, see bug 598468.
NS_ASSERTION(gPreventAssertInCompareTreePosition || parent,
"no common ancestor at all???");
#endif // DEBUG
if (!parent) { // different documents??
return 0;
}

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

@ -156,6 +156,11 @@ public:
static PRBool IsGeneratedContentFor(nsIContent* aContent, nsIFrame* aFrame,
nsIAtom* aPseudoElement);
#ifdef DEBUG
// TODO: remove, see bug 598468.
static bool gPreventAssertInCompareTreePosition;
#endif // DEBUG
/**
* CompareTreePosition determines whether aContent1 comes before or
* after aContent2 in a preorder traversal of the content tree.