clang fmt github action (#13724)

This commit is contained in:
Jarred Sumner
2024-09-06 17:15:07 -07:00
committed by GitHub
parent 3f9ad7cefc
commit e8c65a009f
79 changed files with 282 additions and 219 deletions

View File

@@ -21,6 +21,7 @@ jobs:
sparse-checkout: |
.prettierrc-ci
.github
.vscode
src
scripts
packages
@@ -28,7 +29,7 @@ jobs:
bench
package.json
bun.lockb
.vscode
.clang-format
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
@@ -46,6 +47,9 @@ jobs:
- name: Format Zig
run: |
bun fmt:zig
- name: Format Cpp
run: |
bun fmt:cpp
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:

View File

@@ -61,6 +61,7 @@
"[h]": {
"editor.defaultFormatter": "xaver.clang-format",
},
"clangd.arguments": ["-header-insertion=never"],
// JavaScript
"prettier.enable": true,

View File

@@ -42,6 +42,7 @@
"typecheck": "tsc --noEmit && cd test && bun run typecheck",
"fmt": "prettier --config=.prettierrc-ci --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
"fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
"fmt:cpp": "clang-format -i src/bun.js/bindings/**/*.{cpp,h} --verbose",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
"test": "node scripts/runner.node.mjs ./build/bun-debug",

View File

@@ -0,0 +1,2 @@
*.lut.h
sqlite/sqlite3_local.h

View File

@@ -58,7 +58,6 @@ private:
CallbackResultType m_type = CallbackResultType::Success;
};
template<typename ReturnType> inline CallbackResult<ReturnType>::CallbackResult(CallbackResultType type)
: m_value(makeUnexpected(type))
{
@@ -80,7 +79,6 @@ template<typename ReturnType> inline auto CallbackResult<ReturnType>::releaseRet
return WTFMove(m_value.value());
}
// Void specialization
inline CallbackResult<void>::CallbackResult(CallbackResultType type)

View File

@@ -28,12 +28,14 @@
namespace WebCore {
// clang-format off
#define DEFINE_COMMON_ATOM(atomName, atomValue) \
MainThreadLazyNeverDestroyed<const AtomString> atomName ## AtomData;
#define INITIALIZE_COMMON_ATOM(atomName, atomValue) \
atomName ## AtomData.constructWithoutAccessCheck(atomValue ## _s);
WEBCORE_COMMON_ATOM_STRINGS_FOR_EACH_KEYWORD(DEFINE_COMMON_ATOM)
// clang-format on
void initializeCommonAtomStrings()
{

View File

@@ -30,6 +30,7 @@
namespace WebCore {
// clang-format off
#define WEBCORE_COMMON_ATOM_STRINGS_FOR_EACH_KEYWORD(macro) \
macro(alternative, "alternative") \
macro(auto, "auto") \
@@ -66,6 +67,7 @@ namespace WebCore {
WEBCORE_COMMON_ATOM_STRINGS_FOR_EACH_KEYWORD(DECLARE_COMMON_ATOM)
#undef DECLARE_COMMON_ATOM
// clang-format on
WEBCORE_EXPORT void initializeCommonAtomStrings();

View File

@@ -27,7 +27,8 @@
#include "IDLTypes.h"
namespace WebCore { namespace DOMJIT {
namespace WebCore {
namespace DOMJIT {
template<typename IDLType>
struct DirectConverter;
@@ -56,4 +57,5 @@ struct DirectConverter<IDLRequiresExistingAtomStringAdaptor<IDLDOMString>> {
}
};
} }
}
}

View File

@@ -28,53 +28,116 @@
#include "IDLTypes.h"
#include <JavaScriptCore/SpeculatedType.h>
namespace WebCore { namespace DOMJIT {
namespace WebCore {
namespace DOMJIT {
template<typename IDLType>
struct IDLArgumentTypeFilter;
template<> struct IDLArgumentTypeFilter<IDLBoolean> { static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean; };
template<> struct IDLArgumentTypeFilter<IDLByte> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLArgumentTypeFilter<IDLOctet> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLArgumentTypeFilter<IDLShort> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLArgumentTypeFilter<IDLUnsignedShort> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLArgumentTypeFilter<IDLLong> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLArgumentTypeFilter<IDLDOMString> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLArgumentTypeFilter<IDLAtomStringAdaptor<IDLDOMString>> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLArgumentTypeFilter<IDLRequiresExistingAtomStringAdaptor<IDLDOMString>> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLArgumentTypeFilter<IDLUint8Array> { static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array; };
template<> struct IDLArgumentTypeFilter<IDLBoolean> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean;
};
template<> struct IDLArgumentTypeFilter<IDLByte> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLArgumentTypeFilter<IDLOctet> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLArgumentTypeFilter<IDLShort> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLArgumentTypeFilter<IDLUnsignedShort> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLArgumentTypeFilter<IDLLong> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLArgumentTypeFilter<IDLDOMString> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLArgumentTypeFilter<IDLAtomStringAdaptor<IDLDOMString>> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLArgumentTypeFilter<IDLRequiresExistingAtomStringAdaptor<IDLDOMString>> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLArgumentTypeFilter<IDLUint8Array> {
static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array;
};
template<typename IDLType>
struct IDLResultTypeFilter {
static const constexpr JSC::SpeculatedType value = JSC::SpecFullTop;
};
template<> struct IDLResultTypeFilter<IDLAny> { static const constexpr JSC::SpeculatedType value = JSC::SpecHeapTop; };
template<> struct IDLResultTypeFilter<IDLBoolean> { static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean; };
template<> struct IDLResultTypeFilter<IDLByte> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLResultTypeFilter<IDLOctet> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLResultTypeFilter<IDLShort> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLResultTypeFilter<IDLUnsignedShort> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLResultTypeFilter<IDLLong> { static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only; };
template<> struct IDLResultTypeFilter<IDLUnsignedLong> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLLongLong> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLUnsignedLongLong> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLFloat> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLUnrestrictedFloat> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLDouble> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLUnrestrictedDouble> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber; };
template<> struct IDLResultTypeFilter<IDLDOMString> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLResultTypeFilter<IDLByteString> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLResultTypeFilter<IDLUSVString> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLResultTypeFilter<IDLAtomStringAdaptor<IDLDOMString>> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLResultTypeFilter<IDLRequiresExistingAtomStringAdaptor<IDLDOMString>> { static const constexpr JSC::SpeculatedType value = JSC::SpecString; };
template<> struct IDLResultTypeFilter<IDLUint8Array> { static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array; };
template<> struct IDLResultTypeFilter<IDLObject> { static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeTop; };
template<> struct IDLResultTypeFilter<IDLAny> {
static const constexpr JSC::SpeculatedType value = JSC::SpecHeapTop;
};
template<> struct IDLResultTypeFilter<IDLBoolean> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBoolean;
};
template<> struct IDLResultTypeFilter<IDLByte> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLResultTypeFilter<IDLOctet> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLResultTypeFilter<IDLShort> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLResultTypeFilter<IDLUnsignedShort> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLResultTypeFilter<IDLLong> {
static const constexpr JSC::SpeculatedType value = JSC::SpecInt32Only;
};
template<> struct IDLResultTypeFilter<IDLUnsignedLong> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLLongLong> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLUnsignedLongLong> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLFloat> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLUnrestrictedFloat> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLDouble> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLUnrestrictedDouble> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeNumber;
};
template<> struct IDLResultTypeFilter<IDLDOMString> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLResultTypeFilter<IDLByteString> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLResultTypeFilter<IDLUSVString> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLResultTypeFilter<IDLAtomStringAdaptor<IDLDOMString>> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLResultTypeFilter<IDLRequiresExistingAtomStringAdaptor<IDLDOMString>> {
static const constexpr JSC::SpeculatedType value = JSC::SpecString;
};
template<> struct IDLResultTypeFilter<IDLUint8Array> {
static const constexpr JSC::SpeculatedType value = JSC::SpecUint8Array;
};
template<> struct IDLResultTypeFilter<IDLObject> {
static const constexpr JSC::SpeculatedType value = JSC::SpecBytecodeTop;
};
template<typename T>
struct IDLResultTypeFilter<IDLNullable<T>> {
static const constexpr JSC::SpeculatedType value = JSC::SpecOther | IDLResultTypeFilter<T>::value;
};
} }
}
}

View File

@@ -36,6 +36,7 @@ namespace WebCore {
template<typename IDLType>
class DOMPromiseProxy {
WTF_MAKE_FAST_ALLOCATED;
public:
using Value = typename IDLType::StorageType;
@@ -51,7 +52,7 @@ public:
void resolve(typename IDLType::StorageType);
void resolveWithNewlyCreated(typename IDLType::StorageType);
void reject(Exception, RejectAsHandled = RejectAsHandled::No);
private:
JSC::JSValue resolvePromise(JSC::JSGlobalObject&, JSDOMGlobalObject&, const Function<void(DeferredPromise&)>&);
@@ -62,6 +63,7 @@ private:
template<>
class DOMPromiseProxy<IDLUndefined> {
WTF_MAKE_FAST_ALLOCATED;
public:
DOMPromiseProxy() = default;
~DOMPromiseProxy() = default;
@@ -87,10 +89,11 @@ private:
template<typename IDLType>
class DOMPromiseProxyWithResolveCallback {
WTF_MAKE_FAST_ALLOCATED;
public:
using ResolveCallback = Function<typename IDLType::ParameterType()>;
template <typename Class, typename BaseClass>
template<typename Class, typename BaseClass>
DOMPromiseProxyWithResolveCallback(Class&, typename IDLType::ParameterType (BaseClass::*)());
DOMPromiseProxyWithResolveCallback(ResolveCallback&&);
~DOMPromiseProxyWithResolveCallback() = default;
@@ -104,7 +107,7 @@ public:
void resolve(typename IDLType::ParameterType);
void resolveWithNewlyCreated(typename IDLType::ParameterType);
void reject(Exception, RejectAsHandled = RejectAsHandled::No);
private:
ResolveCallback m_resolveCallback;
std::optional<ExceptionOr<void>> m_valueOrException;
@@ -208,7 +211,6 @@ inline void DOMPromiseProxy<IDLType>::reject(Exception exception, RejectAsHandle
deferredPromise->reject(m_valueOrException->exception(), rejectAsHandled);
}
// MARK: - DOMPromiseProxy<IDLUndefined> specialization
inline JSC::JSValue DOMPromiseProxy<IDLUndefined>::promise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject)
@@ -250,7 +252,7 @@ inline bool DOMPromiseProxy<IDLUndefined>::isFulfilled() const
inline void DOMPromiseProxy<IDLUndefined>::resolve()
{
ASSERT(!m_valueOrException);
m_valueOrException = ExceptionOr<void> { };
m_valueOrException = ExceptionOr<void> {};
for (auto& deferredPromise : m_deferredPromises)
deferredPromise->resolve();
}
@@ -266,7 +268,7 @@ inline void DOMPromiseProxy<IDLUndefined>::reject(Exception exception, RejectAsH
// MARK: - DOMPromiseProxyWithResolveCallback<IDLType> implementation
template<typename IDLType>
template <typename Class, typename BaseClass>
template<typename Class, typename BaseClass>
inline DOMPromiseProxyWithResolveCallback<IDLType>::DOMPromiseProxyWithResolveCallback(Class& object, typename IDLType::ParameterType (BaseClass::*function)())
: m_resolveCallback(std::bind(function, &object))
{
@@ -322,7 +324,7 @@ inline void DOMPromiseProxyWithResolveCallback<IDLType>::resolve(typename IDLTyp
{
ASSERT(!m_valueOrException);
m_valueOrException = ExceptionOr<void> { };
m_valueOrException = ExceptionOr<void> {};
for (auto& deferredPromise : m_deferredPromises)
deferredPromise->template resolve<IDLType>(value);
}
@@ -332,7 +334,7 @@ inline void DOMPromiseProxyWithResolveCallback<IDLType>::resolveWithNewlyCreated
{
ASSERT(!m_valueOrException);
m_valueOrException = ExceptionOr<void> { };
m_valueOrException = ExceptionOr<void> {};
for (auto& deferredPromise : m_deferredPromises)
deferredPromise->template resolveWithNewlyCreated<IDLType>(value);
}

View File

@@ -33,7 +33,7 @@ namespace WebCore {
void ErrorCallback::scheduleCallback(ScriptExecutionContext& context, Ref<DOMException>&& exception)
{
context.postTask([protectedThis = Ref { *this }, exception = WTFMove(exception)] (ScriptExecutionContext&) {
context.postTask([protectedThis = Ref { *this }, exception = WTFMove(exception)](ScriptExecutionContext&) {
protectedThis->handleEvent(exception);
});
}

View File

@@ -53,14 +53,14 @@ public:
virtual bool operator==(const EventListener&) const = 0;
virtual void handleEvent(ScriptExecutionContext&, Event&) = 0;
virtual void visitJSFunction(JSC::AbstractSlotVisitor&) { }
virtual void visitJSFunction(JSC::SlotVisitor&) { }
virtual void visitJSFunction(JSC::AbstractSlotVisitor&) {}
virtual void visitJSFunction(JSC::SlotVisitor&) {}
virtual bool isAttribute() const { return false; }
Type type() const { return m_type; }
#if ASSERT_ENABLED
virtual void checkValidityForEventTarget(EventTarget&) { }
virtual void checkValidityForEventTarget(EventTarget&) {}
#endif
virtual JSC::JSObject* jsFunction() const { return nullptr; }

View File

@@ -30,7 +30,8 @@ namespace WebCore {
struct EventListenerOptions {
EventListenerOptions(bool capture = false)
: capture(capture)
{ }
{
}
bool capture { false };
};

View File

@@ -27,9 +27,13 @@
namespace WebCore {
enum class EventIsTrusted : bool { No, Yes };
enum class EventCanBubble : bool { No, Yes };
enum class EventIsCancelable : bool { No, Yes };
enum class EventIsComposed : bool { No, Yes };
enum class EventIsTrusted : bool { No,
Yes };
enum class EventCanBubble : bool { No,
Yes };
enum class EventIsCancelable : bool { No,
Yes };
enum class EventIsComposed : bool { No,
Yes };
}

View File

@@ -34,7 +34,9 @@ namespace WebCore {
class Page;
template<typename T> class EventSender {
WTF_MAKE_NONCOPYABLE(EventSender); WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(EventSender);
WTF_MAKE_FAST_ALLOCATED;
public:
explicit EventSender(const AtomString& eventType);
@@ -98,7 +100,7 @@ template<typename T> void EventSender<T>::dispatchPendingEvents(Page* page)
m_dispatchSoonList.checkConsistency();
m_dispatchingList = std::exchange(m_dispatchSoonList, { });
m_dispatchingList = std::exchange(m_dispatchSoonList, {});
for (auto& event : m_dispatchingList) {
if (auto sender = event.get()) {
event = nullptr;

View File

@@ -127,7 +127,7 @@ JSC::JSValue InternalWritableStream::abort(JSC::JSGlobalObject& globalObject, JS
auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
if (result.hasException())
return { };
return {};
return result.returnValue();
}
@@ -143,7 +143,7 @@ JSC::JSValue InternalWritableStream::close(JSC::JSGlobalObject& globalObject)
auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
if (result.hasException())
return { };
return {};
return result.returnValue();
}
@@ -159,7 +159,7 @@ JSC::JSValue InternalWritableStream::getWriter(JSC::JSGlobalObject& globalObject
auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
if (result.hasException())
return { };
return {};
return result.returnValue();
}

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSByteLengthQueuingStrategy(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -61,6 +61,7 @@ public:
{
return static_cast<CloseEvent&>(Base::wrapped());
}
protected:
JSCloseEvent(JSC::Structure*, JSDOMGlobalObject&, Ref<CloseEvent>&&);
@@ -78,5 +79,4 @@ template<> struct JSDOMWrapperConverterTraits<CloseEvent> {
};
template<> CloseEvent::Init convertDictionary<CloseEvent::Init>(JSC::JSGlobalObject&, JSC::JSValue);
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSCountQueuingStrategy(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -76,7 +76,7 @@ public:
{
return setter(lexicalGlobalObject, JSC::JSValue::decode(encodedValue));
}
template<Getter getter, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
static JSC::EncodedJSValue get(JSC::JSGlobalObject& lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName attributeName)
{

View File

@@ -38,10 +38,10 @@ template<typename T> struct Converter;
namespace Detail {
template <typename T> inline T* getPtrOrRef(const T* p) { return const_cast<T*>(p); }
template <typename T> inline T& getPtrOrRef(const T& p) { return const_cast<T&>(p); }
template <typename T> inline T* getPtrOrRef(const RefPtr<T>& p) { return p.get(); }
template <typename T> inline T& getPtrOrRef(const Ref<T>& p) { return p.get(); }
template<typename T> inline T* getPtrOrRef(const T* p) { return const_cast<T*>(p); }
template<typename T> inline T& getPtrOrRef(const T& p) { return const_cast<T&>(p); }
template<typename T> inline T* getPtrOrRef(const RefPtr<T>& p) { return p.get(); }
template<typename T> inline T& getPtrOrRef(const Ref<T>& p) { return p.get(); }
}
@@ -89,7 +89,6 @@ template<typename T, typename ExceptionThrower> inline typename Converter<T>::Re
return Converter<T>::convert(lexicalGlobalObject, value, globalObject, std::forward<ExceptionThrower>(exceptionThrower));
}
// Conversion from Implementation -> JSValue
template<typename T> struct JSConverter;
@@ -171,7 +170,7 @@ template<typename T, typename U> inline JSC::JSValue toJS(JSC::JSGlobalObject& l
auto result = valueOrFunctor();
if (UNLIKELY(result.hasException())) {
propagateException(lexicalGlobalObject, throwScope, result.releaseException());
return { };
return {};
}
return JSC::jsUndefined();
} else
@@ -180,7 +179,7 @@ template<typename T, typename U> inline JSC::JSValue toJS(JSC::JSGlobalObject& l
if constexpr (IsExceptionOr<U>) {
if (UNLIKELY(valueOrFunctor.hasException())) {
propagateException(lexicalGlobalObject, throwScope, valueOrFunctor.releaseException());
return { };
return {};
}
return toJS<T>(lexicalGlobalObject, valueOrFunctor.releaseReturnValue());
@@ -201,7 +200,7 @@ template<typename T, typename U> inline JSC::JSValue toJS(JSC::JSGlobalObject& l
auto result = valueOrFunctor();
if (UNLIKELY(result.hasException())) {
propagateException(lexicalGlobalObject, throwScope, result.releaseException());
return { };
return {};
}
return JSC::jsUndefined();
} else
@@ -210,7 +209,7 @@ template<typename T, typename U> inline JSC::JSValue toJS(JSC::JSGlobalObject& l
if constexpr (IsExceptionOr<U>) {
if (UNLIKELY(valueOrFunctor.hasException())) {
propagateException(lexicalGlobalObject, throwScope, valueOrFunctor.releaseException());
return { };
return {};
}
return toJS<T>(lexicalGlobalObject, globalObject, valueOrFunctor.releaseReturnValue());
@@ -231,7 +230,7 @@ template<typename T, typename U> inline JSC::JSValue toJSNewlyCreated(JSC::JSGlo
auto result = valueOrFunctor();
if (UNLIKELY(result.hasException())) {
propagateException(lexicalGlobalObject, throwScope, result.releaseException());
return { };
return {};
}
return JSC::jsUndefined();
} else
@@ -241,7 +240,7 @@ template<typename T, typename U> inline JSC::JSValue toJSNewlyCreated(JSC::JSGlo
if constexpr (IsExceptionOr<U>) {
if (UNLIKELY(valueOrFunctor.hasException())) {
propagateException(lexicalGlobalObject, throwScope, valueOrFunctor.releaseException());
return { };
return {};
}
return toJSNewlyCreated<T>(lexicalGlobalObject, globalObject, valueOrFunctor.releaseReturnValue());

View File

@@ -68,7 +68,7 @@ template<typename T> struct JSConverter<IDLCallbackFunction<T>> {
static constexpr bool needsState = false;
static constexpr bool needsGlobalObject = false;
template <typename U>
template<typename U>
static JSC::JSValue convert(const U& value)
{
return toJS(Detail::getPtrOrRef(value));
@@ -81,7 +81,6 @@ template<typename T> struct JSConverter<IDLCallbackFunction<T>> {
}
};
template<typename T> struct Converter<IDLCallbackInterface<T>> : DefaultConverter<IDLCallbackInterface<T>> {
template<typename ExceptionThrower = DefaultExceptionThrower>
static RefPtr<T> convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower = ExceptionThrower())
@@ -102,7 +101,7 @@ template<typename T> struct JSConverter<IDLCallbackInterface<T>> {
static constexpr bool needsState = false;
static constexpr bool needsGlobalObject = false;
template <typename U>
template<typename U>
static JSC::JSValue convert(const U& value)
{
return toJS(Detail::getPtrOrRef(value));

View File

@@ -33,7 +33,6 @@ namespace WebCore {
// Specialized by generated code for IDL dictionary conversion.
template<typename T> T convertDictionary(JSC::JSGlobalObject&, JSC::JSValue);
template<typename T> struct Converter<IDLDictionary<T>> : DefaultConverter<IDLDictionary<T>> {
using ReturnType = T;

View File

@@ -38,7 +38,7 @@ namespace Detail {
template<typename IDLType>
struct NullableConversionType;
template<typename IDLType>
template<typename IDLType>
struct NullableConversionType {
using Type = typename IDLNullable<IDLType>::ImplementationType;
};
@@ -57,7 +57,7 @@ struct NullableConversionType<IDLAny> {
template<typename T> struct Converter<IDLNullable<T>> : DefaultConverter<IDLNullable<T>> {
using ReturnType = typename Detail::NullableConversionType<T>::Type;
// 1. If Type(V) is not Object, and the conversion to an IDL value is being performed
// due to V being assigned to an attribute whose type is a nullable callback function
// that is annotated with [LegacyTreatNonObjectAsNull], then return the IDL nullable
@@ -146,5 +146,4 @@ template<typename T> struct JSConverter<IDLNullable<T>> {
}
};
} // namespace WebCore

View File

@@ -251,7 +251,6 @@ template<typename T> struct JSConverter<IDLClampAdaptor<T>> {
}
};
template<typename T> struct Converter<IDLEnforceRangeAdaptor<T>> : DefaultConverter<IDLEnforceRangeAdaptor<T>> {
using ReturnType = typename IDLEnforceRangeAdaptor<T>::ImplementationType;
@@ -273,7 +272,6 @@ template<typename T> struct JSConverter<IDLEnforceRangeAdaptor<T>> {
}
};
// MARK: -
// MARK: Floating point types

View File

@@ -56,7 +56,7 @@ template<> struct JSConverter<IDLWebGLExtension> {
static constexpr bool needsState = true;
static constexpr bool needsGlobalObject = true;
template <typename T>
template<typename T>
static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const T& value)
{
return convertToJSValue(lexicalGlobalObject, globalObject, Detail::getPtrOrRef(value));

View File

@@ -38,7 +38,7 @@ public:
template<Operation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName)
{
return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [&operationName] (JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise) {
return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [&operationName](JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise) {
auto* thisObject = IDLOperation<JSClass>::cast(lexicalGlobalObject, callFrame);
if constexpr (shouldThrow != CastedThisErrorBehavior::Assert) {
if (UNLIKELY(!thisObject))
@@ -47,7 +47,7 @@ public:
ASSERT(thisObject);
ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
// FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject and thisObject.
return operation(&lexicalGlobalObject, &callFrame, thisObject, WTFMove(promise));
}));
@@ -74,7 +74,7 @@ public:
template<StaticOperation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
static JSC::EncodedJSValue callStatic(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char*)
{
return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [] (JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise) {
return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise) {
// FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject.
return operation(&lexicalGlobalObject, &callFrame, WTFMove(promise));
}));

View File

@@ -44,11 +44,14 @@ public:
return guarded();
}
enum class IsCallbackRegistered { No, Yes };
enum class IsCallbackRegistered { No,
Yes };
IsCallbackRegistered whenSettled(std::function<void()>&&);
JSC::JSValue result() const;
enum class Status { Pending, Fulfilled, Rejected };
enum class Status { Pending,
Fulfilled,
Rejected };
Status status() const;
static IsCallbackRegistered whenPromiseIsSettled(JSDOMGlobalObject*, JSC::JSObject* promise, Function<void()>&&);

View File

@@ -6,13 +6,13 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

View File

@@ -30,7 +30,6 @@
#include "DOMJITCheckDOM.h"
namespace WebCore {
using namespace JSC;

View File

@@ -63,6 +63,7 @@ public:
{
return static_cast<PerformanceMark&>(Base::wrapped());
}
protected:
JSPerformanceMark(JSC::Structure*, JSDOMGlobalObject&, Ref<PerformanceMark>&&);

View File

@@ -25,7 +25,6 @@
#include "JSDOMConvertNumbers.h"
#include <JavaScriptCore/JSCInlines.h>
namespace WebCore {
using namespace JSC;
@@ -37,7 +36,7 @@ template<> PerformanceMarkOptions convertDictionary<PerformanceMarkOptions>(JSGl
auto* object = isNullOrUndefined ? nullptr : value.getObject();
if (UNLIKELY(!isNullOrUndefined && !object)) {
throwTypeError(&lexicalGlobalObject, throwScope);
return { };
return {};
}
PerformanceMarkOptions result;
JSValue detailValue;
@@ -45,11 +44,11 @@ template<> PerformanceMarkOptions convertDictionary<PerformanceMarkOptions>(JSGl
detailValue = jsUndefined();
else {
detailValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "detail"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!detailValue.isUndefined()) {
result.detail = convert<IDLAny>(lexicalGlobalObject, detailValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
} else
result.detail = jsUndefined();
JSValue startTimeValue;
@@ -57,11 +56,11 @@ template<> PerformanceMarkOptions convertDictionary<PerformanceMarkOptions>(JSGl
startTimeValue = jsUndefined();
else {
startTimeValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "startTime"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!startTimeValue.isUndefined()) {
result.startTime = convert<IDLDouble>(lexicalGlobalObject, startTimeValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
return result;
}

View File

@@ -63,13 +63,13 @@ public:
{
return static_cast<PerformanceMeasure&>(Base::wrapped());
}
protected:
JSPerformanceMeasure(JSC::Structure*, JSDOMGlobalObject&, Ref<PerformanceMeasure>&&);
DECLARE_DEFAULT_FINISH_CREATION;
};
template<> struct JSDOMWrapperConverterTraits<PerformanceMeasure> {
using WrapperClass = JSPerformanceMeasure;
using ToWrappedReturnType = PerformanceMeasure*;

View File

@@ -28,7 +28,6 @@
#include <JavaScriptCore/JSCInlines.h>
#include <variant>
namespace WebCore {
using namespace JSC;
@@ -40,7 +39,7 @@ template<> PerformanceMeasureOptions convertDictionary<PerformanceMeasureOptions
auto* object = isNullOrUndefined ? nullptr : value.getObject();
if (UNLIKELY(!isNullOrUndefined && !object)) {
throwTypeError(&lexicalGlobalObject, throwScope);
return { };
return {};
}
PerformanceMeasureOptions result;
JSValue detailValue;
@@ -48,11 +47,11 @@ template<> PerformanceMeasureOptions convertDictionary<PerformanceMeasureOptions
detailValue = jsUndefined();
else {
detailValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "detail"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!detailValue.isUndefined()) {
result.detail = convert<IDLAny>(lexicalGlobalObject, detailValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
} else
result.detail = jsUndefined();
JSValue durationValue;
@@ -60,33 +59,33 @@ template<> PerformanceMeasureOptions convertDictionary<PerformanceMeasureOptions
durationValue = jsUndefined();
else {
durationValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "duration"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!durationValue.isUndefined()) {
result.duration = convert<IDLDouble>(lexicalGlobalObject, durationValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue endValue;
if (isNullOrUndefined)
endValue = jsUndefined();
else {
endValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "end"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!endValue.isUndefined()) {
result.end = convert<IDLUnion<IDLDOMString, IDLDouble>>(lexicalGlobalObject, endValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue startValue;
if (isNullOrUndefined)
startValue = jsUndefined();
else {
startValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "start"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!startValue.isUndefined()) {
result.start = convert<IDLUnion<IDLDOMString, IDLDouble>>(lexicalGlobalObject, startValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
return result;
}

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSReadableByteStreamController(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSReadableStreamBYOBReader(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSReadableStreamBYOBRequest(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSReadableStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSReadableStreamDefaultReader(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -37,7 +37,7 @@ using namespace JSC;
JSValue JSReadableStreamSource::start(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame, Ref<DeferredPromise>&& promise)
{
VM& vm = lexicalGlobalObject.vm();
// FIXME: Why is it ok to ASSERT the argument count here?
ASSERT(callFrame.argumentCount());
JSReadableStreamDefaultController* controller = jsDynamicCast<JSReadableStreamDefaultController*>(callFrame.uncheckedArgument(0));

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSTransformStream(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSTransformStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSWritableStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -53,12 +53,11 @@ public:
return subspaceForImpl(vm);
}
static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
protected:
JSWritableStreamDefaultWriter(JSC::Structure*, JSDOMGlobalObject&);
void finishCreation(JSC::VM&);
};
} // namespace WebCore

View File

@@ -78,6 +78,7 @@ struct PerformanceMeasureOptions;
class Performance final : public RefCounted<Performance>, public ContextDestructionObserver, public EventTarget {
WTF_MAKE_ISO_ALLOCATED(Performance);
public:
static Ref<Performance> create(ScriptExecutionContext* context, MonotonicTime timeOrigin) { return adoptRef(*new Performance(context, timeOrigin)); }
~Performance();
@@ -123,14 +124,13 @@ public:
ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
using RefCounted::ref;
using RefCounted::deref;
using RefCounted::ref;
// void scheduleNavigationObservationTaskIfNeeded();
// PerformanceNavigationTiming* navigationTiming() { return m_navigationTiming.get(); }
// EventTargetData* eventTargetData() override;
// EventTargetData* eventTargetDataConcurrently() override;
// EventTargetData& ensureEventTargetData() override;
@@ -174,7 +174,6 @@ private:
ListHashSet<RefPtr<PerformanceObserver>> m_observers;
EventTargetData* eventTargetData() final { return &m_eventTargetData; }
EventTargetData* eventTargetDataConcurrently() final { return &m_eventTargetData; }
EventTargetData& ensureEventTargetData() final { return m_eventTargetData; }

View File

@@ -48,7 +48,7 @@ JSC::JSValue PerformanceMeasure::detail(JSC::JSGlobalObject& globalObject)
if (!m_serializedDetail) {
return JSC::jsNull();
}
return m_serializedDetail->deserialize(globalObject, &globalObject);
}

View File

@@ -48,7 +48,6 @@ PerformanceObserver::PerformanceObserver(ScriptExecutionContext& scriptExecution
// } else
// ASSERT_NOT_REACHED();
m_performance = jsCast<Zig::GlobalObject*>(scriptExecutionContext.globalObject())->performance();
}
void PerformanceObserver::disassociate()
@@ -74,7 +73,7 @@ ExceptionOr<void> PerformanceObserver::observe(Init&& init)
filter.add(*type);
}
if (filter.isEmpty())
return { };
return {};
m_typeFilter = filter;
} else {
if (!init.type)
@@ -85,7 +84,7 @@ ExceptionOr<void> PerformanceObserver::observe(Init&& init)
if (auto type = PerformanceEntry::parseEntryTypeString(*init.type))
filter.add(*type);
else
return { };
return {};
if (init.buffered) {
isBuffered = true;
auto oldSize = m_entriesToDeliver.size();
@@ -106,12 +105,12 @@ ExceptionOr<void> PerformanceObserver::observe(Init&& init)
if (isBuffered)
deliver();
return { };
return {};
}
Vector<RefPtr<PerformanceEntry>> PerformanceObserver::takeRecords()
{
return std::exchange(m_entriesToDeliver, { });
return std::exchange(m_entriesToDeliver, {});
}
void PerformanceObserver::disconnect()
@@ -121,7 +120,7 @@ void PerformanceObserver::disconnect()
m_registered = false;
m_entriesToDeliver.clear();
m_typeFilter = { };
m_typeFilter = {};
}
void PerformanceObserver::queueEntry(PerformanceEntry& entry)
@@ -138,7 +137,7 @@ void PerformanceObserver::deliver()
if (!context)
return;
Vector<RefPtr<PerformanceEntry>> entries = std::exchange(m_entriesToDeliver, { });
Vector<RefPtr<PerformanceEntry>> entries = std::exchange(m_entriesToDeliver, {});
auto list = PerformanceObserverEntryList::create(WTFMove(entries));
// InspectorInstrumentation::willFireObserverCallback(*context, "PerformanceObserver"_s);

View File

@@ -35,6 +35,7 @@ class PerformanceEntry;
class PerformanceObserverEntryList : public RefCounted<PerformanceObserverEntryList> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<PerformanceObserverEntryList> create(Vector<RefPtr<PerformanceEntry>>&& entries);

View File

@@ -77,77 +77,77 @@ unsigned long long PerformanceTiming::fetchStart() const
unsigned long long PerformanceTiming::domainLookupStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::domainLookupEnd() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::connectStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::connectEnd() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::secureConnectionStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::requestStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::responseStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::responseEnd() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::domLoading() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::domInteractive() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::domContentLoadedEventStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::domContentLoadedEventEnd() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::domComplete() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::loadEventStart() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::loadEventEnd() const
{
return 0;
return 0;
}
unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(MonotonicTime timeStamp) const

View File

@@ -36,7 +36,8 @@ public:
: capture(capture)
, passive(passive)
, once(once)
{ }
{
}
bool capture;
bool passive;

View File

@@ -29,7 +29,7 @@
namespace WebCore {
enum WebSocketIdentifierType { };
enum WebSocketIdentifierType {};
using WebSocketIdentifier = ObjectIdentifier<WebSocketIdentifierType>;
} // namespace WebCore

View File

@@ -23,7 +23,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "JSDOMPromiseDeferred.h"
@@ -54,8 +53,8 @@ private:
explicit SimpleWritableStreamSink(WriteCallback&&);
void write(ScriptExecutionContext&, JSC::JSValue, DOMPromiseDeferred<void>&&) final;
void close() final { }
void error(String&&) final { }
void close() final {}
void error(String&&) final {}
WriteCallback m_writeCallback;
};

View File

@@ -41,7 +41,7 @@ static const unsigned char IntegerMark = 0x02;
static const unsigned char OctetStringMark = 0x04;
static const unsigned char SequenceMark = 0x30;
// Version 0. Per https://tools.ietf.org/html/rfc5208#section-5
static const unsigned char Version[] = {0x02, 0x01, 0x00};
static const unsigned char Version[] = { 0x02, 0x01, 0x00 };
static const unsigned char InitialOctet = 0x00;
static const size_t MaxLengthInOneByte = 128;

View File

@@ -110,7 +110,7 @@ void CryptoAlgorithmAES_CFB::generateKey(const CryptoAlgorithmParameters& parame
void CryptoAlgorithmAES_CFB::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
{
using namespace CryptoAlgorithmAES_CFBInternal;
if (usagesAreInvalidForCryptoAlgorithmAES_CFB(usages)) {
exceptionCallback(SyntaxError);
return;

View File

@@ -292,7 +292,7 @@ auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator~() c
return { ~m_hi, ~m_lo };
}
auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator <<=(unsigned shift) -> CounterBlockBits&
auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator<<=(unsigned shift) -> CounterBlockBits&
{
if (shift < 64) {
m_hi = (m_hi << shift) | m_lo >> (64 - shift);
@@ -308,7 +308,7 @@ auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator <<=(
return *this;
}
auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator &=(const CounterBlockBits& rhs) -> CounterBlockBits&
auto CryptoAlgorithmAES_CTR::CounterBlockHelper::CounterBlockBits::operator&=(const CounterBlockBits& rhs) -> CounterBlockBits&
{
m_hi &= rhs.m_hi;
m_lo &= rhs.m_lo;

View File

@@ -53,8 +53,8 @@ public:
CounterBlockBits operator&(const CounterBlockBits&) const;
CounterBlockBits operator~() const;
CounterBlockBits& operator <<=(unsigned);
CounterBlockBits& operator &=(const CounterBlockBits&);
CounterBlockBits& operator<<=(unsigned);
CounterBlockBits& operator&=(const CounterBlockBits&);
uint64_t m_hi { 0 };
uint64_t m_lo { 0 };

View File

@@ -42,6 +42,7 @@ public:
static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoAlgorithmEcdsaParams&, const CryptoKeyEC&, const Vector<uint8_t>&);
static ExceptionOr<bool> platformVerify(const CryptoAlgorithmEcdsaParams&, const CryptoKeyEC&, const Vector<uint8_t>&, const Vector<uint8_t>&);
private:
CryptoAlgorithmECDSA() = default;
CryptoAlgorithmIdentifier identifier() const final;
@@ -51,7 +52,6 @@ private:
void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
};
} // namespace WebCore

View File

@@ -62,7 +62,7 @@ ExceptionOr<Vector<uint8_t>> CryptoAlgorithmECDSA::platformSign(const CryptoAlgo
return Exception { OperationError };
Vector<uint8_t> signature(derSigLength);
uint8_t* p = signature.data();
if(i2d_ECDSA_SIG(sig.get(), &p) != derSigLength)
if (i2d_ECDSA_SIG(sig.get(), &p) != derSigLength)
return Exception { OperationError };
return signature;
} else {
@@ -107,7 +107,7 @@ ExceptionOr<bool> CryptoAlgorithmECDSA::platformVerify(const CryptoAlgorithmEcds
// Bail if the signature size isn't double the key size (i.e. concatenated r and s components).
if (signature.size() != keySizeInBytes * 2)
return false;
auto sig = ECDSASigPtr(ECDSA_SIG_new());
auto r = BN_bin2bn(signature.data(), keySizeInBytes, nullptr);
auto s = BN_bin2bn(signature.data() + keySizeInBytes, keySizeInBytes, nullptr);

View File

@@ -39,11 +39,12 @@ public:
static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKeyOKP&, const Vector<uint8_t>&);
static ExceptionOr<bool> platformVerify(const CryptoKeyOKP&, const Vector<uint8_t>&, const Vector<uint8_t>&);
private:
CryptoAlgorithmEd25519() = default;
CryptoAlgorithmIdentifier identifier() const final;
void generateKey(const CryptoAlgorithmParameters& , bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& , ExceptionCallback&& , ScriptExecutionContext&);
void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
void sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
void verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;

View File

@@ -80,7 +80,7 @@ ExceptionOr<size_t> CryptoAlgorithmHKDF::getKeyLength(const CryptoAlgorithmParam
{
return 0;
}
} // namespace WebCore
#endif // ENABLE(WEB_CRYPTO)

View File

@@ -45,7 +45,6 @@ public:
static ExceptionOr<bool> platformVerify(const CryptoKeyHMAC&, const Vector<uint8_t>&, const Vector<uint8_t>&);
static ExceptionOr<bool> platformVerifyWithAlgorithm(const CryptoKeyHMAC&, CryptoAlgorithmIdentifier, const Vector<uint8_t>&, const Vector<uint8_t>&);
private:
CryptoAlgorithmHMAC() = default;
CryptoAlgorithmIdentifier identifier() const final;

View File

@@ -59,8 +59,9 @@ static std::optional<Vector<uint8_t>> calculateSignature(const EVP_MD* algorithm
return cipherText;
}
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSignWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector<uint8_t>& data) {
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSignWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector<uint8_t>& data)
{
auto algorithm = digestAlgorithm(algorithmIdentifier);
if (!algorithm)
return Exception { OperationError };
@@ -83,7 +84,8 @@ ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHMAC::platformSign(const CryptoKeyHM
return WTFMove(*result);
}
ExceptionOr<bool> CryptoAlgorithmHMAC::platformVerifyWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector<uint8_t>& signature, const Vector<uint8_t>& data) {
ExceptionOr<bool> CryptoAlgorithmHMAC::platformVerifyWithAlgorithm(const CryptoKeyHMAC& key, CryptoAlgorithmIdentifier algorithmIdentifier, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
{
auto algorithm = digestAlgorithm(algorithmIdentifier);
if (!algorithm)

View File

@@ -67,9 +67,13 @@ public:
} // namespace WebCore
// clang-format off
#define SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(ToClassName) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CryptoAlgorithm##ToClassName) \
static bool isType(const WebCore::CryptoAlgorithmParameters& parameters) { return parameters.parametersClass() == WebCore::CryptoAlgorithmParameters::Class::ToClassName; } \
SPECIALIZE_TYPE_TRAITS_END()
// clang-format on
#endif // ENABLE(WEB_CRYPTO)

View File

@@ -45,7 +45,6 @@ public:
static ExceptionOr<bool> platformVerify(const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
static ExceptionOr<bool> platformVerifyWithAlgorithm(const CryptoKeyRSA&, CryptoAlgorithmIdentifier, const Vector<uint8_t>&, const Vector<uint8_t>&);
private:
CryptoAlgorithmRSASSA_PKCS1_v1_5() = default;
CryptoAlgorithmIdentifier identifier() const final;

View File

@@ -33,8 +33,8 @@
namespace WebCore {
static ExceptionOr<Vector<uint8_t>> signWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector<uint8_t>& data) {
static ExceptionOr<Vector<uint8_t>> signWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector<uint8_t>& data)
{
std::optional<Vector<uint8_t>> digest = calculateDigest(md, data);
if (!digest)
@@ -65,7 +65,8 @@ static ExceptionOr<Vector<uint8_t>> signWithEVP_MD(const CryptoKeyRSA& key, con
return signature;
}
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSignWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector<uint8_t>& data) {
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSignWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector<uint8_t>& data)
{
const EVP_MD* md = digestAlgorithm(algorithm);
if (!md)
@@ -82,8 +83,8 @@ ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(cons
return signWithEVP_MD(key, md, data);
}
static ExceptionOr<bool> verifyWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector<uint8_t>& signature, const Vector<uint8_t>& data) {
static ExceptionOr<bool> verifyWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD* md, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
{
std::optional<Vector<uint8_t>> digest = calculateDigest(md, data);
if (!digest)
return Exception { OperationError };
@@ -106,7 +107,8 @@ static ExceptionOr<bool> verifyWithEVP_MD(const CryptoKeyRSA& key, const EVP_MD
return ret == 1;
}
ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector<uint8_t>& signature, const Vector<uint8_t>& data) {
ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyWithAlgorithm(const CryptoKeyRSA& key, CryptoAlgorithmIdentifier algorithm, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
{
const EVP_MD* md = digestAlgorithm(algorithm);
if (!md)
return Exception { NotSupportedError };
@@ -114,7 +116,6 @@ ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerifyWithAlgorithm(
return verifyWithEVP_MD(key, md, signature, data);
}
ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
{
const EVP_MD* md = digestAlgorithm(key.hashAlgorithmIdentifier());

View File

@@ -46,7 +46,6 @@ public:
static ExceptionOr<bool> platformVerify(const CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
static ExceptionOr<bool> platformVerifyWithAlgorithm(const CryptoAlgorithmRsaPssParams&, CryptoAlgorithmIdentifier, const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
private:
CryptoAlgorithmRSA_PSS() = default;
CryptoAlgorithmIdentifier identifier() const final;
@@ -56,7 +55,6 @@ private:
void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
};
} // namespace WebCore

View File

@@ -37,7 +37,7 @@ namespace WebCore {
static ExceptionOr<Vector<uint8_t>> signWithMD(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data, const EVP_MD* md)
{
auto padding = parameters.padding;
if(padding == 0) {
if (padding == 0) {
padding = RSA_PKCS1_PSS_PADDING;
}
std::optional<Vector<uint8_t>> digest = calculateDigest(md, data);
@@ -54,7 +54,7 @@ static ExceptionOr<Vector<uint8_t>> signWithMD(const CryptoAlgorithmRsaPssParams
if (EVP_PKEY_CTX_set_rsa_padding(ctx.get(), padding) <= 0)
return Exception { OperationError };
if(padding == RSA_PKCS1_PSS_PADDING) {
if (padding == RSA_PKCS1_PSS_PADDING) {
if (EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx.get(), parameters.saltLength) <= 0)
return Exception { OperationError };
}
@@ -89,7 +89,6 @@ ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSignWithAlgorithm(c
#endif
}
ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
{
#if 1 // defined(EVP_PKEY_CTX_set_rsa_pss_saltlen) && defined(EVP_PKEY_CTX_set_rsa_mgf1_md)
@@ -106,7 +105,7 @@ ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAl
static ExceptionOr<bool> verifyWithMD(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data, const EVP_MD* md)
{
auto padding = parameters.padding;
if(padding == 0) {
if (padding == 0) {
padding = RSA_PKCS1_PSS_PADDING;
}
@@ -120,7 +119,7 @@ static ExceptionOr<bool> verifyWithMD(const CryptoAlgorithmRsaPssParams& paramet
if (EVP_PKEY_CTX_set_rsa_padding(ctx.get(), padding) <= 0)
return Exception { OperationError };
if(padding == RSA_PKCS1_PSS_PADDING) {
if (padding == RSA_PKCS1_PSS_PADDING) {
if (EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx.get(), parameters.saltLength) <= 0)
return Exception { OperationError };
}
@@ -146,7 +145,6 @@ ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerifyWithAlgorithm(const Cryp
return Exception { NotSupportedError };
return verifyWithMD(parameters, key, signature, data, md);
}
ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)

View File

@@ -69,7 +69,7 @@ String CryptoAlgorithmRegistry::name(CryptoAlgorithmIdentifier identifier)
auto contructor = m_constructors.find(static_cast<unsigned>(identifier));
if (contructor == m_constructors.end())
return { };
return {};
return contructor->value.first.isolatedCopy();
}
@@ -97,7 +97,6 @@ void CryptoAlgorithmRegistry::registerAlgorithm(const String& name, CryptoAlgori
m_constructors.add(static_cast<unsigned>(identifier), std::make_pair(name, constructor));
}
} // namespace WebCore
#endif // ENABLE(WEB_CRYPTO)

View File

@@ -35,4 +35,3 @@ struct CryptoEcKeyAlgorithm : CryptoKeyAlgorithm {
};
}

View File

@@ -37,5 +37,3 @@ struct CryptoHmacKeyAlgorithm : CryptoKeyAlgorithm {
};
}

View File

@@ -43,7 +43,7 @@ public:
{
return adoptRef(*new CryptoKeyHMAC(key, hash, extractable, usage));
}
virtual ~CryptoKeyHMAC();
static RefPtr<CryptoKeyHMAC> generate(size_t lengthBits, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap);

View File

@@ -395,7 +395,7 @@ std::unique_ptr<CryptoKeyRSAComponents> CryptoKeyRSA::exportData() const
return CryptoKeyRSAComponents::createPrivateWithAdditionalData(
convertToBytes(n), convertToBytes(e), convertToBytes(d),
WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), Vector<CryptoKeyRSAComponents::PrimeInfo> { });
WTFMove(firstPrimeInfo), WTFMove(secondPrimeInfo), Vector<CryptoKeyRSAComponents::PrimeInfo> {});
}
default:
ASSERT_NOT_REACHED();

View File

@@ -35,4 +35,3 @@ struct CryptoRsaHashedKeyAlgorithm : CryptoRsaKeyAlgorithm {
};
}

View File

@@ -38,4 +38,3 @@ struct CryptoRsaKeyAlgorithm : CryptoKeyAlgorithm {
};
}

View File

@@ -30,7 +30,6 @@
#include <JavaScriptCore/JSCInlines.h>
#include <JavaScriptCore/ObjectConstructor.h>
namespace WebCore {
using namespace JSC;
@@ -44,7 +43,7 @@ template<> CryptoKeyPair convertDictionary<CryptoKeyPair>(JSGlobalObject& lexica
auto* object = isNullOrUndefined ? nullptr : value.getObject();
if (UNLIKELY(!isNullOrUndefined && !object)) {
throwTypeError(&lexicalGlobalObject, throwScope);
return { };
return {};
}
CryptoKeyPair result;
JSValue privateKeyValue;
@@ -52,22 +51,22 @@ template<> CryptoKeyPair convertDictionary<CryptoKeyPair>(JSGlobalObject& lexica
privateKeyValue = jsUndefined();
else {
privateKeyValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "privateKey"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!privateKeyValue.isUndefined()) {
result.privateKey = convert<IDLInterface<CryptoKey>>(lexicalGlobalObject, privateKeyValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
JSValue publicKeyValue;
if (isNullOrUndefined)
publicKeyValue = jsUndefined();
else {
publicKeyValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "publicKey"_s));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
if (!publicKeyValue.isUndefined()) {
result.publicKey = convert<IDLInterface<CryptoKey>>(lexicalGlobalObject, publicKeyValue);
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
}
return result;
}
@@ -81,12 +80,12 @@ JSC::JSObject* convertDictionaryToJS(JSC::JSGlobalObject& lexicalGlobalObject, J
if (!IDLInterface<CryptoKey>::isNullValue(dictionary.privateKey)) {
auto privateKeyValue = toJS<IDLInterface<CryptoKey>>(lexicalGlobalObject, globalObject, throwScope, IDLInterface<CryptoKey>::extractValueFromNullable(dictionary.privateKey));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
result->putDirect(vm, JSC::Identifier::fromString(vm, "privateKey"_s), privateKeyValue);
}
if (!IDLInterface<CryptoKey>::isNullValue(dictionary.publicKey)) {
auto publicKeyValue = toJS<IDLInterface<CryptoKey>>(lexicalGlobalObject, globalObject, throwScope, IDLInterface<CryptoKey>::extractValueFromNullable(dictionary.publicKey));
RETURN_IF_EXCEPTION(throwScope, { });
RETURN_IF_EXCEPTION(throwScope, {});
result->putDirect(vm, JSC::Identifier::fromString(vm, "publicKey"_s), publicKeyValue);
}
return result;

View File

@@ -37,14 +37,14 @@
namespace WebCore {
template <typename T>
template<typename T>
struct OpenSSLCryptoPtrDeleter {
void operator()(T* ptr) const = delete;
};
template <typename T>
template<typename T>
using OpenSSLCryptoPtr = std::unique_ptr<T, OpenSSLCryptoPtrDeleter<T>>;
// clang-format off
#define DEFINE_OPENSSL_CRYPTO_PTR_FULL(alias, typeName, deleterFunc) \
template<> struct OpenSSLCryptoPtrDeleter<typeName> { \
void operator()(typeName* ptr) const { \
@@ -55,7 +55,7 @@ using OpenSSLCryptoPtr = std::unique_ptr<T, OpenSSLCryptoPtrDeleter<T>>;
#define DEFINE_OPENSSL_CRYPTO_PTR(alias, typeName, deleterFunc) \
DEFINE_OPENSSL_CRYPTO_PTR_FULL(alias, typeName, deleterFunc(ptr))
// clang-format on
DEFINE_OPENSSL_CRYPTO_PTR(EvpCipherCtxPtr, EVP_CIPHER_CTX, EVP_CIPHER_CTX_free)
DEFINE_OPENSSL_CRYPTO_PTR(EvpDigestCtxPtr, EVP_MD_CTX, EVP_MD_CTX_free)
DEFINE_OPENSSL_CRYPTO_PTR(EvpPKeyPtr, EVP_PKEY, EVP_PKEY_free)

View File

@@ -84,7 +84,7 @@ Vector<uint8_t> convertToBytesExpand(const BIGNUM* bignum, size_t minimumBufferS
{
int length = BN_num_bytes(bignum);
if (length < 0)
return { };
return {};
size_t bufferSize = std::max<size_t>(length, minimumBufferSize);
@@ -134,5 +134,4 @@ AESKey::~AESKey()
} // namespace WebCore
#endif // ENABLE(WEB_CRYPTO)

View File

@@ -49,6 +49,7 @@ BIGNUMPtr convertToBigNumber(const Vector<uint8_t>& bytes);
class AESKey {
WTF_MAKE_NONCOPYABLE(AESKey);
public:
AESKey() = default;
~AESKey();
@@ -56,6 +57,7 @@ public:
bool setKey(const Vector<uint8_t>& key, int enc /* AES_ENCRYPT or AES_DECRYPT */);
AES_KEY* key() { return &m_key; }
private:
AES_KEY m_key;
};

View File

@@ -1 +1 @@
extern "C" void *memmem(const void *h0, size_t k, const void *n0, size_t l);
extern "C" void* memmem(const void* h0, size_t k, const void* n0, size_t l);