Skip to content

Commit e2ce61e

Browse files
sickl8moz-wptsync-bot
authored andcommitted
Fix blockification and deblockification of flex/grid items when wrapped inside display: contents elements.
- Added new inheritable style builder flag `CASCADE_BEYOND_DISPLAY_CONTENTS` with it's corresponding adjuster function - Modified tests to also include the case where the `display: contents` wrapper stays the same but the container switches `display` type after the first style resolution - Moved adjustment code to `set_bits` - Renamed flag to `DISPLAY_CONTENTS_IN_ITEM_CONTAINER` Differential Revision: https://phabricator.services.mozilla.com/D274679 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1960699 gecko-commit: 9c41ae9c99de9c737bcc39531f6094ed1bb6482d gecko-reviewers: emilio, firefox-style-system-reviewers
1 parent c17bf5d commit e2ce61e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

css/css-display/display-contents-blockify-dynamic.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@
1515
<span></span>
1616
</div>
1717
</div>
18+
<div id="grid-to-block" style="display: grid">
19+
<div style="display: contents">
20+
<div style="display: contents">
21+
<button>button1</button>
22+
<button id="deblockified">button2</button>
23+
</div>
24+
</div>
25+
</div>
26+
<div id="block-to-grid" style="display: block">
27+
<div style="display: contents">
28+
<div style="display: contents">
29+
<button>button1</button>
30+
<button id="blockified">button2</button>
31+
</div>
32+
</div>
33+
</div>
1834
<script>
1935
function display(el) {
2036
return getComputedStyle(el).display;
@@ -31,4 +47,26 @@
3147
assert_equals(display(child), "block", "Grid child should get blockified");
3248
assert_equals(display(grandChild), "inline", "Grid grand-child should get un-blockified when its parent's display stops being `contents`");
3349
}, "Dynamic changes to `display` causing blockification of children are handled correctly");
50+
51+
test(() => {
52+
let gridToBlock = document.getElementById("grid-to-block");
53+
let itemGrandChild = document.getElementById("deblockified");
54+
55+
assert_equals(display(gridToBlock), "grid", "Container should be a grid");
56+
assert_equals(display(itemGrandChild), "block", "Item should have been blockified");
57+
gridToBlock.style.display = "block";
58+
assert_equals(display(gridToBlock), "block", "Container should become a block");
59+
assert_equals(display(itemGrandChild), "inline-block", "Item should get de-blockified");
60+
}, "Dynamic changes to `display` from `grid` to `block` should cause children to get de-blockified despite being children of `display: contents` elements");
61+
62+
test(() => {
63+
let blockToGrid = document.getElementById("block-to-grid");
64+
let itemGrandChild = document.getElementById("blockified");
65+
66+
assert_equals(display(blockToGrid), "block", "Container should be a block");
67+
assert_equals(display(itemGrandChild), "inline-block", "Item should not have been blockified");
68+
blockToGrid.style.display = "grid";
69+
assert_equals(display(blockToGrid), "grid", "Container should become a grid");
70+
assert_equals(display(itemGrandChild), "block", "Item should get blockified");
71+
}, "Dynamic changes to `display` from `block` to `grid` should cause children to get blockified despite being children of `display: contents` elements")
3472
</script>

0 commit comments

Comments
 (0)