Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of LibCSS
  3.  * Licensed under the MIT License,
  4.  *                http://www.opensource.org/licenses/mit-license.php
  5.  * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
  6.  */
  7.  
  8. #ifndef css_select_computed_h_
  9. #define css_select_computed_h_
  10.  
  11. #include <libcss/computed.h>
  12. #include <libcss/hint.h>
  13.  
  14.  
  15.  
  16. typedef struct css_computed_uncommon {
  17. /*
  18.  * border_spacing                 1 + 2(4)        2(4)
  19.  * clip                           2 + 4(4) + 4    4(4)
  20.  * letter_spacing                 2 + 4           4
  21.  * outline_color                  2               4
  22.  * outline_width                  3 + 4           4
  23.  * word_spacing                   2 + 4           4
  24.  *                              ---             ---
  25.  *                               52 bits         40 bytes
  26.  *
  27.  * Encode counter_increment and _reset as an array of name, value pairs,
  28.  * terminated with a blank entry.
  29.  *
  30.  * counter_increment              1               sizeof(ptr)
  31.  * counter_reset                  1               sizeof(ptr)
  32.  *                              ---             ---
  33.  *                                2 bits          2sizeof(ptr) bytes
  34.  *
  35.  * Encode cursor uri(s) as an array of string objects, terminated with a
  36.  * blank entry.
  37.  *
  38.  * cursor                         5               sizeof(ptr)
  39.  *                              ---             ---
  40.  *                                5 bits          sizeof(ptr) bytes
  41.  *
  42.  * Encode content as an array of content items, terminated with a blank entry.
  43.  *
  44.  * content                        2               sizeof(ptr)
  45.  *                              ---             ---
  46.  *                                2 bits          sizeof(ptr)
  47.  *
  48.  *                              ___             ___
  49.  *                               61 bits         40 + 4sizeof(ptr) bytes
  50.  *
  51.  *                                8 bytes        40 + 4sizeof(ptr) bytes
  52.  *                              ===================
  53.  *                               48 + 4sizeof(ptr) bytes
  54.  *
  55.  * Bit allocations:
  56.  *
  57.  *    76543210
  58.  *  1 llllllcc  letter-spacing | outline-color
  59.  *  2 ooooooob  outline-width  | border-spacing
  60.  *  3 bbbbbbbb  border-spacing
  61.  *  4 wwwwwwir  word-spacing   | counter-increment | counter-reset
  62.  *  5 uuuuu...  cursor         | <unused>
  63.  *  6 cccccccc  clip
  64.  *  7 cccccccc  clip
  65.  *  8 ccccccoo  clip           | content
  66.  */
  67.         uint8_t bits[8];
  68.  
  69.         css_fixed border_spacing[2];
  70.  
  71.         css_fixed clip[4];
  72.  
  73.         css_fixed letter_spacing;
  74.  
  75.         css_color outline_color;
  76.         css_fixed outline_width;
  77.  
  78.         css_fixed word_spacing;
  79.  
  80.         css_computed_counter *counter_increment;
  81.         css_computed_counter *counter_reset;
  82.  
  83.         lwc_string **cursor;
  84.  
  85.         css_computed_content_item *content;
  86. } css_computed_uncommon;
  87.  
  88. typedef struct css_computed_page {
  89. /*
  90.  * Bit allocations:
  91.  *
  92.  *    76543210
  93.  *  1 aaabbbii  page_break_after | page_break_before | page_break_inside
  94.  *  2 ......wo  widows  | orphans
  95.  */
  96.         uint8_t bits[2];
  97.        
  98.         css_fixed widows;
  99.         css_fixed orphans;
  100. } css_computed_page;
  101.    
  102. struct css_computed_style {
  103. /*
  104.  * background_attachment          2
  105.  * background_repeat              3
  106.  * border_collapse                2
  107.  * border_top_style               4
  108.  * border_right_style             4
  109.  * border_bottom_style            4
  110.  * border_left_style              4
  111.  * caption_side                   2
  112.  * clear                          3
  113.  * direction                      2
  114.  * display                        5
  115.  * empty_cells                    2
  116.  * float                          2
  117.  * font_style                     2
  118.  * font_variant                   2
  119.  * font_weight                    4
  120.  * list_style_position            2
  121.  * list_style_type                4
  122.  * overflow                       3
  123.  * outline_style                  4
  124.  * position                       3
  125.  * table_layout                   2
  126.  * text_align                     4
  127.  * text_decoration                5
  128.  * text_transform                 3
  129.  * unicode_bidi                   2
  130.  * visibility                     2
  131.  * white_space                    3
  132.  *                              ---
  133.  *                               84 bits
  134.  *
  135.  * Colours are 32bits of AARRGGBB
  136.  * Dimensions are encoded as a fixed point value + 4 bits of unit data
  137.  *
  138.  * background_color               2               4
  139.  * background_image               1               sizeof(ptr)
  140.  * background_position            1 + 2(4)        2(4)
  141.  * border_top_color               2               4
  142.  * border_right_color             2               4
  143.  * border_bottom_color            2               4
  144.  * border_left_color              2               4
  145.  * border_top_width               3 + 4           4
  146.  * border_right_width             3 + 4           4
  147.  * border_bottom_width            3 + 4           4
  148.  * border_left_width              3 + 4           4
  149.  * top                            2 + 4           4
  150.  * right                          2 + 4           4
  151.  * bottom                         2 + 4           4
  152.  * left                           2 + 4           4
  153.  * color                          1               4
  154.  * font_size                      4 + 4           4
  155.  * height                         2 + 4           4
  156.  * line_height                    2 + 4           4
  157.  * list_style_image               1               sizeof(ptr)
  158.  * margin_top                     2 + 4           4
  159.  * margin_right                   2 + 4           4
  160.  * margin_bottom                  2 + 4           4
  161.  * margin_left                    2 + 4           4
  162.  * max_height                     2 + 4           4
  163.  * max_width                      2 + 4           4
  164.  * min_height                     1 + 4           4
  165.  * min_width                      1 + 4           4
  166.  * padding_top                    1 + 4           4
  167.  * padding_right                  1 + 4           4
  168.  * padding_bottom                 1 + 4           4
  169.  * padding_left                   1 + 4           4
  170.  * text_indent                    1 + 4           4
  171.  * vertical_align                 4 + 4           4
  172.  * width                          2 + 4           4
  173.  * z_index                        2               4
  174.  *                              ---             ---
  175.  *                              181 bits        140 + 2sizeof(ptr) bytes
  176.  *
  177.  * Encode font family as an array of string objects, terminated with a
  178.  * blank entry.
  179.  *
  180.  * font_family                    3               sizeof(ptr)
  181.  *                              ---             ---
  182.  *                                3 bits          sizeof(ptr)
  183.  *
  184.  * Encode quotes as an array of string objects, terminated with a blank entry.
  185.  *
  186.  * quotes                         1               sizeof(ptr)
  187.  *                              ---             ---
  188.  *                                1 bit           sizeof(ptr) bytes
  189.  *
  190.  *                              ___             ___
  191.  *                              269 bits        140 + 4sizeof(ptr) bytes
  192.  *
  193.  *                               34 bytes       140 + 4sizeof(ptr) bytes
  194.  *                              ===================
  195.  *                              174 + 4sizeof(ptr) bytes
  196.  *
  197.  * Bit allocations:
  198.  *
  199.  *    76543210
  200.  *  1 vvvvvvvv  vertical-align
  201.  *  2 ffffffff  font-size
  202.  *  3 ttttttti  border-top-width    | background-image
  203.  *  4 rrrrrrrc  border-right-width  | color
  204.  *  5 bbbbbbbl  border-bottom-width | list-style-image
  205.  *  6 lllllllq  border-left-width   | quotes
  206.  *  7 ttttttcc  top                 | border-top-color
  207.  *  8 rrrrrrcc  right               | border-right-color
  208.  *  9 bbbbbbcc  bottom              | border-bottom-color
  209.  * 10 llllllcc  left                | border-left-color
  210.  * 11 hhhhhhbb  height              | background-color
  211.  * 12 llllllzz  line-height         | z-index
  212.  * 13 ttttttbb  margin-top          | background-attachment
  213.  * 14 rrrrrrbb  margin-right        | border-collapse
  214.  * 15 bbbbbbcc  margin-bottom       | caption-side
  215.  * 16 lllllldd  margin-left         | direction
  216.  * 17 mmmmmmee  max-height          | empty-cells
  217.  * 18 mmmmmmff  max-width           | float
  218.  * 19 wwwwwwff  width               | font-style
  219.  * 20 mmmmmbbb  min-height          | background-repeat
  220.  * 21 mmmmmccc  min-width           | clear
  221.  * 22 tttttooo  padding-top         | overflow
  222.  * 23 rrrrrppp  padding-right       | position
  223.  * 24 bbbbbo..  padding-bottom      | opacity               | <unused>
  224.  * 25 lllllttt  padding-left        | text-transform
  225.  * 26 tttttwww  text-indent         | white-space
  226.  * 27 bbbbbbbb  background-position
  227.  * 28 bdddddff  background-position | display               | font-variant
  228.  * 29 tttttfff  text-decoration     | font-family
  229.  * 30 ttttrrrr  border-top-style    | border-right-style
  230.  * 31 bbbbllll  border-bottom-style | border-left-style
  231.  * 32 ffffllll  font-weight         | list-style-type
  232.  * 33 oooottuu  outline-style       | table-layout          | unicode-bidi
  233.  * 34 vvlltttt  visibility          | list-style-position   | text-align
  234.  */
  235.         uint8_t bits[34];
  236.  
  237.         uint8_t unused[2];
  238.  
  239.         css_color background_color;
  240.         lwc_string *background_image;
  241.         css_fixed background_position[2];
  242.  
  243.         css_color border_color[4];
  244.         css_fixed border_width[4];
  245.  
  246.         css_fixed top;
  247.         css_fixed right;
  248.         css_fixed bottom;
  249.         css_fixed left;
  250.  
  251.         css_color color;
  252.  
  253.         css_fixed font_size;
  254.  
  255.         css_fixed height;
  256.  
  257.         css_fixed line_height;
  258.  
  259.         lwc_string *list_style_image;
  260.  
  261.         css_fixed margin[4];
  262.  
  263.         css_fixed max_height;
  264.         css_fixed max_width;
  265.  
  266.         css_fixed min_height;
  267.         css_fixed min_width;
  268.  
  269.         css_fixed opacity;
  270.  
  271.         css_fixed padding[4];
  272.  
  273.         css_fixed text_indent;
  274.  
  275.         css_fixed vertical_align;
  276.  
  277.         css_fixed width;
  278.  
  279.         int32_t z_index;
  280.  
  281.         lwc_string **font_family;
  282.  
  283.         lwc_string **quotes;
  284.  
  285.         css_computed_uncommon *uncommon;/**< Uncommon properties */
  286.         void *aural;                    /**< Aural properties */
  287.         css_computed_page *page;        /**< Page properties */
  288.  
  289.         css_allocator_fn alloc;
  290.         void *pw;
  291. };
  292.  
  293. css_error css__compute_absolute_values(const css_computed_style *parent,
  294.                 css_computed_style *style,
  295.                 css_error (*compute_font_size)(void *pw,
  296.                         const css_hint *parent, css_hint *size),
  297.                 void *pw);
  298.  
  299. #endif
  300.