mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +00:00
LibWeb/CSS: Add the TransitionEvent type
This commit is contained in:
parent
56e6d4f42d
commit
55b4a983a7
Notes:
github-actions[bot]
2024-12-25 16:15:39 +00:00
Author: https://github.com/LucasChollet
Commit: 55b4a983a7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3024
8 changed files with 379 additions and 0 deletions
|
@ -170,6 +170,7 @@ set(SOURCES
|
|||
CSS/SystemColor.cpp
|
||||
CSS/Time.cpp
|
||||
CSS/Transformation.cpp
|
||||
CSS/TransitionEvent.cpp
|
||||
CSS/VisualViewport.cpp
|
||||
Cookie/Cookie.cpp
|
||||
Cookie/ParsedCookie.cpp
|
||||
|
|
43
Libraries/LibWeb/CSS/TransitionEvent.cpp
Normal file
43
Libraries/LibWeb/CSS/TransitionEvent.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Lucas Chollet <lucas.chollet@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "TransitionEvent.h"
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/TransitionEventPrototype.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(TransitionEvent);
|
||||
|
||||
GC::Ref<TransitionEvent> TransitionEvent::create(JS::Realm& realm, FlyString const& type, 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)
|
||||
{
|
||||
return realm.create<TransitionEvent>(realm, type, event_init);
|
||||
}
|
||||
|
||||
TransitionEvent::TransitionEvent(JS::Realm& realm, FlyString const& type, TransitionEventInit const& event_init)
|
||||
: DOM::Event(realm, type, event_init)
|
||||
, m_property_name(event_init.property_name)
|
||||
, m_elapsed_time(event_init.elapsed_time)
|
||||
, m_pseudo_element(event_init.pseudo_element)
|
||||
{
|
||||
}
|
||||
|
||||
TransitionEvent::~TransitionEvent() = default;
|
||||
|
||||
void TransitionEvent::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(TransitionEvent);
|
||||
}
|
||||
|
||||
}
|
42
Libraries/LibWeb/CSS/TransitionEvent.h
Normal file
42
Libraries/LibWeb/CSS/TransitionEvent.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Lucas Chollet <lucas.chollet@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#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& = {});
|
||||
|
||||
virtual ~TransitionEvent() override;
|
||||
|
||||
String const& property_name() const { return m_property_name; }
|
||||
double elapsed_time() const { return m_elapsed_time; }
|
||||
String const& pseudo_element() const { return m_pseudo_element; }
|
||||
|
||||
private:
|
||||
TransitionEvent(JS::Realm&, FlyString const& event_name, TransitionEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
String m_property_name {};
|
||||
double m_elapsed_time {};
|
||||
String m_pseudo_element {};
|
||||
};
|
||||
}
|
16
Libraries/LibWeb/CSS/TransitionEvent.idl
Normal file
16
Libraries/LibWeb/CSS/TransitionEvent.idl
Normal file
|
@ -0,0 +1,16 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
// https://drafts.csswg.org/css-transitions/#transitionevent
|
||||
[Exposed=Window]
|
||||
interface TransitionEvent : Event {
|
||||
constructor(CSSOMString type, optional TransitionEventInit transitionEventInitDict = {});
|
||||
readonly attribute CSSOMString propertyName;
|
||||
readonly attribute double elapsedTime;
|
||||
readonly attribute CSSOMString pseudoElement;
|
||||
};
|
||||
|
||||
dictionary TransitionEventInit : EventInit {
|
||||
CSSOMString propertyName = "";
|
||||
double elapsedTime = 0.0;
|
||||
CSSOMString pseudoElement = "";
|
||||
};
|
|
@ -46,6 +46,7 @@ libweb_js_bindings(CSS/Screen)
|
|||
libweb_js_bindings(CSS/ScreenOrientation)
|
||||
libweb_js_bindings(CSS/StyleSheet)
|
||||
libweb_js_bindings(CSS/StyleSheetList)
|
||||
libweb_js_bindings(CSS/TransitionEvent)
|
||||
libweb_js_bindings(CSS/VisualViewport)
|
||||
libweb_js_bindings(DOM/AbstractRange)
|
||||
libweb_js_bindings(DOM/Attr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue