mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Track custom element state
This commit is contained in:
parent
e700006fb2
commit
9f51c7df21
6 changed files with 59 additions and 21 deletions
|
@ -150,6 +150,8 @@ pub struct Element {
|
|||
/// https://dom.spec.whatwg.org/#concept-element-custom-element-definition
|
||||
#[ignore_heap_size_of = "Rc"]
|
||||
custom_element_definition: DOMRefCell<Option<Rc<CustomElementDefinition>>>,
|
||||
/// https://dom.spec.whatwg.org/#concept-element-custom-element-state
|
||||
custom_element_state: Cell<CustomElementState>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Element {
|
||||
|
@ -179,6 +181,15 @@ pub enum CustomElementCreationMode {
|
|||
Asynchronous,
|
||||
}
|
||||
|
||||
/// https://dom.spec.whatwg.org/#concept-element-custom-element-state
|
||||
#[derive(Clone, Copy, PartialEq, Eq, HeapSizeOf, JSTraceable)]
|
||||
pub enum CustomElementState {
|
||||
Undefined,
|
||||
Failed,
|
||||
Uncustomized,
|
||||
Custom,
|
||||
}
|
||||
|
||||
impl ElementCreator {
|
||||
pub fn is_parser_created(&self) -> bool {
|
||||
match *self {
|
||||
|
@ -255,6 +266,7 @@ impl Element {
|
|||
selector_flags: Cell::new(ElementSelectorFlags::empty()),
|
||||
custom_element_reaction_queue: Default::default(),
|
||||
custom_element_definition: Default::default(),
|
||||
custom_element_state: Cell::new(CustomElementState::Uncustomized),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,6 +301,14 @@ impl Element {
|
|||
self.is.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn set_custom_element_state(&self, state: CustomElementState) {
|
||||
self.custom_element_state.set(state);
|
||||
}
|
||||
|
||||
pub fn get_custom_element_state(&self) -> CustomElementState {
|
||||
self.custom_element_state.get()
|
||||
}
|
||||
|
||||
pub fn set_custom_element_definition(&self, definition: Rc<CustomElementDefinition>) {
|
||||
*self.custom_element_definition.borrow_mut() = Some(definition);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue