| 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 void FontFaceSet::add(FontFace* fontFace, ExceptionState& exceptionState) | 260 PassRefPtrWillBeRawPtr<FontFaceSet> FontFaceSet::addForBinding(ScriptState*, Fon
tFace* fontFace, ExceptionState& exceptionState) |
| 261 { | 261 { |
| 262 if (!inActiveDocumentContext()) | 262 if (!inActiveDocumentContext()) |
| 263 return; | 263 return this; |
| 264 if (!fontFace) { | 264 if (!fontFace) { |
| 265 exceptionState.throwTypeError("The argument is not a FontFace."); | 265 exceptionState.throwTypeError("The argument is not a FontFace."); |
| 266 return; | 266 return this; |
| 267 } | 267 } |
| 268 if (m_nonCSSConnectedFaces.contains(fontFace)) | 268 if (m_nonCSSConnectedFaces.contains(fontFace)) |
| 269 return; | 269 return this; |
| 270 if (isCSSConnectedFontFace(fontFace)) { | 270 if (isCSSConnectedFontFace(fontFace)) { |
| 271 exceptionState.throwDOMException(InvalidModificationError, "Cannot add a
CSS-connected FontFace."); | 271 exceptionState.throwDOMException(InvalidModificationError, "Cannot add a
CSS-connected FontFace."); |
| 272 return; | 272 return this; |
| 273 } | 273 } |
| 274 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); | 274 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); |
| 275 m_nonCSSConnectedFaces.add(fontFace); | 275 m_nonCSSConnectedFaces.add(fontFace); |
| 276 fontSelector->fontFaceCache()->addFontFace(fontSelector, fontFace, false); | 276 fontSelector->fontFaceCache()->addFontFace(fontSelector, fontFace, false); |
| 277 if (fontFace->loadStatus() == FontFace::Loading) | 277 if (fontFace->loadStatus() == FontFace::Loading) |
| 278 addToLoadingFonts(fontFace); | 278 addToLoadingFonts(fontFace); |
| 279 fontSelector->fontFaceInvalidated(); | 279 fontSelector->fontFaceInvalidated(); |
| 280 return this; |
| 280 } | 281 } |
| 281 | 282 |
| 282 void FontFaceSet::clear() | 283 void FontFaceSet::clearForBinding(ScriptState*, ExceptionState&) |
| 283 { | 284 { |
| 284 if (!inActiveDocumentContext() || m_nonCSSConnectedFaces.isEmpty()) | 285 if (!inActiveDocumentContext() || m_nonCSSConnectedFaces.isEmpty()) |
| 285 return; | 286 return; |
| 286 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); | 287 CSSFontSelector* fontSelector = document()->styleEngine().fontSelector(); |
| 287 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); | 288 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); |
| 288 for (const auto& fontFace : m_nonCSSConnectedFaces) { | 289 for (const auto& fontFace : m_nonCSSConnectedFaces) { |
| 289 fontFaceCache->removeFontFace(fontFace.get(), false); | 290 fontFaceCache->removeFontFace(fontFace.get(), false); |
| 290 if (fontFace->loadStatus() == FontFace::Loading) | 291 if (fontFace->loadStatus() == FontFace::Loading) |
| 291 removeFromLoadingFonts(fontFace); | 292 removeFromLoadingFonts(fontFace); |
| 292 } | 293 } |
| 293 m_nonCSSConnectedFaces.clear(); | 294 m_nonCSSConnectedFaces.clear(); |
| 294 fontSelector->fontFaceInvalidated(); | 295 fontSelector->fontFaceInvalidated(); |
| 295 } | 296 } |
| 296 | 297 |
| 297 bool FontFaceSet::remove(FontFace* fontFace, ExceptionState& exceptionState) | 298 bool FontFaceSet::deleteForBinding(ScriptState*, FontFace* fontFace, ExceptionSt
ate& exceptionState) |
| 298 { | 299 { |
| 299 if (!inActiveDocumentContext()) | 300 if (!inActiveDocumentContext()) |
| 300 return false; | 301 return false; |
| 301 if (!fontFace) { | 302 if (!fontFace) { |
| 302 exceptionState.throwTypeError("The argument is not a FontFace."); | 303 exceptionState.throwTypeError("The argument is not a FontFace."); |
| 303 return false; | 304 return false; |
| 304 } | 305 } |
| 305 WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>::iterator it = m_nonCSSC
onnectedFaces.find(fontFace); | 306 WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>::iterator it = m_nonCSSC
onnectedFaces.find(fontFace); |
| 306 if (it != m_nonCSSConnectedFaces.end()) { | 307 if (it != m_nonCSSConnectedFaces.end()) { |
| 307 m_nonCSSConnectedFaces.remove(it); | 308 m_nonCSSConnectedFaces.remove(it); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 visitor->trace(m_loadedFonts); | 553 visitor->trace(m_loadedFonts); |
| 553 visitor->trace(m_failedFonts); | 554 visitor->trace(m_failedFonts); |
| 554 visitor->trace(m_nonCSSConnectedFaces); | 555 visitor->trace(m_nonCSSConnectedFaces); |
| 555 HeapSupplement<Document>::trace(visitor); | 556 HeapSupplement<Document>::trace(visitor); |
| 556 #endif | 557 #endif |
| 557 EventTargetWithInlineData::trace(visitor); | 558 EventTargetWithInlineData::trace(visitor); |
| 558 ActiveDOMObject::trace(visitor); | 559 ActiveDOMObject::trace(visitor); |
| 559 } | 560 } |
| 560 | 561 |
| 561 } // namespace blink | 562 } // namespace blink |
| OLD | NEW |