зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1784058 - Do not allow a list of strings in the @font-face src descriptor's format() function, only a single format string. r=emilio
This aligns with CSS Fonts 4 (rather than Fonts 3) and with behavior in other browsers; I don't expect any significant breakage, given that specifying multiple format strings was never supported in other engines AFAIK, and never served any useful purpose. Differential Revision: https://phabricator.services.mozilla.com/D154235
This commit is contained in:
Родитель
481afa5a20
Коммит
91d8e38d70
|
@ -28,7 +28,6 @@ use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
|
|||
use cssparser::{CowRcStr, SourceLocation};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::values::SequenceWriter;
|
||||
use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError};
|
||||
use style_traits::{StyleParseErrorKind, ToCss};
|
||||
|
||||
|
@ -72,8 +71,8 @@ pub enum FontFaceSourceListComponent {
|
|||
pub struct UrlSource {
|
||||
/// The specified url.
|
||||
pub url: SpecifiedUrl,
|
||||
/// The format hints specified with the `format()` function.
|
||||
pub format_hints: Vec<String>,
|
||||
/// The format hint specified with the `format()` function, if present.
|
||||
pub format_hint: Option<String>,
|
||||
}
|
||||
|
||||
impl ToCss for UrlSource {
|
||||
|
@ -82,14 +81,9 @@ impl ToCss for UrlSource {
|
|||
W: fmt::Write,
|
||||
{
|
||||
self.url.to_css(dest)?;
|
||||
if !self.format_hints.is_empty() {
|
||||
if let Some(hint) = &self.format_hint {
|
||||
dest.write_str(" format(")?;
|
||||
{
|
||||
let mut writer = SequenceWriter::new(dest, ", ");
|
||||
for hint in self.format_hints.iter() {
|
||||
writer.item(hint)?;
|
||||
}
|
||||
}
|
||||
dest.write_str(&hint)?;
|
||||
dest.write_char(')')?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -334,14 +328,11 @@ impl<'a> FontFace<'a> {
|
|||
.rev()
|
||||
.filter(|source| {
|
||||
if let Source::Url(ref url_source) = **source {
|
||||
let hints = &url_source.format_hints;
|
||||
// We support only opentype fonts and truetype is an alias for
|
||||
// that format. Sources without format hints need to be
|
||||
// downloaded in case we support them.
|
||||
hints.is_empty() ||
|
||||
hints.iter().any(|hint| {
|
||||
hint == "truetype" || hint == "opentype" || hint == "woff"
|
||||
})
|
||||
url_source.format_hint.as_ref().map_or(true,
|
||||
|hint| hint == "truetype" || hint == "opentype" || hint == "woff")
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
@ -393,20 +384,20 @@ impl Parse for Source {
|
|||
let url = SpecifiedUrl::parse(context, input)?;
|
||||
|
||||
// Parsing optional format()
|
||||
let format_hints = if input
|
||||
let format_hint = if input
|
||||
.try_parse(|input| input.expect_function_matching("format"))
|
||||
.is_ok()
|
||||
{
|
||||
input.parse_nested_block(|input| {
|
||||
input.parse_comma_separated(|input| Ok(input.expect_string()?.as_ref().to_owned()))
|
||||
Ok(Some(input.expect_string()?.as_ref().to_owned()))
|
||||
})?
|
||||
} else {
|
||||
vec![]
|
||||
None
|
||||
};
|
||||
|
||||
Ok(Source::Url(UrlSource {
|
||||
url: url,
|
||||
format_hints: format_hints,
|
||||
format_hint: format_hint,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3253,8 +3253,7 @@ pub unsafe extern "C" fn Servo_FontFaceRule_GetSources(
|
|||
};
|
||||
let len = sources.iter().fold(0, |acc, src| {
|
||||
acc + match *src {
|
||||
// Each format hint takes one position in the array of mSrc.
|
||||
Source::Url(ref url) => url.format_hints.len() + 1,
|
||||
Source::Url(ref url) => if url.format_hint.is_some() { 2 } else { 1 },
|
||||
Source::Local(_) => 1,
|
||||
}
|
||||
});
|
||||
|
@ -3272,7 +3271,7 @@ pub unsafe extern "C" fn Servo_FontFaceRule_GetSources(
|
|||
match *source {
|
||||
Source::Url(ref url) => {
|
||||
set_next(FontFaceSourceListComponent::Url(&url.url));
|
||||
for hint in url.format_hints.iter() {
|
||||
if let Some(hint) = &url.format_hint {
|
||||
set_next(FontFaceSourceListComponent::FormatHint {
|
||||
length: hint.len(),
|
||||
utf8_bytes: hint.as_ptr(),
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
[font-face-src-format.html]
|
||||
[Check that src: url("foo.ttf") format("opentype", "truetype") is invalid]
|
||||
expected: FAIL
|
||||
|
||||
[Check that src: url("foo.ttf") format(collection) is valid]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче