diff options
author | Josh Matthews <josh@joshmatthews.net> | 2020-06-12 18:19:49 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2020-06-15 11:22:28 -0400 |
commit | d55424e88f732c663d1ec988a3fbe98d6c9a89e5 (patch) | |
tree | df7a560a43747431fd49ef897b682d987fe4082c /components/script/dom/htmlelement.rs | |
parent | 757371f4f08aca089659fa6774e74bb90b511363 (diff) | |
download | servo-d55424e88f732c663d1ec988a3fbe98d6c9a89e5.tar.gz servo-d55424e88f732c663d1ec988a3fbe98d6c9a89e5.zip |
Update document focus when element focusability changes.
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r-- | components/script/dom/htmlelement.rs | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 1820c4367d5..282e980f2d6 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -28,7 +28,7 @@ use crate::dom::htmlinputelement::{HTMLInputElement, InputType}; use crate::dom::htmllabelelement::HTMLLabelElement; use crate::dom::htmltextareaelement::HTMLTextAreaElement; use crate::dom::node::{document_from_node, window_from_node}; -use crate::dom::node::{BindContext, Node, NodeFlags, ShadowIncluding}; +use crate::dom::node::{Node, ShadowIncluding}; use crate::dom::text::Text; use crate::dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; @@ -91,53 +91,6 @@ impl HTMLElement { let eventtarget = self.upcast::<EventTarget>(); eventtarget.is::<HTMLBodyElement>() || eventtarget.is::<HTMLFrameSetElement>() } - - fn update_sequentially_focusable_status(&self) { - let element = self.upcast::<Element>(); - let node = self.upcast::<Node>(); - if element.has_attribute(&local_name!("tabindex")) { - node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, true); - } else { - match node.type_id() { - NodeTypeId::Element(ElementTypeId::HTMLElement( - HTMLElementTypeId::HTMLButtonElement, - )) | - NodeTypeId::Element(ElementTypeId::HTMLElement( - HTMLElementTypeId::HTMLSelectElement, - )) | - NodeTypeId::Element(ElementTypeId::HTMLElement( - HTMLElementTypeId::HTMLIFrameElement, - )) | - NodeTypeId::Element(ElementTypeId::HTMLElement( - HTMLElementTypeId::HTMLTextAreaElement, - )) => node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, true), - NodeTypeId::Element(ElementTypeId::HTMLElement( - HTMLElementTypeId::HTMLLinkElement, - )) | - NodeTypeId::Element(ElementTypeId::HTMLElement( - HTMLElementTypeId::HTMLAnchorElement, - )) => { - if element.has_attribute(&local_name!("href")) { - node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, true); - } - }, - _ => { - if let Some(attr) = element.get_attribute(&ns!(), &local_name!("draggable")) { - let value = attr.value(); - let is_true = match *value { - AttrValue::String(ref string) => string == "true", - _ => false, - }; - node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, is_true); - } else { - node.set_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE, false); - } - //TODO set SEQUENTIALLY_FOCUSABLE flag if editing host - //TODO set SEQUENTIALLY_FOCUSABLE flag if "sorting interface th elements" - }, - } - } - } } impl HTMLElementMethods for HTMLElement { @@ -855,13 +808,6 @@ impl VirtualMethods for HTMLElement { } } - fn bind_to_tree(&self, context: &BindContext) { - if let Some(ref s) = self.super_type() { - s.bind_to_tree(context); - } - self.update_sequentially_focusable_status(); - } - fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { match name { &local_name!("itemprop") => AttrValue::from_serialized_tokenlist(value.into()), |