LibWeb/Bindings: Generate struct definitions from IDL dictionaries
Previously we were inconsistent by generating code for enum definitions but not generating code for dictionaries. With future changes to the IDL generator to expose helpers to convert to and from IDL values this produced circular depdendencies. To solve this problem, also generate the dictionary definitions in bindings headers.
This commit is contained in:
parent
7ad946c669
commit
5adfd1c43a
406 changed files with 1963 additions and 2837 deletions
|
|
@ -1046,6 +1046,9 @@ void Parser::parse_dictionary(HashMap<ByteString, ByteString> extended_attribute
|
|||
auto& it = interface.context.partial_dictionaries.ensure(name);
|
||||
it.append(move(dictionary));
|
||||
} else {
|
||||
auto* module = interface.context.find_parsed_module(interface.module_own_path);
|
||||
VERIFY(module);
|
||||
module->own_dictionaries.set(name);
|
||||
interface.own_dictionaries.set(name);
|
||||
interface.context.dictionaries.set(name, move(dictionary));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,6 +354,7 @@ public:
|
|||
struct Module {
|
||||
Context* context { nullptr };
|
||||
ByteString module_own_path;
|
||||
OrderedHashTable<ByteString> own_dictionaries;
|
||||
OrderedHashTable<ByteString> own_enumerations;
|
||||
Optional<Interface&> interface;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ struct Animatable::Transition {
|
|||
Animatable::Impl::~Impl() = default;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animatable-animate
|
||||
WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options)
|
||||
WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS::Object>> keyframes, Variant<Empty, double, Bindings::KeyframeAnimationOptions> const& options)
|
||||
{
|
||||
// 1. Let target be the object on which this method was called.
|
||||
GC::Ref target { *static_cast<DOM::Element*>(this) };
|
||||
|
|
@ -45,8 +45,8 @@ WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS
|
|||
// timeline member of options is missing, be the default document timeline of the node document of the element
|
||||
// on which this method was called.
|
||||
Optional<GC::Ptr<AnimationTimeline>> timeline;
|
||||
if (options.has<KeyframeAnimationOptions>())
|
||||
timeline = options.get<KeyframeAnimationOptions>().timeline;
|
||||
if (options.has<Bindings::KeyframeAnimationOptions>() && options.get<Bindings::KeyframeAnimationOptions>().timeline.has_value())
|
||||
timeline = options.get<Bindings::KeyframeAnimationOptions>().timeline->ptr();
|
||||
if (!timeline.has_value())
|
||||
timeline = target->document().timeline();
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS
|
|||
|
||||
// 5. If options is a KeyframeAnimationOptions object, assign the value of the id member of options to animation’s
|
||||
// id attribute.
|
||||
if (options.has<KeyframeAnimationOptions>())
|
||||
animation->set_id(options.get<KeyframeAnimationOptions>().id);
|
||||
if (options.has<Bindings::KeyframeAnimationOptions>())
|
||||
animation->set_id(options.get<Bindings::KeyframeAnimationOptions>().id);
|
||||
|
||||
// 6. Run the procedure to play an animation for animation with the auto-rewind flag set to true.
|
||||
TRY(animation->play_an_animation(Animation::AutoRewind::Yes));
|
||||
|
|
@ -67,13 +67,13 @@ WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/web-animations-1/#dom-animatable-getanimations
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations(Optional<GetAnimationsOptions> options)
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations(Optional<Bindings::GetAnimationsOptions> const& options)
|
||||
{
|
||||
as<DOM::Element>(*this).document().update_style();
|
||||
return get_animations_internal(GetAnimationsSorted::Yes, options);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations_internal(GetAnimationsSorted sorted, Optional<GetAnimationsOptions> options)
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations_internal(GetAnimationsSorted sorted, Optional<Bindings::GetAnimationsOptions> const& options)
|
||||
{
|
||||
// 1. Let object be the object on which this method was called.
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/FlyString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibWeb/Animations/KeyframeEffect.h>
|
||||
#include <LibWeb/Bindings/Animatable.h>
|
||||
#include <LibWeb/Export.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -21,18 +22,6 @@ class CSSTransition;
|
|||
|
||||
namespace Web::Animations {
|
||||
|
||||
// https://drafts.csswg.org/web-animations-1/#dictdef-keyframeanimationoptions
|
||||
struct KeyframeAnimationOptions : public KeyframeEffectOptions {
|
||||
FlyString id { ""_fly_string };
|
||||
Optional<GC::Ptr<AnimationTimeline>> timeline;
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/web-animations-1/#dictdef-getanimationsoptions
|
||||
struct GetAnimationsOptions {
|
||||
bool subtree { false };
|
||||
Optional<String> pseudo_element {};
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/web-animations-1/#animatable
|
||||
class WEB_API Animatable {
|
||||
public:
|
||||
|
|
@ -50,9 +39,9 @@ public:
|
|||
Yes
|
||||
};
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<Animation>> animate(Optional<GC::Root<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options = {});
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> get_animations(Optional<GetAnimationsOptions> options = {});
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> get_animations_internal(GetAnimationsSorted sorted, Optional<GetAnimationsOptions> options = {});
|
||||
WebIDL::ExceptionOr<GC::Ref<Animation>> animate(Optional<GC::Root<JS::Object>> keyframes, Variant<Empty, double, Bindings::KeyframeAnimationOptions> const& options = {});
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> get_animations(Optional<Bindings::GetAnimationsOptions> const& options = {});
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> get_animations_internal(GetAnimationsSorted sorted, Optional<Bindings::GetAnimationsOptions> const& options = {});
|
||||
|
||||
void associate_with_animation(GC::Ref<Animation>);
|
||||
void disassociate_with_animation(GC::Ref<Animation>);
|
||||
|
|
|
|||
|
|
@ -658,7 +658,7 @@ void Animation::cancel(ShouldInvalidate should_invalidate)
|
|||
// 8. Let timeline time be the current time of the timeline with which animation is associated. If animation is
|
||||
// not associated with an active timeline, let timeline time be an unresolved time value.
|
||||
// 9. Set cancelEvent’s timelineTime to timeline time. If timeline time is unresolved, set it to null.
|
||||
AnimationPlaybackEventInit init;
|
||||
Bindings::AnimationPlaybackEventInit init;
|
||||
init.timeline_time = m_timeline && !m_timeline->is_inactive() ? NullableCSSNumberish { m_timeline->current_time()->as_css_numberish(realm) } : NullableCSSNumberish { Empty {} };
|
||||
auto cancel_event = AnimationPlaybackEvent::create(realm, HTML::EventNames::cancel, init);
|
||||
|
||||
|
|
@ -1330,7 +1330,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
|
|||
// 6. Set finishEvent’s timelineTime attribute to the current time of the timeline with which animation is
|
||||
// associated. If animation is not associated with a timeline, or the timeline is inactive, let
|
||||
// timelineTime be null.
|
||||
AnimationPlaybackEventInit init;
|
||||
Bindings::AnimationPlaybackEventInit init;
|
||||
init.current_time = current_time()->as_css_numberish(realm);
|
||||
if (m_timeline && !m_timeline->is_inactive())
|
||||
init.timeline_time = m_timeline->current_time()->as_css_numberish(realm);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
#include <LibWeb/Animations/AnimationEffect.h>
|
||||
#include <LibWeb/Animations/AnimationTimeline.h>
|
||||
#include <LibWeb/Bindings/AnimationEffect.h>
|
||||
#include <LibWeb/Bindings/CSSStyleSheet.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSNumericValue.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
|
|
@ -59,43 +61,43 @@ Bindings::PlaybackDirection css_animation_direction_to_bindings_playback_directi
|
|||
}
|
||||
}
|
||||
|
||||
OptionalEffectTiming EffectTiming::to_optional_effect_timing() const
|
||||
Bindings::OptionalEffectTiming to_optional_effect_timing(Bindings::EffectTiming const& effect_timing)
|
||||
{
|
||||
return {
|
||||
.delay = delay,
|
||||
.end_delay = end_delay,
|
||||
.fill = fill,
|
||||
.iteration_start = iteration_start,
|
||||
.iterations = iterations,
|
||||
.duration = duration.visit(
|
||||
.delay = effect_timing.delay,
|
||||
.direction = effect_timing.direction,
|
||||
.duration = effect_timing.duration.visit(
|
||||
[](double const& value) -> Variant<double, String> { return value; },
|
||||
[](String const& value) -> Variant<double, String> { return value; },
|
||||
// NB: We check that this isn't the case in the caller
|
||||
[](GC::Root<CSS::CSSNumericValue> const&) -> Variant<double, String> { VERIFY_NOT_REACHED(); }),
|
||||
.direction = direction,
|
||||
.easing = easing,
|
||||
.easing = effect_timing.easing,
|
||||
.end_delay = effect_timing.end_delay,
|
||||
.fill = effect_timing.fill,
|
||||
.iteration_start = effect_timing.iteration_start,
|
||||
.iterations = effect_timing.iterations,
|
||||
};
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animationeffect-gettiming
|
||||
EffectTiming AnimationEffect::get_timing() const
|
||||
Bindings::EffectTiming AnimationEffect::get_timing() const
|
||||
{
|
||||
// 1. Returns the specified timing properties for this animation effect.
|
||||
return {
|
||||
.delay = m_specified_start_delay,
|
||||
.direction = m_playback_direction,
|
||||
.duration = m_specified_iteration_duration,
|
||||
.easing = m_timing_function.to_string(),
|
||||
.end_delay = m_specified_end_delay,
|
||||
.fill = m_fill_mode,
|
||||
.iteration_start = m_iteration_start,
|
||||
.iterations = m_iteration_count,
|
||||
.duration = m_specified_iteration_duration,
|
||||
.direction = m_playback_direction,
|
||||
.easing = m_timing_function.to_string(),
|
||||
};
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animationeffect-getcomputedtiming
|
||||
// https://drafts.csswg.org/web-animations-2/#dom-animationeffect-getcomputedtiming
|
||||
ComputedEffectTiming AnimationEffect::get_computed_timing() const
|
||||
Bindings::ComputedEffectTiming AnimationEffect::get_computed_timing() const
|
||||
{
|
||||
// 1. Returns the calculated timing properties for this animation effect.
|
||||
|
||||
|
|
@ -118,24 +120,21 @@ ComputedEffectTiming AnimationEffect::get_computed_timing() const
|
|||
// In this level of the specification, that simply means that an auto value is replaced by the none FillMode.
|
||||
auto fill = m_fill_mode == Bindings::FillMode::Auto ? Bindings::FillMode::None : m_fill_mode;
|
||||
|
||||
return {
|
||||
{
|
||||
.delay = m_specified_start_delay,
|
||||
.end_delay = m_specified_end_delay,
|
||||
.fill = fill,
|
||||
.iteration_start = m_iteration_start,
|
||||
.iterations = m_iteration_count,
|
||||
.duration = duration,
|
||||
.direction = m_playback_direction,
|
||||
.easing = m_timing_function.to_string(),
|
||||
},
|
||||
|
||||
end_time().as_css_numberish(realm()),
|
||||
active_duration().as_css_numberish(realm()),
|
||||
NullableCSSNumberish::from_optional_css_numberish_time(realm(), local_time()),
|
||||
transformed_progress(),
|
||||
current_iteration(),
|
||||
};
|
||||
Bindings::ComputedEffectTiming computed_timing {};
|
||||
computed_timing.delay = m_specified_start_delay;
|
||||
computed_timing.end_delay = m_specified_end_delay;
|
||||
computed_timing.fill = fill;
|
||||
computed_timing.iteration_start = m_iteration_start;
|
||||
computed_timing.iterations = m_iteration_count;
|
||||
computed_timing.duration = duration;
|
||||
computed_timing.direction = m_playback_direction;
|
||||
computed_timing.easing = m_timing_function.to_string();
|
||||
computed_timing.active_duration = active_duration().as_css_numberish(realm());
|
||||
computed_timing.current_iteration = current_iteration();
|
||||
computed_timing.end_time = end_time().as_css_numberish(realm());
|
||||
computed_timing.local_time = NullableCSSNumberish::from_optional_css_numberish_time(realm(), local_time());
|
||||
computed_timing.progress = transformed_progress();
|
||||
return computed_timing;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/web-animations-2/#intrinsic-iteration-duration
|
||||
|
|
@ -269,7 +268,7 @@ void AnimationEffect::normalize_specified_timing()
|
|||
// https://www.w3.org/TR/web-animations-1/#dom-animationeffect-updatetiming
|
||||
// https://www.w3.org/TR/web-animations-1/#update-the-timing-properties-of-an-animation-effect
|
||||
// https://drafts.csswg.org/web-animations-2/#updating-animationeffect-timing
|
||||
WebIDL::ExceptionOr<void> AnimationEffect::update_timing(OptionalEffectTiming timing)
|
||||
WebIDL::ExceptionOr<void> AnimationEffect::update_timing(Bindings::OptionalEffectTiming const& timing)
|
||||
{
|
||||
// 1. If the iterationStart member of input exists and is less than zero, throw a TypeError and abort this
|
||||
// procedure.
|
||||
|
|
|
|||
|
|
@ -16,44 +16,6 @@
|
|||
|
||||
namespace Web::Animations {
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#the-effecttiming-dictionaries
|
||||
// https://drafts.csswg.org/web-animations-2/#the-effecttiming-dictionaries
|
||||
struct OptionalEffectTiming {
|
||||
Optional<double> delay {};
|
||||
Optional<double> end_delay {};
|
||||
Optional<Bindings::FillMode> fill {};
|
||||
Optional<double> iteration_start {};
|
||||
Optional<double> iterations {};
|
||||
Optional<Variant<double, String>> duration;
|
||||
Optional<Bindings::PlaybackDirection> direction {};
|
||||
Optional<String> easing {};
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#the-effecttiming-dictionaries
|
||||
// https://drafts.csswg.org/web-animations-2/#the-effecttiming-dictionaries
|
||||
struct EffectTiming {
|
||||
double delay { 0 };
|
||||
double end_delay { 0 };
|
||||
Bindings::FillMode fill { Bindings::FillMode::Auto };
|
||||
double iteration_start { 0.0 };
|
||||
double iterations { 1.0 };
|
||||
FlattenVariant<CSS::CSSNumberish, Variant<String>> duration { "auto"_string };
|
||||
Bindings::PlaybackDirection direction { Bindings::PlaybackDirection::Normal };
|
||||
String easing { "linear"_string };
|
||||
|
||||
OptionalEffectTiming to_optional_effect_timing() const;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#the-computedeffecttiming-dictionary
|
||||
// https://drafts.csswg.org/web-animations-2/#the-computedeffecttiming-dictionary
|
||||
struct ComputedEffectTiming : public EffectTiming {
|
||||
CSS::CSSNumberish end_time;
|
||||
CSS::CSSNumberish active_duration;
|
||||
Optional<NullableCSSNumberish> local_time;
|
||||
Optional<double> progress;
|
||||
Optional<double> current_iteration;
|
||||
};
|
||||
|
||||
enum class AnimationDirection {
|
||||
Forwards,
|
||||
Backwards,
|
||||
|
|
@ -61,6 +23,7 @@ enum class AnimationDirection {
|
|||
|
||||
Bindings::FillMode css_fill_mode_to_bindings_fill_mode(CSS::AnimationFillMode mode);
|
||||
Bindings::PlaybackDirection css_animation_direction_to_bindings_playback_direction(CSS::AnimationDirection direction);
|
||||
Bindings::OptionalEffectTiming to_optional_effect_timing(Bindings::EffectTiming const&);
|
||||
|
||||
// This object lives for the duration of an animation update, and is used to store per-element data about animated CSS properties.
|
||||
struct AnimationUpdateContext {
|
||||
|
|
@ -84,9 +47,9 @@ class AnimationEffect : public Bindings::PlatformObject {
|
|||
public:
|
||||
static Optional<CSS::EasingFunction> parse_easing_string(StringView value);
|
||||
|
||||
EffectTiming get_timing() const;
|
||||
ComputedEffectTiming get_computed_timing() const;
|
||||
WebIDL::ExceptionOr<void> update_timing(OptionalEffectTiming timing = {});
|
||||
Bindings::EffectTiming get_timing() const;
|
||||
Bindings::ComputedEffectTiming get_computed_timing() const;
|
||||
WebIDL::ExceptionOr<void> update_timing(Bindings::OptionalEffectTiming const& timing = {});
|
||||
|
||||
TimeValue start_delay() const { return m_start_delay; }
|
||||
void set_specified_start_delay(double start_delay) { m_specified_start_delay = start_delay; }
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ namespace Web::Animations {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(AnimationPlaybackEvent);
|
||||
|
||||
GC::Ref<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
|
||||
GC::Ref<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& type, Bindings::AnimationPlaybackEventInit const& event_init)
|
||||
{
|
||||
return realm.create<AnimationPlaybackEvent>(realm, type, event_init);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animationplaybackevent-animationplaybackevent
|
||||
WebIDL::ExceptionOr<GC::Ref<AnimationPlaybackEvent>> AnimationPlaybackEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<AnimationPlaybackEvent>> AnimationPlaybackEvent::construct_impl(JS::Realm& realm, FlyString const& type, Bindings::AnimationPlaybackEventInit const& event_init)
|
||||
{
|
||||
return create(realm, type, event_init);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ AnimationPlaybackEvent::CSSNumberishInternal AnimationPlaybackEvent::to_numberis
|
|||
[](auto const& other) -> CSSNumberishInternal { return other; });
|
||||
}
|
||||
|
||||
AnimationPlaybackEvent::AnimationPlaybackEvent(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init)
|
||||
AnimationPlaybackEvent::AnimationPlaybackEvent(JS::Realm& realm, FlyString const& type, Bindings::AnimationPlaybackEventInit const& event_init)
|
||||
: DOM::Event(realm, type, event_init)
|
||||
, m_current_time(to_numberish_internal(event_init.current_time))
|
||||
, m_timeline_time(to_numberish_internal(event_init.timeline_time))
|
||||
|
|
|
|||
|
|
@ -8,25 +8,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/Animations/TimeValue.h>
|
||||
#include <LibWeb/Bindings/AnimationPlaybackEvent.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::Animations {
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dictdef-animationplaybackeventinit
|
||||
struct AnimationPlaybackEventInit : public DOM::EventInit {
|
||||
NullableCSSNumberish current_time { Empty {} };
|
||||
NullableCSSNumberish timeline_time { Empty {} };
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#animationplaybackevent
|
||||
class AnimationPlaybackEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(AnimationPlaybackEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<AnimationPlaybackEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& type, Bindings::AnimationPlaybackEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<AnimationPlaybackEvent>> construct_impl(JS::Realm&, FlyString const& type, Bindings::AnimationPlaybackEventInit const& event_init);
|
||||
|
||||
virtual ~AnimationPlaybackEvent() override = default;
|
||||
|
||||
|
|
@ -34,7 +29,7 @@ public:
|
|||
NullableCSSNumberish timeline_time() const;
|
||||
|
||||
private:
|
||||
AnimationPlaybackEvent(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init);
|
||||
AnimationPlaybackEvent(JS::Realm&, FlyString const& type, Bindings::AnimationPlaybackEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ GC::Ref<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Docume
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-documenttimeline-documenttimeline
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> DocumentTimeline::construct_impl(JS::Realm& realm, DocumentTimelineOptions options)
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> DocumentTimeline::construct_impl(JS::Realm& realm, Bindings::DocumentTimelineOptions options)
|
||||
{
|
||||
// Creates a new DocumentTimeline. The Document with which the timeline is associated is the Document associated
|
||||
// with the Window that is the current global object.
|
||||
|
|
|
|||
|
|
@ -7,16 +7,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/Animations/AnimationTimeline.h>
|
||||
#include <LibWeb/Bindings/DocumentTimeline.h>
|
||||
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Animations {
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dictdef-documenttimelineoptions
|
||||
struct DocumentTimelineOptions {
|
||||
HighResolutionTime::DOMHighResTimeStamp origin_time { 0.0 };
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#the-documenttimeline-interface
|
||||
class DocumentTimeline : public AnimationTimeline {
|
||||
WEB_PLATFORM_OBJECT(DocumentTimeline, AnimationTimeline);
|
||||
|
|
@ -24,7 +20,7 @@ class DocumentTimeline : public AnimationTimeline {
|
|||
|
||||
public:
|
||||
static GC::Ref<DocumentTimeline> create(JS::Realm&, DOM::Document&, HighResolutionTime::DOMHighResTimeStamp origin_time);
|
||||
static WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> construct_impl(JS::Realm&, DocumentTimelineOptions options = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> construct_impl(JS::Realm&, Bindings::DocumentTimelineOptions options = {});
|
||||
|
||||
virtual Optional<TimeValue> duration() const override { return {}; }
|
||||
|
||||
|
|
|
|||
|
|
@ -666,7 +666,7 @@ WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(
|
|||
JS::Realm& realm,
|
||||
GC::Root<DOM::Element> const& target,
|
||||
Optional<GC::Root<JS::Object>> const& keyframes,
|
||||
Variant<double, KeyframeEffectOptions> options)
|
||||
Variant<double, Bindings::KeyframeEffectOptions> options)
|
||||
{
|
||||
// 1. Create a new KeyframeEffect object, effect.
|
||||
auto effect = realm.create<KeyframeEffect>(realm);
|
||||
|
|
@ -677,13 +677,13 @@ WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(
|
|||
// 3. Set the target pseudo-selector to the result corresponding to the first matching condition from below.
|
||||
|
||||
// If options is a KeyframeEffectOptions object with a pseudoElement property,
|
||||
if (options.has<KeyframeEffectOptions>()) {
|
||||
if (options.has<Bindings::KeyframeEffectOptions>()) {
|
||||
// Set the target pseudo-selector to the value of the pseudoElement property.
|
||||
//
|
||||
// When assigning this property, the error-handling defined for the pseudoElement setter on the interface is
|
||||
// applied. If the setter requires an exception to be thrown, this procedure must throw the same exception and
|
||||
// abort all further steps.
|
||||
TRY(effect->set_pseudo_element(options.get<KeyframeEffectOptions>().pseudo_element));
|
||||
TRY(effect->set_pseudo_element(options.get<Bindings::KeyframeEffectOptions>().pseudo_element));
|
||||
}
|
||||
// Otherwise,
|
||||
else {
|
||||
|
|
@ -692,12 +692,12 @@ WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(
|
|||
}
|
||||
|
||||
// 4. Let timing input be the result corresponding to the first matching condition from below.
|
||||
KeyframeEffectOptions timing_input;
|
||||
Bindings::KeyframeEffectOptions timing_input;
|
||||
|
||||
// If options is a KeyframeEffectOptions object,
|
||||
if (options.has<KeyframeEffectOptions>()) {
|
||||
if (options.has<Bindings::KeyframeEffectOptions>()) {
|
||||
// Let timing input be options.
|
||||
timing_input = options.get<KeyframeEffectOptions>();
|
||||
timing_input = options.get<Bindings::KeyframeEffectOptions>();
|
||||
}
|
||||
// Otherwise (if options is a double),
|
||||
else {
|
||||
|
|
@ -716,7 +716,7 @@ WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(
|
|||
|
||||
// 5. Call the procedure to update the timing properties of an animation effect of effect from timing input.
|
||||
// If that procedure causes an exception to be thrown, propagate the exception and abort this procedure.
|
||||
TRY(effect->update_timing(timing_input.to_optional_effect_timing()));
|
||||
TRY(effect->update_timing(to_optional_effect_timing(timing_input)));
|
||||
|
||||
// 6. If options is a KeyframeEffectOptions object, assign the composite property of effect to the corresponding
|
||||
// value from options.
|
||||
|
|
@ -724,8 +724,8 @@ WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> KeyframeEffect::construct_impl(
|
|||
// When assigning this property, the error-handling defined for the corresponding setter on the KeyframeEffect
|
||||
// interface is applied. If the setter requires an exception to be thrown for the value specified by options,
|
||||
// this procedure must throw the same exception and abort all further steps.
|
||||
if (options.has<KeyframeEffectOptions>())
|
||||
effect->set_composite(options.get<KeyframeEffectOptions>().composite);
|
||||
if (options.has<Bindings::KeyframeEffectOptions>())
|
||||
effect->set_composite(options.get<Bindings::KeyframeEffectOptions>().composite);
|
||||
|
||||
// 7. Initialize the set of keyframes by performing the procedure defined for setKeyframes() passing keyframes as
|
||||
// the input.
|
||||
|
|
|
|||
|
|
@ -18,12 +18,6 @@ namespace Web::Animations {
|
|||
|
||||
using EasingValue = Variant<String, CSS::EasingFunction>;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#the-keyframeeffectoptions-dictionary
|
||||
struct KeyframeEffectOptions : public EffectTiming {
|
||||
Bindings::CompositeOperation composite { Bindings::CompositeOperation::Replace };
|
||||
Optional<String> pseudo_element {};
|
||||
};
|
||||
|
||||
Bindings::CompositeOperation css_animation_composition_to_bindings_composite_operation(CSS::AnimationComposition composition);
|
||||
Bindings::CompositeOperationOrAuto css_animation_composition_to_bindings_composite_operation_or_auto(CSS::AnimationComposition composition);
|
||||
|
||||
|
|
@ -84,7 +78,7 @@ public:
|
|||
JS::Realm&,
|
||||
GC::Root<DOM::Element> const& target,
|
||||
Optional<GC::Root<JS::Object>> const& keyframes,
|
||||
Variant<double, KeyframeEffectOptions> options = KeyframeEffectOptions {});
|
||||
Variant<double, Bindings::KeyframeEffectOptions> options = Bindings::KeyframeEffectOptions {});
|
||||
|
||||
static WebIDL::ExceptionOr<GC::Ref<KeyframeEffect>> construct_impl(JS::Realm&, GC::Ref<KeyframeEffect> source);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ GC::Ref<ScrollTimeline> ScrollTimeline::create(JS::Realm& realm, DOM::Document&
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/scroll-animations-1/#dom-scrolltimeline-scrolltimeline
|
||||
GC::Ref<ScrollTimeline> ScrollTimeline::construct_impl(JS::Realm& realm, ScrollTimelineOptions options)
|
||||
GC::Ref<ScrollTimeline> ScrollTimeline::construct_impl(JS::Realm& realm, Bindings::ScrollTimelineOptions options)
|
||||
{
|
||||
auto& document = as<HTML::Window>(realm.global_object()).associated_document();
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ GC::Ref<ScrollTimeline> ScrollTimeline::construct_impl(JS::Realm& realm, ScrollT
|
|||
// If the source member of options is present,
|
||||
// The source member of options.
|
||||
if (options.source.has_value())
|
||||
return options.source.value();
|
||||
return options.source.value().ptr();
|
||||
|
||||
// Otherwise,
|
||||
// The scrollingElement of the Document associated with the Window that is the current global object.
|
||||
|
|
|
|||
|
|
@ -12,13 +12,6 @@
|
|||
|
||||
namespace Web::Animations {
|
||||
|
||||
// https://drafts.csswg.org/scroll-animations-1/#dictdef-scrolltimelineoptions
|
||||
struct ScrollTimelineOptions {
|
||||
// NB: We use Optional here to distinguish between "undefined" and "null"
|
||||
Optional<GC::Ptr<DOM::Element>> source;
|
||||
Bindings::ScrollAxis axis;
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/scroll-animations-1/#scrolltimeline
|
||||
class ScrollTimeline : public AnimationTimeline {
|
||||
WEB_PLATFORM_OBJECT(ScrollTimeline, AnimationTimeline);
|
||||
|
|
@ -35,7 +28,7 @@ public:
|
|||
using Source = Variant<GC::Ptr<DOM::Element const>, AnonymousSource>;
|
||||
|
||||
static GC::Ref<ScrollTimeline> create(JS::Realm&, DOM::Document&, Source source, Bindings::ScrollAxis axis);
|
||||
static GC::Ref<ScrollTimeline> construct_impl(JS::Realm&, ScrollTimelineOptions options = {});
|
||||
static GC::Ref<ScrollTimeline> construct_impl(JS::Realm&, Bindings::ScrollTimelineOptions options = {});
|
||||
|
||||
virtual Optional<TimeValue> duration() const override { return TimeValue { TimeValue::Type::Percentage, 100 }; }
|
||||
|
||||
|
|
|
|||
|
|
@ -189,8 +189,8 @@ void initialize_main_thread_vm(AgentType type)
|
|||
// FIXME: This currently assumes that global is a WindowObject.
|
||||
auto& window = as<HTML::Window>(global);
|
||||
|
||||
HTML::PromiseRejectionEventInit event_init {
|
||||
{}, // Initialize the inherited DOM::EventInit
|
||||
Bindings::PromiseRejectionEventInit event_init {
|
||||
{}, // Initialize the inherited Bindings::EventInit
|
||||
/* .promise = */ promise,
|
||||
/* .reason = */ promise.result(),
|
||||
};
|
||||
|
|
@ -731,7 +731,7 @@ void queue_mutation_observer_microtask()
|
|||
|
||||
// 7. For each slot of signalSet, fire an event named slotchange, with its bubbles attribute set to true, at slot.
|
||||
for (auto& slot : signal_set) {
|
||||
DOM::EventInit event_init;
|
||||
Bindings::EventInit event_init;
|
||||
event_init.bubbles = true;
|
||||
slot->dispatch_event(DOM::Event::create(slot->realm(), HTML::EventNames::slotchange, event_init));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(AnimationEvent);
|
||||
|
||||
GC::Ref<AnimationEvent> AnimationEvent::create(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
GC::Ref<AnimationEvent> AnimationEvent::create(JS::Realm& realm, FlyString const& type, Bindings::AnimationEventInit const& event_init)
|
||||
{
|
||||
return realm.create<AnimationEvent>(realm, type, event_init);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<AnimationEvent>> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<AnimationEvent>> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, Bindings::AnimationEventInit const& event_init)
|
||||
{
|
||||
return create(realm, type, event_init);
|
||||
}
|
||||
|
||||
AnimationEvent::AnimationEvent(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||
AnimationEvent::AnimationEvent(JS::Realm& realm, FlyString const& type, Bindings::AnimationEventInit const& event_init)
|
||||
: DOM::Event(realm, type, event_init)
|
||||
, m_animation_name(event_init.animation_name)
|
||||
, m_elapsed_time(event_init.elapsed_time)
|
||||
|
|
|
|||
|
|
@ -6,26 +6,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/AnimationEvent.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://www.w3.org/TR/css-animations-1/#dictdef-animationeventinit
|
||||
struct AnimationEventInit : public DOM::EventInit {
|
||||
FlyString animation_name { ""_fly_string };
|
||||
double elapsed_time { 0.0 };
|
||||
FlyString pseudo_element { ""_fly_string };
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/css-animations-1/#animationevent
|
||||
class AnimationEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(AnimationEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(AnimationEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<AnimationEvent> create(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<AnimationEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<AnimationEvent> create(JS::Realm&, FlyString const& type, Bindings::AnimationEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<AnimationEvent>> construct_impl(JS::Realm&, FlyString const& type, Bindings::AnimationEventInit const& event_init);
|
||||
|
||||
virtual ~AnimationEvent() override = default;
|
||||
|
||||
|
|
@ -34,7 +28,7 @@ public:
|
|||
FlyString const& pseudo_element() const { return m_pseudo_element; }
|
||||
|
||||
private:
|
||||
AnimationEvent(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
|
||||
AnimationEvent(JS::Realm&, FlyString const& type, Bindings::AnimationEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/CSS.h>
|
||||
#include <LibWeb/CSS/CSS.h>
|
||||
#include <LibWeb/CSS/CSSUnitValue.h>
|
||||
#include <LibWeb/CSS/CustomPropertyRegistration.h>
|
||||
|
|
@ -61,7 +62,7 @@ WebIDL::ExceptionOr<bool> supports(JS::VM& vm, StringView condition_text)
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/css-properties-values-api-1/#the-registerproperty-function
|
||||
WebIDL::ExceptionOr<void> register_property(JS::VM& vm, PropertyDefinition definition)
|
||||
WebIDL::ExceptionOr<void> register_property(JS::VM& vm, Bindings::PropertyDefinition const& definition)
|
||||
{
|
||||
// 1. Let property set be the value of the current global object’s associated Document’s [[registeredPropertySet]] slot.
|
||||
auto& realm = *vm.current_realm();
|
||||
|
|
|
|||
|
|
@ -18,19 +18,12 @@
|
|||
// https://www.w3.org/TR/cssom-1/#namespacedef-css
|
||||
namespace Web::CSS {
|
||||
|
||||
struct PropertyDefinition {
|
||||
String name;
|
||||
String syntax;
|
||||
bool inherits;
|
||||
Optional<String> initial_value;
|
||||
};
|
||||
|
||||
WEB_API WebIDL::ExceptionOr<String> escape(JS::VM&, StringView identifier);
|
||||
|
||||
WEB_API bool supports(JS::VM&, FlyString const& property, StringView value);
|
||||
WEB_API WebIDL::ExceptionOr<bool> supports(JS::VM&, StringView condition_text);
|
||||
|
||||
WEB_API WebIDL::ExceptionOr<void> register_property(JS::VM&, PropertyDefinition definition);
|
||||
WEB_API WebIDL::ExceptionOr<void> register_property(JS::VM&, Bindings::PropertyDefinition const&);
|
||||
|
||||
// NB: Numeric factory functions (https://drafts.css-houdini.org/css-typed-om-1/#numeric-factory) are generated,
|
||||
// see GenerateCSSNumericFactoryMethods.cpp
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ GC::Ref<CSSMatrixComponent> CSSMatrixComponent::create(JS::Realm& realm, Is2D is
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssmatrixcomponent-cssmatrixcomponent
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSMatrixComponent>> CSSMatrixComponent::construct_impl(JS::Realm& realm, GC::Ref<Geometry::DOMMatrixReadOnly> matrix, Optional<CSSMatrixComponentOptions> options)
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSMatrixComponent>> CSSMatrixComponent::construct_impl(JS::Realm& realm, GC::Ref<Geometry::DOMMatrixReadOnly> matrix, Optional<Bindings::CSSMatrixComponentOptions> options)
|
||||
{
|
||||
// The CSSMatrixComponent(matrix, options) constructor must, when invoked, perform the following steps:
|
||||
|
||||
|
|
|
|||
|
|
@ -6,15 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/CSSMatrixComponent.h>
|
||||
#include <LibWeb/CSS/CSSTransformComponent.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dictdef-cssmatrixcomponentoptions
|
||||
struct CSSMatrixComponentOptions {
|
||||
Optional<bool> is2d;
|
||||
};
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssmatrixcomponent
|
||||
class CSSMatrixComponent final : public CSSTransformComponent {
|
||||
WEB_PLATFORM_OBJECT(CSSMatrixComponent, CSSTransformComponent);
|
||||
|
|
@ -22,7 +18,7 @@ class CSSMatrixComponent final : public CSSTransformComponent {
|
|||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CSSMatrixComponent> create(JS::Realm&, Is2D, GC::Ref<Geometry::DOMMatrix>);
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSMatrixComponent>> construct_impl(JS::Realm&, GC::Ref<Geometry::DOMMatrixReadOnly>, Optional<CSSMatrixComponentOptions> = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSMatrixComponent>> construct_impl(JS::Realm&, GC::Ref<Geometry::DOMMatrixReadOnly>, Optional<Bindings::CSSMatrixComponentOptions> = {});
|
||||
|
||||
virtual ~CSSMatrixComponent() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -355,10 +355,10 @@ WebIDL::ExceptionOr<GC::Ref<CSSUnitValue>> CSSNumericValue::to(FlyString const&
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-type
|
||||
CSSNumericType CSSNumericValue::type_for_bindings() const
|
||||
Bindings::CSSNumericType CSSNumericValue::type_for_bindings() const
|
||||
{
|
||||
// 1. Let result be a new CSSNumericType.
|
||||
CSSNumericType result {};
|
||||
Bindings::CSSNumericType result {};
|
||||
|
||||
// 2. For each baseType → power in the type of this,
|
||||
m_type.for_each_type_and_exponent([&result](NumericType::BaseType base_type, auto power) {
|
||||
|
|
|
|||
|
|
@ -15,17 +15,6 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct CSSNumericType {
|
||||
Optional<WebIDL::Long> length;
|
||||
Optional<WebIDL::Long> angle;
|
||||
Optional<WebIDL::Long> time;
|
||||
Optional<WebIDL::Long> frequency;
|
||||
Optional<WebIDL::Long> resolution;
|
||||
Optional<WebIDL::Long> flex;
|
||||
Optional<WebIDL::Long> percent;
|
||||
Optional<Bindings::CSSNumericBaseType> percent_hint;
|
||||
};
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue-sum-value
|
||||
struct SumValueItem {
|
||||
double value;
|
||||
|
|
@ -64,7 +53,7 @@ public:
|
|||
|
||||
virtual Optional<SumValue> create_a_sum_value() const = 0;
|
||||
|
||||
CSSNumericType type_for_bindings() const;
|
||||
Bindings::CSSNumericType type_for_bindings() const;
|
||||
NumericType const& type() const { return m_type; }
|
||||
|
||||
virtual WebIDL::ExceptionOr<String> to_string() const final override { return to_string({}); }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ GC::Ref<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rule
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssstylesheet
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Realm& realm, Optional<CSSStyleSheetInit> const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Realm& realm, Optional<Bindings::CSSStyleSheetInit> const& options)
|
||||
{
|
||||
// 1. Construct a new CSSStyleSheet object sheet.
|
||||
auto sheet = create(realm, CSSRuleList::create(realm), CSS::MediaList::create(realm, {}), {});
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibWeb/Bindings/CSSStyleSheet.h>
|
||||
#include <LibWeb/CSS/CSSNamespaceRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
|
|
@ -28,12 +29,6 @@ class StyleScope;
|
|||
struct ShadowRootStylesheetEffects;
|
||||
struct StyleCache;
|
||||
|
||||
struct CSSStyleSheetInit {
|
||||
Optional<String> base_url {};
|
||||
Variant<GC::Root<MediaList>, String> media { String {} };
|
||||
bool disabled { false };
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/cssom-1/#cssstylesheet
|
||||
class WEB_API CSSStyleSheet final : public StyleSheet {
|
||||
WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet);
|
||||
|
|
@ -63,7 +58,7 @@ public:
|
|||
};
|
||||
|
||||
[[nodiscard]] static GC::Ref<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<::URL::URL> location);
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> construct_impl(JS::Realm&, Optional<CSSStyleSheetInit> const& options = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> construct_impl(JS::Realm&, Optional<Bindings::CSSStyleSheetInit> const& options = {});
|
||||
|
||||
virtual ~CSSStyleSheet() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Typeface const>>> load_vec
|
|||
GC_DEFINE_ALLOCATOR(FontFace);
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#font-face-constructor
|
||||
GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, FontFaceDescriptors const& descriptors)
|
||||
GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, Bindings::FontFaceDescriptors const& descriptors)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,19 +17,6 @@ namespace Web::CSS {
|
|||
|
||||
class FontLoader;
|
||||
|
||||
struct FontFaceDescriptors {
|
||||
String style = "normal"_string;
|
||||
String weight = "normal"_string;
|
||||
String stretch = "normal"_string;
|
||||
String unicode_range = "U+0-10FFFF"_string;
|
||||
String feature_settings = "normal"_string;
|
||||
String variation_settings = "normal"_string;
|
||||
String display = "auto"_string;
|
||||
String ascent_override = "normal"_string;
|
||||
String descent_override = "normal"_string;
|
||||
String line_gap_override = "normal"_string;
|
||||
};
|
||||
|
||||
class FontFace final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(FontFace, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(FontFace);
|
||||
|
|
@ -37,7 +24,7 @@ class FontFace final : public Bindings::PlatformObject {
|
|||
public:
|
||||
using FontFaceSource = Variant<String, GC::Root<WebIDL::BufferSource>>;
|
||||
|
||||
[[nodiscard]] static GC::Ref<FontFace> construct_impl(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
|
||||
[[nodiscard]] static GC::Ref<FontFace> construct_impl(JS::Realm&, String family, FontFaceSource source, Bindings::FontFaceDescriptors const& descriptors);
|
||||
[[nodiscard]] static GC::Ref<FontFace> create_css_connected(JS::Realm&, CSSFontFaceRule&);
|
||||
virtual ~FontFace() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ void FontFaceSet::fire_a_font_load_event(FlyString name, Vector<GC::Ref<FontFace
|
|||
// event named e using the FontFaceSetLoadEvent interface that also meets these conditions:
|
||||
// 1. The fontfaces attribute is initialized to the result of filtering font faces to only contain FontFace
|
||||
// objects contained in target.
|
||||
FontFaceSetLoadEventInit load_event_init {};
|
||||
Bindings::FontFaceSetLoadEventInit load_event_init {};
|
||||
for (auto const& font_face : font_faces) {
|
||||
if (set_entries()->set_has(font_face))
|
||||
load_event_init.fontfaces.append(font_face);
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(FontFaceSetLoadEvent);
|
||||
|
||||
GC::Ref<FontFaceSetLoadEvent> FontFaceSetLoadEvent::create(JS::Realm& realm, FlyString const& event_name, FontFaceSetLoadEventInit const& event_init)
|
||||
GC::Ref<FontFaceSetLoadEvent> FontFaceSetLoadEvent::create(JS::Realm& realm, FlyString const& event_name, Bindings::FontFaceSetLoadEventInit const& event_init)
|
||||
{
|
||||
return realm.create<FontFaceSetLoadEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontfacesetloadevent-fontfacesetloadevent
|
||||
WebIDL::ExceptionOr<GC::Ref<FontFaceSetLoadEvent>> FontFaceSetLoadEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FontFaceSetLoadEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<FontFaceSetLoadEvent>> FontFaceSetLoadEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::FontFaceSetLoadEventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
FontFaceSetLoadEvent::FontFaceSetLoadEvent(JS::Realm& realm, FlyString const& event_name, CSS::FontFaceSetLoadEventInit const& event_init)
|
||||
FontFaceSetLoadEvent::FontFaceSetLoadEvent(JS::Realm& realm, FlyString const& event_name, Bindings::FontFaceSetLoadEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
{
|
||||
m_fontfaces.ensure_capacity(event_init.fontfaces.size());
|
||||
|
|
|
|||
|
|
@ -6,29 +6,26 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/FontFaceSetLoadEvent.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct FontFaceSetLoadEventInit : public DOM::EventInit {
|
||||
Vector<GC::Root<FontFace>> fontfaces;
|
||||
};
|
||||
|
||||
class FontFaceSetLoadEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(FontFaceSetLoadEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(FontFaceSetLoadEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<FontFaceSetLoadEvent> create(JS::Realm&, FlyString const& type, FontFaceSetLoadEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<FontFaceSetLoadEvent>> construct_impl(JS::Realm&, FlyString const& type, FontFaceSetLoadEventInit const& event_init = {});
|
||||
[[nodiscard]] static GC::Ref<FontFaceSetLoadEvent> create(JS::Realm&, FlyString const& type, Bindings::FontFaceSetLoadEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<FontFaceSetLoadEvent>> construct_impl(JS::Realm&, FlyString const& type, Bindings::FontFaceSetLoadEventInit const& event_init = {});
|
||||
|
||||
virtual ~FontFaceSetLoadEvent() override = default;
|
||||
|
||||
Vector<GC::Ref<FontFace>> const& fontfaces() const { return m_fontfaces; }
|
||||
|
||||
private:
|
||||
FontFaceSetLoadEvent(JS::Realm&, FlyString const& type, FontFaceSetLoadEventInit const& event_init = {});
|
||||
FontFaceSetLoadEvent(JS::Realm&, FlyString const& type, Bindings::FontFaceSetLoadEventInit const& event_init = {});
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(MediaQueryListEvent);
|
||||
|
||||
GC::Ref<MediaQueryListEvent> MediaQueryListEvent::create(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
GC::Ref<MediaQueryListEvent> MediaQueryListEvent::create(JS::Realm& realm, FlyString const& event_name, Bindings::MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
auto event = realm.create<MediaQueryListEvent>(realm, event_name, event_init);
|
||||
event->set_is_trusted(true);
|
||||
return event;
|
||||
}
|
||||
|
||||
GC::Ref<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
GC::Ref<MediaQueryListEvent> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return realm.create<MediaQueryListEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, Bindings::MediaQueryListEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
, m_media(event_init.media)
|
||||
, m_matches(event_init.matches)
|
||||
|
|
|
|||
|
|
@ -7,22 +7,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/Bindings/MediaQueryListEvent.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct MediaQueryListEventInit : public DOM::EventInit {
|
||||
String media;
|
||||
bool matches { false };
|
||||
};
|
||||
|
||||
class MediaQueryListEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(MediaQueryListEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<MediaQueryListEvent> create(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<MediaQueryListEvent> create(JS::Realm&, FlyString const& event_name, Bindings::MediaQueryListEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<MediaQueryListEvent> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::MediaQueryListEventInit const& = {});
|
||||
|
||||
virtual ~MediaQueryListEvent() override;
|
||||
|
||||
|
|
@ -30,7 +26,7 @@ public:
|
|||
bool matches() const { return m_matches; }
|
||||
|
||||
private:
|
||||
MediaQueryListEvent(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init);
|
||||
MediaQueryListEvent(JS::Realm&, FlyString const& event_name, Bindings::MediaQueryListEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -2188,7 +2188,7 @@ GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::AbstractEleme
|
|||
|
||||
auto animations = abstract_element.element().get_animations_internal(
|
||||
Animations::Animatable::GetAnimationsSorted::Yes,
|
||||
Animations::GetAnimationsOptions { .subtree = false });
|
||||
Bindings::GetAnimationsOptions { .subtree = false });
|
||||
if (animations.is_exception()) {
|
||||
dbgln("Error getting animations for element {}", abstract_element.debug_description());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(TransitionEvent);
|
||||
|
||||
GC::Ref<TransitionEvent> TransitionEvent::create(JS::Realm& realm, FlyString const& type, TransitionEventInit const& event_init)
|
||||
GC::Ref<TransitionEvent> TransitionEvent::create(JS::Realm& realm, FlyString const& type, Bindings::TransitionEventInit const& event_init)
|
||||
{
|
||||
auto event = realm.create<TransitionEvent>(realm, type, event_init);
|
||||
event->set_is_trusted(true);
|
||||
return event;
|
||||
}
|
||||
|
||||
GC::Ref<TransitionEvent> TransitionEvent::construct_impl(JS::Realm& realm, FlyString const& type, TransitionEventInit const& event_init)
|
||||
GC::Ref<TransitionEvent> TransitionEvent::construct_impl(JS::Realm& realm, FlyString const& type, Bindings::TransitionEventInit const& event_init)
|
||||
{
|
||||
return realm.create<TransitionEvent>(realm, type, event_init);
|
||||
}
|
||||
|
||||
TransitionEvent::TransitionEvent(JS::Realm& realm, FlyString const& type, TransitionEventInit const& event_init)
|
||||
TransitionEvent::TransitionEvent(JS::Realm& realm, FlyString const& type, Bindings::TransitionEventInit const& event_init)
|
||||
: DOM::Event(realm, type, event_init)
|
||||
, m_property_name(event_init.property_name)
|
||||
, m_elapsed_time(event_init.elapsed_time)
|
||||
|
|
|
|||
|
|
@ -6,23 +6,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/TransitionEvent.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct TransitionEventInit : public DOM::EventInit {
|
||||
String property_name {};
|
||||
double elapsed_time = 0.0;
|
||||
String pseudo_element {};
|
||||
};
|
||||
|
||||
class TransitionEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(TransitionEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(TransitionEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<TransitionEvent> create(JS::Realm&, FlyString const& event_name, TransitionEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<TransitionEvent> construct_impl(JS::Realm&, FlyString const& event_name, TransitionEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<TransitionEvent> create(JS::Realm&, FlyString const& event_name, Bindings::TransitionEventInit const& = {});
|
||||
[[nodiscard]] static GC::Ref<TransitionEvent> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::TransitionEventInit const& = {});
|
||||
|
||||
virtual ~TransitionEvent() override;
|
||||
|
||||
|
|
@ -31,7 +26,7 @@ public:
|
|||
String const& pseudo_element() const { return m_pseudo_element; }
|
||||
|
||||
private:
|
||||
TransitionEvent(JS::Realm&, FlyString const& event_name, TransitionEventInit const& event_init);
|
||||
TransitionEvent(JS::Realm&, FlyString const& event_name, Bindings::TransitionEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ static bool check_clipboard_write_permission(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#dom-clipboard-readtext
|
||||
GC::Ref<WebIDL::Promise> Clipboard::read(ClipboardUnsanitizedFormats formats)
|
||||
GC::Ref<WebIDL::Promise> Clipboard::read(Bindings::ClipboardUnsanitizedFormats formats)
|
||||
{
|
||||
// 1. Let realm be this's relevant realm.
|
||||
auto& realm = HTML::relevant_realm(*this);
|
||||
|
|
|
|||
|
|
@ -9,17 +9,13 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/Clipboard.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Clipboard {
|
||||
|
||||
struct ClipboardUnsanitizedFormats {
|
||||
// FIXME: This should not actually be an Optional, but the IDL generator creates it as such.
|
||||
Optional<Vector<String>> unsanitized;
|
||||
};
|
||||
|
||||
class Clipboard final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(Clipboard, DOM::EventTarget);
|
||||
GC_DECLARE_ALLOCATOR(Clipboard);
|
||||
|
|
@ -28,7 +24,7 @@ public:
|
|||
static WebIDL::ExceptionOr<GC::Ref<Clipboard>> construct_impl(JS::Realm&);
|
||||
virtual ~Clipboard() override;
|
||||
|
||||
GC::Ref<WebIDL::Promise> read(ClipboardUnsanitizedFormats formats = {});
|
||||
GC::Ref<WebIDL::Promise> read(Bindings::ClipboardUnsanitizedFormats formats = {});
|
||||
GC::Ref<WebIDL::Promise> read_text();
|
||||
|
||||
GC::Ref<WebIDL::Promise> write(Vector<GC::Root<ClipboardItem>> const&);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ namespace Web::Clipboard {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(ClipboardEvent);
|
||||
|
||||
GC::Ref<ClipboardEvent> ClipboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init)
|
||||
GC::Ref<ClipboardEvent> ClipboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::ClipboardEventInit const& event_init)
|
||||
{
|
||||
return realm.create<ClipboardEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
ClipboardEvent::ClipboardEvent(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init)
|
||||
ClipboardEvent::ClipboardEvent(JS::Realm& realm, FlyString const& event_name, Bindings::ClipboardEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
, m_clipboard_data(event_init.clipboard_data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,24 +13,20 @@
|
|||
|
||||
namespace Web::Clipboard {
|
||||
|
||||
struct ClipboardEventInit : public DOM::EventInit {
|
||||
GC::Ptr<HTML::DataTransfer> clipboard_data;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#clipboardevent
|
||||
class ClipboardEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(ClipboardEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(ClipboardEvent);
|
||||
|
||||
public:
|
||||
static GC::Ref<ClipboardEvent> construct_impl(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
|
||||
static GC::Ref<ClipboardEvent> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::ClipboardEventInit const& event_init);
|
||||
|
||||
virtual ~ClipboardEvent() override;
|
||||
|
||||
GC::Ptr<HTML::DataTransfer> clipboard_data() { return m_clipboard_data; }
|
||||
|
||||
private:
|
||||
ClipboardEvent(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
|
||||
ClipboardEvent(JS::Realm&, FlyString const& event_name, Bindings::ClipboardEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Web::Clipboard {
|
|||
GC_DEFINE_ALLOCATOR(ClipboardItem);
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#dom-clipboarditem-clipboarditem
|
||||
WebIDL::ExceptionOr<GC::Ref<ClipboardItem>> ClipboardItem::construct_impl(JS::Realm& realm, OrderedHashMap<String, GC::Root<WebIDL::Promise>> const& items, ClipboardItemOptions const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<ClipboardItem>> ClipboardItem::construct_impl(JS::Realm& realm, OrderedHashMap<String, GC::Root<WebIDL::Promise>> const& items, Bindings::ClipboardItemOptions const& options)
|
||||
{
|
||||
// 1. If items is empty, then throw a TypeError.
|
||||
if (items.is_empty())
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@ constexpr inline Array MANDATORY_DATA_TYPES = {
|
|||
"text/plain"sv, "text/html"sv, "image/png"sv
|
||||
};
|
||||
|
||||
struct ClipboardItemOptions {
|
||||
Bindings::PresentationStyle presentation_style { Bindings::PresentationStyle::Unspecified };
|
||||
};
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#clipboard-item-interface
|
||||
class ClipboardItem : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(ClipboardItem, Bindings::PlatformObject);
|
||||
|
|
@ -39,7 +35,7 @@ public:
|
|||
GC::Ref<WebIDL::Promise> data; // The actual data for this representation.
|
||||
};
|
||||
|
||||
static WebIDL::ExceptionOr<GC::Ref<ClipboardItem>> construct_impl(JS::Realm&, OrderedHashMap<String, GC::Root<WebIDL::Promise>> const& items, ClipboardItemOptions const& options = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<ClipboardItem>> construct_impl(JS::Realm&, OrderedHashMap<String, GC::Root<WebIDL::Promise>> const& items, Bindings::ClipboardItemOptions const& options = {});
|
||||
|
||||
virtual ~ClipboardItem() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ namespace Web::ContentSecurityPolicy {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SecurityPolicyViolationEvent);
|
||||
|
||||
GC::Ref<SecurityPolicyViolationEvent> SecurityPolicyViolationEvent::create(JS::Realm& realm, FlyString const& event_name, SecurityPolicyViolationEventInit const& event_init)
|
||||
GC::Ref<SecurityPolicyViolationEvent> SecurityPolicyViolationEvent::create(JS::Realm& realm, FlyString const& event_name, Bindings::SecurityPolicyViolationEventInit const& event_init)
|
||||
{
|
||||
return realm.create<SecurityPolicyViolationEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<SecurityPolicyViolationEvent>> SecurityPolicyViolationEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, SecurityPolicyViolationEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<SecurityPolicyViolationEvent>> SecurityPolicyViolationEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::SecurityPolicyViolationEventInit const& event_init)
|
||||
{
|
||||
return realm.create<SecurityPolicyViolationEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
SecurityPolicyViolationEvent::SecurityPolicyViolationEvent(JS::Realm& realm, FlyString const& event_name, SecurityPolicyViolationEventInit const& event_init)
|
||||
SecurityPolicyViolationEvent::SecurityPolicyViolationEvent(JS::Realm& realm, FlyString const& event_name, Bindings::SecurityPolicyViolationEventInit const& event_init)
|
||||
: Event(realm, event_name, event_init)
|
||||
, m_document_uri(event_init.document_uri)
|
||||
, m_referrer(event_init.referrer)
|
||||
|
|
|
|||
|
|
@ -11,28 +11,13 @@
|
|||
|
||||
namespace Web::ContentSecurityPolicy {
|
||||
|
||||
struct SecurityPolicyViolationEventInit final : public DOM::EventInit {
|
||||
String document_uri;
|
||||
String referrer;
|
||||
String blocked_uri;
|
||||
String violated_directive;
|
||||
String effective_directive;
|
||||
String original_policy;
|
||||
String source_file;
|
||||
String sample;
|
||||
Bindings::SecurityPolicyViolationEventDisposition disposition { Bindings::SecurityPolicyViolationEventDisposition::Enforce };
|
||||
u16 status_code { 0 };
|
||||
u32 line_number { 0 };
|
||||
u32 column_number { 0 };
|
||||
};
|
||||
|
||||
class SecurityPolicyViolationEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(SecurityPolicyViolationEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(SecurityPolicyViolationEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<SecurityPolicyViolationEvent> create(JS::Realm&, FlyString const& event_name, SecurityPolicyViolationEventInit const& = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<SecurityPolicyViolationEvent>> construct_impl(JS::Realm&, FlyString const& event_name, SecurityPolicyViolationEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<SecurityPolicyViolationEvent> create(JS::Realm&, FlyString const& event_name, Bindings::SecurityPolicyViolationEventInit const& = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<SecurityPolicyViolationEvent>> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::SecurityPolicyViolationEventInit const& event_init);
|
||||
|
||||
virtual ~SecurityPolicyViolationEvent() override;
|
||||
|
||||
|
|
@ -50,7 +35,7 @@ public:
|
|||
u32 column_number() const { return m_column_number; }
|
||||
|
||||
private:
|
||||
SecurityPolicyViolationEvent(JS::Realm&, FlyString const& event_name, SecurityPolicyViolationEventInit const&);
|
||||
SecurityPolicyViolationEvent(JS::Realm&, FlyString const& event_name, Bindings::SecurityPolicyViolationEventInit const&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ void Violation::report_a_violation(JS::Realm& realm)
|
|||
if (is<DOM::EventTarget>(target_as_object.ptr())) {
|
||||
auto& event_target = static_cast<DOM::EventTarget&>(*target_as_object.ptr());
|
||||
|
||||
SecurityPolicyViolationEventInit event_init {};
|
||||
Bindings::SecurityPolicyViolationEventInit event_init {};
|
||||
|
||||
// bubbles
|
||||
// true
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ namespace Web::CookieStore {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CookieChangeEvent);
|
||||
|
||||
GC::Ref<CookieChangeEvent> CookieChangeEvent::create(JS::Realm& realm, FlyString const& event_name, CookieChangeEventInit const& event_init)
|
||||
GC::Ref<CookieChangeEvent> CookieChangeEvent::create(JS::Realm& realm, FlyString const& event_name, Bindings::CookieChangeEventInit const& event_init)
|
||||
{
|
||||
return realm.create<CookieChangeEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
GC::Ref<CookieChangeEvent> CookieChangeEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CookieChangeEventInit const& event_init)
|
||||
GC::Ref<CookieChangeEvent> CookieChangeEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::CookieChangeEventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
CookieChangeEvent::CookieChangeEvent(JS::Realm& realm, FlyString const& event_name, CookieChangeEventInit const& event_init)
|
||||
CookieChangeEvent::CookieChangeEvent(JS::Realm& realm, FlyString const& event_name, Bindings::CookieChangeEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
, m_changed(event_init.changed.value_or({}))
|
||||
, m_deleted(event_init.deleted.value_or({}))
|
||||
|
|
|
|||
|
|
@ -6,43 +6,37 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CookieStore/CookieStore.h>
|
||||
#include <LibWeb/Bindings/CookieChangeEvent.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/WebIDL/CachedAttribute.h>
|
||||
|
||||
namespace Web::CookieStore {
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dictdef-cookiechangeeventinit
|
||||
struct CookieChangeEventInit final : public DOM::EventInit {
|
||||
Optional<Vector<CookieListItem>> changed;
|
||||
Optional<Vector<CookieListItem>> deleted;
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#cookiechangeevent
|
||||
class CookieChangeEvent final : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(CookieChangeEvent, DOM::Event);
|
||||
GC_DECLARE_ALLOCATOR(CookieChangeEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CookieChangeEvent> create(JS::Realm&, FlyString const& event_name, CookieChangeEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<CookieChangeEvent> construct_impl(JS::Realm&, FlyString const& event_name, CookieChangeEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<CookieChangeEvent> create(JS::Realm&, FlyString const& event_name, Bindings::CookieChangeEventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<CookieChangeEvent> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::CookieChangeEventInit const& event_init);
|
||||
|
||||
virtual ~CookieChangeEvent() override;
|
||||
|
||||
Vector<CookieListItem> changed() const { return m_changed; }
|
||||
Vector<CookieListItem> deleted() const { return m_deleted; }
|
||||
Vector<Bindings::CookieListItem> changed() const { return m_changed; }
|
||||
Vector<Bindings::CookieListItem> deleted() const { return m_deleted; }
|
||||
|
||||
DEFINE_CACHED_ATTRIBUTE(changed);
|
||||
DEFINE_CACHED_ATTRIBUTE(deleted);
|
||||
|
||||
private:
|
||||
CookieChangeEvent(JS::Realm&, FlyString const& event_name, CookieChangeEventInit const& event_init);
|
||||
CookieChangeEvent(JS::Realm&, FlyString const& event_name, Bindings::CookieChangeEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
Vector<CookieListItem> m_changed;
|
||||
Vector<CookieListItem> m_deleted;
|
||||
Vector<Bindings::CookieListItem> m_changed;
|
||||
Vector<Bindings::CookieListItem> m_deleted;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ void CookieStore::visit_edges(Cell::Visitor& visitor)
|
|||
}
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#create-a-cookielistitem
|
||||
static CookieListItem create_a_cookie_list_item(HTTP::Cookie::Cookie const& cookie)
|
||||
static Bindings::CookieListItem create_a_cookie_list_item(HTTP::Cookie::Cookie const& cookie)
|
||||
{
|
||||
// 1. Let name be the result of running UTF-8 decode without BOM on cookie’s name.
|
||||
// 2. Let value be the result of running UTF-8 decode without BOM on cookie’s value.
|
||||
// 3. Return «[ "name" → name, "value" → value ]»
|
||||
return CookieListItem {
|
||||
return Bindings::CookieListItem {
|
||||
.name = cookie.name,
|
||||
.value = cookie.value,
|
||||
};
|
||||
|
|
@ -64,7 +64,7 @@ static String normalize(String const& input)
|
|||
}
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#query-cookies
|
||||
static Vector<CookieListItem> query_cookies(PageClient& client, URL::URL const& url, Optional<String> const& name)
|
||||
static Vector<Bindings::CookieListItem> query_cookies(PageClient& client, URL::URL const& url, Optional<String> const& name)
|
||||
{
|
||||
// 1. Perform the steps defined in Cookies § Retrieval Model to compute the "cookie-string from a given cookie store"
|
||||
// with url as request-uri. The cookie-string itself is ignored, but the intermediate cookie-list is used in subsequent steps.
|
||||
|
|
@ -72,7 +72,7 @@ static Vector<CookieListItem> query_cookies(PageClient& client, URL::URL const&
|
|||
auto cookie_list = client.page_did_request_all_cookies_cookiestore(url);
|
||||
|
||||
// 2. Let list be a new list.
|
||||
Vector<CookieListItem> list;
|
||||
Vector<Bindings::CookieListItem> list;
|
||||
|
||||
// 3. For each cookie in cookie-list, run these steps:
|
||||
for (auto const& cookie : cookie_list) {
|
||||
|
|
@ -147,7 +147,7 @@ GC::Ref<WebIDL::Promise> CookieStore::get(String name)
|
|||
}
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dom-cookiestore-get-options
|
||||
GC::Ref<WebIDL::Promise> CookieStore::get(CookieStoreGetOptions const& options)
|
||||
GC::Ref<WebIDL::Promise> CookieStore::get(Bindings::CookieStoreGetOptions const& options)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
@ -218,9 +218,9 @@ GC::Ref<WebIDL::Promise> CookieStore::get(CookieStoreGetOptions const& options)
|
|||
return promise;
|
||||
}
|
||||
|
||||
static JS::Value cookie_list_to_value(JS::Realm& realm, Vector<CookieListItem> const& cookie_list)
|
||||
static JS::Value cookie_list_to_value(JS::Realm& realm, Vector<Bindings::CookieListItem> const& cookie_list)
|
||||
{
|
||||
return JS::Array::create_from<CookieListItem>(realm, cookie_list, [&](auto const& cookie) {
|
||||
return JS::Array::create_from<Bindings::CookieListItem>(realm, cookie_list, [&](auto const& cookie) {
|
||||
return Bindings::cookie_list_item_to_value(realm, cookie);
|
||||
});
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ GC::Ref<WebIDL::Promise> CookieStore::get_all(String name)
|
|||
}
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dom-cookiestore-getall-options
|
||||
GC::Ref<WebIDL::Promise> CookieStore::get_all(CookieStoreGetOptions const& options)
|
||||
GC::Ref<WebIDL::Promise> CookieStore::get_all(Bindings::CookieStoreGetOptions const& options)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
@ -576,7 +576,7 @@ GC::Ref<WebIDL::Promise> CookieStore::set(String name, String value)
|
|||
}
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dom-cookiestore-set-options
|
||||
GC::Ref<WebIDL::Promise> CookieStore::set(CookieInit const& options)
|
||||
GC::Ref<WebIDL::Promise> CookieStore::set(Bindings::CookieInit const& options)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
@ -684,7 +684,7 @@ GC::Ref<WebIDL::Promise> CookieStore::delete_(String name)
|
|||
}
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dom-cookiestore-delete-options
|
||||
GC::Ref<WebIDL::Promise> CookieStore::delete_(CookieStoreDeleteOptions const& options)
|
||||
GC::Ref<WebIDL::Promise> CookieStore::delete_(Bindings::CookieStoreDeleteOptions const& options)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
@ -773,18 +773,18 @@ static Vector<CookieChange> observable_changes(Vector<HTTP::Cookie::Cookie> chan
|
|||
}
|
||||
|
||||
struct PreparedLists {
|
||||
Vector<CookieListItem> changed_list;
|
||||
Vector<CookieListItem> deleted_list;
|
||||
Vector<Bindings::CookieListItem> changed_list;
|
||||
Vector<Bindings::CookieListItem> deleted_list;
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#prepare-lists
|
||||
static PreparedLists prepare_lists(Vector<CookieChange> const& changes)
|
||||
{
|
||||
// 1. Let changedList be a new list.
|
||||
Vector<CookieListItem> changed_list;
|
||||
Vector<Bindings::CookieListItem> changed_list;
|
||||
|
||||
// 2. Let deletedList be a new list.
|
||||
Vector<CookieListItem> deleted_list;
|
||||
Vector<Bindings::CookieListItem> deleted_list;
|
||||
|
||||
// 3. For each change in changes, run these steps:
|
||||
for (auto const& change : changes) {
|
||||
|
|
@ -829,7 +829,7 @@ void CookieStore::process_cookie_changes(Vector<HTTP::Cookie::Cookie> all_change
|
|||
// 4. Let changedList and deletedList be the result of running prepare lists from changes.
|
||||
auto [changed_list, deleted_list] = prepare_lists(changes);
|
||||
|
||||
CookieChangeEventInit event_init = {};
|
||||
Bindings::CookieChangeEventInit event_init = {};
|
||||
// 5. Set event’s changed attribute to changedList.
|
||||
event_init.changed = move(changed_list);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,37 +16,6 @@
|
|||
|
||||
namespace Web::CookieStore {
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dictdef-cookielistitem
|
||||
struct CookieListItem {
|
||||
Optional<String> name;
|
||||
Optional<String> value;
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dictdef-cookiestoregetoptions
|
||||
struct CookieStoreGetOptions {
|
||||
Optional<String> name;
|
||||
Optional<String> url;
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dictdef-cookieinit
|
||||
struct CookieInit {
|
||||
String name;
|
||||
String value;
|
||||
Optional<HighResolutionTime::DOMHighResTimeStamp> expires;
|
||||
Optional<String> domain;
|
||||
String path;
|
||||
Bindings::CookieSameSite same_site;
|
||||
bool partitioned { false };
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#dictdef-cookiestoredeleteoptions
|
||||
struct CookieStoreDeleteOptions {
|
||||
String name;
|
||||
Optional<String> domain;
|
||||
String path;
|
||||
bool partitioned { false };
|
||||
};
|
||||
|
||||
// https://cookiestore.spec.whatwg.org/#cookiestore
|
||||
class WEB_API CookieStore final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(CookieStore, DOM::EventTarget);
|
||||
|
|
@ -54,16 +23,16 @@ class WEB_API CookieStore final : public DOM::EventTarget {
|
|||
|
||||
public:
|
||||
GC::Ref<WebIDL::Promise> get(String name);
|
||||
GC::Ref<WebIDL::Promise> get(CookieStoreGetOptions const&);
|
||||
GC::Ref<WebIDL::Promise> get(Bindings::CookieStoreGetOptions const&);
|
||||
|
||||
GC::Ref<WebIDL::Promise> get_all(String name);
|
||||
GC::Ref<WebIDL::Promise> get_all(CookieStoreGetOptions const&);
|
||||
GC::Ref<WebIDL::Promise> get_all(Bindings::CookieStoreGetOptions const&);
|
||||
|
||||
GC::Ref<WebIDL::Promise> set(String name, String value);
|
||||
GC::Ref<WebIDL::Promise> set(CookieInit const&);
|
||||
GC::Ref<WebIDL::Promise> set(Bindings::CookieInit const&);
|
||||
|
||||
GC::Ref<WebIDL::Promise> delete_(String name);
|
||||
GC::Ref<WebIDL::Promise> delete_(CookieStoreDeleteOptions const&);
|
||||
GC::Ref<WebIDL::Promise> delete_(Bindings::CookieStoreDeleteOptions const&);
|
||||
|
||||
void set_onchange(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onchange();
|
||||
|
|
@ -83,6 +52,6 @@ private:
|
|||
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS::Value cookie_list_item_to_value(JS::Realm&, CookieStore::CookieListItem const&);
|
||||
JS::Value cookie_list_item_to_value(JS::Realm&, CookieListItem const&);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ GC::Ref<CredentialsContainer> CredentialsContainer::create(JS::Realm& realm)
|
|||
CredentialsContainer::~CredentialsContainer() { }
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-get
|
||||
GC::Ref<WebIDL::Promise> CredentialsContainer::get(CredentialRequestOptions const&)
|
||||
GC::Ref<WebIDL::Promise> CredentialsContainer::get(Bindings::CredentialRequestOptions const&)
|
||||
{
|
||||
auto* realm = vm().current_realm();
|
||||
return WebIDL::create_rejected_promise_from_exception(*realm, vm().throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "get"sv));
|
||||
|
|
@ -32,7 +32,7 @@ GC::Ref<WebIDL::Promise> CredentialsContainer::store(Credential const&)
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-credentialscontainer-create
|
||||
GC::Ref<WebIDL::Promise> CredentialsContainer::create(CredentialCreationOptions const&)
|
||||
GC::Ref<WebIDL::Promise> CredentialsContainer::create(Bindings::CredentialCreationOptions const&)
|
||||
{
|
||||
auto* realm = vm().current_realm();
|
||||
return WebIDL::create_rejected_promise_from_exception(*realm, vm().throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "create"sv));
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ public:
|
|||
|
||||
virtual ~CredentialsContainer() override;
|
||||
|
||||
GC::Ref<WebIDL::Promise> get(CredentialRequestOptions const& options);
|
||||
GC::Ref<WebIDL::Promise> get(Bindings::CredentialRequestOptions const& options);
|
||||
GC::Ref<WebIDL::Promise> store(Credential const& credential);
|
||||
GC::Ref<WebIDL::Promise> create(CredentialCreationOptions const& options);
|
||||
GC::Ref<WebIDL::Promise> create(Bindings::CredentialCreationOptions const& options);
|
||||
GC::Ref<WebIDL::Promise> prevent_silent_access();
|
||||
|
||||
private:
|
||||
|
|
@ -36,20 +36,4 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
struct CredentialRequestOptions {
|
||||
Bindings::CredentialMediationRequirement mediation { Bindings::CredentialMediationRequirement::Optional };
|
||||
GC::Ptr<DOM::AbortSignal> signal;
|
||||
|
||||
Optional<bool> password;
|
||||
Optional<FederatedCredentialRequestOptions> federated;
|
||||
};
|
||||
|
||||
struct CredentialCreationOptions {
|
||||
Bindings::CredentialMediationRequirement mediation { Bindings::CredentialMediationRequirement::Optional };
|
||||
GC::Ptr<DOM::AbortSignal> signal;
|
||||
|
||||
Optional<PasswordCredentialInit> password;
|
||||
Optional<FederatedCredentialInit> federated;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Web::CredentialManagement {
|
|||
GC_DEFINE_ALLOCATOR(FederatedCredential);
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-federatedcredential-federatedcredential
|
||||
WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> FederatedCredential::construct_impl(JS::Realm& realm, FederatedCredentialInit const& data)
|
||||
WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> FederatedCredential::construct_impl(JS::Realm& realm, Bindings::FederatedCredentialInit const& data)
|
||||
{
|
||||
// 1. Let r be the result of executing Create a FederatedCredential from FederatedCredentialInit on data. If that
|
||||
// threw an exception, rethrow that exception.
|
||||
|
|
@ -25,7 +25,7 @@ FederatedCredential::~FederatedCredential()
|
|||
{
|
||||
}
|
||||
|
||||
FederatedCredential::FederatedCredential(JS::Realm& realm, FederatedCredentialInit const& init, URL::Origin origin)
|
||||
FederatedCredential::FederatedCredential(JS::Realm& realm, Bindings::FederatedCredentialInit const& init, URL::Origin origin)
|
||||
: Credential(realm, init.id)
|
||||
, CredentialUserData(init.name.value_or(String {}), init.icon_url.value_or(String {}))
|
||||
, m_provider(init.provider)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class FederatedCredential final
|
|||
GC_DECLARE_ALLOCATOR(FederatedCredential);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> construct_impl(JS::Realm&, FederatedCredentialInit const&);
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> construct_impl(JS::Realm&, Bindings::FederatedCredentialInit const&);
|
||||
|
||||
virtual ~FederatedCredential() override;
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
String type() const override { return "federated"_string; }
|
||||
|
||||
private:
|
||||
FederatedCredential(JS::Realm&, FederatedCredentialInit const&, URL::Origin);
|
||||
FederatedCredential(JS::Realm&, Bindings::FederatedCredentialInit const&, URL::Origin);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
String m_provider;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
namespace Web::CredentialManagement {
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#abstract-opdef-create-a-federatedcredential-from-federatedcredentialinit
|
||||
WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> create_federated_credential(JS::Realm& realm, FederatedCredentialInit const& init)
|
||||
WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> create_federated_credential(JS::Realm& realm, Bindings::FederatedCredentialInit const& init)
|
||||
{
|
||||
// 1. Let c be a new FederatedCredential object.
|
||||
// 2. If any of the following are the empty string, throw a TypeError exception:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Web::CredentialManagement {
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> create_federated_credential(JS::Realm& realm, FederatedCredentialInit const&);
|
||||
WebIDL::ExceptionOr<GC::Ref<FederatedCredential>> create_federated_credential(JS::Realm& realm, Bindings::FederatedCredentialInit const&);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> PasswordCredential::construct_i
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-passwordcredential-passwordcredential-data
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> PasswordCredential::construct_impl(JS::Realm& realm, PasswordCredentialData const& data)
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> PasswordCredential::construct_impl(JS::Realm& realm, Bindings::PasswordCredentialData const& data)
|
||||
{
|
||||
// AD-HOC: Let origin be the current settings object's origin.
|
||||
auto origin = HTML::current_settings_object().origin();
|
||||
|
|
@ -37,7 +37,7 @@ PasswordCredential::~PasswordCredential()
|
|||
{
|
||||
}
|
||||
|
||||
PasswordCredential::PasswordCredential(JS::Realm& realm, PasswordCredentialData const& data, URL::Origin origin)
|
||||
PasswordCredential::PasswordCredential(JS::Realm& realm, Bindings::PasswordCredentialData const& data, URL::Origin origin)
|
||||
: Credential(realm, data.id)
|
||||
, CredentialUserData(data.name.value_or(String {}), data.icon_url.value_or(String {}))
|
||||
, m_password(data.password)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PasswordCredential final
|
|||
|
||||
public:
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> construct_impl(JS::Realm&, GC::Ref<HTML::HTMLFormElement>);
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> construct_impl(JS::Realm&, PasswordCredentialData const&);
|
||||
[[nodiscard]] static WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> construct_impl(JS::Realm&, Bindings::PasswordCredentialData const&);
|
||||
|
||||
virtual ~PasswordCredential() override;
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ public:
|
|||
String type() const override { return "password"_string; }
|
||||
|
||||
private:
|
||||
PasswordCredential(JS::Realm&, PasswordCredentialData const&, URL::Origin);
|
||||
PasswordCredential(JS::Realm&, Bindings::PasswordCredentialData const&, URL::Origin);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
// TODO: Use Core::SecretString when it comes back
|
||||
|
|
@ -44,14 +44,7 @@ private:
|
|||
URL::Origin m_origin;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dictdef-passwordcredentialdata
|
||||
struct PasswordCredentialData : CredentialData {
|
||||
Optional<String> name;
|
||||
Optional<String> icon_url;
|
||||
String password;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#typedefdef-passwordcredentialinit
|
||||
using PasswordCredentialInit = Variant<PasswordCredentialData, GC::Root<HTML::HTMLFormElement>>;
|
||||
using PasswordCredentialInit = Variant<Bindings::PasswordCredentialData, GC::Root<HTML::HTMLFormElement>>;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Web::CredentialManagement {
|
|||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::Realm& realm, GC::Ref<HTML::HTMLFormElement> form, URL::Origin origin)
|
||||
{
|
||||
// 1. Let data be a new PasswordCredentialData dictionary.
|
||||
PasswordCredentialData data;
|
||||
Bindings::PasswordCredentialData data;
|
||||
|
||||
// 2. Set data’s origin member’s value to origin’s value.
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#abstract-opdef-create-a-passwordcredential-from-passwordcredentialdata
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::Realm& realm, PasswordCredentialData const& data, URL::Origin origin)
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::Realm& realm, Bindings::PasswordCredentialData const& data, URL::Origin origin)
|
||||
{
|
||||
// 1. Let c be a new PasswordCredential object.
|
||||
// 2. If any of the following are the empty string, throw a TypeError exception:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
namespace Web::CredentialManagement {
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::Realm& realm, GC::Ref<HTML::HTMLFormElement>, URL::Origin);
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::Realm& realm, PasswordCredentialData const&, URL::Origin);
|
||||
WebIDL::ExceptionOr<GC::Ref<PasswordCredential>> create_password_credential(JS::Realm& realm, Bindings::PasswordCredentialData const&, URL::Origin);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,44 @@ static void normalize_key_usages(Vector<Bindings::KeyUsage>& key_usages)
|
|||
{
|
||||
quick_sort(key_usages);
|
||||
}
|
||||
|
||||
static JsonWebKey to_internal_json_web_key(Bindings::JsonWebKey bindings_jwk)
|
||||
{
|
||||
JsonWebKey jwk;
|
||||
jwk.alg = move(bindings_jwk.alg);
|
||||
jwk.crv = move(bindings_jwk.crv);
|
||||
jwk.d = move(bindings_jwk.d);
|
||||
jwk.dp = move(bindings_jwk.dp);
|
||||
jwk.dq = move(bindings_jwk.dq);
|
||||
jwk.e = move(bindings_jwk.e);
|
||||
jwk.ext = move(bindings_jwk.ext);
|
||||
jwk.k = move(bindings_jwk.k);
|
||||
jwk.key_ops = move(bindings_jwk.key_ops);
|
||||
jwk.kty = move(bindings_jwk.kty);
|
||||
jwk.n = move(bindings_jwk.n);
|
||||
if (bindings_jwk.oth.has_value()) {
|
||||
Vector<RsaOtherPrimesInfo> oth;
|
||||
oth.ensure_capacity(bindings_jwk.oth->size());
|
||||
for (auto& bindings_prime : *bindings_jwk.oth) {
|
||||
oth.append({
|
||||
.r = move(bindings_prime.r),
|
||||
.d = move(bindings_prime.d),
|
||||
.t = move(bindings_prime.t),
|
||||
});
|
||||
}
|
||||
jwk.oth = move(oth);
|
||||
}
|
||||
jwk.p = move(bindings_jwk.p);
|
||||
jwk.priv = move(bindings_jwk.priv);
|
||||
jwk.pub = move(bindings_jwk.pub);
|
||||
jwk.q = move(bindings_jwk.q);
|
||||
jwk.qi = move(bindings_jwk.qi);
|
||||
jwk.use = move(bindings_jwk.use);
|
||||
jwk.x = move(bindings_jwk.x);
|
||||
jwk.y = move(bindings_jwk.y);
|
||||
return jwk;
|
||||
}
|
||||
|
||||
struct RegisteredAlgorithm {
|
||||
NonnullOwnPtr<AlgorithmMethods> (*create_methods)(JS::Realm&) = nullptr;
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> (*parameter_from_value)(JS::VM&, JS::Value) = nullptr;
|
||||
|
|
@ -409,7 +447,7 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::generate_key(AlgorithmIdentifier algorith
|
|||
}
|
||||
|
||||
// https://w3c.github.io/webcrypto/#SubtleCrypto-method-importKey
|
||||
JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> SubtleCrypto::import_key(Bindings::KeyFormat format, KeyDataType key_data, AlgorithmIdentifier algorithm, bool extractable, Vector<Bindings::KeyUsage> key_usages)
|
||||
JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> SubtleCrypto::import_key(Bindings::KeyFormat format, Variant<GC::Root<WebIDL::BufferSource>, Bindings::JsonWebKey> key_data, AlgorithmIdentifier algorithm, bool extractable, Vector<Bindings::KeyUsage> key_usages)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
|
@ -426,7 +464,7 @@ JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> SubtleCrypto::import_key(Binding
|
|||
|| format == Bindings::KeyFormat::Pkcs8
|
||||
|| format == Bindings::KeyFormat::Spki) {
|
||||
// 1. If the keyData parameter passed to the importKey() method is a JsonWebKey dictionary, throw a TypeError.
|
||||
if (key_data.has<JsonWebKey>()) {
|
||||
if (key_data.has<Bindings::JsonWebKey>()) {
|
||||
return realm.vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
}
|
||||
|
||||
|
|
@ -436,12 +474,12 @@ JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> SubtleCrypto::import_key(Binding
|
|||
|
||||
if (format == Bindings::KeyFormat::Jwk) {
|
||||
// 1. If the keyData parameter passed to the importKey() method is not a JsonWebKey dictionary, throw a TypeError.
|
||||
if (!key_data.has<JsonWebKey>()) {
|
||||
if (!key_data.has<Bindings::JsonWebKey>()) {
|
||||
return realm.vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "JsonWebKey");
|
||||
}
|
||||
|
||||
// 2. Let keyData be the keyData parameter passed to the importKey() method.
|
||||
real_key_data = key_data.get<JsonWebKey>();
|
||||
real_key_data = to_internal_json_web_key(key_data.get<Bindings::JsonWebKey>());
|
||||
}
|
||||
|
||||
// NOTE: The spec jumps to 5 here for some reason?
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public:
|
|||
GC::Ref<WebIDL::Promise> derive_bits(AlgorithmIdentifier algorithm, GC::Ref<CryptoKey> base_key, Optional<u32> length_optional);
|
||||
GC::Ref<WebIDL::Promise> derive_key(AlgorithmIdentifier algorithm, GC::Ref<CryptoKey> base_key, AlgorithmIdentifier derived_key_type, bool extractable, Vector<Bindings::KeyUsage> key_usages);
|
||||
|
||||
JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> import_key(Bindings::KeyFormat format, KeyDataType key_data, AlgorithmIdentifier algorithm, bool extractable, Vector<Bindings::KeyUsage> key_usages);
|
||||
JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> import_key(Bindings::KeyFormat format, Variant<GC::Root<WebIDL::BufferSource>, Bindings::JsonWebKey> key_data, AlgorithmIdentifier algorithm, bool extractable, Vector<Bindings::KeyUsage> key_usages);
|
||||
GC::Ref<WebIDL::Promise> export_key(Bindings::KeyFormat format, GC::Ref<CryptoKey> key);
|
||||
|
||||
GC::Ref<WebIDL::Promise> wrap_key(Bindings::KeyFormat format, GC::Ref<CryptoKey> key, GC::Ref<CryptoKey> wrapping_key, AlgorithmIdentifier wrap_algorithm);
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ namespace Web::DOM {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CustomEvent);
|
||||
|
||||
GC::Ref<CustomEvent> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
GC::Ref<CustomEvent> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, Bindings::CustomEventInit const& event_init)
|
||||
{
|
||||
return realm.create<CustomEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<CustomEvent>> CustomEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<CustomEvent>> CustomEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::CustomEventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
CustomEvent::CustomEvent(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||
CustomEvent::CustomEvent(JS::Realm& realm, FlyString const& event_name, Bindings::CustomEventInit const& event_init)
|
||||
: Event(realm, event_name, event_init)
|
||||
, m_detail(event_init.detail)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,23 +8,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/Bindings/CustomEvent.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/Export.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
struct CustomEventInit : public EventInit {
|
||||
JS::Value detail { JS::js_null() };
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#customevent
|
||||
class WEB_API CustomEvent : public Event {
|
||||
WEB_PLATFORM_OBJECT(CustomEvent, Event);
|
||||
GC_DECLARE_ALLOCATOR(CustomEvent);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<CustomEvent> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const&);
|
||||
[[nodiscard]] static GC::Ref<CustomEvent> create(JS::Realm&, FlyString const& event_name, Bindings::CustomEventInit const& = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::CustomEventInit const&);
|
||||
|
||||
virtual ~CustomEvent() override;
|
||||
|
||||
|
|
@ -37,7 +34,7 @@ public:
|
|||
void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail);
|
||||
|
||||
private:
|
||||
CustomEvent(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init);
|
||||
CustomEvent(JS::Realm&, FlyString const& event_name, Bindings::CustomEventInit const& event_init);
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
|
||||
JS::Value m_detail { JS::js_null() };
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <LibURL/Origin.h>
|
||||
#include <LibWeb/Bindings/DOMImplementation.h>
|
||||
#include <LibWeb/Bindings/Document.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/DOM/DOMImplementation.h>
|
||||
|
|
@ -60,7 +61,7 @@ WebIDL::ExceptionOr<GC::Ref<XMLDocument>> DOMImplementation::create_document(Opt
|
|||
|
||||
// 3. If qualifiedName is not the empty string, then set element to the result of running the internal createElementNS steps, given document, namespace, qualifiedName, and an empty dictionary.
|
||||
if (!qualified_name.is_empty())
|
||||
element = TRY(xml_document->create_element_ns(namespace_, qualified_name, ElementCreationOptions {}));
|
||||
element = TRY(xml_document->create_element_ns(namespace_, qualified_name, Bindings::ElementCreationOptions {}));
|
||||
|
||||
// 4. If doctype is non-null, append doctype to document.
|
||||
if (doctype)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <LibWeb/Animations/DocumentTimeline.h>
|
||||
#include <LibWeb/Animations/TimeValue.h>
|
||||
#include <LibWeb/Bindings/Document.h>
|
||||
#include <LibWeb/Bindings/IntersectionObserver.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
||||
#include <LibWeb/CSS/AnimationEvent.h>
|
||||
|
|
@ -2232,11 +2233,11 @@ void Document::set_hovered_node(GC::Ptr<Node> node)
|
|||
|
||||
// https://w3c.github.io/pointerevents/#the-pointerout-event
|
||||
if (old_hovered_node && old_hovered_node != m_hovered_node) {
|
||||
UIEvents::PointerEventInit pointer_event_init {};
|
||||
Bindings::PointerEventInit pointer_event_init {};
|
||||
pointer_event_init.bubbles = true;
|
||||
pointer_event_init.cancelable = true;
|
||||
pointer_event_init.composed = true;
|
||||
pointer_event_init.related_target = m_hovered_node;
|
||||
pointer_event_init.related_target = GC::Root<DOM::EventTarget> { m_hovered_node.ptr() };
|
||||
pointer_event_init.is_primary = true;
|
||||
pointer_event_init.pointer_type = UIEvents::PointerTypes::Mouse;
|
||||
if (auto navigable = this->navigable())
|
||||
|
|
@ -2247,11 +2248,11 @@ void Document::set_hovered_node(GC::Ptr<Node> node)
|
|||
|
||||
// https://w3c.github.io/uievents/#mouseout
|
||||
if (old_hovered_node && old_hovered_node != m_hovered_node) {
|
||||
UIEvents::MouseEventInit mouse_event_init {};
|
||||
Bindings::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.bubbles = true;
|
||||
mouse_event_init.cancelable = true;
|
||||
mouse_event_init.composed = true;
|
||||
mouse_event_init.related_target = m_hovered_node;
|
||||
mouse_event_init.related_target = GC::Root<DOM::EventTarget> { m_hovered_node.ptr() };
|
||||
if (auto navigable = this->navigable())
|
||||
mouse_event_init.view = navigable->active_window_proxy();
|
||||
auto event = UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseout, mouse_event_init);
|
||||
|
|
@ -2262,8 +2263,8 @@ void Document::set_hovered_node(GC::Ptr<Node> node)
|
|||
if (old_hovered_node && (!m_hovered_node || !m_hovered_node->is_descendant_of(*old_hovered_node))) {
|
||||
for (auto target = old_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) {
|
||||
// FIXME: Populate the event with mouse coordinates, etc.
|
||||
UIEvents::PointerEventInit pointer_event_init {};
|
||||
pointer_event_init.related_target = m_hovered_node;
|
||||
Bindings::PointerEventInit pointer_event_init {};
|
||||
pointer_event_init.related_target = GC::Root<DOM::EventTarget> { m_hovered_node.ptr() };
|
||||
pointer_event_init.is_primary = true;
|
||||
pointer_event_init.pointer_type = UIEvents::PointerTypes::Mouse;
|
||||
if (auto navigable = this->navigable())
|
||||
|
|
@ -2276,19 +2277,19 @@ void Document::set_hovered_node(GC::Ptr<Node> node)
|
|||
if (old_hovered_node && (!m_hovered_node || !m_hovered_node->is_descendant_of(*old_hovered_node))) {
|
||||
for (auto target = old_hovered_node; target && target.ptr() != common_ancestor; target = target->parent_or_shadow_host()) {
|
||||
// FIXME: Populate the event with mouse coordinates, etc.
|
||||
UIEvents::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.related_target = m_hovered_node;
|
||||
Bindings::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.related_target = GC::Root<DOM::EventTarget> { m_hovered_node.ptr() };
|
||||
target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave, mouse_event_init));
|
||||
}
|
||||
}
|
||||
|
||||
// https://w3c.github.io/pointerevents/#the-pointerover-event
|
||||
if (m_hovered_node && m_hovered_node != old_hovered_node) {
|
||||
UIEvents::PointerEventInit pointer_event_init {};
|
||||
Bindings::PointerEventInit pointer_event_init {};
|
||||
pointer_event_init.bubbles = true;
|
||||
pointer_event_init.cancelable = true;
|
||||
pointer_event_init.composed = true;
|
||||
pointer_event_init.related_target = old_hovered_node;
|
||||
pointer_event_init.related_target = GC::Root<DOM::EventTarget> { old_hovered_node.ptr() };
|
||||
pointer_event_init.is_primary = true;
|
||||
pointer_event_init.pointer_type = UIEvents::PointerTypes::Mouse;
|
||||
if (auto navigable = this->navigable())
|
||||
|
|
@ -2299,11 +2300,11 @@ void Document::set_hovered_node(GC::Ptr<Node> node)
|
|||
|
||||
// https://w3c.github.io/uievents/#mouseover
|
||||
if (m_hovered_node && m_hovered_node != old_hovered_node) {
|
||||
UIEvents::MouseEventInit mouse_event_init {};
|
||||
Bindings::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.bubbles = true;
|
||||
mouse_event_init.cancelable = true;
|
||||
mouse_event_init.composed = true;
|
||||
mouse_event_init.related_target = old_hovered_node;
|
||||
mouse_event_init.related_target = GC::Root<DOM::EventTarget> { old_hovered_node.ptr() };
|
||||
if (auto navigable = this->navigable())
|
||||
mouse_event_init.view = navigable->active_window_proxy();
|
||||
auto event = UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseover, mouse_event_init);
|
||||
|
|
@ -2321,15 +2322,15 @@ void Document::set_hovered_node(GC::Ptr<Node> node)
|
|||
|
||||
for (auto target : entered_ancestors.in_reverse()) {
|
||||
// FIXME: Populate the events with mouse coordinates, etc.
|
||||
UIEvents::PointerEventInit pointer_event_init {};
|
||||
pointer_event_init.related_target = old_hovered_node;
|
||||
Bindings::PointerEventInit pointer_event_init {};
|
||||
pointer_event_init.related_target = GC::Root<DOM::EventTarget> { old_hovered_node.ptr() };
|
||||
pointer_event_init.is_primary = true;
|
||||
pointer_event_init.pointer_type = UIEvents::PointerTypes::Mouse;
|
||||
if (auto navigable = this->navigable())
|
||||
pointer_event_init.view = navigable->active_window_proxy();
|
||||
target->dispatch_event(UIEvents::PointerEvent::create(realm(), UIEvents::EventNames::pointerenter, pointer_event_init));
|
||||
UIEvents::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.related_target = old_hovered_node;
|
||||
Bindings::MouseEventInit mouse_event_init {};
|
||||
mouse_event_init.related_target = GC::Root<DOM::EventTarget> { old_hovered_node.ptr() };
|
||||
target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter, mouse_event_init));
|
||||
}
|
||||
}
|
||||
|
|
@ -2484,7 +2485,7 @@ HTML::EnvironmentSettingsObject& Document::relevant_settings_object() const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createelement
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> Document::create_element(String const& local_name, Variant<String, ElementCreationOptions> const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> Document::create_element(String const& local_name, Variant<String, Bindings::ElementCreationOptions> const& options)
|
||||
{
|
||||
// 1. If localName is not a valid element local name, then throw an "InvalidCharacterError" DOMException.
|
||||
if (!is_valid_element_local_name(local_name))
|
||||
|
|
@ -2510,7 +2511,7 @@ WebIDL::ExceptionOr<GC::Ref<Element>> Document::create_element(String const& loc
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createelementns
|
||||
// https://dom.spec.whatwg.org/#internal-createelementns-steps
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> Document::create_element_ns(Optional<FlyString> const& namespace_, String const& qualified_name, Variant<String, ElementCreationOptions> const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> Document::create_element_ns(Optional<FlyString> const& namespace_, String const& qualified_name, Variant<String, Bindings::ElementCreationOptions> const& options)
|
||||
{
|
||||
// 1. Let (namespace, prefix, localName) be the result of validating and extracting namespace and qualifiedName
|
||||
// given "element".
|
||||
|
|
@ -2717,7 +2718,7 @@ Vector<GC::Root<HTML::HTMLScriptElement>> Document::take_scripts_to_execute_in_o
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-importnode
|
||||
WebIDL::ExceptionOr<GC::Ref<Node>> Document::import_node(GC::Ref<Node> node, Variant<bool, ImportNodeOptions> options)
|
||||
WebIDL::ExceptionOr<GC::Ref<Node>> Document::import_node(GC::Ref<Node> node, Variant<bool, Bindings::ImportNodeOptions> options)
|
||||
{
|
||||
// 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException.
|
||||
if (is<Document>(*node) || is<ShadowRoot>(*node))
|
||||
|
|
@ -2736,13 +2737,13 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Document::import_node(GC::Ref<Node> node, Var
|
|||
return {};
|
||||
},
|
||||
// 5. Otherwise:
|
||||
[&subtree, ®istry, this](ImportNodeOptions const& options) -> WebIDL::ExceptionOr<void> {
|
||||
[&subtree, ®istry, this](Bindings::ImportNodeOptions const& options) -> WebIDL::ExceptionOr<void> {
|
||||
// 1. Set subtree to the negation of options["selfOnly"].
|
||||
subtree = !options.self_only;
|
||||
|
||||
// 2. If options["customElementRegistry"] exists, then set registry to it.
|
||||
if (options.custom_element_registry)
|
||||
registry = options.custom_element_registry;
|
||||
if (options.custom_element_registry.has_value())
|
||||
registry = options.custom_element_registry->ptr();
|
||||
|
||||
// 3. If registry’s is scoped is false and registry is not this’s custom element registry, then throw a
|
||||
// "NotSupportedError" DOMException.
|
||||
|
|
@ -2933,7 +2934,7 @@ void Document::set_focused_area(GC::Ptr<Node> node)
|
|||
new_focused_element->queue_an_element_task(HTML::Task::Source::UserInteraction, [new_focused_element] {
|
||||
if (new_focused_element->document().focused_area().ptr() != new_focused_element)
|
||||
return;
|
||||
ScrollIntoViewOptions scroll_options;
|
||||
Bindings::ScrollIntoViewOptions scroll_options;
|
||||
scroll_options.block = Bindings::ScrollLogicalPosition::Nearest;
|
||||
scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest;
|
||||
(void)new_focused_element->scroll_into_view(scroll_options);
|
||||
|
|
@ -3228,19 +3229,20 @@ void Document::dispatch_events_for_transition(GC::Ref<CSS::CSSTransition> transi
|
|||
break;
|
||||
}
|
||||
|
||||
Bindings::TransitionEventInit event_init {};
|
||||
event_init.bubbles = true;
|
||||
event_init.property_name = MUST(String::from_utf8(transition->transition_property()));
|
||||
event_init.elapsed_time = elapsed_time_output;
|
||||
event_init.pseudo_element = transition->owning_element()->pseudo_element().map([](auto it) {
|
||||
return MUST(String::formatted("::{}", CSS::pseudo_element_name(it)));
|
||||
})
|
||||
.value_or({});
|
||||
|
||||
append_pending_animation_event({
|
||||
.event = CSS::TransitionEvent::create(
|
||||
transition->owning_element()->element().realm(),
|
||||
type,
|
||||
CSS::TransitionEventInit {
|
||||
{ .bubbles = true },
|
||||
MUST(String::from_utf8(transition->transition_property())),
|
||||
elapsed_time_output,
|
||||
transition->owning_element()->pseudo_element().map([](auto it) {
|
||||
return MUST(String::formatted("::{}", CSS::pseudo_element_name(it)));
|
||||
})
|
||||
.value_or({}),
|
||||
}),
|
||||
event_init),
|
||||
.animation = transition,
|
||||
.target = transition->owning_element()->element(),
|
||||
.scheduled_event_time = HighResolutionTime::unsafe_shared_current_time(),
|
||||
|
|
@ -3332,19 +3334,20 @@ void Document::dispatch_events_for_animation_if_necessary(GC::Ref<Animations::An
|
|||
break;
|
||||
}
|
||||
|
||||
Bindings::AnimationEventInit event_init {};
|
||||
event_init.bubbles = true;
|
||||
event_init.animation_name = static_cast<String>(css_animation.animation_name());
|
||||
event_init.elapsed_time = elapsed_time_output;
|
||||
event_init.pseudo_element = owning_element->pseudo_element().map([](auto it) {
|
||||
return MUST(String::formatted("::{}", CSS::pseudo_element_name(it)));
|
||||
})
|
||||
.value_or({});
|
||||
|
||||
append_pending_animation_event({
|
||||
.event = CSS::AnimationEvent::create(
|
||||
owning_element->element().realm(),
|
||||
name,
|
||||
{
|
||||
{ .bubbles = true },
|
||||
css_animation.animation_name(),
|
||||
elapsed_time_output,
|
||||
owning_element->pseudo_element().map([](auto it) {
|
||||
return MUST(String::formatted("::{}", CSS::pseudo_element_name(it)));
|
||||
})
|
||||
.value_or({}),
|
||||
}),
|
||||
event_init),
|
||||
.animation = css_animation,
|
||||
.target = *target,
|
||||
.scheduled_event_time = HighResolutionTime::unsafe_shared_current_time(),
|
||||
|
|
@ -3450,7 +3453,7 @@ void Document::scroll_to_the_fragment()
|
|||
// FIXME: 4. Run the ancestor revealing algorithm on target.
|
||||
|
||||
// 5. Scroll target into view, with behavior set to "auto", block set to "start", and inline set to "nearest". [CSSOMVIEW]
|
||||
ScrollIntoViewOptions scroll_options;
|
||||
Bindings::ScrollIntoViewOptions scroll_options;
|
||||
scroll_options.block = Bindings::ScrollLogicalPosition::Start;
|
||||
scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest;
|
||||
(void)target->scroll_into_view(scroll_options);
|
||||
|
|
@ -4041,7 +4044,7 @@ void Document::evaluate_media_queries_and_report_changes()
|
|||
media_query_list->set_has_changed_state(false);
|
||||
|
||||
if (did_change_internally == true || did_match != now_matches) {
|
||||
CSS::MediaQueryListEventInit init;
|
||||
Bindings::MediaQueryListEventInit init;
|
||||
init.media = media_query_list->media();
|
||||
init.matches = now_matches;
|
||||
auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init);
|
||||
|
|
@ -5678,7 +5681,7 @@ void Document::start_intersection_observing_a_lazy_loading_element(Element& elem
|
|||
|
||||
// FIXME: The options is an IntersectionObserverInit dictionary with the following dictionary members: «[ "rootMargin" → lazy load root margin ]»
|
||||
// Spec Note: This allows for fetching the image during scrolling, when it does not yet — but is about to — intersect the viewport.
|
||||
auto options = IntersectionObserver::IntersectionObserverInit {};
|
||||
auto options = Bindings::IntersectionObserverInit {};
|
||||
|
||||
auto wrapped_callback = realm.heap().allocate<WebIDL::CallbackType>(callback, realm);
|
||||
m_lazy_load_intersection_observer = IntersectionObserver::IntersectionObserver::construct_impl(realm, wrapped_callback, options).release_value_but_fixme_should_propagate_errors();
|
||||
|
|
@ -5961,7 +5964,7 @@ void Document::update_for_history_step_application(NonnullRefPtr<HTML::SessionHi
|
|||
// with the state attribute initialized to document's history object's state and hasUAVisualTransition initialized to true
|
||||
// if a visual transition, to display a cached rendered state of the latest entry, was done by the user agent.
|
||||
// FIXME: Initialise hasUAVisualTransition
|
||||
HTML::PopStateEventInit popstate_event_init;
|
||||
Bindings::PopStateEventInit popstate_event_init;
|
||||
popstate_event_init.state = history()->unsafe_state();
|
||||
auto& relevant_global_object = as<HTML::Window>(HTML::relevant_global_object(*this));
|
||||
auto pop_state_event = HTML::PopStateEvent::create(realm(), "popstate"_fly_string, popstate_event_init);
|
||||
|
|
@ -5974,7 +5977,7 @@ void Document::update_for_history_step_application(NonnullRefPtr<HTML::SessionHi
|
|||
// using HashChangeEvent, with the oldURL attribute initialized to the serialization of oldURL and the newURL attribute
|
||||
// initialized to the serialization of entry's URL.
|
||||
if (old_url.fragment() != entry->url().fragment()) {
|
||||
HTML::HashChangeEventInit hashchange_event_init;
|
||||
Bindings::HashChangeEventInit hashchange_event_init;
|
||||
hashchange_event_init.old_url = old_url.serialize();
|
||||
hashchange_event_init.new_url = entry->url().serialize();
|
||||
auto hashchange_event = HTML::HashChangeEvent::create(realm(), "hashchange"_fly_string, hashchange_event_init);
|
||||
|
|
@ -6216,7 +6219,7 @@ void Document::remove_replaced_animations()
|
|||
// - Set removeEvent’s currentTime attribute to the current time of animation.
|
||||
// - Set removeEvent’s timelineTime attribute to the current time of the timeline with which animation is
|
||||
// associated.
|
||||
Animations::AnimationPlaybackEventInit init;
|
||||
Bindings::AnimationPlaybackEventInit init;
|
||||
init.current_time = animation->current_time().has_value() ? Animations::NullableCSSNumberish { animation->current_time()->as_css_numberish(realm()) } : Animations::NullableCSSNumberish { Empty {} };
|
||||
init.timeline_time = animation->timeline()->current_time().has_value() ? Animations::NullableCSSNumberish { animation->timeline()->current_time()->as_css_numberish(realm()) } : Animations::NullableCSSNumberish { Empty {} };
|
||||
auto remove_event = Animations::AnimationPlaybackEvent::create(realm(), HTML::EventNames::remove, init);
|
||||
|
|
@ -7155,10 +7158,10 @@ void Document::run_fullscreen_steps()
|
|||
// 2. Fire an event named type, with its bubbles and composed attributes set to true, at target.
|
||||
switch (type) {
|
||||
case PendingFullscreenEvent::Type::Change:
|
||||
target->dispatch_event(Event::create(realm(), HTML::EventNames::fullscreenchange, EventInit { .bubbles = true, .composed = true }));
|
||||
target->dispatch_event(Event::create(realm(), HTML::EventNames::fullscreenchange, Bindings::EventInit { .bubbles = true, .composed = true }));
|
||||
break;
|
||||
case PendingFullscreenEvent::Type::Error:
|
||||
target->dispatch_event(Event::create(realm(), HTML::EventNames::fullscreenerror, EventInit { .bubbles = true, .composed = true }));
|
||||
target->dispatch_event(Event::create(realm(), HTML::EventNames::fullscreenerror, Bindings::EventInit { .bubbles = true, .composed = true }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -7725,7 +7728,7 @@ void Document::run_csp_initialization() const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#flatten-element-creation-options
|
||||
WebIDL::ExceptionOr<Document::RegistryAndIs> Document::flatten_element_creation_options(Variant<String, ElementCreationOptions> const& options) const
|
||||
WebIDL::ExceptionOr<Document::RegistryAndIs> Document::flatten_element_creation_options(Variant<String, Bindings::ElementCreationOptions> const& options) const
|
||||
{
|
||||
// 1. Let registry be the result of looking up a custom element registry given document.
|
||||
GC::Ptr<HTML::CustomElementRegistry> registry = HTML::look_up_a_custom_element_registry(*this);
|
||||
|
|
@ -7734,7 +7737,7 @@ WebIDL::ExceptionOr<Document::RegistryAndIs> Document::flatten_element_creation_
|
|||
Optional<String> is;
|
||||
|
||||
// 3. If options is a dictionary:
|
||||
if (auto* dictionary = options.get_pointer<ElementCreationOptions>()) {
|
||||
if (auto* dictionary = options.get_pointer<Bindings::ElementCreationOptions>()) {
|
||||
// 1. If options["is"] exists, then set is to it.
|
||||
if (dictionary->is.has_value())
|
||||
is = dictionary->is;
|
||||
|
|
|
|||
|
|
@ -165,18 +165,6 @@ struct DocumentUnloadTimingInfo {
|
|||
double unload_event_end_time { 0 };
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#dictdef-elementcreationoptions
|
||||
struct ElementCreationOptions {
|
||||
Optional<GC::Ptr<HTML::CustomElementRegistry>> custom_element_registry;
|
||||
Optional<String> is;
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#dictdef-importnodeoptions
|
||||
struct ImportNodeOptions {
|
||||
GC::Ptr<HTML::CustomElementRegistry> custom_element_registry;
|
||||
bool self_only = false;
|
||||
};
|
||||
|
||||
enum class PolicyControlledFeature : u8 {
|
||||
Autoplay,
|
||||
Camera,
|
||||
|
|
@ -430,8 +418,8 @@ public:
|
|||
|
||||
HTML::EnvironmentSettingsObject& relevant_settings_object() const;
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> create_element(String const& local_name, Variant<String, ElementCreationOptions> const& options);
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> create_element_ns(Optional<FlyString> const& namespace_, String const& qualified_name, Variant<String, ElementCreationOptions> const& options);
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> create_element(String const& local_name, Variant<String, Bindings::ElementCreationOptions> const& options);
|
||||
WebIDL::ExceptionOr<GC::Ref<Element>> create_element_ns(Optional<FlyString> const& namespace_, String const& qualified_name, Variant<String, Bindings::ElementCreationOptions> const& options);
|
||||
GC::Ref<DocumentFragment> create_document_fragment();
|
||||
GC::Ref<Text> create_text_node(Utf16String data);
|
||||
WebIDL::ExceptionOr<GC::Ref<CDATASection>> create_cdata_section(Utf16String data);
|
||||
|
|
@ -485,7 +473,7 @@ public:
|
|||
// https://dom.spec.whatwg.org/#xml-document
|
||||
bool is_xml_document() const { return m_type == Type::XML; }
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<Node>> import_node(GC::Ref<Node> node, Variant<bool, ImportNodeOptions>);
|
||||
WebIDL::ExceptionOr<GC::Ref<Node>> import_node(GC::Ref<Node> node, Variant<bool, Bindings::ImportNodeOptions>);
|
||||
void adopt_node(Node&);
|
||||
WebIDL::ExceptionOr<GC::Ref<Node>> adopt_node_binding(GC::Ref<Node>);
|
||||
|
||||
|
|
@ -1175,7 +1163,7 @@ private:
|
|||
GC::Ptr<HTML::CustomElementRegistry> registry;
|
||||
Optional<String> is;
|
||||
};
|
||||
WebIDL::ExceptionOr<RegistryAndIs> flatten_element_creation_options(Variant<String, ElementCreationOptions> const&) const;
|
||||
WebIDL::ExceptionOr<RegistryAndIs> flatten_element_creation_options(Variant<String, Bindings::ElementCreationOptions> const&) const;
|
||||
|
||||
GC::Ref<Page> m_page;
|
||||
GC::Ptr<CSS::StyleComputer> m_style_computer;
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ static GC::Ref<DOM::Document> load_pdf_document(HTML::NavigationParams const& na
|
|||
|
||||
auto listener_fn = JS::NativeFunction::create(
|
||||
realm, [document, js_response](JS::VM&) mutable -> JS::ThrowCompletionOr<JS::Value> {
|
||||
DOM::CustomEventInit init;
|
||||
Bindings::CustomEventInit init;
|
||||
init.detail = JS::Value(js_response.ptr());
|
||||
document->dispatch_event(*DOM::CustomEvent::create(document->realm(), "ladybirdpdf"_fly_string, init));
|
||||
return JS::js_undefined();
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ WebIDL::ExceptionOr<Vector<GC::Ref<Animations::Animation>>> calculate_get_animat
|
|||
TRY(self.template for_each_child_of_type_fallible<Element>([&](auto& child) -> WebIDL::ExceptionOr<IterationDecision> {
|
||||
relevant_animations.extend(TRY(child.get_animations_internal(
|
||||
Animations::Animatable::GetAnimationsSorted::No,
|
||||
Animations::GetAnimationsOptions { .subtree = true })));
|
||||
Bindings::GetAnimationsOptions { .subtree = true })));
|
||||
return IterationDecision::Continue;
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -1227,7 +1227,7 @@ WebIDL::ExceptionOr<void> Element::attach_a_shadow_root(Bindings::ShadowRootMode
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-attachshadow
|
||||
WebIDL::ExceptionOr<GC::Ref<ShadowRoot>> Element::attach_shadow(ShadowRootInit init)
|
||||
WebIDL::ExceptionOr<GC::Ref<ShadowRoot>> Element::attach_shadow(Bindings::ShadowRootInit const& init)
|
||||
{
|
||||
// 1. Let registry be this’s node document’s custom element registry.
|
||||
auto registry = document().custom_element_registry();
|
||||
|
|
@ -2923,7 +2923,7 @@ static GC::Ref<WebIDL::Promise> scroll_an_element_into_view(Element& target, Bin
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview
|
||||
GC::Ref<WebIDL::Promise> Element::scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> arg)
|
||||
GC::Ref<WebIDL::Promise> Element::scroll_into_view(Optional<Variant<bool, Bindings::ScrollIntoViewOptions>> arg)
|
||||
{
|
||||
// 1. Let behavior be "auto".
|
||||
auto behavior = Bindings::ScrollBehavior::Auto;
|
||||
|
|
@ -2938,8 +2938,8 @@ GC::Ref<WebIDL::Promise> Element::scroll_into_view(Optional<Variant<bool, Scroll
|
|||
GC::Ptr<Element> container = nullptr;
|
||||
|
||||
// 5. If arg is a ScrollIntoViewOptions dictionary, then:
|
||||
if (arg.has_value() && arg->has<ScrollIntoViewOptions>()) {
|
||||
auto options = arg->get<ScrollIntoViewOptions>();
|
||||
if (arg.has_value() && arg->has<Bindings::ScrollIntoViewOptions>()) {
|
||||
auto options = arg->get<Bindings::ScrollIntoViewOptions>();
|
||||
|
||||
// 1. Set behavior to the behavior dictionary member of options.
|
||||
behavior = options.behavior;
|
||||
|
|
@ -3619,7 +3619,7 @@ GC::Ref<WebIDL::Promise> Element::scroll(double x, double y)
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
|
||||
GC::Ref<WebIDL::Promise> Element::scroll(HTML::ScrollToOptions options)
|
||||
GC::Ref<WebIDL::Promise> Element::scroll(Bindings::ScrollToOptions options)
|
||||
{
|
||||
// 1. If invoked with one argument, follow these substeps:
|
||||
// 1. Let options be the argument.
|
||||
|
|
@ -3637,20 +3637,20 @@ GC::Ref<WebIDL::Promise> Element::scroll_by(double x, double y)
|
|||
{
|
||||
// 2. If invoked with two arguments, follow these substeps:
|
||||
// 1. Let options be null converted to a ScrollToOptions dictionary. [WEBIDL]
|
||||
HTML::ScrollToOptions options;
|
||||
Bindings::ScrollToOptions options;
|
||||
|
||||
// 2. Let x and y be the arguments, respectively.
|
||||
// 3. Normalize non-finite values for x and y.
|
||||
// 4. Let the left dictionary member of options have the value x.
|
||||
// 5. Let the top dictionary member of options have the value y.
|
||||
// NOTE: Element::scroll_by(HTML::ScrollToOptions) performs the normalization and following steps.
|
||||
// NOTE: Element::scroll_by(Bindings::ScrollToOptions) performs the normalization and following steps.
|
||||
options.left = x;
|
||||
options.top = y;
|
||||
return scroll_by(options);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scrollby
|
||||
GC::Ref<WebIDL::Promise> Element::scroll_by(HTML::ScrollToOptions options)
|
||||
GC::Ref<WebIDL::Promise> Element::scroll_by(Bindings::ScrollToOptions options)
|
||||
{
|
||||
// 1. If invoked with one argument, follow these substeps:
|
||||
// 1. Let options be the argument.
|
||||
|
|
@ -3671,7 +3671,7 @@ GC::Ref<WebIDL::Promise> Element::scroll_by(HTML::ScrollToOptions options)
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view-1/#dom-element-checkvisibility
|
||||
bool Element::check_visibility(Optional<CheckVisibilityOptions> options)
|
||||
bool Element::check_visibility(Optional<Bindings::CheckVisibilityOptions> options)
|
||||
{
|
||||
// NOTE: Ensure that layout is up-to-date before looking at metrics.
|
||||
document().update_layout_if_needed_for_node(*this, UpdateLayoutReason::ElementCheckVisibility);
|
||||
|
|
@ -4403,7 +4403,7 @@ ElementByIdMap& Element::document_or_shadow_root_element_by_id_map()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-gethtml
|
||||
WebIDL::ExceptionOr<String> Element::get_html(GetHTMLOptions const& options) const
|
||||
WebIDL::ExceptionOr<String> Element::get_html(Bindings::GetHTMLOptions const& options) const
|
||||
{
|
||||
// Element's getHTML(options) method steps are to return the result
|
||||
// of HTML fragment serialization algorithm with this,
|
||||
|
|
@ -4762,7 +4762,7 @@ double Element::ensure_css_random_base_value(CSS::RandomCachingKey const& random
|
|||
});
|
||||
}
|
||||
|
||||
GC::Ref<WebIDL::Promise> Element::request_pointer_lock(Optional<PointerLockOptions>)
|
||||
GC::Ref<WebIDL::Promise> Element::request_pointer_lock(Optional<Bindings::PointerLockOptions>)
|
||||
{
|
||||
dbgln("FIXME: request_pointer_lock()");
|
||||
auto promise = WebIDL::create_promise(realm());
|
||||
|
|
|
|||
|
|
@ -38,36 +38,6 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
struct ShadowRootInit {
|
||||
Bindings::ShadowRootMode mode;
|
||||
bool delegates_focus = false;
|
||||
Bindings::SlotAssignmentMode slot_assignment { Bindings::SlotAssignmentMode::Named };
|
||||
bool clonable = false;
|
||||
bool serializable = false;
|
||||
Optional<GC::Ptr<HTML::CustomElementRegistry>> custom_element_registry {};
|
||||
};
|
||||
|
||||
struct GetHTMLOptions {
|
||||
bool serializable_shadow_roots { false };
|
||||
Vector<GC::Root<ShadowRoot>> shadow_roots {};
|
||||
};
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dictdef-scrollintoviewoptions
|
||||
struct ScrollIntoViewOptions : public HTML::ScrollOptions {
|
||||
Bindings::ScrollLogicalPosition block { Bindings::ScrollLogicalPosition::Start };
|
||||
Bindings::ScrollLogicalPosition inline_ { Bindings::ScrollLogicalPosition::Nearest };
|
||||
Bindings::ScrollIntoViewContainer container { Bindings::ScrollIntoViewContainer::All };
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/cssom-view-1/#dictdef-checkvisibilityoptions
|
||||
struct CheckVisibilityOptions {
|
||||
bool check_opacity = false;
|
||||
bool check_visibility_css = false;
|
||||
bool content_visibility_auto = false;
|
||||
bool opacity_property = false;
|
||||
bool visibility_property = false;
|
||||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/custom-elements.html#upgrade-reaction
|
||||
// An upgrade reaction, which will upgrade the custom element and contains a custom element definition; or
|
||||
struct CustomElementUpgradeReaction {
|
||||
|
|
@ -102,11 +72,6 @@ enum class ProximityToTheViewport : u8 {
|
|||
NotDetermined,
|
||||
};
|
||||
|
||||
// https://w3c.github.io/pointerlock/#pointerlockoptions-dictionary
|
||||
struct PointerLockOptions {
|
||||
bool unadjusted_movement = false;
|
||||
};
|
||||
|
||||
class WEB_API Element
|
||||
: public ParentNode
|
||||
, public ChildNode<Element>
|
||||
|
|
@ -196,7 +161,7 @@ public:
|
|||
GC::Ref<DOMTokenList> part_list();
|
||||
ReadonlySpan<FlyString> part_names() const { return m_parts; }
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<ShadowRoot>> attach_shadow(ShadowRootInit init);
|
||||
WebIDL::ExceptionOr<GC::Ref<ShadowRoot>> attach_shadow(Bindings::ShadowRootInit const&);
|
||||
WebIDL::ExceptionOr<void> attach_a_shadow_root(Bindings::ShadowRootMode mode, bool clonable, bool serializable, bool delegates_focus, Bindings::SlotAssignmentMode slot_assignment, GC::Ptr<HTML::CustomElementRegistry> registry);
|
||||
GC::Ptr<ShadowRoot> shadow_root_for_bindings() const;
|
||||
|
||||
|
|
@ -261,7 +226,7 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<void> set_html_unsafe(TrustedTypes::TrustedHTMLOrString const&);
|
||||
|
||||
WebIDL::ExceptionOr<String> get_html(GetHTMLOptions const&) const;
|
||||
WebIDL::ExceptionOr<String> get_html(Bindings::GetHTMLOptions const&) const;
|
||||
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_html(String const& position, TrustedTypes::TrustedHTMLOrString const&);
|
||||
|
||||
|
|
@ -393,7 +358,7 @@ public:
|
|||
WebIDL::ExceptionOr<void> insert_adjacent_text(String const& where, Utf16String const& data);
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
|
||||
GC::Ref<WebIDL::Promise> scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {});
|
||||
GC::Ref<WebIDL::Promise> scroll_into_view(Optional<Variant<bool, Bindings::ScrollIntoViewOptions>> = {});
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin
|
||||
#define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \
|
||||
|
|
@ -438,12 +403,12 @@ public:
|
|||
void set_custom_element_state(CustomElementState);
|
||||
void setup_custom_element_from_constructor(HTML::CustomElementDefinition& custom_element_definition, Optional<String> const& is_value);
|
||||
|
||||
GC::Ref<WebIDL::Promise> scroll(HTML::ScrollToOptions);
|
||||
GC::Ref<WebIDL::Promise> scroll(Bindings::ScrollToOptions);
|
||||
GC::Ref<WebIDL::Promise> scroll(double x, double y);
|
||||
GC::Ref<WebIDL::Promise> scroll_by(HTML::ScrollToOptions);
|
||||
GC::Ref<WebIDL::Promise> scroll_by(Bindings::ScrollToOptions);
|
||||
GC::Ref<WebIDL::Promise> scroll_by(double x, double y);
|
||||
|
||||
bool check_visibility(Optional<CheckVisibilityOptions>);
|
||||
bool check_visibility(Optional<Bindings::CheckVisibilityOptions>);
|
||||
|
||||
void register_intersection_observer(Badge<IntersectionObserver::IntersectionObserver>, GC::Ref<IntersectionObserver::IntersectionObserver>);
|
||||
void unregister_intersection_observer(Badge<IntersectionObserver::IntersectionObserver>, GC::Ref<IntersectionObserver::IntersectionObserver>);
|
||||
|
|
@ -611,7 +576,7 @@ public:
|
|||
|
||||
double ensure_css_random_base_value(CSS::RandomCachingKey const&);
|
||||
|
||||
GC::Ref<WebIDL::Promise> request_pointer_lock(Optional<PointerLockOptions>);
|
||||
GC::Ref<WebIDL::Promise> request_pointer_lock(Optional<Bindings::PointerLockOptions>);
|
||||
|
||||
GC::Ptr<HTML::CustomElementRegistry> custom_element_registry() const { return m_custom_element_registry; }
|
||||
void set_custom_element_registry(GC::Ptr<HTML::CustomElementRegistry> registry) { m_custom_element_registry = registry; }
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Web::DOM {
|
|||
GC_DEFINE_ALLOCATOR(Event);
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-create
|
||||
GC::Ref<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
GC::Ref<Event> Event::create(JS::Realm& realm, FlyString const& event_name, Bindings::EventInit const& event_init)
|
||||
{
|
||||
auto event = realm.create<Event>(realm, event_name, event_init);
|
||||
// 4. Initialize event’s isTrusted attribute to true.
|
||||
|
|
@ -29,7 +29,7 @@ GC::Ref<Event> Event::create(JS::Realm& realm, FlyString const& event_name, Even
|
|||
return event;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<Event>> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
WebIDL::ExceptionOr<GC::Ref<Event>> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, Bindings::EventInit const& event_init)
|
||||
{
|
||||
return realm.create<Event>(realm, event_name, event_init);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ Event::Event(JS::Realm& realm, FlyString const& type)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#inner-event-creation-steps
|
||||
Event::Event(JS::Realm& realm, FlyString const& type, EventInit const& event_init)
|
||||
Event::Event(JS::Realm& realm, FlyString const& type, Bindings::EventInit const& event_init)
|
||||
: PlatformObject(realm)
|
||||
, m_type(type)
|
||||
, m_bubbles(event_init.bubbles)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/Bindings/Event.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/Export.h>
|
||||
|
|
@ -14,12 +15,6 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
struct EventInit {
|
||||
bool bubbles { false };
|
||||
bool cancelable { false };
|
||||
bool composed { false };
|
||||
};
|
||||
|
||||
class WEB_API Event : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(Event, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(Event);
|
||||
|
|
@ -48,11 +43,11 @@ public:
|
|||
|
||||
using Path = Vector<PathEntry>;
|
||||
|
||||
[[nodiscard]] static GC::Ref<Event> create(JS::Realm&, FlyString const& event_name, EventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<Event>> construct_impl(JS::Realm&, FlyString const& event_name, EventInit const& event_init);
|
||||
[[nodiscard]] static GC::Ref<Event> create(JS::Realm&, FlyString const& event_name, Bindings::EventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<Event>> construct_impl(JS::Realm&, FlyString const& event_name, Bindings::EventInit const& event_init);
|
||||
|
||||
Event(JS::Realm&, FlyString const& type);
|
||||
Event(JS::Realm&, FlyString const& type, EventInit const& event_init);
|
||||
Event(JS::Realm&, FlyString const& type, Bindings::EventInit const& event_init);
|
||||
|
||||
virtual ~Event() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -105,24 +105,24 @@ Vector<GC::Root<DOMEventListener>> EventTarget::event_listener_list()
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-flatten-options
|
||||
static bool flatten_event_listener_options(Variant<EventListenerOptions, bool> const& options)
|
||||
static bool flatten_event_listener_options(Variant<Bindings::EventListenerOptions, bool> const& options)
|
||||
{
|
||||
// 1. If options is a boolean, then return options.
|
||||
if (options.has<bool>())
|
||||
return options.get<bool>();
|
||||
|
||||
// 2. Return options["capture"].
|
||||
return options.get<EventListenerOptions>().capture;
|
||||
return options.get<Bindings::EventListenerOptions>().capture;
|
||||
}
|
||||
|
||||
static bool flatten_event_listener_options(Variant<AddEventListenerOptions, bool> const& options)
|
||||
static bool flatten_event_listener_options(Variant<Bindings::AddEventListenerOptions, bool> const& options)
|
||||
{
|
||||
// 1. If options is a boolean, then return options.
|
||||
if (options.has<bool>())
|
||||
return options.get<bool>();
|
||||
|
||||
// 2. Return options["capture"].
|
||||
return options.get<AddEventListenerOptions>().capture;
|
||||
return options.get<Bindings::AddEventListenerOptions>().capture;
|
||||
}
|
||||
|
||||
struct FlattenedAddEventListenerOptions {
|
||||
|
|
@ -133,7 +133,7 @@ struct FlattenedAddEventListenerOptions {
|
|||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#event-flatten-more
|
||||
static FlattenedAddEventListenerOptions flatten_add_event_listener_options(Variant<AddEventListenerOptions, bool> const& options)
|
||||
static FlattenedAddEventListenerOptions flatten_add_event_listener_options(Variant<Bindings::AddEventListenerOptions, bool> const& options)
|
||||
{
|
||||
// 1. Let capture be the result of flattening options.
|
||||
bool capture = flatten_event_listener_options(options);
|
||||
|
|
@ -146,8 +146,8 @@ static FlattenedAddEventListenerOptions flatten_add_event_listener_options(Varia
|
|||
GC::Ptr<AbortSignal> signal;
|
||||
|
||||
// 4. If options is a dictionary, then:
|
||||
if (options.has<AddEventListenerOptions>()) {
|
||||
auto const& add_event_listener_options = options.get<AddEventListenerOptions>();
|
||||
if (options.has<Bindings::AddEventListenerOptions>()) {
|
||||
auto const& add_event_listener_options = options.get<Bindings::AddEventListenerOptions>();
|
||||
|
||||
// 1. Set once to options["once"].
|
||||
once = add_event_listener_options.once;
|
||||
|
|
@ -157,8 +157,8 @@ static FlattenedAddEventListenerOptions flatten_add_event_listener_options(Varia
|
|||
passive = add_event_listener_options.passive;
|
||||
|
||||
// 3. If options["signal"] exists, then set signal to options["signal"].
|
||||
if (add_event_listener_options.signal)
|
||||
signal = add_event_listener_options.signal;
|
||||
if (add_event_listener_options.signal.has_value())
|
||||
signal = add_event_listener_options.signal->ptr();
|
||||
}
|
||||
|
||||
// 5. Return capture, passive, once, and signal.
|
||||
|
|
@ -187,7 +187,7 @@ static bool default_passive_value(FlyString const& type, EventTarget* event_targ
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||
void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* callback, Variant<AddEventListenerOptions, bool> const& options)
|
||||
void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* callback, Variant<Bindings::AddEventListenerOptions, bool> const& options)
|
||||
{
|
||||
// 1. Let capture, passive, once, and signal be the result of flattening more options.
|
||||
auto flattened_options = flatten_add_event_listener_options(options);
|
||||
|
|
@ -207,7 +207,7 @@ void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* ca
|
|||
|
||||
void EventTarget::add_event_listener_without_options(FlyString const& type, IDLEventListener& callback)
|
||||
{
|
||||
add_event_listener(type, &callback, AddEventListenerOptions {});
|
||||
add_event_listener(type, &callback, Bindings::AddEventListenerOptions {});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#add-an-event-listener
|
||||
|
|
@ -253,7 +253,7 @@ void EventTarget::add_an_event_listener(DOMEventListener& listener)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||
void EventTarget::remove_event_listener(FlyString const& type, IDLEventListener* callback, Variant<EventListenerOptions, bool> const& options)
|
||||
void EventTarget::remove_event_listener(FlyString const& type, IDLEventListener* callback, Variant<Bindings::EventListenerOptions, bool> const& options)
|
||||
{
|
||||
auto& event_listener_list = ensure_data().event_listener_list;
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ void EventTarget::remove_event_listener(FlyString const& type, IDLEventListener*
|
|||
|
||||
void EventTarget::remove_event_listener_without_options(FlyString const& type, IDLEventListener& callback)
|
||||
{
|
||||
remove_event_listener(type, &callback, EventListenerOptions {});
|
||||
remove_event_listener(type, &callback, Bindings::EventListenerOptions {});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#remove-an-event-listener
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ public:
|
|||
|
||||
virtual bool is_focusable() const { return false; }
|
||||
|
||||
void add_event_listener(FlyString const& type, IDLEventListener* callback, Variant<AddEventListenerOptions, bool> const& options);
|
||||
void remove_event_listener(FlyString const& type, IDLEventListener* callback, Variant<EventListenerOptions, bool> const& options);
|
||||
void add_event_listener(FlyString const& type, IDLEventListener* callback, Variant<Bindings::AddEventListenerOptions, bool> const& options);
|
||||
void remove_event_listener(FlyString const& type, IDLEventListener* callback, Variant<Bindings::EventListenerOptions, bool> const& options);
|
||||
|
||||
// NOTE: These are for internal use only. They operate as though addEventListener(type, callback) was called instead of addEventListener(type, callback, options).
|
||||
void add_event_listener_without_options(FlyString const& type, IDLEventListener& callback);
|
||||
|
|
|
|||
|
|
@ -9,22 +9,12 @@
|
|||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibGC/Root.h>
|
||||
#include <LibWeb/Bindings/EventTarget.h>
|
||||
#include <LibWeb/DOM/AbortSignal.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
// NOTE: Even though these dictionaries are defined in EventTarget.idl, they are here to prevent a circular include between EventTarget.h and AbortSignal.h.
|
||||
struct EventListenerOptions {
|
||||
bool capture { false };
|
||||
};
|
||||
|
||||
struct AddEventListenerOptions : public EventListenerOptions {
|
||||
Optional<bool> passive;
|
||||
bool once { false };
|
||||
GC::Ptr<AbortSignal> signal;
|
||||
};
|
||||
|
||||
class IDLEventListener final : public JS::Object {
|
||||
JS_OBJECT(IDLEventListener, JS::Object);
|
||||
GC_DECLARE_ALLOCATOR(IDLEventListener);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void MutationObserver::visit_edges(Cell::Visitor& visitor)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-mutationobserver-observe
|
||||
WebIDL::ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserverInit options)
|
||||
WebIDL::ExceptionOr<void> MutationObserver::observe(Node& target, Bindings::MutationObserverInit options)
|
||||
{
|
||||
// 1. If either options["attributeOldValue"] or options["attributeFilter"] exists, and options["attributes"] does not exist, then set options["attributes"] to true.
|
||||
if ((options.attribute_old_value.has_value() || options.attribute_filter.has_value()) && !options.attributes.has_value())
|
||||
|
|
@ -152,12 +152,12 @@ Vector<GC::Root<MutationRecord>> MutationObserver::take_records()
|
|||
return records;
|
||||
}
|
||||
|
||||
GC::Ref<RegisteredObserver> RegisteredObserver::create(MutationObserver& observer, MutationObserverInit const& options)
|
||||
GC::Ref<RegisteredObserver> RegisteredObserver::create(MutationObserver& observer, Bindings::MutationObserverInit const& options)
|
||||
{
|
||||
return observer.heap().allocate<RegisteredObserver>(observer, options);
|
||||
}
|
||||
|
||||
RegisteredObserver::RegisteredObserver(MutationObserver& observer, MutationObserverInit const& options)
|
||||
RegisteredObserver::RegisteredObserver(MutationObserver& observer, Bindings::MutationObserverInit const& options)
|
||||
: m_observer(observer)
|
||||
, m_options(options)
|
||||
{
|
||||
|
|
@ -171,12 +171,12 @@ void RegisteredObserver::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_observer);
|
||||
}
|
||||
|
||||
GC::Ref<TransientRegisteredObserver> TransientRegisteredObserver::create(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source)
|
||||
GC::Ref<TransientRegisteredObserver> TransientRegisteredObserver::create(MutationObserver& observer, Bindings::MutationObserverInit const& options, RegisteredObserver& source)
|
||||
{
|
||||
return observer.heap().allocate<TransientRegisteredObserver>(observer, options, source);
|
||||
}
|
||||
|
||||
TransientRegisteredObserver::TransientRegisteredObserver(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source)
|
||||
TransientRegisteredObserver::TransientRegisteredObserver(MutationObserver& observer, Bindings::MutationObserverInit const& options, RegisteredObserver& source)
|
||||
: RegisteredObserver(observer, options)
|
||||
, m_source(source)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,23 +8,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGC/Root.h>
|
||||
#include <LibWeb/Bindings/MutationObserver.h>
|
||||
#include <LibWeb/DOM/MutationRecord.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
// https://dom.spec.whatwg.org/#dictdef-mutationobserverinit
|
||||
struct MutationObserverInit {
|
||||
bool child_list { false };
|
||||
Optional<bool> attributes;
|
||||
Optional<bool> character_data;
|
||||
bool subtree { false };
|
||||
Optional<bool> attribute_old_value;
|
||||
Optional<bool> character_data_old_value;
|
||||
Optional<Vector<String>> attribute_filter;
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#mutationobserver
|
||||
class MutationObserver final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(MutationObserver, Bindings::PlatformObject);
|
||||
|
|
@ -34,7 +24,7 @@ public:
|
|||
static WebIDL::ExceptionOr<GC::Ref<MutationObserver>> construct_impl(JS::Realm&, GC::Ptr<WebIDL::CallbackType>);
|
||||
virtual ~MutationObserver() override;
|
||||
|
||||
WebIDL::ExceptionOr<void> observe(Node& target, MutationObserverInit options = {});
|
||||
WebIDL::ExceptionOr<void> observe(Node& target, Bindings::MutationObserverInit = {});
|
||||
void disconnect();
|
||||
Vector<GC::Root<MutationRecord>> take_records();
|
||||
|
||||
|
|
@ -71,27 +61,27 @@ class RegisteredObserver : public JS::Cell {
|
|||
GC_DECLARE_ALLOCATOR(RegisteredObserver);
|
||||
|
||||
public:
|
||||
static GC::Ref<RegisteredObserver> create(MutationObserver&, MutationObserverInit const&);
|
||||
static GC::Ref<RegisteredObserver> create(MutationObserver&, Bindings::MutationObserverInit const&);
|
||||
virtual ~RegisteredObserver() override;
|
||||
|
||||
virtual bool is_transient() const { return false; }
|
||||
|
||||
GC::Ref<MutationObserver> observer() const { return m_observer; }
|
||||
|
||||
MutationObserverInit const& options() const { return m_options; }
|
||||
void set_options(MutationObserverInit options) { m_options = move(options); }
|
||||
Bindings::MutationObserverInit const& options() const { return m_options; }
|
||||
void set_options(Bindings::MutationObserverInit options) { m_options = move(options); }
|
||||
|
||||
template<typename T>
|
||||
bool fast_is() const = delete;
|
||||
|
||||
protected:
|
||||
RegisteredObserver(MutationObserver& observer, MutationObserverInit const& options);
|
||||
RegisteredObserver(MutationObserver& observer, Bindings::MutationObserverInit const& options);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
GC::Ref<MutationObserver> m_observer;
|
||||
MutationObserverInit m_options;
|
||||
Bindings::MutationObserverInit m_options;
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#transient-registered-observer
|
||||
|
|
@ -100,7 +90,7 @@ class TransientRegisteredObserver final : public RegisteredObserver {
|
|||
GC_DECLARE_ALLOCATOR(TransientRegisteredObserver);
|
||||
|
||||
public:
|
||||
static GC::Ref<TransientRegisteredObserver> create(MutationObserver&, MutationObserverInit const&, RegisteredObserver& source);
|
||||
static GC::Ref<TransientRegisteredObserver> create(MutationObserver&, Bindings::MutationObserverInit const&, RegisteredObserver& source);
|
||||
virtual ~TransientRegisteredObserver() override;
|
||||
|
||||
GC::Ref<RegisteredObserver> source() const { return m_source; }
|
||||
|
|
@ -108,7 +98,7 @@ public:
|
|||
virtual bool is_transient() const override { return true; }
|
||||
|
||||
private:
|
||||
TransientRegisteredObserver(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source);
|
||||
TransientRegisteredObserver(MutationObserver& observer, Bindings::MutationObserverInit const& options, RegisteredObserver& source);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -2601,7 +2601,7 @@ bool Node::in_a_document_tree() const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-getrootnode
|
||||
GC::Ref<Node> Node::get_root_node(GetRootNodeOptions const& options)
|
||||
GC::Ref<Node> Node::get_root_node(Bindings::GetRootNodeOptions const& options)
|
||||
{
|
||||
// The getRootNode(options) method steps are to return this’s shadow-including root if options["composed"] is true;
|
||||
if (options.composed)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <AK/RefPtr.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibWeb/Bindings/Node.h>
|
||||
#include <LibWeb/CSS/InvalidationSet.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/DOM/FragmentSerializationMode.h>
|
||||
|
|
@ -45,10 +45,6 @@ enum class NameOrDescription {
|
|||
Description
|
||||
};
|
||||
|
||||
struct GetRootNodeOptions {
|
||||
bool composed { false };
|
||||
};
|
||||
|
||||
enum class IsDescendant {
|
||||
No,
|
||||
Yes,
|
||||
|
|
@ -412,7 +408,7 @@ public:
|
|||
bool is_same_node(Node const*) const;
|
||||
bool is_equal_node(Node const*) const;
|
||||
|
||||
GC::Ref<Node> get_root_node(GetRootNodeOptions const& options = {});
|
||||
GC::Ref<Node> get_root_node(Bindings::GetRootNodeOptions const& options = {});
|
||||
|
||||
bool is_uninteresting_whitespace_node() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void fire_a_selectionchange_event(T& target, Document& document)
|
|||
// cancelable, at target.
|
||||
// 3. Otherwise, if target is a document, fire an event named selectionchange, which does not
|
||||
// bubble and not cancelable, at target.
|
||||
EventInit event_init;
|
||||
Bindings::EventInit event_init;
|
||||
event_init.bubbles = DerivedFrom<T, Element>;
|
||||
event_init.cancelable = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ WebIDL::ExceptionOr<void> ShadowRoot::set_inner_html(TrustedTypes::TrustedHTMLOr
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-gethtml
|
||||
WebIDL::ExceptionOr<String> ShadowRoot::get_html(GetHTMLOptions const& options) const
|
||||
WebIDL::ExceptionOr<String> ShadowRoot::get_html(Bindings::GetHTMLOptions const& options) const
|
||||
{
|
||||
// ShadowRoot's getHTML(options) method steps are to return the result
|
||||
// of HTML fragment serialization algorithm with this,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<void> set_html_unsafe(TrustedTypes::TrustedHTMLOrString const&);
|
||||
|
||||
WebIDL::ExceptionOr<String> get_html(GetHTMLOptions const&) const;
|
||||
WebIDL::ExceptionOr<String> get_html(Bindings::GetHTMLOptions const&) const;
|
||||
|
||||
GC::Ptr<Element> active_element();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ StaticRange::StaticRange(Node& start_container, u32 start_offset, Node& end_cont
|
|||
StaticRange::~StaticRange() = default;
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-staticrange-staticrange
|
||||
WebIDL::ExceptionOr<GC::Ref<StaticRange>> StaticRange::construct_impl(JS::Realm& realm, StaticRangeInit& init)
|
||||
WebIDL::ExceptionOr<GC::Ref<StaticRange>> StaticRange::construct_impl(JS::Realm& realm, Bindings::StaticRangeInit const& init)
|
||||
{
|
||||
// 1. If init["startContainer"] or init["endContainer"] is a DocumentType or Attr node, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (is<DocumentType>(*init.start_container) || is<Attr>(*init.start_container))
|
||||
|
|
|
|||
|
|
@ -11,21 +11,12 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
// NOTE: We must use GCP instead of NNGCP here, otherwise the generated code cannot default initialize this struct.
|
||||
// They will never be null, as they are marked as required and non-null in the dictionary.
|
||||
struct StaticRangeInit {
|
||||
GC::Ptr<Node> start_container;
|
||||
u32 start_offset { 0 };
|
||||
GC::Ptr<Node> end_container;
|
||||
u32 end_offset { 0 };
|
||||
};
|
||||
|
||||
class StaticRange final : public AbstractRange {
|
||||
WEB_PLATFORM_OBJECT(StaticRange, AbstractRange);
|
||||
GC_DECLARE_ALLOCATOR(StaticRange);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<StaticRange>> construct_impl(JS::Realm&, StaticRangeInit& init);
|
||||
static WebIDL::ExceptionOr<GC::Ref<StaticRange>> construct_impl(JS::Realm&, Bindings::StaticRangeInit const&);
|
||||
|
||||
StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
|
||||
virtual ~StaticRange() override;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibWeb/Bindings/InputEvent.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
|
|
@ -119,9 +120,9 @@ WebIDL::ExceptionOr<bool> Document::exec_command(FlyString const& command, [[may
|
|||
bool tree_was_modified = dom_tree_version() != old_dom_tree_version
|
||||
|| character_data_version() != old_character_data_version;
|
||||
if (tree_was_modified && affected_editing_host) {
|
||||
UIEvents::InputEventInit event_init {};
|
||||
Bindings::InputEventInit event_init {};
|
||||
event_init.bubbles = true;
|
||||
event_init.input_type = command_definition.mapped_value;
|
||||
event_init.input_type = command_definition.mapped_value.to_string();
|
||||
|
||||
// AD-HOC: For insertText, we do what other browsers do and set data to value.
|
||||
if (command == Editing::CommandNames::insertText)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibWeb/Bindings/Document.h>
|
||||
#include <LibWeb/CSS/CascadedProperties.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/PropertyNameAndID.h>
|
||||
|
|
@ -3785,7 +3786,7 @@ GC::Ref<DOM::Element> set_the_tag_name(GC::Ref<DOM::Element> element, FlyString
|
|||
return element;
|
||||
|
||||
// 3. Let replacement element be the result of calling createElement(new name) on the ownerDocument of element.
|
||||
auto replacement_element = MUST(element->owner_document()->create_element(new_name.to_string(), DOM::ElementCreationOptions {}));
|
||||
auto replacement_element = MUST(element->owner_document()->create_element(new_name.to_string(), Bindings::ElementCreationOptions {}));
|
||||
|
||||
// 4. Insert replacement element into element's parent immediately before element.
|
||||
element->parent()->insert_before(replacement_element, element);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace Web::Encoding {
|
|||
GC_DEFINE_ALLOCATOR(TextDecoder);
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||
WebIDL::ExceptionOr<GC::Ref<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, FlyString label, Optional<TextDecoderOptions> const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, FlyString label, Optional<Bindings::TextDecoderOptions> const& options)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ void TextDecoder::initialize(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
|
||||
WebIDL::ExceptionOr<String> TextDecoder::decode(Optional<GC::Root<WebIDL::BufferSource>> const& input, Optional<TextDecodeOptions> const&) const
|
||||
WebIDL::ExceptionOr<String> TextDecoder::decode(Optional<GC::Root<WebIDL::BufferSource>> const& input, Optional<Bindings::TextDecodeOptions> const&) const
|
||||
{
|
||||
if (!input.has_value())
|
||||
return TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({}));
|
||||
|
|
|
|||
|
|
@ -11,23 +11,13 @@
|
|||
#include <LibJS/Forward.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Bindings/TextDecoder.h>
|
||||
#include <LibWeb/Encoding/TextDecoderCommon.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Encoding {
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textdecoderoptions
|
||||
struct TextDecoderOptions {
|
||||
bool fatal = false;
|
||||
bool ignore_bom = false;
|
||||
};
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textdecodeoptions
|
||||
struct TextDecodeOptions {
|
||||
bool stream = false;
|
||||
};
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textdecoder
|
||||
class TextDecoder
|
||||
: public Bindings::PlatformObject
|
||||
|
|
@ -36,11 +26,11 @@ class TextDecoder
|
|||
GC_DECLARE_ALLOCATOR(TextDecoder);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding, Optional<TextDecoderOptions> const& options = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding, Optional<Bindings::TextDecoderOptions> const& options = {});
|
||||
|
||||
virtual ~TextDecoder() override;
|
||||
|
||||
WebIDL::ExceptionOr<String> decode(Optional<GC::Root<WebIDL::BufferSource>> const&, Optional<TextDecodeOptions> const& options = {}) const;
|
||||
WebIDL::ExceptionOr<String> decode(Optional<GC::Root<WebIDL::BufferSource>> const&, Optional<Bindings::TextDecodeOptions> const& options = {}) const;
|
||||
|
||||
private:
|
||||
TextDecoder(JS::Realm&, TextCodec::Decoder&, FlyString encoding, ErrorMode error_mode, bool ignore_bom);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/TextDecoder.h>
|
||||
#include <LibWeb/Bindings/TextDecoderStream.h>
|
||||
#include <LibWeb/Encoding/TextDecoderStream.h>
|
||||
#include <LibWeb/Streams/TransformStream.h>
|
||||
|
|
@ -68,7 +69,7 @@ static size_t find_utf8_safe_decode_boundary(ReadonlyBytes bytes)
|
|||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoderstream
|
||||
WebIDL::ExceptionOr<GC::Ref<TextDecoderStream>> TextDecoderStream::construct_impl(JS::Realm& realm, FlyString label, TextDecoderOptions const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<TextDecoderStream>> TextDecoderStream::construct_impl(JS::Realm& realm, FlyString label, Bindings::TextDecoderOptions const& options)
|
||||
{
|
||||
// 1. Let encoding be the result of getting an encoding from label.
|
||||
auto encoding = TextCodec::get_standardized_encoding(label);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class TextDecoderStream final
|
|||
GC_DECLARE_ALLOCATOR(TextDecoderStream);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextDecoderStream>> construct_impl(JS::Realm&, FlyString label, TextDecoderOptions const& options = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextDecoderStream>> construct_impl(JS::Realm&, FlyString label, Bindings::TextDecoderOptions const&);
|
||||
virtual ~TextDecoderStream() override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ GC::Ref<JS::Uint8Array> TextEncoder::encode(String const& input) const
|
|||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encodeinto
|
||||
TextEncoderEncodeIntoResult TextEncoder::encode_into(String const& source, GC::Root<JS::Uint8Array> const& destination) const
|
||||
Bindings::TextEncoderEncodeIntoResult TextEncoder::encode_into(String const& source, GC::Root<JS::Uint8Array> const& destination) const
|
||||
{
|
||||
// AD-HOC: Return early if destination is detached. This is not explicitly handled in the spec,
|
||||
// however no bytes are copied as destinations size is always zero in this case.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
|
@ -18,12 +19,6 @@
|
|||
|
||||
namespace Web::Encoding {
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dictdef-textencoderencodeintoresult
|
||||
struct TextEncoderEncodeIntoResult {
|
||||
WebIDL::UnsignedLongLong read;
|
||||
WebIDL::UnsignedLongLong written;
|
||||
};
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textencoder
|
||||
class TextEncoder final
|
||||
: public Bindings::PlatformObject
|
||||
|
|
@ -37,7 +32,7 @@ public:
|
|||
virtual ~TextEncoder() override;
|
||||
|
||||
GC::Ref<JS::Uint8Array> encode(String const& input) const;
|
||||
TextEncoderEncodeIntoResult encode_into(String const& source, GC::Root<JS::Uint8Array> const& destination) const;
|
||||
Bindings::TextEncoderEncodeIntoResult encode_into(String const& source, GC::Root<JS::Uint8Array> const& destination) const;
|
||||
|
||||
protected:
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ bool supports_container([[maybe_unused]] Utf16String const& container)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-audio-video-type
|
||||
Optional<Vector<MediaKeySystemMediaCapability>> get_supported_capabilities_for_audio_video_type(KeySystem const& implementation, CapabilitiesType type, Vector<MediaKeySystemMediaCapability> requested_capabilities, MediaKeySystemConfiguration config, MediaKeyRestrictions restrictions)
|
||||
Optional<Vector<Bindings::MediaKeySystemMediaCapability>> get_supported_capabilities_for_audio_video_type(KeySystem const& implementation, CapabilitiesType type, Vector<Bindings::MediaKeySystemMediaCapability> requested_capabilities, Bindings::MediaKeySystemConfiguration config, MediaKeyRestrictions restrictions)
|
||||
{
|
||||
// 1. Let local accumulated configuration be a local copy of accumulated configuration.
|
||||
MediaKeySystemConfiguration accumulated_configuration = config;
|
||||
Bindings::MediaKeySystemConfiguration accumulated_configuration = config;
|
||||
|
||||
// 2. Let supported media capabilities be an empty sequence of MediaKeySystemMediaCapability dictionaries.
|
||||
Vector<MediaKeySystemMediaCapability> supported_media_capabilities;
|
||||
Vector<Bindings::MediaKeySystemMediaCapability> supported_media_capabilities;
|
||||
|
||||
// 3. For each requested media capability in requested media capabilities:
|
||||
for (auto& capability : requested_capabilities) {
|
||||
|
|
@ -143,7 +143,7 @@ bool is_persistent_session_type(Utf16String const& session_type)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/encrypted-media/#get-consent-status
|
||||
ConsentStatus get_consent_status(MediaKeySystemConfiguration const& accumulated_configuration, MediaKeyRestrictions& restrictions, URL::Origin const& origin)
|
||||
ConsentStatus get_consent_status(Bindings::MediaKeySystemConfiguration const& accumulated_configuration, MediaKeyRestrictions& restrictions, URL::Origin const& origin)
|
||||
{
|
||||
// FIXME: Implement this
|
||||
(void)accumulated_configuration;
|
||||
|
|
@ -156,10 +156,10 @@ ConsentStatus get_consent_status(MediaKeySystemConfiguration const& accumulated_
|
|||
}
|
||||
|
||||
// https://w3c.github.io/encrypted-media/#get-supported-configuration-and-consent
|
||||
Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem const& implementation, MediaKeySystemConfiguration const& candidate_configuration, MediaKeyRestrictions& restrictions, URL::Origin const& origin)
|
||||
Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem const& implementation, Bindings::MediaKeySystemConfiguration const& candidate_configuration, MediaKeyRestrictions& restrictions, URL::Origin const& origin)
|
||||
{
|
||||
// 1. Let accumulated configuration be a new MediaKeySystemConfiguration dictionary.
|
||||
MediaKeySystemConfiguration accumulated_configuration;
|
||||
Bindings::MediaKeySystemConfiguration accumulated_configuration;
|
||||
|
||||
// 2. Set the label member of accumulated configuration to equal the label member of candidate configuration.
|
||||
accumulated_configuration.label = candidate_configuration.label;
|
||||
|
|
@ -293,7 +293,7 @@ Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem
|
|||
// Otherwise:
|
||||
else {
|
||||
// 1. Set the videoCapabilities member of accumulated configuration to an empty sequence.
|
||||
accumulated_configuration.video_capabilities = Vector<MediaKeySystemMediaCapability> {};
|
||||
accumulated_configuration.video_capabilities = Vector<Bindings::MediaKeySystemMediaCapability> {};
|
||||
}
|
||||
|
||||
// 1. If the audioCapabilities member in candidate configuration is non-empty:
|
||||
|
|
@ -312,7 +312,7 @@ Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem
|
|||
// Otherwise:
|
||||
else {
|
||||
// 1. Set the audioCapabilities member of accumulated configuration to an empty sequence.
|
||||
accumulated_configuration.audio_capabilities = Vector<MediaKeySystemMediaCapability> {};
|
||||
accumulated_configuration.audio_capabilities = Vector<Bindings::MediaKeySystemMediaCapability> {};
|
||||
}
|
||||
|
||||
// 18. If accumulated configuration's distinctiveIdentifier value is "optional", follow the steps for the first matching condition from the following list:
|
||||
|
|
@ -373,7 +373,7 @@ Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem
|
|||
}
|
||||
|
||||
// https://w3c.github.io/encrypted-media/#get-supported-configuration
|
||||
Optional<ConsentConfiguration> get_supported_configuration(KeySystem const& implementation, MediaKeySystemConfiguration const& candidate_configuration, URL::Origin const& origin)
|
||||
Optional<ConsentConfiguration> get_supported_configuration(KeySystem const& implementation, Bindings::MediaKeySystemConfiguration const& candidate_configuration, URL::Origin const& origin)
|
||||
{
|
||||
// 1. Let supported configuration be ConsentDenied.
|
||||
Optional<ConsentConfiguration> supported_configuration = ConsentConfiguration { ConsentStatus::ConsentDenied, {} };
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ bool supports_container(Utf16String const& container);
|
|||
bool is_persistent_session_type(Utf16String const& session_type);
|
||||
bool is_supported_key_system(Utf16String const& key_system);
|
||||
NonnullOwnPtr<KeySystem> key_system_from_string(Utf16String const& key_system);
|
||||
ConsentStatus get_consent_status(MediaKeySystemConfiguration const&, MediaKeyRestrictions&, URL::Origin const&);
|
||||
Optional<Vector<MediaKeySystemMediaCapability>> get_supported_capabilities_for_audio_video_type(KeySystem const&, CapabilitiesType, Vector<MediaKeySystemMediaCapability>, MediaKeySystemConfiguration, MediaKeyRestrictions);
|
||||
Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem const&, MediaKeySystemConfiguration const&, MediaKeyRestrictions&, URL::Origin const&);
|
||||
Optional<ConsentConfiguration> get_supported_configuration(KeySystem const&, MediaKeySystemConfiguration const&, URL::Origin const&);
|
||||
ConsentStatus get_consent_status(Bindings::MediaKeySystemConfiguration const&, MediaKeyRestrictions&, URL::Origin const&);
|
||||
Optional<Vector<Bindings::MediaKeySystemMediaCapability>> get_supported_capabilities_for_audio_video_type(KeySystem const&, CapabilitiesType, Vector<Bindings::MediaKeySystemMediaCapability>, Bindings::MediaKeySystemConfiguration, MediaKeyRestrictions);
|
||||
Optional<ConsentConfiguration> get_supported_configuration_and_consent(KeySystem const&, Bindings::MediaKeySystemConfiguration const&, MediaKeyRestrictions&, URL::Origin const&);
|
||||
Optional<ConsentConfiguration> get_supported_configuration(KeySystem const&, Bindings::MediaKeySystemConfiguration const&, URL::Origin const&);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,6 @@ struct MediaKeySystemMediaCapability {
|
|||
Utf16String robustness;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemconfiguration
|
||||
struct MediaKeySystemConfiguration {
|
||||
Utf16String label;
|
||||
Vector<Utf16String> init_data_types;
|
||||
Vector<MediaKeySystemMediaCapability> audio_capabilities;
|
||||
Vector<MediaKeySystemMediaCapability> video_capabilities;
|
||||
Bindings::MediaKeysRequirement distinctive_identifier { Bindings::MediaKeysRequirement::Optional };
|
||||
Bindings::MediaKeysRequirement persistent_state { Bindings::MediaKeysRequirement::Optional };
|
||||
Optional<Vector<Utf16String>> session_types;
|
||||
};
|
||||
|
||||
struct MediaKeyRestrictions {
|
||||
bool distinctive_identifiers { true };
|
||||
bool persist_state { true };
|
||||
|
|
@ -48,7 +37,7 @@ enum ConsentStatus {
|
|||
|
||||
struct ConsentConfiguration {
|
||||
ConsentStatus status { ConsentStatus::ConsentDenied };
|
||||
Optional<MediaKeySystemConfiguration> configuration;
|
||||
Optional<Bindings::MediaKeySystemConfiguration> configuration;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public:
|
|||
virtual bool supports_init_data_type(Utf16String const& init_data_type) const = 0;
|
||||
virtual bool supports_encryption_scheme(Utf16String const& encryption_scheme) const = 0;
|
||||
virtual bool supports_robustness(Utf16String const& robustness) const = 0;
|
||||
virtual bool definitely_supports_playback(Utf16String const& container, Utf16String const& media_types, Optional<Utf16String> encryption_scheme, Utf16String const& robustness, MediaKeySystemConfiguration const& accumulated_configuration, MediaKeyRestrictions const& restrictions) const = 0;
|
||||
virtual bool definitely_supports_playback(Utf16String const& container, Utf16String const& media_types, Optional<Utf16String> encryption_scheme, Utf16String const& robustness, Bindings::MediaKeySystemConfiguration const& accumulated_configuration, MediaKeyRestrictions const& restrictions) const = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
|
@ -55,7 +55,7 @@ public:
|
|||
return robustness.is_empty();
|
||||
}
|
||||
|
||||
virtual bool definitely_supports_playback(Utf16String const& container, Utf16String const& media_types, Optional<Utf16String> encryption_scheme, Utf16String const& robustness, MediaKeySystemConfiguration const& accumulated_configuration, MediaKeyRestrictions const& restrictions) const override
|
||||
virtual bool definitely_supports_playback(Utf16String const& container, Utf16String const& media_types, Optional<Utf16String> encryption_scheme, Utf16String const& robustness, Bindings::MediaKeySystemConfiguration const& accumulated_configuration, MediaKeyRestrictions const& restrictions) const override
|
||||
{
|
||||
(void)container;
|
||||
(void)media_types;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ GC_DEFINE_ALLOCATOR(MediaKeySystemAccess);
|
|||
|
||||
MediaKeySystemAccess::~MediaKeySystemAccess() = default;
|
||||
|
||||
MediaKeySystemAccess::MediaKeySystemAccess(JS::Realm& realm, Utf16String const& key_system, MediaKeySystemConfiguration configuration, NonnullOwnPtr<KeySystem> cdm_implementation)
|
||||
MediaKeySystemAccess::MediaKeySystemAccess(JS::Realm& realm, Utf16String const& key_system, Bindings::MediaKeySystemConfiguration configuration, NonnullOwnPtr<KeySystem> cdm_implementation)
|
||||
: PlatformObject(realm)
|
||||
, m_key_system(key_system)
|
||||
, m_configuration(move(configuration))
|
||||
|
|
@ -22,7 +22,7 @@ MediaKeySystemAccess::MediaKeySystemAccess(JS::Realm& realm, Utf16String const&
|
|||
{
|
||||
}
|
||||
|
||||
GC::Ref<MediaKeySystemAccess> MediaKeySystemAccess::create(JS::Realm& realm, Utf16String const& key_system, MediaKeySystemConfiguration configuration, NonnullOwnPtr<KeySystem> cdm_implementation)
|
||||
GC::Ref<MediaKeySystemAccess> MediaKeySystemAccess::create(JS::Realm& realm, Utf16String const& key_system, Bindings::MediaKeySystemConfiguration configuration, NonnullOwnPtr<KeySystem> cdm_implementation)
|
||||
{
|
||||
return realm.create<MediaKeySystemAccess>(realm, key_system, configuration, move(cdm_implementation));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,19 +21,19 @@ class MediaKeySystemAccess : public Bindings::PlatformObject {
|
|||
|
||||
public:
|
||||
virtual ~MediaKeySystemAccess() override;
|
||||
[[nodiscard]] static GC::Ref<MediaKeySystemAccess> create(JS::Realm&, Utf16String const&, MediaKeySystemConfiguration, NonnullOwnPtr<KeySystem>);
|
||||
[[nodiscard]] static GC::Ref<MediaKeySystemAccess> create(JS::Realm&, Utf16String const&, Bindings::MediaKeySystemConfiguration, NonnullOwnPtr<KeySystem>);
|
||||
|
||||
[[nodiscard]] Utf16String key_system() const { return m_key_system; }
|
||||
[[nodiscard]] MediaKeySystemConfiguration get_configuration() const { return m_configuration; }
|
||||
[[nodiscard]] Bindings::MediaKeySystemConfiguration get_configuration() const { return m_configuration; }
|
||||
|
||||
protected:
|
||||
explicit MediaKeySystemAccess(JS::Realm&, Utf16String const&, MediaKeySystemConfiguration, NonnullOwnPtr<KeySystem>);
|
||||
explicit MediaKeySystemAccess(JS::Realm&, Utf16String const&, Bindings::MediaKeySystemConfiguration, NonnullOwnPtr<KeySystem>);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
private:
|
||||
Utf16String m_key_system;
|
||||
|
||||
MediaKeySystemConfiguration m_configuration;
|
||||
Bindings::MediaKeySystemConfiguration m_configuration;
|
||||
NonnullOwnPtr<KeySystem> m_cdm_implementation;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
namespace Web::EncryptedMediaExtensions {
|
||||
|
||||
// https://w3c.github.io/encrypted-media/#dom-navigator-requestmediakeysystemaccess
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> NavigatorEncryptedMediaExtensionsPartial::request_media_key_system_access(Utf16String key_system, Vector<MediaKeySystemConfiguration> supported_configurations)
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> NavigatorEncryptedMediaExtensionsPartial::request_media_key_system_access(Utf16String key_system, Vector<Bindings::MediaKeySystemConfiguration> supported_configurations)
|
||||
{
|
||||
auto& navigator = as<HTML::Navigator>(*this);
|
||||
auto& realm = navigator.realm();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Web::EncryptedMediaExtensions {
|
|||
|
||||
class NavigatorEncryptedMediaExtensionsPartial {
|
||||
public:
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> request_media_key_system_access(Utf16String, Vector<MediaKeySystemConfiguration>);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> request_media_key_system_access(Utf16String, Vector<Bindings::MediaKeySystemConfiguration>);
|
||||
|
||||
private:
|
||||
virtual ~NavigatorEncryptedMediaExtensionsPartial() = default;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue