a
    ¥Q•h§f  ã                   @   s  d Z ddlZddlmZ G dd„ dƒZG dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZG dd„ deeƒZG dd„ deƒZ	G dd„ deƒZ
G dd„ de
eƒZG dd„ de
ƒZG dd„ de
ƒZG dd„ deeƒZG dd„ deƒZG dd„ deeƒZG dd „ d eeƒZG d!d"„ d"eeƒZG d#d$„ d$eƒZG d%d&„ d&eƒZG d'd(„ d(eƒZG d)d*„ d*eƒZG d+d,„ d,eƒZG d-d.„ d.eƒZG d/d0„ d0eƒZG d1d2„ d2eƒZG d3d4„ d4eƒZG d5d6„ d6eƒZG d7d8„ d8eƒZG d9d:„ d:eeƒZG d;d<„ d<ee
ƒZG d=d>„ d>eƒZ G d?d@„ d@e eƒZ!G dAdB„ dBe e
ƒZ"dS )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é   )Úcomputed_from_cascadedc                   @   s„  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d„ ZdOdd„Zdd	„ Zd
d„ Zedd„ ƒZdd„ Zdd„ ZdPdd„Zdd„ Zdd„ Zdd„ Z dd„ Z!dd„ Z"dd „ Z#d!d"„ Z$d#d$„ Z%d%d&„ Z&d'd(„ Z'd)d*„ Z(d+d,„ Z)d-d.„ Z*d/d0„ Z+d1d2„ Z,d3d4„ Z-d5d6„ Z.d7d8„ Z/d9d:„ Z0d;d<„ Z1d=d>„ Z2d?d@„ Z3dAdB„ Z4dCdD„ Z5dEdF„ Z6dGdH„ Z7dIdJ„ Z8dKdL„ Z9dMdN„ Z:dS )QÚBoxz"Abstract base class for all boxes.FNc                 C   s   | j S ©N©Úchildren©Úself© r
   ú^/var/www/sistema_ama/venv/lib/python3.9/site-packages/weasyprint/formatting_structure/boxes.pyÚall_childrenU   s    zBox.all_childrenc                 c   s<   | V  | j D ]*}|st|tƒr0| |¡E dH  q|V  qdS )z9A flat generator for a box, its children and descendants.N)r   Ú
isinstancer   Údescendants)r	   ÚplaceholdersÚchildr
   r
   r   r   X   s
    
zBox.descendantsc                 C   s$   || _ || _|| _tƒ | _g | _d S r   )Úelement_tagÚelementÚstyleÚsetÚremove_decoration_sidesr   )r	   r   r   r   r
   r
   r   Ú__init__a   s
    zBox.__init__c                 C   s   dt | ƒj› d| j› d�S ©Nú<ú ú>)ÚtypeÚ__name__r   r   r
   r
   r   Ú__repr__h   s    zBox.__repr__c                 O   s.   t i |jdd�}| |j||jg|¢R i |¤ŽS )z6Return an anonymous box that inherits from ``parent``.N)ÚcascadedÚparent_styler   )r   r   r   r   )ÚclsÚparentÚargsÚkwargsr   r
   r
   r   Úanonymous_fromk   s    ÿzBox.anonymous_fromc                 C   s$   t | ƒ}| |¡}|j | j¡ |S )zReturn shallow copy of the box.)r   Ú__new__Ú__dict__Úupdate)r	   r    Únew_boxr
   r
   r   Úcopyr   s    
zBox.copyc                 C   s   |   ¡ S )z?Return a copy of the box with recursive copies of its children.)r)   r   r
   r
   r   Údeepcopy|   s    zBox.deepcopyr   c                 C   sd   ||  krdkrn ndS |  j |7  _ |  j|7  _|  ¡ D ]}|rP| ¡ s@| |||¡ q@dS )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   r
   r
   r   r.   €   s    zBox.translatec                 C   s   | j | j | j S )zWidth of the padding box.)ÚwidthÚpadding_leftÚpadding_rightr   r
   r
   r   Úpadding_width‘   s    zBox.padding_widthc                 C   s   | j | j | j S )zHeight of the padding box.)ÚheightÚpadding_topÚpadding_bottomr   r
   r
   r   Úpadding_height•   s    zBox.padding_heightc                 C   s   |   ¡ | j | j S )zWidth of the border box.)r5   Úborder_left_widthÚborder_right_widthr   r
   r
   r   Úborder_width™   s    ÿzBox.border_widthc                 C   s   |   ¡ | j | j S )zHeight of the border box.)r9   Úborder_top_widthÚborder_bottom_widthr   r
   r
   r   Úborder_heightž   s    ÿzBox.border_heightc                 C   s   |   ¡ | j | j S )z)Width of the margin box (aka. outer box).)r<   Úmargin_leftÚmargin_rightr   r
   r
   r   Úmargin_width£   s    zBox.margin_widthc                 C   s   |   ¡ | j | j S )z*Height of the margin box (aka. outer box).)r?   Ú
margin_topÚmargin_bottomr   r
   r
   r   Úmargin_height§   s    zBox.margin_heightc                 C   s   | j | j | j | j S )z0Absolute horizontal position of the content box.)r+   r@   r3   r:   r   r
   r
   r   Úcontent_box_x­   s    ÿzBox.content_box_xc                 C   s   | j | j | j | j S )z.Absolute vertical position of the content box.)r,   rC   r7   r=   r   r
   r
   r   Úcontent_box_y²   s    ÿzBox.content_box_yc                 C   s   | j | j | j S )z0Absolute horizontal position of the padding box.)r+   r@   r:   r   r
   r
   r   Úpadding_box_x·   s    zBox.padding_box_xc                 C   s   | j | j | j S )z.Absolute vertical position of the padding box.)r,   rC   r=   r   r
   r
   r   Úpadding_box_y»   s    zBox.padding_box_yc                 C   s   | j | j S )z/Absolute horizontal position of the border box.)r+   r@   r   r
   r
   r   Úborder_box_x¿   s    zBox.border_box_xc                 C   s   | j | j S )z-Absolute vertical position of the border box.)r,   rC   r   r
   r
   r   Úborder_box_yÃ   s    zBox.border_box_yc                 C   s   |   ¡ |  ¡ |  ¡ |  ¡ fS ©z=Return the (x, y, w, h) rectangle where the box is clickable.)rJ   rK   r<   r?   r   r
   r
   r   Úhit_areaÇ   s    ÿzBox.hit_areac              
   C   sT  | j \}}| j\}}| j\}	}
| j\}}td|| ƒ}td|| ƒ}td|| ƒ}td|| ƒ}td|	| ƒ}	td|
| ƒ}
td|| ƒ}td|| ƒ}|  ¡ | }|  ¡ | }|  ¡ | | }|  ¡ | | }t	dgdd„ ||| f|||	 f||| f|||
 ffD ƒ ƒ}|||||| || f|| || f|	| |
| f|| || ffS )z¹Position, 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   é   c                 S   s    g | ]\}}|d kr|| ‘qS )r   r
   )Ú.0ÚextentZ	sum_radiir
   r
   r   Ú
<listcomp>ë   s   ùz#Box.rounded_box.<locals>.<listcomp>)
Úborder_top_left_radiusÚborder_top_right_radiusÚborder_bottom_right_radiusÚborder_bottom_left_radiusÚmaxrJ   rK   r<   r?   Úmin)r	   ÚbtÚbrZbbZblZtlrxZtlryZtrrxZtrryZbrrxZbrryZblrxZblryÚxÚyr2   r6   Úratior
   r
   r   Úrounded_boxÏ   s:    







