Skip to content

Commit

Permalink
bind-gen: Clean up temporary migration of IDL union (core/)
Browse files Browse the repository at this point in the history
Removes use cases of the old IDL unions in core/, as a clean-up
of https://crrev.com/c/2726012

Bug: 839389
Change-Id: Iccb3ce0c7f262d0636052d8f4907bb8c97451222
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2907012
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#885578}
  • Loading branch information
yuki3 authored and Chromium LUCI CQ committed May 21, 2021
1 parent c8a846a commit b8d8ee6
Show file tree
Hide file tree
Showing 170 changed files with 44 additions and 3,772 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include "third_party/blink/renderer/bindings/core/v8/v8_html_all_collection.h"

#include "third_party/blink/renderer/bindings/core/v8/html_collection_or_element.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_element_htmlcollection.h"
#include "third_party/blink/renderer/platform/bindings/v8_set_return_value.h"
Expand Down Expand Up @@ -63,7 +62,6 @@ void GetIndexedOrNamed(const v8::FunctionCallbackInfo<v8::Value>& info) {
}

TOSTRING_VOID(V8StringResource<>, name, info[0]);
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
ScriptState* script_state = ScriptState::From(info.This()->CreationContext());
v8::Local<v8::Value> v8_value;
if (!ToV8Traits<IDLNullable<V8UnionElementOrHTMLCollection>>::ToV8(
Expand All @@ -72,11 +70,6 @@ void GetIndexedOrNamed(const v8::FunctionCallbackInfo<v8::Value>& info) {
return;
}
bindings::V8SetReturnValue(info, v8_value);
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
HTMLCollectionOrElement result;
impl->NamedGetter(name, result);
V8SetReturnValue(info, result);
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
}

void V8HTMLAllCollection::LegacyCallCustom(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.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/v8_dom_wrapper.h"
#include "third_party/blink/renderer/platform/bindings/v8_set_return_value.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ void ScriptCustomElementDefinition::RunFormDisabledCallback(Element& element,
form_disabled_callback_->InvokeAndReportException(&element, is_disabled);
}

#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
void ScriptCustomElementDefinition::RunFormStateRestoreCallback(
Element& element,
const V8ControlValue* value,
Expand All @@ -337,16 +336,5 @@ void ScriptCustomElementDefinition::RunFormStateRestoreCallback(
form_state_restore_callback_->InvokeAndReportException(
&element, value, V8FormStateRestoreMode::Create(mode).value());
}
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
void ScriptCustomElementDefinition::RunFormStateRestoreCallback(
Element& element,
const FileOrUSVStringOrFormData& value,
const String& mode) {
if (!form_state_restore_callback_)
return;
form_state_restore_callback_->InvokeAndReportException(
&element, value, V8FormStateRestoreMode::Create(mode).value());
}
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

} // namespace blink
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ class CORE_EXPORT ScriptCustomElementDefinition final
HTMLFormElement* nullable_form) override;
void RunFormResetCallback(Element& element) override;
void RunFormDisabledCallback(Element& element, bool is_disabled) override;
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
void RunFormStateRestoreCallback(Element& element,
const V8ControlValue* value,
const String& mode) override;
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
void RunFormStateRestoreCallback(Element& element,
const FileOrUSVStringOrFormData& value,
const String& mode) override;
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

private:
// Implementations of |CustomElementDefinition|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,7 @@ TEST(V8ScriptValueSerializerTest, RoundTripDetachedImageData) {
ASSERT_NO_EXCEPTION);
SkPixmap pm = image_data->GetSkPixmap();
pm.writable_addr32(0, 0)[0] = 200u;
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
image_data->data()->GetAsUint8ClampedArray()->BufferBase()->Detach();
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
image_data->data().GetAsUint8ClampedArray()->BufferBase()->Detach();
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

v8::Local<v8::Value> wrapper =
ToV8(image_data, scope.GetContext()->Global(), scope.GetIsolate());
Expand Down
16 changes: 0 additions & 16 deletions third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#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/source_location.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_trusted_script.h"
#include "third_party/blink/renderer/bindings/core/v8/use_counter_callback.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_context_snapshot.h"
Expand Down Expand Up @@ -391,35 +390,20 @@ TrustedTypesCodeGenerationCheck(v8::Local<v8::Context> context,
return {true, v8::MaybeLocal<v8::String>()};
}

#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
V8UnionStringOrTrustedScript* string_or_trusted_script =
NativeValueTraits<V8UnionStringOrTrustedScript>::NativeValue(
context->GetIsolate(), source, exception_state);
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
StringOrTrustedScript string_or_trusted_script;
V8StringOrTrustedScript::ToImpl(
context->GetIsolate(), source, string_or_trusted_script,
UnionTypeConversionMode::kNotNullable, exception_state);
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
if (exception_state.HadException()) {
exception_state.ClearException();
// The input was a string or TrustedScript but the conversion failed.
// Block, just in case.
return {false, v8::MaybeLocal<v8::String>()};
}

#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
if (is_code_like && string_or_trusted_script->IsString()) {
string_or_trusted_script->Set(MakeGarbageCollected<TrustedScript>(
string_or_trusted_script->GetAsString()));
}
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
if (is_code_like && string_or_trusted_script.IsString()) {
string_or_trusted_script = StringOrTrustedScript::FromTrustedScript(
MakeGarbageCollected<TrustedScript>(
string_or_trusted_script.GetAsString()));
}
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

String stringified_source = TrustedTypesCheckForScript(
string_or_trusted_script, ToExecutionContext(context), exception_state);
Expand Down
30 changes: 1 addition & 29 deletions third_party/blink/renderer/core/animation/animatable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

#include "third_party/blink/renderer/core/animation/animatable.h"

#include "third_party/blink/renderer/bindings/core/v8/unrestricted_double_or_keyframe_animation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/unrestricted_double_or_keyframe_effect_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_get_animations_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_keyframe_animation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_keyframeanimationoptions_unrestricteddouble.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_keyframeeffectoptions_unrestricteddouble.h"
#include "third_party/blink/renderer/core/animation/animation.h"
Expand Down Expand Up @@ -45,7 +44,6 @@ void ReportPermissionsPolicyViolationsIfNecessary(
}
}

#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
V8UnionKeyframeEffectOptionsOrUnrestrictedDouble* CoerceEffectOptions(
const V8UnionKeyframeAnimationOptionsOrUnrestrictedDouble* options) {
switch (options->GetContentType()) {
Expand All @@ -63,30 +61,14 @@ V8UnionKeyframeEffectOptionsOrUnrestrictedDouble* CoerceEffectOptions(
NOTREACHED();
return nullptr;
}
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
UnrestrictedDoubleOrKeyframeEffectOptions CoerceEffectOptions(
UnrestrictedDoubleOrKeyframeAnimationOptions options) {
if (options.IsKeyframeAnimationOptions()) {
return UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions(
options.GetAsKeyframeAnimationOptions());
} else {
return UnrestrictedDoubleOrKeyframeEffectOptions::FromUnrestrictedDouble(
options.GetAsUnrestrictedDouble());
}
}
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

} // namespace

// https://drafts.csswg.org/web-animations/#dom-animatable-animate
Animation* Animatable::animate(
ScriptState* script_state,
const ScriptValue& keyframes,
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
const V8UnionKeyframeAnimationOptionsOrUnrestrictedDouble* options,
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
const UnrestrictedDoubleOrKeyframeAnimationOptions& options,
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
ExceptionState& exception_state) {
if (!script_state->ContextIsValid())
return nullptr;
Expand All @@ -106,22 +88,12 @@ Animation* Animatable::animate(

ReportPermissionsPolicyViolationsIfNecessary(*element->GetExecutionContext(),
*effect->Model());
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
if (!options->IsKeyframeAnimationOptions())
return element->GetDocument().Timeline().Play(effect);
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
if (!options.IsKeyframeAnimationOptions())
return element->GetDocument().Timeline().Play(effect);
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

Animation* animation;
#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
const KeyframeAnimationOptions* options_dict =
options->GetAsKeyframeAnimationOptions();
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
const KeyframeAnimationOptions* options_dict =
options.GetAsKeyframeAnimationOptions();
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
if (!options_dict->hasTimeline()) {
animation = element->GetDocument().Timeline().Play(effect);
} else if (AnimationTimeline* timeline = options_dict->timeline()) {
Expand Down
8 changes: 0 additions & 8 deletions third_party/blink/renderer/core/animation/animatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class ExceptionState;
class GetAnimationsOptions;
class ScriptState;
class ScriptValue;
class UnrestrictedDoubleOrKeyframeAnimationOptions;
class V8UnionKeyframeAnimationOptionsOrUnrestrictedDouble;

// https://drafts.csswg.org/web-animations-1/#the-animatable-interface-mixin
Expand All @@ -53,18 +52,11 @@ class CORE_EXPORT Animatable {
// called on.
virtual Element* GetAnimationTarget() = 0;

#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
Animation* animate(
ScriptState* script_state,
const ScriptValue& keyframes,
const V8UnionKeyframeAnimationOptionsOrUnrestrictedDouble* options,
ExceptionState& exception_state);
#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)
Animation* animate(ScriptState*,
const ScriptValue&,
const UnrestrictedDoubleOrKeyframeAnimationOptions&,
ExceptionState&);
#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION)

Animation* animate(ScriptState*, const ScriptValue&, ExceptionState&);

Expand Down
Loading

0 comments on commit b8d8ee6

Please sign in to comment.