LCOV - code coverage report
Current view: top level - layout/style - PostTraversalTask.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 25 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
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_PostTraversalTask_h
       8             : #define mozilla_PostTraversalTask_h
       9             : 
      10             : /* a task to be performed immediately after a Servo traversal */
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : class FontFace;
      15             : class FontFaceSet;
      16             : } // namespace dom
      17             : } // namespace mozilla
      18             : class gfxUserFontEntry;
      19             : 
      20             : namespace mozilla {
      21             : 
      22             : /**
      23             :  * A PostTraversalTask is a task to be performed immediately after a Servo
      24             :  * traversal.  There are just a few tasks we need to perform, so we use this
      25             :  * class rather than Runnables, to avoid virtual calls and some allocations.
      26             :  *
      27             :  * A PostTraversalTask is only safe to run immediately after the Servo
      28             :  * traversal, since it can hold raw pointers to DOM objects.
      29             :  */
      30             : class PostTraversalTask
      31             : {
      32             : public:
      33           0 :   static PostTraversalTask ResolveFontFaceLoadedPromise(dom::FontFace* aFontFace)
      34             :   {
      35           0 :     auto task = PostTraversalTask(Type::ResolveFontFaceLoadedPromise);
      36           0 :     task.mTarget = aFontFace;
      37           0 :     return task;
      38             :   }
      39             : 
      40           0 :   static PostTraversalTask RejectFontFaceLoadedPromise(dom::FontFace* aFontFace,
      41             :                                                        nsresult aResult)
      42             :   {
      43           0 :     auto task = PostTraversalTask(Type::ResolveFontFaceLoadedPromise);
      44           0 :     task.mTarget = aFontFace;
      45           0 :     task.mResult = aResult;
      46           0 :     return task;
      47             :   }
      48             : 
      49           0 :   static PostTraversalTask DispatchLoadingEventAndReplaceReadyPromise(
      50             :     dom::FontFaceSet* aFontFaceSet)
      51             :   {
      52             :     auto task =
      53           0 :       PostTraversalTask(Type::DispatchLoadingEventAndReplaceReadyPromise);
      54           0 :     task.mTarget = aFontFaceSet;
      55           0 :     return task;
      56             :   }
      57             : 
      58           0 :   static PostTraversalTask DispatchFontFaceSetCheckLoadingFinishedAfterDelay(
      59             :     dom::FontFaceSet* aFontFaceSet)
      60             :   {
      61             :     auto task =
      62           0 :       PostTraversalTask(Type::DispatchFontFaceSetCheckLoadingFinishedAfterDelay);
      63           0 :     task.mTarget = aFontFaceSet;
      64           0 :     return task;
      65             :   }
      66             : 
      67           0 :   static PostTraversalTask LoadFontEntry(gfxUserFontEntry* aFontEntry)
      68             :   {
      69           0 :     auto task = PostTraversalTask(Type::LoadFontEntry);
      70           0 :     task.mTarget = aFontEntry;
      71           0 :     return task;
      72             :   }
      73             : 
      74             :   void Run();
      75             : 
      76             : private:
      77             :   // For any new raw pointer type that we need to store in a PostTraversalTask,
      78             :   // please add an assertion that class' destructor that we are not in a Servo
      79             :   // traversal, to protect against the possibility of having dangling pointers.
      80             :   enum class Type
      81             :   {
      82             :     // mTarget (FontFace*)
      83             :     ResolveFontFaceLoadedPromise,
      84             : 
      85             :     // mTarget (FontFace*)
      86             :     // mResult
      87             :     RejectFontFaceLoadedPromise,
      88             : 
      89             :     // mTarget (FontFaceSet*)
      90             :     DispatchLoadingEventAndReplaceReadyPromise,
      91             : 
      92             :     // mTarget (FontFaceSet*)
      93             :     DispatchFontFaceSetCheckLoadingFinishedAfterDelay,
      94             : 
      95             :     // mTarget (gfxUserFontEntry*)
      96             :     LoadFontEntry,
      97             :   };
      98             : 
      99           0 :   explicit PostTraversalTask(Type aType)
     100           0 :     : mType(aType)
     101             :     , mTarget(nullptr)
     102           0 :     , mResult(NS_OK)
     103             :   {
     104           0 :   }
     105             : 
     106             :   Type mType;
     107             :   void* mTarget;
     108             :   nsresult mResult;
     109             : };
     110             : 
     111             : } // namespace mozilla
     112             : 
     113             : #endif // mozilla_PostTraversalTask_h

Generated by: LCOV version 1.13