OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class Dictionary; | 48 class Dictionary; |
49 class Document; | 49 class Document; |
50 class Event; | 50 class Event; |
51 class ExceptionState; | 51 class ExceptionState; |
52 class Font; | 52 class Font; |
53 class FontResource; | 53 class FontResource; |
54 class FontsReadyPromiseResolver; | 54 class FontsReadyPromiseResolver; |
55 class LoadFontPromiseResolver; | 55 class LoadFontPromiseResolver; |
56 class ScriptExecutionContext; | 56 class ScriptExecutionContext; |
57 | 57 |
58 class FontFaceSet : public RefCounted<FontFaceSet>, public ActiveDOMObject, publ
ic EventTarget { | 58 class FontFaceSet : public RefCounted<FontFaceSet>, public ActiveDOMObject, publ
ic EventTargetWithInlineData { |
59 public: | 59 public: |
60 static PassRefPtr<FontFaceSet> create(Document* document) | 60 static PassRefPtr<FontFaceSet> create(Document* document) |
61 { | 61 { |
62 return adoptRef<FontFaceSet>(new FontFaceSet(document)); | 62 return adoptRef<FontFaceSet>(new FontFaceSet(document)); |
63 } | 63 } |
64 virtual ~FontFaceSet(); | 64 virtual ~FontFaceSet(); |
65 | 65 |
66 DEFINE_ATTRIBUTE_EVENT_LISTENER(loading); | 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(loading); |
67 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadingdone); | 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadingdone); |
68 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadingerror); | 68 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadingerror); |
69 | 69 |
70 Vector<RefPtr<FontFace> > match(const String& font, const String& text, Exce
ptionState&); | 70 Vector<RefPtr<FontFace> > match(const String& font, const String& text, Exce
ptionState&); |
71 bool check(const String& font, const String& text, ExceptionState&); | 71 bool check(const String& font, const String& text, ExceptionState&); |
72 ScriptPromise load(const String& font, const String& text, ExceptionState&); | 72 ScriptPromise load(const String& font, const String& text, ExceptionState&); |
73 ScriptPromise ready(); | 73 ScriptPromise ready(); |
74 | 74 |
75 AtomicString status() const; | 75 AtomicString status() const; |
76 | 76 |
77 virtual ScriptExecutionContext* scriptExecutionContext() const; | 77 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
78 virtual const AtomicString& interfaceName() const; | 78 virtual const AtomicString& interfaceName() const OVERRIDE; |
79 | 79 |
80 using RefCounted<FontFaceSet>::ref; | 80 using RefCounted<FontFaceSet>::ref; |
81 using RefCounted<FontFaceSet>::deref; | 81 using RefCounted<FontFaceSet>::deref; |
82 | 82 |
83 Document* document() const; | 83 Document* document() const; |
84 | 84 |
85 void didLayout(); | 85 void didLayout(); |
86 void beginFontLoading(FontFace*); | 86 void beginFontLoading(FontFace*); |
87 void fontLoaded(FontFace*); | 87 void fontLoaded(FontFace*); |
88 void loadError(FontFace*); | 88 void loadError(FontFace*); |
89 void scheduleResolve(LoadFontPromiseResolver*); | 89 void scheduleResolve(LoadFontPromiseResolver*); |
90 | 90 |
91 private: | 91 private: |
92 class FontLoadHistogram { | 92 class FontLoadHistogram { |
93 public: | 93 public: |
94 FontLoadHistogram() : m_count(0), m_recorded(false) { } | 94 FontLoadHistogram() : m_count(0), m_recorded(false) { } |
95 void incrementCount() { m_count++; } | 95 void incrementCount() { m_count++; } |
96 void record(); | 96 void record(); |
97 | 97 |
98 private: | 98 private: |
99 int m_count; | 99 int m_count; |
100 bool m_recorded; | 100 bool m_recorded; |
101 }; | 101 }; |
102 | 102 |
103 FontFaceSet(Document*); | 103 FontFaceSet(Document*); |
104 | 104 |
105 virtual void refEventTarget() { ref(); } | 105 virtual void refEventTarget() OVERRIDE { ref(); } |
106 virtual void derefEventTarget() { deref(); } | 106 virtual void derefEventTarget() OVERRIDE { deref(); } |
107 virtual EventTargetData* eventTargetData(); | |
108 virtual EventTargetData* ensureEventTargetData(); | |
109 | 107 |
110 void scheduleEvent(PassRefPtr<Event>); | 108 void scheduleEvent(PassRefPtr<Event>); |
111 void queueDoneEvent(FontFace*); | 109 void queueDoneEvent(FontFace*); |
112 void firePendingEvents(); | 110 void firePendingEvents(); |
113 void resolvePendingLoadPromises(); | 111 void resolvePendingLoadPromises(); |
114 void fireDoneEventIfPossible(); | 112 void fireDoneEventIfPossible(); |
115 bool resolveFontStyle(const String&, Font&); | 113 bool resolveFontStyle(const String&, Font&); |
116 void timerFired(Timer<FontFaceSet>*); | 114 void timerFired(Timer<FontFaceSet>*); |
117 | 115 |
118 EventTargetData m_eventTargetData; | |
119 unsigned m_loadingCount; | 116 unsigned m_loadingCount; |
120 Vector<RefPtr<Event> > m_pendingEvents; | 117 Vector<RefPtr<Event> > m_pendingEvents; |
121 Vector<RefPtr<LoadFontPromiseResolver> > m_pendingLoadResolvers; | 118 Vector<RefPtr<LoadFontPromiseResolver> > m_pendingLoadResolvers; |
122 Vector<OwnPtr<FontsReadyPromiseResolver> > m_readyResolvers; | 119 Vector<OwnPtr<FontsReadyPromiseResolver> > m_readyResolvers; |
123 FontFaceArray m_loadedFonts; | 120 FontFaceArray m_loadedFonts; |
124 FontFaceArray m_failedFonts; | 121 FontFaceArray m_failedFonts; |
125 bool m_shouldFireDoneEvent; | 122 bool m_shouldFireDoneEvent; |
126 Timer<FontFaceSet> m_timer; | 123 Timer<FontFaceSet> m_timer; |
127 FontLoadHistogram m_histogram; | 124 FontLoadHistogram m_histogram; |
128 }; | 125 }; |
129 | 126 |
130 } // namespace WebCore | 127 } // namespace WebCore |
131 | 128 |
132 #endif // FontFaceSet_h | 129 #endif // FontFaceSet_h |
OLD | NEW |