tor-browser

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

Keyframe.h (2962B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_Keyframe_h
      8 #define mozilla_dom_Keyframe_h
      9 
     10 #include "mozilla/CSSPropertyId.h"
     11 #include "mozilla/Maybe.h"
     12 #include "mozilla/RefPtr.h"
     13 #include "mozilla/ServoStyleConsts.h"
     14 #include "mozilla/dom/BaseKeyframeTypesBinding.h"  // CompositeOperationOrAuto
     15 #include "nsCSSValue.h"
     16 #include "nsTArray.h"
     17 
     18 namespace mozilla {
     19 struct StyleLockedDeclarationBlock;
     20 
     21 /**
     22 * A property-value pair specified on a keyframe.
     23 */
     24 struct PropertyValuePair {
     25  explicit PropertyValuePair(const CSSPropertyId& aProperty)
     26      : mProperty(aProperty) {}
     27 
     28  PropertyValuePair(const CSSPropertyId& aProperty,
     29                    RefPtr<StyleLockedDeclarationBlock>&& aValue)
     30      : mProperty(aProperty), mServoDeclarationBlock(std::move(aValue)) {
     31    MOZ_ASSERT(mServoDeclarationBlock, "Should be valid property value");
     32  }
     33 
     34  CSSPropertyId mProperty;
     35 
     36  // The specified value when using the Servo backend.
     37  RefPtr<StyleLockedDeclarationBlock> mServoDeclarationBlock;
     38 
     39 #ifdef DEBUG
     40  // Flag to indicate that when we call StyleAnimationValue::ComputeValues on
     41  // this value we should behave as if that function had failed.
     42  bool mSimulateComputeValuesFailure = false;
     43 #endif
     44 
     45  bool operator==(const PropertyValuePair&) const;
     46 };
     47 
     48 /**
     49 * A single keyframe.
     50 *
     51 * This is the canonical form in which keyframe effects are stored and
     52 * corresponds closely to the type of objects returned via the getKeyframes()
     53 * API.
     54 *
     55 * Before computing an output animation value, however, we flatten these frames
     56 * down to a series of per-property value arrays where we also resolve any
     57 * overlapping shorthands/longhands, convert specified CSS values to computed
     58 * values, etc.
     59 *
     60 * When the target element or computed style changes, however, we rebuild these
     61 * per-property arrays from the original list of keyframes objects. As a result,
     62 * these objects represent the master definition of the effect's values.
     63 */
     64 struct Keyframe {
     65  Keyframe() = default;
     66  Keyframe(const Keyframe& aOther) = default;
     67  Keyframe(Keyframe&& aOther) = default;
     68 
     69  Keyframe& operator=(const Keyframe& aOther) = default;
     70  Keyframe& operator=(Keyframe&& aOther) = default;
     71 
     72  Maybe<double> mOffset;
     73  static constexpr double kComputedOffsetNotSet = -1.0;
     74  double mComputedOffset = kComputedOffsetNotSet;
     75  Maybe<StyleComputedTimingFunction> mTimingFunction;  // Nothing() here means
     76                                                       // "linear"
     77  dom::CompositeOperationOrAuto mComposite =
     78      dom::CompositeOperationOrAuto::Auto;
     79  CopyableTArray<PropertyValuePair> mPropertyValues;
     80 };
     81 
     82 }  // namespace mozilla
     83 
     84 #endif  // mozilla_dom_Keyframe_h