Commit eb787c95 authored by yhirano@chromium.org's avatar yhirano@chromium.org

Use ScriptPromiseResolverWithContext.

Use ScriptPromiseResolverWithContext instead of a pair of
ScriptPromiseResolver and NewScriptState.
This CL doen't change the behavior in many cases: The only exception
is when the resolution / rejection happens on the suspended or stopped
ExecutionContext. In such a case, ScriptPromiseResolver suspends or stops
resolution or rejection.

R=ksakamoto@chromium.org
BUG=352552

Review URL: https://codereview.chromium.org/236123007

git-svn-id: svn://svn.chromium.org/blink/trunk@171418 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 76e0f464
......@@ -36,7 +36,7 @@
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/NewScriptState.h"
#include "bindings/v8/ScriptPromiseResolver.h"
#include "bindings/v8/ScriptPromiseResolverWithContext.h"
#include "core/css/BinaryDataFontFaceSource.h"
#include "core/css/CSSFontFace.h"
#include "core/css/CSSFontFaceSrcValue.h"
......@@ -72,7 +72,6 @@ public:
void resolve(PassRefPtr<FontFace> fontFace)
{
NewScriptState::Scope scope(m_scriptState.get());
switch (fontFace->loadStatus()) {
case FontFace::Loaded:
m_resolver->resolve(fontFace);
......@@ -89,13 +88,11 @@ public:
private:
FontFaceReadyPromiseResolver(ExecutionContext* context)
: m_scriptState(NewScriptState::current(toIsolate(context)))
, m_resolver(ScriptPromiseResolver::create(context))
: m_resolver(ScriptPromiseResolverWithContext::create(NewScriptState::current(toIsolate(context))))
{
}
RefPtr<NewScriptState> m_scriptState;
RefPtr<ScriptPromiseResolver> m_resolver;
RefPtr<ScriptPromiseResolverWithContext> m_resolver;
};
static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID)
......
......@@ -29,7 +29,7 @@
#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/NewScriptState.h"
#include "bindings/v8/ScriptPromiseResolver.h"
#include "bindings/v8/ScriptPromiseResolverWithContext.h"
#include "core/css/CSSFontFaceLoadEvent.h"
#include "core/css/CSSFontSelector.h"
#include "core/css/parser/BisonCSSParser.h"
......@@ -65,8 +65,7 @@ private:
LoadFontPromiseResolver(FontFaceArray faces, ExecutionContext* context)
: m_numLoading(faces.size())
, m_errorOccured(false)
, m_scriptState(NewScriptState::current(toIsolate(context)))
, m_resolver(ScriptPromiseResolver::create(context))
, m_resolver(ScriptPromiseResolverWithContext::create(NewScriptState::current(toIsolate(context))))
{
m_fontFaces.swap(faces);
}
......@@ -74,8 +73,7 @@ private:
FontFaceArray m_fontFaces;
int m_numLoading;
bool m_errorOccured;
RefPtr<NewScriptState> m_scriptState;
RefPtr<ScriptPromiseResolver> m_resolver;
RefPtr<ScriptPromiseResolverWithContext> m_resolver;
};
void LoadFontPromiseResolver::loadFonts(ExecutionContext* context)
......@@ -95,7 +93,6 @@ void LoadFontPromiseResolver::notifyLoaded(FontFace* fontFace)
if (m_numLoading || m_errorOccured)
return;
NewScriptState::Scope scope(m_scriptState.get());
m_resolver->resolve(m_fontFaces);
}
......@@ -104,7 +101,6 @@ void LoadFontPromiseResolver::notifyError(FontFace* fontFace)
m_numLoading--;
if (!m_errorOccured) {
m_errorOccured = true;
NewScriptState::Scope scope(m_scriptState.get());
m_resolver->reject(fontFace->error());
}
}
......@@ -118,7 +114,6 @@ public:
void resolve(PassRefPtr<FontFaceSet> fontFaceSet)
{
NewScriptState::Scope scope(m_scriptState.get());
m_resolver->resolve(fontFaceSet);
}
......@@ -126,13 +121,11 @@ public:
private:
FontsReadyPromiseResolver(ExecutionContext* context)
: m_scriptState(NewScriptState::current(toIsolate(context)))
, m_resolver(ScriptPromiseResolver::create(context))
: m_resolver(ScriptPromiseResolverWithContext::create(NewScriptState::current(toIsolate(context))))
{
}
RefPtr<NewScriptState> m_scriptState;
RefPtr<ScriptPromiseResolver> m_resolver;
RefPtr<ScriptPromiseResolverWithContext> m_resolver;
};
FontFaceSet::FontFaceSet(Document& document)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment