summaryrefslogtreecommitdiffstats
path: root/dom/html/HTMLSlotElement.cpp
blob: 9f24f8ba3eaaac19ac30539e11f5759e2af6733c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* -*- 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
 * 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/. */

#include "mozilla/dom/HTMLSlotElement.h"
#include "mozilla/dom/HTMLSlotElementBinding.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "nsGkAtoms.h"
#include "nsDocument.h"

nsGenericHTMLElement*
NS_NewHTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                      mozilla::dom::FromParser aFromParser)
{
  RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
  /* Disabled for now
  if (nsDocument::IsWebComponentsEnabled(nodeInfo)) {
    already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
    return new mozilla::dom::HTMLSlotElement(nodeInfoArg);
  }
  */

  already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
  return new mozilla::dom::HTMLUnknownElement(nodeInfoArg);
}

namespace mozilla {
namespace dom {

HTMLSlotElement::HTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  : nsGenericHTMLElement(aNodeInfo)
{
}

HTMLSlotElement::~HTMLSlotElement()
{
}

NS_IMPL_ADDREF_INHERITED(HTMLSlotElement, nsGenericHTMLElement)
NS_IMPL_RELEASE_INHERITED(HTMLSlotElement, nsGenericHTMLElement)

NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLSlotElement,
                                   nsGenericHTMLElement,
                                   mAssignedNodes)

NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLSlotElement)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)

NS_IMPL_ELEMENT_CLONE(HTMLSlotElement)

void
HTMLSlotElement::AssignedNodes(const AssignedNodesOptions& aOptions,
                               nsTArray<RefPtr<nsINode>>& aNodes)
{
  aNodes = mAssignedNodes;
}

JSObject*
HTMLSlotElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
  return HTMLSlotElementBinding::Wrap(aCx, this, aGivenProto);
}

} // namespace dom
} // namespace mozilla