LCOV - code coverage report
Current view: top level - layout/style - ServoStyleSet.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 46 6.5 %
Date: 2017-07-14 16:53:18 Functions: 1 16 6.2 %
Legend: Lines: hit not hit

          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 mozilla_ServoStyleSet_h
       8             : #define mozilla_ServoStyleSet_h
       9             : 
      10             : #include "mozilla/EffectCompositor.h"
      11             : #include "mozilla/EnumeratedArray.h"
      12             : #include "mozilla/EventStates.h"
      13             : #include "mozilla/PostTraversalTask.h"
      14             : #include "mozilla/ServoBindingTypes.h"
      15             : #include "mozilla/ServoElementSnapshot.h"
      16             : #include "mozilla/ServoUtils.h"
      17             : #include "mozilla/StyleSheetInlines.h"
      18             : #include "mozilla/SheetType.h"
      19             : #include "mozilla/UniquePtr.h"
      20             : #include "MainThreadUtils.h"
      21             : #include "nsCSSPseudoElements.h"
      22             : #include "nsCSSAnonBoxes.h"
      23             : #include "nsChangeHint.h"
      24             : #include "nsIAtom.h"
      25             : #include "nsTArray.h"
      26             : 
      27             : namespace mozilla {
      28             : namespace dom {
      29             : class Element;
      30             : } // namespace dom
      31             : class CSSStyleSheet;
      32             : class ServoRestyleManager;
      33             : class ServoStyleSheet;
      34             : struct Keyframe;
      35             : class ServoElementSnapshotTable;
      36             : class ServoStyleContext;
      37             : class ServoStyleRuleMap;
      38             : } // namespace mozilla
      39             : class nsCSSCounterStyleRule;
      40             : class nsIContent;
      41             : class nsIDocument;
      42             : class nsStyleContext;
      43             : class nsPresContext;
      44             : struct nsTimingFunction;
      45             : struct RawServoRuleNode;
      46             : struct TreeMatchContext;
      47             : 
      48             : namespace mozilla {
      49             : 
      50             : /**
      51             :  * A few flags used to track which kind of stylist state we may need to
      52             :  * update.
      53             :  */
      54             : enum class StylistState : uint8_t {
      55             :   /** The stylist is not dirty, we should do nothing */
      56             :   NotDirty = 0,
      57             : 
      58             :   /** The style sheets have changed, so we need to update the style data. */
      59             :   StyleSheetsDirty = 1 << 0,
      60             : 
      61             :   /**
      62             :    * All style data is dirty and both style sheet data and default computed
      63             :    * values need to be recomputed.
      64             :    */
      65             :   FullyDirty = 1 << 1,
      66             : };
      67             : 
      68           0 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(StylistState)
      69             : 
      70             : /**
      71             :  * The set of style sheets that apply to a document, backed by a Servo
      72             :  * Stylist.  A ServoStyleSet contains ServoStyleSheets.
      73             :  */
      74             : class ServoStyleSet
      75             : {
      76             :   friend class ServoRestyleManager;
      77             :   typedef ServoElementSnapshotTable SnapshotTable;
      78             : 
      79             : public:
      80       18243 :   static bool IsInServoTraversal()
      81             :   {
      82             :     // The callers of this function are generally main-thread-only _except_
      83             :     // for potentially running during the Servo traversal, in which case they may
      84             :     // take special paths that avoid writing to caches and the like. In order
      85             :     // to allow those callers to branch efficiently without checking TLS, we
      86             :     // maintain this static boolean. However, the danger is that those callers
      87             :     // are generally unprepared to deal with non-Servo-but-also-non-main-thread
      88             :     // callers, and are likely to take the main-thread codepath if this function
      89             :     // returns false. So we assert against other non-main-thread callers here.
      90       18243 :     MOZ_ASSERT(sInServoTraversal || NS_IsMainThread());
      91       18243 :     return sInServoTraversal;
      92             :   }
      93             : 
      94           0 :   static ServoStyleSet* Current()
      95             :   {
      96           0 :     return sInServoTraversal;
      97             :   }
      98             : 
      99             :   ServoStyleSet();
     100             :   ~ServoStyleSet();
     101             : 
     102             :   void Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager);
     103             :   void BeginShutdown();
     104             :   void Shutdown();
     105             : 
     106             :   void RecordStyleSheetChange(mozilla::ServoStyleSheet*, StyleSheet::ChangeType);
     107             : 
     108           0 :   void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot) {
     109             :     // FIXME(emilio): When we properly support shadow dom we'll need to do
     110             :     // better.
     111           0 :     ForceAllStyleDirty();
     112           0 :   }
     113             : 
     114           0 :   bool StyleSheetsHaveChanged() const
     115             :   {
     116           0 :     return StylistNeedsUpdate();
     117             :   }
     118             : 
     119             :   bool MediumFeaturesChanged() const;
     120             : 
     121             :   void InvalidateStyleForCSSRuleChanges();
     122             : 
     123             :   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
     124           0 :   const RawServoStyleSet* RawSet() const {
     125           0 :     return mRawSet.get();
     126             :   }
     127             : 
     128             :   bool GetAuthorStyleDisabled() const;
     129             :   nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
     130             : 
     131             :   void BeginUpdate();
     132             :   nsresult EndUpdate();
     133             : 
     134             :   already_AddRefed<nsStyleContext>
     135             :   ResolveStyleFor(dom::Element* aElement,
     136             :                   nsStyleContext* aParentContext,
     137             :                   LazyComputeBehavior aMayCompute);
     138             : 
     139             :   // Get a style context for a text node (which no rules will match).
     140             :   //
     141             :   // The returned style context will have nsCSSAnonBoxes::mozText as its pseudo.
     142             :   //
     143             :   // (Perhaps mozText should go away and we shouldn't even create style
     144             :   // contexts for such content nodes, when text-combine-upright is not
     145             :   // present.  However, not doing any rule matching for them is a first step.)
     146             :   already_AddRefed<nsStyleContext>
     147             :   ResolveStyleForText(nsIContent* aTextNode,
     148             :                       nsStyleContext* aParentContext);
     149             : 
     150             :   // Get a style context for a first-letter continuation (which no rules will
     151             :   // match).
     152             :   //
     153             :   // The returned style context will have
     154             :   // nsCSSAnonBoxes::firstLetterContinuation as its pseudo.
     155             :   //
     156             :   // (Perhaps nsCSSAnonBoxes::firstLetterContinuation should go away and we
     157             :   // shouldn't even create style contexts for such frames.  However, not doing
     158             :   // any rule matching for them is a first step.  And right now we do use this
     159             :   // style context for some things)
     160             :   already_AddRefed<nsStyleContext>
     161             :   ResolveStyleForFirstLetterContinuation(nsStyleContext* aParentContext);
     162             : 
     163             :   // Get a style context for a placeholder frame (which no rules will match).
     164             :   //
     165             :   // The returned style context will have nsCSSAnonBoxes::oofPlaceholder as
     166             :   // its pseudo.
     167             :   //
     168             :   // (Perhaps nsCSSAnonBoxes::oofPaceholder should go away and we shouldn't even
     169             :   // create style contexts for placeholders.  However, not doing any rule
     170             :   // matching for them is a first step.)
     171             :   already_AddRefed<nsStyleContext>
     172             :   ResolveStyleForPlaceholder();
     173             : 
     174             :   // Get a style context for a pseudo-element.  aParentElement must be
     175             :   // non-null.  aPseudoID is the CSSPseudoElementType for the
     176             :   // pseudo-element.  aPseudoElement must be non-null if the pseudo-element
     177             :   // type is one that allows user action pseudo-classes after it or allows
     178             :   // style attributes; otherwise, it is ignored.
     179             :   already_AddRefed<nsStyleContext>
     180             :   ResolvePseudoElementStyle(dom::Element* aOriginatingElement,
     181             :                             CSSPseudoElementType aType,
     182             :                             nsStyleContext* aParentContext,
     183             :                             dom::Element* aPseudoElement);
     184             : 
     185             :   // Resolves style for a (possibly-pseudo) Element without assuming that the
     186             :   // style has been resolved, and without worrying about setting the style
     187             :   // context up to live in the style context tree (a null parent is used).
     188             :   // |aPeudoTag| and |aPseudoType| must match.
     189             :   already_AddRefed<nsStyleContext>
     190             :   ResolveTransientStyle(dom::Element* aElement,
     191             :                         nsIAtom* aPseudoTag,
     192             :                         CSSPseudoElementType aPseudoType,
     193             :                         StyleRuleInclusion aRules =
     194             :                           StyleRuleInclusion::All);
     195             : 
     196             :   // Similar to ResolveTransientStyle() but returns ServoComputedValues.
     197             :   // Unlike ResolveServoStyle() this function calls PreTraverseSync().
     198             :   already_AddRefed<ServoComputedValues>
     199             :   ResolveTransientServoStyle(dom::Element* aElement,
     200             :                              CSSPseudoElementType aPseudoTag,
     201             :                              StyleRuleInclusion aRules =
     202             :                                StyleRuleInclusion::All);
     203             : 
     204             :   // Get a style context for an anonymous box.  aPseudoTag is the pseudo-tag to
     205             :   // use and must be non-null.  It must be an anon box, and must be one that
     206             :   // inherits style from the given aParentContext.
     207             :   already_AddRefed<ServoStyleContext>
     208             :   ResolveInheritingAnonymousBoxStyle(nsIAtom* aPseudoTag,
     209             :                                      nsStyleContext* aParentContext);
     210             : 
     211             :   // Get a style context for an anonymous box that does not inherit style from
     212             :   // anything.  aPseudoTag is the pseudo-tag to use and must be non-null.  It
     213             :   // must be an anon box, and must be a non-inheriting one.
     214             :   already_AddRefed<nsStyleContext>
     215             :   ResolveNonInheritingAnonymousBoxStyle(nsIAtom* aPseudoTag);
     216             : 
     217             :   // manage the set of style sheets in the style set
     218             :   nsresult AppendStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
     219             :   nsresult PrependStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
     220             :   nsresult RemoveStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
     221             :   nsresult ReplaceSheets(SheetType aType,
     222             :                          const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets);
     223             :   nsresult InsertStyleSheetBefore(SheetType aType,
     224             :                                   ServoStyleSheet* aNewSheet,
     225             :                                   ServoStyleSheet* aReferenceSheet);
     226             : 
     227             :   // Notify servo that the underlying raw sheet has changed, through cloning.
     228             :   // This should only be called on a just-cloned sheet, because it does not
     229             :   // mark the stylesheets as dirty either here or in servo.
     230             :   void UpdateStyleSheet(ServoStyleSheet* aSheet);
     231             : 
     232             :   int32_t SheetCount(SheetType aType) const;
     233             :   ServoStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
     234             : 
     235             :   void AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const;
     236             : 
     237             :   template<typename Func>
     238           0 :   void EnumerateStyleSheetArrays(Func aCallback) const {
     239           0 :     for (const auto& sheetArray : mSheets) {
     240           0 :       aCallback(sheetArray);
     241             :     }
     242           0 :   }
     243             : 
     244             :   nsresult RemoveDocStyleSheet(ServoStyleSheet* aSheet);
     245             :   nsresult AddDocStyleSheet(ServoStyleSheet* aSheet, nsIDocument* aDocument);
     246             : 
     247             :   // check whether there is ::before/::after style for an element
     248             :   already_AddRefed<nsStyleContext>
     249             :   ProbePseudoElementStyle(dom::Element* aOriginatingElement,
     250             :                           mozilla::CSSPseudoElementType aType,
     251             :                           nsStyleContext* aParentContext);
     252             : 
     253             :   // Test if style is dependent on content state
     254             :   nsRestyleHint HasStateDependentStyle(dom::Element* aElement,
     255             :                                        EventStates aStateMask);
     256             :   nsRestyleHint HasStateDependentStyle(
     257             :     dom::Element* aElement, mozilla::CSSPseudoElementType aPseudoType,
     258             :     dom::Element* aPseudoElement, EventStates aStateMask);
     259             : 
     260             :   /**
     261             :    * Performs a Servo traversal to compute style for all dirty nodes in the
     262             :    * document.
     263             :    *
     264             :    * This will traverse all of the document's style roots (that is, its document
     265             :    * element, and the roots of the document-level native anonymous content).
     266             :    *
     267             :    * |aRestyleBehavior| should be `Normal` or `ForCSSRuleChanges`.
     268             :    * We need to specify |ForCSSRuleChanges| to try to update all CSS animations
     269             :    * when we call this function due to CSS rule changes since @keyframes rules
     270             :    * may have changed.
     271             :    *
     272             :    * Returns true if a post-traversal is required.
     273             :    */
     274             :   bool StyleDocument(TraversalRestyleBehavior aRestyleBehavior);
     275             : 
     276             :   /**
     277             :    * Performs a Servo animation-only traversal to compute style for all nodes
     278             :    * with the animation-only dirty bit in the document.
     279             :    *
     280             :    * This will traverse all of the document's style roots (that is, its document
     281             :    * element, and the roots of the document-level native anonymous content).
     282             :    */
     283             :   bool StyleDocumentForAnimationOnly();
     284             : 
     285             :   /**
     286             :    * Eagerly styles a subtree of unstyled nodes that was just appended to the
     287             :    * tree. This is used in situations where we need the style immediately and
     288             :    * cannot wait for a future batch restyle.
     289             :    */
     290             :   void StyleNewSubtree(dom::Element* aRoot);
     291             : 
     292             :   /**
     293             :    * Like the above, but skips the root node, and only styles unstyled children.
     294             :    * When potentially appending multiple children, it's preferable to call
     295             :    * StyleNewChildren on the node rather than making multiple calls to
     296             :    * StyleNewSubtree on each child, since it allows for more parallelism.
     297             :    */
     298             :   void StyleNewChildren(dom::Element* aParent);
     299             : 
     300             :   /**
     301             :    * Eagerly styles the children of an element that has just had an XBL
     302             :    * binding applied to it.  Some XBL consumers attach bindings to elements
     303             :    * that have not been styled yet, and in such cases, this will do the
     304             :    * equivalent of StyleNewSubtree instead.
     305             :    */
     306             :   void StyleNewlyBoundElement(dom::Element* aElement);
     307             : 
     308             :   /**
     309             :    * Like StyleNewSubtree, but in response to a request to reconstruct frames
     310             :    * for the given subtree, and so works on elements that already have
     311             :    * styles.  This will leave the subtree in a state just like after an initial
     312             :    * styling, i.e. with new styles, no change hints, and with the dirty
     313             :    * descendants bits cleared.  No comparison of old and new styles is done,
     314             :    * so no change hints will be processed.
     315             :    */
     316             :   void StyleSubtreeForReconstruct(dom::Element* aRoot);
     317             : 
     318             :   /**
     319             :    * Records that the contents of style sheets have changed since the last
     320             :    * restyle.  Calling this will ensure that the Stylist rebuilds its
     321             :    * selector maps.
     322             :    */
     323             :   void ForceAllStyleDirty();
     324             : 
     325             :   /**
     326             :    * Helper for correctly calling RebuildStylist without paying the cost of an
     327             :    * extra function call in the common no-rebuild-needed case.
     328             :    */
     329           0 :   void UpdateStylistIfNeeded()
     330             :   {
     331           0 :     if (StylistNeedsUpdate()) {
     332           0 :       UpdateStylist();
     333             :     }
     334           0 :   }
     335             : 
     336             :   /**
     337             :    * Checks whether the rule tree has crossed its threshold for unused nodes,
     338             :    * and if so, frees them.
     339             :    */
     340             :   void MaybeGCRuleTree();
     341             : 
     342             : #ifdef DEBUG
     343             :   void AssertTreeIsClean();
     344             : #else
     345             :   void AssertTreeIsClean() {}
     346             : #endif
     347             : 
     348             :   /**
     349             :    * Clears the style data, both style sheet data and cached non-inheriting
     350             :    * style contexts, and marks the stylist as needing an unconditional full
     351             :    * rebuild, including a device reset.
     352             :    */
     353             :   void ClearDataAndMarkDeviceDirty();
     354             : 
     355             :   /**
     356             :    * Notifies the Servo stylesheet that the document's compatibility mode has changed.
     357             :    */
     358             :   void CompatibilityModeChanged();
     359             : 
     360             :   /**
     361             :    * Resolve style for the given element, and return it as a
     362             :    * ServoComputedValues, not an nsStyleContext.
     363             :    */
     364             :   already_AddRefed<ServoComputedValues> ResolveServoStyle(dom::Element* aElement);
     365             : 
     366             :   bool GetKeyframesForName(const nsString& aName,
     367             :                            const nsTimingFunction& aTimingFunction,
     368             :                            nsTArray<Keyframe>& aKeyframes);
     369             : 
     370             :   nsTArray<ComputedKeyframeValues>
     371             :   GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
     372             :                                dom::Element* aElement,
     373             :                                ServoComputedValuesBorrowed aComputedValues);
     374             : 
     375             :   void
     376             :   GetAnimationValues(RawServoDeclarationBlock* aDeclarations,
     377             :                      dom::Element* aElement,
     378             :                      ServoComputedValuesBorrowed aComputedValues,
     379             :                      nsTArray<RefPtr<RawServoAnimationValue>>& aAnimationValues);
     380             : 
     381             :   bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
     382             : 
     383             :   nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
     384             : 
     385             :   already_AddRefed<ServoComputedValues>
     386             :   GetBaseComputedValuesForElement(dom::Element* aElement,
     387             :                                   CSSPseudoElementType aPseudoType,
     388             :                                   ServoComputedValuesBorrowed aStyle);
     389             : 
     390             :   /**
     391             :    * Resolve style for a given declaration block with/without the parent style.
     392             :    * If the parent style is not specified, the document default computed values
     393             :    * is used.
     394             :    */
     395             :   already_AddRefed<ServoComputedValues>
     396             :   ResolveForDeclarations(ServoComputedValuesBorrowedOrNull aParentOrNull,
     397             :                          RawServoDeclarationBlockBorrowed aDeclarations);
     398             : 
     399             :   already_AddRefed<RawServoAnimationValue>
     400             :   ComputeAnimationValue(dom::Element* aElement,
     401             :                         RawServoDeclarationBlock* aDeclaration,
     402             :                         ServoComputedValuesBorrowed aComputedValues);
     403             : 
     404           0 :   void AppendTask(PostTraversalTask aTask)
     405             :   {
     406           0 :     MOZ_ASSERT(IsInServoTraversal());
     407             : 
     408             :     // We currently only use PostTraversalTasks while the Servo font metrics
     409             :     // mutex is locked.  If we need to use them in other situations during
     410             :     // a traversal, we should assert that we've taken appropriate
     411             :     // synchronization measures.
     412           0 :     AssertIsMainThreadOrServoFontMetricsLocked();
     413             : 
     414           0 :     mPostTraversalTasks.AppendElement(aTask);
     415           0 :   }
     416             : 
     417             :   // Returns true if a restyle of the document is needed due to cloning
     418             :   // sheet inners.
     419             :   bool EnsureUniqueInnerOnCSSSheets();
     420             : 
     421             :   // Called by StyleSheet::EnsureUniqueInner to let us know it cloned
     422             :   // its inner.
     423           0 :   void SetNeedsRestyleAfterEnsureUniqueInner() {
     424           0 :     mNeedsRestyleAfterEnsureUniqueInner = true;
     425           0 :   }
     426             : 
     427             :   // Returns the style rule map.
     428             :   ServoStyleRuleMap* StyleRuleMap();
     429             : 
     430             :   /**
     431             :    * Returns true if a modification to an an attribute with the specified
     432             :    * local name might require us to restyle the element.
     433             :    *
     434             :    * This function allows us to skip taking a an attribute snapshot when
     435             :    * the modified attribute doesn't appear in an attribute selector in
     436             :    * a style sheet.
     437             :    */
     438             :   bool MightHaveAttributeDependency(const dom::Element& aElement,
     439             :                                     nsIAtom* aAttribute) const;
     440             : 
     441             :   /**
     442             :    * Returns true if a change in event state on an element might require
     443             :    * us to restyle the element.
     444             :    *
     445             :    * This function allows us to skip taking a state snapshot when
     446             :    * the changed state isn't depended upon by any pseudo-class selectors
     447             :    * in a style sheet.
     448             :    */
     449             :   bool HasStateDependency(const dom::Element& aElement,
     450             :                           EventStates aState) const;
     451             : 
     452             : private:
     453             :   // On construction, sets sInServoTraversal to the given ServoStyleSet.
     454             :   // On destruction, clears sInServoTraversal and calls RunPostTraversalTasks.
     455             :   class MOZ_STACK_CLASS AutoSetInServoTraversal
     456             :   {
     457             :   public:
     458           0 :     explicit AutoSetInServoTraversal(ServoStyleSet* aSet)
     459           0 :       : mSet(aSet)
     460             :     {
     461           0 :       MOZ_ASSERT(!sInServoTraversal);
     462           0 :       MOZ_ASSERT(aSet);
     463           0 :       sInServoTraversal = aSet;
     464           0 :     }
     465             : 
     466           0 :     ~AutoSetInServoTraversal()
     467           0 :     {
     468           0 :       MOZ_ASSERT(sInServoTraversal);
     469           0 :       sInServoTraversal = nullptr;
     470           0 :       mSet->RunPostTraversalTasks();
     471           0 :     }
     472             : 
     473             :   private:
     474             :     ServoStyleSet* mSet;
     475             :   };
     476             : 
     477             :   already_AddRefed<ServoStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
     478             :                                                  nsStyleContext* aParentContext,
     479             :                                                  nsIAtom* aPseudoTag,
     480             :                                                  CSSPseudoElementType aPseudoType,
     481             :                                                  dom::Element* aElementForAnimation);
     482             : 
     483             :   already_AddRefed<ServoStyleContext> GetContext(nsIContent* aContent,
     484             :                                                  nsStyleContext* aParentContext,
     485             :                                                  nsIAtom* aPseudoTag,
     486             :                                                  CSSPseudoElementType aPseudoType,
     487             :                                                  LazyComputeBehavior aMayCompute);
     488             : 
     489             :   /**
     490             :    * Rebuild the style data. This will force a stylesheet flush, and also
     491             :    * recompute the default computed styles.
     492             :    */
     493             :   void RebuildData();
     494             : 
     495             :   /**
     496             :    * Gets the pending snapshots to handle from the restyle manager.
     497             :    */
     498             :   const SnapshotTable& Snapshots();
     499             : 
     500             :   /**
     501             :    * Resolve all ServoDeclarationBlocks attached to mapped
     502             :    * presentation attributes cached on the document.
     503             :    *
     504             :    * Call this before jumping into Servo's style system.
     505             :    */
     506             :   void ResolveMappedAttrDeclarationBlocks();
     507             : 
     508             :   /**
     509             :    * Perform all lazy operations required before traversing
     510             :    * a subtree.
     511             :    *
     512             :    * Returns whether a post-traversal is required.
     513             :    */
     514             :   bool PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
     515             :                                  TraversalRootBehavior aRootBehavior,
     516             :                                  TraversalRestyleBehavior aRestyleBehavior);
     517             : 
     518             :   /**
     519             :    * Clear our cached mNonInheritingStyleContexts.
     520             :    *
     521             :    * We do this when we want to make sure those style contexts won't live too
     522             :    * long (e.g. when rebuilding all style data or when shutting down the style
     523             :    * set).
     524             :    */
     525             :   void ClearNonInheritingStyleContexts();
     526             : 
     527             :   /**
     528             :    * Perform processes that we should do before traversing.
     529             :    *
     530             :    * When aRoot is null, the entire document is pre-traversed.  Otherwise,
     531             :    * only the subtree rooted at aRoot is pre-traversed.
     532             :    */
     533             :   void PreTraverse(dom::Element* aRoot = nullptr,
     534             :                    EffectCompositor::AnimationRestyleType =
     535             :                      EffectCompositor::AnimationRestyleType::Throttled);
     536             :   // Subset of the pre-traverse steps that involve syncing up data
     537             :   void PreTraverseSync();
     538             : 
     539             :   /**
     540             :    * Note that the stylist needs a style flush due to style sheet changes.
     541             :    */
     542           0 :   void SetStylistStyleSheetsDirty()
     543             :   {
     544           0 :     mStylistState |= StylistState::StyleSheetsDirty;
     545           0 :   }
     546             : 
     547           0 :   bool StylistNeedsUpdate() const
     548             :   {
     549           0 :     return mStylistState != StylistState::NotDirty;
     550             :   }
     551             : 
     552             :   /**
     553             :    * Update the stylist as needed to ensure style data is up-to-date.
     554             :    *
     555             :    * This should only be called if StylistNeedsUpdate returns true.
     556             :    */
     557             :   void UpdateStylist();
     558             : 
     559             :   already_AddRefed<ServoComputedValues>
     560             :     ResolveStyleLazily(dom::Element* aElement,
     561             :                        CSSPseudoElementType aPseudoType,
     562             :                        StyleRuleInclusion aRules =
     563             :                          StyleRuleInclusion::All);
     564             : 
     565             :   void RunPostTraversalTasks();
     566             : 
     567             :   void PrependSheetOfType(SheetType aType,
     568             :                           ServoStyleSheet* aSheet);
     569             : 
     570             :   void AppendSheetOfType(SheetType aType,
     571             :                          ServoStyleSheet* aSheet);
     572             : 
     573             :   void InsertSheetOfType(SheetType aType,
     574             :                          ServoStyleSheet* aSheet,
     575             :                          ServoStyleSheet* aBeforeSheet);
     576             : 
     577             :   void RemoveSheetOfType(SheetType aType,
     578             :                          ServoStyleSheet* aSheet);
     579             : 
     580             :   nsPresContext* mPresContext;
     581             :   UniquePtr<RawServoStyleSet> mRawSet;
     582             :   EnumeratedArray<SheetType, SheetType::Count,
     583             :                   nsTArray<RefPtr<ServoStyleSheet>>> mSheets;
     584             :   bool mAuthorStyleDisabled;
     585             :   StylistState mStylistState;
     586             :   uint64_t mUserFontSetUpdateGeneration;
     587             :   uint32_t mUserFontCacheUpdateGeneration;
     588             : 
     589             :   bool mNeedsRestyleAfterEnsureUniqueInner;
     590             : 
     591             :   // Stores pointers to our cached style contexts for non-inheriting anonymous
     592             :   // boxes.
     593             :   EnumeratedArray<nsCSSAnonBoxes::NonInheriting,
     594             :                   nsCSSAnonBoxes::NonInheriting::_Count,
     595             :                   RefPtr<nsStyleContext>> mNonInheritingStyleContexts;
     596             : 
     597             :   // Tasks to perform after a traversal, back on the main thread.
     598             :   //
     599             :   // These are similar to Servo's SequentialTasks, except that they are
     600             :   // posted by C++ code running on style worker threads.
     601             :   nsTArray<PostTraversalTask> mPostTraversalTasks;
     602             : 
     603             :   // Map from raw Servo style rule to Gecko's wrapper object.
     604             :   // Constructed lazily when requested by devtools.
     605             :   RefPtr<ServoStyleRuleMap> mStyleRuleMap;
     606             : 
     607             :   // This can be null if we are used to hold XBL style sheets.
     608             :   RefPtr<nsBindingManager> mBindingManager;
     609             : 
     610             :   static ServoStyleSet* sInServoTraversal;
     611             : };
     612             : 
     613             : } // namespace mozilla
     614             : 
     615             : #endif // mozilla_ServoStyleSet_h

Generated by: LCOV version 1.13