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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 { | 110 { |
111 visitor->trace(m_fontFaces); | 111 visitor->trace(m_fontFaces); |
112 visitor->trace(m_resolver); | 112 visitor->trace(m_resolver); |
113 LoadFontCallback::trace(visitor); | 113 LoadFontCallback::trace(visitor); |
114 } | 114 } |
115 | 115 |
116 FontFaceSet::FontFaceSet(Document& document) | 116 FontFaceSet::FontFaceSet(Document& document) |
117 : ActiveDOMObject(&document) | 117 : ActiveDOMObject(&document) |
118 , m_shouldFireLoadingEvent(false) | 118 , m_shouldFireLoadingEvent(false) |
119 , m_isLoading(false) | 119 , m_isLoading(false) |
120 , m_ready(new ReadyProperty(executionContext(), this, ReadyProperty::Ready)) | 120 , m_ready(new ReadyProperty(getExecutionContext(), this, ReadyProperty::Read
y)) |
121 , m_asyncRunner(AsyncMethodRunner<FontFaceSet>::create(this, &FontFaceSet::h
andlePendingEventsAndPromises)) | 121 , m_asyncRunner(AsyncMethodRunner<FontFaceSet>::create(this, &FontFaceSet::h
andlePendingEventsAndPromises)) |
122 { | 122 { |
123 suspendIfNeeded(); | 123 suspendIfNeeded(); |
124 } | 124 } |
125 | 125 |
126 FontFaceSet::~FontFaceSet() | 126 FontFaceSet::~FontFaceSet() |
127 { | 127 { |
128 #if !ENABLE(OILPAN) | 128 #if !ENABLE(OILPAN) |
129 stop(); | 129 stop(); |
130 #endif | 130 #endif |
131 } | 131 } |
132 | 132 |
133 Document* FontFaceSet::document() const | 133 Document* FontFaceSet::document() const |
134 { | 134 { |
135 return toDocument(executionContext()); | 135 return toDocument(getExecutionContext()); |
136 } | 136 } |
137 | 137 |
138 bool FontFaceSet::inActiveDocumentContext() const | 138 bool FontFaceSet::inActiveDocumentContext() const |
139 { | 139 { |
140 ExecutionContext* context = executionContext(); | 140 ExecutionContext* context = getExecutionContext(); |
141 return context && toDocument(context)->isActive(); | 141 return context && toDocument(context)->isActive(); |
142 } | 142 } |
143 | 143 |
144 void FontFaceSet::addFontFacesToFontFaceCache(FontFaceCache* fontFaceCache, CSSF
ontSelector* fontSelector) | 144 void FontFaceSet::addFontFacesToFontFaceCache(FontFaceCache* fontFaceCache, CSSF
ontSelector* fontSelector) |
145 { | 145 { |
146 for (const auto& fontFace : m_nonCSSConnectedFaces) | 146 for (const auto& fontFace : m_nonCSSConnectedFaces) |
147 fontFaceCache->addFontFace(fontSelector, fontFace, false); | 147 fontFaceCache->addFontFace(fontSelector, fontFace, false); |
148 } | 148 } |
149 | 149 |
150 const AtomicString& FontFaceSet::interfaceName() const | 150 const AtomicString& FontFaceSet::interfaceName() const |
151 { | 151 { |
152 return EventTargetNames::FontFaceSet; | 152 return EventTargetNames::FontFaceSet; |
153 } | 153 } |
154 | 154 |
155 ExecutionContext* FontFaceSet::executionContext() const | 155 ExecutionContext* FontFaceSet::getExecutionContext() const |
156 { | 156 { |
157 return ActiveDOMObject::executionContext(); | 157 return ActiveDOMObject::getExecutionContext(); |
158 } | 158 } |
159 | 159 |
160 AtomicString FontFaceSet::status() const | 160 AtomicString FontFaceSet::status() const |
161 { | 161 { |
162 DEFINE_STATIC_LOCAL(AtomicString, loading, ("loading", AtomicString::Constru
ctFromLiteral)); | 162 DEFINE_STATIC_LOCAL(AtomicString, loading, ("loading", AtomicString::Constru
ctFromLiteral)); |
163 DEFINE_STATIC_LOCAL(AtomicString, loaded, ("loaded", AtomicString::Construct
FromLiteral)); | 163 DEFINE_STATIC_LOCAL(AtomicString, loaded, ("loaded", AtomicString::Construct
FromLiteral)); |
164 return m_isLoading ? loading : loaded; | 164 return m_isLoading ? loading : loaded; |
165 } | 165 } |
166 | 166 |
167 void FontFaceSet::handlePendingEventsAndPromisesSoon() | 167 void FontFaceSet::handlePendingEventsAndPromisesSoon() |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 FontFaceCache* fontFaceCache = document()->styleEngine().fontSelector()->fon
tFaceCache(); | 386 FontFaceCache* fontFaceCache = document()->styleEngine().fontSelector()->fon
tFaceCache(); |
387 FontFaceArray faces; | 387 FontFaceArray faces; |
388 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next(
)) { | 388 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next(
)) { |
389 CSSSegmentedFontFace* segmentedFontFace = fontFaceCache->get(font.fontDe
scription(), f->family()); | 389 CSSSegmentedFontFace* segmentedFontFace = fontFaceCache->get(font.fontDe
scription(), f->family()); |
390 if (segmentedFontFace) | 390 if (segmentedFontFace) |
391 segmentedFontFace->match(text, faces); | 391 segmentedFontFace->match(text, faces); |
392 } | 392 } |
393 | 393 |
394 RefPtrWillBeRawPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolv
er::create(faces, scriptState); | 394 RefPtrWillBeRawPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolv
er::create(faces, scriptState); |
395 ScriptPromise promise = resolver->promise(); | 395 ScriptPromise promise = resolver->promise(); |
396 resolver->loadFonts(executionContext()); // After this, resolver->promise()
may return null. | 396 resolver->loadFonts(getExecutionContext()); // After this, resolver->promise
() may return null. |
397 return promise; | 397 return promise; |
398 } | 398 } |
399 | 399 |
400 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS
tate& exceptionState) | 400 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS
tate& exceptionState) |
401 { | 401 { |
402 if (!inActiveDocumentContext()) | 402 if (!inActiveDocumentContext()) |
403 return false; | 403 return false; |
404 | 404 |
405 Font font; | 405 Font font; |
406 if (!resolveFontStyle(fontString, font)) { | 406 if (!resolveFontStyle(fontString, font)) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 visitor->trace(m_failedFonts); | 545 visitor->trace(m_failedFonts); |
546 visitor->trace(m_nonCSSConnectedFaces); | 546 visitor->trace(m_nonCSSConnectedFaces); |
547 visitor->trace(m_asyncRunner); | 547 visitor->trace(m_asyncRunner); |
548 HeapSupplement<Document>::trace(visitor); | 548 HeapSupplement<Document>::trace(visitor); |
549 #endif | 549 #endif |
550 EventTargetWithInlineData::trace(visitor); | 550 EventTargetWithInlineData::trace(visitor); |
551 ActiveDOMObject::trace(visitor); | 551 ActiveDOMObject::trace(visitor); |
552 } | 552 } |
553 | 553 |
554 } // namespace blink | 554 } // namespace blink |
OLD | NEW |