Commit a56f770b authored by vidur%netscape.com's avatar vidur%netscape.com
Browse files

First pass to allow HTML forms to be embedded inside XML documents.

parent a4f8f936
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -538,10 +538,12 @@ MakeContentObject(nsHTMLTag aNodeType,
    break;
    break;
  case eHTMLTag_form:
  case eHTMLTag_form:
    // the form was already created 
    // the form was already created 
    *aResult = nsnull;
    if (aForm) {
    if (aForm) {
      rv = aForm->QueryInterface(kIHTMLContentIID, (void**)aResult);
      rv = aForm->QueryInterface(kIHTMLContentIID, (void**)aResult);
    }
    }
    else {
      rv = NS_NewHTMLFormElement(aResult, aAtom);
    }
    break;
    break;
  case eHTMLTag_frame:
  case eHTMLTag_frame:
    rv = NS_NewHTMLFrameElement(aResult, aAtom);
    rv = NS_NewHTMLFrameElement(aResult, aAtom);
+40 −24
Original line number Original line Diff line number Diff line
@@ -455,7 +455,8 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
  nsAutoString tag, nameSpace;
  nsAutoString tag, nameSpace;
  PRInt32 nsoffset;
  PRInt32 nsoffset;
  PRInt32 id = gNameSpaceId_Unknown;
  PRInt32 id = gNameSpaceId_Unknown;
  PRBool isHTML = nsnull;
  PRBool isHTML = PR_FALSE;
  PRBool pushContent = PR_TRUE;
  nsIContent *content;
  nsIContent *content;


  // XXX Hopefully the parser will flag this before we get
  // XXX Hopefully the parser will flag this before we get
@@ -494,7 +495,13 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
    if (nsHTMLAtoms::script == tagAtom) {
    if (nsHTMLAtoms::script == tagAtom) {
      result = ProcessStartSCRIPTTag(aNode);
      result = ProcessStartSCRIPTTag(aNode);
    }
    }
    // XXX Treat the form elements as a leaf element (even if it is a
    // container). Need to do further processing with forms
    else if (nsHTMLAtoms::form == tagAtom) {
      pushContent = PR_FALSE;
    }
    NS_RELEASE(tagAtom);
    NS_RELEASE(tagAtom);

    nsIHTMLContent *htmlContent = nsnull;
    nsIHTMLContent *htmlContent = nsnull;
    result = NS_CreateHTMLElement(&htmlContent, tag);
    result = NS_CreateHTMLElement(&htmlContent, tag);
    content = (nsIContent *)htmlContent;
    content = (nsIContent *)htmlContent;
@@ -533,9 +540,11 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)


        parent->AppendChildTo(content, PR_FALSE);
        parent->AppendChildTo(content, PR_FALSE);
      }
      }
      if (pushContent) {
        PushContent(content);
        PushContent(content);
      }
      }
    }
    }
  }


  return result;
  return result;
}
}
@@ -547,7 +556,8 @@ nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
  nsAutoString tag, nameSpace;
  nsAutoString tag, nameSpace;
  PRInt32 nsoffset;
  PRInt32 nsoffset;
  PRInt32 id = gNameSpaceId_Unknown;
  PRInt32 id = gNameSpaceId_Unknown;
  PRBool isHTML = nsnull;
  PRBool isHTML = PR_FALSE;
  PRBool popContent = PR_TRUE;


  // XXX Hopefully the parser will flag this before we get
  // XXX Hopefully the parser will flag this before we get
  // here. If we're in the prolog or epilog, there should be
  // here. If we're in the prolog or epilog, there should be
