2015-05-03 19:32:37 +00: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: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-11-14 18:05:41 +00:00
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_DocumentFragment_h__
|
|
|
|
#define mozilla_dom_DocumentFragment_h__
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-07-22 21:11:41 +00:00
|
|
|
#include "mozilla/dom/BorrowedAttrInfo.h"
|
2012-11-14 18:05:41 +00:00
|
|
|
#include "mozilla/dom/FragmentOrElement.h"
|
2017-08-16 23:48:52 +00:00
|
|
|
#include "nsStringFwd.h"
|
2012-11-14 18:05:41 +00:00
|
|
|
|
2017-10-02 22:05:19 +00:00
|
|
|
class nsAtom;
|
2012-11-14 18:05:41 +00:00
|
|
|
class nsIContent;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
class Document;
|
2012-11-14 18:05:41 +00:00
|
|
|
class Element;
|
|
|
|
|
2018-05-30 02:58:51 +00:00
|
|
|
class DocumentFragment : public FragmentOrElement {
|
2013-04-10 14:15:54 +00:00
|
|
|
private:
|
|
|
|
void Init() {
|
2018-01-30 04:10:53 +00:00
|
|
|
MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_FRAGMENT_NODE &&
|
2015-02-09 22:34:50 +00:00
|
|
|
mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
|
|
|
|
kNameSpaceID_None),
|
|
|
|
"Bad NodeType in aNodeInfo");
|
2013-04-10 14:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-07-08 12:09:18 +00:00
|
|
|
using FragmentOrElement::GetFirstChild;
|
|
|
|
using nsINode::QuerySelector;
|
|
|
|
using nsINode::QuerySelectorAll;
|
2013-11-01 19:39:25 +00:00
|
|
|
// Make sure bindings can see our superclass' protected GetElementById method.
|
|
|
|
using nsINode::GetElementById;
|
2013-07-08 12:09:18 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2017-09-25 15:09:26 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentFragment, FragmentOrElement)
|
2013-07-08 12:09:18 +00:00
|
|
|
|
2018-09-21 20:45:49 +00:00
|
|
|
explicit DocumentFragment(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: FragmentOrElement(std::move(aNodeInfo)), mHost(nullptr) {
|
2013-04-10 14:15:54 +00:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit DocumentFragment(nsNodeInfoManager* aNodeInfoManager)
|
2013-04-10 14:15:54 +00:00
|
|
|
: FragmentOrElement(aNodeInfoManager->GetNodeInfo(
|
|
|
|
nsGkAtoms::documentFragmentNodeName, nullptr, kNameSpaceID_None,
|
2018-01-30 04:10:53 +00:00
|
|
|
DOCUMENT_FRAGMENT_NODE)),
|
2013-04-10 14:15:54 +00:00
|
|
|
mHost(nullptr) {
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2012-12-25 03:35:19 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
2012-11-14 18:05:41 +00:00
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
|
2018-07-31 18:18:38 +00:00
|
|
|
nsIContent* aBindingParent) override {
|
2012-11-14 18:05:41 +00:00
|
|
|
NS_ASSERTION(false, "Trying to bind a fragment to a tree");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override {
|
2012-11-14 18:05:41 +00:00
|
|
|
NS_ASSERTION(false, "Trying to unbind a fragment from a tree");
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual Element* GetNameSpaceElement() override { return nullptr; }
|
2012-11-14 18:05:41 +00:00
|
|
|
|
2017-09-25 15:09:26 +00:00
|
|
|
Element* GetHost() const { return mHost; }
|
2013-03-26 07:15:23 +00:00
|
|
|
|
2017-09-25 15:09:26 +00:00
|
|
|
void SetHost(Element* aHost) { mHost = aHost; }
|
2013-03-26 07:15:23 +00:00
|
|
|
|
2013-05-23 10:59:00 +00:00
|
|
|
static already_AddRefed<DocumentFragment> Constructor(
|
|
|
|
const GlobalObject& aGlobal, ErrorResult& aRv);
|
|
|
|
|
2012-11-14 18:05:41 +00:00
|
|
|
#ifdef DEBUG
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void List(FILE* out, int32_t aIndent) const override;
|
|
|
|
virtual void DumpContent(FILE* out, int32_t aIndent,
|
|
|
|
bool aDumpAll) const override;
|
2012-11-14 18:05:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2014-07-08 21:23:16 +00:00
|
|
|
virtual ~DocumentFragment() {}
|
|
|
|
|
2018-08-08 23:58:44 +00:00
|
|
|
nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
|
2018-02-18 13:33:14 +00:00
|
|
|
RefPtr<Element> mHost;
|
2012-11-14 18:05:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2018-04-15 10:08:36 +00:00
|
|
|
inline mozilla::dom::DocumentFragment* nsINode::AsDocumentFragment() {
|
|
|
|
MOZ_ASSERT(IsDocumentFragment());
|
|
|
|
return static_cast<mozilla::dom::DocumentFragment*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const mozilla::dom::DocumentFragment* nsINode::AsDocumentFragment()
|
|
|
|
const {
|
|
|
|
MOZ_ASSERT(IsDocumentFragment());
|
|
|
|
return static_cast<const mozilla::dom::DocumentFragment*>(this);
|
|
|
|
}
|
2012-11-14 18:05:41 +00:00
|
|
|
|
|
|
|
#endif // mozilla_dom_DocumentFragment_h__
|