UNPKG

nehan

Version:

Html layout engine for paged-media written in Typescript

108 lines 3.17 kB
import { Config, LogicalPadding, LogicalBorder, LogicalMargin, } from "./public-api"; export class LogicalBoxEdge { constructor(values) { this.padding = values.padding; this.border = values.border; this.margin = values.margin; } static load(element) { if (element.tagName === Config.pageRootTagName) { return this.loadRootBoxEdge(element); } return this.loadBoxEdge(element); } static loadRootBoxEdge(element) { if (Config.engineVersion <= 6) { return new LogicalBoxEdge({ padding: LogicalPadding.load(element), border: LogicalBorder.none, margin: LogicalMargin.none, }); } return this.none; } static loadBoxEdge(element) { return new LogicalBoxEdge({ padding: LogicalPadding.load(element), border: LogicalBorder.load(element), margin: LogicalMargin.load(element) }); } static get none() { return new LogicalBoxEdge({ padding: LogicalPadding.none, border: LogicalBorder.none, margin: LogicalMargin.none }); } clone() { return new LogicalBoxEdge({ padding: this.padding.clone(), border: this.border.clone(), margin: this.margin.clone() }); } clearBefore() { this.padding.before = 0; this.border.clearBefore(); this.margin.before = 0; } clearAfter() { this.padding.after = 0; this.border.clearAfter(); this.margin.after = 0; } clearStart() { this.padding.start = 0; this.border.clearStart(); this.margin.start = 0; } clearEnd() { this.padding.end = 0; this.border.clearEnd(); this.margin.end = 0; } get start() { return this.padding.start + this.border.startWidth + this.margin.start; } get end() { return this.padding.end + this.border.endWidth + this.margin.end; } get before() { return this.padding.before + this.border.beforeWidth + this.margin.before; } get after() { return this.padding.after + this.border.afterWidth + this.margin.after; } get extent() { return this.before + this.after; } get measure() { return this.start + this.end; } get borderBoxBefore() { return this.padding.before + this.border.width.before; } get borderBoxAfter() { return this.padding.after + this.border.width.after; } get borderBoxStart() { return this.padding.start + this.border.width.start; } get borderBoxEnd() { return this.padding.end + this.border.width.end; } get borderBoxExtent() { return this.borderBoxBefore + this.borderBoxAfter; } get borderBoxMeasure() { return this.borderBoxStart + this.borderBoxStart; } getInnerBoxOffset() { return { start: this.padding.start, before: this.padding.before }; } } //# sourceMappingURL=logical-box-edge.js.map