OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef RemoteFontFaceSource_h | 5 #ifndef RemoteFontFaceSource_h |
6 #define RemoteFontFaceSource_h | 6 #define RemoteFontFaceSource_h |
7 | 7 |
8 #include "core/css/CSSFontFaceSource.h" | 8 #include "core/css/CSSFontFaceSource.h" |
9 #include "core/fetch/FontResource.h" | 9 #include "core/fetch/FontResource.h" |
10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class FontLoader; | 14 class CSSFontSelector; |
15 | 15 |
16 enum FontDisplay { | 16 enum FontDisplay { |
17 FontDisplayAuto, | 17 FontDisplayAuto, |
18 FontDisplayBlock, | 18 FontDisplayBlock, |
19 FontDisplaySwap, | 19 FontDisplaySwap, |
20 FontDisplayFallback, | 20 FontDisplayFallback, |
21 FontDisplayOptional, | 21 FontDisplayOptional, |
22 FontDisplayEnumMax | 22 FontDisplayEnumMax |
23 }; | 23 }; |
24 | 24 |
25 class RemoteFontFaceSource final : public CSSFontFaceSource, public FontResource
Client { | 25 class RemoteFontFaceSource final : public CSSFontFaceSource, public FontResource
Client { |
26 USING_PRE_FINALIZER(RemoteFontFaceSource, dispose); | 26 USING_PRE_FINALIZER(RemoteFontFaceSource, dispose); |
27 public: | 27 public: |
28 enum DisplayPeriod { BlockPeriod, SwapPeriod, FailurePeriod }; | 28 enum DisplayPeriod { BlockPeriod, SwapPeriod, FailurePeriod }; |
29 | 29 |
30 explicit RemoteFontFaceSource(FontResource*, FontLoader*, FontDisplay); | 30 explicit RemoteFontFaceSource(FontResource*, CSSFontSelector*, FontDisplay); |
31 ~RemoteFontFaceSource() override; | 31 ~RemoteFontFaceSource() override; |
32 void dispose(); | 32 void dispose(); |
33 | 33 |
34 bool isLoading() const override; | 34 bool isLoading() const override; |
35 bool isLoaded() const override; | 35 bool isLoaded() const override; |
36 bool isValid() const override; | 36 bool isValid() const override; |
37 DisplayPeriod getDisplayPeriod() const { return m_period; } | 37 DisplayPeriod getDisplayPeriod() const { return m_period; } |
38 | 38 |
39 void beginLoadIfNeeded() override; | 39 void beginLoadIfNeeded() override; |
40 | 40 |
41 void didStartFontLoad(FontResource*) override; | |
42 void fontLoaded(FontResource*) override; | 41 void fontLoaded(FontResource*) override; |
43 void fontLoadShortLimitExceeded(FontResource*) override; | 42 void fontLoadShortLimitExceeded(FontResource*) override; |
44 void fontLoadLongLimitExceeded(FontResource*) override; | 43 void fontLoadLongLimitExceeded(FontResource*) override; |
45 String debugName() const override { return "RemoteFontFaceSource"; } | 44 String debugName() const override { return "RemoteFontFaceSource"; } |
46 | 45 |
47 // For UMA reporting | 46 // For UMA reporting |
48 bool hadBlankText() override { return m_histograms.hadBlankText(); } | 47 bool hadBlankText() override { return m_histograms.hadBlankText(); } |
49 void paintRequested() { m_histograms.fallbackFontPainted(m_period); } | 48 void paintRequested() { m_histograms.fallbackFontPainted(m_period); } |
50 | 49 |
51 DECLARE_VIRTUAL_TRACE(); | 50 DECLARE_VIRTUAL_TRACE(); |
(...skipping 20 matching lines...) Expand all Loading... |
72 void recordInterventionResult(bool triggered); | 71 void recordInterventionResult(bool triggered); |
73 double m_loadStartTime; | 72 double m_loadStartTime; |
74 double m_blankPaintTime; | 73 double m_blankPaintTime; |
75 bool m_isLongLimitExceeded; | 74 bool m_isLongLimitExceeded; |
76 }; | 75 }; |
77 | 76 |
78 void switchToSwapPeriod(); | 77 void switchToSwapPeriod(); |
79 void switchToFailurePeriod(); | 78 void switchToFailurePeriod(); |
80 | 79 |
81 Member<FontResource> m_font; | 80 Member<FontResource> m_font; |
82 Member<FontLoader> m_fontLoader; | 81 Member<CSSFontSelector> m_fontSelector; |
83 const FontDisplay m_display; | 82 const FontDisplay m_display; |
84 DisplayPeriod m_period; | 83 DisplayPeriod m_period; |
85 FontLoadHistograms m_histograms; | 84 FontLoadHistograms m_histograms; |
86 bool m_isInterventionTriggered; | 85 bool m_isInterventionTriggered; |
87 }; | 86 }; |
88 | 87 |
89 } // namespace blink | 88 } // namespace blink |
90 | 89 |
91 #endif | 90 #endif |
OLD | NEW |