[XForms] generate xforms-link-error for help, hint, alert and message elements. Bug 300255, r=smaug+allan

git-svn-id: svn://10.0.0.236/trunk@192790 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
aaronr%us.ibm.com
2006-03-22 18:05:49 +00:00
parent 8d81bda849
commit 0d627e8dde
9 changed files with 495 additions and 40 deletions

View File

@@ -271,7 +271,8 @@ nsXFormsModelElement::nsXFormsModelElement()
mInstancesInitialized(PR_FALSE),
mReadyHandled(PR_FALSE),
mInstanceDocuments(nsnull),
mLazyModel(PR_FALSE)
mLazyModel(PR_FALSE),
mConstructDoneHandled(PR_FALSE)
{
}
@@ -561,6 +562,7 @@ nsXFormsModelElement::HandleDefault(nsIDOMEvent *aEvent, PRBool *aHandled)
rv = Rebuild();
} else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_ModelConstructDone].name)) {
rv = ConstructDone();
mConstructDoneHandled = PR_TRUE;
} else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_Reset].name)) {
Reset();
} else if (type.EqualsASCII(sXFormsEventsEntries[eEvent_BindingException].name)) {
@@ -1577,6 +1579,19 @@ nsXFormsModelElement::MaybeNotifyCompletion()
nsXFormsModelElement::ProcessDeferredBinds(domDoc);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (doc) {
PRUint32 loadingMessages = NS_REINTERPRET_CAST(PRUint32,
doc->GetProperty(nsXFormsAtoms::externalMessagesProperty));
if (loadingMessages) {
// if we are still waiting for external messages to load, then put off
// the xforms-ready until a model in the document is notified that they
// are finished loading
return;
}
}
for (i = 0; i < models->Count(); ++i) {
nsXFormsModelElement *model =
NS_STATIC_CAST(nsXFormsModelElement *, models->ElementAt(i));
@@ -1823,6 +1838,51 @@ nsXFormsModelElement::RemoveInstanceElement(nsIInstanceElementPrivate *aInstEle)
return NS_OK;
}
nsresult
nsXFormsModelElement::MessageLoadFinished()
{
// This is our signal that all external message links have been tested. If
// we were waiting for this to send out xforms-ready, then now is the time.
// if this document hasn't processed xforms-model-construct-done, yet (which
// must precede xforms-ready), then we'll send out the xforms-ready later
// as part of our normal handling. If we've already become ready, then this
// event was probably generated by a change in the src attribute on the
// message element. Ignore it in that case.
if (!mConstructDoneHandled || mReadyHandled) {
return NS_OK;
}
nsCOMPtr<nsIDOMDocument> domDoc;
mElement->GetOwnerDocument(getter_AddRefs(domDoc));
const nsVoidArray *models = GetModelList(domDoc);
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
nsCOMArray<nsIXFormsControlBase> *deferredBindList =
NS_STATIC_CAST(nsCOMArray<nsIXFormsControlBase> *,
doc->GetProperty(nsXFormsAtoms::deferredBindListProperty));
// if we've already gotten the xforms-model-construct-done event and not
// yet the xforms-ready, we've hit a window where we may still be
// processing the deferred control binding. If so, we'll leave now and
// leave it to MaybeNotifyCompletion to generate the xforms-ready event.
if (deferredBindList) {
return NS_OK;
}
// if we reached here, then we had to wait on sending out the xforms-ready
// events until the external messages were tested. Now we are finally
// ready to send out xforms-ready to all of the models.
for (int i = 0; i < models->Count(); ++i) {
nsXFormsModelElement *model =
NS_STATIC_CAST(nsXFormsModelElement *, models->ElementAt(i));
model->mReadyHandled = PR_TRUE;
nsXFormsUtils::DispatchEvent(model->mElement, eEvent_Ready);
}
return NS_OK;
}
/* static */ void
nsXFormsModelElement::Startup()
{