2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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");
|
|
|
|
|
2016-03-29 02:09:43 +03:00
|
|
|
nsCOMPtr<nsIAtom> target = NS_Atomize(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) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<XMLStylesheetProcessingInstruction> pi =
|
2013-04-04 16:01:11 +04:00
|
|
|
new XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
|
|
|
|
return pi.forget();
|
2002-09-04 10:57:25 +04:00
|
|
|
}
|
2001-12-16 09:59:31 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(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*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
ProcessingInstruction::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-09 00:45:06 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return ProcessingInstructionBinding::Wrap(aCx, this, aGivenProto);
|
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);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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
|