mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
script: Add an initial command and commandfor attribute implementation (#41237)
Initial command and commandfor attribute implementation Testing: Covered by WPTs Signed-off-by: Luke Warlow <lwarlow@igalia.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
use html5ever::LocalName;
|
||||
use js::context::JSContext;
|
||||
use script_bindings::root::DomRoot;
|
||||
use script_bindings::script_runtime::CanGc;
|
||||
use style::attr::AttrValue;
|
||||
|
||||
@@ -59,6 +60,8 @@ use crate::dom::html::htmltemplateelement::HTMLTemplateElement;
|
||||
use crate::dom::html::htmltextareaelement::HTMLTextAreaElement;
|
||||
use crate::dom::html::htmltitleelement::HTMLTitleElement;
|
||||
use crate::dom::html::htmlvideoelement::HTMLVideoElement;
|
||||
use crate::dom::htmlbuttonelement::CommandState;
|
||||
use crate::dom::htmldialogelement::HTMLDialogElement;
|
||||
use crate::dom::node::{BindContext, ChildrenMutation, CloneChildrenFlag, Node, UnbindContext};
|
||||
use crate::dom::shadowroot::ShadowRoot;
|
||||
use crate::dom::svg::svgelement::SVGElement;
|
||||
@@ -138,6 +141,23 @@ pub(crate) trait VirtualMethods {
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#is-valid-command-steps>
|
||||
fn is_valid_command_steps(&self, command: CommandState) -> bool {
|
||||
self.super_type()
|
||||
.is_some_and(|super_type| super_type.is_valid_command_steps(command))
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#command-steps>
|
||||
fn command_steps(
|
||||
&self,
|
||||
button: DomRoot<HTMLButtonElement>,
|
||||
command: CommandState,
|
||||
can_gc: CanGc,
|
||||
) -> bool {
|
||||
self.super_type()
|
||||
.is_some_and(|super_type| super_type.command_steps(button, command, can_gc))
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#concept-node-adopt-ext>
|
||||
fn adopting_steps(&self, old_doc: &Document, can_gc: CanGc) {
|
||||
if let Some(s) = self.super_type() {
|
||||
@@ -194,6 +214,9 @@ pub(crate) fn vtable_for(node: &Node) -> &dyn VirtualMethods {
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLDetailsElement)) => {
|
||||
node.downcast::<HTMLDetailsElement>().unwrap() as &dyn VirtualMethods
|
||||
},
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLDialogElement)) => {
|
||||
node.downcast::<HTMLDialogElement>().unwrap() as &dyn VirtualMethods
|
||||
},
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFieldSetElement)) => {
|
||||
node.downcast::<HTMLFieldSetElement>().unwrap() as &dyn VirtualMethods
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user