blob: 89bbbe4fafff16cb9e83c0ca422f2d1baad78d5f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package model.layout;
import model.html.ElementNode;
public class BlockLayout extends Layout {
public BlockLayout(ElementNode node, Layout parent) {
super(node, parent);
}
// recursively construct the layout tree
public void layout() {
this.location.x = this.parent.location.x;
this.location.y = this.previousSibling
.map(sibling -> sibling.location.y + sibling.dimension.height)
.orElseGet(() -> this.parent.location.y);
for (Layout child : this.children) {
child.layout();
this.dimension.height = Math.max(this.dimension.height, (child.location.y + child.dimension.height) - this.location.y);
this.dimension.width = Math.max(this.dimension.width, (child.location.x + child.dimension.width) - this.location.x);
}
}
}
|