зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 7b5724d9db7b (bug 1906749) for causing wp failures in page-size-004-print.html. CLOSED TREE
This commit is contained in:
Родитель
a6ad68dd9e
Коммит
58f9d11924
|
@ -135,28 +135,6 @@ pub struct PageSelector {
|
|||
pub pseudos: PagePseudoClasses,
|
||||
}
|
||||
|
||||
/// Computes the [specificity] given the g, h, and f values as in the spec.
|
||||
///
|
||||
/// g is number of `:first` or `:blank`, h is number of `:left` or `:right`,
|
||||
/// f is if the selector includes a page-name (selectors can only include one
|
||||
/// or zero page-names).
|
||||
///
|
||||
/// This places hard limits of 65535 on h and 32767 on g, at which point all
|
||||
/// higher values are treated as those limits respectively.
|
||||
///
|
||||
/// [specificity]: https://drafts.csswg.org/css-page/#specificity
|
||||
#[inline]
|
||||
fn selector_specificity(g: usize, h: usize, f: bool) -> u32 {
|
||||
let h = h.min(0xFFFF) as u32;
|
||||
let g = (g.min(0x7FFF) as u32) << 16;
|
||||
let f = if f {
|
||||
0x80000000
|
||||
} else {
|
||||
0
|
||||
};
|
||||
h + g + f
|
||||
}
|
||||
|
||||
impl PageSelector {
|
||||
/// Checks if the ident matches a page-name's ident.
|
||||
///
|
||||
|
@ -207,7 +185,14 @@ impl PageSelector {
|
|||
PagePseudoClass::Left | PagePseudoClass::Right => h += 1,
|
||||
}
|
||||
}
|
||||
Some(selector_specificity(g, h, !self.name.0.is_empty()))
|
||||
let h = h.min(0xFFFF) as u32;
|
||||
let g = (g.min(0x7FFF) as u32) << 16;
|
||||
let f = if self.name.0.is_empty() {
|
||||
0
|
||||
} else {
|
||||
0x80000000
|
||||
};
|
||||
Some(h + g + f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,17 +219,13 @@ impl Parse for PageSelector {
|
|||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let name = input.try_parse(parse_page_name);
|
||||
let name = input
|
||||
.try_parse(parse_page_name)
|
||||
.unwrap_or(AtomIdent::new(atom!("")));
|
||||
let mut pseudos = PagePseudoClasses::default();
|
||||
while let Ok(pc) = input.try_parse(PagePseudoClass::parse) {
|
||||
pseudos.push(pc);
|
||||
}
|
||||
// If the result was empty, then we didn't get a selector.
|
||||
let name = match name {
|
||||
Ok(name) => name,
|
||||
Err(..) if !pseudos.is_empty() => AtomIdent::new(atom!("")),
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
Ok(PageSelector { name, pseudos })
|
||||
}
|
||||
}
|
||||
|
@ -325,11 +306,6 @@ impl PageRule {
|
|||
///
|
||||
/// The return type is ordered by page-rule specificity.
|
||||
pub fn match_specificity(&self, flags: PagePseudoClassFlags) -> Option<u32> {
|
||||
if self.selectors.is_empty() {
|
||||
// If there are no selectors, get the specificity using the name
|
||||
// only.
|
||||
return Some(selector_specificity(0, 0, true));
|
||||
}
|
||||
let mut specificity = None;
|
||||
for s in self.selectors.0.iter().map(|s| s.match_specificity(flags)) {
|
||||
specificity = s.max(specificity);
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="author" title="Mozilla" href="https://mozilla.org">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-page-3/#at-page-rules">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/css/support/parsing-testcommon.js"></script>
|
||||
<script>
|
||||
test(t => {
|
||||
// At least check that empty selectors are not allowed.
|
||||
test_invalid_rule("@page , { }");
|
||||
test_valid_rule("@page { }");
|
||||
// Some basic name tests.
|
||||
test_valid_rule("@page a { }");
|
||||
test_valid_rule("@page page1 { }");
|
||||
test_valid_rule("@page name1, name2 { }");
|
||||
test_invalid_rule("@page a, { }");
|
||||
test_invalid_rule("@page ,a { }");
|
||||
}, "page-rules-001");
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче