style: [css-lists-3] Make 'none' invalid as a <counter-style> in counter()/counters().

CSSWG resolution:
https://github.com/w3c/csswg-drafts/issues/4163#issuecomment-521331100

Spec:
https://drafts.csswg.org/css-lists-3/#counter-functions

Differential Revision: https://phabricator.services.mozilla.com/D43893
This commit is contained in:
Mats Palmgren 2019-08-30 00:15:37 +00:00 committed by Emilio Cobos Álvarez
parent 1406ae7f39
commit f7a87c49b1
7 changed files with 63 additions and 63 deletions

View file

@ -2199,10 +2199,15 @@ fn static_assert() {
}
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T) {
use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToName;
use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToString;
use nsstring::{nsACString, nsCStr};
use self::longhands::list_style_type::computed_value::T;
match v {
T::None => unsafe {
Gecko_SetCounterStyleToName(&mut self.gecko.mCounterStyle,
atom!("none").into_addrefed());
}
T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle),
T::String(s) => unsafe {
Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle,
@ -2224,9 +2229,19 @@ fn static_assert() {
pub fn clone_list_style_type(&self) -> longhands::list_style_type::computed_value::T {
use self::longhands::list_style_type::computed_value::T;
use crate::values::Either;
use crate::values::generics::CounterStyleOrNone;
use crate::values::generics::CounterStyle;
use crate::gecko_bindings::bindings;
let result = CounterStyleOrNone::from_gecko_value(&self.gecko.mCounterStyle);
let name = unsafe {
bindings::Gecko_CounterStyle_GetName(&self.gecko.mCounterStyle)
};
if !name.is_null() {
let name = unsafe { Atom::from_raw(name) };
if name == atom!("none") {
return T::None;
}
}
let result = CounterStyle::from_gecko_value(&self.gecko.mCounterStyle);
match result {
Either::First(counter_style) => T::CounterStyle(counter_style),
Either::Second(string) => T::String(string),
@ -2573,7 +2588,7 @@ clip-path
pub fn set_content(&mut self, v: longhands::content::computed_value::T) {
use crate::values::CustomIdent;
use crate::values::generics::counters::{Content, ContentItem};
use crate::values::generics::CounterStyleOrNone;
use crate::values::generics::CounterStyle;
use crate::gecko_bindings::structs::nsStyleContentData;
use crate::gecko_bindings::structs::nsStyleContentAttr;
use crate::gecko_bindings::structs::StyleContentType;
@ -2594,7 +2609,7 @@ clip-path
content_type: StyleContentType,
name: CustomIdent,
sep: &str,
style: CounterStyleOrNone,
style: CounterStyle,
) {
debug_assert!(content_type == StyleContentType::Counter ||
content_type == StyleContentType::Counters);
@ -2724,7 +2739,7 @@ clip-path
use crate::gecko_bindings::structs::StyleContentType;
use crate::values::generics::counters::{Content, ContentItem};
use crate::values::{CustomIdent, Either};
use crate::values::generics::CounterStyleOrNone;
use crate::values::generics::CounterStyle;
use crate::values::specified::Attr;
if self.gecko.mContents.is_empty() {
@ -2769,7 +2784,7 @@ clip-path
Atom::from_raw(gecko_function.mIdent.mRawPtr)
});
let style =
CounterStyleOrNone::from_gecko_value(&gecko_function.mCounterStyle);
CounterStyle::from_gecko_value(&gecko_function.mCounterStyle);
let style = match style {
Either::First(counter_style) => counter_style,
Either::Second(_) =>

View file

@ -61,31 +61,23 @@
let position = unwrap_or_initial!(list_style_position, position);
fn list_style_type_none() -> list_style_type::SpecifiedValue {
% if engine == "gecko":
use crate::values::generics::CounterStyleOrNone;
list_style_type::SpecifiedValue::CounterStyle(CounterStyleOrNone::None)
% else:
list_style_type::SpecifiedValue::None
% endif
}
// If there are two `none`s, then we can't have a type or image; if there is one `none`,
// then we can't have both a type *and* an image; if there is no `none` then we're fine as
// long as we parsed something.
use self::list_style_type::SpecifiedValue as ListStyleType;
match (any, nones, list_style_type, image) {
(true, 2, None, None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type_none(),
list_style_type: ListStyleType::None,
})
}
(true, 1, None, Some(image)) => {
Ok(expanded! {
list_style_position: position,
list_style_image: image,
list_style_type: list_style_type_none(),
list_style_type: ListStyleType::None,
})
}
(true, 1, Some(list_style_type), None) => {
@ -99,7 +91,7 @@
Ok(expanded! {
list_style_position: position,
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type_none(),
list_style_type: ListStyleType::None,
})
}
(true, 0, list_style_type, image) => {