diff --git a/cmake/tools/SetupWebKit.cmake b/cmake/tools/SetupWebKit.cmake index 1804cd0848..5aee190f85 100644 --- a/cmake/tools/SetupWebKit.cmake +++ b/cmake/tools/SetupWebKit.cmake @@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use") option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading") if(NOT WEBKIT_VERSION) - set(WEBKIT_VERSION 495c25e24927ba03277ae225cd42811588d03ff8) + set(WEBKIT_VERSION 69fa2714ab5f917c2d15501ff8cfdccfaea78882) endif() string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX) diff --git a/src/bun.js/bindings/node/crypto/CryptoGenDhKeyPair.h b/src/bun.js/bindings/node/crypto/CryptoGenDhKeyPair.h index 5ed7e1a3ef..845cb4b90c 100644 --- a/src/bun.js/bindings/node/crypto/CryptoGenDhKeyPair.h +++ b/src/bun.js/bindings/node/crypto/CryptoGenDhKeyPair.h @@ -33,7 +33,7 @@ public: ncrypto::EVPKeyCtxPointer setup(); static std::optional fromJS(JSC::JSGlobalObject* globalObject, JSC::ThrowScope& scope, const JSC::GCOwnedDataScope& typeView, JSC::JSValue optionsValue, const KeyEncodingConfig& config); - std::variant m_prime; + WTF::Variant m_prime; uint32_t m_generator; }; diff --git a/src/bun.js/bindings/webcore/JSMessageEventCustom.cpp b/src/bun.js/bindings/webcore/JSMessageEventCustom.cpp index e67b3b4b56..eed83eafc4 100644 --- a/src/bun.js/bindings/webcore/JSMessageEventCustom.cpp +++ b/src/bun.js/bindings/webcore/JSMessageEventCustom.cpp @@ -57,14 +57,16 @@ JSC::JSValue JSMessageEvent::data(JSC::JSGlobalObject& lexicalGlobalObject) cons { auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject.vm()); return cachedPropertyValue(throwScope, lexicalGlobalObject, *this, wrapped().cachedData(), [this, &lexicalGlobalObject](JSC::ThrowScope&) { - return WTF::switchOn( - wrapped().data(), [this](MessageEvent::JSValueTag) -> JSC::JSValue { return wrapped().jsData().getValue(JSC::jsNull()); }, - [this, &lexicalGlobalObject](const Ref& data) { - // FIXME: Is it best to handle errors by returning null rather than throwing an exception? - return data->deserialize(lexicalGlobalObject, globalObject(), wrapped().ports(), SerializationErrorMode::NonThrowing); }, - [&lexicalGlobalObject](const String& data) { return toJS(lexicalGlobalObject, data); }, - [this, &lexicalGlobalObject](const Ref& data) { return toJS>(lexicalGlobalObject, *globalObject(), data); }, - [this, &lexicalGlobalObject](const Ref& data) { return toJS>(lexicalGlobalObject, *globalObject(), data); }); + return std::visit( + WTF::makeVisitor( + [this](MessageEvent::JSValueTag) -> JSC::JSValue { return wrapped().jsData().getValue(JSC::jsNull()); }, + [this, &lexicalGlobalObject](const Ref& data) -> JSC::JSValue { + // FIXME: Is it best to handle errors by returning null rather than throwing an exception? + return data->deserialize(lexicalGlobalObject, globalObject(), wrapped().ports(), SerializationErrorMode::NonThrowing); }, + [&lexicalGlobalObject](const String& data) -> JSC::JSValue { return toJS(lexicalGlobalObject, data); }, + [this, &lexicalGlobalObject](const Ref& data) -> JSC::JSValue { return toJS>(lexicalGlobalObject, *globalObject(), data); }, + [this, &lexicalGlobalObject](const Ref& data) -> JSC::JSValue { return toJS>(lexicalGlobalObject, *globalObject(), data); }), + wrapped().data()); }); } diff --git a/src/bun.js/bindings/webcore/MessageEvent.cpp b/src/bun.js/bindings/webcore/MessageEvent.cpp index c8a00d99ed..a050adfe02 100644 --- a/src/bun.js/bindings/webcore/MessageEvent.cpp +++ b/src/bun.js/bindings/webcore/MessageEvent.cpp @@ -146,12 +146,14 @@ EventInterface MessageEvent::eventInterface() const size_t MessageEvent::memoryCost() const { Locker { m_concurrentDataAccessLock }; - return WTF::switchOn( - m_data, [](JSValueTag) -> size_t { return 0; }, - [](const Ref& data) -> size_t { return data->memoryCost(); }, - [](const String& string) -> size_t { return string.sizeInBytes(); }, - [](const Ref& blob) -> size_t { return blob->memoryCost(); }, - [](const Ref& buffer) -> size_t { return buffer->byteLength(); }); + return std::visit( + WTF::makeVisitor( + [](JSValueTag) -> size_t { return 0; }, + [](const Ref& data) -> size_t { return data->memoryCost(); }, + [](const String& string) -> size_t { return string.sizeInBytes(); }, + [](const Ref& blob) -> size_t { return blob->memoryCost(); }, + [](const Ref& buffer) -> size_t { return buffer->byteLength(); }), + m_data); } } // namespace WebCore diff --git a/src/bun.js/bindings/webcore/PerformanceUserTiming.cpp b/src/bun.js/bindings/webcore/PerformanceUserTiming.cpp index 359dafe02a..d9d67ebb21 100644 --- a/src/bun.js/bindings/webcore/PerformanceUserTiming.cpp +++ b/src/bun.js/bindings/webcore/PerformanceUserTiming.cpp @@ -142,9 +142,10 @@ void PerformanceUserTiming::clearMarks(const String& markName) ExceptionOr PerformanceUserTiming::convertMarkToTimestamp(const std::variant& mark) const { - return WTF::switchOn(mark, [&](auto& value) { + return std::visit([&](auto& value) { return convertMarkToTimestamp(value); - }); + }, + mark); } ExceptionOr PerformanceUserTiming::convertMarkToTimestamp(const String& mark) const @@ -283,23 +284,24 @@ static bool isNonEmptyDictionary(const PerformanceMeasureOptions& measureOptions ExceptionOr> PerformanceUserTiming::measure(JSC::JSGlobalObject& globalObject, const String& measureName, std::optional&& startOrMeasureOptions, const String& endMark) { if (startOrMeasureOptions) { - return WTF::switchOn( - *startOrMeasureOptions, - [&](const PerformanceMeasureOptions& measureOptions) -> ExceptionOr> { - if (isNonEmptyDictionary(measureOptions)) { - if (!endMark.isNull()) - return Exception { TypeError }; - if (!measureOptions.start && !measureOptions.end) - return Exception { TypeError }; - if (measureOptions.start && measureOptions.duration && measureOptions.end) - return Exception { TypeError }; - } + return std::visit( + WTF::makeVisitor( + [&](const PerformanceMeasureOptions& measureOptions) -> ExceptionOr> { + if (isNonEmptyDictionary(measureOptions)) { + if (!endMark.isNull()) + return Exception { TypeError }; + if (!measureOptions.start && !measureOptions.end) + return Exception { TypeError }; + if (measureOptions.start && measureOptions.duration && measureOptions.end) + return Exception { TypeError }; + } - return measure(globalObject, measureName, measureOptions); - }, - [&](const String& startMark) { - return measure(measureName, startMark, endMark); - }); + return measure(globalObject, measureName, measureOptions); + }, + [&](const String& startMark) -> ExceptionOr> { + return measure(measureName, startMark, endMark); + }), + *startOrMeasureOptions); } return measure(measureName, {}, endMark); diff --git a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp index 1b16e1bee7..7cf7e2bd13 100644 --- a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp +++ b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp @@ -6275,9 +6275,11 @@ JSValue SerializedScriptValue::deserialize(JSGlobalObject& lexicalGlobalObject, for (const auto& property : m_simpleInMemoryPropertyTable) { // We **must** clone this so that the atomic flag doesn't get set to true. JSC::Identifier identifier = JSC::Identifier::fromString(vm, property.propertyName.isolatedCopy()); - JSValue value = WTF::switchOn( - property.value, [](JSValue value) -> JSValue { return value; }, - [&](const String& string) -> JSValue { return jsString(vm, string); }); + JSValue value = std::visit( + WTF::makeVisitor( + [](JSValue value) -> JSValue { return value; }, + [&](const String& string) -> JSValue { return jsString(vm, string); }), + property.value); object->putDirect(vm, identifier, value); } diff --git a/src/bun.js/bindings/webcrypto/SubtleCrypto.cpp b/src/bun.js/bindings/webcrypto/SubtleCrypto.cpp index eddda7a9a8..4a233ea064 100644 --- a/src/bun.js/bindings/webcrypto/SubtleCrypto.cpp +++ b/src/bun.js/bindings/webcrypto/SubtleCrypto.cpp @@ -512,26 +512,28 @@ static std::optional toKeyData(SubtleCrypto::KeyFormat format, SubtleCr case SubtleCrypto::KeyFormat::Spki: case SubtleCrypto::KeyFormat::Pkcs8: case SubtleCrypto::KeyFormat::Raw: - return WTF::switchOn( - keyDataVariant, - [&promise](JsonWebKey&) -> std::optional { - promise->reject(Exception { TypeError }); - return std::nullopt; - }, - [](auto& bufferSource) -> std::optional { - return KeyData { Vector(std::span { static_cast(bufferSource->data()), bufferSource->byteLength() }) }; - }); + return std::visit( + WTF::makeVisitor( + [&promise](JsonWebKey&) -> std::optional { + promise->reject(Exception { TypeError }); + return std::nullopt; + }, + [](auto& bufferSource) -> std::optional { + return KeyData { Vector(std::span { static_cast(bufferSource->data()), bufferSource->byteLength() }) }; + }), + keyDataVariant); case SubtleCrypto::KeyFormat::Jwk: - return WTF::switchOn( - keyDataVariant, - [](JsonWebKey& webKey) -> std::optional { - normalizeJsonWebKey(webKey); - return KeyData { webKey }; - }, - [&promise](auto&) -> std::optional { - promise->reject(Exception { TypeError }); - return std::nullopt; - }); + return std::visit( + WTF::makeVisitor( + [](JsonWebKey& webKey) -> std::optional { + normalizeJsonWebKey(webKey); + return KeyData { webKey }; + }, + [&promise](auto&) -> std::optional { + promise->reject(Exception { TypeError }); + return std::nullopt; + }), + keyDataVariant); } RELEASE_ASSERT_NOT_REACHED(); @@ -815,22 +817,23 @@ void SubtleCrypto::generateKey(JSC::JSGlobalObject& state, AlgorithmIdentifier&& WeakPtr weakThis { *this }; auto callback = [index, weakThis](KeyOrKeyPair&& keyOrKeyPair) mutable { if (auto promise = getPromise(index, weakThis)) { - WTF::switchOn( - keyOrKeyPair, - [&promise](RefPtr& key) { - if ((key->type() == CryptoKeyType::Private || key->type() == CryptoKeyType::Secret) && !key->usagesBitmap()) { - rejectWithException(promise.releaseNonNull(), SyntaxError, ""_s); - return; - } - promise->resolve>(*key); - }, - [&promise](CryptoKeyPair& keyPair) { - if (!keyPair.privateKey->usagesBitmap()) { - rejectWithException(promise.releaseNonNull(), SyntaxError, ""_s); - return; - } - promise->resolve>(keyPair); - }); + std::visit( + WTF::makeVisitor( + [&promise](RefPtr& key) { + if ((key->type() == CryptoKeyType::Private || key->type() == CryptoKeyType::Secret) && !key->usagesBitmap()) { + rejectWithException(promise.releaseNonNull(), SyntaxError, ""_s); + return; + } + promise->resolve>(*key); + }, + [&promise](CryptoKeyPair& keyPair) { + if (!keyPair.privateKey->usagesBitmap()) { + rejectWithException(promise.releaseNonNull(), SyntaxError, ""_s); + return; + } + promise->resolve>(keyPair); + }), + keyOrKeyPair); } }; auto exceptionCallback = [index, weakThis](ExceptionCode ec, const String& msg) mutable {