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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 m_loadingFonts.remove(fontFace); | 250 m_loadingFonts.remove(fontFace); |
251 if (m_loadingFonts.isEmpty()) | 251 if (m_loadingFonts.isEmpty()) |
252 handlePendingEventsAndPromisesSoon(); | 252 handlePendingEventsAndPromisesSoon(); |
253 } | 253 } |
254 | 254 |
255 ScriptPromise FontFaceSet::ready(ScriptState* scriptState) | 255 ScriptPromise FontFaceSet::ready(ScriptState* scriptState) |
256 { | 256 { |
257 return m_ready->promise(scriptState->world()); | 257 return m_ready->promise(scriptState->world()); |
258 } | 258 } |
259 | 259 |
260 PassRefPtrWillBeRawPtr<FontFaceSet> FontFaceSet::addForBinding(ScriptState*, Fon
tFace* fontFace, ExceptionState& exceptionState) | 260 PassRefPtrWillBeRawPtr<FontFaceSet> FontFaceSet::addForBinding(ScriptState*, Fon
tFace* fontFace, ExceptionState&) |
261 { | 261 { |
| 262 ASSERT(fontFace); |
262 if (!inActiveDocumentContext()) | 263 if (!inActiveDocumentContext()) |
263 return this; | 264 return this; |
264 if (!fontFace) { | |
265 exceptionState.throwTypeError("The argument is not a FontFace."); | |
266 return this; | |
267 } | |
268 if (m_nonCSSConnectedFaces.contains(fontFace)) | 265 if (m_nonCSSConnectedFaces.contains(fontFace)) |
269 return this; | 266 return this; |
270 if (isCSSConnectedFontFace(fontFace)) | 267 if (isCSSConnectedFontFace(fontFace)) |
271 return this; | 268 return this; |
272 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); | 269 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); |
273 m_nonCSSConnectedFaces.add(fontFace); | 270 m_nonCSSConnectedFaces.add(fontFace); |
274 fontSelector->fontFaceCache()->addFontFace(fontSelector, fontFace, false); | 271 fontSelector->fontFaceCache()->addFontFace(fontSelector, fontFace, false); |
275 if (fontFace->loadStatus() == FontFace::Loading) | 272 if (fontFace->loadStatus() == FontFace::Loading) |
276 addToLoadingFonts(fontFace); | 273 addToLoadingFonts(fontFace); |
277 fontSelector->fontFaceInvalidated(); | 274 fontSelector->fontFaceInvalidated(); |
278 return this; | 275 return this; |
279 } | 276 } |
280 | 277 |
281 void FontFaceSet::clearForBinding(ScriptState*, ExceptionState&) | 278 void FontFaceSet::clearForBinding(ScriptState*, ExceptionState&) |
282 { | 279 { |
283 if (!inActiveDocumentContext() || m_nonCSSConnectedFaces.isEmpty()) | 280 if (!inActiveDocumentContext() || m_nonCSSConnectedFaces.isEmpty()) |
284 return; | 281 return; |
285 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); | 282 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); |
286 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); | 283 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); |
287 for (const auto& fontFace : m_nonCSSConnectedFaces) { | 284 for (const auto& fontFace : m_nonCSSConnectedFaces) { |
288 fontFaceCache->removeFontFace(fontFace.get(), false); | 285 fontFaceCache->removeFontFace(fontFace.get(), false); |
289 if (fontFace->loadStatus() == FontFace::Loading) | 286 if (fontFace->loadStatus() == FontFace::Loading) |
290 removeFromLoadingFonts(fontFace); | 287 removeFromLoadingFonts(fontFace); |
291 } | 288 } |
292 m_nonCSSConnectedFaces.clear(); | 289 m_nonCSSConnectedFaces.clear(); |
293 fontSelector->fontFaceInvalidated(); | 290 fontSelector->fontFaceInvalidated(); |
294 } | 291 } |
295 | 292 |
296 bool FontFaceSet::deleteForBinding(ScriptState*, FontFace* fontFace, ExceptionSt
ate& exceptionState) | 293 bool FontFaceSet::deleteForBinding(ScriptState*, FontFace* fontFace, ExceptionSt
ate&) |
297 { | 294 { |
| 295 ASSERT(fontFace); |
298 if (!inActiveDocumentContext()) | 296 if (!inActiveDocumentContext()) |
299 return false; | 297 return false; |
300 if (!fontFace) { | |
301 exceptionState.throwTypeError("The argument is not a FontFace."); | |
302 return false; | |
303 } | |
304 WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>::iterator it = m_nonCSSC
onnectedFaces.find(fontFace); | 298 WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>::iterator it = m_nonCSSC
onnectedFaces.find(fontFace); |
305 if (it != m_nonCSSConnectedFaces.end()) { | 299 if (it != m_nonCSSConnectedFaces.end()) { |
306 m_nonCSSConnectedFaces.remove(it); | 300 m_nonCSSConnectedFaces.remove(it); |
307 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector()
; | 301 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector()
; |
308 fontSelector->fontFaceCache()->removeFontFace(fontFace, false); | 302 fontSelector->fontFaceCache()->removeFontFace(fontFace, false); |
309 if (fontFace->loadStatus() == FontFace::Loading) | 303 if (fontFace->loadStatus() == FontFace::Loading) |
310 removeFromLoadingFonts(fontFace); | 304 removeFromLoadingFonts(fontFace); |
311 fontSelector->fontFaceInvalidated(); | 305 fontSelector->fontFaceInvalidated(); |
312 return true; | 306 return true; |
313 } | 307 } |
314 return false; | 308 return false; |
315 } | 309 } |
316 | 310 |
317 bool FontFaceSet::hasForBinding(ScriptState*, FontFace* fontFace, ExceptionState
& exceptionState) const | 311 bool FontFaceSet::hasForBinding(ScriptState*, FontFace* fontFace, ExceptionState
&) const |
318 { | 312 { |
| 313 ASSERT(fontFace); |
319 if (!inActiveDocumentContext()) | 314 if (!inActiveDocumentContext()) |
320 return false; | 315 return false; |
321 if (!fontFace) { | |
322 exceptionState.throwTypeError("The argument is not a FontFace."); | |
323 return false; | |
324 } | |
325 return m_nonCSSConnectedFaces.contains(fontFace) || isCSSConnectedFontFace(f
ontFace); | 316 return m_nonCSSConnectedFaces.contains(fontFace) || isCSSConnectedFontFace(f
ontFace); |
326 } | 317 } |
327 | 318 |
328 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& FontFaceSet::cssConne
ctedFontFaceList() const | 319 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& FontFaceSet::cssConne
ctedFontFaceList() const |
329 { | 320 { |
330 Document* d = document(); | 321 Document* d = document(); |
331 d->ensureStyleResolver(); // Flush pending style changes. | 322 d->ensureStyleResolver(); // Flush pending style changes. |
332 return d->styleEngine().fontSelector()->fontFaceCache()->cssConnectedFontFac
es(); | 323 return d->styleEngine().fontSelector()->fontFaceCache()->cssConnectedFontFac
es(); |
333 } | 324 } |
334 | 325 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 visitor->trace(m_loadedFonts); | 540 visitor->trace(m_loadedFonts); |
550 visitor->trace(m_failedFonts); | 541 visitor->trace(m_failedFonts); |
551 visitor->trace(m_nonCSSConnectedFaces); | 542 visitor->trace(m_nonCSSConnectedFaces); |
552 HeapSupplement<Document>::trace(visitor); | 543 HeapSupplement<Document>::trace(visitor); |
553 #endif | 544 #endif |
554 EventTargetWithInlineData::trace(visitor); | 545 EventTargetWithInlineData::trace(visitor); |
555 ActiveDOMObject::trace(visitor); | 546 ActiveDOMObject::trace(visitor); |
556 } | 547 } |
557 | 548 |
558 } // namespace blink | 549 } // namespace blink |
OLD | NEW |