mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
ol[type=…] and li[type=…] preshints need to be case-sensitive
This commit is contained in:
parent
853b688d0b
commit
7149a6a29d
7 changed files with 53 additions and 19 deletions
|
@ -2451,6 +2451,11 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
}
|
||||
},
|
||||
|
||||
NonTSPseudoClass::ServoCaseSensitiveTypeAttr(ref expected_value) => {
|
||||
self.get_attribute(&ns!(), &local_name!("type"))
|
||||
.map_or(false, |attr| attr.value().eq(expected_value))
|
||||
}
|
||||
|
||||
// FIXME(#15746): This is wrong, we need to instead use extended filtering as per RFC4647
|
||||
// https://tools.ietf.org/html/rfc4647#section-3.3.2
|
||||
NonTSPseudoClass::Lang(ref lang) => extended_filtering(&*self.get_lang(), &*lang),
|
||||
|
|
|
@ -706,7 +706,10 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
_ => true,
|
||||
}
|
||||
},
|
||||
|
||||
NonTSPseudoClass::ServoCaseSensitiveTypeAttr(ref expected_value) => {
|
||||
self.get_attr_enum(&ns!(), &local_name!("type"))
|
||||
.map_or(false, |attr| attr == expected_value)
|
||||
}
|
||||
NonTSPseudoClass::ReadOnly =>
|
||||
!self.element.get_state_for_layout().contains(pseudo_class.state_flag()),
|
||||
|
||||
|
|
|
@ -379,6 +379,15 @@ impl ::std::ops::Deref for AttrValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq<Atom> for AttrValue {
|
||||
fn eq(&self, other: &Atom) -> bool {
|
||||
match *self {
|
||||
AttrValue::Atom(ref value) => value == other,
|
||||
_ => other == &**self,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#rules-for-parsing-non-zero-dimension-values
|
||||
pub fn parse_nonzero_length(value: &str) -> LengthOrPercentageOrAuto {
|
||||
match parse_length(value) {
|
||||
|
|
|
@ -175,6 +175,7 @@ pub enum NonTSPseudoClass {
|
|||
ReadWrite,
|
||||
ReadOnly,
|
||||
ServoNonZeroBorder,
|
||||
ServoCaseSensitiveTypeAttr(Atom),
|
||||
Target,
|
||||
Visited,
|
||||
}
|
||||
|
@ -182,10 +183,18 @@ pub enum NonTSPseudoClass {
|
|||
impl ToCss for NonTSPseudoClass {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
use self::NonTSPseudoClass::*;
|
||||
if let Lang(ref lang) = *self {
|
||||
dest.write_str(":lang(")?;
|
||||
serialize_identifier(lang, dest)?;
|
||||
return dest.write_str(")");
|
||||
match *self {
|
||||
Lang(ref lang) => {
|
||||
dest.write_str(":lang(")?;
|
||||
serialize_identifier(lang, dest)?;
|
||||
return dest.write_str(")")
|
||||
}
|
||||
ServoCaseSensitiveTypeAttr(ref value) => {
|
||||
dest.write_str(":-servo-case-sensitive-type-attr(")?;
|
||||
serialize_identifier(value, dest)?;
|
||||
return dest.write_str(")")
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
dest.write_str(match *self {
|
||||
|
@ -198,7 +207,6 @@ impl ToCss for NonTSPseudoClass {
|
|||
Fullscreen => ":fullscreen",
|
||||
Hover => ":hover",
|
||||
Indeterminate => ":indeterminate",
|
||||
Lang(_) => unreachable!(),
|
||||
Link => ":link",
|
||||
PlaceholderShown => ":placeholder-shown",
|
||||
ReadWrite => ":read-write",
|
||||
|
@ -206,6 +214,8 @@ impl ToCss for NonTSPseudoClass {
|
|||
ServoNonZeroBorder => ":-servo-nonzero-border",
|
||||
Target => ":target",
|
||||
Visited => ":visited",
|
||||
Lang(_) |
|
||||
ServoCaseSensitiveTypeAttr(_) => unreachable!(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -244,7 +254,8 @@ impl NonTSPseudoClass {
|
|||
Lang(_) |
|
||||
Link |
|
||||
Visited |
|
||||
ServoNonZeroBorder => ElementState::empty(),
|
||||
ServoNonZeroBorder |
|
||||
ServoCaseSensitiveTypeAttr(_) => ElementState::empty(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +324,15 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> {
|
|||
-> Result<NonTSPseudoClass, ()> {
|
||||
use self::NonTSPseudoClass::*;
|
||||
let pseudo_class = match_ignore_ascii_case!{ &name,
|
||||
"lang" => Lang(String::from(try!(parser.expect_ident_or_string())).into_boxed_str()),
|
||||
"lang" => {
|
||||
Lang(parser.expect_ident_or_string()?.into_owned().into_boxed_str())
|
||||
}
|
||||
"-servo-case-sensitive-type-attr" => {
|
||||
if !self.in_user_agent_stylesheet() {
|
||||
return Err(());
|
||||
}
|
||||
ServoCaseSensitiveTypeAttr(Atom::from(parser.expect_ident()?))
|
||||
}
|
||||
_ => return Err(())
|
||||
};
|
||||
|
||||
|
|
|
@ -18,11 +18,15 @@ br[clear=right i] { clear: right; }
|
|||
br[clear=all i], br[clear=both i] { clear: both; }
|
||||
|
||||
|
||||
ol[type=1], li[type=1] { list-style-type: decimal; }
|
||||
ol[type=a], li[type=a] { list-style-type: lower-alpha; }
|
||||
ol[type=A], li[type=A] { list-style-type: upper-alpha; }
|
||||
ol[type=i], li[type=i] { list-style-type: lower-roman; }
|
||||
ol[type=I], li[type=I] { list-style-type: upper-roman; }
|
||||
ol[type="1"], li[type="1"] { list-style-type: decimal; }
|
||||
ol:-servo-case-sensitive-type-attr(a),
|
||||
li:-servo-case-sensitive-type-attr(a) { list-style-type: lower-alpha; }
|
||||
ol:-servo-case-sensitive-type-attr(A),
|
||||
li:-servo-case-sensitive-type-attr(A) { list-style-type: upper-alpha; }
|
||||
ol:-servo-case-sensitive-type-attr(i),
|
||||
li:-servo-case-sensitive-type-attr(i) { list-style-type: lower-roman; }
|
||||
ol:-servo-case-sensitive-type-attr(I),
|
||||
li:-servo-case-sensitive-type-attr(I) { list-style-type: upper-roman; }
|
||||
ul[type=none i], li[type=none i] { list-style-type: none; }
|
||||
ul[type=disc i], li[type=disc i] { list-style-type: disc; }
|
||||
ul[type=circle i], li[type=circle i] { list-style-type: circle; }
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[li-type-supported-xhtml.xhtml]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[li-type-supported.html]
|
||||
type: reftest
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue