/src/mozilla-central/dom/html/HTMLElement.cpp
Line | Count | Source (jump to first uncovered line) |
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 "nsGenericHTMLElement.h" |
8 | | #include "mozilla/dom/HTMLElementBinding.h" |
9 | | #include "nsContentUtils.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace dom { |
13 | | |
14 | | class HTMLElement final : public nsGenericHTMLElement |
15 | | { |
16 | | public: |
17 | | explicit HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); |
18 | | virtual ~HTMLElement(); |
19 | | |
20 | | nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; |
21 | | |
22 | | protected: |
23 | | JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override; |
24 | | }; |
25 | | |
26 | | HTMLElement::HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) |
27 | | : nsGenericHTMLElement(std::move(aNodeInfo)) |
28 | 0 | { |
29 | 0 | if (NodeInfo()->Equals(nsGkAtoms::bdi)) { |
30 | 0 | AddStatesSilently(NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO); |
31 | 0 | } |
32 | 0 | } |
33 | | |
34 | | HTMLElement::~HTMLElement() |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | NS_IMPL_ELEMENT_CLONE(HTMLElement) |
39 | | |
40 | | JSObject* |
41 | | HTMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) |
42 | 0 | { |
43 | 0 | return dom::HTMLElement_Binding::Wrap(aCx, this, aGivenProto); |
44 | 0 | } |
45 | | |
46 | | } // namespace dom |
47 | | } // namespace mozilla |
48 | | |
49 | | // Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand. |
50 | | // (Calling the macro directly (with no args) produces compiler warnings.) |
51 | | nsGenericHTMLElement* |
52 | | NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, |
53 | | mozilla::dom::FromParser aFromParser) |
54 | 0 | { |
55 | 0 | return new mozilla::dom::HTMLElement(std::move(aNodeInfo)); |
56 | 0 | } |
57 | | |
58 | | // Distinct from the above in order to have function pointer that compared unequal |
59 | | // to a function pointer to the above. |
60 | | nsGenericHTMLElement* |
61 | | NS_NewCustomElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, |
62 | | mozilla::dom::FromParser aFromParser) |
63 | 0 | { |
64 | 0 | return new mozilla::dom::HTMLElement(std::move(aNodeInfo)); |
65 | 0 | } |