Cleanups for future script crate split (#35987)

* script: Avoid direct impl blocks on generated dicts and unions.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Remove references to codegen-specific import module.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix tidy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-03-16 09:46:14 -04:00 committed by GitHub
parent 3ecd1c0699
commit d35da38a2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 211 additions and 146 deletions

View file

@ -25,6 +25,7 @@ use servo_url::ServoUrl;
use style::str::HTML_SPACE_CHARACTERS;
use stylo_atoms::Atom;
use crate::conversions::Convert;
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
use crate::dom::bindings::callback::{CallbackContainer, CallbackFunction, ExceptionHandling};
use crate::dom::bindings::cell::DomRefCell;
@ -384,7 +385,7 @@ impl EventListeners {
}
#[dom_struct]
pub(crate) struct EventTarget {
pub struct EventTarget {
reflector_: Reflector,
handlers: DomRefCell<HashMapTracedValues<Atom, EventListeners, BuildHasherDefault<FnvHasher>>>,
}
@ -944,7 +945,7 @@ impl EventTargetMethods<crate::DomTypeHolder> for EventTarget {
listener: Option<Rc<EventListener>>,
options: AddEventListenerOptionsOrBoolean,
) {
self.add_event_listener(ty, listener, options.into())
self.add_event_listener(ty, listener, options.convert())
}
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
@ -954,7 +955,7 @@ impl EventTargetMethods<crate::DomTypeHolder> for EventTarget {
listener: Option<Rc<EventListener>>,
options: EventListenerOptionsOrBoolean,
) {
self.remove_event_listener(ty, listener, options.into())
self.remove_event_listener(ty, listener, options.convert())
}
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
@ -976,11 +977,11 @@ impl VirtualMethods for EventTarget {
}
}
impl From<AddEventListenerOptionsOrBoolean> for AddEventListenerOptions {
fn from(options: AddEventListenerOptionsOrBoolean) -> Self {
match options {
impl Convert<AddEventListenerOptions> for AddEventListenerOptionsOrBoolean {
fn convert(self) -> AddEventListenerOptions {
match self {
AddEventListenerOptionsOrBoolean::AddEventListenerOptions(options) => options,
AddEventListenerOptionsOrBoolean::Boolean(capture) => Self {
AddEventListenerOptionsOrBoolean::Boolean(capture) => AddEventListenerOptions {
parent: EventListenerOptions { capture },
once: false,
passive: None,
@ -989,11 +990,11 @@ impl From<AddEventListenerOptionsOrBoolean> for AddEventListenerOptions {
}
}
impl From<EventListenerOptionsOrBoolean> for EventListenerOptions {
fn from(options: EventListenerOptionsOrBoolean) -> Self {
match options {
impl Convert<EventListenerOptions> for EventListenerOptionsOrBoolean {
fn convert(self) -> EventListenerOptions {
match self {
EventListenerOptionsOrBoolean::EventListenerOptions(options) => options,
EventListenerOptionsOrBoolean::Boolean(capture) => Self { capture },
EventListenerOptionsOrBoolean::Boolean(capture) => EventListenerOptions { capture },
}
}
}