Bug 1856777 [wpt PR 42330] - Update wpt metadata, a=testonly
[gecko.git] / dom / xml / nsXMLElement.cpp
blobef51715d1b60e8c4aaaf5a62ccd678a3a90fac6c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsXMLElement.h"
8 #include "mozilla/dom/ElementBinding.h"
9 #include "mozilla/dom/ElementInlines.h"
10 #include "nsContentUtils.h" // nsAutoScriptBlocker
12 using namespace mozilla;
13 using namespace mozilla::dom;
15 nsresult NS_NewXMLElement(
16 Element** aInstancePtrResult,
17 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) {
18 RefPtr<mozilla::dom::NodeInfo> nodeInfo(std::move(aNodeInfo));
19 auto* nim = nodeInfo->NodeInfoManager();
20 RefPtr<nsXMLElement> it = new (nim) nsXMLElement(nodeInfo.forget());
22 it.forget(aInstancePtrResult);
23 return NS_OK;
26 JSObject* nsXMLElement::WrapNode(JSContext* aCx,
27 JS::Handle<JSObject*> aGivenProto) {
28 return Element_Binding::Wrap(aCx, this, aGivenProto);
31 void nsXMLElement::UnbindFromTree(bool aNullParent) {
32 nsAtom* property;
33 switch (GetPseudoElementType()) {
34 case PseudoStyleType::marker:
35 property = nsGkAtoms::markerPseudoProperty;
36 break;
37 case PseudoStyleType::before:
38 property = nsGkAtoms::beforePseudoProperty;
39 break;
40 case PseudoStyleType::after:
41 property = nsGkAtoms::afterPseudoProperty;
42 break;
43 default:
44 property = nullptr;
46 if (property) {
47 MOZ_ASSERT(GetParent());
48 MOZ_ASSERT(GetParent()->IsElement());
49 GetParent()->RemoveProperty(property);
51 Element::UnbindFromTree(aNullParent);
54 NS_IMPL_ELEMENT_CLONE(nsXMLElement)