tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsDOMCSSAttrDeclaration.h (3732B)


      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 /* DOM object for element.style */
      8 
      9 #ifndef nsDOMCSSAttributeDeclaration_h
     10 #define nsDOMCSSAttributeDeclaration_h
     11 
     12 #include "mozilla/ServoTypes.h"
     13 #include "mozilla/dom/DocGroup.h"
     14 #include "nsDOMCSSDeclaration.h"
     15 
     16 struct RawServoUnlockedDeclarationBlock;
     17 
     18 namespace mozilla {
     19 
     20 class SMILValue;
     21 class SVGAnimatedLength;
     22 class SVGAnimatedPathSegList;
     23 class SVGAnimatedTransformList;
     24 
     25 namespace dom {
     26 class DomGroup;
     27 class Element;
     28 }  // namespace dom
     29 }  // namespace mozilla
     30 
     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);
     37 
     38  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     39  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_WRAPPERCACHE_CLASS_AMBIGUOUS(
     40      nsDOMCSSAttributeDeclaration, nsICSSDeclaration)
     41 
     42  mozilla::DeclarationBlock* GetOrCreateCSSDeclaration(
     43      Operation aOperation, mozilla::DeclarationBlock** aCreated) final;
     44 
     45  nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
     46      nsIPrincipal* aSubjectPrincipal) const final;
     47 
     48  mozilla::css::Rule* GetParentRule() override { return nullptr; }
     49 
     50  nsINode* GetAssociatedNode() const override { return mElement; }
     51  nsINode* GetParentObject() const override { return mElement; }
     52 
     53  nsresult SetSMILValue(const NonCustomCSSPropertyId aPropId,
     54                        const SMILValue& aValue);
     55  nsresult SetSMILValue(const NonCustomCSSPropertyId aPropId,
     56                        const SVGAnimatedLength& aLength);
     57  nsresult SetSMILValue(const NonCustomCSSPropertyId,
     58                        const mozilla::SVGAnimatedPathSegList& aPath);
     59  nsresult SetSMILValue(const NonCustomCSSPropertyId,
     60                        const mozilla::SVGAnimatedTransformList*,
     61                        const mozilla::gfx::Matrix* aAnimateMotion = nullptr);
     62  void ClearSMILValue(const NonCustomCSSPropertyId aPropId) {
     63    // Put empty string in override style for our property
     64    SetPropertyValue(aPropId, ""_ns, nullptr, mozilla::IgnoreErrors());
     65  }
     66 
     67  void SetPropertyValue(const NonCustomCSSPropertyId aPropId,
     68                        const nsACString& aValue,
     69                        nsIPrincipal* aSubjectPrincipal,
     70                        mozilla::ErrorResult& aRv) override;
     71 
     72  static void MutationClosureFunction(void* aData, NonCustomCSSPropertyId);
     73 
     74  void GetPropertyChangeClosure(
     75      mozilla::DeclarationBlockMutationClosure* aClosure,
     76      mozilla::MutationClosureData* aClosureData) final {
     77    if (!mIsSMILOverride) {
     78      aClosure->function = MutationClosureFunction;
     79      aClosure->data = aClosureData;
     80      aClosureData->mShouldBeCalled = true;
     81      aClosureData->mElement = mElement;
     82    }
     83  }
     84 
     85 protected:
     86  ~nsDOMCSSAttributeDeclaration();
     87 
     88  nsresult SetCSSDeclaration(
     89      mozilla::DeclarationBlock* aDecl,
     90      mozilla::MutationClosureData* aClosureData) override;
     91  mozilla::dom::Document* DocToUpdate() final;
     92 
     93  RefPtr<Element> mElement;
     94 
     95  /* If true, this indicates that this nsDOMCSSAttributeDeclaration
     96   * should interact with mContent's SMIL override style rule (rather
     97   * than the inline style rule).
     98   */
     99  const bool mIsSMILOverride;
    100 
    101 private:
    102  template <typename SetterFunc>
    103  nsresult SetSMILValueHelper(SetterFunc aFunc);
    104 };
    105 
    106 #endif /* nsDOMCSSAttributeDeclaration_h */