Bug 385315, Remove unused parameters from XML/XBL/RDFContentSink::FlushText, r+sr=peterv

This commit is contained in:
Olli.Pettay@helsinki.fi 2007-06-26 21:22:35 -07:00
parent ee678ee439
commit 7a515960c9
6 changed files with 41 additions and 64 deletions

View File

@ -840,36 +840,38 @@ nsBindingManager::ProcessAttachedQueue()
mAttachedStack.Compact();
}
// Keep bindings and bound elements alive while executing detached handlers.
struct BindingTableReadClosure
{
nsCOMArray<nsIContent> mBoundElements;
nsBindingList mBindings;
};
PR_STATIC_CALLBACK(PLDHashOperator)
AccumulateBindingsToDetach(nsISupports *aKey, nsXBLBinding *aBinding,
void* aVoidArray)
void* aClosure)
{
nsVoidArray* arr = NS_STATIC_CAST(nsVoidArray*, aVoidArray);
// Hold an owning reference to this binding, just in case
if (arr->AppendElement(aBinding))
NS_ADDREF(aBinding);
BindingTableReadClosure* closure =
NS_STATIC_CAST(BindingTableReadClosure*, aClosure);
if (aBinding && closure->mBindings.AppendElement(aBinding)) {
if (!closure->mBoundElements.AppendObject(aBinding->GetBoundElement())) {
closure->mBindings.RemoveElementAt(closure->mBindings.Length() - 1);
}
}
return PL_DHASH_NEXT;
}
PR_STATIC_CALLBACK(PRBool)
ExecuteDetachedHandler(void* aBinding, void* aClosure)
{
NS_PRECONDITION(aBinding, "Null binding in list?");
nsXBLBinding* binding = NS_STATIC_CAST(nsXBLBinding*, aBinding);
binding->ExecuteDetachedHandler();
// Drop our ref to the binding now
NS_RELEASE(binding);
return PR_TRUE;
}
void
nsBindingManager::ExecuteDetachedHandlers()
{
// Walk our hashtable of bindings.
if (mBindingTable.IsInitialized()) {
nsVoidArray bindingsToDetach;
mBindingTable.EnumerateRead(AccumulateBindingsToDetach, &bindingsToDetach);
bindingsToDetach.EnumerateForwards(ExecuteDetachedHandler, nsnull);
BindingTableReadClosure closure;
mBindingTable.EnumerateRead(AccumulateBindingsToDetach, &closure);
PRUint32 i, count = closure.mBindings.Length();
for (i = 0; i < count; ++i) {
closure.mBindings[i]->ExecuteDetachedHandler();
}
}
}

View File

@ -117,12 +117,9 @@ nsXBLContentSink::MaybeStartLayout(PRBool aIgnorePendingSheets)
}
nsresult
nsXBLContentSink::FlushText(PRBool aCreateTextNode,
PRBool* aDidFlush)
nsXBLContentSink::FlushText()
{
if (mTextLength == 0) {
if (aDidFlush)
*aDidFlush = PR_FALSE;
return NS_OK;
}
@ -133,8 +130,6 @@ nsXBLContentSink::FlushText(PRBool aCreateTextNode,
if (mSecondaryState == eXBL_InHandler)
mHandler->AppendHandlerText(text);
mTextLength = 0;
if (aDidFlush)
*aDidFlush = PR_TRUE;
return NS_OK;
}
else if (mState == eXBL_InImplementation) {
@ -169,8 +164,6 @@ nsXBLContentSink::FlushText(PRBool aCreateTextNode,
mField->AppendFieldText(text);
}
mTextLength = 0;
if (aDidFlush)
*aDidFlush = PR_TRUE;
return NS_OK;
}
@ -196,13 +189,11 @@ nsXBLContentSink::FlushText(PRBool aCreateTextNode,
if (isWS && mTextLength > 0) {
mTextLength = 0;
if (aDidFlush)
*aDidFlush = PR_TRUE;
return NS_OK;
}
}
return nsXMLContentSink::FlushText(aCreateTextNode, aDidFlush);
return nsXMLContentSink::FlushText();
}
NS_IMETHODIMP

View File

@ -145,8 +145,7 @@ protected:
// nsXMLContentSink overrides
nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
PRBool* aDidFlush=nsnull);
nsresult FlushText();
// nsIExpatSink overrides
NS_IMETHOD ReportError(const PRUnichar* aErrorText,

View File

@ -837,30 +837,22 @@ nsXMLContentSink::GetTarget()
}
nsresult
nsXMLContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
nsXMLContentSink::FlushText()
{
nsresult rv = NS_OK;
PRBool didFlush = PR_FALSE;
if (0 != mTextLength) {
if (aCreateTextNode) {
nsCOMPtr<nsIContent> textContent;
rv = NS_NewTextNode(getter_AddRefs(textContent), mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);
// Set the text in the text node
textContent->SetText(mText, mTextLength, PR_FALSE);
// Add text to its parent
AddContentAsLeaf(textContent);
}
mTextLength = 0;
didFlush = PR_TRUE;
if (mTextLength == 0) {
return NS_OK;
}
if (nsnull != aDidFlush) {
*aDidFlush = didFlush;
}
return rv;
nsCOMPtr<nsIContent> textContent;
nsresult rv = NS_NewTextNode(getter_AddRefs(textContent), mNodeInfoManager);
NS_ENSURE_SUCCESS(rv, rv);
// Set the text in the text node
textContent->SetText(mText, mTextLength, PR_FALSE);
mTextLength = 0;
// Add text to its parent
return AddContentAsLeaf(textContent);
}
nsIContent*

View File

@ -136,8 +136,7 @@ protected:
// being closed
virtual nsresult CloseElement(nsIContent* aContent);
virtual nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
PRBool* aDidFlush=nsnull);
virtual nsresult FlushText();
nsresult AddContentAsLeaf(nsIContent *aContent);

View File

@ -210,8 +210,7 @@ protected:
// Text management
void ParseText(nsIRDFNode **aResult);
nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
PRBool* aDidFlush=nsnull);
nsresult FlushText();
nsresult AddText(const PRUnichar* aText, PRInt32 aLength);
// RDF-specific parsing
@ -769,12 +768,11 @@ RDFContentSinkImpl::ParseText(nsIRDFNode **aResult)
}
nsresult
RDFContentSinkImpl::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
RDFContentSinkImpl::FlushText()
{
nsresult rv = NS_OK;
PRBool didFlush = PR_FALSE;
if (0 != mTextLength) {
if (aCreateTextNode && rdf_IsDataInBuffer(mText, mTextLength)) {
if (rdf_IsDataInBuffer(mText, mTextLength)) {
// XXX if there's anything but whitespace, then we'll
// create a text node.
@ -803,10 +801,6 @@ RDFContentSinkImpl::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
}
}
mTextLength = 0;
didFlush = PR_TRUE;
}
if (nsnull != aDidFlush) {
*aDidFlush = didFlush;
}
return rv;
}