Bug 1808995 - Fix WPT testcases that do not properly account for counter-style fallback behavior of prefix/suffix descriptors. r=emilio

Per spec, "If a counter style is used to represent a counter value outside of its ranges,
the counter style instead drops down to its fallback counter style."

  https://www.w3.org/TR/css-counter-styles-3/#counter-style-range
  https://www.w3.org/TR/css-counter-styles-3/#counter-style-fallback

Some existing tests incorrectly assumed that a prefix or suffix from a custom rule will still apply
even when the counter value is not in range. That would mean "fallback" is only partial, using
the symbols/system from the fallback style mixed with the prefix/suffix of the originally-specified
style, which prevents use-cases like that in bug 1808995 working as expected.

Differential Revision: https://phabricator.services.mozilla.com/D167410
This commit is contained in:
Jonathan Kew 2023-01-28 14:06:15 +00:00
Родитель 1cad3c6c0a
Коммит 740935bf3f
10 изменённых файлов: 35 добавлений и 25 удалений

Просмотреть файл

@ -1,12 +1,12 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<title>CSS Reference: symbols function, invalid</title>
<title>CSS Reference: descriptor prefix</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
<link rel="stylesheet" href="support/ref-common.css">
<!-- ol -->
<div>Appendix -2.&nbsp;</div>
<div>Appendix -1.&nbsp;</div>
<div>Appendix 0.&nbsp;</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>0.&nbsp;</div>
<div>Appendix I.&nbsp;</div>
<div>Appendix II.&nbsp;</div>
<!-- section -->

Просмотреть файл

@ -7,6 +7,8 @@
<link rel="stylesheet" href="support/test-common.css">
<style type="text/css">
@counter-style a {
/* Note that upper-roman has a range of (1, 3999), so negative or zero values
will use the fallback style. */
system: extends upper-roman;
prefix: "Appendix ";
}

Просмотреть файл

@ -1,12 +1,12 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<title>CSS Reference: symbols function, invalid</title>
<title>CSS Reference: system additive</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
<link rel="stylesheet" href="support/ref-common.css">
<!-- list-style-type: a -->
<div>-2</div>
<div>-1</div>
<div>0</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>0.&nbsp;</div>
<div>&#x2680;</div>
<div>&#x2681;</div>
<div>&#x2682;</div>
@ -22,8 +22,8 @@
document.write(Array(61).join('&#x2685;'));
</script></div>
<!-- list-style-type: b -->
<div>-2</div>
<div>-1</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>&#x2637;</div>
<div>&#x2636;</div>
<div>&#x2635;</div>

Просмотреть файл

@ -7,11 +7,13 @@
<link rel="stylesheet" href="support/test-common.css">
<style type="text/css">
@counter-style a {
/* Negative and zero values cannot be represented, and will use fallback style (decimal). */
system: additive;
additive-symbols: 6 \2685, 5 \2684, 4 \2683, 3 \2682, 2 \2681, 1 \2680;
suffix: "";
}
@counter-style b {
/* Negative values cannot be represented, and will use fallback style (decimal). */
system: additive;
additive-symbols: 7 \2630, 6 \2631, 5 \2632, 4 \2633, 3 \2634, 2 \2635, 1 \2636, 0 \2637;
suffix: "";

Просмотреть файл

@ -3,9 +3,9 @@
<title>CSS Reference: symbols function, invalid</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
<link rel="stylesheet" href="support/ref-common.css">
<div>-2</div>
<div>-1</div>
<div>0</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>0.&nbsp;</div>
<div>&#x26AA;</div>
<div>&#x26AB;</div>
<div>&#x26AA;&#x26AA;</div>

Просмотреть файл

@ -7,6 +7,8 @@
<link rel="stylesheet" href="support/test-common.css">
<style type="text/css">
@counter-style a {
/* alphabetic has a range that starts from 1, so negative/zero values will
fall back to decimal */
system: alphabetic;
symbols: \26AA \26AB;
suffix: '';

Просмотреть файл

@ -4,24 +4,24 @@
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
<link rel="stylesheet" href="support/ref-common.css">
<!-- list-style-type: a -->
<div>Chapter -2.&nbsp;</div>
<div>Chapter -1.&nbsp;</div>
<div>Chapter 0.&nbsp;</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>0.&nbsp;</div>
<div>Chapter I.&nbsp;</div>
<div>Chapter II.&nbsp;</div>
<div>Chapter III.&nbsp;</div>
<div>Chapter IV.&nbsp;</div>
<div>Chapter V.&nbsp;</div>
<div>Chapter 6.&nbsp;</div>
<div>Chapter 7.&nbsp;</div>
<div>6.&nbsp;</div>
<div>7.&nbsp;</div>
<!-- list-style-type: b -->
<div>Section -2.&nbsp;</div>
<div>Section -1.&nbsp;</div>
<div>Section 0.&nbsp;</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>0.&nbsp;</div>
<div>Section I.&nbsp;</div>
<div>Section II.&nbsp;</div>
<div>Section III.&nbsp;</div>
<div>Section IV.&nbsp;</div>
<div>Section V.&nbsp;</div>
<div>Section VI.&nbsp;</div>
<div>Section 7.&nbsp;</div>
<div>7.&nbsp;</div>

Просмотреть файл

@ -7,11 +7,13 @@
<link rel="stylesheet" href="support/test-common.css">
<style type="text/css">
@counter-style a {
/* Values outside the range will fall back to decimal (and hence have no prefix) */
system: extends upper-roman;
prefix: "Chapter ";
range: 1 5;
}
@counter-style b {
/* Values outside the range will fall back to decimal (and hence have no prefix) */
system: extends a;
prefix: "Section ";
range: 1 6;

Просмотреть файл

@ -4,9 +4,9 @@
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
<link rel="stylesheet" href="support/ref-common.css">
<!-- list-style-type: a -->
<div>-2</div>
<div>-1</div>
<div>0</div>
<div>-2.&nbsp;</div>
<div>-1.&nbsp;</div>
<div>0.&nbsp;</div>
<div>*</div>
<div>&#x2051;</div>
<div>&#x2020;</div>

Просмотреть файл

@ -8,6 +8,8 @@
<style type="text/css">
@counter-style a {
/* system: symbolic; */
/* symbolic does not support negative or zero values, so they will fall back
to decimal */
symbols: '*' \2051 \2020 \2021;
suffix: '';
}