From 85e071b7cb0439571a6abf977c16330e5ce3c523 Mon Sep 17 00:00:00 2001 From: "allan%beaufour.dk" Date: Tue, 14 Jun 2005 07:33:01 +0000 Subject: [PATCH] Parse type attribute on instance node too. Bug 293082, r=smaug+aaronr, a=mkaply git-svn-id: svn://10.0.0.236/trunk@174545 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/xforms/nsXFormsUtils.cpp | 46 +++++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/mozilla/extensions/xforms/nsXFormsUtils.cpp b/mozilla/extensions/xforms/nsXFormsUtils.cpp index ea8e593cef4..84cb6a18a02 100644 --- a/mozilla/extensions/xforms/nsXFormsUtils.cpp +++ b/mozilla/extensions/xforms/nsXFormsUtils.cpp @@ -1154,27 +1154,37 @@ nsXFormsUtils::ParseTypeFromNode(nsIDOMNode *aInstanceData, // aInstanceData could be an instance data node or it could be an attribute // on an instance data node (basically the node that a control is bound to). - // So first checking to see if it is a proper element node. If it isn't, - // making sure that it is at least an attribute. - - /// @bug We need to check for any type attributes set directly on the node - /// too (XXX) nsAutoString *typeVal = nsnull; - nsCOMPtr nodeContent(do_QueryInterface(aInstanceData)); - if (nodeContent) { - typeVal = - NS_STATIC_CAST(nsAutoString*, - nodeContent->GetProperty(nsXFormsAtoms::type, &rv)); - } else { - nsCOMPtr nodeAttribute(do_QueryInterface(aInstanceData)); - if (!nodeAttribute) - // node is neither content or attribute! - return NS_ERROR_FAILURE; - typeVal = - NS_STATIC_CAST(nsAutoString*, - nodeAttribute->GetProperty(nsXFormsAtoms::type, &rv)); + // Get type stored directly on instance node + nsAutoString typeAttribute; + nsCOMPtr nodeElem(do_QueryInterface(aInstanceData)); + if (nodeElem) { + nodeElem->GetAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XML_SCHEMA_INSTANCE), + NS_LITERAL_STRING("type"), typeAttribute); + if (!typeAttribute.IsEmpty()) { + typeVal = &typeAttribute; + } + } + + if (!typeVal) { + // Get MIP type bound to node + nsCOMPtr nodeContent(do_QueryInterface(aInstanceData)); + if (nodeContent) { + typeVal = + NS_STATIC_CAST(nsAutoString*, + nodeContent->GetProperty(nsXFormsAtoms::type, &rv)); + } else { + nsCOMPtr nodeAttribute(do_QueryInterface(aInstanceData)); + if (!nodeAttribute) + // node is neither content or attribute! + return NS_ERROR_FAILURE; + + typeVal = + NS_STATIC_CAST(nsAutoString*, + nodeAttribute->GetProperty(nsXFormsAtoms::type, &rv)); + } } if (NS_FAILED(rv) || !typeVal) {