diff --git a/mozilla/extensions/xforms/nsXFormsInstanceElement.cpp b/mozilla/extensions/xforms/nsXFormsInstanceElement.cpp index a9ace90b5dc..3a51371b276 100644 --- a/mozilla/extensions/xforms/nsXFormsInstanceElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsInstanceElement.cpp @@ -498,16 +498,50 @@ nsXFormsInstanceElement::CloneInlineInstance() temp->GetNextSibling(getter_AddRefs(child)); } - if (child) { - nsCOMPtr newNode; - rv = mDocument->ImportNode(child, PR_TRUE, getter_AddRefs(newNode)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr nodeReturn; - rv = mDocument->AppendChild(newNode, getter_AddRefs(nodeReturn)); - NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to append root instance node"); + // There needs to be a child element, or it is not a valid XML document + if (!child) { + nsXFormsUtils::ReportError(NS_LITERAL_STRING("inlineInstanceNoChildError"), + mElement); + nsCOMPtr model(GetModel()); + nsCOMPtr modelNode(do_QueryInterface(model)); + nsXFormsUtils::DispatchEvent(modelNode, eEvent_LinkException); + nsXFormsUtils::HandleFatalError(mElement, + NS_LITERAL_STRING("XFormsLinkException")); + return NS_ERROR_FAILURE; } + // Check for siblings to first child element node. This is an error, since + // the inline content is then not a well-formed XML document. + nsCOMPtr sibling; + child->GetNextSibling(getter_AddRefs(sibling)); + while (sibling) { + PRUint16 nodeType; + sibling->GetNodeType(&nodeType); + + if (nodeType == nsIDOMNode::ELEMENT_NODE) { + nsXFormsUtils::ReportError(NS_LITERAL_STRING("inlineInstanceMultipleElementsError"), + mElement); + nsCOMPtr model(GetModel()); + nsCOMPtr modelNode(do_QueryInterface(model)); + nsXFormsUtils::DispatchEvent(modelNode, eEvent_LinkException); + nsXFormsUtils::HandleFatalError(mElement, + NS_LITERAL_STRING("XFormsLinkException")); + return NS_ERROR_FAILURE; + } + + temp.swap(sibling); + temp->GetNextSibling(getter_AddRefs(sibling)); + } + + // Clone and insert content into new document + nsCOMPtr newNode; + rv = mDocument->ImportNode(child, PR_TRUE, getter_AddRefs(newNode)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr nodeReturn; + rv = mDocument->AppendChild(newNode, getter_AddRefs(nodeReturn)); + NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to append root instance node"); + return rv; } diff --git a/mozilla/extensions/xforms/nsXFormsModelElement.cpp b/mozilla/extensions/xforms/nsXFormsModelElement.cpp index 3d762e152ad..b051c514320 100644 --- a/mozilla/extensions/xforms/nsXFormsModelElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsModelElement.cpp @@ -761,14 +761,15 @@ nsXFormsModelElement::InitializeInstances() children->GetLength(&childCount); } + nsresult rv; for (PRUint32 i = 0; i < childCount; ++i) { nsCOMPtr child; children->Item(i, getter_AddRefs(child)); if (nsXFormsUtils::IsXFormsElement(child, NS_LITERAL_STRING("instance"))) { nsCOMPtr instance(do_QueryInterface(child)); - if (instance) { - instance->Initialize(); - } + NS_ENSURE_STATE(instance); + rv = instance->Initialize(); + NS_ENSURE_SUCCESS(rv, rv); } } @@ -793,7 +794,7 @@ nsXFormsModelElement::InitializeInstances() mSchemaTotal = schemas.Count(); for (PRInt32 i=0; i newURI; NS_NewURI(getter_AddRefs(newURI), *schemas[i], nsnull, baseURI); nsCOMPtr newURL = do_QueryInterface(newURI); diff --git a/mozilla/extensions/xforms/nsXFormsModule.cpp b/mozilla/extensions/xforms/nsXFormsModule.cpp index f403e825d17..224e65e5267 100644 --- a/mozilla/extensions/xforms/nsXFormsModule.cpp +++ b/mozilla/extensions/xforms/nsXFormsModule.cpp @@ -60,6 +60,10 @@ RegisterXFormsModule(nsIComponentManager *aCompMgr, const char *aComponentType, const nsModuleComponentInfo *aInfo) { +#ifdef DEBUG + printf("XFORMS Module: Registering\n"); +#endif + nsCOMPtr catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID); @@ -93,6 +97,10 @@ UnregisterXFormsModule(nsIComponentManager *aCompMgr, const char *aRegistryLocation, const nsModuleComponentInfo *aInfo) { +#ifdef DEBUG + printf("XFORMS Module: Unregistering\n"); +#endif + nsCOMPtr catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID); diff --git a/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties b/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties index acaef44fe47..db91bbc9e2e 100644 --- a/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties +++ b/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties @@ -72,6 +72,8 @@ instanceNotFound = XForms Error (33): Could not find instance with id == '%S defInstanceNotFound = XForms Error (34): Could not find default instance MDGLoopError = XForms Error (35): There are loops in the bindings of the model! invalidExtFunction = XForms Error (36): Non-existant extension functions listed in this model's function attribute +inlineInstanceNoChildError = XForms Error (37): Inline instance has no child elements. This is illegal. +inlineInstanceMultipleElementsError = XForms Error (38): Inline instance has multiple child elements. This is illegal. # Warning Messages: warnSOAP = XForms Warning (1): You are using the SOAP post feature, which is an experimental feature! Beware that the functionality might change, and forms may stop working at any time.