Skip to content
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

Only compile applicable event handler content attributes #25274

Closed
wants to merge 6 commits into from

Export static arrays for event handler lists

  • Loading branch information
Manishearth committed Dec 13, 2019
commit 56f80c9bc3b8e168f2496bce3941100dd553c75c
@@ -574,9 +574,19 @@ macro_rules! window_event_handlers {
};
}

macro_rules! make_array {
($($name:ident, $get:ident, $set:ident, $event_macro:ident;)+) => {
&[$(stringify!($name)),+]
};
}

pub static GLOBAL_EVENT_HANDLERS: &[&str] = global_event_handlers_list!(make_array);
pub static WINDOW_EVENT_HANDLERS: &[&str] = window_event_handlers_list!(make_array);
pub static WINDOW_DELEGATE_EVENT_HANDLERS: &[&str] = window_event_handlers_list!(make_array, ForwardToWindow);

// https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers
// see webidls/EventHandler.webidl
// As more methods get added, just update them here.
// As more methods get added, just update them here and in DOCUMENT_AND_ELEMENT_EVENT_HANDLERS
macro_rules! document_and_element_event_handlers(
() => (
event_handler!(cut, GetOncut, SetOncut);
@@ -585,6 +595,8 @@ macro_rules! document_and_element_event_handlers(
)
);

pub static DOCUMENT_AND_ELEMENT_EVENT_HANDLERS: &[&str] = &["cut", "copy", "paste"];

#[macro_export]
macro_rules! rooted_vec {
(let mut $name:ident) => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.