Skip to content

Commit

Permalink
more explicit checking of positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
chearon committed Dec 31, 2023
1 parent 75006dd commit c2ea63f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
16 changes: 0 additions & 16 deletions src/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ export class Box extends RenderItem {
return Boolean(this.attrs & Box.ATTRS.isAnonymous);
}

get isRelativeOrStatic() {
return this.style.position === 'relative'
|| this.style.position === 'static'
// XXX anonymous boxes won't have a position since position doesn't
// inherit. Possible this could cause a problem later, so take note
|| this.isAnonymous() && !this.style.position;
}

get isAbsolute() {
return this.style.position === 'absolute';
}

get isPositioned() {
return this.style.position !== 'static';
}

desc(options?: ReprOptions) {
return 'Box';
}
Expand Down
8 changes: 3 additions & 5 deletions src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,20 +877,18 @@ export class BlockContainer extends Box {

assignContainingBlocks(ctx: LayoutContext) {
// CSS2.2 10.1
if (this.isRelativeOrStatic) {
this.containingBlock = ctx.lastBlockContainerArea;
} else if (this.isAbsolute) {
if (this.style.position === 'absolute') {
this.containingBlock = ctx.lastPositionedArea;
} else {
throw new Error(`Could not assign a containing block to box ${this.id}`);
this.containingBlock = ctx.lastBlockContainerArea;
}

this.fillAreas();
this.borderArea.setParent(this.containingBlock);

ctx.lastBlockContainerArea = this.contentArea;

if (this.isPositioned) {
if (this.style.position !== 'static') {
ctx.lastPositionedArea = this.paddingArea;
}
}
Expand Down

0 comments on commit c2ea63f

Please sign in to comment.