2008-10-01 03:04:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-10-01 03:04:10 +00:00
|
|
|
|
|
|
|
/* code for loading in @font-face defined font data */
|
|
|
|
|
|
|
|
#ifndef nsFontFaceLoader_h_
|
|
|
|
#define nsFontFaceLoader_h_
|
|
|
|
|
2014-02-24 14:41:56 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-11-25 05:48:16 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2008-12-12 07:31:51 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2008-10-29 18:09:50 +00:00
|
|
|
#include "nsIStreamLoader.h"
|
2009-01-19 09:21:29 +00:00
|
|
|
#include "nsIChannel.h"
|
2008-10-01 03:04:10 +00:00
|
|
|
#include "gfxUserFontSet.h"
|
2009-01-19 09:21:29 +00:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsTHashtable.h"
|
2011-04-12 10:53:20 +00:00
|
|
|
#include "nsCSSRules.h"
|
2008-10-01 03:04:10 +00:00
|
|
|
|
2008-11-06 00:32:12 +00:00
|
|
|
class nsIPrincipal;
|
2008-10-01 03:04:10 +00:00
|
|
|
|
2008-10-29 18:09:50 +00:00
|
|
|
class nsFontFaceLoader : public nsIStreamLoaderObserver
|
2008-10-01 03:04:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-08 07:23:20 +00:00
|
|
|
nsFontFaceLoader(gfxUserFontEntry* aFontToLoad, nsIURI* aFontURI,
|
2014-10-02 02:32:05 +00:00
|
|
|
mozilla::dom::FontFaceSet* aFontFaceSet,
|
|
|
|
nsIChannel* aChannel);
|
2012-12-19 09:42:25 +00:00
|
|
|
|
2008-10-01 03:04:10 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2008-10-29 18:09:50 +00:00
|
|
|
NS_DECL_NSISTREAMLOADEROBSERVER
|
2008-10-01 03:04:10 +00:00
|
|
|
|
|
|
|
// initiate the load
|
2009-01-19 09:21:29 +00:00
|
|
|
nsresult Init();
|
2014-10-02 02:32:05 +00:00
|
|
|
// cancel the load and remove its reference to mFontFaceSet
|
2009-01-19 09:21:29 +00:00
|
|
|
void Cancel();
|
2008-10-01 03:04:10 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
void DropChannel() { mChannel = nullptr; }
|
2009-01-31 08:58:42 +00:00
|
|
|
|
2013-09-25 13:48:20 +00:00
|
|
|
void StartedLoading(nsIStreamLoader* aStreamLoader);
|
2011-01-05 21:48:48 +00:00
|
|
|
|
2013-09-25 13:48:20 +00:00
|
|
|
static void LoadTimerCallback(nsITimer* aTimer, void* aClosure);
|
2011-01-05 21:48:48 +00:00
|
|
|
|
2015-03-06 08:44:23 +00:00
|
|
|
gfxUserFontEntry* GetUserFontEntry() const { return mUserFontEntry; }
|
2009-01-31 08:58:42 +00:00
|
|
|
|
2014-06-23 22:40:01 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsFontFaceLoader();
|
|
|
|
|
2016-01-07 05:03:05 +00:00
|
|
|
// helper method for determining the font-display value
|
|
|
|
uint8_t GetFontDisplay();
|
|
|
|
|
2008-12-12 07:31:51 +00:00
|
|
|
private:
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<gfxUserFontEntry> mUserFontEntry;
|
2008-12-12 07:31:51 +00:00
|
|
|
nsCOMPtr<nsIURI> mFontURI;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<mozilla::dom::FontFaceSet> mFontFaceSet;
|
2009-01-19 09:21:29 +00:00
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
2011-01-05 21:48:48 +00:00
|
|
|
nsCOMPtr<nsITimer> mLoadTimer;
|
2015-09-10 10:24:34 +00:00
|
|
|
mozilla::TimeStamp mStartTime;
|
2013-09-25 13:48:20 +00:00
|
|
|
nsIStreamLoader* mStreamLoader;
|
2008-10-01 03:04:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsFontFaceLoader_h_) */
|