tor-browser

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

ServoTypes.h (4539B)


      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 /* types defined to pass values through Gecko_* and Servo_* FFI functions */
      8 
      9 #ifndef mozilla_ServoTypes_h
     10 #define mozilla_ServoTypes_h
     11 
     12 #include "NonCustomCSSPropertyId.h"
     13 #include "X11UndefineNone.h"
     14 #include "mozilla/RefPtr.h"
     15 #include "mozilla/TypedEnumBits.h"
     16 #include "nsCoord.h"
     17 
     18 namespace mozilla {
     19 struct StyleLockedFontFaceRule;
     20 enum class StyleOrigin : uint8_t;
     21 struct LangGroupFontPrefs;
     22 }  // namespace mozilla
     23 
     24 // used for associating origin with specific @font-face rules
     25 struct nsFontFaceRuleContainer {
     26  RefPtr<mozilla::StyleLockedFontFaceRule> mRule;
     27  mozilla::StyleOrigin mOrigin;
     28 };
     29 
     30 namespace mozilla {
     31 
     32 // Indicates whether the Servo style system should expect the style on an
     33 // element to have already been resolved (i.e. via a parallel traversal), or
     34 // whether it may be lazily computed.
     35 enum class LazyComputeBehavior {
     36  Allow,
     37  Assert,
     38 };
     39 
     40 // Various flags for the servo traversal.
     41 enum class ServoTraversalFlags : uint32_t {
     42  Empty = 0,
     43  // Perform animation processing but not regular styling.
     44  AnimationOnly = 1 << 0,
     45  // Traverses as normal mode but tries to update all CSS animations.
     46  ForCSSRuleChanges = 1 << 1,
     47  // The final animation-only traversal, which shouldn't really care about other
     48  // style changes anymore.
     49  FinalAnimationTraversal = 1 << 2,
     50  // Allows the traversal to run in parallel if there are sufficient cores on
     51  // the machine.
     52  ParallelTraversal = 1 << 7,
     53  // Flush throttled animations. By default, we only update throttled animations
     54  // when we have other non-throttled work to do. With this flag, we
     55  // unconditionally tick and process them.
     56  FlushThrottledAnimations = 1 << 8,
     57 };
     58 
     59 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ServoTraversalFlags)
     60 
     61 // Indicates which rules should be included when performing selecting matching
     62 // on an element.  DefaultOnly is used to exclude all rules except for those
     63 // that come from UA style sheets, and is used to implemented
     64 // getDefaultComputedStyle.
     65 enum class StyleRuleInclusion {
     66  All,
     67  DefaultOnly,
     68 };
     69 
     70 // Represents which tasks are performed in a SequentialTask of UpdateAnimations.
     71 enum class UpdateAnimationsTasks : uint8_t {
     72  CSSAnimations = 1 << 0,
     73  CSSTransitions = 1 << 1,
     74  EffectProperties = 1 << 2,
     75  CascadeResults = 1 << 3,
     76  DisplayChangedFromNone = 1 << 4,
     77  ScrollTimelines = 1 << 5,
     78  ViewTimelines = 1 << 6,
     79 };
     80 
     81 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(UpdateAnimationsTasks)
     82 
     83 // The kind of style we're generating when requesting Servo to give us an
     84 // inherited style.
     85 enum class InheritTarget {
     86  // We're requesting a text style.
     87  Text,
     88  // We're requesting a first-letter continuation frame style.
     89  FirstLetterContinuation,
     90  // We're requesting a style for a placeholder frame.
     91  PlaceholderFrame,
     92 };
     93 
     94 // Represents values for interaction media features.
     95 // https://drafts.csswg.org/mediaqueries-4/#mf-interaction
     96 enum class PointerCapabilities : uint8_t {
     97  None = 0,
     98  Coarse = 1 << 0,
     99  Fine = 1 << 1,
    100  Hover = 1 << 2,
    101 };
    102 
    103 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PointerCapabilities)
    104 
    105 // These measurements are obtained for both the UA cache and the Stylist, but
    106 // not all the fields are used in both cases.
    107 class ServoStyleSetSizes {
    108 public:
    109  size_t mRuleTree;               // Stylist-only
    110  size_t mPrecomputedPseudos;     // UA cache-only
    111  size_t mElementAndPseudosMaps;  // Used for both
    112  size_t mInvalidationMap;        // Used for both
    113  size_t mRevalidationSelectors;  // Used for both
    114  size_t mOther;                  // Used for both
    115 
    116  ServoStyleSetSizes()
    117      : mRuleTree(0),
    118        mPrecomputedPseudos(0),
    119        mElementAndPseudosMaps(0),
    120        mInvalidationMap(0),
    121        mRevalidationSelectors(0),
    122        mOther(0) {}
    123 };
    124 
    125 // A callback that can be sent via FFI which will be invoked _right before_
    126 // being mutated, and at most once.
    127 struct DeclarationBlockMutationClosure {
    128  // The callback function. The first argument is `data`, the second is the
    129  // property id that changed.
    130  void (*function)(void*, NonCustomCSSPropertyId) = nullptr;
    131  void* data = nullptr;
    132 };
    133 
    134 struct MediumFeaturesChangedResult {
    135  bool mAffectsDocumentRules;
    136  bool mAffectsNonDocumentRules;
    137 };
    138 
    139 }  // namespace mozilla
    140 
    141 #endif  // mozilla_ServoTypes_h