Line data Source code
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/. */
6 :
7 : #include "nsXMLElement.h"
8 : #include "mozilla/dom/ElementBinding.h"
9 : #include "mozilla/dom/ElementInlines.h"
10 : #include "nsContentUtils.h" // nsAutoScriptBlocker
11 :
12 : using namespace mozilla;
13 : using namespace mozilla::dom;
14 :
15 : nsresult
16 257 : NS_NewXMLElement(Element** aInstancePtrResult,
17 : already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
18 : {
19 257 : nsXMLElement* it = new nsXMLElement(aNodeInfo);
20 257 : NS_ADDREF(*aInstancePtrResult = it);
21 257 : return NS_OK;
22 : }
23 :
24 8986 : NS_IMPL_ISUPPORTS_INHERITED(nsXMLElement, Element,
25 : nsIDOMNode, nsIDOMElement)
26 :
27 : JSObject*
28 0 : nsXMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
29 : {
30 0 : return ElementBinding::Wrap(aCx, this, aGivenProto);
31 : }
32 :
33 : void
34 186 : nsXMLElement::UnbindFromTree(bool aDeep, bool aNullParent)
35 : {
36 186 : CSSPseudoElementType pseudoType = GetPseudoElementType();
37 186 : bool isBefore = pseudoType == CSSPseudoElementType::before;
38 : nsIAtom* property = isBefore
39 186 : ? nsGkAtoms::beforePseudoProperty : nsGkAtoms::afterPseudoProperty;
40 :
41 186 : switch (pseudoType) {
42 : case CSSPseudoElementType::before:
43 : case CSSPseudoElementType::after: {
44 0 : MOZ_ASSERT(GetParent());
45 0 : MOZ_ASSERT(GetParent()->IsElement());
46 0 : GetParent()->DeleteProperty(property);
47 0 : break;
48 : }
49 : default:
50 186 : break;
51 : }
52 186 : Element::UnbindFromTree(aDeep, aNullParent);
53 186 : }
54 :
55 302 : NS_IMPL_ELEMENT_CLONE(nsXMLElement)
|