nehan
Version:
Html layout engine for paged-media written in Typescript
41 lines • 1.34 kB
JavaScript
import { Utils, CssLength, FlowFormatContext, } from "./public-api";
export class DynamicStyleContext {
constructor(value) {
this.selector = value.selector;
this.name = value.name;
this.element = value.element;
this.parentContext = value.parentContext;
}
setExternalDOM($dom) {
this.element.$dom = $dom;
}
get fontSize() {
return CssLength.computeFontSize(this.element);
}
get remSize() {
if (this.parentContext instanceof FlowFormatContext && this.parentContext.pageRoot) {
return this.parentContext.pageRoot.env.font.size;
}
return this.emSize;
}
get emSize() {
return CssLength.computeFontSize(this.element);
}
get lineHeight() {
const value = this.element.computedStyle.getPropertyValue("line-height");
if (!value) {
throw new Error("line-height is not defined!");
}
if (value.indexOf("px") < 0) {
return Math.floor(this.emSize * parseFloat(value));
}
return Utils.atoi(value);
}
get restContextBoxExtent() {
if (this.parentContext) {
return this.parentContext.restExtent;
}
throw new Error("parent context is not defined");
}
}
//# sourceMappingURL=dynamic-style-context.js.map