
    3vj6k                        d Z ddlZddlZddlmZ  G d d      Z G d de      Z G d	 d
e      Z G d de      Z G d dee      Z	 G d de      Z
 G d de      Z G d dee      Z G d de      Z G d de      Z G d dee      Z G d de      Z G d dee      Z G d d ee      Z G d! d"ee      Z G d# d$e      Z G d% d&e      Z G d' d(e      Z G d) d*e      Z G d+ d,e      Z G d- d.e      Z G d/ d0e	      Z G d1 d2e      Z G d3 d4e      Z G d5 d6e	      Z G d7 d8e      Z G d9 d:ee      Z G d; d<ee      Z  G d= d>e      Z! G d? d@e!e      Z" G dA dBe!e      Z#y)Cu  Classes for all types of boxes in the CSS formatting structure / box model.

See https://www.w3.org/TR/CSS21/visuren.html

Names are the same as in CSS 2.1 with the exception of ``TextBox``. In
WeasyPrint, any text is in a ``TextBox``. What CSS calls anonymous inline boxes
are text boxes but not all text boxes are anonymous inline boxes.

See https://www.w3.org/TR/CSS21/visuren.html#anonymous

Abstract classes, should not be instantiated:

* Box
* BlockLevelBox
* InlineLevelBox
* BlockContainerBox
* ReplacedBox
* ParentBox
* AtomicInlineLevelBox

Concrete classes:

* PageBox
* BlockBox
* InlineBox
* InlineBlockBox
* BlockReplacedBox
* InlineReplacedBox
* TextBox
* LineBox
* Various table-related Box subclasses

All concrete box classes whose name contains "Inline" or "Block" have one of
the following "outside" behavior:

* Block-level (inherits from :class:`BlockLevelBox`)
* Inline-level (inherits from :class:`InlineLevelBox`)

and one of the following "inside" behavior:

* Block container (inherits from :class:`BlockContainerBox`)
* Inline content (InlineBox and :class:`TextBox`)
* Replaced content (inherits from :class:`ReplacedBox`)

… with various combinasions of both.

See respective docstrings for details.

    N   )AnonymousStylec                   L   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZdZdZdZd Zd)dZd Zd Zed        Zd	 Zd
 Zd*dZ d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d  Z5d! Z6d" Z7d# Z8d$ Z9d% Z:d& Z;d' Z<d( Z=y)+Boxz"Abstract base class for all boxes.FNc                     | j                   S N)childrenselfs    X/root/.hermes/venv/lib/python3.12/site-packages/weasyprint/formatting_structure/boxes.pyall_childrenzBox.all_childrenY   s    }}    c              #      K   |  | j                   D ]2  }|st        |t              r|j                  |      E d{    /| 4 y7 w)z9A flat generator for a box, its children and descendants.N)r	   
isinstancer   descendants)r   placeholderschilds      r   r   zBox.descendants\   sF     
]] 	Ez%5 ,,\:::		:s   :AA	Ac                 v    || _         || _        || _        t               | _        g | _        d | _        d | _        y r   )element_tagelementstylesetremove_decoration_sidesr	   first_letter_stylefirst_line_style)r   r   r   r   s       r   __init__zBox.__init__e   s9    &
'*u$"& $r   c                 N    dt        |       j                   d| j                   dS N< >)type__name__r   r
   s    r   __repr__zBox.__repr__n   s)    4:&&'q)9)9(:!<<r   c                 p    t        |j                        } | |j                  ||j                  g|i |S )z6Return an anonymous box that inherits from ``parent``.)r   r   r   r   )clsparentargskwargsr   s        r   anonymous_fromzBox.anonymous_fromq   s5     v||,6%%ufnnNtNvNNr   c                     t        |       }|j                  |      }|j                  j                  | j                         |S )zReturn shallow copy of the box.)r"   __new____dict__update)r   r&   new_boxs      r   copyzBox.copyw   s8    4j ++c".r   c                 "    | j                         S )z?Return a copy of the box with recursive copies of its children.)r0   r
   s    r   deepcopyzBox.deepcopy   s    yy{r   c                     ||cxk(  rdk(  ry | xj                   |z  c_         | xj                  |z  c_        | j                         D ](  }|r|j                         r|j	                  |||       * y)uc   Change the box’s position.

        Also update the children’s positions accordingly.

        r   N)
position_x
position_yr   
is_floated	translate)r   dxdyignore_floatsr   s        r   r7   zBox.translate   si     =q= 22&&( 	7E!e&6&6&8B6	7r   c                 N    | j                   | j                  z   | j                  z   S )zWidth of the padding box.)widthpadding_leftpadding_rightr
   s    r   padding_widthzBox.padding_width   s"    zzD---0B0BBBr   c                 N    | j                   | j                  z   | j                  z   S )zHeight of the padding box.)heightpadding_toppadding_bottomr
   s    r   padding_heightzBox.padding_height   s"    {{T---0C0CCCr   c                 V    | j                         | j                  z   | j                  z   S )zWidth of the border box.)r?   border_left_widthborder_right_widthr
   s    r   border_widthzBox.border_width   s,    !!#d&<&<<##$ 	$r   c                 V    | j                         | j                  z   | j                  z   S )zHeight of the border box.)rD   border_top_widthborder_bottom_widthr
   s    r   border_heightzBox.border_height   s,    ""$t'<'<<$$% 	%r   c                 V    | j                         | j                  z   | j                  z   S )z)Width of the margin box (aka. outer box).)rH   margin_leftmargin_rightr
   s    r   margin_widthzBox.margin_width   s'      "T%5%558I8IIIr   c                 V    | j                         | j                  z   | j                  z   S )z*Height of the margin box (aka. outer box).)rL   
margin_topmargin_bottomr
   s    r   margin_heightzBox.margin_height   s%    !!#doo58J8JJJr   c                 h    | j                   | j                  z   | j                  z   | j                  z   S )z0Absolute horizontal position of the content box.)r4   rN   r=   rF   r
   s    r   content_box_xzBox.content_box_x   s2    !1!11D4E4EE""# 	#r   c                 h    | j                   | j                  z   | j                  z   | j                  z   S )z.Absolute vertical position of the content box.)r5   rR   rB   rJ   r
   s    r   content_box_yzBox.content_box_y   s0    043C3CC!!" 	"r   c                 N    | j                   | j                  z   | j                  z   S )z0Absolute horizontal position of the padding box.)r4   rN   rF   r
   s    r   padding_box_xzBox.padding_box_x   s"    !1!11D4J4JJJr   c                 N    | j                   | j                  z   | j                  z   S )z.Absolute vertical position of the padding box.)r5   rR   rJ   r
   s    r   padding_box_yzBox.padding_box_y   s     043H3HHHr   c                 4    | j                   | j                  z   S )z/Absolute horizontal position of the border box.)r4   rN   r
   s    r   border_box_xzBox.border_box_x   s    !1!111r   c                 4    | j                   | j                  z   S )z-Absolute vertical position of the border box.)r5   rR   r
   s    r   border_box_yzBox.border_box_y   s    00r   c                 ~    | j                         | j                         | j                         | j                         fS z=Return the (x, y, w, h) rectangle where the box is clickable.)r^   r`   rH   rL   r
   s    r   hit_areazBox.hit_area   s<    
 !!#T%6%6%8!!#T%7%7%9; 	;r   c           
      r   | j                   \  }}| j                  \  }}| j                  \  }	}
| j                  \  }}t	        t        d||z
        t        j                        }t	        t        d||z
        t        j                        }t	        t        d||z
        t        j                        }t	        t        d||z
        t        j                        }t	        t        d|	|z
        t        j                        }	t	        t        d|
|z
        t        j                        }
t	        t        d||z
        t        j                        }t	        t        d||z
        t        j                        }| j                         |z   }| j                         |z   }| j                         |z
  |z
  }| j                         |z
  |z
  }t	        dg|||z   f|||	z   f|||z   f|||
z   ffD cg c]  \  }}|dkD  r||z   c}}z         }||||||z  ||z  f||z  ||z  f|	|z  |
|z  f||z  ||z  ffS c c}}w )zPosition, size and radii of a box inside the outer border box.

        bt, br, bb, and bl are distances from the outer border box,
        defining a rectangle to be rounded.

        r      )border_top_left_radiusborder_top_right_radiusborder_bottom_right_radiusborder_bottom_left_radiusminmaxsysmaxsizer^   r`   rH   rL   )r   btbrbbbltlrxtlrytrrxtrrybrrxbrryblrxblryxyr<   rA   extent	sum_radiiratios                       r   rounded_boxzBox.rounded_box   s;    00
d11
d44
d33
d 3q$)$ckk23q$)$ckk23q$)$ckk23q$)$ckk23q$)$ckk23q$)$ckk23q$)$ckk23q$)$ckk2"$"$!!#b(2-##%*R/ QC t$t$%%	&	
!	 1} Y	
 	
 	 q%E\4%<(E\4%<(E\4%<(E\4%<(* 	*	
s   +H3c                     | j                  | j                  |z  | j                  |z  | j                  |z  | j                  |z        S r   r   rJ   rG   rK   rF   )r   r~   s     r   rounded_box_ratiozBox.rounded_box_ratio  sM    !!E)##e+$$u,""U*	, 	,r   c                 z    | j                  | j                  | j                  | j                  | j                        S )z?Return the position, size and radii of the rounded padding box.r   r
   s    r   rounded_padding_boxzBox.rounded_padding_box	  s9    !!##$$""	$ 	$r   c                 *    | j                  dddd      S )z>Return the position, size and radii of the rounded border box.r   )r   r
   s    r   rounded_border_boxzBox.rounded_border_box  s    1a++r   c                     | j                  | j                  | j                  z   | j                  | j                  z   | j
                  | j                  z   | j                  | j                  z         S )z?Return the position, size and radii of the rounded content box.)	r   rJ   rB   rG   r>   rK   rC   rF   r=   r
   s    r   rounded_content_boxzBox.rounded_content_box  se    !!D$4$44##d&8&88$$t':'::""T%6%66	8 	8r   c                 $    | j                   d   dv S )z#Return whether this box is floated.float)leftrightzinline-startz
inline-endr   r
   s    r   r6   zBox.is_floated  s    zz'"&UUUr   c                 &    | j                   d   dk(  S )z&Return whether this box is a footnote.r   footnoter   r
   s    r   is_footnotezBox.is_footnote#  s    zz'"j00r   c                 $    | j                   d   dv S )z>Return whether this box is in the absolute positioning scheme.position)absolutefixedr   r
   s    r   is_absolutely_positionedzBox.is_absolutely_positioned'  s    zz*%)>>>r   c                 ,    | j                   d   d   dk(  S )z-Return whether this box is a running element.r   r   z	running()r   r
   s    r   
is_runningzBox.is_running+  s    zz*%a(K77r   c                     | j                         xs4 | j                         xs" | j                         xs | j                          S )z*Return whether this box is in normal flow.)r6   r   r   r   r
   s    r   is_in_normal_flowzBox.is_in_normal_flow/  sH     OO 4!>!>!@ 4OO4!%!1!1!35 	5r   c                     t        | t              xsK t        | t              xs9 | j                  d   dv xs& | j                  d   dk(  xr | j                  d   dk7  S )z&Return whether this box is monolithic.overflow)autoscrollhiddenrA   r   )r   AtomicInlineLevelBoxReplacedBoxr   r
   s    r   is_monolithiczBox.is_monolithic5  sh     t12 -t[)-JJz"&88- ZZ
#x/ ,ZZ!V+	.r   c                    | j                         xs| | j                         xsj | j                  xs\ t        | t              xr t        | t
               xs7 t        | t
              xr | j                  d   dk7  xs d| j                  d   v S )z?Return whether this box establishes a block formatting context.r   visiblez	flow-rootdisplay)r6   r   	is_columnr   BlockContainerBoxBlockBoxr   r
   s    r   establishes_formatting_contextz"Box.establishes_formatting_context?  s     OO 1))+1NN1 /0SD(9S5S1 h'ODJJz,Bi,O	1
 4::i00	2r   c                 >    | j                   d   | j                   d   fS )z!Return start and end page values.pager   r
   s    r   page_valueszBox.page_valuesL  s    

6"DJJv$677r   c                     ddl m} | j                  ,| j                  j                  dk(  r || j                  d      S y)z>Return whether this link should be stored as a PDF attachment.r   )element_has_link_typea
attachmentF)htmlr   r   tag)r   r   s     r   is_attachmentzBox.is_attachmentR  s4    0<<#(8(8C(?(|DDr   c                     | j                   d   dk(  r;| j                  /| j                  j                  dv rt        | t        t
        f       S y)z(Return whether this box is a form input.
appearancer   )buttoninputselecttextareaF)r   r   r   r   LineBoxTextBoxr
   s    r   is_inputzBox.is_input\  sI     ::l#v-$,,2J||#LL%dWg,>???r   c                 N    | j                   y| j                   j                  dk(  S )z*Return whether this box is a form element.Fform)r   r   r
   s    r   is_formzBox.is_formd  s$    <<||6))r   )Fr   r   F)>r#   
__module____qualname____doc__proper_table_childinternal_table_or_captiontabular_containerleading_collapsible_spacetrailing_collapsible_spaceis_table_wrapperis_flex_itemis_grid_itemis_for_root_elementr   	is_leaderis_outside_markertransformation_matrixbookmark_label
string_setr   cached_counter_valuesmissing_linklink_annotationforce_fragmentationr   r   r   r$   classmethodr*   r0   r2   r7   r?   rD   rH   rL   rP   rT   rV   rX   rZ   r\   r^   r`   rc   r   r   r   r   r   r6   r   r   r   r   r   r   r   r   r   r    r   r   r   r   9   sN   ,  % !&!& LLII !NJH LO%= O O
7"CD$
%
JK#
"
KI21;,*\,$,8V1?85.	28*r   r   c                   V     e Zd ZdZ fdZd Zd Zd Zd Zd Z	 fdZ
d	 Zd
 Z xZS )	ParentBoxzA box that has children.c                 H    t         |   |||       t        |      | _        y r   )superr   tupler	   r   r   r   r   r	   	__class__s        r   r   zParentBox.__init__m  s    eW5hr   c                     | j                   j                  |       t        | d| d       t        | d| d       t        | d| dd       y)z4Set to 0 the margin, padding and border of ``side``.margin_r   padding_border__widthN)r   addsetattrr   sides     r   _reset_spacingzParentBox._reset_spacingq  sQ    $$((.v&*'+vV,a0r   c                 x    | j                   d   dk(  ry |r| j                  d       |r| j                  d       y y )Nbox_decoration_breakclonetopbottomr   r   )r   startends      r   remove_decorationzParentBox.remove_decorationx  s>    ::,-8&) r   c                 R    | j                         }||_        t               | _        |S )z8Create a new equivalent box with given ``new_children``.)r0   r	   r   r   )r   new_childrenr/   s      r   copy_with_childrenzParentBox.copy_with_children  s&    ))+' (+u$r   c                 h    | j                         }t        d | j                  D              |_        |S )Nc              3   <   K   | ]  }|j                           y wr   )r2   ).0r   s     r   	<genexpr>z%ParentBox.deepcopy.<locals>.<genexpr>  s     KEu~~/Ks   )r0   listr	   )r   results     r   r2   zParentBox.deepcopy  s(    KT]]KKr   c                 ~    | j                   sJ | j                  D ]  }t        |t              s|c S  t	        d      )z!Get the table wrapped by the box.zTable wrapper without a table)r   r	   r   TableBox
ValueError)r   r   s     r   get_wrapped_tablezParentBox.get_wrapped_table  sA    $$$$]] 	>E%*	> <==r   c                 n   t         |          \  }}| j                  D cg c]  }|j                         s| }}|rot	        |      dk(  r)|d   j                         }|d   xs |}|d   xs |}||fS |d   |d   }}|j                         d   xs |}|j                         d   xs |}||fS c c}w )Nre   r   )r   r   r	   r   len)	r   start_value	end_valuer   r	   r   	start_boxend_boxr   s	           r   r   zParentBox.page_values  s    !&!4!6Y
  $}}K0G0G0IEK K8}!&qk557)!n;'N7i	
 I%% &.a[(2,7	'335a8GK#//1!4A		I%%Ks
   B2B2c                     | j                   xsV | j                  xsH | j                  xs: | j                  xs, | j	                         xs | j
                  xs | j                   S r   )rJ   rB   r   r   r   r   r   r
   s    r   top_margin_collapseszParentBox.top_margin_collapses  so    !! %T%5%5 %%!%!2!2%//1% !!% $$& 	&r   c                     | j                   xsV | j                  xsH | j                  xs: | j                  xs, | j	                         xs | j
                  xs | j                   S r   )rK   rC   r   r   r   r   r   r
   s    r   bottom_margin_collapsesz!ParentBox.bottom_margin_collapses  so    $$ %(;(; %%!%!2!2%//1% !!% $$& 	&r   )r#   r   r   r   r   r   r   r   r2   r   r   r  r  __classcell__r   s   @r   r   r   k  s3    "(1*	
>&$&&r   r   c                       e Zd ZdZdZy)BlockLevelBoxzA box that participates in an block formatting context.

    An element with a ``display`` value of ``block``, ``list-item`` or
    ``table`` generates a block-level box.

    N)r#   r   r   r   	clearancer   r   r   r  r    s     Ir   r  c                       e Zd ZdZy)r   aj  A box that contains only block-level boxes or only line boxes.

    A box that either contains only block-level boxes or establishes an inline
    formatting context and thus contains only line boxes.

    A non-replaced element with a ``display`` value of ``block``,
    ``list-item``, ``inline-block`` or 'table-cell' generates a block container
    box.

    Nr#   r   r   r   r   r   r   r   r     s    	r   r   c                       e Zd ZdZy)r   zA block-level box that is also a block container.

    A non-replaced element with a ``display`` value of ``block``, ``list-item``
    generates a block box.

    Nr  r   r   r   r   r         r   r   c                   4     e Zd ZdZdZdZe fd       Z xZS )r   aK  A box that represents a line in an inline formatting context.

    Can only contain inline-level boxes.

    In early stages of building the box tree a single line box contains many
    consecutive inline boxes. Later, during layout phase, each line boxes will
    be split into multiple line boxes, one for each actual line.

    clipnonec                 z    t        |   |g|i |}|j                  d   dk7  r|j                  d   |_        |S )Nr   r   text_overflow)r   r*   r   r  )r&   r'   r(   r)   boxr   s        r   r*   zLineBox.anonymous_from  sC    g$V=d=f=<<
#y0 &_ =C
r   )	r#   r   r   r   r  block_ellipsisr   r*   r	  r
  s   @r   r   r     s&     MN r   r   c                       e Zd ZdZd Zy)InlineLevelBoxaQ  A box that participates in an inline formatting context.

    An inline-level box that is not an inline box is said to be "atomic". Such
    boxes are inline blocks, replaced elements and inline tables.

    An element with a ``display`` value of ``inline``, ``inline-table``, or
    ``inline-block`` generates an inline-level box.

    c                     | j                   d   dk(  ry | j                   d   dk(  }|r| j                  |rdnd       |r| j                  |rdnd       y y )Nr   r   	directionltrr   r   r   )r   r   r   r  s       r   r   z InlineLevelBox.remove_decoration  sY    ::,-8jj%.#7;3F; r   N)r#   r   r   r   r   r   r   r   r  r    s    <r   r  c                       e Zd ZdZd Zy)	InlineBoxa  An inline box with inline children.

    A box that participates in an inline formatting context and whose content
    also participates in that inline formatting context.

    A non-replaced element with a ``display`` value of ``inline`` generates an
    inline box.

    c                 v    | j                         | j                  | j                         | j                         fS rb   )r^   r5   rH   rT   r
   s    r   rc   zInlineBox.hit_area  s7     !!#T__!!#T%7%7%9; 	;r   N)r#   r   r   r   rc   r   r   r   r  r    s    ;r   r  c                   ,     e Zd ZdZdZ fdZd Z xZS )r   zA box that contains only text and has no box children.

    Any text in the document ends up in a text box. What CSS calls "anonymous
    inline boxes" are also text boxes.

    r   c                 >    |sJ t         |   |||       || _        y r   )r   r   text)r   r   r   r   r#  r   s        r   r   zTextBox.__init__  s"    teW5	r   c                 <    |sJ | j                         }||_        |S )z?Return a new TextBox identical to this one except for the text.)r0   r#  )r   r#  r/   s      r   copy_with_textzTextBox.copy_with_text$  s     t))+r   )r#   r   r   r   justification_spacingr   r%  r	  r
  s   @r   r   r     s     
r   r   c                       e Zd ZdZy)r   zpAn atomic box in an inline formatting context.

    This inline-level box cannot be split for line breaks.

    Nr  r   r   r   r   r   ,      r   r   c                       e Zd ZdZy)InlineBlockBoxzA box that is both inline-level and a block container.

    It behaves as inline on the outside and as a block on the inside.

    A non-replaced element with a 'display' value of 'inline-block' generates
    an inline-block box.

    Nr  r   r   r   r*  r*  4  s    r   r*  c                   "     e Zd ZdZ fdZ xZS )r   u   A box whose content is replaced.

    For example, ``<img>`` are replaced: their content is rendered externally
    and is opaque from CSS’s point of view.

    c                 6    t         |   |||       || _        y r   )r   r   replacement)r   r   r   r   r-  r   s        r   r   zReplacedBox.__init__F  s    eW5&r   r#   r   r   r   r   r	  r
  s   @r   r   r   ?  s    ' 'r   r   c                       e Zd ZdZy)BlockReplacedBoxzA box that is both replaced and block-level.

    A replaced element with a ``display`` value of ``block``, ``liste-item`` or
    ``table`` generates a block-level replaced box.

    Nr  r   r   r   r0  r0  K  r  r   r0  c                       e Zd ZdZy)InlineReplacedBoxzA box that is both replaced and inline-level.

    A replaced element with a ``display`` value of ``inline``,
    ``inline-table``, or ``inline-block`` generates an inline-level replaced
    box.

    Nr  r   r   r   r2  r2  T  s    r   r2  c                   4     e Zd ZdZdZd Zd fd	Zd Z xZS )r   z(Box for elements with ``display: table``Tc                 V    t        j                  | j                  | j                        S r   )	itertoolschainr	   column_groupsr
   s    r   r   zTableBox.all_childrend  s    t}}d.@.@AAr   c                 t    | j                   D cg c]  }||z   	 c}| _         t        | 	  |||      S c c}w r   )column_positionsr   r7   )r   r8   r9   r:   r   r   s        r   r7   zTableBox.translateg  sA    *.*?*?!A&HrM!Aw R77!As   5c                 >    | j                   d   | j                   d   fS )Nr   r   r
   s    r   r   zTableBox.page_valuesl  s    

6"DJJv$677r   r   )	r#   r   r   r   r   r   r7   r   r	  r
  s   @r   r   r   ^  s    2 B8
8r   r   c                       e Zd ZdZy)InlineTableBoxz/Box for elements with ``display: inline-table``Nr  r   r   r   r<  r<  p  s    9r   r<  c                   ,    e Zd ZdZdZdZdZeefZ	dZ
dZy)TableRowGroupBoxz2Box for elements with ``display: table-row-group``TFN)r#   r   r   r   r   r   r   r   r<  proper_parents	is_header	is_footerr   r   r   r>  r>  t  s-    < $/N IIr   r>  c                   &    e Zd ZdZdZdZdZeee	fZ
y)TableRowBoxz,Box for elements with ``display: table-row``TN)r#   r   r   r   r   r   r   r   r<  r>  r?  r   r   r   rC  rC    s$    6 $0@ANr   rC  c                   V    e Zd ZdZdZdZeefZdZ	dZ
dZdZdZdZdZdZd Zed        Zy)TableColumnGroupBoxz5Box for elements with ``display: table-column-group``Tr   c                 p    | j                   D cg c]  }|j                         D ]  }|  c}}S c c}}w )z3Return cells that originate in the group's columns.)r	   	get_cells)r   columncells      r   rG  zTableColumnGroupBox.get_cells  sF      $}}M9I9I9KM15DMM 	M Ms   2c                     | j                   rt        | j                         S ddlm}  || j                  j                  d            }|t        |d      S dS Nr   parse_integerspanre   )r	   r   r   rM  r   getrk   r   rM  rN  s      r   rN  zTableColumnGroupBox.span  sJ    ==t}}%%, !1!1&!9:D#'#33tQ<::r   N)r#   r   r   r   r   r   r   r<  r?  rR   rS   rN   rO   rB   rC   r=   r>   rG  propertyrN  r   r   r   rE  rE    s_    ? $/N JMKLKNLMM
 ; ;r   rE  c                   X    e Zd ZdZdZdZeeefZ	dZ
dZdZdZdZdZdZdZd Zed        Zy)TableColumnBoxz/Box for elements with ``display: table-column``Tr   c                     t         )zRReturn cells that originate in the column.

        Is set on instances.

        )NotImplementedErrorr
   s    r   rG  zTableColumnBox.get_cells  s
     "!r   c                 p    ddl m}  || j                  j                  d            }|t	        |d      S dS rK  )r   rM  r   rO  rk   rP  s      r   rN  zTableColumnBox.span  s4    (T\\--f56#/s4|6Q6r   N)r#   r   r   r   r   r   r   r<  rE  r?  rR   rS   rN   rO   rB   rC   r=   r>   rG  rQ  rN  r   r   r   rS  rS    sa    9 $0CDN JMKLKNLM" 7 7r   rS  c                   &     e Zd ZdZdZ fdZ xZS )TableCellBoxz-Box for elements with ``display: table-cell``Tc                    t        |   |i | ddlm}  || j                  j                  d            }|t        |d      nd| _         || j                  j                  d            }|t        |d      | _        y d| _        y )Nr   rL  colspanre   rowspanr   )	r   r   r   rM  r   rO  rk   rZ  r[  )r   r(   r)   rM  rZ  r[  r   s         r   r   zTableCellBox.__init__  sx    $)&) 	) 0 0 ;<*1*=s7A1 0 0 ;<*1*=s7A1r   )r#   r   r   r   r   r   r	  r
  s   @r   rX  rX    s    7 $E Er   rX  c                        e Zd ZdZdZdZeefZy)TableCaptionBoxz0Box for elements with ``display: table-caption``TN)	r#   r   r   r   r   r   r   r<  r?  r   r   r   r]  r]    s    : $/Nr   r]  c                   H     e Zd ZdZ fdZd Zed        Zed        Z xZ	S )PageBoxzBox for a page.

    Initially the whole document will be in the box for the root element.
    During layout a new page box is created after every page break.

    c                 :    || _         t        | 	  d |d g        y N)r   r   r   r	   )	page_typer   r   )r   rb  r   r   s      r   r   zPageBox.__init__  s&    "E4" 	 	Fr   c                 N    dt        |       j                   d| j                   dS r   )r"   r#   rb  r
   s    r   r$   zPageBox.__repr__  s'    4:&&'q(8::r   c                 b    dD ci c]  }|| j                   d|    j                  ! c}S c c}w )N)r   r   r   r   bleed_)r   valuer   s     r   bleedzPageBox.bleed  s>     ;< $**vdV_-333< 	< <s   $,c                     | j                   d    | j                   d    | j                         | j                   d   z   | j                   d   z   | j                         | j                   d   z   | j                   d   z   fS )Nr   r   r   r   )rg  rP   rT   r
   s    r   
bleed_areazPageBox.bleed_area  s}     ZZ$**U"3!3$**V"44tzz'7JJ 4::e#44tzz(7KKM 	Mr   )
r#   r   r   r   r   r$   rQ  rg  ri  r	  r
  s   @r   r_  r_    s=    F; < <
 M Mr   r_  c                   (     e Zd ZdZ fdZd Z xZS )	MarginBoxz3Box in page margins, as defined in CSS3 Paged Mediac                 :    || _         t        | 	  d |d g        y ra  )
at_keywordr   r   )r   rm  r   r   s      r   r   zMarginBox.__init__  s&    $E4" 	 	Fr   c                 N    dt        |       j                   d| j                   dS r   )r"   r#   rm  r
   s    r   r$   zMarginBox.__repr__  s'    4:&&'q(9;;r   r#   r   r   r   r   r$   r	  r
  s   @r   rk  rk    s    =F<r   rk  c                   (     e Zd ZdZ fdZd Z xZS )FootnoteAreaBoxz-Box displaying footnotes, as defined in GCPM.c                 :    || _         t        | 	  d |d g        y ra  )r   r   r   )r   r   r   r   s      r   r   zFootnoteAreaBox.__init__  s&    	E4" 	 	Fr   c                 4    dt        |       j                   dS )Nr   z @footnote>)r"   r#   r
   s    r   r$   zFootnoteAreaBox.__repr__  s    4:&&'{33r   ro  r
  s   @r   rq  rq    s    7F4r   rq  c                       e Zd ZdZy)FlexContainerBoxz$A box that contains only flex-items.Nr  r   r   r   ru  ru    s    .r   ru  c                       e Zd ZdZy)FlexBoxzA box that is both block-level and a flex container.

    It behaves as block on the outside and as a flex container on the inside.

    Nr  r   r   r   rw  rw     r(  r   rw  c                       e Zd ZdZy)InlineFlexBoxzA box that is both inline-level and a flex container.

    It behaves as inline on the outside and as a flex container on the inside.

    Nr  r   r   r   ry  ry  (  r(  r   ry  c                   "     e Zd ZdZ fdZ xZS )GridContainerBoxz$A box that contains only grid-items.c                 8    t         |   ||||       i | _        y r   )r   r   advancementsr   s        r   r   zGridContainerBox.__init__2  s    eWh?r   r.  r
  s   @r   r{  r{  0  s    . r   r{  c                       e Zd ZdZy)GridBoxzA box that is both block-level and a grid container.

    It behaves as block on the outside and as a grid container on the inside.

    Nr  r   r   r   r  r  8  r(  r   r  c                       e Zd ZdZy)InlineGridBoxzA box that is both inline-level and a grid container.

    It behaves as inline on the outside and as a grid container on the inside.

    Nr  r   r   r   r  r  @  r(  r   r  )$r   r5  rl   cssr   r   r   r  r   r   r   r  r  r   r   r*  r   r0  r2  r   r<  r>  rC  rE  rS  rX  r]  r_  rk  rq  ru  rw  ry  r{  r  r  r   r   r   <module>r     s  0d  
  o* o*d	N& N&bC 
	 
 - i *<S <(;	 ;"n ,> )+< 	'# 	'{M %9 8}i 8$:X :	y 	B) B;) ;D7Y 7BE$ E(0h 0Mi M<	<! 	<	4h 	4/y / $n y  $n r   