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