mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb/HTML: Implement CloseWatcher::getEnabledState closer to spec
We previously had this implemented in an ad-hoc way, where we used a boolean on the CloseWatcher instead of a proper function with steps. This worked at the time, but causes problems with the current version of the spec, so let's just implement it properly. This commit consciously does not update the spec text, because it's diverted quite a lot. That will happen in a subsequent commit.
This commit is contained in:
parent
c541d14232
commit
a1fbcfb4c6
Notes:
github-actions[bot]
2025-12-04 14:48:26 +00:00
Author: https://github.com/AtkinsSJ
Commit: a1fbcfb4c6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6990
5 changed files with 54 additions and 27 deletions
|
|
@ -1409,9 +1409,8 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
|
|||
}
|
||||
|
||||
// 6. Set element's popover close watcher to the result of establishing a close watcher given element's relevant global object, with:
|
||||
m_popover_close_watcher = CloseWatcher::establish(*document.window());
|
||||
// - cancelAction being to return true.
|
||||
// We simply don't add an event listener for the cancel action.
|
||||
// NB: We simply don't add an event listener for the cancel action.
|
||||
// - closeAction being to hide a popover given element, true, true, false, and null.
|
||||
auto close_callback_function = JS::NativeFunction::create(
|
||||
realm(), [this](JS::VM&) {
|
||||
|
|
@ -1421,9 +1420,11 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
|
|||
},
|
||||
0, Utf16FlyString {}, &realm());
|
||||
auto close_callback = realm().heap().allocate<WebIDL::CallbackType>(*close_callback_function, realm());
|
||||
m_popover_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
|
||||
// - getEnabledState being to return true.
|
||||
m_popover_close_watcher->set_enabled(true);
|
||||
auto get_enabled_state = GC::create_function(heap(), [] { return true; });
|
||||
|
||||
m_popover_close_watcher = CloseWatcher::establish(*document.window(), move(get_enabled_state));
|
||||
m_popover_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
|
||||
}
|
||||
// FIXME: 19. Set element's previously focused element to null.
|
||||
// FIXME: 20. Let originallyFocusedElement be document's focused area of the document's DOM anchor.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue