Skip to content

Commit

Permalink
add Box.isPaintRoot
Browse files Browse the repository at this point in the history
the change to paintInlinesAndDescendents is non-consequential since
it doesn't descend into inlines and so cannot encounter floats, but
it's more readable
  • Loading branch information
chearon committed Jul 17, 2024
1 parent 5d2711d commit aac86e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/layout-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export class Box extends RenderItem {
return this.isPositioned() && this.style.zIndex !== 'auto';
}

isPaintRoot(): boolean {
return this.isBlockContainer() && this.isFloat() || this.isPositioned();
}

getRelativeVerticalShift() {
const height = this.containingBlock.height;
let {top, bottom} = this.style;
Expand Down
10 changes: 2 additions & 8 deletions src/paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,7 @@ function paintBackgroundDescendents(root: BlockContainer | Inline, b: PaintBacke
}
for (let i = block.children.length - 1; i >= 0; i--) {
const child = block.children[i];
if (
child.isBox() &&
!child.isPositioned() &&
!(child.isBlockContainer() && child.isFloat())
) {
stack.push(child);
}
if (child.isBox() && !child.isPaintRoot()) stack.push(child);
}
}
}
Expand Down Expand Up @@ -313,7 +307,7 @@ function paintInlinesAndDescendents(block: BlockContainer, b: PaintBackend) {
if (box.isBlockContainer()) {
for (let i = box.children.length - 1; i >= 0; i--) {
const child = box.children[i];
if (!child.isPositioned()) stack.push(child);
if (!child.isPaintRoot()) stack.push(child);
}
} else {
paintInlines(box, b);
Expand Down

0 comments on commit aac86e5

Please sign in to comment.