mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
auto merge of #3666 : ttaubert/servo/issue/3644-privatize-dom, r=Manishearth
This PR removes public fields from all (hope I didn't miss any) DOM structs. Should |Page| be privatized as well? This PR additionally introduces a #[privatize] lint to ensure nobody accidentally re-introduces a public field. All changesets compile separately if applied in the same order. Hope that helps reviewing but I can of course squash them before merging.
This commit is contained in:
commit
f350879574
131 changed files with 803 additions and 381 deletions
|
@ -49,21 +49,22 @@ pub enum EventCancelable {
|
|||
|
||||
#[jstraceable]
|
||||
#[must_root]
|
||||
#[privatize]
|
||||
pub struct Event {
|
||||
pub type_id: EventTypeId,
|
||||
type_id: EventTypeId,
|
||||
reflector_: Reflector,
|
||||
pub current_target: MutNullableJS<EventTarget>,
|
||||
pub target: MutNullableJS<EventTarget>,
|
||||
current_target: MutNullableJS<EventTarget>,
|
||||
target: MutNullableJS<EventTarget>,
|
||||
type_: RefCell<DOMString>,
|
||||
pub phase: Cell<EventPhase>,
|
||||
pub canceled: Cell<bool>,
|
||||
pub stop_propagation: Cell<bool>,
|
||||
pub stop_immediate: Cell<bool>,
|
||||
pub cancelable: Cell<bool>,
|
||||
pub bubbles: Cell<bool>,
|
||||
pub trusted: Cell<bool>,
|
||||
pub dispatching: Cell<bool>,
|
||||
pub initialized: Cell<bool>,
|
||||
phase: Cell<EventPhase>,
|
||||
canceled: Cell<bool>,
|
||||
stop_propagation: Cell<bool>,
|
||||
stop_immediate: Cell<bool>,
|
||||
cancelable: Cell<bool>,
|
||||
bubbles: Cell<bool>,
|
||||
trusted: Cell<bool>,
|
||||
dispatching: Cell<bool>,
|
||||
initialized: Cell<bool>,
|
||||
timestamp: u64,
|
||||
}
|
||||
|
||||
|
@ -110,6 +111,61 @@ impl Event {
|
|||
let cancelable = if init.cancelable { Cancelable } else { NotCancelable };
|
||||
Ok(Event::new(global, type_, bubbles, cancelable))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_id<'a>(&'a self) -> &'a EventTypeId {
|
||||
&self.type_id
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn clear_current_target(&self) {
|
||||
self.current_target.clear();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_current_target(&self, val: JSRef<EventTarget>) {
|
||||
self.current_target.assign(Some(val));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_target(&self, val: JSRef<EventTarget>) {
|
||||
self.target.assign(Some(val));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_phase(&self, val: EventPhase) {
|
||||
self.phase.set(val)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn stop_propagation(&self) -> bool {
|
||||
self.stop_propagation.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn stop_immediate(&self) -> bool {
|
||||
self.stop_immediate.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bubbles(&self) -> bool {
|
||||
self.bubbles.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn dispatching(&self) -> bool {
|
||||
self.dispatching.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_dispatching(&self, val: bool) {
|
||||
self.dispatching.set(val)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn initialized(&self) -> bool {
|
||||
self.initialized.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EventMethods for JSRef<'a, Event> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue