1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsMathMLElement_h
7 #define nsMathMLElement_h
9 #include "mozilla/Attributes.h"
10 #include "mozilla/dom/ElementInlines.h"
11 #include "nsMappedAttributeElement.h"
12 #include "nsIDOMElement.h"
14 #include "mozilla/dom/DOMRect.h"
18 typedef nsMappedAttributeElement nsMathMLElementBase
;
21 class EventChainPostVisitor
;
22 class EventChainPreVisitor
;
23 } // namespace mozilla
26 * The base class for MathML elements.
28 class nsMathMLElement MOZ_FINAL
: public nsMathMLElementBase
,
30 public mozilla::dom::Link
33 explicit nsMathMLElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
);
34 explicit nsMathMLElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
36 // Implementation of nsISupports is inherited from nsMathMLElementBase
37 NS_DECL_ISUPPORTS_INHERITED
39 // Forward implementations of parent interfaces of nsMathMLElement to
41 NS_FORWARD_NSIDOMNODE_TO_NSINODE
42 NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
44 nsresult
BindToTree(nsIDocument
* aDocument
, nsIContent
* aParent
,
45 nsIContent
* aBindingParent
,
46 bool aCompileEventHandlers
) MOZ_OVERRIDE
;
47 virtual void UnbindFromTree(bool aDeep
= true,
48 bool aNullParent
= true) MOZ_OVERRIDE
;
50 virtual bool ParseAttribute(int32_t aNamespaceID
,
52 const nsAString
& aValue
,
53 nsAttrValue
& aResult
) MOZ_OVERRIDE
;
55 NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom
* aAttribute
) const MOZ_OVERRIDE
;
56 virtual nsMapRuleToAttributesFunc
GetAttributeMappingFunction() const MOZ_OVERRIDE
;
59 PARSE_ALLOW_UNITLESS
= 0x01, // unitless 0 will be turned into 0px
60 PARSE_ALLOW_NEGATIVE
= 0x02,
61 PARSE_SUPPRESS_WARNINGS
= 0x04,
62 CONVERT_UNITLESS_TO_PERCENT
= 0x08
64 static bool ParseNamedSpaceValue(const nsString
& aString
,
65 nsCSSValue
& aCSSValue
,
68 static bool ParseNumericValue(const nsString
& aString
,
69 nsCSSValue
& aCSSValue
,
71 nsIDocument
* aDocument
);
73 static void MapMathMLAttributesInto(const nsMappedAttributes
* aAttributes
,
74 nsRuleData
* aRuleData
);
76 virtual nsresult
PreHandleEvent(
77 mozilla::EventChainPreVisitor
& aVisitor
) MOZ_OVERRIDE
;
78 virtual nsresult
PostHandleEvent(
79 mozilla::EventChainPostVisitor
& aVisitor
) MOZ_OVERRIDE
;
80 nsresult
Clone(mozilla::dom::NodeInfo
*, nsINode
**) const MOZ_OVERRIDE
;
81 virtual mozilla::EventStates
IntrinsicState() const MOZ_OVERRIDE
;
82 virtual bool IsNodeOfType(uint32_t aFlags
) const MOZ_OVERRIDE
;
84 // Set during reflow as necessary. Does a style change notification,
85 // aNotify must be true.
86 void SetIncrementScriptLevel(bool aIncrementScriptLevel
, bool aNotify
);
87 bool GetIncrementScriptLevel() const {
88 return mIncrementScriptLevel
;
91 virtual bool IsFocusableInternal(int32_t* aTabIndex
, bool aWithMouse
) MOZ_OVERRIDE
;
92 virtual bool IsLink(nsIURI
** aURI
) const MOZ_OVERRIDE
;
93 virtual void GetLinkTarget(nsAString
& aTarget
) MOZ_OVERRIDE
;
94 virtual already_AddRefed
<nsIURI
> GetHrefURI() const MOZ_OVERRIDE
;
95 nsresult
SetAttr(int32_t aNameSpaceID
, nsIAtom
* aName
,
96 const nsAString
& aValue
, bool aNotify
)
98 return SetAttr(aNameSpaceID
, aName
, nullptr, aValue
, aNotify
);
100 virtual nsresult
SetAttr(int32_t aNameSpaceID
, nsIAtom
* aName
,
101 nsIAtom
* aPrefix
, const nsAString
& aValue
,
102 bool aNotify
) MOZ_OVERRIDE
;
103 virtual nsresult
UnsetAttr(int32_t aNameSpaceID
, nsIAtom
* aAttribute
,
104 bool aNotify
) MOZ_OVERRIDE
;
106 virtual nsIDOMNode
* AsDOMNode() MOZ_OVERRIDE
{ return this; }
109 virtual ~nsMathMLElement() {}
111 virtual JSObject
* WrapNode(JSContext
*aCx
) MOZ_OVERRIDE
;
114 bool mIncrementScriptLevel
;
117 #endif // nsMathMLElement_h