diff options
author | Patrick Shaughnessy <pshaughn@comcast.net> | 2020-01-27 22:45:07 -0500 |
---|---|---|
committer | Patrick Shaughnessy <pshaughn@comcast.net> | 2020-02-12 20:54:41 -0500 |
commit | 3f8a9f63821abff0c7a284cd4d3bb75f41ea3cd4 (patch) | |
tree | 34ee55ecfa340f6899f294611e39b6b54bc02909 /components/script/dom/element.rs | |
parent | d0f64d9d56979f66a0de2f239c3fc691b45535d6 (diff) | |
download | servo-3f8a9f63821abff0c7a284cd4d3bb75f41ea3cd4.tar.gz servo-3f8a9f63821abff0c7a284cd4d3bb75f41ea3cd4.zip |
Translate attribute and its inheritance semantics
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 29bdaf2f3bf..cd9fb4481ad 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -514,6 +514,25 @@ impl Element { debug_assert!(false, "Trying to detach a non-attached shadow root"); } } + + // https://html.spec.whatwg.org/multipage/#translation-mode + pub fn is_translate_enabled(&self) -> bool { + // TODO change this to local_name! when html5ever updates + let name = &LocalName::from("translate"); + if self.has_attribute(name) { + match &*self.get_string_attribute(name) { + "yes" | "" => return true, + "no" => return false, + _ => {}, + } + } + if let Some(parent) = self.upcast::<Node>().GetParentNode() { + if let Some(elem) = parent.downcast::<Element>() { + return elem.is_translate_enabled(); + } + } + true // whatwg/html#5239 + } } #[allow(unsafe_code)] |