Skip to content

Commit cc5ad59

Browse files
committed
unnecessary walking of inlines when painting backgrounds
when painting backgrounds, there's no point descending into IFCs since we stop at inlines anyways similarly, there's no point in having a background painting phase of inlines, since they can't have backgrounds. inline painting already has separate phases for floats, inline-blocks: https://www.w3.org/TR/CSS22/zindex.html#painting-order
1 parent 5ed352f commit cc5ad59

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/paint.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ function paintFormattingBoxBackground(box: FormattingBox, b: PaintBackend, isRoo
153153
}
154154
}
155155

156-
function paintBackgroundDescendents(root: FormattingBox | Inline, b: PaintBackend) {
157-
const stack: (FormattingBox | Inline | {sentinel: true})[] = [root];
156+
function paintBackgroundDescendents(root: FormattingBox, b: PaintBackend) {
157+
const stack: (FormattingBox | {sentinel: true})[] = [root];
158158
const parents: Box[] = [];
159159

160160
while (stack.length) {
@@ -171,7 +171,11 @@ function paintBackgroundDescendents(root: FormattingBox | Inline, b: PaintBacken
171171
paintFormattingBoxBackground(box, b);
172172
}
173173

174-
if (box.isBlockContainer() && box.hasBackgroundInLayerRoot()) {
174+
if (
175+
box.isBlockContainer() &&
176+
box.isBlockContainerOfBlocks() &&
177+
box.hasBackgroundInLayerRoot()
178+
) {
175179
stack.push({sentinel: true});
176180
parents.push(box);
177181

@@ -651,10 +655,6 @@ function createLayerRoot(rootBox: BlockContainer) {
651655
function paintInlineLayerRoot(root: InlineLayerRoot, b: PaintBackend) {
652656
for (const r of root.negativeRoots) paintLayerRoot(r, b);
653657

654-
if (root.box.hasBackgroundInLayerRoot()) {
655-
paintBackgroundDescendents(root.box, b);
656-
}
657-
658658
for (const r of root.floats) paintLayerRoot(r, b);
659659

660660
if (root.box.hasForeground() || root.box.hasForegroundInLayerRoot()) {

0 commit comments

Comments
 (0)