diff --git a/mozilla/content/base/test/Makefile.in b/mozilla/content/base/test/Makefile.in index 5590ca74375..d60f6a3a5ae 100644 --- a/mozilla/content/base/test/Makefile.in +++ b/mozilla/content/base/test/Makefile.in @@ -113,6 +113,7 @@ _TEST_FILES = test_bug5141.html \ test_bug402150.html \ test_bug402150.html^headers^ \ test_bug401662.html \ + test_bug403868.xml \ $(NULL) libs:: $(_TEST_FILES) diff --git a/mozilla/content/base/test/test_bug311681.xml b/mozilla/content/base/test/test_bug311681.xml index 9e3dadedeca..5e704ac890b 100644 --- a/mozilla/content/base/test/test_bug311681.xml +++ b/mozilla/content/base/test/test_bug311681.xml @@ -43,15 +43,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681 newParent.appendChild(node); // Check what getElementById returns, no flushing - todo(getCont() == testNode, "Should be getting orig node pre-flush 1"); - is(getCont(), node, "XML does it differently, for now"); + is(getCont(), node, "Should be getting orig node pre-flush 1"); // Trigger a layout flush, just in case. var itemHeight = newParent.offsetHeight/10; // Check what getElementById returns now. - todo(getCont() == testNode, "Should be getting orig node post-flush 1"); - is(getCont(), node, "XML does it differently, for now"); + is(getCont(), node, "Should be getting new node post-flush 1"); clear(newParent); diff --git a/mozilla/content/base/test/test_bug403868.xml b/mozilla/content/base/test/test_bug403868.xml new file mode 100644 index 00000000000..b85dcc9237b --- /dev/null +++ b/mozilla/content/base/test/test_bug403868.xml @@ -0,0 +1,86 @@ + + +
++ ++ + + diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index d973bf1a66d..7e3d725af7c 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -269,15 +269,36 @@ IdAndNameMapEntry::AddIdContent(nsIContent* aContent) return mIdContentList.ReplaceElementAt(aContent, 0); } - // Have to check whether it's in the list already, in case we're - // registering from the top when going live. - PRInt32 index = mIdContentList.IndexOf(aContent); - if (index != -1) { - // nothing else to do here - return PR_TRUE; + // Common case + if (mIdContentList.Count() == 0) { + return mIdContentList.AppendElement(aContent); } + + // We seem to have multiple content nodes for the same id, or we're doing our + // top-down registration when the id table is going live. Search for the + // right place to insert the content. + PRInt32 start = 0; + PRInt32 end = mIdContentList.Count(); + do { + NS_ASSERTION(start < end, "Bogus start/end"); - return mIdContentList.AppendElement(aContent); + PRInt32 cur = (start + end) / 2; + NS_ASSERTION(cur >= start && cur < end, "What happened here?"); + + nsIContent* curContent = static_cast
+ ++ + + diff --git a/mozilla/content/html/document/test/test_bug403868.xhtml b/mozilla/content/html/document/test/test_bug403868.xhtml new file mode 100644 index 00000000000..9f41e759020 --- /dev/null +++ b/mozilla/content/html/document/test/test_bug403868.xhtml @@ -0,0 +1,87 @@ + + + +
+ ++ + + diff --git a/mozilla/content/xul/document/test/Makefile.in b/mozilla/content/xul/document/test/Makefile.in index 9f20d64704b..183e8ca27fe 100644 --- a/mozilla/content/xul/document/test/Makefile.in +++ b/mozilla/content/xul/document/test/Makefile.in @@ -47,6 +47,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES = \ test_bug311681.xul \ test_bug199692.xul \ + test_bug403868.xul \ $(NULL) libs:: $(_TEST_FILES) diff --git a/mozilla/content/xul/document/test/test_bug311681.xul b/mozilla/content/xul/document/test/test_bug311681.xul index 9c7f5af878d..b1a3ed1e4ab 100644 --- a/mozilla/content/xul/document/test/test_bug311681.xul +++ b/mozilla/content/xul/document/test/test_bug311681.xul @@ -47,13 +47,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681 newParent.appendChild(node); // Check what getElementById returns, no flushing - is(getCont(), testNode, "Should be getting orig node pre-flush 1"); + todo(getCont() == node, "Should be getting new node pre-flush 1") + is(getCont(), testNode, "XUL does it differently for now"); // Trigger a layout flush, just in case. var itemHeight = newParent.offsetHeight/10; // Check what getElementById returns now. - is(getCont(), testNode, "Should be getting orig node post-flush 1"); + todo(getCont() == node, "Should be getting new node post-flush 1") + is(getCont(), testNode, "XUL does it differently for now"); clear(newParent); diff --git a/mozilla/content/xul/document/test/test_bug403868.xul b/mozilla/content/xul/document/test/test_bug403868.xul new file mode 100644 index 00000000000..b1b76f70b9a --- /dev/null +++ b/mozilla/content/xul/document/test/test_bug403868.xul @@ -0,0 +1,90 @@ + + + + +