Modified: trunk/Source/WebCore/ChangeLog (220619 => 220620)
--- trunk/Source/WebCore/ChangeLog 2017-08-12 00:07:00 UTC (rev 220619)
+++ trunk/Source/WebCore/ChangeLog 2017-08-12 00:32:03 UTC (rev 220620)
@@ -1,5 +1,33 @@
2017-08-11 Sam Weinig <s...@webkit.org>
+ [Bindings] Simplify DOMPromiseProxy now that WTF::Function can return references
+ https://bugs.webkit.org/show_bug.cgi?id=175394
+
+ Reviewed by Chris Dumez.
+
+ * bindings/IDLTypes.h:
+ (WebCore::IDLWrapper::convertToParameterType): Deleted.
+
+ Remove no longer used convertToParameterType.
+
+ * bindings/js/DOMPromiseProxy.h:
+
+ - Replace Variant<Value, Exception> with ExceptionOr<Value> / ExceptionOr<void>.
+ - Update ResolveCallback to have a return type of IDLType::ParameterType, rather than
+ IDLType::ImplementationType, now that WTF::Function supports references as the
+ return type. This is needed, since the IDLType::ParameterType for an interface T
+ is T&.
+
+ * css/FontFace.cpp:
+ * css/FontFace.h:
+ * css/FontFaceSet.cpp:
+ * css/FontFaceSet.h:
+
+ Update resolve callbacks to return a reference rather than a RefPtr, matching
+ the new signature requirement.
+
+2017-08-11 Sam Weinig <s...@webkit.org>
+
[WebIDL] Replace JSCryptoKeyCustom and JSCryptoAlgorithmBuilder with generated code
https://bugs.webkit.org/show_bug.cgi?id=175457
Modified: trunk/Source/WebCore/bindings/js/DOMPromiseProxy.h (220619 => 220620)
--- trunk/Source/WebCore/bindings/js/DOMPromiseProxy.h 2017-08-12 00:07:00 UTC (rev 220619)
+++ trunk/Source/WebCore/bindings/js/DOMPromiseProxy.h 2017-08-12 00:32:03 UTC (rev 220620)
@@ -25,12 +25,11 @@
#pragma once
-#include "Exception.h"
+#include "ExceptionOr.h"
#include "JSDOMGlobalObject.h"
#include "JSDOMPromiseDeferred.h"
#include <wtf/Function.h>
#include <wtf/Optional.h>
-#include <wtf/Variant.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -39,7 +38,6 @@
class DOMPromiseProxy {
public:
using Value = typename IDLType::StorageType;
- using ValueOrException = Variant<Value, Exception>;
DOMPromiseProxy() = default;
~DOMPromiseProxy() = default;
@@ -55,7 +53,7 @@
void reject(Exception);
private:
- std::optional<ValueOrException> m_valueOrException;
+ std::optional<ExceptionOr<Value>> m_valueOrException;
Vector<Ref<DeferredPromise>, 1> m_deferredPromises;
};
@@ -62,9 +60,6 @@
template<>
class DOMPromiseProxy<IDLVoid> {
public:
- using Value = bool;
- using ValueOrException = Variant<Value, Exception>;
-
DOMPromiseProxy() = default;
~DOMPromiseProxy() = default;
@@ -78,7 +73,7 @@
void reject(Exception);
private:
- std::optional<ValueOrException> m_valueOrException;
+ std::optional<ExceptionOr<void>> m_valueOrException;
Vector<Ref<DeferredPromise>, 1> m_deferredPromises;
};
@@ -89,15 +84,10 @@
template<typename IDLType>
class DOMPromiseProxyWithResolveCallback {
public:
- using Value = bool;
- using ValueOrException = Variant<Value, Exception>;
- // FIXME: This should return a IDLType::ParameterType, but WTF::Function does
- // not support returning references / non-default initializable types.
- // See https://webkit.org/b/175244.
- using ResolveCallback = WTF::Function<typename IDLType::ImplementationType ()>;
+ using ResolveCallback = WTF::Function<typename IDLType::ParameterType ()>;
template <typename Class, typename BaseClass>
- DOMPromiseProxyWithResolveCallback(Class&, typename IDLType::ImplementationType (BaseClass::*)());
+ DOMPromiseProxyWithResolveCallback(Class&, typename IDLType::ParameterType (BaseClass::*)());
DOMPromiseProxyWithResolveCallback(ResolveCallback&&);
~DOMPromiseProxyWithResolveCallback() = default;
@@ -113,8 +103,7 @@
private:
ResolveCallback m_resolveCallback;
-
- std::optional<ValueOrException> m_valueOrException;
+ std::optional<ExceptionOr<void>> m_valueOrException;
Vector<Ref<DeferredPromise>, 1> m_deferredPromises;
};
@@ -135,10 +124,10 @@
return JSC::jsUndefined();
if (m_valueOrException) {
- if (WTF::holds_alternative<Value>(*m_valueOrException))
- deferredPromise->template resolve<IDLType>(WTF::get<Value>(*m_valueOrException));
+ if (m_valueOrException->hasException())
+ deferredPromise->reject(m_valueOrException->exception());
else
- deferredPromise->reject(WTF::get<Exception>(*m_valueOrException));
+ deferredPromise->template resolve<IDLType>(m_valueOrException->returnValue());
}
auto result = deferredPromise->promise();
@@ -164,9 +153,9 @@
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { std::forward<typename IDLType::ParameterType>(value) };
+ m_valueOrException = ExceptionOr<Value> { std::forward<typename IDLType::ParameterType>(value) };
for (auto& deferredPromise : m_deferredPromises)
- deferredPromise->template resolve<IDLType>(WTF::get<Value>(*m_valueOrException));
+ deferredPromise->template resolve<IDLType>(m_valueOrException->returnValue());
}
template<typename IDLType>
@@ -174,9 +163,9 @@
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { std::forward<typename IDLType::ParameterType>(value) };
+ m_valueOrException = ExceptionOr<Value> { std::forward<typename IDLType::ParameterType>(value) };
for (auto& deferredPromise : m_deferredPromises)
- deferredPromise->template resolveWithNewlyCreated<IDLType>(WTF::get<Value>(*m_valueOrException));
+ deferredPromise->template resolveWithNewlyCreated<IDLType>(m_valueOrException->returnValue());
}
template<typename IDLType>
@@ -184,9 +173,9 @@
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { WTFMove(exception) };
+ m_valueOrException = ExceptionOr<Value> { WTFMove(exception) };
for (auto& deferredPromise : m_deferredPromises)
- deferredPromise->reject(WTF::get<Exception>(*m_valueOrException));
+ deferredPromise->reject(m_valueOrException->exception());
}
@@ -205,10 +194,10 @@
return JSC::jsUndefined();
if (m_valueOrException) {
- if (WTF::holds_alternative<Value>(*m_valueOrException))
+ if (m_valueOrException->hasException())
+ deferredPromise->reject(m_valueOrException->exception());
+ else
deferredPromise->resolve();
- else
- deferredPromise->reject(WTF::get<Exception>(*m_valueOrException));
}
auto result = deferredPromise->promise();
@@ -230,7 +219,7 @@
inline void DOMPromiseProxy<IDLVoid>::resolve()
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { true };
+ m_valueOrException = ExceptionOr<void> { };
for (auto& deferredPromise : m_deferredPromises)
deferredPromise->resolve();
}
@@ -238,9 +227,9 @@
inline void DOMPromiseProxy<IDLVoid>::reject(Exception exception)
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { WTFMove(exception) };
+ m_valueOrException = ExceptionOr<void> { WTFMove(exception) };
for (auto& deferredPromise : m_deferredPromises)
- deferredPromise->reject(WTF::get<Exception>(*m_valueOrException));
+ deferredPromise->reject(m_valueOrException->exception());
}
// MARK: - DOMPromiseProxyWithResolveCallback<IDLType> implementation
@@ -247,7 +236,7 @@
template<typename IDLType>
template <typename Class, typename BaseClass>
-inline DOMPromiseProxyWithResolveCallback<IDLType>::DOMPromiseProxyWithResolveCallback(Class& object, typename IDLType::ImplementationType (BaseClass::*function)())
+inline DOMPromiseProxyWithResolveCallback<IDLType>::DOMPromiseProxyWithResolveCallback(Class& object, typename IDLType::ParameterType (BaseClass::*function)())
: m_resolveCallback(std::bind(function, &object))
{
}
@@ -272,10 +261,10 @@
return JSC::jsUndefined();
if (m_valueOrException) {
- if (WTF::holds_alternative<Value>(*m_valueOrException))
- deferredPromise->template resolve<IDLType>(IDLType::convertToParameterType(m_resolveCallback()));
+ if (m_valueOrException->hasException())
+ deferredPromise->reject(m_valueOrException->exception());
else
- deferredPromise->reject(WTF::get<Exception>(*m_valueOrException));
+ deferredPromise->template resolve<IDLType>(m_resolveCallback());
}
auto result = deferredPromise->promise();
@@ -301,7 +290,7 @@
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { true };
+ m_valueOrException = ExceptionOr<void> { };
for (auto& deferredPromise : m_deferredPromises)
deferredPromise->template resolve<IDLType>(value);
}
@@ -311,7 +300,7 @@
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { true };
+ m_valueOrException = ExceptionOr<void> { };
for (auto& deferredPromise : m_deferredPromises)
deferredPromise->template resolveWithNewlyCreated<IDLType>(value);
}
@@ -321,9 +310,9 @@
{
ASSERT(!m_valueOrException);
- m_valueOrException = ValueOrException { WTFMove(exception) };
+ m_valueOrException = ExceptionOr<void> { WTFMove(exception) };
for (auto& deferredPromise : m_deferredPromises)
- deferredPromise->reject(WTF::get<Exception>(*m_valueOrException));
+ deferredPromise->reject(m_valueOrException->exception());
}
}
Modified: trunk/Source/WebCore/css/FontFaceSet.h (220619 => 220620)
--- trunk/Source/WebCore/css/FontFaceSet.h 2017-08-12 00:07:00 UTC (rev 220619)
+++ trunk/Source/WebCore/css/FontFaceSet.h 2017-08-12 00:32:03 UTC (rev 220620)
@@ -108,7 +108,8 @@
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
- RefPtr<FontFaceSet> readyPromiseResolve();
+ // Callback for ReadyPromise.
+ FontFaceSet& readyPromiseResolve();
Ref<CSSFontFaceSet> m_backing;
HashMap<RefPtr<FontFace>, Vector<Ref<PendingPromise>>> m_pendingPromises;