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
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's nsIDOMDocumentFragment.
|
|
|
|
*/
|
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
#include "mozilla/dom/DocumentFragment.h"
|
2012-11-14 14:10:08 -08:00
|
|
|
#include "mozilla/dom/Element.h" // for DOMCI_NODE_DATA
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsNodeInfoManager.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsDOMString.h"
|
2012-05-18 01:29:38 -07:00
|
|
|
#include "nsContentUtils.h"
|
2012-12-24 19:35:19 -08:00
|
|
|
#include "mozilla/dom/DocumentFragmentBinding.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2012-12-24 19:35:19 -08:00
|
|
|
JSObject*
|
2013-04-25 09:29:54 -07:00
|
|
|
DocumentFragment::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
2012-12-24 19:35:19 -08:00
|
|
|
{
|
2013-03-11 16:03:47 -07:00
|
|
|
return DocumentFragmentBinding::Wrap(aCx, aScope, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-11-14 10:05:41 -08:00
|
|
|
DocumentFragment::IsNodeOfType(uint32_t aFlags) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT));
|
|
|
|
}
|
|
|
|
|
2010-06-03 18:09:20 -07:00
|
|
|
nsIAtom*
|
2012-11-14 10:05:41 -08:00
|
|
|
DocumentFragment::DoGetID() const
|
2010-06-03 18:09:20 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-06-03 18:09:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
2012-11-14 10:05:41 -08:00
|
|
|
DocumentFragment::GetIDAttributeName() const
|
2010-06-03 18:09:20 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-06-03 18:09:20 -07:00
|
|
|
}
|
|
|
|
|
2012-07-02 06:31:49 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2012-11-14 10:05:41 -08:00
|
|
|
DocumentFragment::List(FILE* out, int32_t aIndent) const
|
2012-07-02 06:31:49 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t indent;
|
2012-07-02 06:31:49 -07:00
|
|
|
for (indent = aIndent; --indent >= 0; ) {
|
|
|
|
fputs(" ", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(out, "DocumentFragment@%p", (void *)this);
|
|
|
|
|
|
|
|
fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
|
|
|
|
fprintf(out, " refcount=%d<", mRefCnt.get());
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-11-14 10:05:41 -08:00
|
|
|
DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
|
|
|
|
bool aDumpAll) const
|
2012-07-02 06:31:49 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t indent;
|
2012-07-02 06:31:49 -07: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 08:56:38 -07:00
|
|
|
int32_t indent = aIndent ? aIndent + 1 : 0;
|
2012-07-02 06:31:49 -07:00
|
|
|
child->DumpContent(out, indent, aDumpAll);
|
|
|
|
}
|
|
|
|
for (indent = aIndent; --indent >= 0; ) {
|
|
|
|
fputs(" ", out);
|
|
|
|
}
|
|
|
|
fputs("</DocumentFragment>", out);
|
|
|
|
|
|
|
|
if(aIndent) {
|
|
|
|
fputs("\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
// QueryInterface implementation for DocumentFragment
|
|
|
|
NS_INTERFACE_MAP_BEGIN(DocumentFragment)
|
2012-05-18 01:29:38 -07:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2012-11-14 10:05:41 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(DocumentFragment)
|
2012-05-18 01:29:38 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsINode)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentFragment)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
2013-01-29 05:44:01 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
|
2012-05-18 01:29:38 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
|
|
|
|
new nsNodeSupportsWeakRefTearoff(this))
|
|
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNodeSelector,
|
|
|
|
new nsNodeSelectorTearoff(this))
|
|
|
|
// nsNodeSH::PreCreate() depends on the identity pointer being the
|
|
|
|
// same as nsINode (which nsIContent inherits), so if you change the
|
|
|
|
// below line, make sure nsNodeSH::PreCreate() still does the right
|
|
|
|
// thing!
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
|
|
|
NS_INTERFACE_MAP_END
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(DocumentFragment, FragmentOrElement)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(DocumentFragment, FragmentOrElement)
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE(DocumentFragment)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-14 10:05:41 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|