import options import css/values import html/dom import io/term type #LayoutUnit* = distinct int32 LayoutUnit* = int Offset* = object x*: LayoutUnit y*: LayoutUnit Size* = object width*: LayoutUnit height*: LayoutUnit Strut* = object pos*: int neg*: int Box* = ref object of RootObj BlockBox* = ref object of Box flowRoot*: bool FlowRoot* = ref object of BlockBox #InlineRoot* = ref object of Viewport* = ref object term*: TermAttributes root*: BlockContext BoxBuilder* = ref object of RootObj children*: seq[BoxBuilder] inlinelayout*: bool computed*: CSSComputedValues node*: Node element*: Element InlineBoxBuilder* = ref object of BoxBuilder text*: seq[string] ictx*: InlineContext newline*: bool BlockBoxBuilder* = ref object of BoxBuilder listItemCounter: int # ordinal value of current list InlineBlockBoxBuilder* = ref object of BoxBuilder content*: BlockBoxBuilder # iblock.bctx is equivalent to box.bctx MarkerBoxBuilder* = ref object of InlineBoxBuilder ordinalvalue*: int inside*: bool ListItemBoxBuilder* = ref object of BoxBuilder marker*: MarkerBoxBuilder content*: BlockBoxBuilder InlineAtom* = ref object of RootObj offset*: Offset width*: int height*: int vertalign*: CSSVerticalAlign ComputedFormat* = ref object fontstyle*: CSSFontStyle fontweight*: int textdecoration*: CSSTextDecoration color*: CSSColor node*: Node InlineSpacing* = ref object of InlineAtom format*: ComputedFormat InlineWord* = ref object of InlineAtom str*: string format*: ComputedFormat InlineRow* = ref object atoms*: seq[InlineAtom] offset*: Offset width*: int height*: int lineheight*: int #line-height property InlineContext* = ref object offset*: Offset height*: int rows*: seq[InlineRow] thisrow*: InlineRow whitespacenum*: int maxwidth*: int viewport*: Viewport node*: Node shrink*: bool format*: ComputedFormat BlockContext* = ref object of RootObj inline*: InlineContext nested*: seq[BlockContext] computed*: CSSComputedValues viewport*: Viewport offset*: Offset width*: int height*: int margin_top*: int margin_bottom*: int margin_left*: int margin_right*: int padding_top*: int padding_bottom*: int padding_left*: int padding_right*: int compwidth*: int maxwidth*: int nocenter*: bool compheight*: Option[int] shrink*: bool ListItem* = ref object of BlockContext marker*: InlineContext InlineBlock* = ref object of InlineAtom bctx*: BlockContext proc append*(a: var Strut, b: int) = if b < 0: a.neg = min(b, a.neg) else: a.pos = max(b, a.pos) func sum*(a: Strut): int = return a.pos + a.neg #proc `div`(a, b: LayoutUnit): LayoutUnit {.borrow.} # #func `+`*(a, b: LayoutUnit): LayoutUnit {.borrow.} #func `-`*(a, b: LayoutUnit): LayoutUnit {.borrow.} #func `*`*(a, b: LayoutUnit): LayoutUnit {.borrow.} #func `/`*(a, b: LayoutUnit): LayoutUnit = a div b # #proc `+=`*(a: var LayoutUnit, b: LayoutUnit) {.borrow.} #proc `-=`*(a: var LayoutUnit, b: LayoutUnit) {.borrow.} #proc `*=`*(a: var LayoutUnit, b: LayoutUnit) {.borrow.} #proc `/=`*(a: var LayoutUnit, b: LayoutUnit) = a = a div b