nsFontFaceLoader.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. // vim:cindent:ts=2:et:sw=2:
  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. /* code for loading in @font-face defined font data */
  7. #ifndef nsFontFaceLoader_h_
  8. #define nsFontFaceLoader_h_
  9. #include "mozilla/Attributes.h"
  10. #include "mozilla/TimeStamp.h"
  11. #include "nsCOMPtr.h"
  12. #include "nsIStreamLoader.h"
  13. #include "nsIChannel.h"
  14. #include "gfxUserFontSet.h"
  15. #include "nsHashKeys.h"
  16. #include "nsTHashtable.h"
  17. #include "nsCSSRules.h"
  18. class nsIPrincipal;
  19. class nsFontFaceLoader : public nsIStreamLoaderObserver
  20. {
  21. public:
  22. nsFontFaceLoader(gfxUserFontEntry* aFontToLoad, nsIURI* aFontURI,
  23. mozilla::dom::FontFaceSet* aFontFaceSet,
  24. nsIChannel* aChannel);
  25. NS_DECL_ISUPPORTS
  26. NS_DECL_NSISTREAMLOADEROBSERVER
  27. // initiate the load
  28. nsresult Init();
  29. // cancel the load and remove its reference to mFontFaceSet
  30. void Cancel();
  31. void DropChannel() { mChannel = nullptr; }
  32. void StartedLoading(nsIStreamLoader* aStreamLoader);
  33. static void LoadTimerCallback(nsITimer* aTimer, void* aClosure);
  34. gfxUserFontEntry* GetUserFontEntry() const { return mUserFontEntry; }
  35. protected:
  36. virtual ~nsFontFaceLoader();
  37. // helper method for determining the font-display value
  38. uint8_t GetFontDisplay();
  39. private:
  40. RefPtr<gfxUserFontEntry> mUserFontEntry;
  41. nsCOMPtr<nsIURI> mFontURI;
  42. RefPtr<mozilla::dom::FontFaceSet> mFontFaceSet;
  43. nsCOMPtr<nsIChannel> mChannel;
  44. nsCOMPtr<nsITimer> mLoadTimer;
  45. mozilla::TimeStamp mStartTime;
  46. nsIStreamLoader* mStreamLoader;
  47. };
  48. #endif /* !defined(nsFontFaceLoader_h_) */