1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is MathML DOM code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * mozilla.org.
19 : * Portions created by the Initial Developer are Copyright (C) 2007
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Vlad Sukhoy <vladimir.sukhoy@gmail.com> (original developer)
24 : * Daniel Kraft <d@domob.eu> (nsMathMLElement patch, attachment 262925)
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef nsMathMLElement_h
41 : #define nsMathMLElement_h
42 :
43 : #include "nsMappedAttributeElement.h"
44 : #include "nsIDOMElement.h"
45 : #include "nsILink.h"
46 : #include "Link.h"
47 :
48 : class nsCSSValue;
49 :
50 : typedef nsMappedAttributeElement nsMathMLElementBase;
51 :
52 : /*
53 : * The base class for MathML elements.
54 : */
55 : class nsMathMLElement : public nsMathMLElementBase,
56 : public nsIDOMElement,
57 : public nsILink,
58 : public mozilla::dom::Link
59 0 : {
60 : public:
61 0 : nsMathMLElement(already_AddRefed<nsINodeInfo> aNodeInfo)
62 : : nsMathMLElementBase(aNodeInfo), Link(this),
63 0 : mIncrementScriptLevel(false)
64 0 : {}
65 :
66 : // Implementation of nsISupports is inherited from nsMathMLElementBase
67 : NS_DECL_ISUPPORTS_INHERITED
68 :
69 : // Forward implementations of parent interfaces of nsMathMLElement to
70 : // our base class
71 0 : NS_FORWARD_NSIDOMNODE(nsMathMLElementBase::)
72 0 : NS_FORWARD_NSIDOMELEMENT(nsMathMLElementBase::)
73 :
74 : nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
75 : nsIContent* aBindingParent,
76 : bool aCompileEventHandlers);
77 : virtual void UnbindFromTree(bool aDeep = true,
78 : bool aNullParent = true);
79 :
80 : virtual bool ParseAttribute(PRInt32 aNamespaceID,
81 : nsIAtom* aAttribute,
82 : const nsAString& aValue,
83 : nsAttrValue& aResult);
84 :
85 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
86 : virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
87 :
88 : enum {
89 : PARSE_ALLOW_UNITLESS = 0x01, // unitless 0 will be turned into 0px
90 : PARSE_ALLOW_NEGATIVE = 0x02
91 : };
92 : static bool ParseNumericValue(const nsString& aString,
93 : nsCSSValue& aCSSValue,
94 : PRUint32 aFlags);
95 :
96 : static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
97 : nsRuleData* aRuleData);
98 :
99 : virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
100 : virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
101 : nsresult Clone(nsINodeInfo*, nsINode**) const;
102 : virtual nsEventStates IntrinsicState() const;
103 : virtual bool IsNodeOfType(PRUint32 aFlags) const;
104 :
105 : // Set during reflow as necessary. Does a style change notification,
106 : // aNotify must be true.
107 : void SetIncrementScriptLevel(bool aIncrementScriptLevel, bool aNotify);
108 0 : bool GetIncrementScriptLevel() const {
109 0 : return mIncrementScriptLevel;
110 : }
111 :
112 0 : NS_IMETHOD LinkAdded() { return NS_OK; }
113 0 : NS_IMETHOD LinkRemoved() { return NS_OK; }
114 : virtual bool IsFocusable(PRInt32 *aTabIndex = nsnull,
115 : bool aWithMouse = false);
116 : virtual bool IsLink(nsIURI** aURI) const;
117 : virtual void GetLinkTarget(nsAString& aTarget);
118 : virtual nsLinkState GetLinkState() const;
119 : virtual already_AddRefed<nsIURI> GetHrefURI() const;
120 : nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
121 : const nsAString& aValue, bool aNotify)
122 : {
123 : return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
124 : }
125 : virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
126 : nsIAtom* aPrefix, const nsAString& aValue,
127 : bool aNotify);
128 : virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
129 : bool aNotify);
130 :
131 : virtual nsXPCClassInfo* GetClassInfo();
132 : private:
133 : bool mIncrementScriptLevel;
134 : };
135 :
136 : #endif // nsMathMLElement_h
|