1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>Logical properties with deferred <code>writing-mode</code></title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" />
<link rel="help" href="https://drafts.csswg.org/css-logical-1/#box">
<link rel="help" href="https://drafts.csswg.org/css-variables-1/">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#common-keywords">
<meta name="assert" content="Checks that logical properties are resolved correctly when the writing mode isn't known until computed-value time.">
<style>
#parent {
writing-mode: vertical-lr;
}
@layer {
.revert-layer {
writing-mode: vertical-rl;
}
}
@layer {
.revert-layer {
writing-mode: horizontal-tb;
writing-mode: revert-layer;
}
}
</style>
<div id="parent">
<div id="target"></div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const target = document.getElementById("target");
const computedStyle = getComputedStyle(target);
function check(expected) {
for (let [prop, value] of Object.entries(expected)) {
assert_equals(computedStyle.getPropertyValue(prop), value, prop);
}
}
test(function() {
target.style.cssText = `
--wm: vertical-rl;
writing-mode: var(--wm);
margin-block-start: 1px;
margin-block-end: 2px;
margin-inline-start: 3px;
margin-inline-end: 4px;
`;
check({
// Logicals
"margin-block-start": "1px",
"margin-block-end": "2px",
"margin-inline-start": "3px",
"margin-inline-end": "4px",
// Physicals
"margin-right": "1px",
"margin-left": "2px",
"margin-top": "3px",
"margin-bottom": "4px",
});
}, "Writing mode with variable");
test(function() {
target.style.cssText = `
--wm1: vertical-rl;
--wm2: var(--wm1);
writing-mode: var(--wm2);
margin-block-start: 1px;
margin-block-end: 2px;
margin-inline-start: 3px;
margin-inline-end: 4px;
`;
check({
// Logicals
"margin-block-start": "1px",
"margin-block-end": "2px",
"margin-inline-start": "3px",
"margin-inline-end": "4px",
// Physicals
"margin-right": "1px",
"margin-left": "2px",
"margin-top": "3px",
"margin-bottom": "4px",
});
}, "Writing mode with nested variables");
test(function() {
target.style.cssText = `
writing-mode: inherit;
margin-block-start: 1px;
margin-block-end: 2px;
margin-inline-start: 3px;
margin-inline-end: 4px;
`;
check({
// Logicals
"margin-block-start": "1px",
"margin-block-end": "2px",
"margin-inline-start": "3px",
"margin-inline-end": "4px",
// Physicals
"margin-left": "1px",
"margin-right": "2px",
"margin-top": "3px",
"margin-bottom": "4px",
});
}, "Writing mode with 'inherit'");
test(function() {
target.style.cssText = `
writing-mode: initial;
margin-block-start: 1px;
margin-block-end: 2px;
margin-inline-start: 3px;
margin-inline-end: 4px;
`;
check({
// Logicals
"margin-block-start": "1px",
"margin-block-end": "2px",
"margin-inline-start": "3px",
"margin-inline-end": "4px",
// Physicals
"margin-top": "1px",
"margin-bottom": "2px",
"margin-left": "3px",
"margin-right": "4px",
});
}, "Writing mode with 'initial'");
test(function() {
target.style.cssText = `
writing-mode: revert;
margin-block-start: 1px;
margin-block-end: 2px;
margin-inline-start: 3px;
margin-inline-end: 4px;
`;
check({
// Logicals
"margin-block-start": "1px",
"margin-block-end": "2px",
"margin-inline-start": "3px",
"margin-inline-end": "4px",
// Physicals
"margin-left": "1px",
"margin-right": "2px",
"margin-top": "3px",
"margin-bottom": "4px",
});
}, "Writing mode with 'revert'");
test(function() {
target.className = "revert-layer";
target.style.cssText = `
margin-block-start: 1px;
margin-block-end: 2px;
margin-inline-start: 3px;
margin-inline-end: 4px;
`;
check({
// Logicals
"margin-block-start": "1px",
"margin-block-end": "2px",
"margin-inline-start": "3px",
"margin-inline-end": "4px",
// Physicals
"margin-right": "1px",
"margin-left": "2px",
"margin-top": "3px",
"margin-bottom": "4px",
});
}, "Writing mode with 'revert-layer'");
</script>
|