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 #include "PostTraversalTask.h"
8 
9 #include "mozilla/dom/FontFace.h"
10 #include "mozilla/dom/FontFaceSet.h"
11 #include "gfxPlatformFontList.h"
12 #include "gfxTextRun.h"
13 #include "ServoStyleSet.h"
14 #include "nsPresContext.h"
15 
16 namespace mozilla {
17 
18 using namespace dom;
19 
Run()20 void PostTraversalTask::Run() {
21   switch (mType) {
22     case Type::ResolveFontFaceLoadedPromise:
23       static_cast<FontFace*>(mTarget)->DoResolve();
24       break;
25 
26     case Type::RejectFontFaceLoadedPromise:
27       static_cast<FontFace*>(mTarget)->DoReject(mResult);
28       break;
29 
30     case Type::DispatchLoadingEventAndReplaceReadyPromise:
31       static_cast<FontFaceSet*>(mTarget)
32           ->DispatchLoadingEventAndReplaceReadyPromise();
33       break;
34 
35     case Type::DispatchFontFaceSetCheckLoadingFinishedAfterDelay:
36       static_cast<FontFaceSet*>(mTarget)
37           ->DispatchCheckLoadingFinishedAfterDelay();
38       break;
39 
40     case Type::LoadFontEntry:
41       static_cast<gfxUserFontEntry*>(mTarget)->ContinueLoad();
42       break;
43 
44     case Type::InitializeFamily:
45       Unused << gfxPlatformFontList::PlatformFontList()->InitializeFamily(
46           static_cast<fontlist::Family*>(mTarget));
47       break;
48 
49     case Type::FontInfoUpdate:
50       nsPresContext* pc =
51           static_cast<ServoStyleSet*>(mTarget)->GetPresContext();
52       if (pc) {
53         pc->ForceReflowForFontInfoUpdate();
54       }
55       break;
56   }
57 }
58 
59 }  // namespace mozilla
60