Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/style/nsFontFaceLoader.h
Line
Count
Source (jump to first uncovered line)
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
/* code for loading in @font-face defined font data */
8
9
#ifndef nsFontFaceLoader_h_
10
#define nsFontFaceLoader_h_
11
12
#include "mozilla/Attributes.h"
13
#include "mozilla/TimeStamp.h"
14
#include "mozilla/dom/FontFaceSet.h"
15
#include "nsCOMPtr.h"
16
#include "nsIStreamLoader.h"
17
#include "nsIChannel.h"
18
#include "nsIRequestObserver.h"
19
#include "gfxUserFontSet.h"
20
#include "nsHashKeys.h"
21
#include "nsTHashtable.h"
22
23
class nsIPrincipal;
24
25
class nsFontFaceLoader final : public nsIStreamLoaderObserver
26
                             , public nsIRequestObserver
27
{
28
public:
29
  nsFontFaceLoader(gfxUserFontEntry* aFontToLoad, nsIURI* aFontURI,
30
                   mozilla::dom::FontFaceSet* aFontFaceSet,
31
                   nsIChannel* aChannel);
32
33
  NS_DECL_ISUPPORTS
34
  NS_DECL_NSISTREAMLOADEROBSERVER
35
  NS_DECL_NSIREQUESTOBSERVER
36
37
  // initiate the load
38
  nsresult Init();
39
  // cancel the load and remove its reference to mFontFaceSet
40
  void Cancel();
41
42
0
  void DropChannel() { mChannel = nullptr; }
43
44
  void StartedLoading(nsIStreamLoader* aStreamLoader);
45
46
  static void LoadTimerCallback(nsITimer* aTimer, void* aClosure);
47
48
0
  gfxUserFontEntry* GetUserFontEntry() const { return mUserFontEntry; }
49
50
protected:
51
  virtual ~nsFontFaceLoader();
52
53
  // helper method for determining the font-display value
54
  uint8_t GetFontDisplay();
55
56
private:
57
  RefPtr<gfxUserFontEntry>  mUserFontEntry;
58
  nsCOMPtr<nsIURI>        mFontURI;
59
  RefPtr<mozilla::dom::FontFaceSet> mFontFaceSet;
60
  nsCOMPtr<nsIChannel>    mChannel;
61
  nsCOMPtr<nsITimer>      mLoadTimer;
62
  mozilla::TimeStamp      mStartTime;
63
  nsIStreamLoader*        mStreamLoader;
64
};
65
66
#endif /* !defined(nsFontFaceLoader_h_) */