2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsUnicharUtils.h"
|
2013-01-08 12:45:06 -08:00
|
|
|
#include "mozilla/dom/ProcessingInstruction.h"
|
2013-01-08 12:45:06 -08:00
|
|
|
#include "mozilla/dom/ProcessingInstructionBinding.h"
|
2013-04-04 05:01:11 -07:00
|
|
|
#include "mozilla/dom/XMLStylesheetProcessingInstruction.h"
|
2014-03-27 13:38:33 -07:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2012-02-27 03:57:48 -08:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-04 05:01:11 -07:00
|
|
|
already_AddRefed<mozilla::dom::ProcessingInstruction>
|
|
|
|
NS_NewXMLProcessingInstruction(nsNodeInfoManager *aNodeInfoManager,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAString& aTarget,
|
|
|
|
const nsAString& aData)
|
|
|
|
{
|
2013-01-08 12:45:06 -08:00
|
|
|
using mozilla::dom::ProcessingInstruction;
|
2013-04-04 05:01:11 -07:00
|
|
|
using mozilla::dom::XMLStylesheetProcessingInstruction;
|
2013-01-08 12:45:06 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager");
|
|
|
|
|
2011-06-14 00:56:49 -07:00
|
|
|
nsCOMPtr<nsIAtom> target = do_GetAtom(aTarget);
|
2013-04-04 05:01:11 -07:00
|
|
|
MOZ_ASSERT(target);
|
2011-06-14 00:56:49 -07:00
|
|
|
|
|
|
|
if (target == nsGkAtoms::xml_stylesheet) {
|
2013-04-04 05:01:11 -07:00
|
|
|
nsRefPtr<XMLStylesheetProcessingInstruction> pi =
|
|
|
|
new XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
|
|
|
|
return pi.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> ni;
|
2008-09-12 15:32:18 -07:00
|
|
|
ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::processingInstructionTagName,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr, kNameSpaceID_None,
|
2011-06-14 00:56:49 -07:00
|
|
|
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
|
|
|
target);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-04 05:01:11 -07:00
|
|
|
nsRefPtr<ProcessingInstruction> instance =
|
2013-01-08 12:45:06 -08:00
|
|
|
new ProcessingInstruction(ni.forget(), aData);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-04 05:01:11 -07:00
|
|
|
return instance.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-08 12:45:06 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
ProcessingInstruction::ProcessingInstruction(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-01-08 12:45:06 -08:00
|
|
|
const nsAString& aData)
|
2014-03-15 12:00:17 -07:00
|
|
|
: nsGenericDOMDataNode(Move(aNodeInfo))
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
|
|
|
"Bad NodeType in aNodeInfo");
|
2011-06-14 00:56:49 -07:00
|
|
|
|
2008-03-04 23:14:42 -08:00
|
|
|
SetTextInternal(0, mText.GetLength(),
|
|
|
|
aData.BeginReading(), aData.Length(),
|
2011-10-17 07:59:28 -07:00
|
|
|
false); // Don't notify (bug 420429).
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-08 12:45:06 -08:00
|
|
|
ProcessingInstruction::~ProcessingInstruction()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(ProcessingInstruction, nsGenericDOMDataNode,
|
|
|
|
nsIDOMNode, nsIDOMCharacterData,
|
|
|
|
nsIDOMProcessingInstruction)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-08 12:45:06 -08:00
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
ProcessingInstruction::WrapNode(JSContext *aCx)
|
2013-01-08 12:45:06 -08: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-08 15:27:17 -07:00
|
|
|
return ProcessingInstructionBinding::Wrap(aCx, this);
|
2013-01-08 12:45:06 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-01-08 12:45:06 -08:00
|
|
|
ProcessingInstruction::GetTarget(nsAString& aTarget)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-14 00:56:49 -07:00
|
|
|
aTarget = NodeName();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-08 12:45:06 -08:00
|
|
|
ProcessingInstruction::GetAttrValue(nsIAtom *aName, nsAString& aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsAutoString data;
|
|
|
|
|
|
|
|
GetData(data);
|
2012-02-27 03:57:48 -08:00
|
|
|
return nsContentUtils::GetPseudoAttributeValue(data, aName, aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-08 12:45:06 -08:00
|
|
|
ProcessingInstruction::IsNodeOfType(uint32_t aFlags) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return !(aFlags & ~(eCONTENT | ePROCESSING_INSTRUCTION | eDATA_NODE));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericDOMDataNode*
|
2014-06-19 19:01:40 -07:00
|
|
|
ProcessingInstruction::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
2013-01-08 12:45:06 -08:00
|
|
|
bool aCloneText) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsAutoString data;
|
|
|
|
nsGenericDOMDataNode::GetData(data);
|
2014-06-19 19:01:40 -07:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
2013-01-08 12:45:06 -08:00
|
|
|
return new ProcessingInstruction(ni.forget(), data);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2013-01-08 12:45:06 -08:00
|
|
|
ProcessingInstruction::List(FILE* out, int32_t aIndent) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t index;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
2014-03-27 13:38:33 -07:00
|
|
|
fprintf(out, "Processing instruction refcount=%" PRIuPTR "<", mRefCnt.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
2011-06-14 00:56:49 -07:00
|
|
|
tmp.Insert(nsDependentAtomString(NodeInfo()->GetExtraName()).get(), 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
|
|
|
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-08 12:45:06 -08:00
|
|
|
ProcessingInstruction::DumpContent(FILE* out, int32_t aIndent,
|
|
|
|
bool aDumpAll) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2013-01-08 12:45:06 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|