| Index: third_party/WebKit/Source/core/css/FontFaceSet.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/FontFaceSet.cpp b/third_party/WebKit/Source/core/css/FontFaceSet.cpp
|
| index e0c6c7f57d5db04227694db60bbc390c76f22fb3..3de2ed2322c448c2cf6620d60fd22ea4a043bfb8 100644
|
| --- a/third_party/WebKit/Source/core/css/FontFaceSet.cpp
|
| +++ b/third_party/WebKit/Source/core/css/FontFaceSet.cpp
|
| @@ -25,13 +25,16 @@
|
|
|
| #include "core/css/FontFaceSet.h"
|
|
|
| +#include "bindings/core/v8/CallbackPromiseAdapter.h"
|
| #include "bindings/core/v8/Dictionary.h"
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| #include "bindings/core/v8/ScriptState.h"
|
| #include "core/css/CSSFontSelector.h"
|
| #include "core/css/CSSSegmentedFontFace.h"
|
| #include "core/css/FontFaceCache.h"
|
| +#include "core/css/FontFaceDescriptors.h"
|
| #include "core/css/FontFaceSetLoadEvent.h"
|
| +#include "core/css/LocalFontFace.h"
|
| #include "core/css/StylePropertySet.h"
|
| #include "core/css/parser/CSSParser.h"
|
| #include "core/css/resolver/StyleResolver.h"
|
| @@ -41,6 +44,9 @@
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/style/StyleInheritedData.h"
|
| #include "platform/Histogram.h"
|
| +#include "public/platform/Platform.h"
|
| +#include "public/platform/modules/font_access/WebFontAccess.h"
|
| +#include "public/platform/modules/font_access/WebFontAccessDescription.h"
|
|
|
| namespace blink {
|
|
|
| @@ -536,6 +542,54 @@ bool FontFaceSet::IterationSource::next(ScriptState*, RefPtrWillBeMember<FontFac
|
| return true;
|
| }
|
|
|
| +class FontAccessDescriptionCallback final : public FontAccessCallbacks {
|
| +public:
|
| + FontAccessDescriptionCallback(ScriptPromiseResolver* resolver, ScriptState* scriptState)
|
| + : m_resolver(resolver)
|
| + , m_executionContext(scriptState->executionContext())
|
| + {
|
| + }
|
| +
|
| + void onSuccess(WebPassOwnPtr<WebVector<WebFontAccessDescription>> description) override
|
| + {
|
| + WillBeHeapVector<RefPtrWillBeMember<FontFace>> fonts;
|
| + OwnPtr<WebVector<WebFontAccessDescription>> webFonts = description.release();
|
| + blink::FontFaceDescriptors faceDecsription;
|
| + for (const auto webFont : *webFonts) {
|
| + StringOrArrayBufferOrArrayBufferView cssString;
|
| + StringBuilder result;
|
| + result.append("local('");
|
| + result.append(webFont.fullName);
|
| + result.append(')');
|
| + cssString.setString(result.toString());
|
| + RefPtrWillBeMember<LocalFontFace> ff = LocalFontFace::create(m_executionContext.get(), webFont.family, webFont.style, webFont.fullName, cssString, faceDecsription);
|
| + fonts.append(ff);
|
| + }
|
| +
|
| + m_resolver->resolve(fonts);
|
| + }
|
| + void onError() override
|
| + {
|
| + }
|
| +
|
| +private:
|
| + Persistent<ScriptPromiseResolver> m_resolver;
|
| + RefPtrWillBePersistent<ExecutionContext> m_executionContext;
|
| +};
|
| +
|
| +ScriptPromise FontFaceSet::systemFonts(ScriptState* scriptState)
|
| +{
|
| + WebFontAccess* webfontaccess = Platform::current()->fontAccess();
|
| + if (!webfontaccess)
|
| + return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError));
|
| +
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| +
|
| + webfontaccess->getFonts(new FontAccessDescriptionCallback(resolver, scriptState));
|
| + return promise;
|
| +}
|
| +
|
| DEFINE_TRACE(FontFaceSet)
|
| {
|
| #if ENABLE(OILPAN)
|
|
|