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 /**
8  * nsMappedAttributeElement is the base for elements supporting style mapped
9  * attributes via nsMappedAttributes (HTML and MathML).
10  */
11 
12 #ifndef NS_MAPPEDATTRIBUTEELEMENT_H_
13 #define NS_MAPPEDATTRIBUTEELEMENT_H_
14 
15 #include "mozilla/Attributes.h"
16 #include "mozilla/GenericSpecifiedValues.h"
17 #include "nsStyledElement.h"
18 
19 class nsMappedAttributes;
20 struct nsRuleData;
21 
22 typedef void (*nsMapRuleToAttributesFunc)(
23     const nsMappedAttributes* aAttributes,
24     mozilla::GenericSpecifiedValues* aData);
25 
26 typedef nsStyledElement nsMappedAttributeElementBase;
27 
28 class nsMappedAttributeElement : public nsMappedAttributeElementBase {
29  protected:
nsMappedAttributeElement(already_AddRefed<mozilla::dom::NodeInfo> & aNodeInfo)30   explicit nsMappedAttributeElement(
31       already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
32       : nsMappedAttributeElementBase(aNodeInfo) {}
33 
34  public:
35   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
36 
37   static void MapNoAttributesInto(
38       const nsMappedAttributes* aAttributes,
39       mozilla::GenericSpecifiedValues* aGenericData);
40 
41 #ifdef MOZ_OLD_STYLE
42   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) override;
43 #endif
44   virtual bool SetAndSwapMappedAttribute(nsAtom* aName, nsAttrValue& aValue,
45                                          bool* aValueWasSet,
46                                          nsresult* aRetval) override;
47 
48   virtual void NodeInfoChanged(nsIDocument* aOldDoc) override;
49 };
50 
51 #endif  // NS_MAPPEDATTRIBUTEELEMENT_H_
52