mElement->GetAttribute(NS_LITERAL_STRING("src"), src); PRBool hasSrc = !src.IsEmpty();
if (!hasBinding) { mElement->GetAttribute(NS_LITERAL_STRING("src"), src); }
nsXFormsMessageElement::HandleModalAndModelessMessage(nsIDOMDocument* aDoc,                                                      nsAString& aLevel){  nsCOMPtr<nsIDOMDocumentView> dview(do_QueryInterface(aDoc));  if (!dview)    return NS_OK;  nsCOMPtr<nsIDOMAbstractView> aview;  dview->GetDefaultView(getter_AddRefs(aview));  nsCOMPtr<nsIDOMWindowInternal> internal(do_QueryInterface(aview));  if (!internal)    return NS_OK;  nsAutoString instanceData;  PRBool hasBinding = nsXFormsUtils::GetSingleNodeBindingValue(mElement,                                                               instanceData);  nsAutoString options;  options.AppendLiteral(MESSAGE_WINDOW_PROPERTIES);  nsAutoString src;  mElement->GetAttribute(NS_LITERAL_STRING("src"), src);  PRBool hasSrc = !src.IsEmpty();  nsCOMPtr<nsIDOMViewCSS> cssView(do_QueryInterface(internal));  AppendCSSOptions(cssView, options);  nsresult rv;  if (hasSrc) {    // Creating a normal window for messages with src attribute.    options.AppendLiteral(",chrome=no");    rv = ConstructMessageWindowURL(src, PR_TRUE, src);    NS_ENSURE_SUCCESS(rv, rv);  } else {    // Cloning the content of the xf:message and creating a    // dialog for it.    options.AppendLiteral(",dialog,chrome,dependent");    nsCOMPtr<nsIDOMDocument> ddoc;    nsCOMPtr<nsIDOMDOMImplementation> domImpl;    rv = aDoc->GetImplementation(getter_AddRefs(domImpl));    NS_ENSURE_SUCCESS(rv, rv);    rv = domImpl->CreateDocument(EmptyString(), EmptyString(), nsnull,                                 getter_AddRefs(ddoc));    NS_ENSURE_SUCCESS(rv, rv);    if (!ddoc)      return NS_OK;    nsCOMPtr<nsIDOMNode> tmp;    nsCOMPtr<nsIDOMElement> htmlEl;    rv = ddoc->CreateElementNS(NS_LITERAL_STRING(NS_NAMESPACE_XHTML),                               NS_LITERAL_STRING("html"),                               getter_AddRefs(htmlEl));    NS_ENSURE_SUCCESS(rv, rv);    ddoc->AppendChild(htmlEl, getter_AddRefs(tmp));        nsCOMPtr<nsIDOMElement> bodyEl;    rv = ddoc->CreateElementNS(NS_LITERAL_STRING(NS_NAMESPACE_XHTML),                               NS_LITERAL_STRING("body"),                               getter_AddRefs(bodyEl));    NS_ENSURE_SUCCESS(rv, rv);    htmlEl->AppendChild(bodyEl, getter_AddRefs(tmp));        // If we have a binding, it is enough to show a simple message    if (hasBinding) {      nsCOMPtr<nsIDOM3Node> body3(do_QueryInterface(bodyEl));      if (body3)        body3->SetTextContent(instanceData);    } else {      // Otherwise copying content from the original document to      // the modeless/modal message document.      nsCOMPtr<nsIDOMNode> tmp;      nsCOMPtr<nsIDOMNodeList> childNodes;      mElement->GetChildNodes(getter_AddRefs(childNodes));      PRUint32 count = 0;      if (childNodes)        childNodes->GetLength(&count);      for (PRUint32 i = 0; i < count; ++i) {        nsCOMPtr<nsIDOMNode> child;        childNodes->Item(i, getter_AddRefs(child));                if (child) {          nsCOMPtr<nsIDOMNode> clone;          CloneNode(child, getter_AddRefs(clone));          if (clone)            bodyEl->AppendChild(clone, getter_AddRefs(tmp));        }      }    }        nsCOMPtr<nsIDOMSerializer> serializer =      do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv);    NS_ENSURE_SUCCESS(rv, rv);    nsAutoString docString;    rv = serializer->SerializeToString(ddoc, docString);    NS_ENSURE_SUCCESS(rv, rv);        rv = ConstructMessageWindowURL(docString, PR_FALSE, src);    NS_ENSURE_SUCCESS(rv, rv);  }    nsCOMPtr<nsISupports> arg;  PRBool isModal = aLevel.EqualsLiteral("modal");  if (isModal) {    options.AppendLiteral(",modal");    // We need to have an argument to set the window modal.    // Using nsXFormsAtoms::messageProperty so that we don't create new    // cycles between the windows.    arg = nsXFormsAtoms::messageProperty;  }    //XXX Add support for xforms-link-error.  nsCOMPtr<nsIDOMWindow> messageWindow;  internal->OpenDialog(src, aLevel, options, arg, getter_AddRefs(messageWindow));  if (!isModal) {    nsCOMPtr<nsIDOMWindowInternal> msgWinInternal =      do_QueryInterface(messageWindow);    if (msgWinInternal)      msgWinInternal->Focus();  }  return NS_OK;}