/src/mozilla-central/dom/mathml/nsMathMLElement.h
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 | | #ifndef nsMathMLElement_h |
8 | | #define nsMathMLElement_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "mozilla/dom/Element.h" |
12 | | #include "nsMappedAttributeElement.h" |
13 | | #include "Link.h" |
14 | | #include "mozilla/dom/DOMRect.h" |
15 | | |
16 | | class nsCSSValue; |
17 | | |
18 | | typedef nsMappedAttributeElement nsMathMLElementBase; |
19 | | |
20 | | namespace mozilla { |
21 | | class EventChainPostVisitor; |
22 | | class EventChainPreVisitor; |
23 | | } // namespace mozilla |
24 | | |
25 | | /* |
26 | | * The base class for MathML elements. |
27 | | */ |
28 | | class nsMathMLElement final : public nsMathMLElementBase, |
29 | | public mozilla::dom::Link |
30 | | { |
31 | | public: |
32 | | explicit nsMathMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo); |
33 | | explicit nsMathMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); |
34 | | |
35 | | // Implementation of nsISupports is inherited from nsMathMLElementBase |
36 | | NS_DECL_ISUPPORTS_INHERITED |
37 | | |
38 | | nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
39 | | nsIContent* aBindingParent) override; |
40 | | virtual void UnbindFromTree(bool aDeep = true, |
41 | | bool aNullParent = true) override; |
42 | | |
43 | | virtual bool ParseAttribute(int32_t aNamespaceID, |
44 | | nsAtom* aAttribute, |
45 | | const nsAString& aValue, |
46 | | nsIPrincipal* aMaybeScriptedPrincipal, |
47 | | nsAttrValue& aResult) override; |
48 | | |
49 | | NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; |
50 | | virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override; |
51 | | |
52 | | enum { |
53 | | PARSE_ALLOW_UNITLESS = 0x01, // unitless 0 will be turned into 0px |
54 | | PARSE_ALLOW_NEGATIVE = 0x02, |
55 | | PARSE_SUPPRESS_WARNINGS = 0x04, |
56 | | CONVERT_UNITLESS_TO_PERCENT = 0x08 |
57 | | }; |
58 | | static bool ParseNamedSpaceValue(const nsString& aString, |
59 | | nsCSSValue& aCSSValue, |
60 | | uint32_t aFlags); |
61 | | |
62 | | static bool ParseNumericValue(const nsString& aString, |
63 | | nsCSSValue& aCSSValue, |
64 | | uint32_t aFlags, |
65 | | nsIDocument* aDocument); |
66 | | |
67 | | static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes, |
68 | | mozilla::MappedDeclarations&); |
69 | | |
70 | | void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override; |
71 | | virtual nsresult PostHandleEvent( |
72 | | mozilla::EventChainPostVisitor& aVisitor) override; |
73 | | nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const override; |
74 | | virtual mozilla::EventStates IntrinsicState() const override; |
75 | | virtual bool IsNodeOfType(uint32_t aFlags) const override; |
76 | | |
77 | | // Set during reflow as necessary. Does a style change notification, |
78 | | // aNotify must be true. |
79 | | void SetIncrementScriptLevel(bool aIncrementScriptLevel, bool aNotify); |
80 | 0 | bool GetIncrementScriptLevel() const { |
81 | 0 | return mIncrementScriptLevel; |
82 | 0 | } |
83 | | |
84 | | virtual bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override; |
85 | | virtual bool IsLink(nsIURI** aURI) const override; |
86 | | virtual void GetLinkTarget(nsAString& aTarget) override; |
87 | | virtual already_AddRefed<nsIURI> GetHrefURI() const override; |
88 | | |
89 | | virtual void NodeInfoChanged(nsIDocument* aOldDoc) override |
90 | 0 | { |
91 | 0 | ClearHasPendingLinkUpdate(); |
92 | 0 | nsMathMLElementBase::NodeInfoChanged(aOldDoc); |
93 | 0 | } |
94 | | |
95 | | protected: |
96 | 0 | virtual ~nsMathMLElement() {} |
97 | | |
98 | | virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override; |
99 | | |
100 | | virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, |
101 | | const nsAttrValue* aValue, |
102 | | const nsAttrValue* aOldValue, |
103 | | nsIPrincipal* aSubjectPrincipal, |
104 | | bool aNotify) override; |
105 | | |
106 | | private: |
107 | | bool mIncrementScriptLevel; |
108 | | }; |
109 | | |
110 | | #endif // nsMathMLElement_h |