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 lazy statics

  • Loading branch information
Manishearth committed Dec 13, 2019
commit 5975eba66efcad1d9e2273227a18acd50a189e6d
@@ -580,9 +580,9 @@ macro_rules! make_array {
};
}

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);
static GLOBAL_EVENT_HANDLERS: &[&str] = global_event_handlers_list!(make_array);
static WINDOW_DELEGATE_EVENT_HANDLERS: &[&str] =
window_event_handlers_list!(make_array, ForwardToWindow);

// https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers
// see webidls/EventHandler.webidl
@@ -595,7 +595,25 @@ macro_rules! document_and_element_event_handlers(
)
);

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

// XXXManishearth ideally we can construct these maps at compile time using phf map and a proc macro
use html5ever::LocalName;
use std::collections::HashSet;
lazy_static! {
pub static ref ELEMENT_EVENT_HANDLERS: HashSet<LocalName> = GLOBAL_EVENT_HANDLERS
.iter()
.chain(DOCUMENT_AND_ELEMENT_EVENT_HANDLERS.iter())
.copied()
.map(Into::into)
.collect();
pub static ref BODY_FRAMESET_EVENT_HANDLERS: HashSet<LocalName> =
WINDOW_DELEGATE_EVENT_HANDLERS
.iter()
.copied()
.map(Into::into)
.collect();
}

#[macro_export]
macro_rules! rooted_vec {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.