üþ
ûzBox.rounded_boxc                 C   s(   |   | j| | j| | j| | j| ¡S r   ©r]   r=   r;   r>   r:   )r	   r\   r
   r
   r   Úrounded_box_ratioü   s    üzBox.rounded_box_ratioc                 C   s   |   | j| j| j| j¡S )z?Return the position, size and radii of the rounded padding box.r^   r   r
   r
   r   Úrounded_padding_box  s    üzBox.rounded_padding_boxc                 C   s   |   dddd¡S )z>Return the position, size and radii of the rounded border box.r   )r]   r   r
   r
   r   Úrounded_border_box  s    zBox.rounded_border_boxc                 C   s0   |   | j| j | j| j | j| j | j| j ¡S )z?Return the position, size and radii of the rounded content box.)	r]   r=   r7   r;   r4   r>   r8   r:   r3   r   r
   r
   r   Úrounded_content_box  s    



üzBox.rounded_content_boxc                 C   s   | j d dv S )z#Return whether this box is floated.Úfloat)ÚleftÚright©r   r   r
   r
   r   r-     s    zBox.is_floatedc                 C   s   | j d dkS )z&Return whether this box is a footnote.rc   Úfootnoterf   r   r
   r
   r   Úis_footnote  s    zBox.is_footnotec                 C   s   | j d dv S )z>Return whether this box is in the absolute positioning scheme.Úposition)ÚabsoluteÚfixedrf   r   r
   r
   r   Úis_absolutely_positioned!  s    zBox.is_absolutely_positionedc                 C   s   | j d d dkS )z-Return whether this box is a running element.ri   r   z	running()rf   r   r
   r
   r   Ú
is_running%  s    zBox.is_runningc                 C   s"   |   ¡ p|  ¡ p|  ¡ p|  ¡  S )z*Return whether this box is in normal flow.)r-   rl   rm   rh   r   r
   r
   r   Úis_in_normal_flow)  s
    ÿþzBox.is_in_normal_flowc                 C   s>   t | tƒp<t | tƒp<| jd dv p<| jd dko<| jd dkS )z&Return whether this box is monolithic.Úoverflow)ÚautoÚscrollÚhiddenr6   rp   )r   ÚAtomicInlineLevelBoxÚReplacedBoxr   r   r
   r
   r   Úis_monolithic/  s    
ÿþûzBox.is_monolithicc                 C   sR   |   ¡ pP|  ¡ pP| jpPt| tƒr,t| tƒ pPt| tƒrD| jd dkpPd| jd v S )z?Return whether this box establishes a block formatting context.ro   Úvisiblez	flow-rootÚdisplay)r-   rl   Ú	is_columnr   ÚBlockContainerBoxÚBlockBoxr   r   r
   r
   r   Úestablishes_formatting_context9  s    ÿþýüúz"Box.establishes_formatting_contextc                 C   s   | j d | j d fS )z!Return start and end page values.Úpagerf   r   r
   r
   r   Úpage_valuesF  s    zBox.page_valuesc                 C   s2   ddl m} | jdur.| jjdkr.|| jdƒS dS )z>Return whether this link should be stored as a PDF attachment.r   )Úelement_has_link_typeNÚaÚ
attachmentF)Úhtmlr~   r   Útag)r	   r~   r
   r
   r   Úis_attachmentL  s    zBox.is_attachmentc                 C   s8   | j d dkr4| jdur4| jjdv r4t| ttfƒ S dS )z(Return whether this box is a form input.Ú
appearancerp   N)ÚbuttonÚinputÚselectÚtextareaF)r   r   r‚   r   ÚLineBoxÚTextBoxr   r
   r
   r   Úis_inputV  s    zBox.is_inputc                 C   s   | j du rdS | j jdkS )z*Return whether this box is a form element.NFÚform)r   r‚   r   r
   r
   r   Úis_form^  s    
zBox.is_form)F)r   r   F);r   Ú
__module__Ú__qualname__Ú__doc__Úproper_table_childÚinternal_table_or_captionÚtabular_containerZleading_collapsible_spaceZtrailing_collapsible_spaceÚis_table_wrapperZis_flex_itemZis_grid_itemZis_for_root_elementrx   Z	is_leaderZtransformation_matrixÚbookmark_labelÚ
string_setrg   Zcached_counter_valuesZmissing_linkr   r   r   r   Úclassmethodr$   r)   r*   r.   r5   r9   r<   r?   rB   rE   rF   rG   rH   rI   rJ   rK   rM   r]   r_   r`   ra   rb   r-   rh   rl   rm   rn   ru   r{   r}   rƒ   r‹   r�   r
   r
   r
   r   r   8   sp   
	


-


r   c                       sT   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	‡ fdd„Z
‡  ZS )Ú	ParentBoxzA box that has children.c                    s   t ƒ  |||¡ t|ƒ| _d S r   )Úsuperr   Útupler   )r	   r   r   r   r   ©Ú	__class__r
   r   r   g  s    zParentBox.__init__c                 C   sH   | j  |¡ t| d|› �dƒ t| d|› �dƒ t| d|› d�dƒ dS )z4Set to 0 the margin, padding and border of ``side``.Úmargin_r   Úpadding_Zborder_Ú_widthN)r   ÚaddÚsetattr)r	   Úsider
   r
   r   Ú_reset_spacingk  s    zParentBox._reset_spacingc                 C   s2   | j d dkrd S |r |  d¡ |r.|  d¡ d S )NÚbox_decoration_breakÚcloneÚtopÚbottom©r   r£   )r	   ÚstartÚendr
   r
   r   Úremove_decorationr  s    
zParentBox.remove_decorationc                 C   s   |   ¡ }||_tƒ | _|S )z8Create a new equivalent box with given ``new_children``.)r)   r   r   r   )r	   Znew_childrenr(   r
   r
   r   Úcopy_with_childrenz  s    zParentBox.copy_with_childrenc                 C   s"   |   ¡ }tdd„ | jD ƒƒ|_|S )Nc                 s   s   | ]}|  ¡ V  qd S r   )r*   ©rO   r   r
   r
   r   Ú	<genexpr>‡  ó    z%ParentBox.deepcopy.<locals>.<genexpr>)r)   Úlistr   )r	   Úresultr
   r
   r   r*   …  s    zParentBox.deepcopyc                 C   s4   | j s
J ‚| jD ]}t|tƒr|  S qtdƒ‚dS )z!Get the table wrapped by the box.zTable wrapper without a tableN)r”   r   r   ÚTableBoxÚ
ValueError)r	   r   r
   r
   r   Úget_wrapped_tableŠ  s
    



zParentBox.get_wrapped_tablec                    sŽ   t ƒ  ¡ \}}dd„ | jD ƒ}|r†t|ƒdkrT|d  ¡ }|d pD|}|d pP|}n2|d |d  }}| ¡ d pt|}| ¡ d p„|}||fS )Nc                 S   s   g | ]}|  ¡ r|‘qS r
   )rn   r­   r
   r
   r   rQ   ˜  s   z)ParentBox.page_values.<locals>.<listcomp>rN   r   éÿÿÿÿ)r™   r}   r   Úlen)r	   Zstart_valueZ	end_valuer   r}   Z	start_boxZend_boxr›   r
   r   r}   “  s    ÿzParentBox.page_values)r   rŽ   r�   r�   r   r£   r«   r¬   r*   r´   r}   Ú__classcell__r
   r
   r›   r   r˜   e  s   	r˜   c                   @   s   e Zd ZdZdZdS )ÚBlockLevelBoxz°A 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�   Z	clearancer
   r
   r
   r   r¸   ¦  s   r¸   c                   @   s   e Zd ZdZdS )ry   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   ry   °  s   ry   c                   @   s   e Zd ZdZdS )rz   z£A 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   rz   ½  s   rz   c                       s,   e Zd ZdZdZdZe‡ fdd„ƒZ‡  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                    s8   t ƒ j|g|¢R i |¤Ž}|jd dkr4|jd |_|S )Nro   rv   Útext_overflow)r™   r$   r   r¼   )r    r!   r"   r#   Úboxr›   r
   r   r$   Ó  s    zLineBox.anonymous_from)	r   rŽ   r�   r�   r¼   Úblock_ellipsisr—   r$   r·   r
   r
   r›   r   r‰   Æ  s
   	r‰   c                   @   s   e Zd ZdZdd„ ZdS )Ú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                 C   sP   | j d dkrd S | j d dk}|r6|  |r0dnd¡ |rL|  |rFdnd¡ d S )Nr¤   r¥   Ú	directionÚltrrd   re   r¨   )r	   r©   rª   rÁ   r
   r
   r   r«   å  s    z InlineLevelBox.remove_decorationN)r   rŽ   r�   r�   r«   r
   r
   r
   r   r¿   Û  s   	r¿   c                   @   s   e Zd ZdZdZdd„ ZdS )Ú	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.

    Nc                 C   s   |   ¡ | j|  ¡ |  ¡ fS rL   )rJ   r,   r<   rE   r   r
   r
   r   rM   û  s    
ÿzInlineBox.hit_area)r   rŽ   r�   r�   Zlink_annotationrM   r
   r
   r
   r   rÂ   ï  s   	rÂ   c                       s,   e Zd ZdZdZ‡ fdd„Zdd„ Z‡  ZS )rŠ   z²A 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"   |sJ ‚t ƒ  |||¡ || _d S r   )r™   r   Útext)r	   r   r   r   rÃ   r›   r
   r   r     s    zTextBox.__init__c                 C   s   |sJ ‚|   ¡ }||_|S )z?Return a new TextBox identical to this one except for the text.)r)   rÃ   )r	   rÃ   r(   r
   r
   r   Úcopy_with_text  s    zTextBox.copy_with_text)r   rŽ   r�   r�   Újustification_spacingr   rÄ   r·   r
   r
   r›   r   rŠ     s   rŠ   c                   @   s   e Zd ZdZdS )rs   zpAn atomic box in an inline formatting context.

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

    Nr¹   r
   r
   r
   r   rs     s   rs   c                   @   s   e Zd ZdZdS )ÚInlineBlockBoxzëA 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Æ      s   rÆ   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )rt   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                    s   t ƒ  |||¡ || _d S r   )r™   r   Úreplacement)r	   r   r   r   rÇ   r›   r
   r   r   2  s    zReplacedBox.__init__)r   rŽ   r�   r�   r   r·   r
   r
   r›   r   rt   +  s   rt   c                   @   s   e Zd ZdZdS )ÚBlockReplacedBoxz·A 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
   r   rÈ   7  s   rÈ   c                   @   s   e Zd ZdZdS )ÚInlineReplacedBoxzÉA 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
   r   rÉ   @  s   rÉ   c                       s6   e Zd ZdZdZdd„ Zd‡ fdd„	Zd	d
„ Z‡  ZS )r²   z(Box for elements with ``display: table``Tc                 C   s   t  | j| j¡S r   )Ú	itertoolsÚchainr   Zcolumn_groupsr   r
   r
   r   r   P  s    zTableBox.all_childrenr   Fc                    s&   ‡ fdd„| j D ƒ| _ tƒ  ˆ ||¡S )Nc                    s   g | ]}|ˆ  ‘qS r
   r
   )rO   ri   ©r/   r
   r   rQ   T  s   z&TableBox.translate.<locals>.<listcomp>)Zcolumn_positionsr™   r.   )r	   r/   r0   r1   r›   rÌ   r   r.   S  s    
ÿzTableBox.translatec                 C   s   | j d | j d fS )Nr|   rf   r   r
   r
   r   r}   X  s    zTableBox.page_values)r   r   F)	r   rŽ   r�   r�   r“   r   r.   r}   r·   r
   r
   r›   r   r²   J  s
   r²   c                   @   s   e Zd ZdZdS )ÚInlineTableBoxz/Box for elements with ``display: inline-table``Nr¹   r
   r
   r
   r   rÍ   \  s   rÍ   c                   @   s,   e Zd ZdZdZdZdZeefZ	dZ
dZdS )ÚTableRowGroupBoxz2Box for elements with ``display: table-row-group``TFN)r   rŽ   r�   r�   r‘   r’   r“   r²   rÍ   Úproper_parentsZ	is_headerZ	is_footerr
   r
   r
   r   rÎ   `  s   rÎ   c                   @   s&   e Zd ZdZdZdZdZeee	fZ
dS )ÚTableRowBoxz,Box for elements with ``display: table-row``TN)r   rŽ   r�   r�   r‘   r’   r“   r²   rÍ   rÎ   rÏ   r
   r
   r
   r   rÐ   l  s
   rÐ   c                   @   sT   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d„ Zedd„ ƒZdS )	ÚTableColumnGroupBoxz5Box for elements with ``display: table-column-group``Tr   c                 C   s   dd„ | j D ƒS )z3Return cells that originate in the group's columns.c                 S   s   g | ]}|  ¡ D ]}|‘qqS r
   )Ú	get_cells)rO   ÚcolumnÚcellr
   r
   r   rQ   ‡  s   z1TableColumnGroupBox.get_cells.<locals>.<listcomp>r   r   r
   r
   r   rÒ   …  s    ÿzTableColumnGroupBox.get_cellsc                 C   sH   | j rt| j ƒS ztt| j dd¡ ¡ ƒdƒW S  tyB   Y dS 0 d S ©NÚspanÚ rN   )r   r¶   rV   Úintr   ÚgetÚstripr³   r   r
   r
   r   rÖ   Š  s    
zTableColumnGroupBox.spanN)r   rŽ   r�   r�   r‘   r’   r²   rÍ   rÏ   rC   rD   r@   rA   r7   r8   r3   r4   rÒ   ÚpropertyrÖ   r
   r
   r
   r   rÑ   t  s   rÑ   c                   @   sV   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d„ Zedd„ ƒZdS )	ÚTableColumnBoxz/Box for elements with ``display: table-column``Tr   c                 C   s   t ‚dS )zRReturn cells that originate in the column.

        Is set on instances.

        N)ÚNotImplementedErrorr   r
   r
   r   rÒ   §  s    zTableColumnBox.get_cellsc                 C   s8   zt t| j dd¡ ¡ ƒdƒW S  ty2   Y dS 0 d S rÕ   )rV   rØ   r   rÙ   rÚ   r³   r   r
   r
   r   rÖ   ¯  s    zTableColumnBox.spanN)r   rŽ   r�   r�   r‘   r’   r²   rÍ   rÑ   rÏ   rC   rD   r@   rA   r7   r8   r3   r4   rÒ   rÛ   rÖ   r
   r
   r
   r   rÜ   –  s   
rÜ   c                       s$   e Zd ZdZdZ‡ fdd„Z‡  ZS )ÚTableCellBoxz-Box for elements with ``display: table-cell``Tc              	      s–   t ƒ j|i |¤Ž z"tt| j dd¡ ¡ ƒdƒ| _W n tt	fyP   d| _Y n0 z"tt| j dd¡ ¡ ƒdƒ| _
W n tt	fy�   d| _
Y n0 d S )NÚcolspanr×   rN   Úrowspanr   )r™   r   rV   rØ   r   rÙ   rÚ   rß   ÚAttributeErrorr³   rà   )r	   r"   r#   r›   r
   r   r   »  s    ""zTableCellBox.__init__)r   rŽ   r�   r�   r’   r   r·   r
   r
   r›   r   rÞ   ·  s   rÞ   c                   @   s    e Zd ZdZdZdZeefZdS )ÚTableCaptionBoxz0Box for elements with ``display: table-caption``TN)	r   rŽ   r�   r�   r‘   r’   r²   rÍ   rÏ   r
   r
   r
   r   râ   Í  s   râ   c                       s@   e Zd ZdZ‡ fdd„Zdd„ Zedd„ ƒZedd	„ ƒZ‡  Z	S )
ÚPageBoxz¤Box 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                    s   || _ tƒ jd |d g d� d S ©N)r   r   r   r   )Ú	page_typer™   r   )r	   rå   r   r›   r
   r   r   Û  s    ÿzPageBox.__init__c                 C   s   dt | ƒj› d| j› d�S r   )r   r   rå   r   r
   r
   r   r   á  s    zPageBox.__repr__c                    s   ‡ fdd„dD ƒS )Nc                    s    i | ]}|ˆ j d |› � j“qS )Zbleed_)r   Úvalue)rO   r¢   r   r
   r   Ú
<dictcomp>æ  s   ÿz!PageBox.bleed.<locals>.<dictcomp>)r¦   re   r§   rd   r
   r   r
   r   r   Úbleedä  s    
þzPageBox.bleedc                 C   sL   | j d  | j d  |  ¡ | j d  | j d  |  ¡ | j d  | j d  fS )Nrd   r¦   re   r§   )rè   rB   rE   r   r
   r
   r   Ú
bleed_areaê  s    ýzPageBox.bleed_area)
r   rŽ   r�   r�   r   r   rÛ   rè   ré   r·   r
   r
   r›   r   rã   Ô  s   
rã   c                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )Ú	MarginBoxz3Box in page margins, as defined in CSS3 Paged Mediac                    s   || _ tƒ jd |d g d� d S rä   )Ú
at_keywordr™   r   )r	   rë   r   r›   r
   r   r   ô  s    ÿzMarginBox.__init__c                 C   s   dt | ƒj› d| j› d�S r   )r   r   rë   r   r
   r
   r   r   ú  s    zMarginBox.__repr__©r   rŽ   r�   r�   r   r   r·   r
   r
   r›   r   rê   ò  s   rê   c                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚFootnoteAreaBoxz-Box displaying footnotes, as defined in GCPM.c                    s   || _ tƒ jd |d g d� d S rä   )r|   r™   r   )r	   r|   r   r›   r
   r   r      s    ÿzFootnoteAreaBox.__init__c                 C   s   dt | ƒj› d�S )Nr   z @footnote>)r   r   r   r
   r
   r   r     s    zFootnoteAreaBox.__repr__rì   r
   r
   r›   r   rí   þ  s   rí   c                   @   s   e Zd ZdZdS )ÚFlexContainerBoxz$A box that contains only flex-items.Nr¹   r
   r
   r
   r   rî   
  s   rî   c                   @   s   e Zd ZdZdS )ÚFlexBoxz‰A 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
   r   rï     s   rï   c                   @   s   e Zd ZdZdS )ÚInlineFlexBoxz‹A 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
   r   rð     s   rð   c                   @   s   e Zd ZdZdS )ÚGridContainerBoxz$A box that contains only grid-items.Nr¹   r
   r
   r
   r   rñ     s   rñ   c                   @   s   e Zd ZdZdS )ÚGridBoxz‰A 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ò   "  s   rò   c                   @   s   e Zd ZdZdS )ÚInlineGridBoxz‹A 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ó   *  s   ró   )#r�   rÊ   Úcssr   r   r˜   r¸   ry   rz   r‰   r¿   rÂ   rŠ   rs   rÆ   rt   rÈ   rÉ   r²   rÍ   rÎ   rÐ   rÑ   rÜ   rÞ   râ   rã   rê   rí   rî   rï   rð   rñ   rò   ró   r
   r
   r
   r   Ú<module>   sF   2  /A
		
"!