Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: Source/core/css/FontFace.cpp

Issue 236123007: Use ScriptPromiseResolverWithContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/css/FontFaceSet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/css/FontFace.h" 32 #include "core/css/FontFace.h"
33 33
34 #include "CSSValueKeywords.h" 34 #include "CSSValueKeywords.h"
35 #include "FontFamilyNames.h" 35 #include "FontFamilyNames.h"
36 #include "bindings/v8/Dictionary.h" 36 #include "bindings/v8/Dictionary.h"
37 #include "bindings/v8/ExceptionState.h" 37 #include "bindings/v8/ExceptionState.h"
38 #include "bindings/v8/NewScriptState.h" 38 #include "bindings/v8/NewScriptState.h"
39 #include "bindings/v8/ScriptPromiseResolver.h" 39 #include "bindings/v8/ScriptPromiseResolverWithContext.h"
40 #include "core/css/BinaryDataFontFaceSource.h" 40 #include "core/css/BinaryDataFontFaceSource.h"
41 #include "core/css/CSSFontFace.h" 41 #include "core/css/CSSFontFace.h"
42 #include "core/css/CSSFontFaceSrcValue.h" 42 #include "core/css/CSSFontFaceSrcValue.h"
43 #include "core/css/CSSFontSelector.h" 43 #include "core/css/CSSFontSelector.h"
44 #include "core/css/CSSPrimitiveValue.h" 44 #include "core/css/CSSPrimitiveValue.h"
45 #include "core/css/CSSUnicodeRangeValue.h" 45 #include "core/css/CSSUnicodeRangeValue.h"
46 #include "core/css/CSSValueList.h" 46 #include "core/css/CSSValueList.h"
47 #include "core/css/LocalFontFaceSource.h" 47 #include "core/css/LocalFontFaceSource.h"
48 #include "core/css/RemoteFontFaceSource.h" 48 #include "core/css/RemoteFontFaceSource.h"
49 #include "core/css/StylePropertySet.h" 49 #include "core/css/StylePropertySet.h"
(...skipping 15 matching lines...) Expand all
65 65
66 class FontFaceReadyPromiseResolver { 66 class FontFaceReadyPromiseResolver {
67 public: 67 public:
68 static PassOwnPtr<FontFaceReadyPromiseResolver> create(ExecutionContext* con text) 68 static PassOwnPtr<FontFaceReadyPromiseResolver> create(ExecutionContext* con text)
69 { 69 {
70 return adoptPtr(new FontFaceReadyPromiseResolver(context)); 70 return adoptPtr(new FontFaceReadyPromiseResolver(context));
71 } 71 }
72 72
73 void resolve(PassRefPtr<FontFace> fontFace) 73 void resolve(PassRefPtr<FontFace> fontFace)
74 { 74 {
75 NewScriptState::Scope scope(m_scriptState.get());
76 switch (fontFace->loadStatus()) { 75 switch (fontFace->loadStatus()) {
77 case FontFace::Loaded: 76 case FontFace::Loaded:
78 m_resolver->resolve(fontFace); 77 m_resolver->resolve(fontFace);
79 break; 78 break;
80 case FontFace::Error: 79 case FontFace::Error:
81 m_resolver->reject(fontFace->error()); 80 m_resolver->reject(fontFace->error());
82 break; 81 break;
83 default: 82 default:
84 ASSERT_NOT_REACHED(); 83 ASSERT_NOT_REACHED();
85 } 84 }
86 } 85 }
87 86
88 ScriptPromise promise() { return m_resolver->promise(); } 87 ScriptPromise promise() { return m_resolver->promise(); }
89 88
90 private: 89 private:
91 FontFaceReadyPromiseResolver(ExecutionContext* context) 90 FontFaceReadyPromiseResolver(ExecutionContext* context)
92 : m_scriptState(NewScriptState::current(toIsolate(context))) 91 : m_resolver(ScriptPromiseResolverWithContext::create(NewScriptState::cu rrent(toIsolate(context))))
93 , m_resolver(ScriptPromiseResolver::create(context))
94 { 92 {
95 } 93 }
96 94
97 RefPtr<NewScriptState> m_scriptState; 95 RefPtr<ScriptPromiseResolverWithContext> m_resolver;
98 RefPtr<ScriptPromiseResolver> m_resolver;
99 }; 96 };
100 97
101 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID) 98 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID)
102 { 99 {
103 if (s.isEmpty()) 100 if (s.isEmpty())
104 return nullptr; 101 return nullptr;
105 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create(); 102 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create();
106 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document ); 103 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, *document );
107 return parsedStyle->getPropertyCSSValue(propertyID); 104 return parsedStyle->getPropertyCSSValue(propertyID);
108 } 105 }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 visitor->trace(m_featureSettings); 627 visitor->trace(m_featureSettings);
631 visitor->trace(m_error); 628 visitor->trace(m_error);
632 } 629 }
633 630
634 bool FontFace::hadBlankText() const 631 bool FontFace::hadBlankText() const
635 { 632 {
636 return m_cssFontFace->hadBlankText(); 633 return m_cssFontFace->hadBlankText();
637 } 634 }
638 635
639 } // namespace WebCore 636 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/FontFaceSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698