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