2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2001-10-20 01:00:02 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
2013-01-09 00:45:06 +04:00
|
|
|
#include "mozilla/dom/ProcessingInstruction.h"
|
2013-01-09 00:45:06 +04:00
|
|
|
#include "mozilla/dom/ProcessingInstructionBinding.h"
|
2013-04-04 16:01:11 +04:00
|
|
|
#include "mozilla/dom/XMLStylesheetProcessingInstruction.h"
|
2014-03-28 00:38:33 +04:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2012-02-27 15:57:48 +04:00
|
|
|
#include "nsContentUtils.h"
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2013-04-04 16:01:11 +04:00
|
|
|
already_AddRefed<mozilla::dom::ProcessingInstruction>
|
|
|
|
NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
|
2002-03-24 01:46:13 +03:00
|
|
|
const nsAString& aTarget,
|
2005-09-24 22:43:15 +04:00
|
|
|
const nsAString& aData)
|
1999-04-01 00:49:25 +04:00
|
|
|
{
|
2013-01-09 00:45:06 +04:00
|
|
|
using mozilla::dom::ProcessingInstruction;
|
2013-04-04 16:01:11 +04:00
|
|
|
using mozilla::dom::XMLStylesheetProcessingInstruction;
|
2013-01-09 00:45:06 +04:00
|
|
|
|
2005-09-24 22:43:15 +04:00
|
|
|
NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager");
|
|
|
|
|
2011-06-14 11:56:49 +04:00
|
|
|
nsCOMPtr<nsIAtom> target = do_GetAtom(aTarget);
|
2013-04-04 16:01:11 +04:00
|
|
|
MOZ_ASSERT(target);
|
2011-06-14 11:56:49 +04:00
|
|
|
|
|
|
|
if (target == nsGkAtoms::xml_stylesheet) {
|
2013-04-04 16:01:11 +04:00
|
|
|
nsRefPtr<XMLStylesheetProcessingInstruction> pi =
|
|
|
|
new XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
|
|
|
|
return pi.forget();
|
2002-09-04 10:57:25 +04:00
|
|
|
}
|
2001-12-16 09:59:31 +03:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> ni;
|
2008-09-13 02:32:18 +04:00
|
|
|
ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::processingInstructionTagName,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr, kNameSpaceID_None,
|
2011-06-14 11:56:49 +04:00
|
|
|
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
|
|
|
target);
|
2005-09-24 22:43:15 +04:00
|
|
|
|
2013-04-04 16:01:11 +04:00
|
|
|
nsRefPtr<ProcessingInstruction> instance =
|
2013-01-09 00:45:06 +04:00
|
|
|
new ProcessingInstruction(ni.forget(), aData);
|
2004-08-10 14:22:36 +04:00
|
|
|
|
2013-04-04 16:01:11 +04:00
|
|
|
return instance.forget();
|
1999-04-01 00:49:25 +04:00
|
|
|
}
|
|
|
|
|
2013-01-09 00:45:06 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
ProcessingInstruction::ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-01-09 00:45:06 +04:00
|
|
|
const nsAString& aData)
|
2014-03-15 23:00:17 +04:00
|
|
|
: nsGenericDOMDataNode(Move(aNodeInfo))
|
1999-04-01 00:49:25 +04:00
|
|
|
{
|
2015-02-07 02:04:32 +03:00
|
|
|
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
|
|
|
|
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
|
|
|
"Bad NodeType in aNodeInfo");
|
2011-06-14 11:56:49 +04:00
|
|
|
|
2008-03-05 10:14:42 +03:00
|
|
|
SetTextInternal(0, mText.GetLength(),
|
|
|
|
aData.BeginReading(), aData.Length(),
|
2011-10-17 18:59:28 +04:00
|
|
|
false); // Don't notify (bug 420429).
|
1999-04-01 00:49:25 +04:00
|
|
|
}
|
|
|
|
|
2013-01-09 00:45:06 +04:00
|
|
|
ProcessingInstruction::~ProcessingInstruction()
|
1999-04-01 00:49:25 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(ProcessingInstruction, nsGenericDOMDataNode,
|
|
|
|
nsIDOMNode, nsIDOMCharacterData,
|
|
|
|
nsIDOMProcessingInstruction)
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2013-01-09 00:45:06 +04:00
|
|
|
JSObject*
|
2014-04-09 02:27:17 +04:00
|
|
|
ProcessingInstruction::WrapNode(JSContext *aCx)
|
2013-01-09 00:45:06 +04:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-09 02:27:17 +04:00
|
|
|
return ProcessingInstructionBinding::Wrap(aCx, this);
|
2013-01-09 00:45:06 +04:00
|
|
|
}
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2000-05-14 06:11:44 +04:00
|
|
|
NS_IMETHODIMP
|
2013-01-09 00:45:06 +04:00
|
|
|
ProcessingInstruction::GetTarget(nsAString& aTarget)
|
1999-04-01 00:49:25 +04:00
|
|
|
{
|
2011-06-14 11:56:49 +04:00
|
|
|
aTarget = NodeName();
|
1999-04-01 00:49:25 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-09 00:45:06 +04:00
|
|
|
ProcessingInstruction::GetAttrValue(nsIAtom *aName, nsAString& aValue)
|
2000-05-14 06:11:44 +04:00
|
|
|
{
|
|
|
|
nsAutoString data;
|
|
|
|
|
2001-12-16 09:59:31 +03:00
|
|
|
GetData(data);
|
2012-02-27 15:57:48 +04:00
|
|
|
return nsContentUtils::GetPseudoAttributeValue(data, aName, aValue);
|
2000-05-14 06:11:44 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-09 00:45:06 +04:00
|
|
|
ProcessingInstruction::IsNodeOfType(uint32_t aFlags) const
|
2003-08-01 15:44:17 +04:00
|
|
|
{
|
2006-07-19 08:36:36 +04:00
|
|
|
return !(aFlags & ~(eCONTENT | ePROCESSING_INSTRUCTION | eDATA_NODE));
|
2003-08-01 15:44:17 +04:00
|
|
|
}
|
|
|
|
|
2005-09-11 21:15:08 +04:00
|
|
|
nsGenericDOMDataNode*
|
2014-06-20 06:01:40 +04:00
|
|
|
ProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
2013-01-09 00:45:06 +04:00
|
|
|
bool aCloneText) const
|
1999-04-01 00:49:25 +04:00
|
|
|
{
|
2001-12-16 09:59:31 +03:00
|
|
|
nsAutoString data;
|
2005-09-12 11:34:25 +04:00
|
|
|
nsGenericDOMDataNode::GetData(data);
|
2014-06-20 06:01:40 +04:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
2013-01-09 00:45:06 +04:00
|
|
|
return new ProcessingInstruction(ni.forget(), data);
|
2004-05-08 00:55:17 +04:00
|
|
|
}
|
|
|
|
|
2001-12-16 09:59:31 +03:00
|
|
|
#ifdef DEBUG
|
2004-01-10 02:54:21 +03:00
|
|
|
void
|
2013-01-09 00:45:06 +04:00
|
|
|
ProcessingInstruction::List(FILE* out, int32_t aIndent) const
|
1999-04-01 00:49:25 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index;
|
1999-04-01 00:49:25 +04:00
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
2014-03-28 00:38:33 +04:00
|
|
|
fprintf(out, "Processing instruction refcount=%" PRIuPTR "<", mRefCnt.get());
|
1999-04-01 00:49:25 +04:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
2001-12-16 09:59:31 +03:00
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
2011-06-14 11:56:49 +04:00
|
|
|
tmp.Insert(nsDependentAtomString(NodeInfo()->GetExtraName()).get(), 0);
|
2006-02-03 17:18:39 +03:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
1999-04-01 00:49:25 +04:00
|
|
|
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
void
|
2013-01-09 00:45:06 +04:00
|
|
|
ProcessingInstruction::DumpContent(FILE* out, int32_t aIndent,
|
|
|
|
bool aDumpAll) const
|
2004-01-10 02:54:21 +03:00
|
|
|
{
|
2000-05-26 23:45:54 +04:00
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2013-01-09 00:45:06 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|