зеркало из https://github.com/mozilla/pjs.git
Bug 10617. Get folder performance back. We now _do not_ tell layout about individual content that gets appended during CreateContainerContents(), and instead wait until we've constructed all child nodes to do a ContentChanged() notification.
This commit is contained in:
Родитель
35ff975e0d
Коммит
50c29e871d
|
@ -218,7 +218,7 @@ public:
|
|||
NS_IMETHOD DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection);
|
||||
NS_IMETHOD OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *container, nsIRDFResource **flatArray,
|
||||
PRInt32 numElements, PRInt32 elementSize);
|
||||
NS_IMETHOD InsertContainerNode(nsIContent *container, nsIContent *node);
|
||||
NS_IMETHOD InsertContainerNode(nsIContent *container, nsIContent *node, PRBool aNotify);
|
||||
};
|
||||
|
||||
nsIXULSortService *XULSortServiceImpl::gXULSortService = nsnull;
|
||||
|
@ -1278,7 +1278,7 @@ XULSortServiceImpl::OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *con
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
||||
XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
nsString sortResource, sortDirection;
|
||||
|
@ -1420,13 +1420,13 @@ XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
|||
{
|
||||
if (current >= numChildren)
|
||||
{
|
||||
container->AppendChildTo(node, PR_TRUE);
|
||||
container->AppendChildTo(node, aNotify);
|
||||
}
|
||||
else
|
||||
{
|
||||
container->InsertChildAt(node,
|
||||
((direction > 0) ? current + 1: (current >= 0) ? current : 0),
|
||||
PR_TRUE);
|
||||
aNotify);
|
||||
}
|
||||
childAdded = PR_TRUE;
|
||||
break;
|
||||
|
@ -1451,7 +1451,7 @@ XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
|||
PRInt32 sortVal = inplaceSortCallback(&node, &theChild, &sortInfo);
|
||||
if (sortVal <= 0)
|
||||
{
|
||||
container->InsertChildAt(node, childIndex, PR_TRUE);
|
||||
container->InsertChildAt(node, childIndex, aNotify);
|
||||
childAdded = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1462,7 +1462,7 @@ XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
|||
|
||||
if (childAdded == PR_FALSE)
|
||||
{
|
||||
container->AppendChildTo(node, PR_TRUE);
|
||||
container->AppendChildTo(node, aNotify);
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
|
|
@ -604,7 +604,7 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
|||
|
||||
// Okay, it's a "live" element, so go ahead and append the new
|
||||
// child to this node.
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0);
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
|||
if (! newresource)
|
||||
return NS_OK;
|
||||
|
||||
rv = CreateWidgetItem(element, aProperty, newresource, 0);
|
||||
rv = CreateWidgetItem(element, aProperty, newresource, 0, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
|
@ -1531,7 +1531,8 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
nsIContent *aRealNode,
|
||||
PRBool aIsUnique,
|
||||
nsIRDFResource* aChild,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -1611,7 +1612,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
}
|
||||
|
||||
// Recurse until we get to the resource element.
|
||||
rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1);
|
||||
rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1, aNotify);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else if (isResourceElement) {
|
||||
|
@ -1759,13 +1760,13 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
if (! aIsUnique) {
|
||||
// Note: add into tree, but only sort if its a resource element!
|
||||
if ((nsnull != XULSortService) && (isResourceElement)) {
|
||||
rv = XULSortService->InsertContainerNode(aRealNode, realKid);
|
||||
rv = XULSortService->InsertContainerNode(aRealNode, realKid, aNotify);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRealNode->AppendChildTo(realKid, PR_TRUE);
|
||||
aRealNode->AppendChildTo(realKid, aNotify);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aRealNode->AppendChildTo(realKid, PR_TRUE);
|
||||
aRealNode->AppendChildTo(realKid, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1789,7 +1790,8 @@ nsresult
|
|||
RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFResource *aChild,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsIContent> tmpl;
|
||||
nsresult rv;
|
||||
|
@ -1804,7 +1806,8 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,
|
|||
aElement,
|
||||
PR_TRUE,
|
||||
aChild,
|
||||
aNaturalOrderPos);
|
||||
aNaturalOrderPos,
|
||||
aNotify);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to build content from template");
|
||||
return rv;
|
||||
}
|
||||
|
@ -1931,16 +1934,11 @@ RDFGenericBuilderImpl::RemoveWidgetItem(nsIContent* aElement,
|
|||
nsIRDFResource* aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
// This works as follows. It finds all of the elements in the
|
||||
// document that correspond to aValue. Any that are contained
|
||||
// within aElement are removed from their direct parent.
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(mDocument);
|
||||
if (! xuldoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = aValue->GetValue(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2097,15 +2095,30 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou
|
|||
XULSortService->OpenContainer(mDB, aElement, flatArray, numElements/2, 2*sizeof(nsIRDFResource *));
|
||||
}
|
||||
|
||||
// This will insert all of the elements into the
|
||||
// container, but _won't_ bother layout about it.
|
||||
for (loop=0; loop<numElements; loop+=2) {
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1);
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
|
||||
for (PRInt32 i = PRInt32(numElements) - 1; i >=0; i--) {
|
||||
NS_IF_RELEASE(flatArray[i]);
|
||||
}
|
||||
delete [] flatArray;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
if (! doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// _Now_ tell layout that we've mucked with the
|
||||
// container. This'll force a reflow and get the content
|
||||
// displayed.
|
||||
rv = doc->ContentChanged(aElement, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
for (int i = numElements - 1; i >= 0; i--) {
|
||||
|
@ -2175,7 +2188,7 @@ RDFGenericBuilderImpl::CreateTemplateContents(nsIContent* aElement, const nsStri
|
|||
element = parent;
|
||||
}
|
||||
|
||||
rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1);
|
||||
rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The sort service interface. This is a singleton object, and should be
|
||||
obtained from the <tt>nsServiceManager</tt>.
|
||||
*/
|
||||
|
||||
#ifndef nsIXULSortService_h__
|
||||
#define nsIXULSortService_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsString.h"
|
||||
|
||||
|
||||
// {BFD05261-834C-11d2-8EAC-00805F29F371}
|
||||
#define NS_IXULSORTSERVICE_IID \
|
||||
{ 0xbfd05261, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x71 } }
|
||||
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIContent;
|
||||
class nsIRDFResource;
|
||||
class nsIDOMNode;
|
||||
|
||||
class nsIXULSortService : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXULSORTSERVICE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection) = 0;
|
||||
NS_IMETHOD OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *container,
|
||||
nsIRDFResource **flatArray, PRInt32 numElements, PRInt32 elementSize) = 0;
|
||||
NS_IMETHOD InsertContainerNode(nsIContent *container, nsIContent *child) = 0;
|
||||
};
|
||||
|
||||
|
||||
extern nsresult
|
||||
NS_NewXULSortService(nsIXULSortService** result);
|
||||
|
||||
#endif // nsIXULSortService_h__
|
|
@ -604,7 +604,7 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
|||
|
||||
// Okay, it's a "live" element, so go ahead and append the new
|
||||
// child to this node.
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0);
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
|||
if (! newresource)
|
||||
return NS_OK;
|
||||
|
||||
rv = CreateWidgetItem(element, aProperty, newresource, 0);
|
||||
rv = CreateWidgetItem(element, aProperty, newresource, 0, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
|
@ -1531,7 +1531,8 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
nsIContent *aRealNode,
|
||||
PRBool aIsUnique,
|
||||
nsIRDFResource* aChild,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -1611,7 +1612,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
}
|
||||
|
||||
// Recurse until we get to the resource element.
|
||||
rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1);
|
||||
rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1, aNotify);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else if (isResourceElement) {
|
||||
|
@ -1759,13 +1760,13 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
if (! aIsUnique) {
|
||||
// Note: add into tree, but only sort if its a resource element!
|
||||
if ((nsnull != XULSortService) && (isResourceElement)) {
|
||||
rv = XULSortService->InsertContainerNode(aRealNode, realKid);
|
||||
rv = XULSortService->InsertContainerNode(aRealNode, realKid, aNotify);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRealNode->AppendChildTo(realKid, PR_TRUE);
|
||||
aRealNode->AppendChildTo(realKid, aNotify);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aRealNode->AppendChildTo(realKid, PR_TRUE);
|
||||
aRealNode->AppendChildTo(realKid, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1789,7 +1790,8 @@ nsresult
|
|||
RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFResource *aChild,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsIContent> tmpl;
|
||||
nsresult rv;
|
||||
|
@ -1804,7 +1806,8 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,
|
|||
aElement,
|
||||
PR_TRUE,
|
||||
aChild,
|
||||
aNaturalOrderPos);
|
||||
aNaturalOrderPos,
|
||||
aNotify);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to build content from template");
|
||||
return rv;
|
||||
}
|
||||
|
@ -1931,16 +1934,11 @@ RDFGenericBuilderImpl::RemoveWidgetItem(nsIContent* aElement,
|
|||
nsIRDFResource* aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
// This works as follows. It finds all of the elements in the
|
||||
// document that correspond to aValue. Any that are contained
|
||||
// within aElement are removed from their direct parent.
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(mDocument);
|
||||
if (! xuldoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = aValue->GetValue(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2097,15 +2095,30 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou
|
|||
XULSortService->OpenContainer(mDB, aElement, flatArray, numElements/2, 2*sizeof(nsIRDFResource *));
|
||||
}
|
||||
|
||||
// This will insert all of the elements into the
|
||||
// container, but _won't_ bother layout about it.
|
||||
for (loop=0; loop<numElements; loop+=2) {
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1);
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
|
||||
for (PRInt32 i = PRInt32(numElements) - 1; i >=0; i--) {
|
||||
NS_IF_RELEASE(flatArray[i]);
|
||||
}
|
||||
delete [] flatArray;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
if (! doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// _Now_ tell layout that we've mucked with the
|
||||
// container. This'll force a reflow and get the content
|
||||
// displayed.
|
||||
rv = doc->ContentChanged(aElement, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
for (int i = numElements - 1; i >= 0; i--) {
|
||||
|
@ -2175,7 +2188,7 @@ RDFGenericBuilderImpl::CreateTemplateContents(nsIContent* aElement, const nsStri
|
|||
element = parent;
|
||||
}
|
||||
|
||||
rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1);
|
||||
rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -123,13 +123,15 @@ public:
|
|||
nsIContent *aRealNode,
|
||||
PRBool aIsUnique,
|
||||
nsIRDFResource* aChild,
|
||||
PRInt32 aNaturalOrderPos);
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify);
|
||||
|
||||
nsresult
|
||||
CreateWidgetItem(nsIContent* aElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aChild,
|
||||
PRInt32 aNaturalOrderPos);
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify);
|
||||
|
||||
enum eUpdateAction { eSet, eClear };
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ public:
|
|||
NS_IMETHOD DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection);
|
||||
NS_IMETHOD OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *container, nsIRDFResource **flatArray,
|
||||
PRInt32 numElements, PRInt32 elementSize);
|
||||
NS_IMETHOD InsertContainerNode(nsIContent *container, nsIContent *node);
|
||||
NS_IMETHOD InsertContainerNode(nsIContent *container, nsIContent *node, PRBool aNotify);
|
||||
};
|
||||
|
||||
nsIXULSortService *XULSortServiceImpl::gXULSortService = nsnull;
|
||||
|
@ -1278,7 +1278,7 @@ XULSortServiceImpl::OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *con
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
||||
XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
nsString sortResource, sortDirection;
|
||||
|
@ -1420,13 +1420,13 @@ XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
|||
{
|
||||
if (current >= numChildren)
|
||||
{
|
||||
container->AppendChildTo(node, PR_TRUE);
|
||||
container->AppendChildTo(node, aNotify);
|
||||
}
|
||||
else
|
||||
{
|
||||
container->InsertChildAt(node,
|
||||
((direction > 0) ? current + 1: (current >= 0) ? current : 0),
|
||||
PR_TRUE);
|
||||
aNotify);
|
||||
}
|
||||
childAdded = PR_TRUE;
|
||||
break;
|
||||
|
@ -1451,7 +1451,7 @@ XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
|||
PRInt32 sortVal = inplaceSortCallback(&node, &theChild, &sortInfo);
|
||||
if (sortVal <= 0)
|
||||
{
|
||||
container->InsertChildAt(node, childIndex, PR_TRUE);
|
||||
container->InsertChildAt(node, childIndex, aNotify);
|
||||
childAdded = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1462,7 +1462,7 @@ XULSortServiceImpl::InsertContainerNode(nsIContent *container, nsIContent *node)
|
|||
|
||||
if (childAdded == PR_FALSE)
|
||||
{
|
||||
container->AppendChildTo(node, PR_TRUE);
|
||||
container->AppendChildTo(node, aNotify);
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
|
|
@ -604,7 +604,7 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
|||
|
||||
// Okay, it's a "live" element, so go ahead and append the new
|
||||
// child to this node.
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0);
|
||||
rv = CreateWidgetItem(element, aProperty, resource, 0, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
|||
if (! newresource)
|
||||
return NS_OK;
|
||||
|
||||
rv = CreateWidgetItem(element, aProperty, newresource, 0);
|
||||
rv = CreateWidgetItem(element, aProperty, newresource, 0, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
|
@ -1531,7 +1531,8 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
nsIContent *aRealNode,
|
||||
PRBool aIsUnique,
|
||||
nsIRDFResource* aChild,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -1611,7 +1612,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
}
|
||||
|
||||
// Recurse until we get to the resource element.
|
||||
rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1);
|
||||
rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1, aNotify);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else if (isResourceElement) {
|
||||
|
@ -1759,13 +1760,13 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
if (! aIsUnique) {
|
||||
// Note: add into tree, but only sort if its a resource element!
|
||||
if ((nsnull != XULSortService) && (isResourceElement)) {
|
||||
rv = XULSortService->InsertContainerNode(aRealNode, realKid);
|
||||
rv = XULSortService->InsertContainerNode(aRealNode, realKid, aNotify);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRealNode->AppendChildTo(realKid, PR_TRUE);
|
||||
aRealNode->AppendChildTo(realKid, aNotify);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aRealNode->AppendChildTo(realKid, PR_TRUE);
|
||||
aRealNode->AppendChildTo(realKid, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1789,7 +1790,8 @@ nsresult
|
|||
RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,
|
||||
nsIRDFResource *aProperty,
|
||||
nsIRDFResource *aChild,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
PRInt32 aNaturalOrderPos,
|
||||
PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsIContent> tmpl;
|
||||
nsresult rv;
|
||||
|
@ -1804,7 +1806,8 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,
|
|||
aElement,
|
||||
PR_TRUE,
|
||||
aChild,
|
||||
aNaturalOrderPos);
|
||||
aNaturalOrderPos,
|
||||
aNotify);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to build content from template");
|
||||
return rv;
|
||||
}
|
||||
|
@ -1931,16 +1934,11 @@ RDFGenericBuilderImpl::RemoveWidgetItem(nsIContent* aElement,
|
|||
nsIRDFResource* aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
// This works as follows. It finds all of the elements in the
|
||||
// document that correspond to aValue. Any that are contained
|
||||
// within aElement are removed from their direct parent.
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(mDocument);
|
||||
if (! xuldoc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = aValue->GetValue(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -2097,15 +2095,30 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou
|
|||
XULSortService->OpenContainer(mDB, aElement, flatArray, numElements/2, 2*sizeof(nsIRDFResource *));
|
||||
}
|
||||
|
||||
// This will insert all of the elements into the
|
||||
// container, but _won't_ bother layout about it.
|
||||
for (loop=0; loop<numElements; loop+=2) {
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1);
|
||||
rv = CreateWidgetItem(aElement, flatArray[loop+1], flatArray[loop], loop+1, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item");
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
|
||||
for (PRInt32 i = PRInt32(numElements) - 1; i >=0; i--) {
|
||||
NS_IF_RELEASE(flatArray[i]);
|
||||
}
|
||||
delete [] flatArray;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
if (! doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// _Now_ tell layout that we've mucked with the
|
||||
// container. This'll force a reflow and get the content
|
||||
// displayed.
|
||||
rv = doc->ContentChanged(aElement, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
for (int i = numElements - 1; i >= 0; i--) {
|
||||
|
@ -2175,7 +2188,7 @@ RDFGenericBuilderImpl::CreateTemplateContents(nsIContent* aElement, const nsStri
|
|||
element = parent;
|
||||
}
|
||||
|
||||
rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1);
|
||||
rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче