bug 495648 unbreak scrolling in xul listboxes with rdf datasources.

patch by bz, r=enndeakin, sr=roc, a=ss


git-svn-id: svn://10.0.0.236/trunk@257355 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dveditz%cruzio.com
2009-06-02 17:24:02 +00:00
parent 23b3d930b2
commit e635cb06d9
4 changed files with 309 additions and 26 deletions

View File

@@ -8507,6 +8507,30 @@ GetAdjustedParentFrame(nsIFrame* aParentFrame,
static void
InvalidateCanvasIfNeeded(nsIFrame* aFrame);
#ifdef MOZ_XUL
static
nsIListBoxObject*
MaybeGetListBoxBodyFrame(nsIContent* aContainer, nsIContent* aChild)
{
NS_PRECONDITION(aContainer, "Must have container here");
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
static PRBool
IsSpecialFramesetChild(nsIContent* aContent)
{
@@ -8608,7 +8632,13 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
PRUint32 containerCount = aContainer->GetChildCount();
for (PRUint32 i = aNewIndexInContainer; i < containerCount; i++) {
nsIContent *child = aContainer->GetChildAt(i);
if (mPresShell->GetPrimaryFrameFor(child)) {
if (mPresShell->GetPrimaryFrameFor(child)
#ifdef MOZ_XUL
// Except listboxes suck, so do NOT skip anything here if
// we plan to notify a listbox.
&& !MaybeGetListBoxBodyFrame(aContainer, child)
#endif
) {
// Already have a frame for this content; a previous ContentInserted
// in this loop must have reconstructed its insertion parent. Skip
// it.
@@ -8844,34 +8874,25 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext,
PRBool aUseXBLForms,
content_operation aOperation)
{
if (!aContainer)
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) {
nsIListBoxObject* listboxBody = listBoxObject->GetListBoxBody(PR_FALSE);
if (listboxBody) {
nsListBoxBodyFrame *listBoxBodyFrame = static_cast<nsListBoxBodyFrame*>(listboxBody);
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 {
listBoxBodyFrame->OnContentInserted(aPresContext, aChild);
return PR_TRUE;
}
nsIListBoxObject* listboxBody =
MaybeGetListBoxBodyFrame(aContainer, aChild);
if (listboxBody) {
nsListBoxBodyFrame *listBoxBodyFrame = static_cast<nsListBoxBodyFrame*>(listboxBody);
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 {
listBoxBodyFrame->OnContentInserted(aPresContext, aChild);
return PR_TRUE;
}
}

View File

@@ -92,6 +92,8 @@ _TEST_FILES = \
test_bug416896.html \
test_bug420499.xul \
test_bug423523.html \
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>