mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Translate attribute and its inheritance semantics
This commit is contained in:
parent
d0f64d9d56
commit
3f8a9f6382
11 changed files with 38 additions and 44 deletions
|
@ -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)]
|
||||
|
|
|
@ -516,6 +516,23 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// Step 7.
|
||||
Node::replace_all(Some(fragment.upcast()), self.upcast::<Node>());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-translate
|
||||
fn Translate(&self) -> bool {
|
||||
self.upcast::<Element>().is_translate_enabled()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-translate
|
||||
fn SetTranslate(&self, yesno: bool) {
|
||||
self.upcast::<Element>().set_string_attribute(
|
||||
// TODO change this to local_name! when html5ever updates
|
||||
&LocalName::from("translate"),
|
||||
match yesno {
|
||||
true => DOMString::from("yes"),
|
||||
false => DOMString::from("no"),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn append_text_node_to_fragment(document: &Document, fragment: &DocumentFragment, text: String) {
|
||||
|
|
|
@ -12,8 +12,8 @@ interface HTMLElement : Element {
|
|||
attribute DOMString title;
|
||||
[CEReactions]
|
||||
attribute DOMString lang;
|
||||
// [CEReactions]
|
||||
// attribute boolean translate;
|
||||
[CEReactions]
|
||||
attribute boolean translate;
|
||||
// [CEReactions]
|
||||
// attribute DOMString dir;
|
||||
readonly attribute DOMStringMap dataset;
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
[HTMLElement.html]
|
||||
type: testharness
|
||||
[translate on HTMLElement must enqueue an attributeChanged reaction when adding translate content attribute]
|
||||
expected: FAIL
|
||||
|
||||
[translate on HTMLElement must enqueue an attributeChanged reaction when replacing an existing attribute]
|
||||
expected: FAIL
|
||||
|
||||
[dir on HTMLElement must enqueue an attributeChanged reaction when adding dir content attribute]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[the-translate-attribute-007.html]
|
||||
type: testharness
|
||||
[In the default case, ie. with no translate attribute in the page, javascript will detect the translation mode of text as translate-enabled.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[the-translate-attribute-008.html]
|
||||
type: testharness
|
||||
[If the translate attribute is set to yes, javascript will detect the translation mode of text as translate-enabled.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[the-translate-attribute-009.html]
|
||||
type: testharness
|
||||
[If the translate attribute is set to no, javascript will detect the translation mode of text as no-translate.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[the-translate-attribute-010.html]
|
||||
type: testharness
|
||||
[If the translate attribute is set to no, javascript will detect the translation mode of elements inside that element with no translate flag as no-translate.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[the-translate-attribute-011.html]
|
||||
type: testharness
|
||||
[If the translate attribute is set to yes on an element inside an element with the translate attribute set to no, javascript will detect the translation mode of text in the inner element as translate-enabled.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[the-translate-attribute-012.html]
|
||||
type: testharness
|
||||
[If the translate attribute is set to a null string, javascript will detect the translation mode of text as translate-enabled.]
|
||||
expected: FAIL
|
||||
|
|
@ -2424,9 +2424,6 @@
|
|||
[HTMLObjectElement interface: attribute name]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: document.createElement("noscript") must inherit property "translate" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLFrameElement interface: document.createElement("frame") must inherit property "contentWindow" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -3765,9 +3762,6 @@
|
|||
[HTMLAreaElement interface: attribute hostname]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: attribute translate]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLTableColElement interface: attribute span]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue