commit 469e86eac6566af0b3c4441c498e3369d8b4ccaa
Author: Yuki Shiino <
yukis...@chromium.org>
AuthorDate: Sat Jun 12 16:03:03 2021
Commit: Chromium LUCI CQ <
chromiu...@luci-project-accounts.iam.gserviceaccount.com>
CommitDate: Sat Jun 12 16:03:03 2021
bind-gen: Make Blink buildable with the new IDL dictionary
Makes Blink code base buildable with both of the old and new IDL
dictionary implementations. Until
https://crrev.com/c/2928684
will enable the flag, the old IDL dictionaries are used in prod.
The plan of rolling out the new IDL dictionaries is:
1. Land this patch to make Blink able to work with both the old
and new IDL dictionary implementations.
2. Land
https://crrev.com/c/2928684 to enable the flag and make
Blink use the new IDL dictionary implementations.
3. Watch the stability for a few days ~ a week.
4. Remove the use cases of the old IDL dictionary
implementations and clean up.
Bug: 839389
Change-Id: If63d82c7018e3d881c5a4d66b54fda3d16aa2cda
Reviewed-on:
https://chromium-review.googlesource.com/c/chromium/src/+/2915025
Commit-Queue: Yuki Shiino <
yukis...@chromium.org>
Reviewed-by: Kentaro Hara <
har...@chromium.org>
Owners-Override: Kentaro Hara <
har...@chromium.org>
Cr-Commit-Position: refs/heads/master@{#891909}
diff --git a/third_party/blink/renderer/bindings/core/v8/dictionary.h b/third_party/blink/renderer/bindings/core/v8/dictionary.h
index 9909d90..4444970 100644
--- a/third_party/blink/renderer/bindings/core/v8/dictionary.h
+++ b/third_party/blink/renderer/bindings/core/v8/dictionary.h
@@ -27,6 +27,7 @@
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_DICTIONARY_H_
#include "third_party/abseil-cpp/absl/types/optional.h"
+#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/core_export.h"
diff --git a/third_party/blink/renderer/core/animation/animation_effect_test.cc b/third_party/blink/renderer/core/animation/animation_effect_test.cc
index 7628a5a1..4014443 100644
--- a/third_party/blink/renderer/core/animation/animation_effect_test.cc
+++ b/third_party/blink/renderer/core/animation/animation_effect_test.cc
@@ -790,12 +790,25 @@
effect->updateTiming(effect_timing);
EXPECT_EQ("ease-in-out", effect->getTiming()->easing());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ EXPECT_EQ("auto", effect->getTiming()->duration()->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ("auto", effect->getTiming()->duration().GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing = OptionalEffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ effect_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(2.5));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDuration(
UnrestrictedDoubleOrString::FromUnrestrictedDouble(2.5));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect->updateTiming(effect_timing);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ EXPECT_EQ(2.5, effect->getTiming()->duration()->GetAsUnrestrictedDouble());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ(2.5, effect->getTiming()->duration().GetAsUnrestrictedDouble());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
TEST(AnimationAnimationEffectTest, UpdateTimingThrowsWhenExpected) {
@@ -826,15 +839,26 @@
// If it is a number, duration must be non-negative and non-null.
exception_state.ClearException();
effect_timing = OptionalEffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ effect_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(-100));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDuration(
UnrestrictedDoubleOrString::FromUnrestrictedDouble(-100));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect->updateTiming(effect_timing, exception_state);
EXPECT_TRUE(exception_state.HadException());
exception_state.ClearException();
effect_timing = OptionalEffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ effect_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(
+ std::numeric_limits<double>::quiet_NaN()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDuration(UnrestrictedDoubleOrString::FromUnrestrictedDouble(
std::numeric_limits<double>::quiet_NaN()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect->updateTiming(effect_timing, exception_state);
EXPECT_TRUE(exception_state.HadException());
@@ -896,8 +920,13 @@
effect_timing = OptionalEffectTiming::Create();
effect_timing->setIterations(3);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ effect_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(2000));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDuration(
UnrestrictedDoubleOrString::FromUnrestrictedDouble(2000));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDirection("alternate-reverse");
effect->updateTiming(effect_timing);
diff --git a/third_party/blink/renderer/core/animation/animation_test.cc b/third_party/blink/renderer/core/animation/animation_test.cc
index 90ab0a3..be0ffc3 100644
--- a/third_party/blink/renderer/core/animation/animation_test.cc
+++ b/third_party/blink/renderer/core/animation/animation_test.cc
@@ -1509,8 +1509,14 @@
animation->CheckCanStartAnimationOnCompositor(nullptr));
OptionalEffectTiming* effect_timing = OptionalEffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ effect_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(
+ std::numeric_limits<double>::infinity()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDuration(UnrestrictedDoubleOrString::FromUnrestrictedDouble(
std::numeric_limits<double>::infinity()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
animation->effect()->updateTiming(effect_timing);
EXPECT_EQ(CompositorAnimations::kEffectHasUnsupportedTimingParameters,
animation->CheckCanStartAnimationOnCompositor(nullptr));
@@ -1682,8 +1688,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 20),
mojom::blink::ScrollType::kProgrammatic);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -1751,8 +1762,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 100),
mojom::blink::ScrollType::kProgrammatic);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -1830,8 +1846,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 20),
mojom::blink::ScrollType::kProgrammatic);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -1886,8 +1907,13 @@
// Create ScrollTimeline
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -2233,8 +2259,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 20),
mojom::blink::ScrollType::kProgrammatic);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
diff --git a/third_party/blink/renderer/core/animation/animation_test_helpers.cc b/third_party/blink/renderer/core/animation/animation_test_helpers.cc
index 081611a..7d75e8c 100644
--- a/third_party/blink/renderer/core/animation/animation_test_helpers.cc
+++ b/third_party/blink/renderer/core/animation/animation_test_helpers.cc
@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/animation/animation_test_helpers.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_csskeywordvalue_cssnumericvalue_scrolltimelineelementbasedoffset_string.h"
#include "third_party/blink/renderer/core/animation/css_interpolation_environment.h"
#include "third_party/blink/renderer/core/animation/css_interpolation_types_map.h"
#include "third_party/blink/renderer/core/animation/invalidatable_interpolation.h"
@@ -89,6 +90,22 @@
cascade.Apply();
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8ScrollTimelineOffset* OffsetFromString(Document& document,
+ const String& string) {
+ const CSSValue* value = css_test_helpers::ParseValue(
+ document, "<length-percentage> | auto", string);
+
+ if (const auto* primitive = DynamicTo<CSSPrimitiveValue>(value)) {
+ return MakeGarbageCollected<V8ScrollTimelineOffset>(
+ CSSNumericValue::FromCSSValue(*primitive));
+ } else if (DynamicTo<CSSIdentifierValue>(value)) {
+ return MakeGarbageCollected<V8ScrollTimelineOffset>(
+ CSSKeywordValue::Create("auto"));
+ }
+ return MakeGarbageCollected<V8ScrollTimelineOffset>(string);
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ScrollTimelineOffsetValue OffsetFromString(Document& document,
const String& string) {
ScrollTimelineOffsetValue result;
@@ -105,6 +122,7 @@
return result;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace animation_test_helpers
} // namespace blink
diff --git a/third_party/blink/renderer/core/animation/animation_test_helpers.h b/third_party/blink/renderer/core/animation/animation_test_helpers.h
index dd701819..442ee34 100644
--- a/third_party/blink/renderer/core/animation/animation_test_helpers.h
+++ b/third_party/blink/renderer/core/animation/animation_test_helpers.h
@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_ANIMATION_ANIMATION_TEST_HELPERS_H_
#include "third_party/blink/renderer/bindings/core/v8/css_numeric_value_or_string_or_css_keyword_value_or_scroll_timeline_element_based_offset.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/core/animation/interpolation.h"
#include "third_party/blink/renderer/core/animation/scroll_timeline_offset.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
@@ -50,7 +51,11 @@
// <length-percentage>.
// - A CSSKeywordValue. if the incoming string can be parsed as 'auto'.
// - Otherwise, the incoming string.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8ScrollTimelineOffset* OffsetFromString(Document&, const String&);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ScrollTimelineOffsetValue OffsetFromString(Document&, const String&);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace animation_test_helpers
} // namespace blink
diff --git a/third_party/blink/renderer/core/animation/effect_input.cc b/third_party/blink/renderer/core/animation/effect_input.cc
index e6b9c92e..f746728 100644
--- a/third_party/blink/renderer/core/animation/effect_input.cc
+++ b/third_party/blink/renderer/core/animation/effect_input.cc
@@ -64,6 +64,30 @@
// Converts the composite property of a BasePropertyIndexedKeyframe into a
// vector of absl::optional<EffectModel::CompositeOperation> enums.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+Vector<absl::optional<EffectModel::CompositeOperation>> ParseCompositeProperty(
+ const BasePropertyIndexedKeyframe* keyframe) {
+ const auto* composite = keyframe->composite();
+ switch (composite->GetContentType()) {
+ case V8UnionCompositeOperationOrAutoOrCompositeOperationOrAutoSequence::
+ ContentType::kCompositeOperationOrAuto:
+ return {EffectModel::StringToCompositeOperation(
+ composite->GetAsCompositeOperationOrAuto().AsString())};
+ case V8UnionCompositeOperationOrAutoOrCompositeOperationOrAutoSequence::
+ ContentType::kCompositeOperationOrAutoSequence: {
+ Vector<absl::optional<EffectModel::CompositeOperation>> result;
+ for (const auto& composite_operation :
+ composite->GetAsCompositeOperationOrAutoSequence()) {
+ result.push_back(EffectModel::StringToCompositeOperation(
+ composite_operation.AsString()));
+ }
+ return result;
+ }
+ }
+ NOTREACHED();
+ return {};
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Vector<absl::optional<EffectModel::CompositeOperation>> ParseCompositeProperty(
const BasePropertyIndexedKeyframe* keyframe) {
const CompositeOperationOrAutoOrCompositeOperationOrAutoSequence& composite =
@@ -82,6 +106,7 @@
}
return result;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void SetKeyframeValue(Element* element,
Document& document,
@@ -454,20 +479,36 @@
return {};
Vector<absl::optional<double>> offsets;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (property_indexed_keyframe->offset()->IsNull())
+ offsets.push_back(absl::nullopt);
+ else if (property_indexed_keyframe->offset()->IsDouble())
+ offsets.push_back(property_indexed_keyframe->offset()->GetAsDouble());
+ else
+ offsets = property_indexed_keyframe->offset()->GetAsDoubleOrNullSequence();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (property_indexed_keyframe->offset().IsNull())
offsets.push_back(absl::nullopt);
else if (property_indexed_keyframe->offset().IsDouble())
offsets.push_back(property_indexed_keyframe->offset().GetAsDouble());
else
offsets = property_indexed_keyframe->offset().GetAsDoubleOrNullSequence();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// The web-animations spec explicitly states that easings should be kept as
// DOMStrings here and not parsed into timing functions until later.
Vector<String> easings;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (property_indexed_keyframe->easing()->IsString())
+ easings.push_back(property_indexed_keyframe->easing()->GetAsString());
+ else
+ easings = property_indexed_keyframe->easing()->GetAsStringSequence();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (property_indexed_keyframe->easing().IsString())
easings.push_back(property_indexed_keyframe->easing().GetAsString());
else
easings = property_indexed_keyframe->easing().GetAsStringSequence();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Vector<absl::optional<EffectModel::CompositeOperation>> composite_operations =
ParseCompositeProperty(property_indexed_keyframe);
diff --git a/third_party/blink/renderer/core/animation/keyframe_effect_test.cc b/third_party/blink/renderer/core/animation/keyframe_effect_test.cc
index 4917fa3..0110802 100644
--- a/third_party/blink/renderer/core/animation/keyframe_effect_test.cc
+++ b/third_party/blink/renderer/core/animation/keyframe_effect_test.cc
@@ -304,10 +304,17 @@
timing_input_dictionary_with_duration);
EffectTiming* specified_with_duration = animation_with_duration->getTiming();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* duration = specified_with_duration->duration();
+ EXPECT_TRUE(duration->IsUnrestrictedDouble());
+ EXPECT_EQ(2.5, duration->GetAsUnrestrictedDouble());
+ EXPECT_FALSE(duration->IsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnrestrictedDoubleOrString duration = specified_with_duration->duration();
EXPECT_TRUE(duration.IsUnrestrictedDouble());
EXPECT_EQ(2.5, duration.GetAsUnrestrictedDouble());
EXPECT_FALSE(duration.IsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
v8::Local<v8::Object> timing_input_no_duration =
v8::Object::New(scope.GetIsolate());
@@ -321,10 +328,17 @@
timing_input_dictionary_no_duration);
EffectTiming* specified_no_duration = animation_no_duration->getTiming();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* duration2 = specified_no_duration->duration();
+ EXPECT_FALSE(duration2->IsUnrestrictedDouble());
+ EXPECT_TRUE(duration2->IsString());
+ EXPECT_EQ("auto", duration2->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnrestrictedDoubleOrString duration2 = specified_no_duration->duration();
EXPECT_FALSE(duration2.IsUnrestrictedDouble());
EXPECT_TRUE(duration2.IsString());
EXPECT_EQ("auto", duration2.GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
TEST_F(AnimationKeyframeEffectV8Test, SetKeyframesAdditiveCompositeOperation) {
diff --git a/third_party/blink/renderer/core/animation/scroll_timeline.cc b/third_party/blink/renderer/core/animation/scroll_timeline.cc
index c4a8b6b..537515b 100644
--- a/third_party/blink/renderer/core/animation/scroll_timeline.cc
+++ b/third_party/blink/renderer/core/animation/scroll_timeline.cc
@@ -136,9 +136,15 @@
}
absl::optional<double> time_range;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (options->timeRange()->IsDouble()) {
+ time_range = absl::make_optional(options->timeRange()->GetAsDouble());
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (options->timeRange().IsDouble()) {
time_range = absl::make_optional(options->timeRange().GetAsDouble());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// The scrollingElement depends on style/layout-tree in quirks mode. Update
// such that subsequent calls to ScrollingElementNoLayout returns up-to-date
diff --git a/third_party/blink/renderer/core/animation/scroll_timeline_offset.cc b/third_party/blink/renderer/core/animation/scroll_timeline_offset.cc
index 4f0711a..3c17a05f 100644
--- a/third_party/blink/renderer/core/animation/scroll_timeline_offset.cc
+++ b/third_party/blink/renderer/core/animation/scroll_timeline_offset.cc
@@ -22,7 +22,8 @@
namespace {
-bool ValidateElementBasedOffset(ScrollTimelineElementBasedOffset* offset) {
+bool ValidateElementBasedOffset(
+ const ScrollTimelineElementBasedOffset* offset) {
if (!offset->hasTarget())
return false;
@@ -66,6 +67,7 @@
o1->threshold() == o2->threshold();
}
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
CSSKeywordValue* GetCSSKeywordValue(const ScrollTimelineOffsetValue& offset) {
if (offset.IsCSSKeywordValue())
return offset.GetAsCSSKeywordValue();
@@ -74,9 +76,51 @@
return CSSKeywordValue::Create(offset.GetAsString());
return nullptr;
}
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+// static
+ScrollTimelineOffset* ScrollTimelineOffset::Create(
+ const V8ScrollTimelineOffset* offset) {
+ switch (offset->GetContentType()) {
+ case V8ScrollTimelineOffset::ContentType::kCSSKeywordValue: {
+ const auto* keyword = offset->GetAsCSSKeywordValue();
+ if (keyword->KeywordValueID() != CSSValueID::kAuto)
+ return nullptr;
+ return MakeGarbageCollected<ScrollTimelineOffset>();
+ }
+ case V8ScrollTimelineOffset::ContentType::kCSSNumericValue: {
+ const auto* value =
+ To<CSSPrimitiveValue>(offset->GetAsCSSNumericValue()->ToCSSValue());
+ bool matches_length_percentage =
+ value->IsLength() || value->IsPercentage() ||
+ value->IsCalculatedPercentageWithLength();
+ if (!matches_length_percentage)
+ return nullptr;
+ return MakeGarbageCollected<ScrollTimelineOffset>(value);
+ }
+ case V8ScrollTimelineOffset::ContentType::
+ kScrollTimelineElementBasedOffset: {
+ auto* value = offset->GetAsScrollTimelineElementBasedOffset();
+ if (!ValidateElementBasedOffset(value))
+ return nullptr;
+ return MakeGarbageCollected<ScrollTimelineOffset>(value);
+ }
+ case V8ScrollTimelineOffset::ContentType::kString: {
+ if (offset->GetAsString().IsEmpty())
+ return nullptr;
+ const auto* keyword = CSSKeywordValue::Create(offset->GetAsString());
+ if (keyword->KeywordValueID() != CSSValueID::kAuto)
+ return nullptr;
+ return MakeGarbageCollected<ScrollTimelineOffset>();
+ }
+ }
+ NOTREACHED();
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// static
ScrollTimelineOffset* ScrollTimelineOffset::Create(
const ScrollTimelineOffsetValue& input_offset) {
@@ -107,6 +151,7 @@
return nullptr;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
absl::optional<double> ScrollTimelineOffset::ResolveOffset(
Node* scroll_source,
diff --git a/third_party/blink/renderer/core/animation/scroll_timeline_offset.h b/third_party/blink/renderer/core/animation/scroll_timeline_offset.h
index bcb2888..8c1dca9 100644
--- a/third_party/blink/renderer/core/animation/scroll_timeline_offset.h
+++ b/third_party/blink/renderer/core/animation/scroll_timeline_offset.h
@@ -14,18 +14,24 @@
namespace blink {
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
class
CSSNumericValueOrStringOrCSSKeywordValueOrScrollTimelineElementBasedOffset;
using ScrollTimelineOffsetValue =
CSSNumericValueOrStringOrCSSKeywordValueOrScrollTimelineElementBasedOffset;
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// Represent a scroll timeline start/end offset which can be an
// scroll offset or an element based offset
class CORE_EXPORT ScrollTimelineOffset final
: public GarbageCollected<ScrollTimelineOffset> {
public:
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ static ScrollTimelineOffset* Create(const V8ScrollTimelineOffset* offset);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
static ScrollTimelineOffset* Create(const ScrollTimelineOffsetValue& offset);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// Create a default offset representing 'auto'.
ScrollTimelineOffset() = default;
diff --git a/third_party/blink/renderer/core/animation/scroll_timeline_offset_test.cc b/third_party/blink/renderer/core/animation/scroll_timeline_offset_test.cc
index fb88361..22182ab 100644
--- a/third_party/blink/renderer/core/animation/scroll_timeline_offset_test.cc
+++ b/third_party/blink/renderer/core/animation/scroll_timeline_offset_test.cc
@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/animation/scroll_timeline_offset.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_csskeywordvalue_cssnumericvalue_scrolltimelineelementbasedoffset_string.h"
#include "third_party/blink/renderer/core/animation/animation_test_helpers.h"
#include "third_party/blink/renderer/core/animation/scroll_timeline_offset.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
@@ -27,8 +28,12 @@
auto* inner = CreateElementBasedOffset(target, edge, threshold);
if (!inner)
return nullptr;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* param = MakeGarbageCollected<V8ScrollTimelineOffset>(inner);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ScrollTimelineOffsetValue param;
param.SetScrollTimelineElementBasedOffset(inner);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return ScrollTimelineOffset::Create(param);
}
diff --git a/third_party/blink/renderer/core/animation/scroll_timeline_test.cc b/third_party/blink/renderer/core/animation/scroll_timeline_test.cc
index bdc9d1c9..b3b7504 100644
--- a/third_party/blink/renderer/core/animation/scroll_timeline_test.cc
+++ b/third_party/blink/renderer/core/animation/scroll_timeline_test.cc
@@ -91,9 +91,15 @@
return count;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ V8ScrollTimelineOffset* OffsetFromString(const String& value) {
+ return animation_test_helpers::OffsetFromString(GetDocument(), value);
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ScrollTimelineOffsetValue OffsetFromString(const String& value) {
return animation_test_helpers::OffsetFromString(GetDocument(), value);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
};
class TestScrollTimeline : public ScrollTimeline {
@@ -134,8 +140,13 @@
ASSERT_TRUE(scroller);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -164,8 +175,13 @@
PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
ASSERT_TRUE(scrollable_area);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
options->setScrollOffsets(
@@ -200,16 +216,26 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 90),
mojom::blink::ScrollType::kProgrammatic);
SimulateFrame();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ EXPECT_EQ(scroll_timeline->CurrentTimeMilliseconds(),
+ time_range->GetAsDouble());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ(scroll_timeline->CurrentTimeMilliseconds(),
time_range.GetAsDouble());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ("after", scroll_timeline->phase());
current_time_is_null = true;
scrollable_area->SetScrollOffset(ScrollOffset(0, 100),
mojom::blink::ScrollType::kProgrammatic);
SimulateFrame();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ EXPECT_EQ(scroll_timeline->CurrentTimeMilliseconds(),
+ time_range->GetAsDouble());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ(scroll_timeline->CurrentTimeMilliseconds(),
time_range.GetAsDouble());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ("after", scroll_timeline->phase());
EXPECT_TRUE(scroll_timeline->IsActive());
}
@@ -233,8 +259,13 @@
PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
ASSERT_TRUE(scrollable_area);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
options->setScrollOffsets(
@@ -262,8 +293,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 100),
mojom::blink::ScrollType::kProgrammatic);
SimulateFrame();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ EXPECT_EQ(time_range->GetAsDouble(),
+ scroll_timeline->CurrentTimeMilliseconds());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ(time_range.GetAsDouble(),
scroll_timeline->CurrentTimeMilliseconds());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ("after", scroll_timeline->phase());
EXPECT_TRUE(scroll_timeline->IsActive());
}
@@ -286,8 +322,13 @@
PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
ASSERT_TRUE(scrollable_area);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
options->setScrollOffsets(
@@ -333,8 +374,13 @@
// Create the ScrollTimeline with Document.scrollingElement() as source. The
// resolved scroll source should be the Document.
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetDocument().scrollingElement());
ScrollTimeline* scroll_timeline =
@@ -359,8 +405,13 @@
// Create the ScrollTimeline with Document.scrollingElement() as source. The
// resolved scroll source should be the Document.
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetDocument().scrollingElement());
ScrollTimeline* scroll_timeline =
@@ -724,8 +775,13 @@
PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
ASSERT_TRUE(scrollable_area);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
@@ -933,11 +989,21 @@
ASSERT_TRUE(scrollable_area);
double time_range = 100.0;
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setTimeRange(
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(
+ time_range));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(
DoubleOrScrollTimelineAutoKeyword::FromDouble(time_range));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setScrollSource(GetElementById("scroller"));
// Empty scroll offsets resolve into [0, 100%].
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ HeapVector<Member<V8ScrollTimelineOffset>> scroll_offsets = {};
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
HeapVector<ScrollTimelineOffsetValue> scroll_offsets = {};
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setScrollOffsets(scroll_offsets);
ScrollTimeline* scroll_timeline =
@@ -1000,10 +1066,20 @@
ASSERT_TRUE(scrollable_area);
double time_range = 100.0;
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setTimeRange(
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(
+ time_range));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(
DoubleOrScrollTimelineAutoKeyword::FromDouble(time_range));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setScrollSource(GetElementById("scroller"));
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ HeapVector<Member<V8ScrollTimelineOffset>> scroll_offsets;
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
HeapVector<ScrollTimelineOffsetValue> scroll_offsets;
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
scroll_offsets.push_back(OffsetFromString("10px"));
scroll_offsets.push_back(OffsetFromString("20px"));
scroll_offsets.push_back(OffsetFromString("40px"));
@@ -1091,12 +1167,24 @@
ASSERT_TRUE(scrollable_area);
double time_range = 100.0;
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setTimeRange(
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(
+ time_range));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(
DoubleOrScrollTimelineAutoKeyword::FromDouble(time_range));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setScrollSource(GetElementById("scroller"));
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ HeapVector<Member<V8ScrollTimelineOffset>> scroll_offsets = {
+ OffsetFromString("90px"), OffsetFromString("40px"),
+ OffsetFromString("10px")};
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
HeapVector<ScrollTimelineOffsetValue> scroll_offsets = {
OffsetFromString("90px"), OffsetFromString("40px"),
OffsetFromString("10px")};
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setScrollOffsets(scroll_offsets);
ScrollTimeline* scroll_timeline =
diff --git a/third_party/blink/renderer/core/animation/scroll_timeline_util_test.cc b/third_party/blink/renderer/core/animation/scroll_timeline_util_test.cc
index 9742ddd..0752627 100644
--- a/third_party/blink/renderer/core/animation/scroll_timeline_util_test.cc
+++ b/third_party/blink/renderer/core/animation/scroll_timeline_util_test.cc
@@ -61,8 +61,14 @@
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
options->setScrollSource(scroller);
const double time_range = 100;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setTimeRange(
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(
+ time_range));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(
DoubleOrScrollTimelineAutoKeyword::FromDouble(time_range));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setOrientation("block");
options->setScrollOffsets({OffsetFromString(GetDocument(), "50px"),
OffsetFromString(GetDocument(), "auto")});
@@ -116,8 +122,13 @@
ASSERT_FALSE(div->GetLayoutBox());
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(div);
ScrollTimeline* timeline =
diff --git a/third_party/blink/renderer/core/animation/timing.cc b/third_party/blink/renderer/core/animation/timing.cc
index c1cec54..1c6a919 100644
--- a/third_party/blink/renderer/core/animation/timing.cc
+++ b/third_party/blink/renderer/core/animation/timing.cc
@@ -94,6 +94,16 @@
effect_timing->setFill(FillModeString(fill_mode));
effect_timing->setIterationStart(iteration_start);
effect_timing->setIterations(iteration_count);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ V8UnionStringOrUnrestrictedDouble* duration;
+ if (iteration_duration) {
+ duration = MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(
+ iteration_duration->InMillisecondsF());
+ } else {
+ duration = MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>("auto");
+ }
+ effect_timing->setDuration(duration);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnrestrictedDoubleOrString duration;
if (iteration_duration) {
duration.SetUnrestrictedDouble(iteration_duration->InMillisecondsF());
@@ -101,6 +111,7 @@
duration.SetString("auto");
}
effect_timing->setDuration(duration);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDirection(PlaybackDirectionString(direction));
effect_timing->setEasing(timing_function->ToString());
@@ -113,16 +124,32 @@
ComputedEffectTiming* computed_timing = ComputedEffectTiming::Create();
// ComputedEffectTiming members.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ computed_timing->setEndTime(MakeGarbageCollected<V8CSSNumberish>(
+ EndTimeInternal().InMillisecondsF()));
+ computed_timing->setActiveDuration(
+ MakeGarbageCollected<V8CSSNumberish>(ActiveDuration().InMillisecondsF()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
computed_timing->setEndTime(
CSSNumberish::FromDouble(EndTimeInternal().InMillisecondsF()));
computed_timing->setActiveDuration(
CSSNumberish::FromDouble(ActiveDuration().InMillisecondsF()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (calculated_timing.local_time) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ computed_timing->setLocalTime(MakeGarbageCollected<V8CSSNumberish>(
+ calculated_timing.local_time->InMillisecondsF()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
computed_timing->setLocalTime(CSSNumberish::FromDouble(
calculated_timing.local_time->InMillisecondsF()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} else {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ computed_timing->setLocalTime(nullptr);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
computed_timing->setLocalTime(CSSNumberish());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
if (calculated_timing.is_in_effect) {
@@ -132,8 +159,13 @@
computed_timing->setCurrentIteration(
calculated_timing.current_iteration.value());
} else {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ computed_timing->setProgress(absl::nullopt);
+ computed_timing->setCurrentIteration(absl::nullopt);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
computed_timing->setProgressToNull();
computed_timing->setCurrentIterationToNull();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
// For the EffectTiming members, getComputedTiming is equivalent to getTiming
@@ -147,9 +179,15 @@
computed_timing->setIterationStart(iteration_start);
computed_timing->setIterations(iteration_count);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ computed_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(
+ IterationDuration().InMillisecondsF()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnrestrictedDoubleOrString duration;
duration.SetUnrestrictedDouble(IterationDuration().InMillisecondsF());
computed_timing->setDuration(duration);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
computed_timing->setDirection(Timing::PlaybackDirectionString(direction));
computed_timing->setEasing(timing_function->ToString());
diff --git a/third_party/blink/renderer/core/animation/timing_input.cc b/third_party/blink/renderer/core/animation/timing_input.cc
index 17e214c..f15b87d 100644
--- a/third_party/blink/renderer/core/animation/timing_input.cc
+++ b/third_party/blink/renderer/core/animation/timing_input.cc
@@ -28,6 +28,16 @@
return Timing::PlaybackDirection::NORMAL;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+absl::optional<AnimationTimeDelta> ConvertIterationDuration(
+ const V8UnionStringOrUnrestrictedDouble* duration) {
+ if (duration->IsUnrestrictedDouble()) {
+ return AnimationTimeDelta::FromMillisecondsD(
+ duration->GetAsUnrestrictedDouble());
+ }
+ return absl::nullopt;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
absl::optional<AnimationTimeDelta> ConvertIterationDuration(
const UnrestrictedDoubleOrString& duration) {
if (duration.IsUnrestrictedDouble()) {
@@ -36,6 +46,7 @@
}
return absl::nullopt;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Timing ConvertEffectTiming(const EffectTiming* timing_input,
Document* document,
@@ -79,9 +90,15 @@
// Let timing input be a new EffectTiming object with all members set to
// their default values and duration set to options.
EffectTiming* timing_input = EffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ timing_input->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(
+ options->GetAsUnrestrictedDouble()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
timing_input->setDuration(
UnrestrictedDoubleOrString::FromUnrestrictedDouble(
options->GetAsUnrestrictedDouble()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return ConvertEffectTiming(timing_input, document, exception_state);
}
}
@@ -109,9 +126,15 @@
// Let timing input be a new EffectTiming object with all members set to
// their default values and duration set to options.
EffectTiming* timing_input = EffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ timing_input->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(
+ options->GetAsUnrestrictedDouble()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
timing_input->setDuration(
UnrestrictedDoubleOrString::FromUnrestrictedDouble(
options->GetAsUnrestrictedDouble()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return ConvertEffectTiming(timing_input, document, exception_state);
}
}
@@ -146,6 +169,25 @@
//
https://github.com/w3c/csswg-drafts/issues/247 .
if (input->hasDuration()) {
const char* error_message = "duration must be non-negative or auto";
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (input->duration()->GetContentType()) {
+ case V8UnionStringOrUnrestrictedDouble::ContentType::kString:
+ if (input->duration()->GetAsString() != "auto") {
+ exception_state.ThrowTypeError(error_message);
+ return false;
+ }
+ break;
+ case V8UnionStringOrUnrestrictedDouble::ContentType::
+ kUnrestrictedDouble: {
+ double duration = input->duration()->GetAsUnrestrictedDouble();
+ if (std::isnan(duration) || duration < 0) {
+ exception_state.ThrowTypeError(error_message);
+ return false;
+ }
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (input->duration().IsUnrestrictedDouble()) {
double duration = input->duration().GetAsUnrestrictedDouble();
if (std::isnan(duration) || duration < 0) {
@@ -156,6 +198,7 @@
exception_state.ThrowTypeError(error_message);
return false;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
// 4. If the easing member of input is present but cannot be parsed using the
diff --git a/third_party/blink/renderer/core/app_history/app_history.cc b/third_party/blink/renderer/core/app_history/app_history.cc
index 9f0447f..a5a186f 100644
--- a/third_party/blink/renderer/core/app_history/app_history.cc
+++ b/third_party/blink/renderer/core/app_history/app_history.cc
@@ -6,9 +6,10 @@
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_app_history_navigate_event_init.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_app_history_navigate_options.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/app_history/app_history_entry.h"
#include "third_party/blink/renderer/core/app_history/app_history_navigate_event.h"
-#include "third_party/blink/renderer/core/app_history/app_history_navigate_options.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/events/error_event.h"
#include "third_party/blink/renderer/core/frame/history_util.h"
@@ -255,8 +256,16 @@
MakeGarbageCollected<ScriptPromiseResolver>(script_state));
base::AutoReset<bool> did_react(&did_react_to_promise_, false);
goto_promise_resolver_ = nullptr;
- base::AutoReset<ScriptValue> event_info(&navigate_event_info_,
- options->navigateInfo());
+ base::AutoReset<ScriptValue> event_info(
+ &navigate_event_info_,
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->getNavigateInfoOr(
+ ScriptValue(script_state->GetIsolate(),
+ v8::Undefined(script_state->GetIsolate())))
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->navigateInfo()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ );
WebFrameLoadType frame_load_type = options->replace()
? WebFrameLoadType::kReplaceCurrentItem
: WebFrameLoadType::kStandard;
@@ -323,8 +332,16 @@
&navigate_method_call_promise_resolver_,
MakeGarbageCollected<ScriptPromiseResolver>(script_state));
goto_promise_resolver_ = nullptr;
- base::AutoReset<ScriptValue> event_info(&navigate_event_info_,
- options->navigateInfo());
+ base::AutoReset<ScriptValue> event_info(
+ &navigate_event_info_,
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->getNavigateInfoOr(
+ ScriptValue(script_state->GetIsolate(),
+ v8::Undefined(script_state->GetIsolate())))
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->navigateInfo()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ );
AppHistoryEntry* destination = entries_[keys_to_indices_.at(key)];
// TODO(japhet): Right now this is the only kind of back/forward navigation
// that fires the navigate event. This should probably move to a more central
@@ -422,7 +439,8 @@
init->setUserInitiated(involvement != UserNavigationInvolvement::kNone);
init->setFormData(form ? FormData::Create(form, ASSERT_NO_EXCEPTION)
: nullptr);
- init->setInfo(navigate_event_info_);
+ if (!(navigate_event_info_.IsEmpty() || navigate_event_info_.IsUndefined()))
+ init->setInfo(navigate_event_info_);
auto* navigate_event = AppHistoryNavigateEvent::Create(
GetSupplementable(), event_type_names::kNavigate, init);
navigate_event->SetUrl(url);
diff --git a/third_party/blink/renderer/core/app_history/app_history_navigate_event.cc b/third_party/blink/renderer/core/app_history/app_history_navigate_event.cc
index aca594e..f1f7bbd 100644
--- a/third_party/blink/renderer/core/app_history/app_history_navigate_event.cc
+++ b/third_party/blink/renderer/core/app_history/app_history_navigate_event.cc
@@ -23,7 +23,10 @@
user_initiated_(init->userInitiated()),
hash_change_(init->hashChange()),
form_data_(init->formData()),
- info_(init->info()) {
+ info_(init->hasInfo()
+ ? init->info()
+ : ScriptValue(context->GetIsolate(),
+ v8::Undefined(context->GetIsolate()))) {
DCHECK(IsA<LocalDOMWindow>(context));
}
diff --git a/third_party/blink/renderer/core/css/css_style_sheet.cc b/third_party/blink/renderer/core/css/css_style_sheet.cc
index 92739eb..f63be44 100644
--- a/third_party/blink/renderer/core/css/css_style_sheet.cc
+++ b/third_party/blink/renderer/core/css/css_style_sheet.cc
@@ -110,12 +110,24 @@
sheet->ClearOwnerRule();
contents->RegisterClient(sheet);
scoped_refptr<MediaQuerySet> media_query_set;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (options->media()->GetContentType()) {
+ case V8UnionMediaListOrString::ContentType::kMediaList:
+ media_query_set = options->media()->GetAsMediaList()->Queries()->Copy();
+ break;
+ case V8UnionMediaListOrString::ContentType::kString:
+ media_query_set = MediaQuerySet::Create(options->media()->GetAsString(),
+ document.GetExecutionContext());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (options->media().IsString()) {
media_query_set = MediaQuerySet::Create(options->media().GetAsString(),
document.GetExecutionContext());
} else {
media_query_set = options->media().GetAsMediaList()->Queries()->Copy();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* media_list = MakeGarbageCollected<MediaList>(
media_query_set, const_cast<CSSStyleSheet*>(sheet));
sheet->SetMedia(media_list);
diff --git a/third_party/blink/renderer/core/css/css_style_sheet_test.cc b/third_party/blink/renderer/core/css/css_style_sheet_test.cc
index 2ecb48e2..b18dda2 100644
--- a/third_party/blink/renderer/core/css/css_style_sheet_test.cc
+++ b/third_party/blink/renderer/core/css/css_style_sheet_test.cc
@@ -56,7 +56,12 @@
CSSStyleSheetConstructionWithNonEmptyCSSStyleSheetInit) {
DummyExceptionStateForTesting exception_state;
CSSStyleSheetInit* init = CSSStyleSheetInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setMedia(
+ MakeGarbageCollected<V8UnionMediaListOrString>("screen, print"));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setMedia(MediaListOrString::FromString("screen, print"));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setTitle("test");
init->setAlternate(true);
init->setDisabled(true);
@@ -68,7 +73,11 @@
EXPECT_EQ(sheet->ownerNode(), nullptr);
EXPECT_EQ(sheet->ownerRule(), nullptr);
EXPECT_EQ(sheet->media()->length(), 2U);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ EXPECT_EQ(sheet->media()->mediaText(nullptr), init->media()->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ(sheet->media()->mediaText(nullptr), init->media().GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ(sheet->title(), init->title());
EXPECT_TRUE(sheet->AlternateFromConstructor());
EXPECT_TRUE(sheet->disabled());
diff --git a/third_party/blink/renderer/core/fetch/headers.cc b/third_party/blink/renderer/core/fetch/headers.cc
index e894f49..f76661c 100644
--- a/third_party/blink/renderer/core/fetch/headers.cc
+++ b/third_party/blink/renderer/core/fetch/headers.cc
@@ -275,8 +275,7 @@
NOTREACHED();
}
-// TODO(
crbug.com/1181288): Remove the old IDL union version.
-// Old IDL dictionaries still use old IDL unions.
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Headers::FillWith(const HeadersInit& init,
ExceptionState& exception_state) {
DCHECK_EQ(header_list_->size(), 0U);
@@ -288,6 +287,7 @@
NOTREACHED();
}
}
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Headers::FillWith(const Vector<Vector<String>>& object,
ExceptionState& exception_state) {
diff --git a/third_party/blink/renderer/core/fetch/headers.h b/third_party/blink/renderer/core/fetch/headers.h
index da62763..386686cc 100644
--- a/third_party/blink/renderer/core/fetch/headers.h
+++ b/third_party/blink/renderer/core/fetch/headers.h
@@ -60,9 +60,9 @@
// These methods should only be called when size() would return 0.
void FillWith(const Headers*, ExceptionState&);
void FillWith(const V8HeadersInit* init, ExceptionState& exception_state);
- // TODO(
crbug.com/1181288): Remove the old IDL union version.
- // Old IDL dictionaries still use old IDL unions.
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void FillWith(const HeadersInit&, ExceptionState&);
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
//
https://fetch.spec.whatwg.org/#concept-headers-remove-privileged-no-cors-request-headers
void RemovePrivilegedNoCorsRequestHeaders();
diff --git a/third_party/blink/renderer/core/html/forms/form_data_event.cc b/third_party/blink/renderer/core/html/forms/form_data_event.cc
index 6f5fac0..b9e46fc 100644
--- a/third_party/blink/renderer/core/html/forms/form_data_event.cc
+++ b/third_party/blink/renderer/core/html/forms/form_data_event.cc
@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/bindings/core/v8/v8_form_data_event_init.h"
#include "third_party/blink/renderer/core/event_interface_names.h"
+#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/html/forms/form_data.h"
namespace blink {
diff --git a/third_party/blink/renderer/core/html/html_dialog_element.cc b/third_party/blink/renderer/core/html/html_dialog_element.cc
index 2e78100..82a99c1 100644
--- a/third_party/blink/renderer/core/html/html_dialog_element.cc
+++ b/third_party/blink/renderer/core/html/html_dialog_element.cc
@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/core/html/html_dialog_element.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_focus_options.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/flat_tree_traversal.h"
@@ -33,7 +34,6 @@
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
-#include "third_party/blink/renderer/core/html/focus_options.h"
#include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
@@ -137,11 +137,11 @@
// modify this element.
if (RuntimeEnabledFeatures::DialogFocusNewSpecBehaviorEnabled() &&
previously_focused_element_) {
- FocusOptions focus_options;
- focus_options.setPreventScroll(true);
+ FocusOptions* focus_options = FocusOptions::Create();
+ focus_options->setPreventScroll(true);
Element* previously_focused_element = previously_focused_element_;
previously_focused_element_ = nullptr;
- previously_focused_element->focus(&focus_options);
+ previously_focused_element->focus(focus_options);
}
}
diff --git a/third_party/blink/renderer/core/html/html_marquee_element.cc b/third_party/blink/renderer/core/html/html_marquee_element.cc
index 6cbe378..bc15149 100644
--- a/third_party/blink/renderer/core/html/html_marquee_element.cc
+++ b/third_party/blink/renderer/core/html/html_marquee_element.cc
@@ -292,8 +292,13 @@
Timing timing;
OptionalEffectTiming* effect_timing = OptionalEffectTiming::Create();
effect_timing->setFill("forwards");
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ effect_timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(duration));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
effect_timing->setDuration(
UnrestrictedDoubleOrString::FromUnrestrictedDouble(duration));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
TimingInput::Update(timing, effect_timing, nullptr, ASSERT_NO_EXCEPTION);
auto* keyframe_effect =
diff --git a/third_party/blink/renderer/core/html/track/track_event.cc b/third_party/blink/renderer/core/html/track/track_event.cc
index 3fb853e..cd4b8df 100644
--- a/third_party/blink/renderer/core/html/track/track_event.cc
+++ b/third_party/blink/renderer/core/html/track/track_event.cc
@@ -43,6 +43,20 @@
if (!initializer->hasTrack())
return;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const V8UnionAudioTrackOrTextTrackOrVideoTrack* track = initializer->track();
+ switch (track->GetContentType()) {
+ case V8UnionAudioTrackOrTextTrackOrVideoTrack::ContentType::kAudioTrack:
+ track_ = track->GetAsAudioTrack();
+ break;
+ case V8UnionAudioTrackOrTextTrackOrVideoTrack::ContentType::kTextTrack:
+ track_ = track->GetAsTextTrack();
+ break;
+ case V8UnionAudioTrackOrTextTrackOrVideoTrack::ContentType::kVideoTrack:
+ track_ = track->GetAsVideoTrack();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const VideoTrackOrAudioTrackOrTextTrack& track = initializer->track();
if (track.IsVideoTrack())
track_ = track.GetAsVideoTrack();
@@ -52,6 +66,7 @@
track_ = track.GetAsTextTrack();
else
NOTREACHED();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
TrackEvent::~TrackEvent() = default;
diff --git a/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc b/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc
index aa36959..b7449cc 100644
--- a/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc
+++ b/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc
@@ -103,7 +103,11 @@
BuildObjectForAnimationEffect(KeyframeEffect* effect) {
ComputedEffectTiming* computed_timing = effect->getComputedTiming();
double delay = computed_timing->delay();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ double duration = computed_timing->duration()->GetAsUnrestrictedDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
double duration = computed_timing->duration().GetAsUnrestrictedDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
String easing = effect->SpecifiedTiming().timing_function->ToString();
std::unique_ptr<protocol::Animation::AnimationEffect> animation_object =
@@ -385,9 +389,14 @@
NonThrowableExceptionState exception_state;
OptionalEffectTiming* timing = OptionalEffectTiming::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ timing->setDuration(
+ MakeGarbageCollected<V8UnionStringOrUnrestrictedDouble>(duration));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnrestrictedDoubleOrString unrestricted_duration;
unrestricted_duration.SetUnrestrictedDouble(duration);
timing->setDuration(unrestricted_duration);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
timing->setDelay(delay);
animation->effect()->updateTiming(timing, exception_state);
return Response::Success();
diff --git a/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc b/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc
index 1622705..091bc39 100644
--- a/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc
+++ b/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc
@@ -133,9 +133,26 @@
}
}
-void ParseThresholds(const DoubleOrDoubleSequence& threshold_parameter,
- Vector<float>& thresholds,
- ExceptionState& exception_state) {
+void ParseThresholds(
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const V8UnionDoubleOrDoubleSequence* threshold_parameter,
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const DoubleOrDoubleSequence& threshold_parameter,
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ Vector<float>& thresholds,
+ ExceptionState& exception_state) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (threshold_parameter->GetContentType()) {
+ case V8UnionDoubleOrDoubleSequence::ContentType::kDouble:
+ thresholds.push_back(
+ base::MakeClampedNum<float>(threshold_parameter->GetAsDouble()));
+ break;
+ case V8UnionDoubleOrDoubleSequence::ContentType::kDoubleSequence:
+ for (auto threshold_value : threshold_parameter->GetAsDoubleSequence())
+ thresholds.push_back(base::MakeClampedNum<float>(threshold_value));
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (threshold_parameter.IsDouble()) {
thresholds.push_back(
base::MakeClampedNum<float>(threshold_parameter.GetAsDouble()));
@@ -143,6 +160,7 @@
for (auto threshold_value : threshold_parameter.GetAsDoubleSequence())
thresholds.push_back(base::MakeClampedNum<float>(threshold_value));
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (thresholds.IsEmpty())
thresholds.push_back(0.f);
@@ -174,11 +192,24 @@
IntersectionObserverDelegate& delegate,
ExceptionState& exception_state) {
Node* root = nullptr;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (observer_init->root()) {
+ switch (observer_init->root()->GetContentType()) {
+ case V8UnionDocumentOrElement::ContentType::kDocument:
+ root = observer_init->root()->GetAsDocument();
+ break;
+ case V8UnionDocumentOrElement::ContentType::kElement:
+ root = observer_init->root()->GetAsElement();
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (observer_init->root().IsElement()) {
root = observer_init->root().GetAsElement();
} else if (observer_init->root().IsDocument()) {
root = observer_init->root().GetAsDocument();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DOMHighResTimeStamp delay = 0;
bool track_visibility = false;
diff --git a/third_party/blink/renderer/core/intersection_observer/intersection_observer_test.cc b/third_party/blink/renderer/core/intersection_observer/intersection_observer_test.cc
index ecced03..f4555398 100644
--- a/third_party/blink/renderer/core/intersection_observer/intersection_observer_test.cc
+++ b/third_party/blink/renderer/core/intersection_observer/intersection_observer_test.cc
@@ -87,7 +87,11 @@
Element* root = GetDocument().getElementById("root");
ASSERT_TRUE(root);
IntersectionObserverInit* observer_init = IntersectionObserverInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ observer_init->setRoot(MakeGarbageCollected<V8UnionDocumentOrElement>(root));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
observer_init->setRoot(ElementOrDocument::FromElement(root));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
TestIntersectionObserverDelegate* observer_delegate =
MakeGarbageCollected<TestIntersectionObserverDelegate>(GetDocument());
@@ -133,7 +137,12 @@
->GetFrame()
->GetDocument();
IntersectionObserverInit* observer_init = IntersectionObserverInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ observer_init->setRoot(
+ MakeGarbageCollected<V8UnionDocumentOrElement>(iframe_document));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
observer_init->setRoot(ElementOrDocument::FromDocument(iframe_document));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
TestIntersectionObserverDelegate* observer_delegate =
MakeGarbageCollected<TestIntersectionObserverDelegate>(GetDocument());
@@ -545,7 +554,11 @@
Persistent<Element> target = GetDocument().getElementById("target1");
Persistent<IntersectionObserverInit> observer_init =
IntersectionObserverInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ observer_init->setRoot(MakeGarbageCollected<V8UnionDocumentOrElement>(root));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
observer_init->setRoot(ElementOrDocument::FromElement(root));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Persistent<TestIntersectionObserverDelegate> observer_delegate =
MakeGarbageCollected<TestIntersectionObserverDelegate>(GetDocument());
Persistent<IntersectionObserver> observer =
@@ -707,7 +720,11 @@
Element* target2 = GetDocument().getElementById("target2");
IntersectionObserverInit* observer_init = IntersectionObserverInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ observer_init->setRoot(MakeGarbageCollected<V8UnionDocumentOrElement>(root));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
observer_init->setRoot(ElementOrDocument::FromElement(root));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
TestIntersectionObserverDelegate* observer_delegate =
MakeGarbageCollected<TestIntersectionObserverDelegate>(GetDocument());
diff --git a/third_party/blink/renderer/core/timing/measure_memory/measure_memory_controller.cc b/third_party/blink/renderer/core/timing/measure_memory/measure_memory_controller.cc
index 66a0568..601ef01 100644
--- a/third_party/blink/renderer/core/timing/measure_memory/measure_memory_controller.cc
+++ b/third_party/blink/renderer/core/timing/measure_memory/measure_memory_controller.cc
@@ -237,7 +237,9 @@
result->setUrl(kCrossOriginUrl);
}
result->setScope(ConvertScope(attribution->scope));
- result->setContainer(ConvertContainer(attribution));
+ if (auto* container = ConvertContainer(attribution)) {
+ result->setContainer(container);
+ }
return result;
}
diff --git a/third_party/blink/renderer/core/timing/performance.cc b/third_party/blink/renderer/core/timing/performance.cc
index 8fdbdaf..b8db6cc 100644
--- a/third_party/blink/renderer/core/timing/performance.cc
+++ b/third_party/blink/renderer/core/timing/performance.cc
@@ -128,7 +128,7 @@
.Record(execution_context->UkmRecorder());
}
-// TODO(
crbug.com/1181288): Remove the old IDL union version.
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
V8UnionDoubleOrString* StringOrDoubleToV8UnionDoubleOrString(
const StringOrDouble& value) {
if (value.IsString())
@@ -137,6 +137,7 @@
return MakeGarbageCollected<V8UnionDoubleOrString>(value.GetAsDouble());
return nullptr;
}
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace
@@ -903,18 +904,26 @@
return nullptr;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ V8UnionDoubleOrString* start = options->getStartOr(nullptr);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
V8UnionDoubleOrString* start = nullptr;
if (options->hasStart()) {
start = StringOrDoubleToV8UnionDoubleOrString(options->start());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
absl::optional<double> duration;
if (options->hasDuration()) {
duration = options->duration();
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ V8UnionDoubleOrString* end = options->getEndOr(nullptr);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
V8UnionDoubleOrString* end = nullptr;
if (options->hasEnd()) {
end = StringOrDoubleToV8UnionDoubleOrString(options->end());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return MeasureWithDetail(
script_state, measure_name, start, duration, end,
diff --git a/third_party/blink/renderer/core/typed_arrays/dom_array_piece.cc b/third_party/blink/renderer/core/typed_arrays/dom_array_piece.cc
index a49ddf8..b9cfcc0 100644
--- a/third_party/blink/renderer/core/typed_arrays/dom_array_piece.cc
+++ b/third_party/blink/renderer/core/typed_arrays/dom_array_piece.cc
@@ -39,7 +39,7 @@
InitNull();
}
-// TODO(
crbug.com/1181288): Remove the old IDL union version.
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DOMArrayPiece::DOMArrayPiece(
const ArrayBufferOrArrayBufferView& array_buffer_or_view) {
if (array_buffer_or_view.IsArrayBuffer()) {
@@ -51,6 +51,7 @@
InitWithArrayBufferView(array_buffer_view);
}
}
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
bool DOMArrayPiece::IsNull() const {
return is_null_;
diff --git a/third_party/blink/renderer/core/typed_arrays/dom_array_piece.h b/third_party/blink/renderer/core/typed_arrays/dom_array_piece.h
index 2954328..a855174 100644
--- a/third_party/blink/renderer/core/typed_arrays/dom_array_piece.h
+++ b/third_party/blink/renderer/core/typed_arrays/dom_array_piece.h
@@ -28,12 +28,17 @@
public:
DOMArrayPiece();
+ // NOLINTNEXTLINE(google-explicit-constructor)
DOMArrayPiece(DOMArrayBuffer* buffer);
+ // NOLINTNEXTLINE(google-explicit-constructor)
DOMArrayPiece(DOMArrayBufferView* view);
+ // NOLINTNEXTLINE(google-explicit-constructor)
DOMArrayPiece(
const V8UnionArrayBufferOrArrayBufferView* array_buffer_or_view);
- // TODO(
crbug.com/1181288): Remove the old IDL union version.
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ // NOLINTNEXTLINE(google-explicit-constructor)
DOMArrayPiece(const ArrayBufferOrArrayBufferView&);
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
bool operator==(const DOMArrayBuffer& other) const {
return ByteLength() == other.ByteLength() &&
diff --git a/third_party/blink/renderer/modules/ad_auction/navigator_auction.cc b/third_party/blink/renderer/modules/ad_auction/navigator_auction.cc
index 0fba4da..b157e77 100644
--- a/third_party/blink/renderer/modules/ad_auction/navigator_auction.cc
+++ b/third_party/blink/renderer/modules/ad_auction/navigator_auction.cc
@@ -256,6 +256,40 @@
if (!input.hasInterestGroupBuyers())
return true;
output.interest_group_buyers = mojom::blink::InterestGroupBuyers::New();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (input.interestGroupBuyers()->GetContentType()) {
+ case V8UnionUSVStringOrUSVStringSequence::ContentType::kUSVString: {
+ const String& maybe_wildcard =
+ input.interestGroupBuyers()->GetAsUSVString();
+ if (maybe_wildcard != "*") {
+ exception_state.ThrowTypeError(ErrorInvalidAuctionConfig(
+ input, "interestGroupBuyers", maybe_wildcard,
+ "must be \"*\" (wildcard) or a list of buyer https origin "
+ "strings."));
+ return false;
+ }
+ output.interest_group_buyers->set_all_buyers(
+ mojom::blink::AllBuyers::New());
+ break;
+ }
+ case V8UnionUSVStringOrUSVStringSequence::ContentType::kUSVStringSequence: {
+ Vector<scoped_refptr<const SecurityOrigin>> buyers;
+ for (const auto& buyer_str :
+ input.interestGroupBuyers()->GetAsUSVStringSequence()) {
+ scoped_refptr<const SecurityOrigin> buyer = ParseOrigin(buyer_str);
+ if (!buyer) {
+ exception_state.ThrowTypeError(ErrorInvalidAuctionConfig(
+ input, "interestGroupBuyers buyer", buyer_str,
+ "must be a valid https origin."));
+ return false;
+ }
+ buyers.push_back(buyer);
+ }
+ output.interest_group_buyers->set_buyers(std::move(buyers));
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (input.interestGroupBuyers().IsUSVString()) {
String maybe_wildcard = input.interestGroupBuyers().GetAsUSVString();
if (maybe_wildcard != "*") {
@@ -282,6 +316,7 @@
}
output.interest_group_buyers->set_buyers(std::move(buyers));
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return true;
}
diff --git a/third_party/blink/renderer/modules/animationworklet/worklet_animation_test.cc b/third_party/blink/renderer/modules/animationworklet/worklet_animation_test.cc
index 8a7edb2..b857086 100644
--- a/third_party/blink/renderer/modules/animationworklet/worklet_animation_test.cc
+++ b/third_party/blink/renderer/modules/animationworklet/worklet_animation_test.cc
@@ -202,8 +202,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 20),
mojom::blink::ScrollType::kProgrammatic);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -319,8 +324,13 @@
scrollable_area->SetScrollOffset(ScrollOffset(0, 20),
mojom::blink::ScrollType::kProgrammatic);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -373,8 +383,13 @@
PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
ASSERT_TRUE(scrollable_area);
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(GetElementById("scroller"));
ScrollTimeline* scroll_timeline =
@@ -422,8 +437,13 @@
Element* scroller_element = GetElementById("scroller");
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(scroller_element);
ScrollTimeline* scroll_timeline =
@@ -479,8 +499,13 @@
Element* scroller_element = GetElementById("scroller");
ScrollTimelineOptions* options = ScrollTimelineOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* time_range =
+ MakeGarbageCollected<V8UnionDoubleOrScrollTimelineAutoKeyword>(100);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrScrollTimelineAutoKeyword time_range =
DoubleOrScrollTimelineAutoKeyword::FromDouble(100);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setTimeRange(time_range);
options->setScrollSource(scroller_element);
ScrollTimeline* scroll_timeline =
diff --git a/third_party/blink/renderer/modules/bluetooth/bluetooth.cc b/third_party/blink/renderer/modules/bluetooth/bluetooth.cc
index de7241c..d1c5ee9 100644
--- a/third_party/blink/renderer/modules/bluetooth/bluetooth.cc
+++ b/third_party/blink/renderer/modules/bluetooth/bluetooth.cc
@@ -58,6 +58,7 @@
namespace {
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// TODO(
crbug.com/1181288): Remove the old IDL union version.
V8BluetoothServiceUUID* ToV8BluetoothServiceUUID(
const StringOrUnsignedLong& uuid) {
@@ -70,6 +71,7 @@
NOTREACHED();
return nullptr;
}
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace
@@ -106,6 +108,15 @@
return;
}
canonicalized_filter->services.emplace();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ for (const V8UnionStringOrUnsignedLong* service : filter->services()) {
+ const String& validated_service =
+ BluetoothUUID::getService(service, exception_state);
+ if (exception_state.HadException())
+ return;
+ canonicalized_filter->services->push_back(validated_service);
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
for (const StringOrUnsignedLong& service : filter->services()) {
const String& validated_service = BluetoothUUID::getService(
ToV8BluetoothServiceUUID(service), exception_state);
@@ -113,6 +124,7 @@
return;
canonicalized_filter->services->push_back(validated_service);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
if (filter->hasName()) {
@@ -146,8 +158,14 @@
}
canonicalized_filter->manufacturer_data.emplace();
for (const auto& manufacturer_data : filter->manufacturerData()) {
- DOMArrayPiece mask_buffer = manufacturer_data->mask();
- DOMArrayPiece data_prefix_buffer = manufacturer_data->dataPrefix();
+ DOMArrayPiece mask_buffer = manufacturer_data->hasMask()
+ ? DOMArrayPiece(manufacturer_data->mask())
+ : DOMArrayPiece();
+ DOMArrayPiece data_prefix_buffer =
+ manufacturer_data->hasDataPrefix()
+ ? DOMArrayPiece(manufacturer_data->dataPrefix())
+ : DOMArrayPiece();
+
if (manufacturer_data->hasMask()) {
if (mask_buffer.IsDetached()) {
exception_state.ThrowDOMException(
@@ -247,6 +265,16 @@
}
if (options->hasOptionalServices()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ for (const V8UnionStringOrUnsignedLong* optional_service :
+ options->optionalServices()) {
+ const String& validated_optional_service =
+ BluetoothUUID::getService(optional_service, exception_state);
+ if (exception_state.HadException())
+ return;
+ result->optional_services.push_back(validated_optional_service);
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
for (const StringOrUnsignedLong& optional_service :
options->optionalServices()) {
const String& validated_optional_service = BluetoothUUID::getService(
@@ -255,6 +283,7 @@
return;
result->optional_services.push_back(validated_optional_service);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
if (options->hasOptionalManufacturerData()) {
diff --git a/third_party/blink/renderer/modules/bluetooth/bluetooth_advertising_event.cc b/third_party/blink/renderer/modules/bluetooth/bluetooth_advertising_event.cc
index 9f318ae..8be2b5f 100644
--- a/third_party/blink/renderer/modules/bluetooth/bluetooth_advertising_event.cc
+++ b/third_party/blink/renderer/modules/bluetooth/bluetooth_advertising_event.cc
@@ -25,6 +25,11 @@
rssi_(initializer->hasRssi() ? initializer->rssi() : 0),
manufacturer_data_map_(initializer->manufacturerData()),
service_data_map_(initializer->serviceData()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (initializer->hasUuids()) {
+ uuids_ = initializer->uuids();
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
for (const auto& uuid : initializer->uuids()) {
if (uuid.IsString()) {
uuids_.push_back(
@@ -36,6 +41,7 @@
NOTREACHED();
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
BluetoothAdvertisingEvent::BluetoothAdvertisingEvent(
diff --git a/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc b/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc
index 195ecbf..de06c805 100644
--- a/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc
+++ b/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc
@@ -20,6 +20,7 @@
#include "third_party/blink/renderer/modules/bluetooth/bluetooth_attribute_instance_map.h"
#include "third_party/blink/renderer/modules/bluetooth/bluetooth_error.h"
#include "third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_server.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
namespace blink {
diff --git a/third_party/blink/renderer/modules/bluetooth/bluetooth_le_scan.cc b/third_party/blink/renderer/modules/bluetooth/bluetooth_le_scan.cc
index 84df2a3..46498b3 100644
--- a/third_party/blink/renderer/modules/bluetooth/bluetooth_le_scan.cc
+++ b/third_party/blink/renderer/modules/bluetooth/bluetooth_le_scan.cc
@@ -30,12 +30,20 @@
filter_init->setNamePrefix(filter->name_prefix);
if (filter->services && filter->services.has_value()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ HeapVector<Member<V8UnionStringOrUnsignedLong>> services;
+ for (const auto& uuid : filter->services.value()) {
+ services.push_back(
+ MakeGarbageCollected<V8UnionStringOrUnsignedLong>(uuid));
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
HeapVector<blink::StringOrUnsignedLong> services;
for (const auto& uuid : filter->services.value()) {
blink::StringOrUnsignedLong uuid_string;
uuid_string.SetString(uuid);
services.push_back(uuid_string);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
filter_init->setServices(services);
}
filters_.push_back(std::move(filter_init));
diff --git a/third_party/blink/renderer/modules/breakout_box/media_stream_track_generator.cc b/third_party/blink/renderer/modules/breakout_box/media_stream_track_generator.cc
index e3f6501..880e33e 100644
--- a/third_party/blink/renderer/modules/breakout_box/media_stream_track_generator.cc
+++ b/third_party/blink/renderer/modules/breakout_box/media_stream_track_generator.cc
@@ -102,7 +102,12 @@
return MakeGarbageCollected<MediaStreamTrackGenerator>(
script_state, type,
- /*track_id=*/WTF::CreateCanonicalUUIDString(), init->signalTarget(),
+ /*track_id=*/WTF::CreateCanonicalUUIDString(),
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->getSignalTargetOr(nullptr),
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->signalTarget(),
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
max_signal_buffer_size);
}
diff --git a/third_party/blink/renderer/modules/compute_pressure/compute_pressure_observer.cc b/third_party/blink/renderer/modules/compute_pressure/compute_pressure_observer.cc
index e9feea6..197a15d8 100644
--- a/third_party/blink/renderer/modules/compute_pressure/compute_pressure_observer.cc
+++ b/third_party/blink/renderer/modules/compute_pressure/compute_pressure_observer.cc
@@ -9,10 +9,10 @@
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_compute_pressure_observer_options.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_compute_pressure_observer_update.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
-#include "third_party/blink/renderer/modules/compute_pressure/compute_pressure_observer_options.h"
-#include "third_party/blink/renderer/modules/compute_pressure/compute_pressure_observer_update.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
diff --git a/third_party/blink/renderer/modules/cookie_store/cookie_change_event.cc b/third_party/blink/renderer/modules/cookie_store/cookie_change_event.cc
index ccb4af1..bb5616e 100644
--- a/third_party/blink/renderer/modules/cookie_store/cookie_change_event.cc
+++ b/third_party/blink/renderer/modules/cookie_store/cookie_change_event.cc
@@ -109,8 +109,11 @@
if (!is_deleted) {
list_item->setValue(String::FromUTF8(canonical_cookie.Value()));
if (canonical_cookie.ExpiryDate().is_null()) {
- // TODO(
crbug.com/1070871): Use absl::nullopt instead.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ list_item->setExpires(absl::nullopt);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
list_item->setExpiresToNull();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} else {
list_item->setExpires(ConvertSecondsToDOMTimeStamp(
canonical_cookie.ExpiryDate().ToDoubleT()));
diff --git a/third_party/blink/renderer/modules/cookie_store/cookie_store.cc b/third_party/blink/renderer/modules/cookie_store/cookie_store.cc
index 73c8f65..606ca6e6 100644
--- a/third_party/blink/renderer/modules/cookie_store/cookie_store.cc
+++ b/third_party/blink/renderer/modules/cookie_store/cookie_store.cc
@@ -12,6 +12,7 @@
#include "services/network/public/mojom/restricted_cookie_manager.mojom-blink.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_cookie_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_cookie_list_item.h"
diff --git a/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc b/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc
index 287e63b..12812da 100644
--- a/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc
+++ b/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.cc
@@ -11,6 +11,8 @@
#include "build/build_config.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_large_blob_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authenticator_selection_criteria.h"
@@ -22,6 +24,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_request_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_rp_entity.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_user_entity.h"
+#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
#include "third_party/blink/renderer/modules/credentialmanager/credential.h"
#include "third_party/blink/renderer/modules/credentialmanager/federated_credential.h"
#include "third_party/blink/renderer/modules/credentialmanager/password_credential.h"
@@ -180,6 +183,15 @@
}
// static helper method.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+Vector<uint8_t> ConvertFixedSizeArray(const blink::V8BufferSource* buffer,
+ unsigned length) {
+ if (blink::DOMArrayPiece(buffer).ByteLength() != length)
+ return {};
+
+ return ConvertTo<Vector<uint8_t>>(buffer);
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Vector<uint8_t> ConvertFixedSizeArray(
const blink::ArrayBufferOrArrayBufferView& buffer,
unsigned length) {
@@ -195,7 +207,32 @@
return ConvertTo<Vector<uint8_t>>(buffer);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+// static
+Vector<uint8_t>
+TypeConverter<Vector<uint8_t>, blink::V8UnionArrayBufferOrArrayBufferView*>::
+ Convert(const blink::V8UnionArrayBufferOrArrayBufferView* buffer) {
+ DCHECK(buffer);
+ Vector<uint8_t> vector;
+ switch (buffer->GetContentType()) {
+ case blink::V8UnionArrayBufferOrArrayBufferView::ContentType::kArrayBuffer:
+ vector.Append(static_cast<uint8_t*>(buffer->GetAsArrayBuffer()->Data()),
+ base::checked_cast<wtf_size_t>(
+ buffer->GetAsArrayBuffer()->ByteLength()));
+ break;
+ case blink::V8UnionArrayBufferOrArrayBufferView::ContentType::
+ kArrayBufferView:
+ vector.Append(
+ static_cast<uint8_t*>(buffer->GetAsArrayBufferView()->BaseAddress()),
+ base::checked_cast<wtf_size_t>(
+ buffer->GetAsArrayBufferView()->byteLength()));
+ break;
+ }
+ return vector;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// static
Vector<uint8_t>
TypeConverter<Vector<uint8_t>, blink::ArrayBufferOrArrayBufferView>::Convert(
@@ -215,6 +252,7 @@
}
return vector;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// static
PublicKeyCredentialType TypeConverter<PublicKeyCredentialType, String>::Convert(
diff --git a/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.h b/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.h
index fe48abd..2187ad9 100644
--- a/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.h
+++ b/third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.h
@@ -13,8 +13,8 @@
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
-class AuthenticatorSelectionCriteria;
class ArrayBufferOrArrayBufferView;
+class AuthenticatorSelectionCriteria;
class CableAuthenticationData;
class CableRegistrationData;
class Credential;
@@ -25,6 +25,7 @@
class PublicKeyCredentialRpEntity;
class PublicKeyCredentialUserEntity;
class UserVerificationRequirement;
+class V8UnionArrayBufferOrArrayBufferView;
} // namespace blink
namespace mojo {
@@ -52,10 +53,19 @@
const blink::mojom::blink::AuthenticatorStatus&);
};
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+template <>
+struct TypeConverter<Vector<uint8_t>,
+ blink::V8UnionArrayBufferOrArrayBufferView*> {
+ static Vector<uint8_t> Convert(
+ const blink::V8UnionArrayBufferOrArrayBufferView*);
+};
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
template <>
struct TypeConverter<Vector<uint8_t>, blink::ArrayBufferOrArrayBufferView> {
static Vector<uint8_t> Convert(const blink::ArrayBufferOrArrayBufferView&);
};
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
template <>
struct TypeConverter<blink::mojom::blink::PublicKeyCredentialType, String> {
diff --git a/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc b/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
index 53b140b..115d7b3 100644
--- a/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
+++ b/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
@@ -292,6 +292,25 @@
// Checks if the size of the supplied ArrayBuffer or ArrayBufferView is at most
// the maximum size allowed.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+bool IsArrayBufferOrViewBelowSizeLimit(
+ const V8UnionArrayBufferOrArrayBufferView* buffer_or_view) {
+ if (!buffer_or_view)
+ return true;
+ switch (buffer_or_view->GetContentType()) {
+ case V8UnionArrayBufferOrArrayBufferView::ContentType::kArrayBuffer:
+ return base::CheckedNumeric<wtf_size_t>(
+ buffer_or_view->GetAsArrayBuffer()->ByteLength())
+ .IsValid();
+ case V8UnionArrayBufferOrArrayBufferView::ContentType::kArrayBufferView:
+ return base::CheckedNumeric<wtf_size_t>(
+ buffer_or_view->GetAsArrayBufferView()->byteLength())
+ .IsValid();
+ }
+ NOTREACHED();
+ return false;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
bool IsArrayBufferOrViewBelowSizeLimit(
ArrayBufferOrArrayBufferView buffer_or_view) {
if (buffer_or_view.IsNull())
@@ -308,6 +327,7 @@
buffer_or_view.GetAsArrayBufferView()->byteLength())
.IsValid();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DOMException* CredentialManagerErrorToDOMException(
CredentialManagerError reason) {
@@ -1214,6 +1234,16 @@
}
if (options->hasPassword()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ resolver->Resolve(
+ options->password()->IsPasswordCredentialData()
+ ? PasswordCredential::Create(
+ options->password()->GetAsPasswordCredentialData(),
+ exception_state)
+ : PasswordCredential::Create(
+ options->password()->GetAsHTMLFormElement(),
+ exception_state));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
resolver->Resolve(
options->password().IsPasswordCredentialData()
? PasswordCredential::Create(
@@ -1221,6 +1251,7 @@
exception_state)
: PasswordCredential::Create(
options->password().GetAsHTMLFormElement(), exception_state));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return promise;
}
if (options->hasFederated()) {
diff --git a/third_party/blink/renderer/modules/credentialmanager/credentials_container_test.cc b/third_party/blink/renderer/modules/credentialmanager/credentials_container_test.cc
index 0463d18..fcb7f74 100644
--- a/third_party/blink/renderer/modules/credentialmanager/credentials_container_test.cc
+++ b/third_party/blink/renderer/modules/credentialmanager/credentials_container_test.cc
@@ -249,9 +249,15 @@
auto* user_options = PublicKeyCredentialUserEntity::Create();
int dummy_buffer_source = 1;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* dummy_buffer =
+ MakeGarbageCollected<V8BufferSource>(DOMArrayBuffer::Create(
+ &dummy_buffer_source, sizeof(dummy_buffer_source)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto dummy_buffer =
ArrayBufferOrArrayBufferView::FromArrayBuffer(DOMArrayBuffer::Create(
&dummy_buffer_source, sizeof(dummy_buffer_source)));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
user_options->setId(dummy_buffer);
user_options->setIcon("invalid URL");
diff --git a/third_party/blink/renderer/modules/file_system_access/file_system_underlying_sink.cc b/third_party/blink/renderer/modules/file_system_access/file_system_underlying_sink.cc
index e2151857..c6030b7 100644
--- a/third_party/blink/renderer/modules/file_system_access/file_system_underlying_sink.cc
+++ b/third_party/blink/renderer/modules/file_system_access/file_system_underlying_sink.cc
@@ -123,6 +123,9 @@
"Invalid params passed. write requires a data argument");
return ScriptPromise();
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ return WriteData(script_state, position, params.data(), exception_state);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
V8UnionArrayBufferOrArrayBufferViewOrBlobOrUSVString* data;
if (params.data().IsArrayBuffer()) {
data = MakeGarbageCollected<
@@ -143,6 +146,7 @@
params.data().GetAsUSVString());
}
return WriteData(script_state, position, data, exception_state);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
diff --git a/third_party/blink/renderer/modules/file_system_access/global_file_system_access.cc b/third_party/blink/renderer/modules/file_system_access/global_file_system_access.cc
index e19c2be..2c2c4a1 100644
--- a/third_party/blink/renderer/modules/file_system_access/global_file_system_access.cc
+++ b/third_party/blink/renderer/modules/file_system_access/global_file_system_access.cc
@@ -138,6 +138,24 @@
}
mimeTypes.push_back(type);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (a.second->GetContentType()) {
+ case V8UnionUSVStringOrUSVStringSequence::ContentType::kUSVString:
+ if (!AddExtension(a.second->GetAsUSVString(), extensions,
+ exception_state)) {
+ return {};
+ }
+ break;
+ case V8UnionUSVStringOrUSVStringSequence::ContentType::
+ kUSVStringSequence:
+ for (const auto& extension : a.second->GetAsUSVStringSequence()) {
+ if (!AddExtension(extension, extensions, exception_state)) {
+ return {};
+ }
+ }
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (a.second.IsUSVString()) {
if (!AddExtension(a.second.GetAsUSVString(), extensions,
exception_state))
@@ -148,6 +166,7 @@
return {};
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
result.emplace_back(
blink::mojom::blink::ChooseFileSystemEntryAcceptsOption::New(
@@ -309,6 +328,20 @@
mojom::blink::WellKnownDirectory::kDefault;
mojo::PendingRemote<blink::mojom::blink::FileSystemAccessTransferToken> token;
if (options->hasStartIn()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto* start_in = options->startIn();
+ switch (start_in->GetContentType()) {
+ case V8UnionFileSystemHandleOrWellKnownDirectory::ContentType::
+ kFileSystemHandle:
+ token = start_in->GetAsFileSystemHandle()->Transfer();
+ break;
+ case V8UnionFileSystemHandleOrWellKnownDirectory::ContentType::
+ kWellKnownDirectory:
+ well_known_starting_directory =
+ ConvertWellKnownDirectory(start_in->GetAsWellKnownDirectory());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto& start_in = options->startIn();
if (start_in.IsWellKnownDirectory()) {
well_known_starting_directory =
@@ -317,6 +350,7 @@
if (start_in.IsFileSystemHandle()) {
token = start_in.GetAsFileSystemHandle()->Transfer();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
VerifyIsAllowedToShowFilePicker(window, exception_state);
@@ -368,6 +402,20 @@
mojom::blink::WellKnownDirectory::kDefault;
mojo::PendingRemote<blink::mojom::blink::FileSystemAccessTransferToken> token;
if (options->hasStartIn()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto* start_in = options->startIn();
+ switch (start_in->GetContentType()) {
+ case V8UnionFileSystemHandleOrWellKnownDirectory::ContentType::
+ kFileSystemHandle:
+ token = start_in->GetAsFileSystemHandle()->Transfer();
+ break;
+ case V8UnionFileSystemHandleOrWellKnownDirectory::ContentType::
+ kWellKnownDirectory:
+ well_known_starting_directory =
+ ConvertWellKnownDirectory(start_in->GetAsWellKnownDirectory());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto& start_in = options->startIn();
if (start_in.IsWellKnownDirectory()) {
well_known_starting_directory =
@@ -376,6 +424,7 @@
if (start_in.IsFileSystemHandle()) {
token = start_in.GetAsFileSystemHandle()->Transfer();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
VerifyIsAllowedToShowFilePicker(window, exception_state);
@@ -417,6 +466,20 @@
mojom::blink::WellKnownDirectory::kDefault;
mojo::PendingRemote<blink::mojom::blink::FileSystemAccessTransferToken> token;
if (options->hasStartIn()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto* start_in = options->startIn();
+ switch (start_in->GetContentType()) {
+ case V8UnionFileSystemHandleOrWellKnownDirectory::ContentType::
+ kFileSystemHandle:
+ token = start_in->GetAsFileSystemHandle()->Transfer();
+ break;
+ case V8UnionFileSystemHandleOrWellKnownDirectory::ContentType::
+ kWellKnownDirectory:
+ well_known_starting_directory =
+ ConvertWellKnownDirectory(start_in->GetAsWellKnownDirectory());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto& start_in = options->startIn();
if (start_in.IsWellKnownDirectory()) {
well_known_starting_directory =
@@ -425,6 +488,7 @@
if (start_in.IsFileSystemHandle()) {
token = start_in.GetAsFileSystemHandle()->Transfer();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
VerifyIsAllowedToShowFilePicker(window, exception_state);
diff --git a/third_party/blink/renderer/modules/imagecapture/image_capture.cc b/third_party/blink/renderer/modules/imagecapture/image_capture.cc
index da85cd3..a6f7aa3f 100644
--- a/third_party/blink/renderer/modules/imagecapture/image_capture.cc
+++ b/third_party/blink/renderer/modules/imagecapture/image_capture.cc
@@ -20,6 +20,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_capabilities.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_photo_capabilities.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_point_2d.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
@@ -501,11 +502,22 @@
// TODO(mcasas): support other Mode types beyond simple string i.e. the
// equivalents of "sequence<DOMString>"" or "ConstrainDOMStringParameters".
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_white_balance_mode =
+ constraints->hasWhiteBalanceMode() &&
+ constraints->whiteBalanceMode()->IsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_white_balance_mode = constraints->hasWhiteBalanceMode() &&
constraints->whiteBalanceMode().IsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_white_balance_mode) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto white_balance_mode =
+ constraints->whiteBalanceMode()->GetAsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto white_balance_mode =
constraints->whiteBalanceMode().GetAsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (capabilities_->whiteBalanceMode().Find(white_balance_mode) ==
kNotFound) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -516,10 +528,19 @@
temp_constraints->setWhiteBalanceMode(constraints->whiteBalanceMode());
settings->white_balance_mode = ParseMeteringMode(white_balance_mode);
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_exposure_mode =
+ constraints->hasExposureMode() && constraints->exposureMode()->IsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_exposure_mode =
constraints->hasExposureMode() && constraints->exposureMode().IsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_exposure_mode) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto exposure_mode = constraints->exposureMode()->GetAsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto exposure_mode = constraints->exposureMode().GetAsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (capabilities_->exposureMode().Find(exposure_mode) == kNotFound) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, "Unsupported exposureMode."));
@@ -529,10 +550,19 @@
settings->exposure_mode = ParseMeteringMode(exposure_mode);
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_focus_mode =
+ constraints->hasFocusMode() && constraints->focusMode()->IsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_focus_mode =
constraints->hasFocusMode() && constraints->focusMode().IsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_focus_mode) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto focus_mode = constraints->focusMode()->GetAsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto focus_mode = constraints->focusMode().GetAsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (capabilities_->focusMode().Find(focus_mode) == kNotFound) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, "Unsupported focusMode."));
@@ -544,9 +574,19 @@
// TODO(mcasas): support ConstrainPoint2DParameters.
if (constraints->hasPointsOfInterest() &&
- constraints->pointsOfInterest().IsPoint2DSequence()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ constraints->pointsOfInterest()->IsPoint2DSequence()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ constraints->pointsOfInterest().IsPoint2DSequence()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
for (const auto& point :
- constraints->pointsOfInterest().GetAsPoint2DSequence()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ constraints->pointsOfInterest()->GetAsPoint2DSequence()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ constraints->pointsOfInterest().GetAsPoint2DSequence()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
auto mojo_point = media::mojom::blink::Point2D::New();
mojo_point->x = point->x();
mojo_point->y = point->y();
@@ -556,12 +596,23 @@
}
// TODO(mcasas): support ConstrainDoubleRange where applicable.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_exposure_compensation =
+ constraints->hasExposureCompensation() &&
+ constraints->exposureCompensation()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_exposure_compensation =
constraints->hasExposureCompensation() &&
constraints->exposureCompensation().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_exposure_compensation) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto exposure_compensation =
+ constraints->exposureCompensation()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto exposure_compensation =
constraints->exposureCompensation().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (exposure_compensation < capabilities_->exposureCompensation()->min() ||
exposure_compensation > capabilities_->exposureCompensation()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -574,10 +625,19 @@
settings->exposure_compensation = exposure_compensation;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_exposure_time =
+ constraints->hasExposureTime() && constraints->exposureTime()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_exposure_time =
constraints->hasExposureTime() && constraints->exposureTime().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_exposure_time) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto exposure_time = constraints->exposureTime()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto exposure_time = constraints->exposureTime().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (exposure_time < capabilities_->exposureTime()->min() ||
exposure_time > capabilities_->exposureTime()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -588,11 +648,21 @@
temp_constraints->setExposureTime(constraints->exposureTime());
settings->exposure_time = exposure_time;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_color_temperature = constraints->hasColorTemperature() &&
+ constraints->colorTemperature()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_color_temperature = constraints->hasColorTemperature() &&
constraints->colorTemperature().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_color_temperature) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto color_temperature =
+ constraints->colorTemperature()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto color_temperature =
constraints->colorTemperature().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (color_temperature < capabilities_->colorTemperature()->min() ||
color_temperature > capabilities_->colorTemperature()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -603,9 +673,17 @@
temp_constraints->setColorTemperature(constraints->colorTemperature());
settings->color_temperature = color_temperature;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_iso = constraints->hasIso() && constraints->iso()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_iso = constraints->hasIso() && constraints->iso().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_iso) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto iso = constraints->iso()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto iso = constraints->iso().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (iso < capabilities_->iso()->min() ||
iso > capabilities_->iso()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -616,10 +694,19 @@
settings->iso = iso;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_brightness =
+ constraints->hasBrightness() && constraints->brightness()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_brightness =
constraints->hasBrightness() && constraints->brightness().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_brightness) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto brightness = constraints->brightness()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto brightness = constraints->brightness().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (brightness < capabilities_->brightness()->min() ||
brightness > capabilities_->brightness()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -630,10 +717,19 @@
temp_constraints->setBrightness(constraints->brightness());
settings->brightness = brightness;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_contrast =
+ constraints->hasContrast() && constraints->contrast()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_contrast =
constraints->hasContrast() && constraints->contrast().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_contrast) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto contrast = constraints->contrast()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto contrast = constraints->contrast().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (contrast < capabilities_->contrast()->min() ||
contrast > capabilities_->contrast()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -644,10 +740,19 @@
temp_constraints->setContrast(constraints->contrast());
settings->contrast = contrast;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_saturation =
+ constraints->hasSaturation() && constraints->saturation()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_saturation =
constraints->hasSaturation() && constraints->saturation().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_saturation) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto saturation = constraints->saturation()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto saturation = constraints->saturation().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (saturation < capabilities_->saturation()->min() ||
saturation > capabilities_->saturation()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -658,10 +763,19 @@
temp_constraints->setSaturation(constraints->saturation());
settings->saturation = saturation;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_sharpness =
+ constraints->hasSharpness() && constraints->sharpness()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_sharpness =
constraints->hasSharpness() && constraints->sharpness().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_sharpness) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto sharpness = constraints->sharpness()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto sharpness = constraints->sharpness().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (sharpness < capabilities_->sharpness()->min() ||
sharpness > capabilities_->sharpness()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -673,10 +787,19 @@
settings->sharpness = sharpness;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_focus_distance = constraints->hasFocusDistance() &&
+ constraints->focusDistance()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_focus_distance = constraints->hasFocusDistance() &&
constraints->focusDistance().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_focus_distance) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto focus_distance = constraints->focusDistance()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto focus_distance = constraints->focusDistance().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (focus_distance < capabilities_->focusDistance()->min() ||
focus_distance > capabilities_->focusDistance()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -688,14 +811,22 @@
settings->focus_distance = focus_distance;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_pan = constraints->hasPan() && constraints->pan()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_pan = constraints->hasPan() && constraints->pan().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_pan) {
if (!IsPageVisible()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kSecurityError, "the page is not visible"));
return;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto pan = constraints->pan()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto pan = constraints->pan().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (pan < capabilities_->pan()->min() ||
pan > capabilities_->pan()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -706,14 +837,23 @@
settings->pan = pan;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_tilt =
+ constraints->hasTilt() && constraints->tilt()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_tilt = constraints->hasTilt() && constraints->tilt().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_tilt) {
if (!IsPageVisible()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kSecurityError, "the page is not visible"));
return;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto tilt = constraints->tilt()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto tilt = constraints->tilt().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (tilt < capabilities_->tilt()->min() ||
tilt > capabilities_->tilt()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -724,14 +864,23 @@
settings->tilt = tilt;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_zoom =
+ constraints->hasZoom() && constraints->zoom()->IsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_zoom = constraints->hasZoom() && constraints->zoom().IsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_zoom) {
if (!IsPageVisible()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kSecurityError, "the page is not visible"));
return;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto zoom = constraints->zoom()->GetAsDouble();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto zoom = constraints->zoom().GetAsDouble();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (zoom < capabilities_->zoom()->min() ||
zoom > capabilities_->zoom()->max()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
@@ -743,10 +892,19 @@
}
// TODO(mcasas): support ConstrainBooleanParameters where applicable.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ settings->has_torch =
+ constraints->hasTorch() && constraints->torch()->IsBoolean();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
settings->has_torch =
constraints->hasTorch() && constraints->torch().IsBoolean();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (settings->has_torch) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto torch = constraints->torch()->GetAsBoolean();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto torch = constraints->torch().GetAsBoolean();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (torch && !capabilities_->torch()) {
resolver->Reject(MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, "torch not supported"));
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_key_path.cc b/third_party/blink/renderer/modules/indexeddb/idb_key_path.cc
index 0e08d63..2ed7be2 100644
--- a/third_party/blink/renderer/modules/indexeddb/idb_key_path.cc
+++ b/third_party/blink/renderer/modules/indexeddb/idb_key_path.cc
@@ -138,6 +138,7 @@
}
}
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
IDBKeyPath::IDBKeyPath(const StringOrStringSequence& key_path) {
if (key_path.IsNull()) {
type_ = mojom::IDBKeyPathType::Null;
@@ -155,6 +156,7 @@
#endif
}
}
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
bool IDBKeyPath::IsValid() const {
switch (type_) {
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_key_path.h b/third_party/blink/renderer/modules/indexeddb/idb_key_path.h
index 64ac34af..564d0d18 100644
--- a/third_party/blink/renderer/modules/indexeddb/idb_key_path.h
+++ b/third_party/blink/renderer/modules/indexeddb/idb_key_path.h
@@ -54,8 +54,9 @@
explicit IDBKeyPath(const String&);
explicit IDBKeyPath(const Vector<String>& array);
explicit IDBKeyPath(const V8UnionStringOrStringSequence* key_path);
- // TODO(
crbug.com/1181288): Remove the old IDL union version.
+#if !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
explicit IDBKeyPath(const StringOrStringSequence& key_path);
+#endif // !defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
mojom::IDBKeyPathType GetType() const { return type_; }
diff --git a/third_party/blink/renderer/modules/mediastream/capture_handle_change_event.cc b/third_party/blink/renderer/modules/mediastream/capture_handle_change_event.cc
index a3b1044..8d2a60e 100644
--- a/third_party/blink/renderer/modules/mediastream/capture_handle_change_event.cc
+++ b/third_party/blink/renderer/modules/mediastream/capture_handle_change_event.cc
@@ -4,7 +4,7 @@
#include "third_party/blink/renderer/modules/mediastream/capture_handle_change_event.h"
-#include "third_party/blink/renderer/modules/mediastream/capture_handle.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_capture_handle.h"
namespace blink {
diff --git a/third_party/blink/renderer/modules/mediastream/identifiability_metrics.cc b/third_party/blink/renderer/modules/mediastream/identifiability_metrics.cc
index 79122a4..46f58fe 100644
--- a/third_party/blink/renderer/modules/mediastream/identifiability_metrics.cc
+++ b/third_party/blink/renderer/modules/mediastream/identifiability_metrics.cc
@@ -17,6 +17,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/string_or_string_sequence_or_constrain_dom_string_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_stream_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraint_set.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
@@ -40,6 +41,22 @@
builder.AddToken(range->hasMin() ? range->min() : IdentifiableToken());
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder, const V8ConstrainDouble* d) {
+ if (!d) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (d->GetContentType()) {
+ case V8ConstrainDouble::ContentType::kConstrainDoubleRange:
+ return Visit(builder, d->GetAsConstrainDoubleRange());
+ case V8ConstrainDouble::ContentType::kDouble:
+ builder.AddToken(d->GetAsDouble());
+ return;
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder, const ConstrainDouble& d) {
if (d.IsDouble()) {
builder.AddToken(d.GetAsDouble());
@@ -52,7 +69,24 @@
DCHECK(d.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder, const V8ConstrainLong* l) {
+ if (!l) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (l->GetContentType()) {
+ case V8ConstrainLong::ContentType::kConstrainLongRange:
+ return Visit(builder, l->GetAsConstrainLongRange());
+ case V8ConstrainLong::ContentType::kLong:
+ builder.AddToken(l->GetAsLong());
+ return;
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder, const ConstrainLong& l) {
if (l.IsLong()) {
builder.AddToken(l.GetAsLong());
@@ -65,7 +99,28 @@
DCHECK(l.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder,
+ const V8UnionStringOrStringSequence* s) {
+ if (!s) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (s->GetContentType()) {
+ case V8UnionStringOrStringSequence::ContentType::kString:
+ builder.AddToken(IdentifiabilityBenignStringToken(s->GetAsString()));
+ return;
+ case V8UnionStringOrStringSequence::ContentType::kStringSequence:
+ for (const String& str : s->GetAsStringSequence()) {
+ builder.AddToken(IdentifiabilityBenignStringToken(str));
+ }
+ return;
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder, const StringOrStringSequence& s) {
if (s.IsString()) {
builder.AddToken(IdentifiabilityBenignStringToken(s.GetAsString()));
@@ -80,7 +135,34 @@
DCHECK(s.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder, const V8ConstrainDOMString* s) {
+ if (!s) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (s->GetContentType()) {
+ case V8ConstrainDOMString::ContentType::kConstrainDOMStringParameters: {
+ const ConstrainDOMStringParameters* params =
+ s->GetAsConstrainDOMStringParameters();
+ Visit(builder, params->getExactOr(nullptr));
+ Visit(builder, params->getIdealOr(nullptr));
+ return;
+ }
+ case V8ConstrainDOMString::ContentType::kString:
+ builder.AddToken(IdentifiabilityBenignStringToken(s->GetAsString()));
+ return;
+ case V8ConstrainDOMString::ContentType::kStringSequence:
+ for (const String& str : s->GetAsStringSequence()) {
+ builder.AddToken(IdentifiabilityBenignStringToken(str));
+ }
+ return;
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder, const ConstrainDOMString& s) {
if (s.IsString()) {
builder.AddToken(IdentifiabilityBenignStringToken(s.GetAsString()));
@@ -110,7 +192,31 @@
DCHECK(s.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder, const V8ConstrainBoolean* b) {
+ if (!b) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (b->GetContentType()) {
+ case V8ConstrainBoolean::ContentType::kBoolean:
+ builder.AddToken(b->GetAsBoolean());
+ return;
+ case V8ConstrainBoolean::ContentType::kConstrainBooleanParameters: {
+ const ConstrainBooleanParameters* params =
+ b->GetAsConstrainBooleanParameters();
+ builder.AddToken(params->hasExact() ? params->exact()
+ : IdentifiableToken());
+ builder.AddToken(params->hasIdeal() ? params->ideal()
+ : IdentifiableToken());
+ return;
+ }
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder, const ConstrainBoolean& b) {
if (b.IsBoolean()) {
builder.AddToken(b.GetAsBoolean());
@@ -128,7 +234,28 @@
DCHECK(b.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder,
+ const V8UnionBooleanOrConstrainDouble* x) {
+ if (!x) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (x->GetContentType()) {
+ case V8UnionBooleanOrConstrainDouble::ContentType::kBoolean:
+ builder.AddToken(x->GetAsBoolean());
+ return;
+ case V8UnionBooleanOrConstrainDouble::ContentType::kConstrainDoubleRange:
+ return Visit(builder, x->GetAsConstrainDoubleRange());
+ case V8UnionBooleanOrConstrainDouble::ContentType::kDouble:
+ builder.AddToken(x->GetAsDouble());
+ return;
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder,
const BooleanOrDoubleOrConstrainDoubleRange& x) {
if (x.IsBoolean()) {
@@ -146,6 +273,7 @@
DCHECK(x.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder,
const HeapVector<Member<Point2D>>& points) {
@@ -155,6 +283,34 @@
}
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder, const V8ConstrainPoint2D* p) {
+ if (!p) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (p->GetContentType()) {
+ case V8ConstrainPoint2D::ContentType::kConstrainPoint2DParameters: {
+ const ConstrainPoint2DParameters* params =
+ p->GetAsConstrainPoint2DParameters();
+ if (params->hasExact()) {
+ Visit(builder, params->exact());
+ } else {
+ builder.AddToken(IdentifiableToken());
+ }
+ if (params->hasIdeal()) {
+ Visit(builder, params->ideal());
+ } else {
+ builder.AddToken(IdentifiableToken());
+ }
+ return;
+ }
+ case V8ConstrainPoint2D::ContentType::kPoint2DSequence:
+ return Visit(builder, p->GetAsPoint2DSequence());
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder, const ConstrainPoint2D& x) {
if (x.IsPoint2DSequence()) {
Visit(builder, x.GetAsPoint2DSequence());
@@ -178,11 +334,43 @@
DCHECK(x.IsNull());
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder,
const MediaTrackConstraintSet& set) {
// TODO(
crbug.com/1070871): As a workaround for code simplicity, we use a
// default value of a union type if each member is not provided in input.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ Visit(builder, set.getWidthOr(nullptr));
+ Visit(builder, set.getHeightOr(nullptr));
+ Visit(builder, set.getAspectRatioOr(nullptr));
+ Visit(builder, set.getFrameRateOr(nullptr));
+ Visit(builder, set.getFacingModeOr(nullptr));
+ Visit(builder, set.getSampleRateOr(nullptr));
+ Visit(builder, set.getSampleSizeOr(nullptr));
+ Visit(builder, set.getEchoCancellationOr(nullptr));
+ Visit(builder, set.getAutoGainControlOr(nullptr));
+ Visit(builder, set.getLatencyOr(nullptr));
+ Visit(builder, set.getChannelCountOr(nullptr));
+ Visit(builder, set.getVideoKindOr(nullptr));
+ Visit(builder, set.getWhiteBalanceModeOr(nullptr));
+ Visit(builder, set.getExposureModeOr(nullptr));
+ Visit(builder, set.getFocusModeOr(nullptr));
+ Visit(builder, set.getPointsOfInterestOr(nullptr));
+ Visit(builder, set.getExposureCompensationOr(nullptr));
+ Visit(builder, set.getExposureTimeOr(nullptr));
+ Visit(builder, set.getColorTemperatureOr(nullptr));
+ Visit(builder, set.getIsoOr(nullptr));
+ Visit(builder, set.getBrightnessOr(nullptr));
+ Visit(builder, set.getContrastOr(nullptr));
+ Visit(builder, set.getSaturationOr(nullptr));
+ Visit(builder, set.getSharpnessOr(nullptr));
+ Visit(builder, set.getFocusDistanceOr(nullptr));
+ Visit(builder, set.getPanOr(nullptr));
+ Visit(builder, set.getTiltOr(nullptr));
+ Visit(builder, set.getZoomOr(nullptr));
+ Visit(builder, set.getTorchOr(nullptr));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Visit(builder, set.hasWidth() ? set.width() : ConstrainLong());
Visit(builder, set.hasHeight() ? set.height() : ConstrainLong());
Visit(builder, set.hasAspectRatio() ? set.aspectRatio() : ConstrainDouble());
@@ -224,8 +412,38 @@
Visit(builder,
set.hasZoom() ? set.zoom() : BooleanOrDoubleOrConstrainDoubleRange());
Visit(builder, set.hasTorch() ? set.torch() : ConstrainBoolean());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void Visit(IdentifiableTokenBuilder& builder,
+ const V8UnionBooleanOrMediaTrackConstraints* constraint) {
+ if (!constraint) {
+ builder.AddToken(IdentifiableToken());
+ return;
+ }
+ switch (constraint->GetContentType()) {
+ case V8UnionBooleanOrMediaTrackConstraints::ContentType::kBoolean:
+ builder.AddToken(constraint->GetAsBoolean());
+ return;
+ case V8UnionBooleanOrMediaTrackConstraints::ContentType::
+ kMediaTrackConstraints: {
+ const MediaTrackConstraints* constraints =
+ constraint->GetAsMediaTrackConstraints();
+ DCHECK(constraints);
+ if (constraints->hasAdvanced()) {
+ for (const auto& advanced : constraints->advanced()) {
+ Visit(builder, *advanced);
+ }
+ } else {
+ builder.AddToken(IdentifiableToken());
+ }
+ return;
+ }
+ }
+ NOTREACHED();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void Visit(IdentifiableTokenBuilder& builder,
const BooleanOrMediaTrackConstraints& constraint) {
if (constraint.IsBoolean()) {
@@ -246,6 +464,7 @@
}
builder.AddToken(IdentifiableToken());
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace
diff --git a/third_party/blink/renderer/modules/mediastream/media_constraints_impl.cc b/third_party/blink/renderer/modules/mediastream/media_constraints_impl.cc
index 3e4f87d..20ed561e 100644
--- a/third_party/blink/renderer/modules/mediastream/media_constraints_impl.cc
+++ b/third_party/blink/renderer/modules/mediastream/media_constraints_impl.cc
@@ -33,11 +33,17 @@
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/renderer/bindings/core/v8/array_value.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_boolean_parameters.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_dom_string_parameters.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_double_range.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_long_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
+#include "third_party/blink/renderer/modules/mediastream/media_error_state.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
@@ -47,7 +53,6 @@
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
-
namespace media_constraints_impl {
// A naked value is treated as an "ideal" value in the basic constraints,
@@ -493,6 +498,41 @@
return CreateFromNamedConstraints(context, mandatory, optional, error_state);
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void CopyLongConstraint(const V8ConstrainLong* blink_union_form,
+ NakedValueDisposition naked_treatment,
+ LongConstraint& web_form) {
+ web_form.SetIsPresent(true);
+ switch (blink_union_form->GetContentType()) {
+ case V8ConstrainLong::ContentType::kConstrainLongRange: {
+ const auto* blink_form = blink_union_form->GetAsConstrainLongRange();
+ if (blink_form->hasMin()) {
+ web_form.SetMin(blink_form->min());
+ }
+ if (blink_form->hasMax()) {
+ web_form.SetMax(blink_form->max());
+ }
+ if (blink_form->hasIdeal()) {
+ web_form.SetIdeal(blink_form->ideal());
+ }
+ if (blink_form->hasExact()) {
+ web_form.SetExact(blink_form->exact());
+ }
+ break;
+ }
+ case V8ConstrainLong::ContentType::kLong:
+ switch (naked_treatment) {
+ case NakedValueDisposition::kTreatAsIdeal:
+ web_form.SetIdeal(blink_union_form->GetAsLong());
+ break;
+ case NakedValueDisposition::kTreatAsExact:
+ web_form.SetExact(blink_union_form->GetAsLong());
+ break;
+ }
+ break;
+ }
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void CopyLongConstraint(const LongOrConstrainLongRange& blink_union_form,
NakedValueDisposition naked_treatment,
LongConstraint& web_form) {
@@ -522,7 +562,43 @@
web_form.SetExact(blink_form->exact());
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void CopyDoubleConstraint(const V8ConstrainDouble* blink_union_form,
+ NakedValueDisposition naked_treatment,
+ DoubleConstraint& web_form) {
+ web_form.SetIsPresent(true);
+ switch (blink_union_form->GetContentType()) {
+ case V8ConstrainDouble::ContentType::kConstrainDoubleRange: {
+ const auto* blink_form = blink_union_form->GetAsConstrainDoubleRange();
+ if (blink_form->hasMin()) {
+ web_form.SetMin(blink_form->min());
+ }
+ if (blink_form->hasMax()) {
+ web_form.SetMax(blink_form->max());
+ }
+ if (blink_form->hasIdeal()) {
+ web_form.SetIdeal(blink_form->ideal());
+ }
+ if (blink_form->hasExact()) {
+ web_form.SetExact(blink_form->exact());
+ }
+ break;
+ }
+ case V8ConstrainDouble::ContentType::kDouble:
+ switch (naked_treatment) {
+ case NakedValueDisposition::kTreatAsIdeal:
+ web_form.SetIdeal(blink_union_form->GetAsDouble());
+ break;
+ case NakedValueDisposition::kTreatAsExact:
+ web_form.SetExact(blink_union_form->GetAsDouble());
+ break;
+ }
+ break;
+ }
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void CopyDoubleConstraint(const DoubleOrConstrainDoubleRange& blink_union_form,
NakedValueDisposition naked_treatment,
DoubleConstraint& web_form) {
@@ -552,7 +628,25 @@
web_form.SetExact(blink_form->exact());
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void CopyBooleanOrDoubleConstraint(
+ const V8UnionBooleanOrConstrainDouble* blink_union_form,
+ NakedValueDisposition naked_treatment,
+ DoubleConstraint& web_form) {
+ switch (blink_union_form->GetContentType()) {
+ case V8UnionBooleanOrConstrainDouble::ContentType::kBoolean:
+ web_form.SetIsPresent(blink_union_form->GetAsBoolean());
+ break;
+ case V8UnionBooleanOrConstrainDouble::ContentType::kConstrainDoubleRange:
+ case V8UnionBooleanOrConstrainDouble::ContentType::kDouble:
+ CopyDoubleConstraint(blink_union_form->GetAsV8ConstrainDouble(),
+ naked_treatment, web_form);
+ break;
+ }
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void CopyBooleanOrDoubleConstraint(
const BooleanOrDoubleOrConstrainDoubleRange& blink_union_form,
NakedValueDisposition naked_treatment,
@@ -571,7 +665,64 @@
}
CopyDoubleConstraint(double_constraint, naked_treatment, web_form);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void CopyStringConstraint(const V8ConstrainDOMString* blink_union_form,
+ NakedValueDisposition naked_treatment,
+ StringConstraint& web_form) {
+ web_form.SetIsPresent(true);
+ switch (blink_union_form->GetContentType()) {
+ case V8ConstrainDOMString::ContentType::kConstrainDOMStringParameters: {
+ const auto* blink_form =
+ blink_union_form->GetAsConstrainDOMStringParameters();
+ if (blink_form->hasIdeal()) {
+ switch (blink_form->ideal()->GetContentType()) {
+ case V8UnionStringOrStringSequence::ContentType::kString:
+ web_form.SetIdeal(
+ Vector<String>(1, blink_form->ideal()->GetAsString()));
+ break;
+ case V8UnionStringOrStringSequence::ContentType::kStringSequence:
+ web_form.SetIdeal(blink_form->ideal()->GetAsStringSequence());
+ break;
+ }
+ }
+ if (blink_form->hasExact()) {
+ switch (blink_form->exact()->GetContentType()) {
+ case V8UnionStringOrStringSequence::ContentType::kString:
+ web_form.SetExact(
+ Vector<String>(1, blink_form->exact()->GetAsString()));
+ break;
+ case V8UnionStringOrStringSequence::ContentType::kStringSequence:
+ web_form.SetExact(blink_form->exact()->GetAsStringSequence());
+ break;
+ }
+ }
+ break;
+ }
+ case V8ConstrainDOMString::ContentType::kString:
+ switch (naked_treatment) {
+ case NakedValueDisposition::kTreatAsIdeal:
+ web_form.SetIdeal(Vector<String>(1, blink_union_form->GetAsString()));
+ break;
+ case NakedValueDisposition::kTreatAsExact:
+ web_form.SetExact(Vector<String>(1, blink_union_form->GetAsString()));
+ break;
+ }
+ break;
+ case V8ConstrainDOMString::ContentType::kStringSequence:
+ switch (naked_treatment) {
+ case NakedValueDisposition::kTreatAsIdeal:
+ web_form.SetIdeal(blink_union_form->GetAsStringSequence());
+ break;
+ case NakedValueDisposition::kTreatAsExact:
+ web_form.SetExact(blink_union_form->GetAsStringSequence());
+ break;
+ }
+ break;
+ }
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void CopyStringConstraint(
const StringOrStringSequenceOrConstrainDOMStringParameters&
blink_union_form,
@@ -617,7 +768,38 @@
}
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+void CopyBooleanConstraint(const V8ConstrainBoolean* blink_union_form,
+ NakedValueDisposition naked_treatment,
+ BooleanConstraint& web_form) {
+ web_form.SetIsPresent(true);
+ switch (blink_union_form->GetContentType()) {
+ case V8ConstrainBoolean::ContentType::kBoolean:
+ switch (naked_treatment) {
+ case NakedValueDisposition::kTreatAsIdeal:
+ web_form.SetIdeal(blink_union_form->GetAsBoolean());
+ break;
+ case NakedValueDisposition::kTreatAsExact:
+ web_form.SetExact(blink_union_form->GetAsBoolean());
+ break;
+ }
+ break;
+ case V8ConstrainBoolean::ContentType::kConstrainBooleanParameters: {
+ const auto* blink_form =
+ blink_union_form->GetAsConstrainBooleanParameters();
+ if (blink_form->hasIdeal()) {
+ web_form.SetIdeal(blink_form->ideal());
+ }
+ if (blink_form->hasExact()) {
+ web_form.SetExact(blink_form->exact());
+ }
+ break;
+ }
+ }
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void CopyBooleanConstraint(
const BooleanOrConstrainBooleanParameters& blink_union_form,
NakedValueDisposition naked_treatment,
@@ -642,6 +824,7 @@
web_form.SetExact(blink_form->exact());
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void CopyConstraintSet(const MediaTrackConstraintSet* constraints_in,
NakedValueDisposition naked_treatment,
@@ -820,6 +1003,27 @@
return input.Exact();
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8ConstrainLong* ConvertLong(const LongConstraint& input,
+ NakedValueDisposition naked_treatment) {
+ if (UseNakedNumeric(input, naked_treatment)) {
+ return MakeGarbageCollected<V8ConstrainLong>(
+ GetNakedValue<uint32_t>(input, naked_treatment));
+ } else if (!input.IsUnconstrained()) {
+ ConstrainLongRange* output = ConstrainLongRange::Create();
+ if (input.HasExact())
+ output->setExact(input.Exact());
+ if (input.HasMin())
+ output->setMin(input.Min());
+ if (input.HasMax())
+ output->setMax(input.Max());
+ if (input.HasIdeal())
+ output->setIdeal(input.Ideal());
+ return MakeGarbageCollected<V8ConstrainLong>(output);
+ }
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
LongOrConstrainLongRange ConvertLong(const LongConstraint& input,
NakedValueDisposition naked_treatment) {
LongOrConstrainLongRange output_union;
@@ -839,7 +1043,29 @@
}
return output_union;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8ConstrainDouble* ConvertDouble(const DoubleConstraint& input,
+ NakedValueDisposition naked_treatment) {
+ if (UseNakedNumeric(input, naked_treatment)) {
+ return MakeGarbageCollected<V8ConstrainDouble>(
+ GetNakedValue<double>(input, naked_treatment));
+ } else if (!input.IsUnconstrained()) {
+ ConstrainDoubleRange* output = ConstrainDoubleRange::Create();
+ if (input.HasExact())
+ output->setExact(input.Exact());
+ if (input.HasIdeal())
+ output->setIdeal(input.Ideal());
+ if (input.HasMin())
+ output->setMin(input.Min());
+ if (input.HasMax())
+ output->setMax(input.Max());
+ return MakeGarbageCollected<V8ConstrainDouble>(output);
+ }
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DoubleOrConstrainDoubleRange ConvertDouble(
const DoubleConstraint& input,
NakedValueDisposition naked_treatment) {
@@ -860,7 +1086,30 @@
}
return output_union;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8UnionBooleanOrConstrainDouble* ConvertBooleanOrDouble(
+ const DoubleConstraint& input,
+ NakedValueDisposition naked_treatment) {
+ if (UseNakedNumeric(input, naked_treatment)) {
+ return MakeGarbageCollected<V8UnionBooleanOrConstrainDouble>(
+ GetNakedValue<double>(input, naked_treatment));
+ } else if (!input.IsUnconstrained()) {
+ ConstrainDoubleRange* output = ConstrainDoubleRange::Create();
+ if (input.HasExact())
+ output->setExact(input.Exact());
+ if (input.HasIdeal())
+ output->setIdeal(input.Ideal());
+ if (input.HasMin())
+ output->setMin(input.Min());
+ if (input.HasMax())
+ output->setMax(input.Max());
+ return MakeGarbageCollected<V8UnionBooleanOrConstrainDouble>(output);
+ }
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
BooleanOrDoubleOrConstrainDoubleRange ConvertBooleanOrDouble(
const DoubleConstraint& input,
NakedValueDisposition naked_treatment) {
@@ -881,7 +1130,23 @@
}
return output_union;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8UnionStringOrStringSequence* ConvertStringSequence(
+ const WebVector<WebString>& input) {
+ if (input.size() > 1) {
+ Vector<String> buffer;
+ for (const auto& scanner : input)
+ buffer.push_back(scanner);
+ return MakeGarbageCollected<V8UnionStringOrStringSequence>(
+ std::move(buffer));
+ } else if (!input.empty()) {
+ return MakeGarbageCollected<V8UnionStringOrStringSequence>(input[0]);
+ }
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
StringOrStringSequence ConvertStringSequence(
const WebVector<WebString>& input) {
StringOrStringSequence the_strings;
@@ -895,7 +1160,35 @@
}
return the_strings;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8ConstrainDOMString* ConvertString(const StringConstraint& input,
+ NakedValueDisposition naked_treatment) {
+ if (UseNakedNonNumeric(input, naked_treatment)) {
+ WebVector<WebString> input_buffer(
+ GetNakedValue<WebVector<WebString>>(input, naked_treatment));
+ if (input_buffer.size() > 1) {
+ Vector<String> buffer;
+ for (const auto& scanner : input_buffer)
+ buffer.push_back(scanner);
+ return MakeGarbageCollected<V8ConstrainDOMString>(std::move(buffer));
+ } else if (!input_buffer.empty()) {
+ return MakeGarbageCollected<V8ConstrainDOMString>(input_buffer[0]);
+ }
+ return nullptr;
+ } else if (!input.IsUnconstrained()) {
+ ConstrainDOMStringParameters* output =
+ ConstrainDOMStringParameters::Create();
+ if (input.HasExact())
+ output->setExact(ConvertStringSequence(input.Exact()));
+ if (input.HasIdeal())
+ output->setIdeal(ConvertStringSequence(input.Ideal()));
+ return MakeGarbageCollected<V8ConstrainDOMString>(output);
+ }
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
StringOrStringSequenceOrConstrainDOMStringParameters ConvertString(
const StringConstraint& input,
NakedValueDisposition naked_treatment) {
@@ -922,7 +1215,25 @@
}
return output_union;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8ConstrainBoolean* ConvertBoolean(const BooleanConstraint& input,
+ NakedValueDisposition naked_treatment) {
+ if (UseNakedNonNumeric(input, naked_treatment)) {
+ return MakeGarbageCollected<V8ConstrainBoolean>(
+ GetNakedValue<bool>(input, naked_treatment));
+ } else if (!input.IsUnconstrained()) {
+ ConstrainBooleanParameters* output = ConstrainBooleanParameters::Create();
+ if (input.HasExact())
+ output->setExact(input.Exact());
+ if (input.HasIdeal())
+ output->setIdeal(input.Ideal());
+ return MakeGarbageCollected<V8ConstrainBoolean>(output);
+ }
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
BooleanOrConstrainBooleanParameters ConvertBoolean(
const BooleanConstraint& input,
NakedValueDisposition naked_treatment) {
@@ -939,6 +1250,7 @@
}
return output_union;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void ConvertConstraintSet(const MediaTrackConstraintSetPlatform& input,
NakedValueDisposition naked_treatment,
diff --git a/third_party/blink/renderer/modules/mediastream/media_constraints_impl.h b/third_party/blink/renderer/modules/mediastream/media_constraints_impl.h
index 82ac353..15c0438 100644
--- a/third_party/blink/renderer/modules/mediastream/media_constraints_impl.h
+++ b/third_party/blink/renderer/modules/mediastream/media_constraints_impl.h
@@ -31,15 +31,14 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_MEDIA_CONSTRAINTS_IMPL_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_MEDIA_CONSTRAINTS_IMPL_H_
-#include "third_party/blink/renderer/modules/mediastream/media_error_state.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/mediastream/media_constraints.h"
-#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class Dictionary;
class ExecutionContext;
+class MediaErrorState;
class MediaTrackConstraints;
namespace media_constraints_impl {
diff --git a/third_party/blink/renderer/modules/mediastream/media_constraints_test.cc b/third_party/blink/renderer/modules/mediastream/media_constraints_test.cc
index 263a953..beeec76 100644
--- a/third_party/blink/renderer/modules/mediastream/media_constraints_test.cc
+++ b/third_party/blink/renderer/modules/mediastream/media_constraints_test.cc
@@ -3,8 +3,11 @@
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/mediastream/media_constraints.h"
+
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_dom_string_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints_impl.h"
namespace blink {
@@ -162,8 +165,13 @@
MediaTrackConstraints* output =
media_constraints_impl::ConvertConstraints(input);
ASSERT_TRUE(output->hasFacingMode());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ASSERT_TRUE(output->facingMode()->IsString());
+ EXPECT_EQ("foo", output->facingMode()->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(output->facingMode().IsString());
EXPECT_EQ("foo", output->facingMode().GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
TEST(MediaTrackConstraintsTest, ConvertWebDoubleStringConstraint) {
@@ -181,8 +189,13 @@
MediaTrackConstraints* output =
media_constraints_impl::ConvertConstraints(input);
ASSERT_TRUE(output->hasFacingMode());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ASSERT_TRUE(output->facingMode()->IsStringSequence());
+ const auto& out_buffer = output->facingMode()->GetAsStringSequence();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(output->facingMode().IsStringSequence());
auto out_buffer = output->facingMode().GetAsStringSequence();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
EXPECT_EQ("foo", out_buffer[0]);
EXPECT_EQ("bar", out_buffer[1]);
}
@@ -190,8 +203,12 @@
TEST(MediaTrackConstraintsTest, ConvertBlinkStringConstraint) {
MediaTrackConstraints* input = MediaTrackConstraints::Create();
MediaConstraints output;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* parameter = MakeGarbageCollected<V8ConstrainDOMString>("foo");
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
StringOrStringSequenceOrConstrainDOMStringParameters parameter;
parameter.SetString("foo");
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
input->setFacingMode(parameter);
output =
media_constraints_impl::ConvertTrackConstraintsToMediaConstraints(input);
@@ -203,13 +220,19 @@
TEST(MediaTrackConstraintsTest, ConvertBlinkComplexStringConstraint) {
MediaTrackConstraints* input = MediaTrackConstraints::Create();
MediaConstraints output;
- StringOrStringSequenceOrConstrainDOMStringParameters parameter;
ConstrainDOMStringParameters* subparameter =
ConstrainDOMStringParameters::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ subparameter->setIdeal(
+ MakeGarbageCollected<V8UnionStringOrStringSequence>("foo"));
+ auto* parameter = MakeGarbageCollected<V8ConstrainDOMString>(subparameter);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
StringOrStringSequence inner_string;
inner_string.SetString("foo");
subparameter->setIdeal(inner_string);
+ StringOrStringSequenceOrConstrainDOMStringParameters parameter;
parameter.SetConstrainDOMStringParameters(subparameter);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
input->setFacingMode(parameter);
output =
media_constraints_impl::ConvertTrackConstraintsToMediaConstraints(input);
@@ -221,14 +244,23 @@
MediaTrackConstraints* recycled =
media_constraints_impl::ConvertConstraints(output);
ASSERT_TRUE(recycled->hasFacingMode());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ASSERT_TRUE(recycled->facingMode()->IsString());
+ ASSERT_EQ("foo", recycled->facingMode()->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(recycled->facingMode().IsString());
ASSERT_EQ("foo", recycled->facingMode().GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
TEST(MediaTrackConstraintsTest, NakedIsExactInAdvanced) {
MediaTrackConstraints* input = MediaTrackConstraints::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* parameter = MakeGarbageCollected<V8ConstrainDOMString>("foo");
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
StringOrStringSequenceOrConstrainDOMStringParameters parameter;
parameter.SetString("foo");
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
input->setFacingMode(parameter);
HeapVector<Member<MediaTrackConstraintSet>> advanced(
1, MediaTrackConstraintSet::Create());
@@ -277,19 +309,37 @@
MediaTrackConstraintSet* element2 = output->advanced()[1];
ASSERT_TRUE(output->hasFacingMode());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ASSERT_TRUE(output->facingMode()->IsString());
+ EXPECT_EQ("ideal", output->facingMode()->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(output->facingMode().IsString());
EXPECT_EQ("ideal", output->facingMode().GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(element1->hasFacingMode());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ASSERT_TRUE(element1->facingMode()->IsConstrainDOMStringParameters());
+ EXPECT_EQ("ideal", element1->facingMode()
+ ->GetAsConstrainDOMStringParameters()
+ ->ideal()
+ ->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(element1->facingMode().IsConstrainDOMStringParameters());
EXPECT_EQ("ideal", element1->facingMode()
.GetAsConstrainDOMStringParameters()
->ideal()
.GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(element2->hasFacingMode());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ASSERT_TRUE(element2->facingMode()->IsString());
+ EXPECT_EQ("exact", element2->facingMode()->GetAsString());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ASSERT_TRUE(element2->facingMode().IsString());
EXPECT_EQ("exact", element2->facingMode().GetAsString());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
} // namespace blink
diff --git a/third_party/blink/renderer/modules/mediastream/media_devices.cc b/third_party/blink/renderer/modules/mediastream/media_devices.cc
index 6ced1a4..49f1459 100644
--- a/third_party/blink/renderer/modules/mediastream/media_devices.cc
+++ b/third_party/blink/renderer/modules/mediastream/media_devices.cc
@@ -14,6 +14,7 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_stream_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_supported_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_domexception_overconstrainederror.h"
@@ -23,7 +24,6 @@
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
-#include "third_party/blink/renderer/modules/mediastream/capture_handle_config.h"
#include "third_party/blink/renderer/modules/mediastream/identifiability_metrics.h"
#include "third_party/blink/renderer/modules/mediastream/input_device_info.h"
#include "third_party/blink/renderer/modules/mediastream/media_error_state.h"
diff --git a/third_party/blink/renderer/modules/mediastream/media_devices_test.cc b/third_party/blink/renderer/modules/mediastream/media_devices_test.cc
index ec05e7c..96c79e2 100644
--- a/third_party/blink/renderer/modules/mediastream/media_devices_test.cc
+++ b/third_party/blink/renderer/modules/mediastream/media_devices_test.cc
@@ -15,10 +15,10 @@
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_stream_constraints.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/testing/null_execution_context.h"
-#include "third_party/blink/renderer/modules/mediastream/capture_handle_config.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_track.cc b/third_party/blink/renderer/modules/mediastream/media_stream_track.cc
index da2a349d..2467ff8db 100644
--- a/third_party/blink/renderer/modules/mediastream/media_stream_track.cc
+++ b/third_party/blink/renderer/modules/mediastream/media_stream_track.cc
@@ -36,9 +36,12 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_capture_handle.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_change_event.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_capture_handle_change_event_init.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_double_range.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_long_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_capabilities.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_settings.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_point_2d.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
@@ -48,6 +51,7 @@
#include "third_party/blink/renderer/modules/imagecapture/image_capture.h"
#include "third_party/blink/renderer/modules/mediastream/apply_constraints_request.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints_impl.h"
+#include "third_party/blink/renderer/modules/mediastream/media_error_state.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_utils.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h"
diff --git a/third_party/blink/renderer/modules/mediastream/user_media_request.cc b/third_party/blink/renderer/modules/mediastream/user_media_request.cc
index fccef17..926ed3b 100644
--- a/third_party/blink/renderer/modules/mediastream/user_media_request.cc
+++ b/third_party/blink/renderer/modules/mediastream/user_media_request.cc
@@ -48,6 +48,7 @@
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/modules/mediastream/identifiability_metrics.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints_impl.h"
+#include "third_party/blink/renderer/modules/mediastream/media_error_state.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream.h"
#include "third_party/blink/renderer/modules/mediastream/overconstrained_error.h"
#include "third_party/blink/renderer/modules/mediastream/user_media_controller.h"
@@ -279,6 +280,29 @@
}
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+MediaConstraints ParseOptions(
+ ExecutionContext* execution_context,
+ const V8UnionBooleanOrMediaTrackConstraints* options,
+ MediaErrorState& error_state) {
+ if (!options)
+ return MediaConstraints();
+ switch (options->GetContentType()) {
+ case V8UnionBooleanOrMediaTrackConstraints::ContentType::kBoolean:
+ if (options->GetAsBoolean())
+ return media_constraints_impl::Create();
+ else
+ return MediaConstraints();
+ case V8UnionBooleanOrMediaTrackConstraints::ContentType::
+ kMediaTrackConstraints:
+ return media_constraints_impl::Create(
+ execution_context, options->GetAsMediaTrackConstraints(),
+ error_state);
+ }
+ NOTREACHED();
+ return MediaConstraints();
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
MediaConstraints ParseOptions(ExecutionContext* context,
const BooleanOrMediaTrackConstraints& options,
MediaErrorState& error_state) {
@@ -298,6 +322,7 @@
return constraints;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace
@@ -396,9 +421,14 @@
return nullptr;
}
if (audio.IsNull() && video.IsNull()) {
- video = ParseOptions(context,
- BooleanOrMediaTrackConstraints::FromBoolean(true),
- error_state);
+ video = ParseOptions(
+ context,
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ MakeGarbageCollected<V8UnionBooleanOrMediaTrackConstraints>(true),
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ BooleanOrMediaTrackConstraints::FromBoolean(true),
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ error_state);
if (error_state.HadException())
return nullptr;
}
diff --git a/third_party/blink/renderer/modules/nfc/ndef_record.cc b/third_party/blink/renderer/modules/nfc/ndef_record.cc
index 1c3bda9..87d5aac 100644
--- a/third_party/blink/renderer/modules/nfc/ndef_record.cc
+++ b/third_party/blink/renderer/modules/nfc/ndef_record.cc
@@ -13,6 +13,7 @@
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
+#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_data_view.h"
#include "third_party/blink/renderer/modules/nfc/ndef_message.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
@@ -23,9 +24,6 @@
namespace blink {
-using NDEFRecordDataSource =
- StringOrArrayBufferOrArrayBufferViewOrNDEFMessageInit;
-
namespace {
WTF::Vector<uint8_t> GetUTF8DataFromString(const String& string) {
@@ -35,6 +33,37 @@
return data;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
+bool GetBytesOfBufferSource(const V8NDEFRecordDataSource* buffer_source,
+ WTF::Vector<uint8_t>* target,
+ ExceptionState& exception_state) {
+ DCHECK(buffer_source->IsV8BufferSource());
+ DOMArrayPiece array_piece;
+ if (buffer_source->IsArrayBuffer()) {
+ array_piece = DOMArrayPiece(buffer_source->GetAsArrayBuffer());
+ } else if (buffer_source->IsArrayBufferView()) {
+ array_piece = DOMArrayPiece(buffer_source->GetAsArrayBufferView().Get());
+ } else {
+ NOTREACHED();
+ return true; // true to be consistent with `exception_state`.
+ }
+ wtf_size_t checked_length;
+ if (!base::CheckedNumeric<wtf_size_t>(array_piece.ByteLength())
+ .AssignIfValid(&checked_length)) {
+ exception_state.ThrowRangeError(
+ "The provided buffer source exceeds the maximum supported length");
+ return false;
+ }
+ target->Append(array_piece.Bytes(), checked_length);
+ return true;
+}
+
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
+using NDEFRecordDataSource =
+ StringOrArrayBufferOrArrayBufferViewOrNDEFMessageInit;
+
bool IsBufferSource(const NDEFRecordDataSource& data) {
return data.IsArrayBuffer() || data.IsArrayBufferView();
}
@@ -69,6 +98,8 @@
return true;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
//
https://w3c.github.io/web-nfc/#dfn-validate-external-type
// Validates |input| as an external type.
bool IsValidExternalType(const String& input) {
@@ -152,8 +183,15 @@
const NDEFRecordInit& record,
ExceptionState& exception_state) {
//
https://w3c.github.io/web-nfc/#mapping-string-to-ndef
- if (!record.hasData() ||
- !(record.data().IsString() || IsBufferSource(record.data()))) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() ||
+ !(record.data()->IsString() || record.data()->IsV8BufferSource())
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() ||
+ !(record.data().IsString() || IsBufferSource(record.data()))
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
exception_state.ThrowTypeError(
"The data for 'text' NDEFRecords must be a String or a BufferSource.");
return nullptr;
@@ -176,8 +214,40 @@
return nullptr;
}
- auto& data = record.data();
- // TODO(
crbug.com/1070871): Use encodingOr("utf-8").
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto* data = record.data();
+ const String& encoding_label = record.getEncodingOr("utf-8");
+ WTF::Vector<uint8_t> bytes;
+ switch (data->GetContentType()) {
+ case V8NDEFRecordDataSource::ContentType::kArrayBuffer:
+ case V8NDEFRecordDataSource::ContentType::kArrayBufferView:
+ if (encoding_label != "utf-8" && encoding_label != "utf-16" &&
+ encoding_label != "utf-16be" && encoding_label != "utf-16le") {
+ exception_state.ThrowTypeError(
+ "Encoding must be either \"utf-8\", \"utf-16\", \"utf-16be\", or "
+ "\"utf-16le\".");
+ return nullptr;
+ }
+ if (!GetBytesOfBufferSource(data, &bytes, exception_state)) {
+ return nullptr;
+ }
+ break;
+ case V8NDEFRecordDataSource::ContentType::kNDEFMessageInit:
+ NOTREACHED();
+ break;
+ case V8NDEFRecordDataSource::ContentType::kString:
+ if (encoding_label != "utf-8") {
+ exception_state.ThrowTypeError(
+ "A DOMString data source is always encoded as \"utf-8\" so other "
+ "encodings are not allowed.");
+ return nullptr;
+ }
+ StringUTF8Adaptor utf8_string(data->GetAsString());
+ bytes.Append(utf8_string.data(), utf8_string.size());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto& data = record.data();
String encoding_label = record.hasEncoding() ? record.encoding() : "utf-8";
WTF::Vector<uint8_t> bytes;
if (data.IsString()) {
@@ -202,6 +272,7 @@
return nullptr;
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return MakeGarbageCollected<NDEFRecord>(id, encoding_label, language,
std::move(bytes));
@@ -212,14 +283,24 @@
const NDEFRecordInit& record,
ExceptionState& exception_state) {
//
https://w3c.github.io/web-nfc/#mapping-url-to-ndef
- if (!record.hasData() || !record.data().IsString()) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !record.data()->IsString()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !record.data().IsString()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
exception_state.ThrowTypeError(
"The data for url NDEFRecord must be a String.");
return nullptr;
}
// No need to check mediaType according to the spec.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const String& url = record.data()->GetAsString();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
String url = record.data().GetAsString();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (!KURL(NullURL(), url).IsValid()) {
exception_state.ThrowDOMException(DOMExceptionCode::kSyntaxError,
"Cannot parse data for url record.");
@@ -235,7 +316,13 @@
const NDEFRecordInit& record,
ExceptionState& exception_state) {
//
https://w3c.github.io/web-nfc/#mapping-binary-data-to-ndef
- if (!record.hasData() || !IsBufferSource(record.data())) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !record.data()->IsV8BufferSource()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !IsBufferSource(record.data())
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
exception_state.ThrowTypeError(
"The data for 'mime' NDEFRecord must be a BufferSource.");
return nullptr;
@@ -260,7 +347,13 @@
static NDEFRecord* CreateUnknownRecord(const String& id,
const NDEFRecordInit& record,
ExceptionState& exception_state) {
- if (!record.hasData() || !IsBufferSource(record.data())) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !record.data()->IsV8BufferSource()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !IsBufferSource(record.data())
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
exception_state.ThrowTypeError(
"The data for 'unknown' NDEFRecord must be a BufferSource.");
return nullptr;
@@ -282,14 +375,26 @@
const NDEFRecordInit& record,
ExceptionState& exception_state) {
//
https://w3c.github.io/web-nfc/#dfn-map-smart-poster-to-ndef
- if (!record.hasData() || !record.data().IsNDEFMessageInit()) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !record.data()->IsNDEFMessageInit()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !record.hasData() || !record.data().IsNDEFMessageInit()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
exception_state.ThrowTypeError(
"The data for 'smart-poster' NDEFRecord must be an NDEFMessageInit.");
return nullptr;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ NDEFMessage* payload_message = NDEFMessage::CreateAsPayloadOfSmartPoster(
+ execution_context, record.data()->GetAsNDEFMessageInit(),
+ exception_state);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
NDEFMessage* payload_message = NDEFMessage::CreateAsPayloadOfSmartPoster(
execution_context, record.data().GetAsNDEFMessageInit(), exception_state);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (exception_state.HadException())
return nullptr;
DCHECK(payload_message);
@@ -307,6 +412,35 @@
const String& record_type = record.recordType();
//
https://w3c.github.io/web-nfc/#dfn-map-external-data-to-ndef
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (record.hasData()) {
+ switch (record.data()->GetContentType()) {
+ case V8NDEFRecordDataSource::ContentType::kArrayBuffer:
+ case V8NDEFRecordDataSource::ContentType::kArrayBufferView: {
+ Vector<uint8_t> bytes;
+ if (!GetBytesOfBufferSource(record.data(), &bytes, exception_state)) {
+ return nullptr;
+ }
+ return MakeGarbageCollected<NDEFRecord>(
+ device::mojom::blink::NDEFRecordTypeCategory::kExternal,
+ record_type, id, bytes);
+ }
+ case V8NDEFRecordDataSource::ContentType::kNDEFMessageInit: {
+ NDEFMessage* payload_message = NDEFMessage::Create(
+ execution_context, record.data()->GetAsNDEFMessageInit(),
+ exception_state, /*is_embedded=*/true);
+ if (exception_state.HadException())
+ return nullptr;
+ DCHECK(payload_message);
+ return MakeGarbageCollected<NDEFRecord>(
+ device::mojom::blink::NDEFRecordTypeCategory::kExternal,
+ record_type, id, payload_message);
+ }
+ case V8NDEFRecordDataSource::ContentType::kString:
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (record.hasData() && IsBufferSource(record.data())) {
WTF::Vector<uint8_t> bytes;
if (!GetBytesOfBufferSource(record.data(), &bytes, exception_state)) {
@@ -326,6 +460,7 @@
device::mojom::blink::NDEFRecordTypeCategory::kExternal, record_type,
id, payload_message);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
exception_state.ThrowTypeError(
"The data for external type NDEFRecord must be a BufferSource or an "
@@ -340,6 +475,35 @@
const String& record_type = record.recordType();
//
https://w3c.github.io/web-nfc/#dfn-map-local-type-to-ndef
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (record.hasData()) {
+ switch (record.data()->GetContentType()) {
+ case V8NDEFMessageSource::ContentType::kArrayBuffer:
+ case V8NDEFMessageSource::ContentType::kArrayBufferView: {
+ Vector<uint8_t> bytes;
+ if (!GetBytesOfBufferSource(record.data(), &bytes, exception_state)) {
+ return nullptr;
+ }
+ return MakeGarbageCollected<NDEFRecord>(
+ device::mojom::blink::NDEFRecordTypeCategory::kLocal, record_type,
+ id, bytes);
+ }
+ case V8NDEFMessageSource::ContentType::kNDEFMessageInit: {
+ NDEFMessage* payload_message = NDEFMessage::Create(
+ execution_context, record.data()->GetAsNDEFMessageInit(),
+ exception_state, /*is_embedded=*/true);
+ if (exception_state.HadException())
+ return nullptr;
+ DCHECK(payload_message);
+ return MakeGarbageCollected<NDEFRecord>(
+ device::mojom::blink::NDEFRecordTypeCategory::kLocal, record_type,
+ id, payload_message);
+ }
+ case V8NDEFMessageSource::ContentType::kString:
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (record.hasData() && IsBufferSource(record.data())) {
WTF::Vector<uint8_t> bytes;
if (!GetBytesOfBufferSource(record.data(), &bytes, exception_state)) {
@@ -359,6 +523,7 @@
device::mojom::blink::NDEFRecordTypeCategory::kLocal, record_type, id,
payload_message);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
exception_state.ThrowTypeError(
"The data for local type NDEFRecord must be a BufferSource or an "
diff --git a/third_party/blink/renderer/modules/notifications/notification_data_test.cc b/third_party/blink/renderer/modules/notifications/notification_data_test.cc
index 319c4d0..6c31aff 100644
--- a/third_party/blink/renderer/modules/notifications/notification_data_test.cc
+++ b/third_party/blink/renderer/modules/notifications/notification_data_test.cc
@@ -57,8 +57,14 @@
for (size_t i = 0; i < base::size(kNotificationVibration); ++i)
vibration_pattern.push_back(kNotificationVibration[i]);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* vibration_sequence =
+ MakeGarbageCollected<V8UnionUnsignedLongOrUnsignedLongSequence>(
+ vibration_pattern);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnsignedLongOrUnsignedLongSequence vibration_sequence;
vibration_sequence.SetUnsignedLongSequence(vibration_pattern);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
HeapVector<Member<NotificationAction>> actions;
for (size_t i = 0; i < Notification::maxActions(); ++i) {
@@ -144,8 +150,14 @@
for (size_t i = 0; i < base::size(kNotificationVibration); ++i)
vibration_pattern.push_back(kNotificationVibration[i]);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* vibration_sequence =
+ MakeGarbageCollected<V8UnionUnsignedLongOrUnsignedLongSequence>(
+ std::move(vibration_pattern));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnsignedLongOrUnsignedLongSequence vibration_sequence;
vibration_sequence.SetUnsignedLongSequence(vibration_pattern);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
NotificationOptions* options =
NotificationOptions::Create(scope.GetIsolate());
@@ -243,8 +255,14 @@
for (size_t i = 0; i < base::size(kNotificationVibrationUnnormalized); ++i)
unnormalized_pattern.push_back(kNotificationVibrationUnnormalized[i]);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* vibration_sequence =
+ MakeGarbageCollected<V8UnionUnsignedLongOrUnsignedLongSequence>(
+ unnormalized_pattern);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
UnsignedLongOrUnsignedLongSequence vibration_sequence;
vibration_sequence.SetUnsignedLongSequence(unnormalized_pattern);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
NotificationOptions* options =
NotificationOptions::Create(scope.GetIsolate());
diff --git a/third_party/blink/renderer/modules/payments/payment_event_data_conversion.cc b/third_party/blink/renderer/modules/payments/payment_event_data_conversion.cc
index a7c77c06..6f9966d 100644
--- a/third_party/blink/renderer/modules/payments/payment_event_data_conversion.cc
+++ b/third_party/blink/renderer/modules/payments/payment_event_data_conversion.cc
@@ -64,8 +64,10 @@
DCHECK(data);
PaymentMethodData* method_data = PaymentMethodData::Create();
method_data->setSupportedMethod(data->supported_method);
- method_data->setData(
- StringDataToScriptValue(script_state, data->stringified_data));
+ ScriptValue v8_data =
+ StringDataToScriptValue(script_state, data->stringified_data);
+ if (!v8_data.IsEmpty())
+ method_data->setData(std::move(v8_data));
return method_data;
}
diff --git a/third_party/blink/renderer/modules/payments/payment_request_for_invalid_origin_or_ssl_test.cc b/third_party/blink/renderer/modules/payments/payment_request_for_invalid_origin_or_ssl_test.cc
index e0789ff..d0e9109 100644
--- a/third_party/blink/renderer/modules/payments/payment_request_for_invalid_origin_or_ssl_test.cc
+++ b/third_party/blink/renderer/modules/payments/payment_request_for_invalid_origin_or_ssl_test.cc
@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/modules/payments/payment_request.h"
#include "third_party/blink/renderer/modules/payments/payment_test_helper.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
+#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
diff --git a/third_party/blink/renderer/modules/payments/secure_payment_confirmation_type_converter.cc b/third_party/blink/renderer/modules/payments/secure_payment_confirmation_type_converter.cc
index 8056093..e6385cc 100644
--- a/third_party/blink/renderer/modules/payments/secure_payment_confirmation_type_converter.cc
+++ b/third_party/blink/renderer/modules/payments/secure_payment_confirmation_type_converter.cc
@@ -4,15 +4,32 @@
#include "third_party/blink/renderer/modules/payments/secure_payment_confirmation_type_converter.h"
-#include <stdint.h>
+#include <cstdint>
#include "base/time/time.h"
#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview.h"
#include "third_party/blink/renderer/modules/credentialmanager/credential_manager_type_converters.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace mojo {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+template <>
+struct TypeConverter<Vector<Vector<uint8_t>>,
+ blink::HeapVector<blink::Member<
+ blink::V8UnionArrayBufferOrArrayBufferView>>> {
+ static Vector<Vector<uint8_t>> Convert(
+ const blink::HeapVector<
+ blink::Member<blink::V8UnionArrayBufferOrArrayBufferView>>& input) {
+ Vector<Vector<uint8_t>> result;
+ for (const auto& item : input) {
+ result.push_back(mojo::ConvertTo<Vector<uint8_t>>(item.Get()));
+ }
+ return result;
+ }
+};
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
template <>
struct TypeConverter<Vector<Vector<uint8_t>>,
blink::HeapVector<blink::ArrayBufferOrArrayBufferView>> {
@@ -25,6 +42,7 @@
return result;
}
};
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
payments::mojom::blink::SecurePaymentConfirmationRequestPtr
TypeConverter<payments::mojom::blink::SecurePaymentConfirmationRequestPtr,
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc b/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc
index dcf512a..4dbcf22 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc
@@ -6,6 +6,7 @@
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/web/web_local_frame.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_string_stringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_gather_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_ice_server.h"
@@ -224,11 +225,22 @@
// Prefer standardized 'urls' field over deprecated 'url' field.
Vector<String> url_strings;
if (ice_server->hasUrls()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (ice_server->urls()->GetContentType()) {
+ case V8UnionStringOrStringSequence::ContentType::kString:
+ url_strings.push_back(ice_server->urls()->GetAsString());
+ break;
+ case V8UnionStringOrStringSequence::ContentType::kStringSequence:
+ url_strings = ice_server->urls()->GetAsStringSequence();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (ice_server->urls().IsString()) {
url_strings.push_back(ice_server->urls().GetAsString());
} else if (ice_server->urls().IsStringSequence()) {
url_strings = ice_server->urls().GetAsStringSequence();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} else if (ice_server->hasUrl()) {
url_strings.push_back(ice_server->url());
}
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
index f926807..3ee4952 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
@@ -46,6 +46,7 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_crypto_algorithm_params.h"
#include "third_party/blink/public/web/web_local_frame.h"
+#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_object_string.h"
@@ -75,6 +76,7 @@
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/modules/crypto/crypto_result_impl.h"
#include "third_party/blink/renderer/modules/mediastream/media_constraints_impl.h"
+#include "third_party/blink/renderer/modules/mediastream/media_error_state.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_event.h"
#include "third_party/blink/renderer/modules/mediastream/user_media_controller.h"
@@ -386,6 +388,16 @@
Vector<String> url_strings;
if (ice_server->hasUrls()) {
UseCounter::Count(context, WebFeature::kRTCIceServerURLs);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (ice_server->urls()->GetContentType()) {
+ case V8UnionStringOrStringSequence::ContentType::kString:
+ url_strings.push_back(ice_server->urls()->GetAsString());
+ break;
+ case V8UnionStringOrStringSequence::ContentType::kStringSequence:
+ url_strings = ice_server->urls()->GetAsStringSequence();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const StringOrStringSequence& urls = ice_server->urls();
if (urls.IsString()) {
url_strings.push_back(urls.GetAsString());
@@ -393,6 +405,7 @@
DCHECK(urls.IsStringSequence());
url_strings = urls.GetAsStringSequence();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} else if (ice_server->hasUrl()) {
UseCounter::Count(context, WebFeature::kRTCIceServerURL);
url_strings.push_back(ice_server->url());
@@ -1723,13 +1736,18 @@
for (const auto& webrtc_server : webrtc_configuration.servers) {
auto* ice_server = RTCIceServer::Create();
- StringOrStringSequence urls;
Vector<String> url_vector;
url_vector.ReserveCapacity(SafeCast<wtf_size_t>(webrtc_server.urls.size()));
for (const auto& url : webrtc_server.urls) {
url_vector.emplace_back(url.c_str());
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* urls = MakeGarbageCollected<V8UnionStringOrStringSequence>(
+ std::move(url_vector));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ StringOrStringSequence urls;
urls.SetStringSequence(std::move(url_vector));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ice_server->setUrls(urls);
ice_server->setUsername(webrtc_server.username.c_str());
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_session_description_request_impl.cc b/third_party/blink/renderer/modules/peerconnection/rtc_session_description_request_impl.cc
index 27e6fe4..61e8331 100644
--- a/third_party/blink/renderer/modules/peerconnection/rtc_session_description_request_impl.cc
+++ b/third_party/blink/renderer/modules/peerconnection/rtc_session_description_request_impl.cc
@@ -31,11 +31,11 @@
#include "third_party/blink/renderer/modules/peerconnection/rtc_session_description_request_impl.h"
#include "base/memory/scoped_refptr.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_session_description_init.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_error_util.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_session_description.h"
-#include "third_party/blink/renderer/modules/peerconnection/rtc_session_description_init.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h"
namespace blink {
@@ -74,7 +74,8 @@
requester_->NoteSessionDescriptionRequestCompleted(operation_, true);
RTCSessionDescriptionInit* description =
RTCSessionDescriptionInit::Create();
- description->setType(description_platform->GetType());
+ if (description_platform->GetType())
+ description->setType(description_platform->GetType());
description->setSdp(description_platform->Sdp());
requester_->NoteSdpCreated(
diff --git a/third_party/blink/renderer/modules/push_messaging/push_event.cc b/third_party/blink/renderer/modules/push_messaging/push_event.cc
index b75aaed..279aed9 100644
--- a/third_party/blink/renderer/modules/push_messaging/push_event.cc
+++ b/third_party/blink/renderer/modules/push_messaging/push_event.cc
@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_push_event_init.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
@@ -20,6 +21,21 @@
ExceptionState& exception_state)
: ExtendableEvent(type, initializer) {
if (initializer->hasData()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto* message_data = initializer->data();
+ if (message_data->IsArrayBuffer() || message_data->IsArrayBufferView()) {
+ DOMArrayPiece array_piece =
+ message_data->IsArrayBuffer()
+ ? DOMArrayPiece(message_data->GetAsArrayBuffer())
+ : DOMArrayPiece(message_data->GetAsArrayBufferView().Get());
+ if (!base::CheckedNumeric<uint32_t>(array_piece.ByteLength()).IsValid()) {
+ exception_state.ThrowRangeError(
+ "The provided ArrayBuffer exceeds the maximum supported size "
+ "(4294967295)");
+ return;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const ArrayBufferOrArrayBufferViewOrUSVString& message_data =
initializer->data();
if (message_data.IsArrayBuffer() || message_data.IsArrayBufferView()) {
@@ -34,6 +50,7 @@
return;
}
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
data_ = PushMessageData::Create(initializer->data());
}
}
diff --git a/third_party/blink/renderer/modules/push_messaging/push_manager_test.cc b/third_party/blink/renderer/modules/push_messaging/push_manager_test.cc
index 425d3ad2..3741369 100644
--- a/third_party/blink/renderer/modules/push_messaging/push_manager_test.cc
+++ b/third_party/blink/renderer/modules/push_messaging/push_manager_test.cc
@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_push_subscription_options_init.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/modules/push_messaging/push_subscription_options.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
@@ -48,10 +49,17 @@
TEST(PushManagerTest, ValidSenderKey) {
PushSubscriptionOptionsInit* options = PushSubscriptionOptionsInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setApplicationServerKey(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrString>(
+ DOMArrayBuffer::Create(kApplicationServerKey,
+ kApplicationServerKeyLength)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setApplicationServerKey(
ArrayBufferOrArrayBufferViewOrString::FromArrayBuffer(
DOMArrayBuffer::Create(kApplicationServerKey,
kApplicationServerKeyLength)));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
PushSubscriptionOptions* output =
@@ -74,8 +82,14 @@
WTF::Base64URLEncode(reinterpret_cast<const char*>(kApplicationServerKey),
kApplicationServerKeyLength);
base64_url = base64_url.RemoveCharacters(RemovePad);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setApplicationServerKey(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrString>(
+ base64_url));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setApplicationServerKey(
ArrayBufferOrArrayBufferViewOrString::FromString(base64_url));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
PushSubscriptionOptions* output =
@@ -89,9 +103,15 @@
uint8_t sender_key[kMaxKeyLength + 1];
memset(sender_key, 0, sizeof(sender_key));
PushSubscriptionOptionsInit* options = PushSubscriptionOptionsInit::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setApplicationServerKey(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrString>(
+ DOMArrayBuffer::Create(sender_key, kMaxKeyLength + 1)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setApplicationServerKey(
ArrayBufferOrArrayBufferViewOrString::FromArrayBuffer(
DOMArrayBuffer::Create(sender_key, kMaxKeyLength + 1)));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
PushSubscriptionOptions* output =
@@ -105,9 +125,15 @@
TEST(PushManagerTest, InvalidBase64SenderKey) {
PushSubscriptionOptionsInit* options =
MakeGarbageCollected<PushSubscriptionOptionsInit>();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setApplicationServerKey(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrString>(
+ Base64Encode(kApplicationServerKey)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setApplicationServerKey(
ArrayBufferOrArrayBufferViewOrString::FromString(
Base64Encode(kApplicationServerKey)));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
PushSubscriptionOptions* output =
@@ -122,10 +148,18 @@
TEST(PushManagerTest, InvalidBase64URLWithPaddingSenderKey) {
PushSubscriptionOptionsInit* options =
MakeGarbageCollected<PushSubscriptionOptionsInit>();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options->setApplicationServerKey(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrString>(
+ WTF::Base64URLEncode(
+ reinterpret_cast<const char*>(kApplicationServerKey),
+ kApplicationServerKeyLength)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
options->setApplicationServerKey(
ArrayBufferOrArrayBufferViewOrString::FromString(WTF::Base64URLEncode(
reinterpret_cast<const char*>(kApplicationServerKey),
kApplicationServerKeyLength)));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DummyExceptionStateForTesting exception_state;
PushSubscriptionOptions* output =
diff --git a/third_party/blink/renderer/modules/push_messaging/push_message_data.cc b/third_party/blink/renderer/modules/push_messaging/push_message_data.cc
index 24c865b..24d725d 100644
--- a/third_party/blink/renderer/modules/push_messaging/push_message_data.cc
+++ b/third_party/blink/renderer/modules/push_messaging/push_message_data.cc
@@ -7,6 +7,7 @@
#include <memory>
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview_usvstring.h"
#include "third_party/blink/renderer/bindings/modules/v8/array_buffer_or_array_buffer_view_or_usv_string.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
@@ -26,10 +27,50 @@
// be set in the PushEvent.
if (message_string.IsNull())
return nullptr;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ return PushMessageData::Create(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrUSVString>(
+ message_string));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return PushMessageData::Create(
ArrayBufferOrArrayBufferViewOrUSVString::FromUSVString(message_string));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+PushMessageData* PushMessageData::Create(
+ const V8UnionArrayBufferOrArrayBufferViewOrUSVString* message_data) {
+ if (!message_data)
+ return nullptr;
+ switch (message_data->GetContentType()) {
+ case V8UnionArrayBufferOrArrayBufferViewOrUSVString::ContentType::
+ kArrayBuffer: {
+ DOMArrayBuffer* buffer = message_data->GetAsArrayBuffer();
+ return MakeGarbageCollected<PushMessageData>(
+ static_cast<const char*>(buffer->Data()),
+ base::checked_cast<wtf_size_t>(buffer->ByteLength()));
+ }
+ case V8UnionArrayBufferOrArrayBufferViewOrUSVString::ContentType::
+ kArrayBufferView: {
+ DOMArrayBufferView* buffer_view =
+ message_data->GetAsArrayBufferView().Get();
+ return MakeGarbageCollected<PushMessageData>(
+ static_cast<const char*>(buffer_view->BaseAddress()),
+ base::checked_cast<wtf_size_t>(buffer_view->byteLength()));
+ }
+ case V8UnionArrayBufferOrArrayBufferViewOrUSVString::ContentType::
+ kUSVString: {
+ std::string encoded_string = UTF8Encoding().Encode(
+ message_data->GetAsUSVString(), WTF::kNoUnencodables);
+ return MakeGarbageCollected<PushMessageData>(
+ encoded_string.c_str(),
+ static_cast<unsigned>(encoded_string.length()));
+ }
+ }
+ NOTREACHED();
+ return nullptr;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
PushMessageData* PushMessageData::Create(
const ArrayBufferOrArrayBufferViewOrUSVString& message_data) {
if (message_data.IsArrayBuffer()) {
@@ -56,6 +97,7 @@
DCHECK(message_data.IsNull());
return nullptr;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
PushMessageData::PushMessageData(const char* data, unsigned bytes_size) {
data_.Append(data, bytes_size);
diff --git a/third_party/blink/renderer/modules/push_messaging/push_message_data.h b/third_party/blink/renderer/modules/push_messaging/push_message_data.h
index 1185601..65fceb2 100644
--- a/third_party/blink/renderer/modules/push_messaging/push_message_data.h
+++ b/third_party/blink/renderer/modules/push_messaging/push_message_data.h
@@ -19,14 +19,20 @@
class DOMArrayBuffer;
class ExceptionState;
class ScriptState;
+class V8UnionArrayBufferOrArrayBufferViewOrUSVString;
class MODULES_EXPORT PushMessageData final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static PushMessageData* Create(const String& data);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ static PushMessageData* Create(
+ const V8UnionArrayBufferOrArrayBufferViewOrUSVString* data);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
static PushMessageData* Create(
const ArrayBufferOrArrayBufferViewOrUSVString& data);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
PushMessageData(const char* data, unsigned bytes_size);
~PushMessageData() override;
diff --git a/third_party/blink/renderer/modules/push_messaging/push_subscription_options.cc b/third_party/blink/renderer/modules/push_messaging/push_subscription_options.cc
index 7511965..2ddf1c3 100644
--- a/third_party/blink/renderer/modules/push_messaging/push_subscription_options.cc
+++ b/third_party/blink/renderer/modules/push_messaging/push_subscription_options.cc
@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/modules/push_messaging/push_subscription_options.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/array_buffer_or_array_buffer_view_or_string.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_push_subscription_options_init.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
@@ -19,7 +20,11 @@
const int kMaxApplicationServerKeyLength = 255;
Vector<uint8_t> BufferSourceToVector(
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const V8UnionBufferSourceOrString* application_server_key,
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const ArrayBufferOrArrayBufferViewOrString& application_server_key,
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ExceptionState& exception_state) {
char* input;
size_t length;
@@ -27,6 +32,32 @@
Vector<uint8_t> result;
// Convert the input array into a string of bytes.
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (application_server_key->GetContentType()) {
+ case V8UnionBufferSourceOrString::ContentType::kArrayBuffer:
+ input = static_cast<char*>(
+ application_server_key->GetAsArrayBuffer()->Data());
+ length = application_server_key->GetAsArrayBuffer()->ByteLength();
+ break;
+ case V8UnionBufferSourceOrString::ContentType::kArrayBufferView:
+ input = static_cast<char*>(
+ application_server_key->GetAsArrayBufferView()->BaseAddress());
+ length = application_server_key->GetAsArrayBufferView()->byteLength();
+ break;
+ case V8UnionBufferSourceOrString::ContentType::kString:
+ if (!Base64UnpaddedURLDecode(application_server_key->GetAsString(),
+ decoded_application_server_key)) {
+ exception_state.ThrowDOMException(
+ DOMExceptionCode::kInvalidCharacterError,
+ "The provided applicationServerKey is not encoded as base64url "
+ "without padding.");
+ return result;
+ }
+ input = reinterpret_cast<char*>(decoded_application_server_key.data());
+ length = decoded_application_server_key.size();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (application_server_key.IsArrayBuffer()) {
input =
static_cast<char*>(application_server_key.GetAsArrayBuffer()->Data());
@@ -50,6 +81,7 @@
NOTREACHED();
return result;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// Check the validity of the sender info. It must either be a 65-byte
// uncompressed VAPID key, which has the byte 0x04 as the first byte or a
@@ -82,7 +114,12 @@
// has a default value, but we check |hasApplicationServerKey()| here for
// backward compatibility.
if (options_init->hasApplicationServerKey() &&
- !options_init->applicationServerKey().IsNull()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ options_init->applicationServerKey()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ !options_init->applicationServerKey().IsNull()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
application_server_key.AppendVector(BufferSourceToVector(
options_init->applicationServerKey(), exception_state));
}
diff --git a/third_party/blink/renderer/modules/sanitizer_api/sanitizer_config_impl.cc b/third_party/blink/renderer/modules/sanitizer_api/sanitizer_config_impl.cc
index dd433b7..e9b186e 100644
--- a/third_party/blink/renderer/modules/sanitizer_api/sanitizer_config_impl.cc
+++ b/third_party/blink/renderer/modules/sanitizer_api/sanitizer_config_impl.cc
@@ -4,7 +4,7 @@
#include "third_party/blink/renderer/modules/sanitizer_api/sanitizer_config_impl.h"
-#include "third_party/blink/renderer/modules/sanitizer_api/sanitizer_config.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_sanitizer_config.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
diff --git a/third_party/blink/renderer/modules/scheduler/dom_scheduler.cc b/third_party/blink/renderer/modules/scheduler/dom_scheduler.cc
index 767862b..e6d71ee 100644
--- a/third_party/blink/renderer/modules/scheduler/dom_scheduler.cc
+++ b/third_party/blink/renderer/modules/scheduler/dom_scheduler.cc
@@ -65,7 +65,7 @@
"Current window is detached");
return ScriptPromise();
}
- if (options->signal() && options->signal()->aborted()) {
+ if (options->hasSignal() && options->signal()->aborted()) {
exception_state.ThrowDOMException(DOMExceptionCode::kAbortError,
"The task was aborted");
return ScriptPromise();
@@ -73,7 +73,8 @@
// Always honor the priority and the task signal if given.
DOMTaskSignal* task_signal = nullptr;
- if (!options->hasPriority() && IsA<DOMTaskSignal>(options->signal())) {
+ if (!options->hasPriority() && options->hasSignal() &&
+ IsA<DOMTaskSignal>(options->signal())) {
// If only a signal is given, and it is a TaskSignal rather than an
// basic AbortSignal, use it.
task_signal = To<DOMTaskSignal>(options->signal());
@@ -95,7 +96,7 @@
IDLEnumAsString(options->priority())))
: kDefaultPriority;
task_signal = CreateTaskSignalFor(priority);
- if (options->signal())
+ if (options->hasSignal())
task_signal->Follow(options->signal());
}
diff --git a/third_party/blink/renderer/modules/scheduler/dom_task_signal.cc b/third_party/blink/renderer/modules/scheduler/dom_task_signal.cc
index 0c24499..7a17f27d 100644
--- a/third_party/blink/renderer/modules/scheduler/dom_task_signal.cc
+++ b/third_party/blink/renderer/modules/scheduler/dom_task_signal.cc
@@ -7,10 +7,10 @@
#include <utility>
#include "base/callback.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_task_priority_change_event_init.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/modules/scheduler/task_priority_change_event.h"
-#include "third_party/blink/renderer/modules/scheduler/task_priority_change_event_init.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
diff --git a/third_party/blink/renderer/modules/scheduler/task_priority_change_event.cc b/third_party/blink/renderer/modules/scheduler/task_priority_change_event.cc
index b08d8cf..840a9b7 100644
--- a/third_party/blink/renderer/modules/scheduler/task_priority_change_event.cc
+++ b/third_party/blink/renderer/modules/scheduler/task_priority_change_event.cc
@@ -28,8 +28,14 @@
return event_interface_names::kTaskPriorityChangeEvent;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+V8TaskPriority TaskPriorityChangeEvent::previousPriority() const {
+ return previous_priority_;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AtomicString TaskPriorityChangeEvent::previousPriority() const {
return previous_priority_;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} // namespace blink
diff --git a/third_party/blink/renderer/modules/scheduler/task_priority_change_event.h b/third_party/blink/renderer/modules/scheduler/task_priority_change_event.h
index c4d99fb..ff8ce27 100644
--- a/third_party/blink/renderer/modules/scheduler/task_priority_change_event.h
+++ b/third_party/blink/renderer/modules/scheduler/task_priority_change_event.h
@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SCHEDULER_TASK_PRIORITY_CHANGE_EVENT_H_
#include "base/macros.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_task_priority.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/modules/event_modules.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
@@ -27,10 +28,18 @@
const AtomicString& InterfaceName() const override;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ V8TaskPriority previousPriority() const;
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AtomicString previousPriority() const;
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
private:
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const V8TaskPriority previous_priority_;
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const AtomicString previous_priority_;
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DISALLOW_COPY_AND_ASSIGN(TaskPriorityChangeEvent);
};
diff --git a/third_party/blink/renderer/modules/serial/serial_port.cc b/third_party/blink/renderer/modules/serial/serial_port.cc
index 681820a..135e1da 100644
--- a/third_party/blink/renderer/modules/serial/serial_port.cc
+++ b/third_party/blink/renderer/modules/serial/serial_port.cc
@@ -19,6 +19,7 @@
#include "third_party/blink/renderer/modules/serial/serial.h"
#include "third_party/blink/renderer/modules/serial/serial_port_underlying_sink.h"
#include "third_party/blink/renderer/modules/serial/serial_port_underlying_source.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
namespace blink {
diff --git a/third_party/blink/renderer/modules/service_worker/extendable_message_event.cc b/third_party/blink/renderer/modules/service_worker/extendable_message_event.cc
index 1d870b1..ff3e642 100644
--- a/third_party/blink/renderer/modules/service_worker/extendable_message_event.cc
+++ b/third_party/blink/renderer/modules/service_worker/extendable_message_event.cc
@@ -135,6 +135,22 @@
origin_ = initializer->origin();
if (initializer->hasLastEventId())
last_event_id_ = initializer->lastEventId();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (initializer->hasSource() and initializer->source()) {
+ switch (initializer->source()->GetContentType()) {
+ case V8UnionClientOrMessagePortOrServiceWorker::ContentType::kClient:
+ source_as_client_ = initializer->source()->GetAsClient();
+ break;
+ case V8UnionClientOrMessagePortOrServiceWorker::ContentType::kMessagePort:
+ source_as_message_port_ = initializer->source()->GetAsMessagePort();
+ break;
+ case V8UnionClientOrMessagePortOrServiceWorker::ContentType::
+ kServiceWorker:
+ source_as_service_worker_ = initializer->source()->GetAsServiceWorker();
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (initializer->hasSource()) {
if (initializer->source().IsClient())
source_as_client_ = initializer->source().GetAsClient();
@@ -143,6 +159,7 @@
else if (initializer->source().IsMessagePort())
source_as_message_port_ = initializer->source().GetAsMessagePort();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (initializer->hasPorts())
ports_ = MakeGarbageCollected<MessagePortArray>(initializer->ports());
}
diff --git a/third_party/blink/renderer/modules/url_pattern/url_pattern.cc b/third_party/blink/renderer/modules/url_pattern/url_pattern.cc
index 4f56816..c07541f 100644
--- a/third_party/blink/renderer/modules/url_pattern/url_pattern.cc
+++ b/third_party/blink/renderer/modules/url_pattern/url_pattern.cc
@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_regexp.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_urlpatterninit_usvstring.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_url_pattern_component_result.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_url_pattern_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_url_pattern_result.h"
#include "third_party/blink/renderer/modules/url_pattern/url_pattern_canon.h"
#include "third_party/blink/renderer/modules/url_pattern/url_pattern_component.h"
@@ -417,69 +418,85 @@
String search(g_empty_string);
String hash(g_empty_string);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ HeapVector<Member<V8URLPatternInput>> inputs;
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
HeapVector<USVStringOrURLPatternInit> inputs;
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
- if (input->GetContentType() ==
- V8URLPatternInput::ContentType::kURLPatternInit) {
- if (base_url) {
- exception_state.ThrowTypeError(
- "Invalid second argument baseURL '" + base_url +
- "' provided with a URLPatternInit input. Use the "
- "URLPatternInit.baseURL property instead.");
- return false;
+ switch (input->GetContentType()) {
+ case V8URLPatternInput::ContentType::kURLPatternInit: {
+ if (base_url) {
+ exception_state.ThrowTypeError(
+ "Invalid second argument baseURL '" + base_url +
+ "' provided with a URLPatternInit input. Use the "
+ "URLPatternInit.baseURL property instead.");
+ return false;
+ }
+
+ URLPatternInit* init = input->GetAsURLPatternInit();
+
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ inputs.push_back(MakeGarbageCollected<V8URLPatternInput>(init));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ inputs.push_back(USVStringOrURLPatternInit::FromURLPatternInit(init));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
+ // Layer the URLPatternInit values on top of the default empty strings.
+ ApplyInit(init, ValueType::kURL, protocol, username, password, hostname,
+ port, pathname, search, hash, exception_state);
+ if (exception_state.HadException()) {
+ // Treat exceptions simply as a failure to match.
+ exception_state.ClearException();
+ return false;
+ }
+ break;
}
+ case V8URLPatternInput::ContentType::kUSVString: {
+ KURL parsed_base_url(base_url);
+ if (base_url && !parsed_base_url.IsValid()) {
+ // Treat as failure to match, but don't throw an exception.
+ return false;
+ }
- URLPatternInit* init =
- input->GetAsURLPatternInit();
+ const String& input_string = input->GetAsUSVString();
- inputs.push_back(USVStringOrURLPatternInit::FromURLPatternInit(init));
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ inputs.push_back(MakeGarbageCollected<V8URLPatternInput>(input_string));
+ if (base_url)
+ inputs.push_back(MakeGarbageCollected<V8URLPatternInput>(base_url));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ inputs.push_back(USVStringOrURLPatternInit::FromUSVString(input_string));
+ if (base_url)
+ inputs.push_back(USVStringOrURLPatternInit::FromUSVString(base_url));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
- // Layer the URLPatternInit values on top of the default empty strings.
- ApplyInit(init, ValueType::kURL, protocol, username, password, hostname,
- port, pathname, search, hash, exception_state);
- if (exception_state.HadException()) {
- // Treat exceptions simply as a failure to match.
- exception_state.ClearException();
- return false;
+ // The compile the input string as a fully resolved URL.
+ KURL url(parsed_base_url, input_string);
+ if (!url.IsValid() || url.IsEmpty()) {
+ // Treat as failure to match, but don't throw an exception.
+ return false;
+ }
+
+ // Apply the parsed URL components on top of our defaults.
+ if (url.Protocol())
+ protocol = url.Protocol();
+ if (url.User())
+ username = url.User();
+ if (url.Pass())
+ password = url.Pass();
+ if (url.Host())
+ hostname = url.Host();
+ if (url.Port() > 0)
+ port = String::Number(url.Port());
+ if (url.GetPath())
+ pathname = url.GetPath();
+ if (url.Query())
+ search = url.Query();
+ if (url.FragmentIdentifier())
+ hash = url.FragmentIdentifier();
+ break;
}
- } else {
- KURL parsed_base_url(base_url);
- if (base_url && !parsed_base_url.IsValid()) {
- // Treat as failure to match, but don't throw an exception.
- return false;
- }
-
- const String& input_string =
- input->GetAsUSVString();
-
- inputs.push_back(USVStringOrURLPatternInit::FromUSVString(input_string));
- if (base_url)
- inputs.push_back(USVStringOrURLPatternInit::FromUSVString(base_url));
-
- // The compile the input string as a fully resolved URL.
- KURL url(parsed_base_url, input_string);
- if (!url.IsValid() || url.IsEmpty()) {
- // Treat as failure to match, but don't throw an exception.
- return false;
- }
-
- // Apply the parsed URL components on top of our defaults.
- if (url.Protocol())
- protocol = url.Protocol();
- if (url.User())
- username = url.User();
- if (url.Pass())
- password = url.Pass();
- if (url.Host())
- hostname = url.Host();
- if (url.Port() > 0)
- port = String::Number(url.Port());
- if (url.GetPath())
- pathname = url.GetPath();
- if (url.Query())
- search = url.Query();
- if (url.FragmentIdentifier())
- hash = url.FragmentIdentifier();
}
Vector<String> protocol_group_list;
diff --git a/third_party/blink/renderer/modules/url_pattern/url_pattern.idl b/third_party/blink/renderer/modules/url_pattern/url_pattern.idl
index 672fb5d..56a1cb0 100644
--- a/third_party/blink/renderer/modules/url_pattern/url_pattern.idl
+++ b/third_party/blink/renderer/modules/url_pattern/url_pattern.idl
@@ -16,7 +16,7 @@
boolean test(URLPatternInput input, optional USVString baseURL);
[RaisesException]
- URLPatternResult exec(URLPatternInput input, optional USVString baseURL);
+ URLPatternResult? exec(URLPatternInput input, optional USVString baseURL);
readonly attribute USVString protocol;
readonly attribute USVString username;
diff --git a/third_party/blink/renderer/modules/url_pattern/url_pattern_parser.cc b/third_party/blink/renderer/modules/url_pattern/url_pattern_parser.cc
index fc558682..81cd416 100644
--- a/third_party/blink/renderer/modules/url_pattern/url_pattern_parser.cc
+++ b/third_party/blink/renderer/modules/url_pattern/url_pattern_parser.cc
@@ -5,8 +5,8 @@
#include "third_party/blink/renderer/modules/url_pattern/url_pattern_parser.h"
#include "base/notreached.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_url_pattern_init.h"
#include "third_party/blink/renderer/modules/url_pattern/url_pattern_component.h"
-#include "third_party/blink/renderer/modules/url_pattern/url_pattern_init.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/liburlpattern/tokenize.h"
diff --git a/third_party/blink/renderer/modules/vibration/vibration_controller.cc b/third_party/blink/renderer/modules/vibration/vibration_controller.cc
index 463b1d4..ceb91f5 100644
--- a/third_party/blink/renderer/modules/vibration/vibration_controller.cc
+++ b/third_party/blink/renderer/modules/vibration/vibration_controller.cc
@@ -23,6 +23,7 @@
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_union_unsignedlong_unsignedlongsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_or_unsigned_long_sequence.h"
#include "third_party/blink/renderer/core/frame/intervention.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
@@ -102,6 +103,26 @@
}
// static
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+VibrationController::VibrationPattern
+VibrationController::SanitizeVibrationPattern(
+ const V8UnionUnsignedLongOrUnsignedLongSequence* input) {
+ switch (input->GetContentType()) {
+ case V8UnionUnsignedLongOrUnsignedLongSequence::ContentType::
+ kUnsignedLong: {
+ VibrationPattern pattern;
+ pattern.push_back(input->GetAsUnsignedLong());
+ return sanitizeVibrationPatternInternal(pattern);
+ }
+ case V8UnionUnsignedLongOrUnsignedLongSequence::ContentType::
+ kUnsignedLongSequence:
+ return sanitizeVibrationPatternInternal(
+ input->GetAsUnsignedLongSequence());
+ }
+ NOTREACHED();
+ return {};
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
VibrationController::VibrationPattern
VibrationController::SanitizeVibrationPattern(
const UnsignedLongOrUnsignedLongSequence& input) {
@@ -114,6 +135,7 @@
return sanitizeVibrationPatternInternal(pattern);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// static
VibrationController& VibrationController::From(Navigator& navigator) {
diff --git a/third_party/blink/renderer/modules/vibration/vibration_controller.h b/third_party/blink/renderer/modules/vibration/vibration_controller.h
index 2e1fbf8..8da6318 100644
--- a/third_party/blink/renderer/modules/vibration/vibration_controller.h
+++ b/third_party/blink/renderer/modules/vibration/vibration_controller.h
@@ -36,6 +36,7 @@
class Navigator;
class UnsignedLongOrUnsignedLongSequence;
+class V8UnionUnsignedLongOrUnsignedLongSequence;
class MODULES_EXPORT VibrationController final
: public GarbageCollected<VibrationController>,
@@ -54,8 +55,13 @@
explicit VibrationController(Navigator&);
~VibrationController() override;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ static VibrationPattern SanitizeVibrationPattern(
+ const V8UnionUnsignedLongOrUnsignedLongSequence* input);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
static VibrationPattern SanitizeVibrationPattern(
const UnsignedLongOrUnsignedLongSequence&);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
void DoVibrate(TimerBase*);
void DidVibrate();
diff --git a/third_party/blink/renderer/modules/webaudio/audio_context.cc b/third_party/blink/renderer/modules/webaudio/audio_context.cc
index 7466cef..689adb4 100644
--- a/third_party/blink/renderer/modules/webaudio/audio_context.cc
+++ b/third_party/blink/renderer/modules/webaudio/audio_context.cc
@@ -103,6 +103,26 @@
WebFeature::kAudioContextCrossOriginIframe);
WebAudioLatencyHint latency_hint(WebAudioLatencyHint::kCategoryInteractive);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (context_options->latencyHint()->GetContentType()) {
+ case V8UnionAudioContextLatencyCategoryOrDouble::ContentType::
+ kAudioContextLatencyCategory:
+ latency_hint =
+ WebAudioLatencyHint(context_options->latencyHint()
+ ->GetAsAudioContextLatencyCategory()
+ .AsString());
+ break;
+ case V8UnionAudioContextLatencyCategoryOrDouble::ContentType::kDouble:
+ // This should be the requested output latency in seconds, without taking
+ // into account double buffering (same as baseLatency).
+ latency_hint =
+ WebAudioLatencyHint(context_options->latencyHint()->GetAsDouble());
+
+ base::UmaHistogramTimes(
+ "WebAudio.AudioContext.latencyHintMilliSeconds",
+ base::TimeDelta::FromSecondsD(latency_hint.Seconds()));
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (context_options->latencyHint().IsAudioContextLatencyCategory()) {
latency_hint = WebAudioLatencyHint(
context_options->latencyHint().GetAsAudioContextLatencyCategory());
@@ -116,6 +136,7 @@
"WebAudio.AudioContext.latencyHintMilliSeconds",
base::TimeDelta::FromSecondsD(latency_hint.Seconds()));
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
base::UmaHistogramEnumeration(
"WebAudio.AudioContext.latencyHintCategory", latency_hint.Category(),
diff --git a/third_party/blink/renderer/modules/webaudio/audio_context_test.cc b/third_party/blink/renderer/modules/webaudio/audio_context_test.cc
index b7e88eb..ceae7d3 100644
--- a/third_party/blink/renderer/modules/webaudio/audio_context_test.cc
+++ b/third_party/blink/renderer/modules/webaudio/audio_context_test.cc
@@ -114,33 +114,60 @@
TEST_F(AudioContextTest, AudioContextOptions_WebAudioLatencyHint) {
AudioContextOptions* interactive_options = AudioContextOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ interactive_options->setLatencyHint(
+ MakeGarbageCollected<V8UnionAudioContextLatencyCategoryOrDouble>(
+ V8AudioContextLatencyCategory(
+ V8AudioContextLatencyCategory::Enum::kInteractive)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
interactive_options->setLatencyHint(
AudioContextLatencyCategoryOrDouble::FromAudioContextLatencyCategory(
"interactive"));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AudioContext* interactive_context = AudioContext::Create(
GetDocument(), interactive_options, ASSERT_NO_EXCEPTION);
AudioContextOptions* balanced_options = AudioContextOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ balanced_options->setLatencyHint(
+ MakeGarbageCollected<V8UnionAudioContextLatencyCategoryOrDouble>(
+ V8AudioContextLatencyCategory(
+ V8AudioContextLatencyCategory::Enum::kBalanced)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
balanced_options->setLatencyHint(
AudioContextLatencyCategoryOrDouble::FromAudioContextLatencyCategory(
"balanced"));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AudioContext* balanced_context = AudioContext::Create(
GetDocument(), balanced_options, ASSERT_NO_EXCEPTION);
EXPECT_GT(balanced_context->baseLatency(),
interactive_context->baseLatency());
AudioContextOptions* playback_options = AudioContextOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ playback_options->setLatencyHint(
+ MakeGarbageCollected<V8UnionAudioContextLatencyCategoryOrDouble>(
+ V8AudioContextLatencyCategory(
+ V8AudioContextLatencyCategory::Enum::kPlayback)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
playback_options->setLatencyHint(
AudioContextLatencyCategoryOrDouble::FromAudioContextLatencyCategory(
"playback"));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AudioContext* playback_context = AudioContext::Create(
GetDocument(), playback_options, ASSERT_NO_EXCEPTION);
EXPECT_GT(playback_context->baseLatency(), balanced_context->baseLatency());
AudioContextOptions* exact_too_small_options = AudioContextOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ exact_too_small_options->setLatencyHint(
+ MakeGarbageCollected<V8UnionAudioContextLatencyCategoryOrDouble>(
+ interactive_context->baseLatency() / 2));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
exact_too_small_options->setLatencyHint(
AudioContextLatencyCategoryOrDouble::FromDouble(
interactive_context->baseLatency() / 2));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AudioContext* exact_too_small_context = AudioContext::Create(
GetDocument(), exact_too_small_options, ASSERT_NO_EXCEPTION);
EXPECT_EQ(exact_too_small_context->baseLatency(),
@@ -150,16 +177,28 @@
(interactive_context->baseLatency() + playback_context->baseLatency()) /
2;
AudioContextOptions* exact_ok_options = AudioContextOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ exact_ok_options->setLatencyHint(
+ MakeGarbageCollected<V8UnionAudioContextLatencyCategoryOrDouble>(
+ exact_latency_sec));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
exact_ok_options->setLatencyHint(
AudioContextLatencyCategoryOrDouble::FromDouble(exact_latency_sec));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AudioContext* exact_ok_context = AudioContext::Create(
GetDocument(), exact_ok_options, ASSERT_NO_EXCEPTION);
EXPECT_EQ(exact_ok_context->baseLatency(), exact_latency_sec);
AudioContextOptions* exact_too_big_options = AudioContextOptions::Create();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ exact_too_big_options->setLatencyHint(
+ MakeGarbageCollected<V8UnionAudioContextLatencyCategoryOrDouble>(
+ playback_context->baseLatency() * 2));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
exact_too_big_options->setLatencyHint(
AudioContextLatencyCategoryOrDouble::FromDouble(
playback_context->baseLatency() * 2));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
AudioContext* exact_too_big_context = AudioContext::Create(
GetDocument(), exact_too_big_options, ASSERT_NO_EXCEPTION);
EXPECT_EQ(exact_too_big_context->baseLatency(),
diff --git a/third_party/blink/renderer/modules/webcodecs/audio_data.cc b/third_party/blink/renderer/modules/webcodecs/audio_data.cc
index 21e9675..40c66f9 100644
--- a/third_party/blink/renderer/modules/webcodecs/audio_data.cc
+++ b/third_party/blink/renderer/modules/webcodecs/audio_data.cc
@@ -8,6 +8,7 @@
#include "media/base/audio_bus.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_data_init.h"
#include "third_party/blink/renderer/modules/webaudio/audio_buffer.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
diff --git a/third_party/blink/renderer/modules/webcodecs/audio_decoder.cc b/third_party/blink/renderer/modules/webcodecs/audio_decoder.cc
index 458d13b..9082b92 100644
--- a/third_party/blink/renderer/modules/webcodecs/audio_decoder.cc
+++ b/third_party/blink/renderer/modules/webcodecs/audio_decoder.cc
@@ -63,8 +63,12 @@
DOMArrayPiece buffer(config.description());
DOMArrayBuffer* buffer_copy =
DOMArrayBuffer::Create(buffer.Data(), buffer.ByteLength());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ copy->setDescription(MakeGarbageCollected<V8BufferSource>(buffer_copy));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
copy->setDescription(
ArrayBufferOrArrayBufferView::FromArrayBuffer(buffer_copy));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
return copy;
}
diff --git a/third_party/blink/renderer/modules/webcodecs/audio_encoder.cc b/third_party/blink/renderer/modules/webcodecs/audio_encoder.cc
index 22494f0..efd27bb 100644
--- a/third_party/blink/renderer/modules/webcodecs/audio_encoder.cc
+++ b/third_party/blink/renderer/modules/webcodecs/audio_encoder.cc
@@ -17,6 +17,7 @@
#include "media/base/mime_util.h"
#include "media/base/offloading_audio_encoder.h"
#include "third_party/blink/public/mojom/web_feature/web_feature.mojom-blink.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_data_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_decoder_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_encoder_config.h"
@@ -24,6 +25,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_encoded_audio_chunk_metadata.h"
#include "third_party/blink/renderer/modules/webaudio/audio_buffer.h"
#include "third_party/blink/renderer/modules/webcodecs/encoded_audio_chunk.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace blink {
@@ -328,8 +330,13 @@
if (codec_desc.has_value()) {
auto* desc_array_buf = DOMArrayBuffer::Create(codec_desc.value().data(),
codec_desc.value().size());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ decoder_config->setDescription(
+ MakeGarbageCollected<V8BufferSource>(desc_array_buf));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
decoder_config->setDescription(
ArrayBufferOrArrayBufferView::FromArrayBuffer(desc_array_buf));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
metadata->setDecoderConfig(decoder_config);
}
diff --git a/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc b/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc
index 0bcf7de..f56b122 100644
--- a/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc
+++ b/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc
@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_data_output_callback.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_decoder_config.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_decoder_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_decoder_config.h"
diff --git a/third_party/blink/renderer/modules/webcodecs/encoded_video_chunk_test.cc b/third_party/blink/renderer/modules/webcodecs/encoded_video_chunk_test.cc
index 4ab072ec..75474298 100644
--- a/third_party/blink/renderer/modules/webcodecs/encoded_video_chunk_test.cc
+++ b/third_party/blink/renderer/modules/webcodecs/encoded_video_chunk_test.cc
@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/modules/webcodecs/encoded_video_chunk.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_encoded_video_chunk_init.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
@@ -14,11 +15,18 @@
class EncodedVideoChunkTest : public testing::Test {
public:
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ V8BufferSource* StringToBuffer(std::string data) {
+ return MakeGarbageCollected<V8BufferSource>(
+ DOMArrayBuffer::Create(data.data(), data.size()));
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ArrayBufferOrArrayBufferView StringToBuffer(std::string data) {
ArrayBufferOrArrayBufferView result;
result.SetArrayBuffer(DOMArrayBuffer::Create(data.data(), data.size()));
return result;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
std::string BufferToString(DOMArrayBuffer* buffer) {
return std::string(static_cast<char*>(buffer->Data()),
diff --git a/third_party/blink/renderer/modules/webcodecs/fuzzer_utils.cc b/third_party/blink/renderer/modules/webcodecs/fuzzer_utils.cc
index c633cab..fd5baa6 100644
--- a/third_party/blink/renderer/modules/webcodecs/fuzzer_utils.cc
+++ b/third_party/blink/renderer/modules/webcodecs/fuzzer_utils.cc
@@ -56,8 +56,12 @@
config->setCodec(proto.codec().c_str());
DOMArrayBuffer* data_copy = DOMArrayBuffer::Create(
proto.description().data(), proto.description().size());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ config->setDescription(MakeGarbageCollected<V8BufferSource>(data_copy));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
config->setDescription(
ArrayBufferOrArrayBufferView::FromArrayBuffer(data_copy));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return config;
}
@@ -70,8 +74,12 @@
DOMArrayBuffer* data_copy = DOMArrayBuffer::Create(
proto.description().data(), proto.description().size());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ config->setDescription(MakeGarbageCollected<V8BufferSource>(data_copy));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
config->setDescription(
ArrayBufferOrArrayBufferView::FromArrayBuffer(data_copy));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return config;
}
@@ -126,9 +134,14 @@
EncodedVideoChunk* MakeEncodedVideoChunk(
const wc_fuzzer::EncodedVideoChunk& proto) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* data = MakeGarbageCollected<V8BufferSource>(
+ DOMArrayBuffer::Create(proto.data().data(), proto.data().size()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ArrayBufferOrArrayBufferView data;
data.SetArrayBuffer(
DOMArrayBuffer::Create(proto.data().data(), proto.data().size()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* init = EncodedVideoChunkInit::Create();
init->setTimestamp(proto.timestamp());
@@ -140,9 +153,14 @@
EncodedAudioChunk* MakeEncodedAudioChunk(
const wc_fuzzer::EncodedAudioChunk& proto) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ auto* data = MakeGarbageCollected<V8BufferSource>(
+ DOMArrayBuffer::Create(proto.data().data(), proto.data().size()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ArrayBufferOrArrayBufferView data;
data.SetArrayBuffer(
DOMArrayBuffer::Create(proto.data().data(), proto.data().size()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* init = EncodedAudioChunkInit::Create();
init->setTimestamp(proto.timestamp());
diff --git a/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc b/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc
index 1eee849a..af778b0 100644
--- a/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc
+++ b/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc
@@ -19,6 +19,7 @@
#include "third_party/blink/renderer/modules/webcodecs/image_track_list.h"
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
+#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image_metrics.h"
@@ -122,7 +123,11 @@
// |data| is a required field.
DCHECK(init->hasData());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ DCHECK(init->data());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
DCHECK(!init->data().IsNull());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
constexpr char kNoneOption[] = "none";
auto color_behavior = ColorBehavior::Tag();
@@ -152,9 +157,22 @@
{base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
- if (init->data().IsReadableStream()) {
- if (init->data().GetAsReadableStream()->IsLocked() ||
- init->data().GetAsReadableStream()->IsDisturbed()) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->data()->IsReadableStream()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->data().IsReadableStream()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
+ if (
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->data()->GetAsReadableStream()->IsLocked() ||
+ init->data()->GetAsReadableStream()->IsDisturbed()
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->data().GetAsReadableStream()->IsLocked() ||
+ init->data().GetAsReadableStream()->IsDisturbed()
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ ) {
exception_state.ThrowTypeError(
"ImageDecoder can only accept readable streams that are not yet "
"locked to a reader");
@@ -166,8 +184,13 @@
/*data_complete=*/false, alpha_option, color_behavior, desired_size,
animation_option_);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ consumer_ = MakeGarbageCollected<ReadableStreamBytesConsumer>(
+ script_state, init->data()->GetAsReadableStream());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
consumer_ = MakeGarbageCollected<ReadableStreamBytesConsumer>(
script_state, init->data().GetAsReadableStream());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
construction_succeeded_ = true;
@@ -179,6 +202,19 @@
}
DOMArrayPiece buffer;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (init->data()->GetContentType()) {
+ case V8ImageBufferSource::ContentType::kArrayBuffer:
+ buffer = DOMArrayPiece(init->data()->GetAsArrayBuffer());
+ break;
+ case V8ImageBufferSource::ContentType::kArrayBufferView:
+ buffer = DOMArrayPiece(init->data()->GetAsArrayBufferView().Get());
+ break;
+ case V8ImageBufferSource::ContentType::kReadableStream:
+ NOTREACHED();
+ return;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (init->data().IsArrayBuffer()) {
buffer = DOMArrayPiece(init->data().GetAsArrayBuffer());
} else if (init->data().IsArrayBufferView()) {
@@ -187,6 +223,7 @@
NOTREACHED();
return;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (!buffer.ByteLength()) {
exception_state.ThrowDOMException(DOMExceptionCode::kConstraintError,
diff --git a/third_party/blink/renderer/modules/webcodecs/image_decoder_external_test.cc b/third_party/blink/renderer/modules/webcodecs/image_decoder_external_test.cc
index d752b66..6de6adb 100644
--- a/third_party/blink/renderer/modules/webcodecs/image_decoder_external_test.cc
+++ b/third_party/blink/renderer/modules/webcodecs/image_decoder_external_test.cc
@@ -45,8 +45,14 @@
auto data = ReadFile(file_name);
DCHECK(!data->IsEmpty()) << "Missing file: " << file_name;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(MakeGarbageCollected<
+ V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ DOMArrayBuffer::Create(std::move(data))));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(ArrayBufferOrArrayBufferViewOrReadableStream::FromArrayBuffer(
DOMArrayBuffer::Create(std::move(data))));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return ImageDecoderExternal::Create(v8_scope->GetScriptState(), init,
v8_scope->GetExceptionState());
}
@@ -119,8 +125,14 @@
auto* init = MakeGarbageCollected<ImageDecoderInit>();
init->setType("image/png");
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ DOMArrayBuffer::Create(SharedBuffer::Create())));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(ArrayBufferOrArrayBufferViewOrReadableStream::FromArrayBuffer(
DOMArrayBuffer::Create(SharedBuffer::Create())));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* decoder = ImageDecoderExternal::Create(v8_scope.GetScriptState(), init,
v8_scope.GetExceptionState());
EXPECT_FALSE(decoder);
@@ -134,8 +146,14 @@
auto* buffer = DOMArrayBuffer::Create(SharedBuffer::Create());
init->setType("image/png");
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ buffer));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromArrayBuffer(buffer));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ArrayBufferContents contents;
ASSERT_TRUE(buffer->Transfer(v8_scope.GetIsolate(), contents));
@@ -161,8 +179,14 @@
auto* buffer = DOMArrayBuffer::Create(std::move(data));
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ buffer));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromArrayBuffer(buffer));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* decoder = ImageDecoderExternal::Create(v8_scope.GetScriptState(), init,
v8_scope.GetExceptionState());
@@ -449,8 +473,14 @@
auto* init = MakeGarbageCollected<ImageDecoderInit>();
init->setType(kImageType);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ stream));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromReadableStream(stream));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Persistent<ImageDecoderExternal> decoder = ImageDecoderExternal::Create(
v8_scope.GetScriptState(), init, IGNORE_EXCEPTION_FOR_TESTING);
@@ -550,8 +580,14 @@
auto* init = MakeGarbageCollected<ImageDecoderInit>();
init->setType(kImageType);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ stream));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromReadableStream(stream));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Persistent<ImageDecoderExternal> decoder = ImageDecoderExternal::Create(
v8_scope.GetScriptState(), init, IGNORE_EXCEPTION_FOR_TESTING);
@@ -618,8 +654,14 @@
auto* init = MakeGarbageCollected<ImageDecoderInit>();
init->setType(kImageType);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ stream));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromReadableStream(stream));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Persistent<ImageDecoderExternal> decoder = ImageDecoderExternal::Create(
v8_scope.GetScriptState(), init, IGNORE_EXCEPTION_FOR_TESTING);
@@ -685,8 +727,14 @@
auto* array_buffer = DOMArrayBuffer::Create(128, 1);
ASSERT_TRUE(data->GetBytes(array_buffer->Data(), array_buffer->ByteLength()));
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ array_buffer));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(ArrayBufferOrArrayBufferViewOrReadableStream::FromArrayBuffer(
array_buffer));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* decoder = ImageDecoderExternal::Create(v8_scope.GetScriptState(), init,
v8_scope.GetExceptionState());
ASSERT_TRUE(decoder);
@@ -731,8 +779,14 @@
auto* init = MakeGarbageCollected<ImageDecoderInit>();
init->setType(kImageType);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ stream));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromReadableStream(stream));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Persistent<ImageDecoderExternal> decoder = ImageDecoderExternal::Create(
v8_scope.GetScriptState(), init, IGNORE_EXCEPTION_FOR_TESTING);
@@ -779,8 +833,14 @@
auto* init = MakeGarbageCollected<ImageDecoderInit>();
init->setType(kImageType);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setData(
+ MakeGarbageCollected<V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(
+ stream));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromReadableStream(stream));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
Persistent<ImageDecoderExternal> decoder = ImageDecoderExternal::Create(
v8_scope.GetScriptState(), init, IGNORE_EXCEPTION_FOR_TESTING);
diff --git a/third_party/blink/renderer/modules/webcodecs/image_decoder_fuzzer.cc b/third_party/blink/renderer/modules/webcodecs/image_decoder_fuzzer.cc
index a608974..e55e7fc 100644
--- a/third_party/blink/renderer/modules/webcodecs/image_decoder_fuzzer.cc
+++ b/third_party/blink/renderer/modules/webcodecs/image_decoder_fuzzer.cc
@@ -124,9 +124,15 @@
image_decoder_init->setType(proto.config().type().c_str());
Persistent<DOMArrayBuffer> data_copy = DOMArrayBuffer::Create(
proto.config().data().data(), proto.config().data().size());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ image_decoder_init->setData(
+ MakeGarbageCollected<
+ V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(data_copy));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
image_decoder_init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromArrayBuffer(
data_copy));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
image_decoder_init->setPremultiplyAlpha(
ToPremultiplyAlpha(proto.config().options().premultiply_alpha()));
image_decoder_init->setColorSpaceConversion(ToColorSpaceConversion(
@@ -161,9 +167,15 @@
ReadableStream::CreateWithCountQueueingStrategy(script_state,
underlying_source, 0);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ image_decoder_init->setData(
+ MakeGarbageCollected<
+ V8UnionArrayBufferOrArrayBufferViewOrReadableStream>(stream));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
image_decoder_init->setData(
ArrayBufferOrArrayBufferViewOrReadableStream::FromReadableStream(
stream));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
image_decoder = ImageDecoderExternal::Create(
script_state, image_decoder_init, IGNORE_EXCEPTION_FOR_TESTING);
image_decoder_init = nullptr;
diff --git a/third_party/blink/renderer/modules/webcodecs/parsed_read_into_options.cc b/third_party/blink/renderer/modules/webcodecs/parsed_read_into_options.cc
index 8506ebb..045f37e 100644
--- a/third_party/blink/renderer/modules/webcodecs/parsed_read_into_options.cc
+++ b/third_party/blink/renderer/modules/webcodecs/parsed_read_into_options.cc
@@ -7,9 +7,9 @@
#include <algorithm>
#include "base/numerics/checked_math.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_plane_layout.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame_read_into_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame_region.h"
-#include "third_party/blink/renderer/modules/webcodecs/plane_layout.h"
-#include "third_party/blink/renderer/modules/webcodecs/video_frame_read_into_options.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
diff --git a/third_party/blink/renderer/modules/webcodecs/video_decoder.cc b/third_party/blink/renderer/modules/webcodecs/video_decoder.cc
index d72f7c7..85f9c56 100644
--- a/third_party/blink/renderer/modules/webcodecs/video_decoder.cc
+++ b/third_party/blink/renderer/modules/webcodecs/video_decoder.cc
@@ -171,8 +171,12 @@
DOMArrayPiece buffer(config.description());
DOMArrayBuffer* buffer_copy =
DOMArrayBuffer::Create(buffer.Data(), buffer.ByteLength());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ copy->setDescription(MakeGarbageCollected<V8BufferSource>(buffer_copy));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
copy->setDescription(
ArrayBufferOrArrayBufferView::FromArrayBuffer(buffer_copy));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
if (config.hasCodedWidth())
diff --git a/third_party/blink/renderer/modules/webcodecs/video_encoder.cc b/third_party/blink/renderer/modules/webcodecs/video_encoder.cc
index fa6380f..6d441ce 100644
--- a/third_party/blink/renderer/modules/webcodecs/video_encoder.cc
+++ b/third_party/blink/renderer/modules/webcodecs/video_encoder.cc
@@ -331,7 +331,7 @@
if (config.hasHardwareAcceleration())
result->setHardwareAcceleration(config.hardwareAcceleration());
- if (config.hasAvc() && config.avc()->format()) {
+ if (config.hasAvc() && config.avc()->hasFormat()) {
auto* avc = AvcEncoderConfig::Create();
avc->setFormat(config.avc()->format());
result->setAvc(avc);
@@ -718,8 +718,13 @@
if (codec_desc.has_value()) {
auto* desc_array_buf = DOMArrayBuffer::Create(codec_desc.value().data(),
codec_desc.value().size());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ decoder_config->setDescription(
+ MakeGarbageCollected<V8BufferSource>(desc_array_buf));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
decoder_config->setDescription(
ArrayBufferOrArrayBufferView::FromArrayBuffer(desc_array_buf));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
metadata->setDecoderConfig(decoder_config);
}
diff --git a/third_party/blink/renderer/modules/webcodecs/video_frame.cc b/third_party/blink/renderer/modules/webcodecs/video_frame.cc
index 7ecbe71..d97b1eb 100644
--- a/third_party/blink/renderer/modules/webcodecs/video_frame.cc
+++ b/third_party/blink/renderer/modules/webcodecs/video_frame.cc
@@ -18,6 +18,7 @@
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_plane_init.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_plane_layout.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_cssimagevalue_htmlcanvaselement_htmlimageelement_htmlvideoelement_imagebitmap_offscreencanvas_svgimageelement_videoframe.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame_plane_init.h"
@@ -29,7 +30,6 @@
#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
#include "third_party/blink/renderer/modules/canvas/imagebitmap/image_bitmap_factories.h"
#include "third_party/blink/renderer/modules/webcodecs/parsed_read_into_options.h"
-#include "third_party/blink/renderer/modules/webcodecs/plane_layout.h"
#include "third_party/blink/renderer/modules/webcodecs/webcodecs_logger.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
@@ -546,7 +546,7 @@
DOMExceptionCode::kConstraintError,
String::Format("Invalid number of planes for format %s; expected %zu, "
"received %u.",
- init->format().Ascii().c_str(),
+ IDLEnumAsString(init->format()).Ascii().c_str(),
media::VideoFrame::NumPlanes(media_fmt), planes.size()));
return nullptr;
}
diff --git a/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc b/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc
index b1444ea..ed60c55 100644
--- a/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc
+++ b/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc
@@ -15,7 +15,6 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_programmable_stage.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_doublesequence_gpucolordict.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_gpuextent3ddict_unsignedlongenforcerangesequence.h"
-#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_texture.h"
@@ -59,7 +58,7 @@
return WGPUColor{};
}
-WGPUExtent3D AsDawnType(const V8GPUExtent3D* webgpu_extent, GPUDevice* device) {
+WGPUExtent3D AsDawnType(const V8GPUExtent3D* webgpu_extent) {
DCHECK(webgpu_extent);
// Set all extents to their default value of 1.
@@ -108,6 +107,50 @@
return dawn_extent;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
+WGPUOrigin3D AsDawnType(const V8GPUOrigin3D* webgpu_origin) {
+ DCHECK(webgpu_origin);
+
+ WGPUOrigin3D dawn_origin = {0, 0, 0};
+
+ switch (webgpu_origin->GetContentType()) {
+ case V8GPUOrigin3D::ContentType::kGPUOrigin3DDict: {
+ const GPUOrigin3DDict* webgpu_origin_3d_dict =
+ webgpu_origin->GetAsGPUOrigin3DDict();
+ dawn_origin.x = webgpu_origin_3d_dict->x();
+ dawn_origin.y = webgpu_origin_3d_dict->y();
+ dawn_origin.z = webgpu_origin_3d_dict->z();
+ break;
+ }
+ case V8GPUOrigin3D::ContentType::kUnsignedLongEnforceRangeSequence: {
+ const Vector<uint32_t>& webgpu_origin_sequence =
+ webgpu_origin->GetAsUnsignedLongEnforceRangeSequence();
+
+ // The WebGPU spec states that if the sequence isn't big enough then the
+ // default values of 0 are used (which are set above).
+ switch (webgpu_origin_sequence.size()) {
+ default:
+ dawn_origin.z = webgpu_origin_sequence[2];
+ FALLTHROUGH;
+ case 2:
+ dawn_origin.y = webgpu_origin_sequence[1];
+ FALLTHROUGH;
+ case 1:
+ dawn_origin.x = webgpu_origin_sequence[0];
+ FALLTHROUGH;
+ case 0:
+ break;
+ }
+ break;
+ }
+ }
+
+ return dawn_origin;
+}
+
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
WGPUExtent3D AsDawnType(
const UnsignedLongEnforceRangeSequenceOrGPUExtent3DDict* webgpu_extent,
GPUDevice* device) {
@@ -197,6 +240,8 @@
return dawn_origin;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
WGPUTextureCopyView AsDawnType(const GPUImageCopyTexture* webgpu_view,
GPUDevice* device) {
DCHECK(webgpu_view);
@@ -205,7 +250,11 @@
WGPUTextureCopyView dawn_view = {};
dawn_view.texture = webgpu_view->texture()->GetHandle();
dawn_view.mipLevel = webgpu_view->mipLevel();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ dawn_view.origin = AsDawnType(webgpu_view->origin());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_view.origin = AsDawnType(&webgpu_view->origin());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_view.aspect = AsDawnEnum<WGPUTextureAspect>(webgpu_view->aspect());
return dawn_view;
diff --git a/third_party/blink/renderer/modules/webgpu/dawn_conversions.h b/third_party/blink/renderer/modules/webgpu/dawn_conversions.h
index 7d1f776..5434011 100644
--- a/third_party/blink/renderer/modules/webgpu/dawn_conversions.h
+++ b/third_party/blink/renderer/modules/webgpu/dawn_conversions.h
@@ -34,13 +34,16 @@
WGPUColor AsDawnColor(const Vector<double>&);
WGPUColor AsDawnType(const GPUColorDict*);
WGPUColor AsDawnType(const V8GPUColor* webgpu_color);
-WGPUExtent3D AsDawnType(const V8GPUExtent3D* webgpu_extent, GPUDevice* device);
-// TODO(
crbug.com/1181288): Remove the old IDL union version.
+WGPUExtent3D AsDawnType(const V8GPUExtent3D* webgpu_extent);
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+WGPUOrigin3D AsDawnType(const V8GPUOrigin3D* webgpu_extent);
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
WGPUExtent3D AsDawnType(
const UnsignedLongEnforceRangeSequenceOrGPUExtent3DDict*,
GPUDevice* device);
WGPUOrigin3D AsDawnType(
const UnsignedLongEnforceRangeSequenceOrGPUOrigin3DDict*);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
WGPUTextureCopyView AsDawnType(const GPUImageCopyTexture* webgpu_view,
GPUDevice* device);
const char* ValidateTextureDataLayout(const GPUImageDataLayout* webgpu_layout,
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc b/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc
index c329580..9f6d0560 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc
@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_bind_group_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_bind_group_entry.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_buffer_binding.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
@@ -21,6 +22,26 @@
dawn_binding.binding = webgpu_binding->binding();
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (webgpu_binding->resource()->GetContentType()) {
+ case V8GPUBindingResource::ContentType::kGPUBufferBinding: {
+ GPUBufferBinding* buffer =
+ webgpu_binding->resource()->GetAsGPUBufferBinding();
+ dawn_binding.offset = buffer->offset();
+ dawn_binding.size = buffer->hasSize() ? buffer->size() : WGPU_WHOLE_SIZE;
+ dawn_binding.buffer = AsDawnType(buffer->buffer());
+ break;
+ }
+ case V8GPUBindingResource::ContentType::kGPUSampler:
+ dawn_binding.sampler =
+ AsDawnType(webgpu_binding->resource()->GetAsGPUSampler());
+ break;
+ case V8GPUBindingResource::ContentType::kGPUTextureView:
+ dawn_binding.textureView =
+ AsDawnType(webgpu_binding->resource()->GetAsGPUTextureView());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (webgpu_binding->resource().IsGPUBufferBinding()) {
GPUBufferBinding* buffer =
webgpu_binding->resource().GetAsGPUBufferBinding();
@@ -40,6 +61,7 @@
} else {
NOTREACHED();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
return dawn_binding;
}
@@ -72,7 +94,8 @@
GPUBindGroup* bind_group = MakeGarbageCollected<GPUBindGroup>(
device, device->GetProcs().deviceCreateBindGroup(device->GetHandle(),
&dawn_desc));
- bind_group->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ bind_group->setLabel(webgpu_desc->label());
return bind_group;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.cc b/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.cc
index f755b45..cb62791 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.cc
@@ -102,7 +102,8 @@
GPUBindGroupLayout* layout = MakeGarbageCollected<GPUBindGroupLayout>(
device, device->GetProcs().deviceCreateBindGroupLayout(
device->GetHandle(), &dawn_desc));
- layout->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ layout->setLabel(webgpu_desc->label());
return layout;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc b/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc
index 16aeac0..4cf2fd74 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc
@@ -73,7 +73,8 @@
GPUBuffer* buffer = MakeGarbageCollected<GPUBuffer>(
device, dawn_desc.size,
device->GetProcs().deviceCreateBuffer(device->GetHandle(), &dawn_desc));
- buffer->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ buffer->setLabel(webgpu_desc->label());
return buffer;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc b/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
index f067687..3396967 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
@@ -198,8 +198,12 @@
// deprecated behavior of resizing to match the canvas size each frame.
size = IntSize(-1, -1);
} else if (descriptor->hasSize()) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ WGPUExtent3D dawn_extent = AsDawnType(descriptor->size());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
WGPUExtent3D dawn_extent =
AsDawnType(&descriptor->size(), descriptor->device());
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
size = IntSize(dawn_extent.width, dawn_extent.height);
if (dawn_extent.depthOrArrayLayers != 1) {
@@ -215,7 +219,8 @@
swapchain_ = MakeGarbageCollected<GPUSwapChain>(
this, descriptor->device(), usage, format, filter_quality_, size);
swapchain_->CcLayer()->SetContentsOpaque(!CreationAttributes().alpha);
- swapchain_->setLabel(descriptor->label());
+ if (descriptor->hasLabel())
+ swapchain_->setLabel(descriptor->label());
// If we don't notify the host that something has changed it may never check
// for the new cc::Layer.
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc
index 32eedb7..69cb4a5 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc
@@ -36,10 +36,28 @@
// Deprecated path
dawn_desc.view = webgpu_desc->attachment()->GetHandle();
}
- dawn_desc.resolveTarget = webgpu_desc->resolveTarget()
+ dawn_desc.resolveTarget = webgpu_desc->hasResolveTarget()
? webgpu_desc->resolveTarget()->GetHandle()
: nullptr;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (webgpu_desc->loadValue()->GetContentType()) {
+ case V8UnionGPUColorOrGPULoadOp::ContentType::kGPULoadOp:
+ dawn_desc.loadOp =
+ AsDawnEnum<WGPULoadOp>(webgpu_desc->loadValue()->GetAsGPULoadOp());
+ break;
+ case V8UnionGPUColorOrGPULoadOp::ContentType::kGPUColorDict:
+ dawn_desc.loadOp = WGPULoadOp_Clear;
+ dawn_desc.clearColor =
+ AsDawnType(webgpu_desc->loadValue()->GetAsGPUColorDict());
+ break;
+ case V8UnionGPUColorOrGPULoadOp::ContentType::kDoubleSequence:
+ dawn_desc.loadOp = WGPULoadOp_Clear;
+ dawn_desc.clearColor =
+ AsDawnColor(webgpu_desc->loadValue()->GetAsDoubleSequence());
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (webgpu_desc->loadValue().IsGPULoadOp()) {
const WTF::String& gpuLoadOp = webgpu_desc->loadValue().GetAsGPULoadOp();
dawn_desc.loadOp = AsDawnEnum<WGPULoadOp>(gpuLoadOp);
@@ -58,8 +76,10 @@
} else {
NOTREACHED();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
- dawn_desc.storeOp = AsDawnEnum<WGPUStoreOp>(webgpu_desc->storeOp());
+ if (webgpu_desc->hasStoreOp())
+ dawn_desc.storeOp = AsDawnEnum<WGPUStoreOp>(webgpu_desc->storeOp());
return dawn_desc;
}
@@ -78,6 +98,19 @@
dawn_desc.view = webgpu_desc->attachment()->GetHandle();
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (webgpu_desc->depthLoadValue()->GetContentType()) {
+ case V8UnionFloatOrGPULoadOp::ContentType::kGPULoadOp:
+ dawn_desc.depthLoadOp = AsDawnEnum<WGPULoadOp>(
+ webgpu_desc->depthLoadValue()->GetAsGPULoadOp());
+ dawn_desc.clearDepth = 1.0f;
+ break;
+ case V8UnionFloatOrGPULoadOp::ContentType::kFloat:
+ dawn_desc.depthLoadOp = WGPULoadOp_Clear;
+ dawn_desc.clearDepth = webgpu_desc->depthLoadValue()->GetAsFloat();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (webgpu_desc->depthLoadValue().IsGPULoadOp()) {
const WTF::String& gpuLoadOp =
webgpu_desc->depthLoadValue().GetAsGPULoadOp();
@@ -91,9 +124,24 @@
} else {
NOTREACHED();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_desc.depthStoreOp = AsDawnEnum<WGPUStoreOp>(webgpu_desc->depthStoreOp());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ switch (webgpu_desc->stencilLoadValue()->GetContentType()) {
+ case V8UnionGPULoadOpOrGPUStencilValue::ContentType::kGPULoadOp:
+ dawn_desc.stencilLoadOp = AsDawnEnum<WGPULoadOp>(
+ webgpu_desc->stencilLoadValue()->GetAsGPULoadOp());
+ dawn_desc.clearStencil = 0;
+ break;
+ case V8UnionGPULoadOpOrGPUStencilValue::ContentType::kV8GPUStencilValue:
+ dawn_desc.stencilLoadOp = WGPULoadOp_Clear;
+ dawn_desc.clearStencil =
+ webgpu_desc->stencilLoadValue()->GetAsV8GPUStencilValue();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (webgpu_desc->stencilLoadValue().IsGPULoadOp()) {
const WTF::String& gpuLoadOp =
webgpu_desc->stencilLoadValue().GetAsGPULoadOp();
@@ -108,6 +156,7 @@
} else {
NOTREACHED();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_desc.stencilStoreOp =
AsDawnEnum<WGPUStoreOp>(webgpu_desc->stencilStoreOp());
@@ -153,20 +202,15 @@
const GPUCommandEncoderDescriptor* webgpu_desc) {
DCHECK(device);
DCHECK(webgpu_desc);
- ALLOW_UNUSED_LOCAL(webgpu_desc);
std::string label;
- WGPUCommandEncoderDescriptor dawn_desc = {};
- const WGPUCommandEncoderDescriptor* dawn_desc_ptr = nullptr;
- if (webgpu_desc) {
- dawn_desc = AsDawnType(webgpu_desc, &label);
- dawn_desc_ptr = &dawn_desc;
- }
+ WGPUCommandEncoderDescriptor dawn_desc = AsDawnType(webgpu_desc, &label);
GPUCommandEncoder* encoder = MakeGarbageCollected<GPUCommandEncoder>(
device, device->GetProcs().deviceCreateCommandEncoder(device->GetHandle(),
- dawn_desc_ptr));
- encoder->setLabel(webgpu_desc->label());
+ &dawn_desc));
+ if (webgpu_desc->hasLabel())
+ encoder->setLabel(webgpu_desc->label());
return encoder;
}
@@ -199,6 +243,13 @@
return nullptr;
}
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ if (color_attachment->loadValue()->IsDoubleSequence() &&
+ color_attachment->loadValue()->GetAsDoubleSequence().size() != 4) {
+ exception_state.ThrowRangeError("loadValue color size must be 4");
+ return nullptr;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const GPULoadOpOrDoubleSequenceOrGPUColorDict load_value =
color_attachment->loadValue();
@@ -207,6 +258,7 @@
exception_state.ThrowRangeError("loadValue color size must be 4");
return nullptr;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
std::string label;
@@ -251,7 +303,8 @@
GPURenderPassEncoder* encoder = MakeGarbageCollected<GPURenderPassEncoder>(
device_,
GetProcs().commandEncoderBeginRenderPass(GetHandle(), &dawn_desc));
- encoder->setLabel(descriptor->label());
+ if (descriptor->hasLabel())
+ encoder->setLabel(descriptor->label());
return encoder;
}
@@ -267,14 +320,15 @@
GPUComputePassEncoder* encoder = MakeGarbageCollected<GPUComputePassEncoder>(
device_,
GetProcs().commandEncoderBeginComputePass(GetHandle(), &dawn_desc));
- encoder->setLabel(descriptor->label());
+ if (descriptor->hasLabel())
+ encoder->setLabel(descriptor->label());
return encoder;
}
void GPUCommandEncoder::copyBufferToTexture(GPUImageCopyBuffer* source,
GPUImageCopyTexture* destination,
const V8GPUExtent3D* copy_size) {
- WGPUExtent3D dawn_copy_size = AsDawnType(copy_size, device_);
+ WGPUExtent3D dawn_copy_size = AsDawnType(copy_size);
WGPUTextureCopyView dawn_destination = AsDawnType(destination, device_);
const char* error = nullptr;
@@ -292,7 +346,7 @@
void GPUCommandEncoder::copyTextureToBuffer(GPUImageCopyTexture* source,
GPUImageCopyBuffer* destination,
const V8GPUExtent3D* copy_size) {
- WGPUExtent3D dawn_copy_size = AsDawnType(copy_size, device_);
+ WGPUExtent3D dawn_copy_size = AsDawnType(copy_size);
WGPUTextureCopyView dawn_source = AsDawnType(source, device_);
const char* error = nullptr;
@@ -312,7 +366,7 @@
const V8GPUExtent3D* copy_size) {
WGPUTextureCopyView dawn_source = AsDawnType(source, device_);
WGPUTextureCopyView dawn_destination = AsDawnType(destination, device_);
- WGPUExtent3D dawn_copy_size = AsDawnType(copy_size, device_);
+ WGPUExtent3D dawn_copy_size = AsDawnType(copy_size);
GetProcs().commandEncoderCopyTextureToTexture(
GetHandle(), &dawn_source, &dawn_destination, &dawn_copy_size);
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.cc b/third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.cc
index 39ad724..6389af91 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.cc
@@ -60,7 +60,8 @@
GPUComputePipeline* pipeline = MakeGarbageCollected<GPUComputePipeline>(
device, device->GetProcs().deviceCreateComputePipeline(
device->GetHandle(), &dawn_desc));
- pipeline->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ pipeline->setLabel(webgpu_desc->label());
return pipeline;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_device.cc b/third_party/blink/renderer/modules/webgpu/gpu_device.cc
index e44e2b2..b714267 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_device.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_device.cc
@@ -98,7 +98,8 @@
lost_callback_->UnboundCallback(),
lost_callback_->AsUserdata());
- setLabel(descriptor->label());
+ if (descriptor->hasLabel())
+ setLabel(descriptor->label());
}
void GPUDevice::InjectError(WGPUErrorType type, const char* message) {
@@ -134,14 +135,26 @@
GPUUncapturedErrorEventInit* init = GPUUncapturedErrorEventInit::Create();
if (errorType == WGPUErrorType_Validation) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setError(
+ MakeGarbageCollected<V8UnionGPUOutOfMemoryErrorOrGPUValidationError>(
+ MakeGarbageCollected<GPUValidationError>(message)));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto* error = MakeGarbageCollected<GPUValidationError>(message);
init->setError(
GPUOutOfMemoryErrorOrGPUValidationError::FromGPUValidationError(error));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} else if (errorType == WGPUErrorType_OutOfMemory) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ init->setError(
+ MakeGarbageCollected<V8UnionGPUOutOfMemoryErrorOrGPUValidationError>(
+ GPUOutOfMemoryError::Create()));
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
GPUOutOfMemoryError* error = GPUOutOfMemoryError::Create();
init->setError(
GPUOutOfMemoryErrorOrGPUValidationError::FromGPUOutOfMemoryError(
error));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
} else {
return;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.cc b/third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.cc
index dace784..4c8ee81 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.cc
@@ -38,7 +38,8 @@
GPUPipelineLayout* layout = MakeGarbageCollected<GPUPipelineLayout>(
device, device->GetProcs().deviceCreatePipelineLayout(device->GetHandle(),
&dawn_desc));
- layout->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ layout->setLabel(webgpu_desc->label());
return layout;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_query_set.cc b/third_party/blink/renderer/modules/webgpu/gpu_query_set.cc
index afdd9bf80..69b18ff 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_query_set.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_query_set.cc
@@ -40,7 +40,8 @@
GPUQuerySet* query_set = MakeGarbageCollected<GPUQuerySet>(
device,
device->GetProcs().deviceCreateQuerySet(device->GetHandle(), &dawn_desc));
- query_set->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ query_set->setLabel(webgpu_desc->label());
return query_set;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_queue.cc b/third_party/blink/renderer/modules/webgpu/gpu_queue.cc
index 7bea16c..ecf907f 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_queue.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_queue.cc
@@ -13,8 +13,12 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_external_image.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_image_bitmap.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_image_copy_texture.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_origin_2d_dict.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
+#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h"
+#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
+#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
@@ -29,6 +33,47 @@
namespace {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+WGPUOrigin3D GPUOrigin2DToWGPUOrigin3D(const V8GPUOrigin2D* webgpu_origin) {
+ DCHECK(webgpu_origin);
+
+ WGPUOrigin3D dawn_origin = {
+ 0,
+ 0,
+ 0,
+ };
+
+ switch (webgpu_origin->GetContentType()) {
+ case V8GPUOrigin2D::ContentType::kGPUOrigin2DDict: {
+ const GPUOrigin2DDict* webgpu_origin_2d_dict =
+ webgpu_origin->GetAsGPUOrigin2DDict();
+ dawn_origin.x = webgpu_origin_2d_dict->x();
+ dawn_origin.y = webgpu_origin_2d_dict->y();
+ break;
+ }
+ case V8GPUOrigin2D::ContentType::kUnsignedLongEnforceRangeSequence: {
+ const Vector<uint32_t>& webgpu_origin_sequence =
+ webgpu_origin->GetAsUnsignedLongEnforceRangeSequence();
+ // The WebGPU spec states that if the sequence isn't big enough then the
+ // default values of 0 are used (which are set above).
+ switch (webgpu_origin_sequence.size()) {
+ default:
+ // This is a 2D origin and the depth should be 0 always.
+ dawn_origin.y = webgpu_origin_sequence[1];
+ FALLTHROUGH;
+ case 1:
+ dawn_origin.x = webgpu_origin_sequence[0];
+ FALLTHROUGH;
+ case 0:
+ break;
+ }
+ break;
+ }
+ }
+
+ return dawn_origin;
+}
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
WGPUOrigin3D GPUOrigin2DToWGPUOrigin3D(
const UnsignedLongEnforceRangeSequenceOrGPUOrigin2DDict* webgpu_origin) {
DCHECK(webgpu_origin);
@@ -66,6 +111,7 @@
return dawn_origin;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
bool IsValidExternalImageDestinationFormat(
WGPUTextureFormat dawn_texture_format) {
@@ -129,9 +175,33 @@
}
scoped_refptr<Image> GetImageFromExternalImage(
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const V8UnionHTMLCanvasElementOrImageBitmapOrOffscreenCanvas*
+ external_image,
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas& external_image,
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
ExceptionState& exception_state) {
CanvasImageSource* source = nullptr;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ CanvasRenderingContextHost* canvas = nullptr;
+ switch (external_image->GetContentType()) {
+ case V8UnionHTMLCanvasElementOrImageBitmapOrOffscreenCanvas::ContentType::
+ kHTMLCanvasElement:
+ source = external_image->GetAsHTMLCanvasElement();
+ canvas = external_image->GetAsHTMLCanvasElement();
+ break;
+ case V8UnionHTMLCanvasElementOrImageBitmapOrOffscreenCanvas::ContentType::
+ kImageBitmap:
+ source = external_image->GetAsImageBitmap();
+ break;
+ case V8UnionHTMLCanvasElementOrImageBitmapOrOffscreenCanvas::ContentType::
+ kOffscreenCanvas:
+ source = external_image->GetAsOffscreenCanvas();
+ canvas = external_image->GetAsOffscreenCanvas();
+ break;
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (external_image.IsImageBitmap()) {
source = external_image.GetAsImageBitmap();
} else {
@@ -155,6 +225,18 @@
}
source = canvas;
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ // The rendering context is 2d or webgl/webgl2.
+ if (canvas && !(canvas->Is3d() || canvas->IsRenderingContext2D())) {
+ exception_state.ThrowDOMException(
+ DOMExceptionCode::kOperationError,
+ "CopyExternalImageToTexture doesn't support canvas without 2d, webgl "
+ "or webgl2 conext");
+ return nullptr;
+ }
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// Neutered external image.
if (source->IsNeutered()) {
@@ -195,7 +277,7 @@
return image;
}
-} // anonymous namespace
+} // namespace
GPUQueue::GPUQueue(GPUDevice* device, WGPUQueue queue)
: DawnObject<WGPUQueue>(device, queue) {
@@ -368,7 +450,7 @@
GPUImageDataLayout* data_layout,
const V8GPUExtent3D* write_size,
ExceptionState& exception_state) {
- WGPUExtent3D dawn_write_size = AsDawnType(write_size, device_);
+ WGPUExtent3D dawn_write_size = AsDawnType(write_size);
WGPUTextureCopyView dawn_destination = AsDawnType(destination, device_);
WGPUTextureDataLayout dawn_data_layout = {};
@@ -405,11 +487,16 @@
// TODO(
crbug.com/1197369): Extract alpha info and config the following
// CopyContentFromCPU() and CopyContentFromGPU().
- WGPUExtent3D dawn_copy_size = AsDawnType(copy_size, device_);
+ WGPUExtent3D dawn_copy_size = AsDawnType(copy_size);
// Extract source origin
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ WGPUOrigin3D origin_in_external_image =
+ GPUOrigin2DToWGPUOrigin3D(copyImage->origin());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
WGPUOrigin3D origin_in_external_image =
GPUOrigin2DToWGPUOrigin3D(&(copyImage->origin()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// Validate origin value
const bool copyRectOutOfBounds =
@@ -528,11 +615,16 @@
// appropriate format. Now only support texture format exactly the same. The
// compatible formats need to be defined in WebGPU spec.
- WGPUExtent3D dawn_copy_size = AsDawnType(copy_size, device_);
+ WGPUExtent3D dawn_copy_size = AsDawnType(copy_size);
// Extract imageBitmap attributes
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ WGPUOrigin3D origin_in_image_bitmap =
+ GPUOrigin2DToWGPUOrigin3D(source->origin());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
WGPUOrigin3D origin_in_image_bitmap =
GPUOrigin2DToWGPUOrigin3D(&(source->origin()));
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
// Validate copy depth
if (dawn_copy_size.depthOrArrayLayers > 1) {
@@ -579,7 +671,7 @@
exception_state.ThrowTypeError("Failed to copy content from imageBitmap.");
return;
}
-} // namespace blink
+}
bool GPUQueue::CopyContentFromCPU(StaticBitmapImage* image,
const WGPUOrigin3D& origin,
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.cc b/third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.cc
index cde508d..5221cc3 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.cc
@@ -48,7 +48,8 @@
MakeGarbageCollected<GPURenderBundleEncoder>(
device, device->GetProcs().deviceCreateRenderBundleEncoder(
device->GetHandle(), &dawn_desc));
- encoder->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ encoder->setLabel(webgpu_desc->label());
return encoder;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.cc b/third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.cc
index 367a9cf..8835c91 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.cc
@@ -126,8 +126,10 @@
dawn_state->dawn_desc.nextInChain = nullptr;
dawn_state->dawn_desc.topology =
AsDawnEnum<WGPUPrimitiveTopology>(webgpu_desc->topology());
- dawn_state->dawn_desc.stripIndexFormat =
- AsDawnEnum<WGPUIndexFormat>(webgpu_desc->stripIndexFormat());
+ if (webgpu_desc->hasStripIndexFormat()) {
+ dawn_state->dawn_desc.stripIndexFormat =
+ AsDawnEnum<WGPUIndexFormat>(webgpu_desc->stripIndexFormat());
+ }
dawn_state->dawn_desc.frontFace =
AsDawnEnum<WGPUFrontFace>(webgpu_desc->frontFace());
dawn_state->dawn_desc.cullMode =
@@ -136,7 +138,12 @@
if (webgpu_desc->hasClampDepth()) {
auto* clamp_state = &dawn_state->depth_clamping_state;
clamp_state->chain.sType = WGPUSType_PrimitiveDepthClampingState;
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ clamp_state->clampDepth = webgpu_desc->clampDepth().has_value() &&
+ webgpu_desc->clampDepth().value();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
clamp_state->clampDepth = webgpu_desc->clampDepth();
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_state->dawn_desc.nextInChain =
reinterpret_cast<WGPUChainedStruct*>(clamp_state);
}
@@ -375,7 +382,8 @@
pipeline = MakeGarbageCollected<GPURenderPipeline>(
device, device->GetProcs().deviceCreateRenderPipeline2(
device->GetHandle(), &dawn_desc_info.dawn_desc));
- pipeline->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ pipeline->setLabel(webgpu_desc->label());
return pipeline;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_sampler.cc b/third_party/blink/renderer/modules/webgpu/gpu_sampler.cc
index aebb8e6..785ad6d 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_sampler.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_sampler.cc
@@ -55,7 +55,8 @@
GPUSampler* sampler = MakeGarbageCollected<GPUSampler>(
device,
device->GetProcs().deviceCreateSampler(device->GetHandle(), &dawn_desc));
- sampler->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ sampler->setLabel(webgpu_desc->label());
return sampler;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_shader_module.cc b/third_party/blink/renderer/modules/webgpu/gpu_shader_module.cc
index 2c448a2..09bbd66 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_shader_module.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_shader_module.cc
@@ -32,6 +32,34 @@
std::string label;
WGPUShaderModuleDescriptor dawn_desc = {};
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ const auto* wgsl_or_spirv = webgpu_desc->code();
+ switch (wgsl_or_spirv->GetContentType()) {
+ case V8UnionUSVStringOrUint32Array::ContentType::kUSVString: {
+ wgsl_code = wgsl_or_spirv->GetAsUSVString().Utf8();
+ wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
+ wgsl_desc.source = wgsl_code.c_str();
+ dawn_desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
+ break;
+ }
+ case V8UnionUSVStringOrUint32Array::ContentType::kUint32Array: {
+ NotShared<DOMUint32Array> code = wgsl_or_spirv->GetAsUint32Array();
+ uint32_t length_words = 0;
+ if (!base::CheckedNumeric<uint32_t>(code->length())
+ .AssignIfValid(&length_words)) {
+ exception_state.ThrowRangeError(
+ "The provided ArrayBuffer exceeds the maximum supported size "
+ "(4294967295)");
+ return nullptr;
+ }
+ spirv_desc.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor;
+ spirv_desc.code = code->Data();
+ spirv_desc.codeSize = length_words;
+ dawn_desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&spirv_desc);
+ break;
+ }
+ }
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
auto wgsl_or_spirv = webgpu_desc->code();
if (wgsl_or_spirv.IsUSVString()) {
wgsl_code = wgsl_or_spirv.GetAsUSVString().Utf8();
@@ -57,6 +85,7 @@
spirv_desc.codeSize = length_words;
dawn_desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&spirv_desc);
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
if (webgpu_desc->hasLabel()) {
label = webgpu_desc->label().Utf8();
@@ -66,7 +95,8 @@
GPUShaderModule* shader = MakeGarbageCollected<GPUShaderModule>(
device, device->GetProcs().deviceCreateShaderModule(device->GetHandle(),
&dawn_desc));
- shader->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ shader->setLabel(webgpu_desc->label());
return shader;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_texture.cc b/third_party/blink/renderer/modules/webgpu/gpu_texture.cc
index f5cb122..93d0ae7 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_texture.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_texture.cc
@@ -38,7 +38,11 @@
dawn_desc.usage = static_cast<WGPUTextureUsage>(webgpu_desc->usage());
dawn_desc.dimension =
AsDawnEnum<WGPUTextureDimension>(webgpu_desc->dimension());
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ dawn_desc.size = AsDawnType(webgpu_desc->size());
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_desc.size = AsDawnType(&webgpu_desc->size(), device);
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
dawn_desc.format = AsDawnEnum<WGPUTextureFormat>(webgpu_desc->format());
dawn_desc.mipLevelCount = webgpu_desc->mipLevelCount();
dawn_desc.sampleCount = webgpu_desc->sampleCount();
@@ -59,9 +63,13 @@
WGPUTextureViewDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
- dawn_desc.format = AsDawnEnum<WGPUTextureFormat>(webgpu_desc->format());
- dawn_desc.dimension =
- AsDawnEnum<WGPUTextureViewDimension>(webgpu_desc->dimension());
+ if (webgpu_desc->hasFormat()) {
+ dawn_desc.format = AsDawnEnum<WGPUTextureFormat>(webgpu_desc->format());
+ }
+ if (webgpu_desc->hasDimension()) {
+ dawn_desc.dimension =
+ AsDawnEnum<WGPUTextureViewDimension>(webgpu_desc->dimension());
+ }
dawn_desc.baseMipLevel = webgpu_desc->baseMipLevel();
dawn_desc.mipLevelCount = webgpu_desc->mipLevelCount();
dawn_desc.baseArrayLayer = webgpu_desc->baseArrayLayer();
@@ -112,7 +120,8 @@
device,
device->GetProcs().deviceCreateTexture(device->GetHandle(), &dawn_desc),
dawn_desc.format, static_cast<WGPUTextureUsage>(dawn_desc.usage));
- texture->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ texture->setLabel(webgpu_desc->label());
return texture;
}
@@ -329,7 +338,8 @@
WGPUTextureViewDescriptor dawn_desc = AsDawnType(webgpu_desc, &label);
GPUTextureView* view = MakeGarbageCollected<GPUTextureView>(
device_, GetProcs().textureCreateView(GetHandle(), &dawn_desc));
- view->setLabel(webgpu_desc->label());
+ if (webgpu_desc->hasLabel())
+ view->setLabel(webgpu_desc->label());
return view;
}
diff --git a/third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event.cc b/third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event.cc
index 832ef8e..c2921c8 100644
--- a/third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event.cc
+++ b/third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event.cc
@@ -21,6 +21,9 @@
const AtomicString& type,
const GPUUncapturedErrorEventInit* gpuUncapturedErrorEventInitDict)
: Event(type, Bubbles::kNo, Cancelable::kYes) {
+#if defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
+ error_ = gpuUncapturedErrorEventInitDict->error();
+#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
const auto& old_union = gpuUncapturedErrorEventInitDict->error();
if (old_union.IsGPUOutOfMemoryError()) {
error_ =
@@ -31,6 +34,7 @@
} else {
NOTREACHED();
}
+#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_DICTIONARY)
}
void GPUUncapturedErrorEvent::Trace(Visitor* visitor) const {