| 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 | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "core/frame/Settings.h" | 57 #include "core/frame/Settings.h" |
| 58 #include "core/svg/SVGFontFaceElement.h" | 58 #include "core/svg/SVGFontFaceElement.h" |
| 59 #include "core/svg/SVGFontFaceSource.h" | 59 #include "core/svg/SVGFontFaceSource.h" |
| 60 #include "core/svg/SVGRemoteFontFaceSource.h" | 60 #include "core/svg/SVGRemoteFontFaceSource.h" |
| 61 #include "platform/SharedBuffer.h" | 61 #include "platform/SharedBuffer.h" |
| 62 | 62 |
| 63 namespace WebCore { | 63 namespace WebCore { |
| 64 | 64 |
| 65 class FontFaceReadyPromiseResolver { | 65 class FontFaceReadyPromiseResolver { |
| 66 public: | 66 public: |
| 67 static PassOwnPtr<FontFaceReadyPromiseResolver> create(ExecutionContext* con
text) | 67 static PassOwnPtr<FontFaceReadyPromiseResolver> create(ScriptState* scriptSt
ate) |
| 68 { | 68 { |
| 69 return adoptPtr(new FontFaceReadyPromiseResolver(context)); | 69 return adoptPtr(new FontFaceReadyPromiseResolver(scriptState)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void resolve(PassRefPtrWillBeRawPtr<FontFace> fontFace) | 72 void resolve(PassRefPtrWillBeRawPtr<FontFace> fontFace) |
| 73 { | 73 { |
| 74 switch (fontFace->loadStatus()) { | 74 switch (fontFace->loadStatus()) { |
| 75 case FontFace::Loaded: | 75 case FontFace::Loaded: |
| 76 m_resolver->resolve(fontFace); | 76 m_resolver->resolve(fontFace); |
| 77 break; | 77 break; |
| 78 case FontFace::Error: | 78 case FontFace::Error: |
| 79 m_resolver->reject(fontFace->error()); | 79 m_resolver->reject(fontFace->error()); |
| 80 break; | 80 break; |
| 81 default: | 81 default: |
| 82 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 ScriptPromise promise() { return m_resolver->promise(); } | 86 ScriptPromise promise() { return m_resolver->promise(); } |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 FontFaceReadyPromiseResolver(ExecutionContext* context) | 89 FontFaceReadyPromiseResolver(ScriptState* scriptState) |
| 90 : m_resolver(ScriptPromiseResolverWithContext::create(ScriptState::curre
nt(toIsolate(context)))) | 90 : m_resolver(ScriptPromiseResolverWithContext::create(scriptState)) |
| 91 { | 91 { |
| 92 } | 92 } |
| 93 | 93 |
| 94 RefPtr<ScriptPromiseResolverWithContext> m_resolver; | 94 RefPtr<ScriptPromiseResolverWithContext> m_resolver; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& s, CSSPropertyID propertyID) | 97 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& s, CSSPropertyID propertyID) |
| 98 { | 98 { |
| 99 if (s.isEmpty()) | 99 if (s.isEmpty()) |
| 100 return nullptr; | 100 return nullptr; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 m_callbacks.swap(callbacks); | 382 m_callbacks.swap(callbacks); |
| 383 for (size_t i = 0; i < callbacks.size(); ++i) { | 383 for (size_t i = 0; i < callbacks.size(); ++i) { |
| 384 if (m_status == Loaded) | 384 if (m_status == Loaded) |
| 385 callbacks[i]->notifyLoaded(this); | 385 callbacks[i]->notifyLoaded(this); |
| 386 else | 386 else |
| 387 callbacks[i]->notifyError(this); | 387 callbacks[i]->notifyError(this); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 ScriptPromise FontFace::load(ExecutionContext* context) | 392 ScriptPromise FontFace::load(ScriptState* scriptState) |
| 393 { | 393 { |
| 394 OwnPtr<FontFaceReadyPromiseResolver> resolver = FontFaceReadyPromiseResolver
::create(context); | 394 OwnPtr<FontFaceReadyPromiseResolver> resolver = FontFaceReadyPromiseResolver
::create(scriptState); |
| 395 ScriptPromise promise = resolver->promise(); | 395 ScriptPromise promise = resolver->promise(); |
| 396 if (m_status == Loaded || m_status == Error) | 396 if (m_status == Loaded || m_status == Error) |
| 397 resolver->resolve(this); | 397 resolver->resolve(this); |
| 398 else | 398 else |
| 399 m_readyResolvers.append(resolver.release()); | 399 m_readyResolvers.append(resolver.release()); |
| 400 | 400 |
| 401 loadInternal(context); | 401 loadInternal(scriptState->executionContext()); |
| 402 return promise; | 402 return promise; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void FontFace::loadWithCallback(PassRefPtrWillBeRawPtr<LoadFontCallback> callbac
k, ExecutionContext* context) | 405 void FontFace::loadWithCallback(PassRefPtrWillBeRawPtr<LoadFontCallback> callbac
k, ExecutionContext* context) |
| 406 { | 406 { |
| 407 loadInternal(context); | 407 loadInternal(context); |
| 408 if (m_status == Loaded) | 408 if (m_status == Loaded) |
| 409 callback->notifyLoaded(this); | 409 callback->notifyLoaded(this); |
| 410 else if (m_status == Error) | 410 else if (m_status == Error) |
| 411 callback->notifyError(this); | 411 callback->notifyError(this); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 visitor->trace(m_cssFontFace); | 622 visitor->trace(m_cssFontFace); |
| 623 visitor->trace(m_callbacks); | 623 visitor->trace(m_callbacks); |
| 624 } | 624 } |
| 625 | 625 |
| 626 bool FontFace::hadBlankText() const | 626 bool FontFace::hadBlankText() const |
| 627 { | 627 { |
| 628 return m_cssFontFace->hadBlankText(); | 628 return m_cssFontFace->hadBlankText(); |
| 629 } | 629 } |
| 630 | 630 |
| 631 } // namespace WebCore | 631 } // namespace WebCore |
| OLD | NEW |