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 nsCSSCounterStyleRule_h
8 : #define nsCSSCounterStyleRule_h
9 :
10 : #include "mozilla/css/Rule.h"
11 : #include "nsCSSValue.h"
12 : #include "nsIDOMCSSCounterStyleRule.h"
13 :
14 : class nsCSSCounterStyleRule final : public mozilla::css::Rule,
15 : public nsIDOMCSSCounterStyleRule
16 : {
17 : public:
18 138 : explicit nsCSSCounterStyleRule(nsIAtom* aName,
19 : uint32_t aLineNumber, uint32_t aColumnNumber)
20 138 : : mozilla::css::Rule(aLineNumber, aColumnNumber)
21 : , mName(aName)
22 138 : , mGeneration(0)
23 : {
24 138 : MOZ_ASSERT(aName, "Must have non-null name");
25 138 : }
26 :
27 : private:
28 : nsCSSCounterStyleRule(const nsCSSCounterStyleRule& aCopy);
29 : ~nsCSSCounterStyleRule();
30 :
31 : public:
32 : NS_DECL_ISUPPORTS_INHERITED
33 : virtual bool IsCCLeaf() const override;
34 :
35 : #ifdef DEBUG
36 : virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
37 : #endif
38 : virtual int32_t GetType() const override;
39 : using Rule::GetType;
40 : virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
41 :
42 : // nsIDOMCSSCounterStyleRule
43 : NS_DECL_NSIDOMCSSCOUNTERSTYLERULE
44 :
45 : // WebIDL interface
46 : uint16_t Type() const override;
47 : void GetCssTextImpl(nsAString& aCssText) const override;
48 : // The XPCOM GetName is OK
49 : // The XPCOM SetName is OK
50 : // The XPCOM GetSystem is OK
51 : // The XPCOM SetSystem is OK
52 : // The XPCOM GetSymbols is OK
53 : // The XPCOM SetSymbols is OK
54 : // The XPCOM GetAdditiveSymbols is OK
55 : // The XPCOM SetAdditiveSymbols is OK
56 : // The XPCOM GetNegative is OK
57 : // The XPCOM SetNegative is OK
58 : // The XPCOM GetPrefix is OK
59 : // The XPCOM SetPrefix is OK
60 : // The XPCOM GetSuffix is OK
61 : // The XPCOM SetSuffix is OK
62 : // The XPCOM GetRange is OK
63 : // The XPCOM SetRange is OK
64 : // The XPCOM GetPad is OK
65 : // The XPCOM SetPad is OK
66 : // The XPCOM GetSpeakAs is OK
67 : // The XPCOM SetSpeakAs is OK
68 : // The XPCOM GetFallback is OK
69 : // The XPCOM SetFallback is OK
70 :
71 : // This function is only used to check whether a non-empty value, which has
72 : // been accepted by parser, is valid for the given system and descriptor.
73 : static bool CheckDescValue(int32_t aSystem,
74 : nsCSSCounterDesc aDescID,
75 : const nsCSSValue& aValue);
76 :
77 552 : nsIAtom* Name() const { return mName; }
78 :
79 0 : uint32_t GetGeneration() const { return mGeneration; }
80 :
81 : int32_t GetSystem() const;
82 : const nsCSSValue& GetSystemArgument() const;
83 :
84 336 : const nsCSSValue& GetDesc(nsCSSCounterDesc aDescID) const
85 : {
86 336 : MOZ_ASSERT(aDescID >= 0 && aDescID < eCSSCounterDesc_COUNT,
87 : "descriptor ID out of range");
88 336 : return mValues[aDescID];
89 : }
90 :
91 : void SetDesc(nsCSSCounterDesc aDescID, const nsCSSValue& aValue);
92 :
93 : virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
94 :
95 : virtual JSObject* WrapObject(JSContext* aCx,
96 : JS::Handle<JSObject*> aGivenProto) override;
97 :
98 : private:
99 : typedef decltype(&nsCSSCounterStyleRule::GetSymbols) Getter;
100 : static const Getter kGetters[];
101 :
102 : nsresult GetDescriptor(nsCSSCounterDesc aDescID, nsAString& aValue);
103 : nsresult SetDescriptor(nsCSSCounterDesc aDescID, const nsAString& aValue);
104 :
105 : nsCOMPtr<nsIAtom> mName;
106 : nsCSSValue mValues[eCSSCounterDesc_COUNT];
107 : uint32_t mGeneration;
108 : };
109 :
110 : #endif // nsCSSCounterStyleRule_h
|