mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 06:40:05 +00:00
LibWeb: Set user activation when this
is Document
EventTarget::dispatch_event, per comments, does ad-hoc solution for UA, and I don't know why it checks if `this` is window or `element`, but web platform tests would fail, because `this` would actually be a `Document` type.
This commit is contained in:
parent
d8cb5fc788
commit
2fc8fdf381
1 changed files with 14 additions and 8 deletions
|
@ -859,16 +859,22 @@ bool EventTarget::dispatch_event(Event& event)
|
||||||
auto unsafe_shared_time = HighResolutionTime::unsafe_shared_current_time();
|
auto unsafe_shared_time = HighResolutionTime::unsafe_shared_current_time();
|
||||||
auto current_time = HighResolutionTime::relative_high_resolution_time(unsafe_shared_time, realm().global_object());
|
auto current_time = HighResolutionTime::relative_high_resolution_time(unsafe_shared_time, realm().global_object());
|
||||||
|
|
||||||
if (is<HTML::Window>(this)) {
|
GC::Ptr<HTML::Window> window = [&]() {
|
||||||
auto* window = static_cast<HTML::Window*>(this);
|
if (is<HTML::Window>(this))
|
||||||
|
return GC::Ptr { static_cast<HTML::Window*>(this) };
|
||||||
|
|
||||||
|
if (is<DOM::Element>(this))
|
||||||
|
return static_cast<DOM::Element const*>(this)->document().window();
|
||||||
|
|
||||||
|
if (is<DOM::Document>(this))
|
||||||
|
return static_cast<DOM::Document const*>(this)->window();
|
||||||
|
|
||||||
|
return GC::Ptr<HTML::Window> { nullptr };
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (window) {
|
||||||
window->set_last_activation_timestamp(current_time);
|
window->set_last_activation_timestamp(current_time);
|
||||||
window->close_watcher_manager()->notify_about_user_activation();
|
window->close_watcher_manager()->notify_about_user_activation();
|
||||||
} else if (is<DOM::Element>(this)) {
|
|
||||||
auto const* element = static_cast<DOM::Element const*>(this);
|
|
||||||
if (auto window = element->document().window()) {
|
|
||||||
window->set_last_activation_timestamp(current_time);
|
|
||||||
window->close_watcher_manager()->notify_about_user_activation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue