mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Add some style quirks for legacy ::markers created from list-style-type/list-style-image
Specifically: For "bullets", i.e. 'list-style-type:disc|circle|square| disclosure-closed|disclosure-open', we use a built-in font (-moz-bullet-font, which has glyphs for those symbols + space) to retain mostly backwards compatible rendering for those. Authors may override that with an explicit 'font-family' ::marker style though. We also use this font for 'list-style-image' in case it would fallback to one of the above when the image fails to load (so that we get the same width space). When the -moz-bullet-font is used we also set 'font-synthesis' to avoid synthesizing italic/bold for this font. Authors may override this with an explicit ::marker declaration. We also set 'letter-spacing' and 'word-spacing' to the initial value for bullets for web-compat reasons. Again, authors may override this with an explicit ::marker declaration. (This breaks backwards- compat slightly but makes us compatible with Chrome. We used to ignore these for list-style-type:<string> too.) Differential Revision: https://phabricator.services.mozilla.com/D111693
This commit is contained in:
parent
d2a7ebf789
commit
d7e00ba03d
7 changed files with 128 additions and 1 deletions
|
@ -110,6 +110,14 @@ impl ToComputedValue for specified::WordSpacing {
|
|||
/// A computed value for the `line-height` property.
|
||||
pub type LineHeight = GenericLineHeight<NonNegativeNumber, NonNegativeLength>;
|
||||
|
||||
impl WordSpacing {
|
||||
/// Return the `normal` computed value, which is just zero.
|
||||
#[inline]
|
||||
pub fn normal() -> Self {
|
||||
LengthPercentage::zero()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue)]
|
||||
#[repr(C)]
|
||||
/// text-overflow.
|
||||
|
|
|
@ -95,6 +95,21 @@ impl CounterStyle {
|
|||
pub fn decimal() -> Self {
|
||||
CounterStyle::Name(CustomIdent(atom!("decimal")))
|
||||
}
|
||||
|
||||
/// Is this a bullet? (i.e. `list-style-type: disc|circle|square|disclosure-closed|disclosure-open`)
|
||||
#[inline]
|
||||
pub fn is_bullet(&self) -> bool {
|
||||
match self {
|
||||
CounterStyle::Name(CustomIdent(ref name)) => {
|
||||
name == &atom!("disc") ||
|
||||
name == &atom!("circle") ||
|
||||
name == &atom!("square") ||
|
||||
name == &atom!("disclosure-closed") ||
|
||||
name == &atom!("disclosure-open")
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for CounterStyle {
|
||||
|
|
|
@ -2005,6 +2005,14 @@ impl FontSynthesis {
|
|||
style: true,
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
/// Get the 'none' value of font-synthesis
|
||||
pub fn none() -> Self {
|
||||
FontSynthesis {
|
||||
weight: false,
|
||||
style: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for FontSynthesis {
|
||||
|
|
|
@ -67,6 +67,15 @@ impl ListStyleType {
|
|||
_ => unreachable!("Unknown counter style keyword value"),
|
||||
})))
|
||||
}
|
||||
|
||||
/// Is this a bullet? (i.e. `list-style-type: disc|circle|square|disclosure-closed|disclosure-open`)
|
||||
#[inline]
|
||||
pub fn is_bullet(&self) -> bool {
|
||||
match self {
|
||||
ListStyleType::CounterStyle(ref style) => style.is_bullet(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue