aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/element.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-13 08:26:28 -0500
committerGitHub <noreply@github.com>2020-02-13 08:26:28 -0500
commite3a2301efe911dfa232803a293f62c16ffdd3925 (patch)
treeb0f4a74dade56bddf7a8c2ae2241302e5e10e3c5 /components/script/dom/element.rs
parent43c558fa597901f30f6994e2d99858f2954fdce2 (diff)
parent3f8a9f63821abff0c7a284cd4d3bb75f41ea3cd4 (diff)
downloadservo-e3a2301efe911dfa232803a293f62c16ffdd3925.tar.gz
servo-e3a2301efe911dfa232803a293f62c16ffdd3925.zip
Auto merge of #25629 - pshaughn:reflect_translate, r=jdm
Implement "translate" attribute This attribute is almost a straightforward enumerated one, but the getter value inherits from parents when the content attribute is absent, even when the parents are non-HTML elements. This initial commit is using LocalName::from on a static string; once html5ever has a release with "translate" in the built-in local name list, a small change will be needed. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25628 <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r--components/script/dom/element.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index c26e492d544..3c321d83f54 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -523,6 +523,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)]