Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / layout / style / nsDOMCSSAttrDeclaration.h
blobebae280bf0528b650ee5a26729c3e87036d4121c
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/. */
7 /* DOM object for element.style */
9 #ifndef nsDOMCSSAttributeDeclaration_h
10 #define nsDOMCSSAttributeDeclaration_h
12 #include "mozilla/Attributes.h"
13 #include "mozilla/dom/DocGroup.h"
14 #include "mozilla/ServoTypes.h"
15 #include "nsDOMCSSDeclaration.h"
17 struct RawServoUnlockedDeclarationBlock;
19 namespace mozilla {
21 class SMILValue;
22 class SVGAnimatedLength;
23 class SVGAnimatedPathSegList;
25 namespace dom {
26 class DomGroup;
27 class Element;
28 } // namespace dom
29 } // namespace mozilla
31 class nsDOMCSSAttributeDeclaration final : public nsDOMCSSDeclaration {
32 public:
33 typedef mozilla::dom::Element Element;
34 typedef mozilla::SMILValue SMILValue;
35 typedef mozilla::SVGAnimatedLength SVGAnimatedLength;
36 nsDOMCSSAttributeDeclaration(Element* aContent, bool aIsSMILOverride);
38 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_WRAPPERCACHE_CLASS_AMBIGUOUS(
40 nsDOMCSSAttributeDeclaration, nsICSSDeclaration)
42 mozilla::DeclarationBlock* GetOrCreateCSSDeclaration(
43 Operation aOperation, mozilla::DeclarationBlock** aCreated) final;
45 nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
46 nsIPrincipal* aSubjectPrincipal) const final;
48 mozilla::css::Rule* GetParentRule() override { return nullptr; }
50 nsINode* GetAssociatedNode() const override { return mElement; }
51 nsINode* GetParentObject() const override { return mElement; }
53 nsresult SetSMILValue(const nsCSSPropertyID aPropID, const SMILValue& aValue);
54 nsresult SetSMILValue(const nsCSSPropertyID aPropID,
55 const SVGAnimatedLength& aLength);
56 nsresult SetSMILValue(const nsCSSPropertyID,
57 const mozilla::SVGAnimatedPathSegList& aPath);
58 void ClearSMILValue(const nsCSSPropertyID aPropID) {
59 // Put empty string in override style for our property
60 SetPropertyValue(aPropID, ""_ns, nullptr, mozilla::IgnoreErrors());
63 void SetPropertyValue(const nsCSSPropertyID aPropID, const nsACString& aValue,
64 nsIPrincipal* aSubjectPrincipal,
65 mozilla::ErrorResult& aRv) override;
67 static void MutationClosureFunction(void* aData, nsCSSPropertyID);
69 void GetPropertyChangeClosure(
70 mozilla::DeclarationBlockMutationClosure* aClosure,
71 mozilla::MutationClosureData* aClosureData) final {
72 if (!mIsSMILOverride) {
73 aClosure->function = MutationClosureFunction;
74 aClosure->data = aClosureData;
75 aClosureData->mShouldBeCalled = true;
76 aClosureData->mElement = mElement;
80 protected:
81 ~nsDOMCSSAttributeDeclaration();
83 nsresult SetCSSDeclaration(
84 mozilla::DeclarationBlock* aDecl,
85 mozilla::MutationClosureData* aClosureData) override;
86 mozilla::dom::Document* DocToUpdate() override;
88 RefPtr<Element> mElement;
90 /* If true, this indicates that this nsDOMCSSAttributeDeclaration
91 * should interact with mContent's SMIL override style rule (rather
92 * than the inline style rule).
94 const bool mIsSMILOverride;
96 private:
97 template <typename SetterFunc>
98 nsresult SetSMILValueHelper(SetterFunc aFunc);
101 #endif /* nsDOMCSSAttributeDeclaration_h */