Bug 495648. Work around yet more listbox suckage: it'll randomly create frames for content it hasn't included in its row count! r=enn, sr=roc pending

This commit is contained in:
Boris Zbarsky 2009-06-01 12:46:31 -04:00
parent bf40fdaa90
commit a85a4909f6
4 changed files with 311 additions and 30 deletions

View File

@ -6030,6 +6030,32 @@ IsSpecialFramesetChild(nsIContent* aContent)
static void
InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node);
#ifdef MOZ_XUL
static
nsListBoxBodyFrame*
MaybeGetListBoxBodyFrame(nsIContent* aContainer, nsIContent* aChild)
{
if (!aContainer)
return nsnull;
if (aContainer->IsNodeOfType(nsINode::eXUL) &&
aChild->IsNodeOfType(nsINode::eXUL) &&
aContainer->Tag() == nsGkAtoms::listbox &&
aChild->Tag() == nsGkAtoms::listitem) {
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(aContainer);
nsCOMPtr<nsIBoxObject> boxObject;
xulElement->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsPIListBoxObject> listBoxObject = do_QueryInterface(boxObject);
if (listBoxObject) {
return listBoxObject->GetListBoxBody(PR_FALSE);
}
}
return nsnull;
}
#endif
nsresult
nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
@ -6120,7 +6146,13 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
PRUint32 containerCount = aContainer->GetChildCount();
for (PRUint32 i = aNewIndexInContainer; i < containerCount; i++) {
nsIContent* content = aContainer->GetChildAt(i);
if (mPresShell->GetPrimaryFrameFor(content)) {
if (mPresShell->GetPrimaryFrameFor(content)
#ifdef MOZ_XUL
// Except listboxes suck, so do NOT skip anything here if
// we plan to notify a listbox.
&& !MaybeGetListBoxBodyFrame(aContainer, content)
#endif
) {
// Already have a frame for this content; a previous ContentInserted
// in this loop must have reconstructed its insertion parent. Skip
// it.
@ -6329,36 +6361,23 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext,
nsIFrame* aChildFrame,
content_operation aOperation)
{
if (!aContainer)
return PR_FALSE;
if (aContainer->IsNodeOfType(nsINode::eXUL) &&
aChild->IsNodeOfType(nsINode::eXUL) &&
aContainer->Tag() == nsGkAtoms::listbox &&
aChild->Tag() == nsGkAtoms::listitem) {
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(aContainer);
nsCOMPtr<nsIBoxObject> boxObject;
xulElement->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsPIListBoxObject> listBoxObject = do_QueryInterface(boxObject);
if (listBoxObject) {
nsListBoxBodyFrame* listBoxBodyFrame = listBoxObject->GetListBoxBody(PR_FALSE);
if (listBoxBodyFrame) {
if (aOperation == CONTENT_REMOVED) {
// Except if we have an aChildFrame and its parent is not the right
// thing, then we don't do this. Pseudo frames are so much fun....
if (!aChildFrame || aChildFrame->GetParent() == listBoxBodyFrame) {
listBoxBodyFrame->OnContentRemoved(aPresContext, aChildFrame,
aIndexInContainer);
return PR_TRUE;
}
} else {
// If this codepath ever starts using aIndexInContainer, need to
// change ContentInserted to pass in something resembling a correct
// one in the XBL cases.
listBoxBodyFrame->OnContentInserted(aPresContext, aChild);
return PR_TRUE;
}
nsListBoxBodyFrame* listBoxBodyFrame =
MaybeGetListBoxBodyFrame(aContainer, aChild);
if (listBoxBodyFrame) {
if (aOperation == CONTENT_REMOVED) {
// Except if we have an aChildFrame and its parent is not the right
// thing, then we don't do this. Pseudo frames are so much fun....
if (!aChildFrame || aChildFrame->GetParent() == listBoxBodyFrame) {
listBoxBodyFrame->OnContentRemoved(aPresContext, aChildFrame,
aIndexInContainer);
return PR_TRUE;
}
} else {
// If this codepath ever starts using aIndexInContainer, need to
// change ContentInserted to pass in something resembling a correct
// one in the XBL cases.
listBoxBodyFrame->OnContentInserted(aPresContext, aChild);
return PR_TRUE;
}
}

View File

@ -75,6 +75,8 @@ _TEST_FILES = \
test_printpreview.html \
test_bug482976.html \
decoration_line_rendering.js \
test_bug495648.xul \
bug495648.rdf \
$(NULL)
# test_bug396024.html is currently disabled because it interacts badly with
# the "You can't print-preview while the page is loading" dialog.

View File

@ -0,0 +1,214 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:NS1="http://sitedelta.schierla.de/SD-rdf#"
xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=19&amp;btnG=Suche&amp;meta="
NC:name="19 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Bag RDF:about="urn:root:bag">
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=1&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=2&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=3&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=4&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=5&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=6&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=7&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=8&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=9&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=10&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=11&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=12&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=13&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=14&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=15&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=16&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=17&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=18&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=19&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=20&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=21&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=22&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=23&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=24&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=25&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=26&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=27&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=28&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=29&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=30&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=31&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=32&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=33&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=34&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=35&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=36&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=37&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=38&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=39&amp;btnG=Suche&amp;meta="/>
<RDF:li RDF:resource="http://www.google.de/search?hl=de&amp;q=40&amp;btnG=Suche&amp;meta="/>
</RDF:Bag>
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=2&amp;btnG=Suche&amp;meta="
NC:name="2 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=12&amp;btnG=Suche&amp;meta="
NC:name="12 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=5&amp;btnG=Suche&amp;meta="
NC:name="5 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=6&amp;btnG=Suche&amp;meta="
NC:name="6 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=22&amp;btnG=Suche&amp;meta="
NC:name="22 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=17&amp;btnG=Suche&amp;meta="
NC:name="17 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="urn:root">
<NC:links RDF:resource="urn:root:bag"/>
</RDF:Description>
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=8&amp;btnG=Suche&amp;meta="
NC:name="8 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=1&amp;btnG=Suche&amp;meta="
NC:name="1 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=16&amp;btnG=Suche&amp;meta="
NC:name="16 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=21&amp;btnG=Suche&amp;meta="
NC:name="21 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=20&amp;btnG=Suche&amp;meta="
NC:name="20 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=9&amp;btnG=Suche&amp;meta="
NC:name="9 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=11&amp;btnG=Suche&amp;meta="
NC:name="11 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=14&amp;btnG=Suche&amp;meta="
NC:name="14 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=23&amp;btnG=Suche&amp;meta="
NC:name="23 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=24&amp;btnG=Suche&amp;meta="
NC:name="24 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=18&amp;btnG=Suche&amp;meta="
NC:name="18 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www0.pafnet.de/user/322033"
NC:name="pafnet - You2_xD"
NS1:nextScan="1243707104073"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=3&amp;btnG=Suche&amp;meta="
NC:name="3 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=7&amp;btnG=Suche&amp;meta="
NC:name="7 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=15&amp;btnG=Suche&amp;meta="
NC:name="15 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=4&amp;btnG=Suche&amp;meta="
NC:name="4 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=13&amp;btnG=Suche&amp;meta="
NC:name="13 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=10&amp;btnG=Suche&amp;meta="
NC:name="10 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=25&amp;btnG=Suche&amp;meta="
NC:name="25 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=26&amp;btnG=Suche&amp;meta="
NC:name="26 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=27&amp;btnG=Suche&amp;meta="
NC:name="27 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=28&amp;btnG=Suche&amp;meta="
NC:name="28 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=29&amp;btnG=Suche&amp;meta="
NC:name="29 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=30&amp;btnG=Suche&amp;meta="
NC:name="30 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=31&amp;btnG=Suche&amp;meta="
NC:name="31 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=32&amp;btnG=Suche&amp;meta="
NC:name="32 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=33&amp;btnG=Suche&amp;meta="
NC:name="33 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=34&amp;btnG=Suche&amp;meta="
NC:name="34 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=35&amp;btnG=Suche&amp;meta="
NC:name="35 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=36&amp;btnG=Suche&amp;meta="
NC:name="36 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=37&amp;btnG=Suche&amp;meta="
NC:name="37 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=38&amp;btnG=Suche&amp;meta="
NC:name="38 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=39&amp;btnG=Suche&amp;meta="
NC:name="39 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
<RDF:Description RDF:about="http://www.google.de/search?hl=de&amp;q=40&amp;btnG=Suche&amp;meta="
NC:name="40 - Google-Suche"
NS1:nextScan="0"
NS1:status="0" />
</RDF:RDF>

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=495648
-->
<window title="Mozilla Bug 495648"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="/MochiKit/packed.js"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=495648"
target="_blank">Mozilla Bug 495648</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 495648 **/
var uri = window.location.href.replace(/test_bug495648.xul/, "bug495648.rdf");
function doTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var list = document.getElementById('l');
var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
var rdf = rdfService.GetDataSourceBlocking(uri);
list.database.AddDataSource(rdf);
list.builder.rebuild();
is(list.itemCount, 40, "Unexpected item count");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
]]>
</script>
<listbox flex="1" id="l" seltype="multiple" datasources="rdf:null" ref="urn:root" sortResource="http://home.netscape.com/NC-rdf#name" sortDirection="ascending">
<template>
<rule><conditions><content uri="?uri" /><triple subject="?uri" predicate="http://home.netscape.com/NC-rdf#links" object="?links" /><member container="?links" child="?child" /><triple subject="?child" predicate="http://home.netscape.com/NC-rdf#name" object="?name" /></conditions><bindings><binding subject="?child" predicate="http://sitedelta.schierla.de/SD-rdf#status" object="?status" /></bindings><action><listitem label="?name" class="listitem-iconic" status="?status" uri="?child" /></action></rule>
</template>
</listbox>
</window>