forked from mirrors/gecko-dev
servo: Merge #19038 - Added implementation for itemprop and itemtype along with test files (from CJ8664:master); r=jdm
<!-- Please describe your changes on the following line: --> --- <!-- 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 <!-- Either: --> - [x] There are tests for these changes OR <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: 5227df260c601b86358e08ab88adcc9eca93be45 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 0cf672106d56747fa1f164d37aa17e8ba8ec21d8
This commit is contained in:
parent
a903e7c823
commit
ae622d03ea
4 changed files with 53 additions and 0 deletions
1
servo/.gitignore
vendored
1
servo/.gitignore
vendored
|
|
@ -36,3 +36,4 @@ Servo.app
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
/unminified-js
|
/unminified-js
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ use dom::virtualmethods::VirtualMethods;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use html5ever::{LocalName, Prefix};
|
use html5ever::{LocalName, Prefix};
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use style::attr::AttrValue;
|
use style::attr::AttrValue;
|
||||||
|
|
@ -277,6 +278,38 @@ impl HTMLElementMethods for HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#attr-itemtype
|
||||||
|
fn Itemtypes(&self) -> Option<Vec<DOMString>> {
|
||||||
|
let atoms = self.element.get_tokenlist_attribute(&local_name!("itemtype"), );
|
||||||
|
|
||||||
|
if atoms.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut item_attr_values = HashSet::new();
|
||||||
|
for attr_value in &atoms {
|
||||||
|
item_attr_values.insert(DOMString::from(String::from(attr_value.trim())));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(item_attr_values.into_iter().collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#names:-the-itemprop-attribute
|
||||||
|
fn PropertyNames(&self) -> Option<Vec<DOMString>> {
|
||||||
|
let atoms = self.element.get_tokenlist_attribute(&local_name!("itemprop"), );
|
||||||
|
|
||||||
|
if atoms.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut item_attr_values = HashSet::new();
|
||||||
|
for attr_value in &atoms {
|
||||||
|
item_attr_values.insert(DOMString::from(String::from(attr_value.trim())));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(item_attr_values.into_iter().collect())
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-click
|
// https://html.spec.whatwg.org/multipage/#dom-click
|
||||||
fn Click(&self) {
|
fn Click(&self) {
|
||||||
if !self.upcast::<Element>().disabled_state() {
|
if !self.upcast::<Element>().disabled_state() {
|
||||||
|
|
@ -577,4 +610,17 @@ impl VirtualMethods for HTMLElement {
|
||||||
}
|
}
|
||||||
self.update_sequentially_focusable_status();
|
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()),
|
||||||
|
&local_name!("itemtype") => AttrValue::from_serialized_tokenlist(value.into()),
|
||||||
|
_ => {
|
||||||
|
self.super_type().unwrap().parse_plain_attribute(
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,14 @@ interface HTMLElement : Element {
|
||||||
|
|
||||||
// microdata
|
// microdata
|
||||||
// attribute boolean itemScope;
|
// attribute boolean itemScope;
|
||||||
|
|
||||||
// attribute DOMString itemId;
|
// attribute DOMString itemId;
|
||||||
//readonly attribute HTMLPropertiesCollection properties;
|
//readonly attribute HTMLPropertiesCollection properties;
|
||||||
// attribute any itemValue; // acts as DOMString on setting
|
// attribute any itemValue; // acts as DOMString on setting
|
||||||
|
[Pref="dom.microdata.testing.enabled"]
|
||||||
|
sequence<DOMString>? propertyNames();
|
||||||
|
[Pref="dom.microdata.testing.enabled"]
|
||||||
|
sequence<DOMString>? itemtypes();
|
||||||
|
|
||||||
// user interaction
|
// user interaction
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"dom.customelements.enabled": true,
|
"dom.customelements.enabled": true,
|
||||||
"dom.forcetouch.enabled": false,
|
"dom.forcetouch.enabled": false,
|
||||||
"dom.gamepad.enabled": false,
|
"dom.gamepad.enabled": false,
|
||||||
|
"dom.microdata.testing.enabled": true,
|
||||||
"dom.mouseevent.which.enabled": false,
|
"dom.mouseevent.which.enabled": false,
|
||||||
"dom.mozbrowser.enabled": false,
|
"dom.mozbrowser.enabled": false,
|
||||||
"dom.mutation_observer.enabled": false,
|
"dom.mutation_observer.enabled": false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue