Skip to content

Commit ccd16c8

Browse files
shannonboothawesomekling
authored andcommitted
LibWeb: Set timestamp for DOM Events
1 parent 51a52a8 commit ccd16c8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Userland/Libraries/LibWeb/DOM/Document.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,10 +1661,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(StringView i
16611661
// NOTE: These are done in the if-chain above
16621662
// 5. Let event be the result of creating an event given constructor.
16631663
// 6. Initialize event’s type attribute to the empty string.
1664+
// 7. Initialize event’s timeStamp attribute to the result of calling current high resolution time with this’s relevant global object.
16641665
// NOTE: This is handled by each constructor.
16651666

1666-
// FIXME: 7. Initialize event’s timeStamp attribute to the result of calling current high resolution time with this’s relevant global object.
1667-
16681667
// 8. Initialize event’s isTrusted attribute to false.
16691668
event->set_is_trusted(false);
16701669

Userland/Libraries/LibWeb/DOM/Event.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <LibWeb/DOM/Event.h>
1212
#include <LibWeb/DOM/Node.h>
1313
#include <LibWeb/DOM/ShadowRoot.h>
14+
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
1415

1516
namespace Web::DOM {
1617

@@ -26,20 +27,24 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Event::construct_impl(JS::Realm& re
2627
return create(realm, event_name, event_init);
2728
}
2829

30+
// https://dom.spec.whatwg.org/#inner-event-creation-steps
2931
Event::Event(JS::Realm& realm, FlyString const& type)
3032
: PlatformObject(realm)
3133
, m_type(type)
3234
, m_initialized(true)
35+
, m_time_stamp(HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(*this)))
3336
{
3437
}
3538

39+
// https://dom.spec.whatwg.org/#inner-event-creation-steps
3640
Event::Event(JS::Realm& realm, FlyString const& type, EventInit const& event_init)
3741
: PlatformObject(realm)
3842
, m_type(type)
3943
, m_bubbles(event_init.bubbles)
4044
, m_cancelable(event_init.cancelable)
4145
, m_composed(event_init.composed)
4246
, m_initialized(true)
47+
, m_time_stamp(HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(*this)))
4348
{
4449
}
4550

0 commit comments

Comments
 (0)