about summary refs log blame commit diff stats
path: root/src/layout/box.nim
blob: d31f0e1d3e5d5f96e56b8db43f594cc2971407e8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
                  
                 
               









                               



                
                          
                     
                           
                                 
 
                       


                               

                 

                     
                     
 


                                 



                               
                     
 
                     

           

                


                            
                                      
                
                     
 

                                     
                            


                                   
                


                                 
import types/enums
import css/values
import html/dom

type
  CSSRect* = object
    x1*: int
    y1*: int
    x2*: int
    y2*: int

  CSSBox* = ref CSSBoxObj
  CSSBoxObj = object of RootObj
    x*: int
    y*: int
    width*: int
    height*: int
    children*: seq[CSSBox]
    context*: Context
    bcontext*: BlockContext
    cssvalues*: CSSComputedValues

  Context* = ref object
    context*: FormatContextType
    fromx*: int
    fromy*: int
    marginx*: int
    marginy*: int
    conty*: bool
    whitespace*: bool
    ws_initial*: bool

  InlineContext* = object
    cssvalues*: CSSComputedValues

  BlockContext* = ref object
    context*: FormatContextType
    marginx*: int
    marginy*: int
    nodes*: seq[Node]

  CSSRowBox* = object
    x*: int
    y*: int
    width*: int
    height*: int
    color*: CSSColor
    fontstyle*: CSSFontStyle
    fontweight*: int
    textdecoration*: CSSTextDecoration
    str*: string
    nodes*: seq[Node]

  CSSInlineBox* = ref CSSInlineBoxObj
  CSSInlineBoxObj = object of CSSBox
    content*: seq[CSSRowBox]

  CSSBlockBox* = ref CSSBlockBoxObj
  CSSBlockBoxObj = object of CSSBox
    tag*: string

  FormatContextType* = enum
    CONTEXT_BLOCK, CONTEXT_INLINE