From 1ecb83edfe412fcd79673477d808bb4281ba2ee4 Mon Sep 17 00:00:00 2001 From: "allan%beaufour.dk" Date: Wed, 11 May 2005 09:21:20 +0000 Subject: [PATCH] Validate controls on form initialization. Bug 292915, r=aaronr+smaug, a=mkaply, NPOTB git-svn-id: svn://10.0.0.236/trunk@173289 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/xforms/nsXFormsMDGEngine.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mozilla/extensions/xforms/nsXFormsMDGEngine.cpp b/mozilla/extensions/xforms/nsXFormsMDGEngine.cpp index f6422471b8c..0a58b3cee0b 100644 --- a/mozilla/extensions/xforms/nsXFormsMDGEngine.cpp +++ b/mozilla/extensions/xforms/nsXFormsMDGEngine.cpp @@ -166,7 +166,7 @@ nsXFormsMDGEngine::AddMIP(ModelItemPropName aType, printf("nsXFormsMDGEngine::AddMIP(aContextNode=%s, aExpression=%p, aDependencies=|%d|,\n", NS_ConvertUCS2toUTF8(nodename).get(), (void*) aExpression, - aDependencies->Count()); + aDependencies ? aDependencies->Count() : 0); printf(" aContextPos=%d, aContextSize=%d, aType=%s, aDynFunc=%d)\n", aContextPos, aContextSize, gMIPNames[aType], aDynFunc); #endif @@ -348,6 +348,7 @@ nsXFormsMDGEngine::Recalculate(nsCOMArray *aChangedNodes) NS_ENSURE_TRUE(ns, NS_ERROR_FAILURE); PRBool constraint = PR_TRUE; + PRBool conChanged; // Find MIP-type and handle it accordingly switch (g->mType) { case eModel_calculate: @@ -385,9 +386,15 @@ nsXFormsMDGEngine::Recalculate(nsCOMArray *aChangedNodes) NS_ENSURE_SUCCESS(rv, rv); } - if (ns->IsConstraint() != constraint) { - ns->Set(eFlag_CONSTRAINT, constraint); - ns->Set(eFlag_DISPATCH_VALID_CHANGED, PR_TRUE); + conChanged = ns->IsConstraint() != constraint; + // On the first calculate after a rebuild (mFirstCalculate) we also + // add constraints to the set of changed nodes to trigger validation + // of type information if present. + if (conChanged || mFirstCalculate) { + if (conChanged) { + ns->Set(eFlag_CONSTRAINT, constraint); + ns->Set(eFlag_DISPATCH_VALID_CHANGED, PR_TRUE); + } NS_ENSURE_TRUE(aChangedNodes->AppendObject(g->mContextNode), NS_ERROR_FAILURE); }