OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 class SVGFontFaceElement; | 44 class SVGFontFaceElement; |
45 #endif | 45 #endif |
46 | 46 |
47 | 47 |
48 class CSSFontFaceSource : public FontResourceClient { | 48 class CSSFontFaceSource : public FontResourceClient { |
49 public: | 49 public: |
50 CSSFontFaceSource(const String&, FontResource* = 0); | 50 CSSFontFaceSource(const String&, FontResource* = 0); |
51 virtual ~CSSFontFaceSource(); | 51 virtual ~CSSFontFaceSource(); |
52 | 52 |
53 bool isLocal() const; | 53 bool isLocal() const; |
| 54 bool isLoading() const; |
54 bool isLoaded() const; | 55 bool isLoaded() const; |
55 bool isValid() const; | 56 bool isValid() const; |
56 | 57 |
57 const AtomicString& string() const { return m_string; } | 58 const AtomicString& string() const { return m_string; } |
58 | 59 |
59 void setFontFace(CSSFontFace* face) { m_face = face; } | 60 void setFontFace(CSSFontFace* face) { m_face = face; } |
60 | 61 |
61 virtual void didStartFontLoad(FontResource*) OVERRIDE; | 62 virtual void didStartFontLoad(FontResource*) OVERRIDE; |
62 virtual void fontLoaded(FontResource*); | 63 virtual void fontLoaded(FontResource*); |
63 | 64 |
64 PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheti
cBold, bool syntheticItalic, CSSFontSelector*); | 65 PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheti
cBold, bool syntheticItalic, CSSFontSelector*); |
65 | 66 |
66 void pruneTable(); | 67 void pruneTable(); |
67 | 68 |
68 #if ENABLE(SVG_FONTS) | 69 #if ENABLE(SVG_FONTS) |
69 SVGFontFaceElement* svgFontFaceElement() const; | 70 SVGFontFaceElement* svgFontFaceElement() const; |
70 void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement>); | 71 void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement>); |
71 bool isSVGFontFaceSource() const; | 72 bool isSVGFontFaceSource() const; |
72 void setHasExternalSVGFont(bool value) { m_hasExternalSVGFont = value; } | 73 void setHasExternalSVGFont(bool value) { m_hasExternalSVGFont = value; } |
73 #endif | 74 #endif |
74 | 75 |
75 bool isDecodeError() const; | 76 bool isDecodeError() const; |
76 bool ensureFontData(); | 77 bool ensureFontData(); |
77 bool isLocalFontAvailable(const FontDescription&); | 78 bool isLocalFontAvailable(const FontDescription&); |
78 void willUseFontData(); | 79 void willUseFontData(); |
| 80 void beginLoadingFontSoon(); |
79 | 81 |
80 private: | 82 private: |
| 83 typedef HashMap<unsigned, RefPtr<SimpleFontData> > FontDataTable; // The has
h key is composed of size synthetic styles. |
| 84 |
81 class FontLoadHistograms { | 85 class FontLoadHistograms { |
82 public: | 86 public: |
83 FontLoadHistograms() : m_loadStartTime(0) { } | 87 FontLoadHistograms() : m_loadStartTime(0) { } |
84 void willUseFontData(); | 88 void willUseFontData(); |
85 void loadStarted(); | 89 void loadStarted(); |
86 void recordLocalFont(bool loadSuccess); | 90 void recordLocalFont(bool loadSuccess); |
87 void recordRemoteFont(const FontResource*); | 91 void recordRemoteFont(const FontResource*); |
88 private: | 92 private: |
89 const char* histogramName(const FontResource*); | 93 const char* histogramName(const FontResource*); |
90 double m_loadStartTime; | 94 double m_loadStartTime; |
91 }; | 95 }; |
92 | 96 |
93 void startLoadingTimerFired(Timer<CSSFontFaceSource>*); | 97 void startLoadingTimerFired(Timer<CSSFontFaceSource>*); |
94 | 98 |
95 AtomicString m_string; // URI for remote, built-in font name for local. | 99 AtomicString m_string; // URI for remote, built-in font name for local. |
96 ResourcePtr<FontResource> m_font; // For remote fonts, a pointer to our cach
ed resource. | 100 ResourcePtr<FontResource> m_font; // For remote fonts, a pointer to our cach
ed resource. |
97 CSSFontFace* m_face; // Our owning font face. | 101 CSSFontFace* m_face; // Our owning font face. |
98 HashMap<unsigned, RefPtr<SimpleFontData> > m_fontDataTable; // The hash key
is composed of size synthetic styles. | 102 FontDataTable m_fontDataTable; |
99 FontLoadHistograms m_histograms; | 103 FontLoadHistograms m_histograms; |
100 | 104 |
101 #if ENABLE(SVG_FONTS) | 105 #if ENABLE(SVG_FONTS) |
102 RefPtr<SVGFontFaceElement> m_svgFontFaceElement; | 106 RefPtr<SVGFontFaceElement> m_svgFontFaceElement; |
103 RefPtr<SVGFontElement> m_externalSVGFontElement; | 107 RefPtr<SVGFontElement> m_externalSVGFontElement; |
104 bool m_hasExternalSVGFont; | 108 bool m_hasExternalSVGFont; |
105 #endif | 109 #endif |
106 }; | 110 }; |
107 | 111 |
108 } | 112 } |
109 | 113 |
110 #endif | 114 #endif |
OLD | NEW |