-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement toggleevents for dialog open/close #23332
base: main
Are you sure you want to change the base?
Conversation
EWS run on previous version of this PR (hash ef08e8f) |
Is this is in the spec somewhere? |
https://bugs.webkit.org/show_bug.cgi?id=268160 Reviewed by NOBODY (OOPS!). This adds the `beforetoggle` cancelable event to `show()`/`showModal()` calls. If `beforetoggle` isn't cancelled, it will show the dialog and dispatch a `toggle` event. Likewise, the close method adds a NON cancelable `beforetoggle` and `toggle` event. These events can help developers when prepping a dialog to be shown or hidden, such as doing page calculations or kicking off animations. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/toggle-events.tentative-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/toggle-events.tentative.html: Added. * Source/WebCore/html/HTMLDialogElement.cpp: (WebCore::HTMLDialogElement::show): (WebCore::HTMLDialogElement::showModal): (WebCore::HTMLDialogElement::close): (WebCore::HTMLDialogElement::queueDialogToggleEventTask): * Source/WebCore/html/HTMLDialogElement.h:
ef08e8f
to
706583c
Compare
EWS run on current version of this PR (hash 706583c) |
Not yet but we discussed it as TPAC and it was deemed a reasonable addition. Tentative spec PR here: whatwg/html#10091 |
@@ -177,4 +198,21 @@ void HTMLDialogElement::setIsModal(bool newValue) | |||
m_isModal = newValue; | |||
} | |||
|
|||
void HTMLDialogElement::queueDialogToggleEventTask(DialogState oldState, DialogState newState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be shared somehow with the details / popover code to avoid duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had considered this but I also thought it might be better as a follow up PR. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer refactoring details / popover first and then adopting the new shared code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queueDialogToggleEventTask(DialogState::Open, DialogState::Closed); | ||
|
||
queueTaskToDispatchEvent(TaskSource::UserInteraction, Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the close event should be emitted before toggle, to get consistent event ordering (otherwise toggle might fire first when no coalescing is happening, but after when it isn't)
706583c