diff --git a/LayoutTests/fast/mediastream/image-capture-get-photo-settings-expected.txt b/LayoutTests/fast/mediastream/image-capture-get-photo-settings-expected.txt
new file mode 100644
index 000000000000..bd6bb23b02c1
--- /dev/null
+++ b/LayoutTests/fast/mediastream/image-capture-get-photo-settings-expected.txt
@@ -0,0 +1,5 @@
+
+
+PASS getPhotoSettings() on an 'ended' track should throw "InvalidStateError"
+PASS Check getPhotoSettings()
+
diff --git a/LayoutTests/fast/mediastream/image-capture-get-photo-settings.html b/LayoutTests/fast/mediastream/image-capture-get-photo-settings.html
new file mode 100644
index 000000000000..ebf1598b1322
--- /dev/null
+++ b/LayoutTests/fast/mediastream/image-capture-get-photo-settings.html
@@ -0,0 +1,48 @@
+
+
+
+
+ ImageCapture getPhotoSettings
+
+
+
+
+
+
+
+
diff --git a/LayoutTests/platform/ios-16/TestExpectations b/LayoutTests/platform/ios-16/TestExpectations
index 6bcf7865ecd0..f5e9a784737e 100644
--- a/LayoutTests/platform/ios-16/TestExpectations
+++ b/LayoutTests/platform/ios-16/TestExpectations
@@ -20,3 +20,13 @@ accessibility/ios-simulator/inline-prediction-attributed-string.html [ Skip ]
# Only supported with iOS 17 and later.
media/media-webm-opus-variable-length.html [ Failure ]
+
+# webkit.org/b/262663 (REGRESSION(iOS17/Sonoma): 8 WebCryptoAPI tests are constantly crashing.)
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.worker.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.worker.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.worker.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.html [ Pass ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.worker.html [ Pass ]
diff --git a/LayoutTests/platform/ios/TestExpectations b/LayoutTests/platform/ios/TestExpectations
index 5e964725c8b1..cfbc4b25192e 100644
--- a/LayoutTests/platform/ios/TestExpectations
+++ b/LayoutTests/platform/ios/TestExpectations
@@ -4649,3 +4649,13 @@ imported/w3c/web-platform-tests/css/css-fonts/font-palette-modify.html [ ImageOn
imported/w3c/web-platform-tests/css/css-fonts/font-palette-remove.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-fonts/palette-values-rule-add.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-fonts/palette-values-rule-delete.html [ ImageOnlyFailure ]
+
+# webkit.org/b/262663 (REGRESSION(iOS17/Sonoma): 8 WebCryptoAPI tests are constantly crashing.)
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.worker.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.worker.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.worker.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.html [ Crash ]
+imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.worker.html [ Crash ]
diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations
index 98966a5b8fac..10039033017c 100644
--- a/LayoutTests/platform/mac/TestExpectations
+++ b/LayoutTests/platform/mac/TestExpectations
@@ -2886,3 +2886,13 @@ webkit.org/b/261306 imported/w3c/web-platform-tests/content-security-policy/repo
# rdar://114294654 (REGRESSION (265615@main): [ Sonoma ] fast/attachment/cocoa/wide-attachment-rendering.html is a constant failure)
[ Sonoma+ ] fast/attachment/cocoa/wide-attachment-rendering.html [ Failure ]
+
+# webkit.org/b/262663 (REGRESSION(iOS17/Sonoma): 8 WebCryptoAPI tests are constantly crashing.)
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.worker.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.worker.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.worker.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.html [ Crash ]
+[ Sonoma ] imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.worker.html [ Crash ]
diff --git a/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml b/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
index 96f1cf72103b..0497568acddb 100644
--- a/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
+++ b/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
@@ -4914,6 +4914,22 @@ OffscreenCanvasInWorkersEnabled:
"PLATFORM(COCOA)": true
default: false
+# FIXME: Reenable this on iOS once we can mitigate impact on memory use.
+OpportunisticSweepingAndGarbageCollectionEnabled:
+ type: bool
+ status: internal
+ humanReadableName: "Opportunistic Sweeping and GC"
+ humanReadableDescription: "Enable Opportunistic Sweeping and GC"
+ category: javascript
+ defaultValue:
+ WebKitLegacy:
+ default: false
+ WebKit:
+ "PLATFORM(IOS_FAMILY)": false
+ default: true
+ WebCore:
+ default: false
+
OpusDecoderEnabled:
type: bool
status: mature
diff --git a/Source/WTF/wtf/CrossThreadCopier.cpp b/Source/WTF/wtf/CrossThreadCopier.cpp
index 17d971ada563..4f348bee7333 100644
--- a/Source/WTF/wtf/CrossThreadCopier.cpp
+++ b/Source/WTF/wtf/CrossThreadCopier.cpp
@@ -44,11 +44,6 @@ static_assert((std::is_same, CrossThreadC
static_assert((std::is_same, CrossThreadCopier::Type>::value), "RawPointerTest");
static_assert((std::is_same[, CrossThreadCopier][>::Type>::value), "RawPointerTest");
-// Add specializations for RefCounted types which will let us verify that no other template matches.
-template struct CrossThreadCopierBase> {
- typedef int Type;
-};
-
template struct CrossThreadCopierBase {
typedef int Type;
};
@@ -57,7 +52,6 @@ template struct CrossThreadCopierBase {
class CopierRefCountedTest : public RefCounted {
};
-static_assert((std::is_same>::Type>::value), "CrossThreadCopier specialization improperly applied to RefPtr<> of a RefCounted (but not ThreadSafeRefCounted) type");
static_assert((std::is_same::Type>::value), "CrossThreadCopier specialization improperly applied to raw pointer of a RefCounted (but not ThreadSafeRefCounted) type");
} // namespace WTF
diff --git a/Source/WTF/wtf/CrossThreadCopier.h b/Source/WTF/wtf/CrossThreadCopier.h
index 1e44d4aed236..889741e20774 100644
--- a/Source/WTF/wtf/CrossThreadCopier.h
+++ b/Source/WTF/wtf/CrossThreadCopier.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
- * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,13 +31,17 @@
#pragma once
+#include
#include
+#include
#include
+#include
#include
#include
#include
#include
#include
+#include
#include
namespace WTF {
@@ -68,7 +72,9 @@ struct CrossThreadCopierBaseHelper {
};
template struct CrossThreadCopierPassThrough {
- typedef T Type;
+ static_assert(CrossThreadCopierBaseHelper::IsEnumOrConvertibleToInteger::value, "CrossThreadCopierPassThrough only used for enums or integers");
+ using Type = T;
+ static constexpr bool IsNeeded = false;
static Type copy(const T& parameter)
{
return parameter;
@@ -82,37 +88,89 @@ template struct CrossThreadCopierBase : public Cross
};
// Classes that have an isolatedCopy() method get a default specialization.
-template struct CrossThreadCopierBase {
- template static auto copy(U&& value)
+template
+struct CrossThreadCopierBase {
+ using Type = T;
+ static constexpr bool IsNeeded = HasIsolatedCopy::value;
+ template static auto copy(U&& value) -> Type
{
- return std::forward(value).isolatedCopy();
+ if constexpr (HasIsolatedCopy::value)
+ return std::forward(value).isolatedCopy();
+ else
+ return std::forward(value);
}
};
// Custom copy methods.
template struct CrossThreadCopierBase {
- typedef typename CrossThreadCopierBaseHelper::RemovePointer::Type RefCountedType;
+ using RefCountedType = typename CrossThreadCopierBaseHelper::RemovePointer::Type;
static_assert(std::is_convertible::value, "T is not convertible to ThreadSafeRefCounted!");
- typedef RefPtr Type;
+ using Type = RefPtr;
+ static constexpr bool IsNeeded = false;
+
static Type copy(const T& refPtr)
{
return refPtr;
}
+ static Type copy(T&& refPtr)
+ {
+ return WTFMove(refPtr);
+ }
+};
+
+// Can only be moved
+template struct CrossThreadCopierBase> {
+ using Type = Ref;
+ static constexpr bool IsNeeded = false;
+ static Type copy(Type&& ref)
+ {
+ return WTFMove(ref);
+ }
+};
+
+// Can only be moved
+template struct CrossThreadCopierBase> {
+ using Type = RefPtr;
+ static constexpr bool IsNeeded = false;
+ static Type copy(Type&& ref)
+ {
+ return WTFMove(ref);
+ }
};
template struct CrossThreadCopierBase> {
static_assert(std::is_convertible::value, "T is not convertible to ThreadSafeRefCounted!");
+ static constexpr bool IsNeeded = false;
- typedef Ref Type;
+ using Type = Ref;
static Type copy(const Type& ref)
{
return ref;
}
+ static Type copy(Type&& ref)
+ {
+ return WTFMove(ref);
+ }
+};
+
+// Default specialization for AtomString of CrossThreadCopyable classes.
+template<> struct CrossThreadCopierBase {
+ using Type = String;
+ static constexpr bool IsNeeded = true;
+ static Type copy(const AtomString& source)
+ {
+ return source.string().isolatedCopy();
+ }
+ static Type copy(AtomString&& source)
+ {
+ return source.releaseString().isolatedCopy();
+ }
};
template<> struct CrossThreadCopierBase {
- typedef WTF::ASCIILiteral Type;
+ using Type = WTF::ASCIILiteral;
+ static constexpr bool IsNeeded = false;
static Type copy(const Type& source)
{
return source;
@@ -120,7 +178,8 @@ template<> struct CrossThreadCopierBase {
};
template struct CrossThreadCopierBase> {
- typedef ObjectIdentifierGeneric Type;
+ using Type = ObjectIdentifierGeneric;
+ static constexpr bool IsNeeded = false;
static Type copy(const Type& source)
{
return source;
@@ -134,6 +193,7 @@ struct CrossThreadCopier : public CrossThreadCopierBase struct CrossThreadCopierBase> {
using Type = Vector;
+ static constexpr bool IsNeeded = CrossThreadCopier::IsNeeded;
static Type copy(const Type& source)
{
return WTF::map(source, [](auto& object) {
@@ -147,10 +207,11 @@ template struct CrossThreadCopierBase > {
- typedef HashSet Type;
+ using Type = HashSet;
+ static constexpr bool IsNeeded = CrossThreadCopier::IsNeeded;
static Type copy(const Type& source)
{
Type destination;
@@ -171,7 +232,8 @@ template struct CrossThreadCopierBase > {
// Default specialization for HashMaps of CrossThreadCopyable classes
template
struct CrossThreadCopierBase> {
- typedef HashMap Type;
+ using Type = HashMap;
+ static constexpr bool IsNeeded = CrossThreadCopier::IsNeeded || CrossThreadCopier::IsNeeded;
static Type copy(const Type& source)
{
Type destination;
@@ -191,7 +253,8 @@ struct CrossThreadCopierBase struct CrossThreadCopierBase > {
- typedef std::pair Type;
+ using Type = std::pair;
+ static constexpr bool IsNeeded = CrossThreadCopier::IsNeeded || CrossThreadCopier]::IsNeeded;
template static Type copy(U&& source)
{
return std::make_pair(CrossThreadCopier::copy(std::get<0>(std::forward(source))), CrossThreadCopier::copy(std::get<1>(std::forward(source))));
@@ -200,6 +263,8 @@ template struct CrossThreadCopierBase struct CrossThreadCopierBase> {
+ using Type = std::optional;
+ static constexpr bool IsNeeded = CrossThreadCopier::IsNeeded;
template static std::optional copy(U&& source)
{
if (!source)
@@ -210,7 +275,9 @@ template struct CrossThreadCopierBase
// Default specialization for Markable of CrossThreadCopyable class.
template struct CrossThreadCopierBase> {
- template static Markable copy(V&& source)
+ using Type = Markable;
+ static constexpr bool IsNeeded = CrossThreadCopier::IsNeeded;
+ template static Type copy(V&& source)
{
if (!source)
return std::nullopt;
@@ -219,12 +286,14 @@ template struct CrossThreadCopierBase struct CrossThreadCopierBase {
+ static constexpr bool IsNeeded = false;
static std::nullptr_t copy(std::nullptr_t) { return nullptr; }
};
// Default specialization for std::variant of CrossThreadCopyable classes.
template struct CrossThreadCopierBase> {
using Type = std::variant;
+ static constexpr bool IsNeeded = (CrossThreadCopier>::IsNeeded || ...);
static std::variant copy(const Type& source)
{
return std::visit([] (auto& type) -> std::variant {
@@ -239,11 +308,61 @@ template struct CrossThreadCopierBase
+struct CrossThreadCopierBase {
+ static constexpr bool IsNeeded = false;
+ using Type = void;
+};
+
+template struct CrossThreadCopierBase > {
+ using Type = Expected;
+ static constexpr bool IsNeeded = CrossThreadCopier>::IsNeeded || CrossThreadCopier>::IsNeeded;
+ static Type copy(const Type& source)
+ {
+ if (source.has_value()) {
+ if constexpr (std::is_void_v)
+ return source;
+ else
+ return CrossThreadCopier::copy(source.value());
+ }
+ return Unexpected(CrossThreadCopier::copy(source.error()));
+ }
+
+ static Type copy(Type&& source)
+ {
+ if (source.has_value()) {
+ if constexpr (std::is_void_v)
+ return WTFMove(source);
+ else
+ return CrossThreadCopier::copy(WTFMove(source.value()));
+ }
+ return Unexpected(CrossThreadCopier::copy(WTFMove(source.error())));
+ }
+};
+
+// Default specialization for std::tuple of CrossThreadCopyable classes.
+template struct CrossThreadCopierBase> {
+ using Type = std::tuple;
+ static constexpr bool IsNeeded = (CrossThreadCopier>::IsNeeded || ...);
+ static Type copy(const Type& source)
+ {
+ return std::apply([](Ts const&... ts) {
+ return std::make_tuple((CrossThreadCopier>::copy(ts), ...));
+ }, source);
+ }
+ static Type copy(Type&& source)
+ {
+ return std::apply([](Ts&&... ts) {
+ return std::make_tuple((CrossThreadCopier>::copy(WTFMove(ts)), ...));
+ }, WTFMove(source));
+ }
+};
+
template auto crossThreadCopy(T&& source)
{
return CrossThreadCopier>::copy(std::forward(source));
}
-
+
} // namespace WTF
using WTF::CrossThreadCopierBaseHelper;
diff --git a/Source/WTF/wtf/Forward.h b/Source/WTF/wtf/Forward.h
index 02b60e80e16c..0d101674c60a 100644
--- a/Source/WTF/wtf/Forward.h
+++ b/Source/WTF/wtf/Forward.h
@@ -122,7 +122,7 @@ template, typename = HashTraits> class HashCountedSet;
template, typename = HashTraits, typename = HashTraits, typename = HashTableTraits> class HashMap;
template, typename = HashTraits, typename = HashTableTraits> class HashSet;
-template class NativePromise;
+template class NativePromise;
}
diff --git a/Source/WTF/wtf/Markable.h b/Source/WTF/wtf/Markable.h
index 37b81a5639d7..f36867a4a8db 100644
--- a/Source/WTF/wtf/Markable.h
+++ b/Source/WTF/wtf/Markable.h
@@ -76,6 +76,18 @@ struct IntegralMarkableTraits {
}
};
+struct FloatMarkableTraits {
+ constexpr static bool isEmptyValue(float value)
+ {
+ return value != value;
+ }
+
+ constexpr static float emptyValue()
+ {
+ return std::numeric_limits::quiet_NaN();
+ }
+};
+
// The goal of Markable is offering Optional without sacrificing storage efficiency.
// Markable takes Traits, which should have isEmptyValue and emptyValue functions. By using
// one value of T as an empty value, we can remove bool flag in Optional. This strategy is
@@ -129,6 +141,13 @@ class Markable {
constexpr const T& operator*() const& { return m_value; }
constexpr T& operator*() & { return m_value; }
+ template constexpr T value_or(U&& fallback) const
+ {
+ if (bool(*this))
+ return m_value;
+ return static_cast(std::forward(fallback));
+ }
+
operator std::optional() &&
{
if (bool(*this))
diff --git a/Source/WTF/wtf/NativePromise.h b/Source/WTF/wtf/NativePromise.h
index b501fba720a8..600307de8e74 100644
--- a/Source/WTF/wtf/NativePromise.h
+++ b/Source/WTF/wtf/NativePromise.h
@@ -33,7 +33,9 @@
#include
#include
#include
+#include
#include
+#include
#include
#include
#include
@@ -70,6 +72,10 @@ namespace WTF {
* - values are passed to the resolve/reject callbacks through either const references or pointers.
* - the resolve or reject object will be deleted on the last SerialFunctionDispatcher that got used.
*
+ * By default, a NativePromise will use crossThreadCopy() on the resolved or rejected object if it contains a type with the `isolatedCopy()` method
+ * or an AtomString (be it directly, or in a composited object (e.g. Vector).
+ * This behaviour can be overridden with either PromiseOption::WithCrossThreadCopy or PromiseOption::WithoutCrossThreadCopy
+ *
* A typical workflow would be as follow:
* If the work is to be done immediately:
* From the producer side:
@@ -94,7 +100,8 @@ namespace WTF {
*
* By disconnecting the NativePromiseRequest (via NativePromiseRequest::disconnect(), the then()/whenSettled() callbacks will not be run.
*
- * For now, care should be taken by the Producer to only return an object that is usable on the target's queue (don't return an AtomString for example)
+ * The object given to resolve, reject or resolveOrReject must have a CrossThreadCopier specialisation as needed.
+ * The type of this object may not be identical to ResolveValueType or RejectValueType as the methods allow for implicit conversion.
*
* Examples:
* 1. Basic usage. methodA runs on the main thread, methodB must run on a WorkQueue, and expects a std::unique.
@@ -207,13 +214,40 @@ enum class PromiseDispatchMode : uint8_t {
};
-template
+enum class PromiseOption : uint8_t {
+ Default = 0, // Exclusive | WithAutomaticCrossThreadCopy
+ NonExclusive = (1 << 0),
+ WithCrossThreadCopy = (1 << 2),
+ WithoutCrossThreadCopy = (1 << 3),
+};
+constexpr unsigned operator|(PromiseOption a, PromiseOption b)
+{
+ return static_cast(a) | static_cast(b);
+}
+constexpr unsigned operator|(unsigned a, PromiseOption b)
+{
+ return a | static_cast(b);
+}
+constexpr unsigned operator&(PromiseOption a, PromiseOption b)
+{
+ return static_cast(a) & static_cast(b);
+}
+constexpr unsigned operator&(unsigned a, PromiseOption b)
+{
+ return a & static_cast(b);
+}
+
+template
class NativePromise final : public NativePromiseBase, public ConvertibleToNativePromise {
public:
- using Result = Expected;
- using Error = Unexpected;
- using ResolveValueType = ResolveValueT;
- using RejectValueType = RejectValueT;
+ static constexpr bool IsExclusive = !(options & PromiseOption::NonExclusive);
+ static constexpr bool WithCrossThreadCopy = !!(options & PromiseOption::WithCrossThreadCopy);
+ static constexpr bool WithAutomaticCrossThreadCopy = !(options & (PromiseOption::WithCrossThreadCopy | PromiseOption::WithoutCrossThreadCopy)) && (CrossThreadCopier::IsNeeded || CrossThreadCopier::IsNeeded);
+ static_assert(!WithAutomaticCrossThreadCopy || IsExclusive, "Using Non-Exclusive NativePromise with a ResolveValueT or RejectValueT requiring a call to isolatedCopy() must be explicitly set with WithCrossThreadCopy or WithoutCrossThreadCopy option");
+ using ResolveValueType = std::conditional_t::Type, ResolveValueT>;
+ using RejectValueType = std::conditional_t::Type, RejectValueT>;
+ using Result = Expected;
+ using Error = Unexpected;
// used by IsConvertibleToNativePromise to determine how to cast the result.
using PromiseType = NativePromise;
@@ -328,8 +362,8 @@ class NativePromise final : public NativePromiseBase, public ConvertibleToNative
return p;
}
- using AllPromiseType = NativePromise, RejectValueType, IsExclusive>;
- using AllSettledPromiseType = NativePromise, bool, IsExclusive>;
+ using AllPromiseType = NativePromise, RejectValueType, options>;
+ using AllSettledPromiseType = NativePromise, bool, options>;
private:
friend class Producer;
@@ -340,7 +374,10 @@ class NativePromise final : public NativePromiseBase, public ConvertibleToNative
Locker lock { m_lock };
PROMISE_LOG(resolveSite, " resolving ", *this);
ASSERT(isNothing());
- m_result = std::forward(resolveValue);
+ if constexpr (WithCrossThreadCopy || WithAutomaticCrossThreadCopy)
+ m_result = crossThreadCopy(std::forward(resolveValue));
+ else
+ m_result = std::forward(resolveValue);
dispatchAll(lock);
}
@@ -361,17 +398,24 @@ class NativePromise final : public NativePromiseBase, public ConvertibleToNative
Locker lock { m_lock };
PROMISE_LOG(rejectSite, " rejecting ", *this);
ASSERT(isNothing());
- m_result = Unexpected(std::forward(rejectValue));
+ if constexpr (WithCrossThreadCopy || WithAutomaticCrossThreadCopy)
+ m_result = Unexpected(crossThreadCopy(std::forward(rejectValue)));
+ else
+ m_result = Unexpected(std::forward(rejectValue));
dispatchAll(lock);
}
template
void resolveOrReject(ResolveOrRejectValue_&& result, const Logger::LogSiteIdentifier& site)
{
+ static_assert(std::is_convertible_v, "resolveOrReject() argument must be implicitly convertible to NativePromise's Result");
Locker lock { m_lock };
ASSERT(isNothing());
PROMISE_LOG(site, " resolveOrRejecting ", *this);
- m_result = std::forward(result);
+ if constexpr (WithCrossThreadCopy || WithAutomaticCrossThreadCopy)
+ m_result = crossThreadCopy(std::forward(result));
+ else
+ m_result = std::forward(result);
dispatchAll(lock);
}
@@ -675,7 +719,7 @@ class NativePromise final : public NativePromiseBase, public ConvertibleToNative
template
class ThenCommand : public ConvertibleToNativePromise {
// Allow Promise::then() to access the private constructor,
- template
+ template
friend class NativePromise;
// used by IsConvertibleToNativePromise to determine how to cast the result.
@@ -979,12 +1023,12 @@ class NativePromise final : public NativePromiseBase, public ConvertibleToNative
std::atomic m_dispatchMode { PromiseDispatchMode::Default };
};
-template
-class NativePromise::Producer final : public ConvertibleToNativePromise {
+template
+class NativePromise::Producer final : public ConvertibleToNativePromise {
WTF_MAKE_FAST_ALLOCATED;
public:
// used by IsConvertibleToNativePromise to determine how to cast the result.
- using PromiseType = NativePromise;
+ using PromiseType = NativePromise;
explicit Producer(PromiseDispatchMode dispatchMode = PromiseDispatchMode::Default, const Logger::LogSiteIdentifier& creationSite = DEFAULT_LOGSITEIDENTIFIER)
: m_promise(adoptRef(new PromiseType(creationSite)))
@@ -1120,10 +1164,10 @@ class NativePromise::Producer final :
};
// A generic promise type that does the trick for simple use cases.
-using GenericPromise = NativePromise;
+using GenericPromise = NativePromise;
// A generic, non-exclusive promise type that does the trick for simple use cases.
-using GenericNonExclusivePromise = NativePromise;
+using GenericNonExclusivePromise = NativePromise;
template
class NativePromiseRequest final {
@@ -1184,9 +1228,9 @@ static auto invokeAsync(SerialFunctionDispatcher& targetQueue, Function&& functi
return promise;
}
-template
-struct LogArgument> {
- static String toString(const NativePromise& p)
+template
+struct LogArgument> {
+ static String toString(const NativePromise& p)
{
return makeString("NativePromise", LogArgument::toString(&p), '<', LogArgument::toString(p.logSiteIdentifier()), '>');
}
diff --git a/Source/WTF/wtf/TypeTraits.h b/Source/WTF/wtf/TypeTraits.h
index d5d306e3778c..d76ac6b1e2bd 100644
--- a/Source/WTF/wtf/TypeTraits.h
+++ b/Source/WTF/wtf/TypeTraits.h
@@ -107,6 +107,19 @@ static auto HasRefCountMethodsTest(long) -> std::false_type;
template
struct HasRefCountMethods : decltype(detail::HasRefCountMethodsTest(0)) { };
+// HasIsolatedCopy()
+namespace detail {
+
+template
+static auto HasIsolatedCopyTest(int) -> SFINAE1True().isolatedCopy())>;
+template
+static auto HasIsolatedCopyTest(long) -> std::false_type;
+
+} // namespace detail
+
+template
+struct HasIsolatedCopy : decltype(detail::HasIsolatedCopyTest(0)) { };
+
// LooksLikeRCSerialDispatcher implementation
namespace detail {
diff --git a/Source/WTF/wtf/URLParser.cpp b/Source/WTF/wtf/URLParser.cpp
index 800872baf935..56c50e8e0879 100644
--- a/Source/WTF/wtf/URLParser.cpp
+++ b/Source/WTF/wtf/URLParser.cpp
@@ -47,9 +47,7 @@ ALWAYS_INLINE static void appendCodePoint(Vector& destination, UChar32 co
destination.append(static_cast(codePoint));
return;
}
- destination.reserveCapacity(destination.size() + 2);
- destination.uncheckedAppend(U16_LEAD(codePoint));
- destination.uncheckedAppend(U16_TRAIL(codePoint));
+ destination.appendList({ U16_LEAD(codePoint), U16_TRAIL(codePoint) });
}
enum URLCharacterClass {
diff --git a/Source/WTF/wtf/Vector.h b/Source/WTF/wtf/Vector.h
index e194403e70eb..1c1152e50822 100644
--- a/Source/WTF/wtf/Vector.h
+++ b/Source/WTF/wtf/Vector.h
@@ -862,6 +862,7 @@ class Vector : private VectorBuffer {
template ALWAYS_INLINE void append(const U* u, size_t size) { append(u, size); }
template ALWAYS_INLINE bool tryAppend(const U* u, size_t size) { return append(u, size); }
template ALWAYS_INLINE void append(std::span span) { append(span.data(), span.size()); }
+ template ALWAYS_INLINE void appendList(std::initializer_list initializerList) { append(std::data(initializerList), initializerList.size()); }
template void appendVector(const Vector&);
template void appendVector(Vector&&);
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index cdbd0f9ac004..14858ef2a6a0 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -459,6 +459,7 @@ set(WebCore_NON_SVG_IDL_FILES
Modules/mediastream/OverconstrainedError.idl
Modules/mediastream/OverconstrainedErrorEvent.idl
Modules/mediastream/PhotoCapabilities.idl
+ Modules/mediastream/PhotoSettings.idl
Modules/mediastream/RTCAnswerOptions.idl
Modules/mediastream/RTCCertificate.idl
Modules/mediastream/RTCConfiguration.idl
diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make
index 628808d00706..503a7228a692 100644
--- a/Source/WebCore/DerivedSources.make
+++ b/Source/WebCore/DerivedSources.make
@@ -454,6 +454,7 @@ JS_BINDING_IDLS := \
$(WebCore)/Modules/mediastream/OverconstrainedError.idl \
$(WebCore)/Modules/mediastream/OverconstrainedErrorEvent.idl \
$(WebCore)/Modules/mediastream/PhotoCapabilities.idl \
+ $(WebCore)/Modules/mediastream/PhotoSettings.idl \
$(WebCore)/Modules/mediastream/RedEyeReduction.idl \
$(WebCore)/Modules/mediastream/RTCAnswerOptions.idl \
$(WebCore)/Modules/mediastream/RTCCertificate.idl \
diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake
index 964b0a2aea25..0e5a2800cf1e 100644
--- a/Source/WebCore/Headers.cmake
+++ b/Source/WebCore/Headers.cmake
@@ -2152,6 +2152,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/mediastream/MediaStreamTrackPrivate.h
platform/mediastream/MeteringMode.h
platform/mediastream/PhotoCapabilities.h
+ platform/mediastream/PhotoSettings.h
platform/mediastream/RedEyeReduction.h
platform/mediastream/RTCDataChannelHandler.h
platform/mediastream/RTCDataChannelHandlerClient.h
diff --git a/Source/WebCore/Modules/mediastream/ImageCapture.cpp b/Source/WebCore/Modules/mediastream/ImageCapture.cpp
index 0e3ac2b9223d..3fb8da362196 100644
--- a/Source/WebCore/Modules/mediastream/ImageCapture.cpp
+++ b/Source/WebCore/Modules/mediastream/ImageCapture.cpp
@@ -63,6 +63,16 @@ void ImageCapture::getPhotoCapabilities(PhotoCapabilitiesPromise&& promise)
m_track->getPhotoCapabilities(WTFMove(promise));
}
+void ImageCapture::getPhotoSettings(PhotoSettingsPromise&& promise)
+{
+ if (m_track->readyState() == MediaStreamTrack::State::Ended) {
+ promise.reject(Exception { InvalidStateError, "Track has ended"_s });
+ return;
+ }
+
+ m_track->getPhotoSettings(WTFMove(promise));
+}
+
const char* ImageCapture::activeDOMObjectName() const
{
return "ImageCapture";
diff --git a/Source/WebCore/Modules/mediastream/ImageCapture.h b/Source/WebCore/Modules/mediastream/ImageCapture.h
index eaa2024fd3aa..ff03eda74dc8 100644
--- a/Source/WebCore/Modules/mediastream/ImageCapture.h
+++ b/Source/WebCore/Modules/mediastream/ImageCapture.h
@@ -32,6 +32,7 @@
#include "JSDOMPromiseDeferred.h"
#include "MediaStreamTrack.h"
#include "PhotoCapabilities.h"
+#include "PhotoSettings.h"
namespace WebCore {
@@ -45,6 +46,9 @@ class ImageCapture : public RefCounted, public ActiveDOMObject {
using PhotoCapabilitiesPromise = DOMPromiseDeferred