2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-03-31 20:49:25 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-03-31 20:49:25 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-03-31 20:49:25 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 01:32:19 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
#include "nsGenericElement.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
2001-10-19 21:00:02 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
2002-09-04 06:57:25 +00:00
|
|
|
#include "nsXMLProcessingInstruction.h"
|
2002-04-05 11:29:40 +00:00
|
|
|
#include "nsParserUtils.h"
|
2004-06-25 12:26:02 +00:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
2002-03-23 22:46:13 +00:00
|
|
|
const nsAString& aTarget,
|
|
|
|
const nsAString& aData)
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
2004-05-22 22:15:22 +00:00
|
|
|
if (aTarget.EqualsLiteral("xml-stylesheet")) {
|
2002-09-04 06:57:25 +00:00
|
|
|
return NS_NewXMLStylesheetProcessingInstruction(aInstancePtrResult, aData);
|
|
|
|
}
|
2001-12-16 06:59:31 +00:00
|
|
|
*aInstancePtrResult = new nsXMLProcessingInstruction(aTarget, aData);
|
|
|
|
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
NS_ADDREF(*aInstancePtrResult);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
2002-03-23 22:46:13 +00:00
|
|
|
nsXMLProcessingInstruction::nsXMLProcessingInstruction(const nsAString& aTarget,
|
|
|
|
const nsAString& aData) :
|
1999-03-31 20:49:25 +00:00
|
|
|
mTarget(aTarget)
|
|
|
|
{
|
2001-12-16 06:59:31 +00:00
|
|
|
nsGenericDOMDataNode::SetData(aData);
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXMLProcessingInstruction::~nsXMLProcessingInstruction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
|
|
|
|
// QueryInterface implementation for nsXMLProcessingInstruction
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsXMLProcessingInstruction)
|
2001-12-16 06:59:31 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMProcessingInstruction)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ProcessingInstruction)
|
2001-12-16 06:59:31 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
|
|
|
|
|
2001-12-16 06:59:31 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsXMLProcessingInstruction, nsGenericDOMDataNode)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsXMLProcessingInstruction, nsGenericDOMDataNode)
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
|
2000-05-14 02:11:44 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 22:46:13 +00:00
|
|
|
nsXMLProcessingInstruction::GetTarget(nsAString& aTarget)
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
2000-08-23 17:27:06 +00:00
|
|
|
aTarget.Assign(mTarget);
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-14 02:11:44 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 22:46:13 +00:00
|
|
|
nsXMLProcessingInstruction::SetData(const nsAString& aData)
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
2002-09-04 06:57:25 +00:00
|
|
|
return SetNodeValue(aData);
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
2000-05-14 02:11:44 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 22:46:13 +00:00
|
|
|
nsXMLProcessingInstruction::GetData(nsAString& aData)
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
2001-12-16 06:59:31 +00:00
|
|
|
return nsGenericDOMDataNode::GetData(aData);
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
2000-05-14 02:11:44 +00:00
|
|
|
PRBool
|
2001-12-16 06:59:31 +00:00
|
|
|
nsXMLProcessingInstruction::GetAttrValue(const nsAString& aAttr,
|
|
|
|
nsAString& aValue)
|
2000-05-14 02:11:44 +00:00
|
|
|
{
|
|
|
|
nsAutoString data;
|
|
|
|
|
2001-12-16 06:59:31 +00:00
|
|
|
GetData(data);
|
2002-04-05 11:29:40 +00:00
|
|
|
return nsParserUtils::GetQuotedAttributeValue(data, aAttr, aValue);
|
2000-05-14 02:11:44 +00:00
|
|
|
}
|
|
|
|
|
2003-11-19 01:20:56 +00:00
|
|
|
nsIAtom *
|
|
|
|
nsXMLProcessingInstruction::Tag() const
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
2003-11-19 01:20:56 +00:00
|
|
|
return nsLayoutAtoms::processingInstructionTagName;
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 23:54:21 +00:00
|
|
|
PRBool
|
|
|
|
nsXMLProcessingInstruction::IsContentOfType(PRUint32 aFlags) const
|
2003-08-01 11:44:17 +00:00
|
|
|
{
|
|
|
|
return !(aFlags & ~ePROCESSING_INSTRUCTION);
|
|
|
|
}
|
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 22:46:13 +00:00
|
|
|
nsXMLProcessingInstruction::GetNodeName(nsAString& aNodeName)
|
1999-03-31 20:49:25 +00:00
|
|
|
{
|
2000-08-23 17:27:06 +00:00
|
|
|
aNodeName.Assign(mTarget);
|
1999-03-31 20:49:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-30 12:24:28 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLProcessingInstruction::GetNodeValue(nsAString& aNodeValue)
|
|
|
|
{
|
|
|
|
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLProcessingInstruction::SetNodeValue(const nsAString& aNodeValue)
|
|
|
|
{
|
|
|
|
return nsGenericDOMDataNode::SetNodeValue(aNodeValue);
|
|
|
|
}
|
|
|
|
|
1999-03-31 20:49:25 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLProcessingInstruction::GetNodeType(PRUint16* aNodeType)
|
|
|
|
{
|
|
|
|
*aNodeType = (PRUint16)nsIDOMNode::PROCESSING_INSTRUCTION_NODE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLProcessingInstruction::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|
|
|
{
|
2001-12-16 06:59:31 +00:00
|
|
|
nsAutoString data;
|
|
|
|
GetData(data);
|
1999-03-31 20:49:25 +00:00
|
|
|
|
2001-12-16 06:59:31 +00:00
|
|
|
*aReturn = new nsXMLProcessingInstruction(mTarget, data);
|
|
|
|
if (!*aReturn) {
|
1999-03-31 20:49:25 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2001-12-16 06:59:31 +00:00
|
|
|
|
|
|
|
NS_ADDREF(*aReturn);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-03-31 20:49:25 +00:00
|
|
|
}
|
|
|
|
|
2004-05-07 20:55:17 +00:00
|
|
|
already_AddRefed<nsITextContent>
|
|
|
|
nsXMLProcessingInstruction::CloneContent(PRBool aCloneText)
|
|
|
|
{
|
|
|
|
NS_ERROR("Huh, this shouldn't be called!");
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2001-12-16 06:59:31 +00:00
|
|
|
#ifdef DEBUG
|
2004-01-09 23:54:21 +00:00
|
|
|
void
|
1999-03-31 20:49:25 +00:00
|
|
|
nsXMLProcessingInstruction::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
2001-12-16 06:59:31 +00:00
|
|
|
NS_PRECONDITION(mDocument, "bad content");
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
PRInt32 index;
|
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
2002-09-30 14:18:27 +00:00
|
|
|
fprintf(out, "Processing instruction refcount=%d<", mRefCnt.get());
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
2001-12-16 06:59:31 +00:00
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
2001-06-30 11:02:25 +00:00
|
|
|
tmp.Insert(mTarget.get(), 0);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out);
|
1999-03-31 20:49:25 +00:00
|
|
|
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
2004-01-09 23:54:21 +00:00
|
|
|
void
|
2001-12-16 06:59:31 +00:00
|
|
|
nsXMLProcessingInstruction::DumpContent(FILE* out, PRInt32 aIndent,
|
2004-01-09 23:54:21 +00:00
|
|
|
PRBool aDumpAll) const
|
|
|
|
{
|
2000-05-26 19:45:54 +00:00
|
|
|
}
|
2001-10-16 05:31:36 +00:00
|
|
|
#endif
|