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 #ifndef mozilla_dom_MathMLElement_h_
8 #define mozilla_dom_MathMLElement_h_
10 #include "mozilla/Attributes.h"
11 #include "nsStyledElement.h"
17 class EventChainPostVisitor
;
18 class EventChainPreVisitor
;
21 using MathMLElementBase
= nsStyledElement
;
24 * The base class for MathML elements.
26 class MathMLElement final
: public MathMLElementBase
, public Link
{
28 explicit MathMLElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
);
29 explicit MathMLElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
31 // Implementation of nsISupports is inherited from MathMLElementBase
32 NS_DECL_ISUPPORTS_INHERITED
34 NS_IMPL_FROMNODE(MathMLElement
, kNameSpaceID_MathML
)
36 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
37 void UnbindFromTree(UnbindContext
&) override
;
39 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
40 const nsAString
& aValue
,
41 nsIPrincipal
* aMaybeScriptedPrincipal
,
42 nsAttrValue
& aResult
) override
;
44 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
45 nsMapRuleToAttributesFunc
GetAttributeMappingFunction() const override
;
48 PARSE_ALLOW_NEGATIVE
= 0x02,
49 PARSE_SUPPRESS_WARNINGS
= 0x04,
51 static bool ParseNamedSpaceValue(const nsString
& aString
,
52 nsCSSValue
& aCSSValue
, uint32_t aFlags
,
53 const Document
& aDocument
);
55 static bool ParseNumericValue(const nsString
& aString
, nsCSSValue
& aCSSValue
,
56 uint32_t aFlags
, Document
* aDocument
);
58 static void MapGlobalMathMLAttributesInto(
59 mozilla::MappedDeclarationsBuilder
&);
60 static void MapMiAttributesInto(mozilla::MappedDeclarationsBuilder
&);
61 static void MapMTableAttributesInto(mozilla::MappedDeclarationsBuilder
&);
63 void GetEventTargetParent(mozilla::EventChainPreVisitor
& aVisitor
) override
;
65 nsresult
PostHandleEvent(mozilla::EventChainPostVisitor
& aVisitor
) override
;
66 nsresult
Clone(mozilla::dom::NodeInfo
*, nsINode
** aResult
) const override
;
68 // Set during reflow as necessary. Does a style change notification,
69 // aNotify must be true.
70 void SetIncrementScriptLevel(bool aIncrementScriptLevel
, bool aNotify
);
71 bool GetIncrementScriptLevel() const {
72 return Element::State().HasState(ElementState::INCREMENT_SCRIPT_LEVEL
);
75 int32_t TabIndexDefault() final
;
77 Focusable
IsFocusableWithoutStyle(IsFocusableFlags
) override
;
78 already_AddRefed
<nsIURI
> GetHrefURI() const override
;
80 void NodeInfoChanged(Document
* aOldDoc
) override
{
81 ClearHasPendingLinkUpdate();
82 MathMLElementBase::NodeInfoChanged(aOldDoc
);
85 bool IsEventAttributeNameInternal(nsAtom
* aName
) final
;
87 bool Autofocus() const { return GetBoolAttr(nsGkAtoms::autofocus
); }
88 void SetAutofocus(bool aAutofocus
, ErrorResult
& aRv
) {
90 SetAttr(nsGkAtoms::autofocus
, u
""_ns
, aRv
);
92 UnsetAttr(nsGkAtoms::autofocus
, aRv
);
97 virtual ~MathMLElement() = default;
99 JSObject
* WrapNode(JSContext
*, JS::Handle
<JSObject
*> aGivenProto
) override
;
101 void BeforeSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
102 const nsAttrValue
* aValue
, bool aNotify
) final
;
103 void AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
104 const nsAttrValue
* aValue
, const nsAttrValue
* aOldValue
,
105 nsIPrincipal
* aSubjectPrincipal
, bool aNotify
) override
;
109 } // namespace mozilla
111 #endif // mozilla_dom_MathMLElement_h_