@@ -571,19 +581,24 @@ nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
    FlushText();
    FlushText();
  }
  }


  nsIContent* content = PopContent();
  if (nsnull != content) {
    PRInt32 nestLevel = GetCurrentNestLevel();

  if (isHTML) {
  if (isHTML) {
    tag.ToUpperCase();
    tag.ToUpperCase();
    nsIAtom* tagAtom = NS_NewAtom(tag);
    nsIAtom* tagAtom = NS_NewAtom(tag);
    if (nsHTMLAtoms::script == tagAtom) {
    if (nsHTMLAtoms::script == tagAtom) {
      result = ProcessEndSCRIPTTag(aNode);
      result = ProcessEndSCRIPTTag(aNode);
    }
    }
    // XXX Form content was never pushed on the stack
    else if (nsHTMLAtoms::form == tagAtom) {
      popContent = PR_FALSE;
    }
    NS_RELEASE(tagAtom);
    NS_RELEASE(tagAtom);
  }
  }


  if (popContent) {
    nsIContent* content = PopContent();
    if (nsnull != content) {
      PRInt32 nestLevel = GetCurrentNestLevel();
      
      CloseNameSpacesAtNestLevel(nestLevel);
      CloseNameSpacesAtNestLevel(nestLevel);
      
      
      if (mDocElement == content) {
      if (mDocElement == content) {
@@ -596,6 +611,7 @@ nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
      // we should never get here.
      // we should never get here.
      PR_ASSERT(0);
      PR_ASSERT(0);
    }
    }
  }


  return result;
  return result;
}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -265,6 +265,9 @@ NS_IMETHODIMP
nsXMLDocument::CreateElement(const nsString& aTagName, 
nsXMLDocument::CreateElement(const nsString& aTagName, 
                              nsIDOMElement** aReturn)
                              nsIDOMElement** aReturn)
{
{
  // XXX Should actually check parse namespace, determine
  // current namespace scope and, potentially, create new
  // HTML content form tags with a HTML prefix.
  nsIXMLContent* content;
  nsIXMLContent* content;
  nsIAtom* tag = NS_NewAtom(aTagName);
  nsIAtom* tag = NS_NewAtom(aTagName);
  nsresult rv = NS_NewXMLElement(&content, tag);
  nsresult rv = NS_NewXMLElement(&content, tag);
+3 −1
Original line number Original line Diff line number Diff line
@@ -538,10 +538,12 @@ MakeContentObject(nsHTMLTag aNodeType,
    break;
    break;
  case eHTMLTag_form:
  case eHTMLTag_form:
    // the form was already created 
    // the form was already created 
    *aResult = nsnull;
    if (aForm) {
    if (aForm) {
      rv = aForm->QueryInterface(kIHTMLContentIID, (void**)aResult);
      rv = aForm->QueryInterface(kIHTMLContentIID, (void**)aResult);
    }
    }
    else {
      rv = NS_NewHTMLFormElement(aResult, aAtom);
    }
    break;
    break;
  case eHTMLTag_frame:
  case eHTMLTag_frame:
    rv = NS_NewHTMLFrameElement(aResult, aAtom);
    rv = NS_NewHTMLFrameElement(aResult, aAtom);
+40 −24
Original line number Original line Diff line number Diff line
@@ -455,7 +455,8 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
  nsAutoString tag, nameSpace;
  nsAutoString tag, nameSpace;
  PRInt32 nsoffset;
  PRInt32 nsoffset;
  PRInt32 id = gNameSpaceId_Unknown;
  PRInt32 id = gNameSpaceId_Unknown;
  PRBool isHTML = nsnull;
  PRBool isHTML = PR_FALSE;
  PRBool pushContent = PR_TRUE;
  nsIContent *content;
  nsIContent *content;


  // XXX Hopefully the parser will flag this before we get
  // XXX Hopefully the parser will flag this before we get
@@ -494,7 +495,13 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
    if (nsHTMLAtoms::script == tagAtom) {
    if (nsHTMLAtoms::script == tagAtom) {
      result = ProcessStartSCRIPTTag(aNode);
      result = ProcessStartSCRIPTTag(aNode);
    }
    }
    // XXX Treat the form elements as a leaf element (even if it is a
    // container). Need to do further processing with forms
    else if (nsHTMLAtoms::form == tagAtom) {
      pushContent = PR_FALSE;
    }
    NS_RELEASE(tagAtom);
    NS_RELEASE(tagAtom);

    nsIHTMLContent *htmlContent = nsnull;
    nsIHTMLContent *htmlContent = nsnull;
    result = NS_CreateHTMLElement(&htmlContent, tag);
    result = NS_CreateHTMLElement(&htmlContent, tag);
    content = (nsIContent *)htmlContent;
    content = (nsIContent *)htmlContent;
@@ -533,9 +540,11 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)


        parent->AppendChildTo(content, PR_FALSE);
        parent->AppendChildTo(content, PR_FALSE);
      }
      }
      if (pushContent) {
        PushContent(content);
        PushContent(content);
      }
      }
    }
    }
  }


  return result;
  return result;
}
}
@@ -547,7 +556,8 @@ nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
  nsAutoString tag, nameSpace;
  nsAutoString tag, nameSpace;
  PRInt32 nsoffset;
  PRInt32 nsoffset;
  PRInt32 id = gNameSpaceId_Unknown;
  PRInt32 id = gNameSpaceId_Unknown;
  PRBool isHTML = nsnull;
  PRBool isHTML = PR_FALSE;
  PRBool popContent = PR_TRUE;


  // XXX Hopefully the parser will flag this before we get
  // XXX Hopefully the parser will flag this before we get
  // here. If we're in the prolog or epilog, there should be
  // here. If we're in the prolog or epilog, there should be
@@ -571,19 +581,24 @@ nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
    FlushText();
    FlushText();
  }
  }


  nsIContent* content = PopContent();
  if (nsnull != content) {
    PRInt32 nestLevel = GetCurrentNestLevel();

  if (isHTML) {
  if (isHTML) {
    tag.ToUpperCase();
    tag.ToUpperCase();
    nsIAtom* tagAtom = NS_NewAtom(tag);
    nsIAtom* tagAtom = NS_NewAtom(tag);
    if (nsHTMLAtoms::script == tagAtom) {
    if (nsHTMLAtoms::script == tagAtom) {
      result = ProcessEndSCRIPTTag(aNode);
      result = ProcessEndSCRIPTTag(aNode);
    }
    }
    // XXX Form content was never pushed on the stack
    else if (nsHTMLAtoms::form == tagAtom) {
      popContent = PR_FALSE;
    }
    NS_RELEASE(tagAtom);
    NS_RELEASE(tagAtom);
  }
  }


  if (popContent) {
    nsIContent* content = PopContent();
    if (nsnull != content) {
      PRInt32 nestLevel = GetCurrentNestLevel();
      
      CloseNameSpacesAtNestLevel(nestLevel);
      CloseNameSpacesAtNestLevel(nestLevel);
      
      
      if (mDocElement == content) {
      if (mDocElement == content) {
@@ -596,6 +611,7 @@ nsXMLContentSink::CloseContainer(const nsIParserNode& aNode)
      // we should never get here.
      // we should never get here.
      PR_ASSERT(0);
      PR_ASSERT(0);
    }
    }
  }


  return result;
  return result;
}
}
Loading