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"
|
2020-05-21 06:07:16 +03:00
|
|
|
#include "mozilla/dom/LinkStyle.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) {
|
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
|
|
|
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aNodeInfoManager, "Missing nodeinfo manager");
|
2005-09-24 22:43:15 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> 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) {
|
2020-03-17 17:55:36 +03:00
|
|
|
RefPtr<XMLStylesheetProcessingInstruction> pi = new (aNodeInfoManager)
|
|
|
|
XMLStylesheetProcessingInstruction(aNodeInfoManager, aData);
|
2013-04-04 16:01:11 +04:00
|
|
|
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, nullptr, kNameSpaceID_None,
|
2018-01-30 07:10:53 +03:00
|
|
|
nsINode::PROCESSING_INSTRUCTION_NODE, target);
|
2005-09-24 22:43:15 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ProcessingInstruction> instance =
|
2020-03-17 17:55:36 +03:00
|
|
|
new (aNodeInfoManager) 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
|
|
|
}
|
|
|
|
|
2022-05-09 23:41:21 +03:00
|
|
|
namespace mozilla::dom {
|
2013-01-09 00:45:06 +04:00
|
|
|
|
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)
|
2018-05-30 22:15:35 +03:00
|
|
|
: CharacterData(std::move(aNodeInfo)) {
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(mNodeInfo->NodeType() == nsINode::PROCESSING_INSTRUCTION_NODE,
|
2015-02-10 01:34:50 +03:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2020-03-04 12:10:03 +03:00
|
|
|
ProcessingInstruction::~ProcessingInstruction() = default;
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2020-11-01 18:45:40 +03:00
|
|
|
StyleSheet* ProcessingInstruction::GetSheetForBindings() const {
|
2020-05-21 06:07:16 +03:00
|
|
|
if (const auto* linkStyle = LinkStyle::FromNode(*this)) {
|
2020-11-01 18:45:40 +03:00
|
|
|
return linkStyle->GetSheetForBindings();
|
2020-05-21 06:07:16 +03:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
1999-04-01 00:49:25 +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
|
|
|
JSObject* ProcessingInstruction::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return ProcessingInstruction_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-09 00:45:06 +04:00
|
|
|
}
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
bool ProcessingInstruction::GetAttrValue(nsAtom* 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
|
|
|
}
|
|
|
|
|
2018-03-19 22:50:16 +03:00
|
|
|
already_AddRefed<CharacterData> ProcessingInstruction::CloneDataNode(
|
2014-06-20 06:01:40 +04:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
|
2001-12-16 09:59:31 +03:00
|
|
|
nsAutoString data;
|
2018-03-19 22:18:06 +03:00
|
|
|
GetData(data);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
2020-03-17 17:55:36 +03:00
|
|
|
auto* nim = ni->NodeInfoManager();
|
|
|
|
return do_AddRef(new (nim) ProcessingInstruction(ni.forget(), data));
|
2004-05-08 00:55:17 +04:00
|
|
|
}
|
|
|
|
|
2021-02-23 23:08:13 +03:00
|
|
|
#ifdef MOZ_DOM_LIST
|
2013-01-09 00:45:06 +04:00
|
|
|
void ProcessingInstruction::List(FILE* out, int32_t aIndent) const {
|
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);
|
|
|
|
}
|
|
|
|
|
2013-01-09 00:45:06 +04:00
|
|
|
void ProcessingInstruction::DumpContent(FILE* out, int32_t aIndent,
|
|
|
|
bool aDumpAll) const {}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2013-01-09 00:45:06 +04:00
|
|
|
|
2022-05-09 23:41:21 +03:00
|
|
|
} // namespace mozilla::dom
|