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 "nsMappedAttributeElement.h"
17 class EventChainPostVisitor
;
18 class EventChainPreVisitor
;
21 typedef nsMappedAttributeElement MathMLElementBase
;
24 * The base class for MathML elements.
26 class MathMLElement final
: public MathMLElementBase
,
27 public mozilla::dom::Link
{
29 explicit MathMLElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
);
30 explicit MathMLElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
32 // Implementation of nsISupports is inherited from MathMLElementBase
33 NS_DECL_ISUPPORTS_INHERITED
35 NS_IMPL_FROMNODE(MathMLElement
, kNameSpaceID_MathML
)
37 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
38 virtual void UnbindFromTree(bool aNullParent
= true) override
;
40 virtual bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
41 const nsAString
& aValue
,
42 nsIPrincipal
* aMaybeScriptedPrincipal
,
43 nsAttrValue
& aResult
) override
;
45 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
46 virtual nsMapRuleToAttributesFunc
GetAttributeMappingFunction()
50 PARSE_ALLOW_UNITLESS
= 0x01, // unitless 0 will be turned into 0px
51 PARSE_ALLOW_NEGATIVE
= 0x02,
52 PARSE_SUPPRESS_WARNINGS
= 0x04,
53 CONVERT_UNITLESS_TO_PERCENT
= 0x08
55 static bool ParseNamedSpaceValue(const nsString
& aString
,
56 nsCSSValue
& aCSSValue
, uint32_t aFlags
,
57 const Document
& aDocument
);
59 static bool ParseNumericValue(const nsString
& aString
, nsCSSValue
& aCSSValue
,
60 uint32_t aFlags
, Document
* aDocument
);
62 static void MapMathMLAttributesInto(const nsMappedAttributes
* aAttributes
,
63 mozilla::MappedDeclarations
&);
65 void GetEventTargetParent(mozilla::EventChainPreVisitor
& aVisitor
) override
;
67 nsresult
PostHandleEvent(mozilla::EventChainPostVisitor
& aVisitor
) override
;
68 nsresult
Clone(mozilla::dom::NodeInfo
*, nsINode
** aResult
) const override
;
69 virtual mozilla::EventStates
IntrinsicState() const override
;
70 virtual bool IsNodeOfType(uint32_t aFlags
) const override
;
72 // Set during reflow as necessary. Does a style change notification,
73 // aNotify must be true.
74 void SetIncrementScriptLevel(bool aIncrementScriptLevel
, bool aNotify
);
75 bool GetIncrementScriptLevel() const { return mIncrementScriptLevel
; }
77 int32_t TabIndexDefault() final
;
78 virtual bool IsFocusableInternal(int32_t* aTabIndex
,
79 bool aWithMouse
) override
;
80 virtual bool IsLink(nsIURI
** aURI
) const override
;
81 virtual void GetLinkTarget(nsAString
& aTarget
) override
;
82 virtual already_AddRefed
<nsIURI
> GetHrefURI() const override
;
84 virtual void NodeInfoChanged(Document
* aOldDoc
) override
{
85 ClearHasPendingLinkUpdate();
86 MathMLElementBase::NodeInfoChanged(aOldDoc
);
89 void RecompileScriptEventListeners() final
;
90 bool IsEventAttributeNameInternal(nsAtom
* aName
) final
;
93 virtual ~MathMLElement() = default;
95 virtual JSObject
* WrapNode(JSContext
* aCx
,
96 JS::Handle
<JSObject
*> aGivenProto
) override
;
98 nsresult
BeforeSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
99 const nsAttrValueOrString
* aValue
, bool aNotify
) final
;
100 virtual nsresult
AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
101 const nsAttrValue
* aValue
,
102 const nsAttrValue
* aOldValue
,
103 nsIPrincipal
* aSubjectPrincipal
,
104 bool aNotify
) override
;
107 bool mIncrementScriptLevel
;
111 } // namespace mozilla
113 #endif // mozilla_dom_MathMLElement_h_