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/. */
|
1998-11-25 11:14:47 +03:00
|
|
|
|
2006-03-30 12:03:04 +04:00
|
|
|
/*
|
2018-04-18 04:13:03 +03:00
|
|
|
* Implementation of DOM Core's DocumentFragment.
|
2006-03-30 12:03:04 +04:00
|
|
|
*/
|
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
#include "mozilla/dom/DocumentFragment.h"
|
2013-06-26 18:59:45 +04:00
|
|
|
#include "mozilla/dom/Element.h" // for NS_IMPL_ELEMENT_CLONE
|
2014-06-20 06:01:40 +04:00
|
|
|
#include "mozilla/dom/NodeInfo.h"
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2004-04-01 23:44:17 +04:00
|
|
|
#include "nsDOMString.h"
|
2013-08-14 10:56:21 +04:00
|
|
|
#include "nsContentUtils.h" // for NS_INTERFACE_MAP_ENTRY_TEAROFF
|
2012-12-25 07:35:19 +04:00
|
|
|
#include "mozilla/dom/DocumentFragmentBinding.h"
|
2013-10-03 00:09:18 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2014-03-28 00:38:33 +04:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
1999-01-19 06:54:26 +03:00
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
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* DocumentFragment::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return DocumentFragment_Binding::Wrap(aCx, this, aGivenProto);
|
1998-11-25 11:14:47 +03:00
|
|
|
}
|
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
bool DocumentFragment::IsNodeOfType(uint32_t aFlags) const { return false; }
|
1998-11-25 11:14:47 +03:00
|
|
|
|
2012-07-02 17:31:49 +04:00
|
|
|
#ifdef DEBUG
|
2012-11-14 22:05:41 +04:00
|
|
|
void DocumentFragment::List(FILE* out, int32_t aIndent) const {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indent;
|
2012-07-02 17:31:49 +04:00
|
|
|
for (indent = aIndent; --indent >= 0;) {
|
|
|
|
fputs(" ", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(out, "DocumentFragment@%p", (void*)this);
|
|
|
|
|
|
|
|
fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
|
2014-03-28 00:38:33 +04:00
|
|
|
fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());
|
2012-07-02 17:31:49 +04:00
|
|
|
|
|
|
|
nsIContent* child = GetFirstChild();
|
|
|
|
if (child) {
|
|
|
|
fputs("\n", out);
|
|
|
|
|
|
|
|
for (; child; child = child->GetNextSibling()) {
|
|
|
|
child->List(out, aIndent + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (indent = aIndent; --indent >= 0;) {
|
|
|
|
fputs(" ", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
void DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
|
|
|
|
bool aDumpAll) const {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indent;
|
2012-07-02 17:31:49 +04:00
|
|
|
for (indent = aIndent; --indent >= 0;) {
|
|
|
|
fputs(" ", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("<DocumentFragment>", out);
|
|
|
|
|
|
|
|
if (aIndent) {
|
|
|
|
fputs("\n", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (nsIContent* child = GetFirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indent = aIndent ? aIndent + 1 : 0;
|
2012-07-02 17:31:49 +04:00
|
|
|
child->DumpContent(out, indent, aDumpAll);
|
|
|
|
}
|
|
|
|
for (indent = aIndent; --indent >= 0;) {
|
|
|
|
fputs(" ", out);
|
|
|
|
}
|
|
|
|
fputs("</DocumentFragment>", out);
|
|
|
|
|
|
|
|
if (aIndent) {
|
|
|
|
fputs("\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<DocumentFragment> DocumentFragment::Constructor(
|
2013-08-23 09:17:08 +04:00
|
|
|
const GlobalObject& aGlobal, ErrorResult& aRv) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> window =
|
|
|
|
do_QueryInterface(aGlobal.GetAsSupports());
|
2013-05-23 14:59:00 +04:00
|
|
|
if (!window || !window->GetDoc()) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window->GetDoc()->CreateDocumentFragment();
|
|
|
|
}
|
|
|
|
|
2017-09-25 18:09:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(DocumentFragment, FragmentOrElement, mHost)
|
2017-09-06 11:37:17 +03:00
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
// QueryInterface implementation for DocumentFragment
|
|
|
|
NS_INTERFACE_MAP_BEGIN(DocumentFragment)
|
2012-05-18 12:29:38 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2012-11-14 22:05:41 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(DocumentFragment)
|
2012-05-18 12:29:38 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsINode)
|
2013-01-29 17:44:01 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
|
2012-05-18 12:29:38 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
|
|
|
|
new nsNodeSupportsWeakRefTearoff(this))
|
2013-06-26 18:59:45 +04:00
|
|
|
// DOM bindings depend on the identity pointer being the
|
|
|
|
// same as nsINode (which nsIContent inherits).
|
2012-05-18 12:29:38 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
|
|
|
NS_INTERFACE_MAP_END
|
1998-11-25 11:14:47 +03:00
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(DocumentFragment, FragmentOrElement)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(DocumentFragment, FragmentOrElement)
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE(DocumentFragment)
|
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 20:46:42 +04:00
|
|
|
|
2012-11-14 22:05:41 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|