Gitweb links:

...log 
http://git.netsurf-browser.org/libcss.git/shortlog/16505397bc2d474e365d0b7a3b57e1b81fd28661
...commit 
http://git.netsurf-browser.org/libcss.git/commit/16505397bc2d474e365d0b7a3b57e1b81fd28661
...tree 
http://git.netsurf-browser.org/libcss.git/tree/16505397bc2d474e365d0b7a3b57e1b81fd28661

The branch, lcneves/units has been updated
       via  16505397bc2d474e365d0b7a3b57e1b81fd28661 (commit)
      from  41cee64272bed090f3b2151ce00b00c3c89222f1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=16505397bc2d474e365d0b7a3b57e1b81fd28661
commit 16505397bc2d474e365d0b7a3b57e1b81fd28661
Author: Lucas Neves <[email protected]>
Commit: Lucas Neves <[email protected]>

    WIP: Select: Autogen for selection properties.

diff --git a/src/select/__pycache__/assets.cpython-36.pyc 
b/src/select/__pycache__/assets.cpython-36.pyc
index f7b7da8..9b622ce 100644
Binary files a/src/select/__pycache__/assets.cpython-36.pyc and 
b/src/select/__pycache__/assets.cpython-36.pyc differ
diff --git a/src/select/__pycache__/select_config.cpython-36.pyc 
b/src/select/__pycache__/select_config.cpython-36.pyc
index bcda842..55e01f8 100644
Binary files a/src/select/__pycache__/select_config.cpython-36.pyc and 
b/src/select/__pycache__/select_config.cpython-36.pyc differ
diff --git a/src/select/assets.py b/src/select/assets.py
index 33982b0..91bf92a 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -29,7 +29,7 @@ assets['computed.h']['footer'] = '''\
  * Take a new reference to a computed style
  *
  * \param style  The style to take a new reference to.
- * \return The new computed style reference
+ * \\return The new computed style reference
  */
 static inline css_computed_style * css__computed_style_ref(
                css_computed_style *style)
diff --git a/src/select/autogenerated_computed.h 
b/src/select/autogenerated_computed.h
index 76a6b32..a76c528 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -14,122 +14,157 @@
 
 
 /*
- * border_spacing                 1 + 10          8
- * break_after                    4               
- * break_before                   4               
- * break_inside                   4               
- * clip                           6               
- * column_count                   2               4
- * column_fill                    2               
- * column_gap                     2 + 5           4
- * column_rule_color              2               4
- * column_rule_style              4               
- * column_rule_width              3 + 5           4
- * column_span                    2               
- * column_width                   2 + 5           4
- * content                        2               sizeof(ptr)
- * counter_increment              1               sizeof(ptr)
- * counter_reset                  1               sizeof(ptr)
- * cursor                         5               sizeof(ptr)
- * letter_spacing                 2 + 5           4
- * outline_color                  2               4
- * outline_width                  3 + 5           4
- * word_spacing                   2 + 5           4
+ * Property                       Size (bits)     Size (bytes)
+ * ---                            ---             ---
+ * border_spacing                   1 + 10          8
+ * break_after                      4             
+ * break_before                     4             
+ * break_inside                     4             
+ * clip                             6 + 20         16
+ * column_count                     2               4
+ * column_fill                      2             
+ * column_gap                       2 + 5           4
+ * column_rule_color                2               4
+ * column_rule_style                4             
+ * column_rule_width                3 + 5           4
+ * column_span                      2             
+ * column_width                     2 + 5           4
+ * letter_spacing                   2 + 5           4
+ * outline_color                    2               4
+ * outline_width                    3 + 5           4
+ * word_spacing                     2 + 5           4
+ * 
+ * Encode content as an array of content items, terminated with a blank entry.
+ * 
+ * content                          2             sizeof(ptr)
+ * 
+ * Encode counter_increment as an array of name, value pairs, terminated with a
+ * blank entry.
+ * 
+ * counter_increment                1             sizeof(ptr)
+ * 
+ * Encode counter_reset as an array of name, value pairs, terminated with a
+ * blank entry.
+ * 
+ * counter_reset                    1             sizeof(ptr)
+ * 
+ * Encode cursor uri(s) as an array of string objects, terminated with a blank
+ * entry
+ * 
+ * cursor                           5             sizeof(ptr)
+ * ---                            ---             ---
+ *                                116 bits         60 + 4sizeof(ptr) bytes
  */
 
 /*
- * orphans                        1               4
- * page_break_after               3               
- * page_break_before              3               
- * page_break_inside              2               
- * widows                         1               4
+ * Property                       Size (bits)     Size (bytes)
+ * ---                            ---             ---
+ * orphans                          1               4
+ * page_break_after                 3             
+ * page_break_before                3             
+ * page_break_inside                2             
+ * widows                           1               4
+ * 
+ * ---                            ---             ---
+ *                                 10 bits          8 bytes
  */
 
 /*
- * align_content                  3               
- * align_items                    3               
- * align_self                     3               
- * background_attachment          2               
- * background_color               2               4
- * background_image               1               sizeof(ptr)
- * background_position            1 + 10          8
- * background_repeat              3               
- * border_bottom_color            2               4
- * border_bottom_style            4               
- * border_bottom_width            3 + 5           4
- * border_collapse                2               
- * border_left_color              2               4
- * border_left_style              4               
- * border_left_width              3 + 5           4
- * border_right_color             2               4
- * border_right_style             4               
- * border_right_width             3 + 5           4
- * border_top_color               2               4
- * border_top_style               4               
- * border_top_width               3 + 5           4
- * bottom                         2 + 5           4
- * box_sizing                     2               
- * caption_side                   2               
- * clear                          3               
- * color                          1               4
- * direction                      2               
- * display                        5               
- * empty_cells                    2               
- * flex_basis                     2 + 5           4
- * flex_direction                 3               
- * flex_grow                      1               4
- * flex_shrink                    1               4
- * flex_wrap                      2               
- * float                          2               
- * font_family                    3               sizeof(ptr)
- * font_size                      4 + 5           4
- * font_style                     2               
- * font_variant                   2               
- * font_weight                    4               
- * height                         2 + 5           4
- * justify_content                3               
- * left                           2 + 5           4
- * line_height                    2 + 5           4
- * list_style_image               1               sizeof(ptr)
- * list_style_position            2               
- * list_style_type                4               
- * margin_bottom                  2 + 5           4
- * margin_left                    2 + 5           4
- * margin_right                   2 + 5           4
- * margin_top                     2 + 5           4
- * max_height                     2 + 5           4
- * max_width                      2 + 5           4
- * min_height                     2 + 5           4
- * min_width                      2 + 5           4
- * opacity                        1               4
- * order                          1               4
- * outline_style                  4               
- * overflow                       3               
- * padding_bottom                 1 + 5           4
- * padding_left                   1 + 5           4
- * padding_right                  1 + 5           4
- * padding_top                    1 + 5           4
- * position                       3               
- * quotes                         1               sizeof(ptr)
- * right                          2 + 5           4
- * table_layout                   2               
- * text_align                     4               
- * text_decoration                5               
- * text_indent                    1 + 5           4
- * text_transform                 3               
- * top                            2 + 5           4
- * unicode_bidi                   2               
- * vertical_align                 4 + 5           4
- * visibility                     2               
- * white_space                    3               
- * width                          2 + 5           4
- * z_index                        2               4
+ * Property                       Size (bits)     Size (bytes)
+ * ---                            ---             ---
+ * align_content                    3             
+ * align_items                      3             
+ * align_self                       3             
+ * background_attachment            2             
+ * background_color                 2               4
+ * background_image                 1             sizeof(ptr)
+ * background_position              1 + 10          8
+ * background_repeat                3             
+ * border_bottom_color              2               4
+ * border_bottom_style              4             
+ * border_bottom_width              3 + 5           4
+ * border_collapse                  2             
+ * border_left_color                2               4
+ * border_left_style                4             
+ * border_left_width                3 + 5           4
+ * border_right_color               2               4
+ * border_right_style               4             
+ * border_right_width               3 + 5           4
+ * border_top_color                 2               4
+ * border_top_style                 4             
+ * border_top_width                 3 + 5           4
+ * bottom                           2 + 5           4
+ * box_sizing                       2             
+ * caption_side                     2             
+ * clear                            3             
+ * color                            1               4
+ * direction                        2             
+ * display                          5             
+ * empty_cells                      2             
+ * flex_basis                       2 + 5           4
+ * flex_direction                   3             
+ * flex_grow                        1               4
+ * flex_shrink                      1               4
+ * flex_wrap                        2             
+ * float                            2             
+ * font_size                        4 + 5           4
+ * font_style                       2             
+ * font_variant                     2             
+ * font_weight                      4             
+ * height                           2 + 5           4
+ * justify_content                  3             
+ * left                             2 + 5           4
+ * line_height                      2 + 5           4
+ * list_style_image                 1             sizeof(ptr)
+ * list_style_position              2             
+ * list_style_type                  4             
+ * margin_bottom                    2 + 5           4
+ * margin_left                      2 + 5           4
+ * margin_right                     2 + 5           4
+ * margin_top                       2 + 5           4
+ * max_height                       2 + 5           4
+ * max_width                        2 + 5           4
+ * min_height                       2 + 5           4
+ * min_width                        2 + 5           4
+ * opacity                          1               4
+ * order                            1               4
+ * outline_style                    4             
+ * overflow                         3             
+ * padding_bottom                   1 + 5           4
+ * padding_left                     1 + 5           4
+ * padding_right                    1 + 5           4
+ * padding_top                      1 + 5           4
+ * position                         3             
+ * right                            2 + 5           4
+ * table_layout                     2             
+ * text_align                       4             
+ * text_decoration                  5             
+ * text_indent                      1 + 5           4
+ * text_transform                   3             
+ * top                              2 + 5           4
+ * unicode_bidi                     2             
+ * vertical_align                   4 + 5           4
+ * visibility                       2             
+ * white_space                      3             
+ * width                            2 + 5           4
+ * z_index                          2               4
+ * 
+ * Encode font family as an array of string objects, terminated with a blank
+ * entry.
+ * 
+ * font_family                      3             sizeof(ptr)
+ * 
+ * Encode quotes as an array of string objects, terminated with a blank entry.
+ * 
+ * quotes                           1             sizeof(ptr)
+ * ---                            ---             ---
+ *                                329 bits        160 + 4sizeof(ptr) bytes
  */
 /**
  * Take a new reference to a computed style
  *
  * \param style  The style to take a new reference to.
- * 
eturn The new computed style reference
+ * \return The new computed style reference
  */
 static inline css_computed_style * css__computed_style_ref(
                css_computed_style *style)
diff --git a/src/select/select_config.py b/src/select/select_config.py
index 27b2dc9..e63dc8b 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -121,7 +121,7 @@ uncommon = {
     ('break_after', 4, None, None, 'CSS_BREAK_AFTER_AUTO'),
     ('break_before', 4, None, None, 'CSS_BREAK_BEFORE_AUTO'),
     ('break_inside', 4, None, None, 'CSS_BREAK_INSIDE_AUTO'),
-    ('clip', 6, ('length, length, length, length'),
+    ('clip', 6, ('length', 'length', 'length', 'length'),
         'CSS_CLIP_RECT', None, None, ('get', 'set')),
     ('column_count', 2, 'integer', None, 'CSS_COLUMN_COUNT_AUTO'),
     ('column_fill', 2, None, None, 'CSS_COLUMN_FILL_BALANCE'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index a1af7a5..31fe613 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -12,6 +12,9 @@ class Text:
         self._comment = False
         self._indent = 0
 
+    name_width = 31
+    bits_width = 16
+
     def indent(self, value, absolute=False):
         if absolute:
             self._indent = value
@@ -25,11 +28,16 @@ class Text:
         self._comment = not comm
 
     def append(self, text=None, pre_formatted=False):
-        if text is None:
+        if not text:
             self._lines.append('\t' * self._indent + ' * '
                     if self._comment else '')
             return
 
+        if isinstance(text, list):
+            for t in text:
+                self.append(t, pre_formatted)
+            return
+
         if pre_formatted:
             self._lines.append(text)
             return
@@ -46,7 +54,7 @@ class Text:
                 line += text
                 text = ''
             else:
-                break_index = text[:text[:column_max - prefix_size].rfind(' ')]
+                break_index = text[:column_max - prefix_size].rfind(' ')
                 line += text[:break_index].rstrip()
                 text = text[break_index:].lstrip()
             self._lines.append(line)
@@ -57,6 +65,16 @@ class Text:
         if multiline:
             self._indent(-2)
 
+    def table_line(self):
+        self.append('{0:{n}}{0:{b}}{0}'.format(
+            '---', n=self.name_width, b=self.bits_width))
+
+    def table_header(self):
+        self.append('{:{n}}{:{b}}{}'.format(
+            'Property', 'Size (bits)', 'Size (bytes)', 
+            n=self.name_width, b=self.bits_width))
+        self.table_line()
+
     def to_string(self):
         return '\n'.join(self._lines)
 
@@ -108,15 +126,24 @@ class CSSProperty:
             if v.bits is not None ])
 
     @property
+    def bytes_size(self):
+        return sum([ v.size for v in self.values if v.size is not None ])
+
+    @property
+    def ptr_size(self):
+        return sum([ 1 for v in self.values if v.size is None ])
+
+    @property
     def size_line(self):
-        name = '{:31}'.format(self.name)
-        type_size = str(self.type_size)
+        name = '{:{width}}'.format(self.name, width=Text.name_width)
+        type_size = '{:>3}'.format(str(self.type_size))
         extra_size = sum([ v.bits['size'] for v in self.values
                 if v.bits is not None ])
-        bits_size = '{:16}'.format(type_size +
-                (' + ' + str(extra_size) if extra_size else ''))
-        vars_size = sum([ v.size for v in self.values if v.size is not None ])
-        vars_size = str(vars_size) if vars_size else ''
+        bits_size = '{:{width}}'.format(type_size +
+                (' + ' + str(extra_size) if extra_size else ''),
+                width=Text.bits_width)
+        vars_size = '{:>3}'.format(
+                str(self.bytes_size)) if self.bytes_size else ''
         ptr = ''
         for v in self.values:
             if v.size is None:
@@ -145,6 +172,18 @@ class CSSGroup:
         self.__bits_array = None
 
     @property
+    def bits_size(self):
+        return sum([ p.bits_size for p in self.props ])
+
+    @property
+    def bytes_size(self):
+        return sum([ p.bytes_size for p in self.props ])
+
+    @property
+    def ptr_size(self):
+        return sum([ p.ptr_size for p in self.props ])
+
+    @property
     def bits_array(self):
         '''Implements a `best fit first` heuristics for the bin packing of
         property bits in the bits array'''
@@ -173,9 +212,23 @@ class CSSGroup:
         t = Text()
         t.append()
         t.comment()
+        commented = []
+        t.table_header()
         for prop in sorted(self.props, key=(lambda x: x.name)):
-            t.append(prop.size_line)
+            if prop.comments is None:
+                t.append(prop.size_line)
+            else:
+                commented.extend(( '', prop.comments, '', prop.size_line ))
+        t.append(commented)
+        t.table_line()
+        t.append('{:{len_1}}{:>3}{:{len_2}}{:>3}{}{}'.format('',
+            str(self.bits_size), ' bits', str(self.bytes_size),
+            ' + ' + str(self.ptr_size) + 'sizeof(ptr)'
+                    if self.ptr_size else '',
+            ' bytes',
+            len_1=Text.name_width, len_2=(Text.bits_width - 3)))
         t.comment()
+
         return t.to_string()
 
     def make_text(self, filename):
@@ -187,7 +240,7 @@ class CSSGroup:
 css_groups = [ CSSGroup(g) for g in groups['others'] ]
 css_groups.append(CSSGroup(groups['main'], is_main=True))
 
-for k, v in assets:
+for k, v in assets.items():
     # Key is filename string (e.g. "computed.h") without autogenerated_ prefix
     body = '\n'.join([ g.make_text(k) for g in css_groups ])
     text = '\n'.join([ v['header'], body, v['footer'] ])


-----------------------------------------------------------------------

Summary of changes:
 src/select/__pycache__/assets.cpython-36.pyc       |  Bin 1375 -> 1398 bytes
 .../__pycache__/select_config.cpython-36.pyc       |  Bin 6502 -> 6490 bytes
 src/select/assets.py                               |    2 +-
 src/select/autogenerated_computed.h                |  245 +++++++++++---------
 src/select/select_config.py                        |    2 +-
 src/select/select_generator.py                     |   73 +++++-
 6 files changed, 205 insertions(+), 117 deletions(-)

diff --git a/src/select/__pycache__/assets.cpython-36.pyc 
b/src/select/__pycache__/assets.cpython-36.pyc
index f7b7da8..9b622ce 100644
Binary files a/src/select/__pycache__/assets.cpython-36.pyc and 
b/src/select/__pycache__/assets.cpython-36.pyc differ
diff --git a/src/select/__pycache__/select_config.cpython-36.pyc 
b/src/select/__pycache__/select_config.cpython-36.pyc
index bcda842..55e01f8 100644
Binary files a/src/select/__pycache__/select_config.cpython-36.pyc and 
b/src/select/__pycache__/select_config.cpython-36.pyc differ
diff --git a/src/select/assets.py b/src/select/assets.py
index 33982b0..91bf92a 100644
--- a/src/select/assets.py
+++ b/src/select/assets.py
@@ -29,7 +29,7 @@ assets['computed.h']['footer'] = '''\
  * Take a new reference to a computed style
  *
  * \param style  The style to take a new reference to.
- * \return The new computed style reference
+ * \\return The new computed style reference
  */
 static inline css_computed_style * css__computed_style_ref(
                css_computed_style *style)
diff --git a/src/select/autogenerated_computed.h 
b/src/select/autogenerated_computed.h
index 76a6b32..a76c528 100644
--- a/src/select/autogenerated_computed.h
+++ b/src/select/autogenerated_computed.h
@@ -14,122 +14,157 @@
 
 
 /*
- * border_spacing                 1 + 10          8
- * break_after                    4               
- * break_before                   4               
- * break_inside                   4               
- * clip                           6               
- * column_count                   2               4
- * column_fill                    2               
- * column_gap                     2 + 5           4
- * column_rule_color              2               4
- * column_rule_style              4               
- * column_rule_width              3 + 5           4
- * column_span                    2               
- * column_width                   2 + 5           4
- * content                        2               sizeof(ptr)
- * counter_increment              1               sizeof(ptr)
- * counter_reset                  1               sizeof(ptr)
- * cursor                         5               sizeof(ptr)
- * letter_spacing                 2 + 5           4
- * outline_color                  2               4
- * outline_width                  3 + 5           4
- * word_spacing                   2 + 5           4
+ * Property                       Size (bits)     Size (bytes)
+ * ---                            ---             ---
+ * border_spacing                   1 + 10          8
+ * break_after                      4             
+ * break_before                     4             
+ * break_inside                     4             
+ * clip                             6 + 20         16
+ * column_count                     2               4
+ * column_fill                      2             
+ * column_gap                       2 + 5           4
+ * column_rule_color                2               4
+ * column_rule_style                4             
+ * column_rule_width                3 + 5           4
+ * column_span                      2             
+ * column_width                     2 + 5           4
+ * letter_spacing                   2 + 5           4
+ * outline_color                    2               4
+ * outline_width                    3 + 5           4
+ * word_spacing                     2 + 5           4
+ * 
+ * Encode content as an array of content items, terminated with a blank entry.
+ * 
+ * content                          2             sizeof(ptr)
+ * 
+ * Encode counter_increment as an array of name, value pairs, terminated with a
+ * blank entry.
+ * 
+ * counter_increment                1             sizeof(ptr)
+ * 
+ * Encode counter_reset as an array of name, value pairs, terminated with a
+ * blank entry.
+ * 
+ * counter_reset                    1             sizeof(ptr)
+ * 
+ * Encode cursor uri(s) as an array of string objects, terminated with a blank
+ * entry
+ * 
+ * cursor                           5             sizeof(ptr)
+ * ---                            ---             ---
+ *                                116 bits         60 + 4sizeof(ptr) bytes
  */
 
 /*
- * orphans                        1               4
- * page_break_after               3               
- * page_break_before              3               
- * page_break_inside              2               
- * widows                         1               4
+ * Property                       Size (bits)     Size (bytes)
+ * ---                            ---             ---
+ * orphans                          1               4
+ * page_break_after                 3             
+ * page_break_before                3             
+ * page_break_inside                2             
+ * widows                           1               4
+ * 
+ * ---                            ---             ---
+ *                                 10 bits          8 bytes
  */
 
 /*
- * align_content                  3               
- * align_items                    3               
- * align_self                     3               
- * background_attachment          2               
- * background_color               2               4
- * background_image               1               sizeof(ptr)
- * background_position            1 + 10          8
- * background_repeat              3               
- * border_bottom_color            2               4
- * border_bottom_style            4               
- * border_bottom_width            3 + 5           4
- * border_collapse                2               
- * border_left_color              2               4
- * border_left_style              4               
- * border_left_width              3 + 5           4
- * border_right_color             2               4
- * border_right_style             4               
- * border_right_width             3 + 5           4
- * border_top_color               2               4
- * border_top_style               4               
- * border_top_width               3 + 5           4
- * bottom                         2 + 5           4
- * box_sizing                     2               
- * caption_side                   2               
- * clear                          3               
- * color                          1               4
- * direction                      2               
- * display                        5               
- * empty_cells                    2               
- * flex_basis                     2 + 5           4
- * flex_direction                 3               
- * flex_grow                      1               4
- * flex_shrink                    1               4
- * flex_wrap                      2               
- * float                          2               
- * font_family                    3               sizeof(ptr)
- * font_size                      4 + 5           4
- * font_style                     2               
- * font_variant                   2               
- * font_weight                    4               
- * height                         2 + 5           4
- * justify_content                3               
- * left                           2 + 5           4
- * line_height                    2 + 5           4
- * list_style_image               1               sizeof(ptr)
- * list_style_position            2               
- * list_style_type                4               
- * margin_bottom                  2 + 5           4
- * margin_left                    2 + 5           4
- * margin_right                   2 + 5           4
- * margin_top                     2 + 5           4
- * max_height                     2 + 5           4
- * max_width                      2 + 5           4
- * min_height                     2 + 5           4
- * min_width                      2 + 5           4
- * opacity                        1               4
- * order                          1               4
- * outline_style                  4               
- * overflow                       3               
- * padding_bottom                 1 + 5           4
- * padding_left                   1 + 5           4
- * padding_right                  1 + 5           4
- * padding_top                    1 + 5           4
- * position                       3               
- * quotes                         1               sizeof(ptr)
- * right                          2 + 5           4
- * table_layout                   2               
- * text_align                     4               
- * text_decoration                5               
- * text_indent                    1 + 5           4
- * text_transform                 3               
- * top                            2 + 5           4
- * unicode_bidi                   2               
- * vertical_align                 4 + 5           4
- * visibility                     2               
- * white_space                    3               
- * width                          2 + 5           4
- * z_index                        2               4
+ * Property                       Size (bits)     Size (bytes)
+ * ---                            ---             ---
+ * align_content                    3             
+ * align_items                      3             
+ * align_self                       3             
+ * background_attachment            2             
+ * background_color                 2               4
+ * background_image                 1             sizeof(ptr)
+ * background_position              1 + 10          8
+ * background_repeat                3             
+ * border_bottom_color              2               4
+ * border_bottom_style              4             
+ * border_bottom_width              3 + 5           4
+ * border_collapse                  2             
+ * border_left_color                2               4
+ * border_left_style                4             
+ * border_left_width                3 + 5           4
+ * border_right_color               2               4
+ * border_right_style               4             
+ * border_right_width               3 + 5           4
+ * border_top_color                 2               4
+ * border_top_style                 4             
+ * border_top_width                 3 + 5           4
+ * bottom                           2 + 5           4
+ * box_sizing                       2             
+ * caption_side                     2             
+ * clear                            3             
+ * color                            1               4
+ * direction                        2             
+ * display                          5             
+ * empty_cells                      2             
+ * flex_basis                       2 + 5           4
+ * flex_direction                   3             
+ * flex_grow                        1               4
+ * flex_shrink                      1               4
+ * flex_wrap                        2             
+ * float                            2             
+ * font_size                        4 + 5           4
+ * font_style                       2             
+ * font_variant                     2             
+ * font_weight                      4             
+ * height                           2 + 5           4
+ * justify_content                  3             
+ * left                             2 + 5           4
+ * line_height                      2 + 5           4
+ * list_style_image                 1             sizeof(ptr)
+ * list_style_position              2             
+ * list_style_type                  4             
+ * margin_bottom                    2 + 5           4
+ * margin_left                      2 + 5           4
+ * margin_right                     2 + 5           4
+ * margin_top                       2 + 5           4
+ * max_height                       2 + 5           4
+ * max_width                        2 + 5           4
+ * min_height                       2 + 5           4
+ * min_width                        2 + 5           4
+ * opacity                          1               4
+ * order                            1               4
+ * outline_style                    4             
+ * overflow                         3             
+ * padding_bottom                   1 + 5           4
+ * padding_left                     1 + 5           4
+ * padding_right                    1 + 5           4
+ * padding_top                      1 + 5           4
+ * position                         3             
+ * right                            2 + 5           4
+ * table_layout                     2             
+ * text_align                       4             
+ * text_decoration                  5             
+ * text_indent                      1 + 5           4
+ * text_transform                   3             
+ * top                              2 + 5           4
+ * unicode_bidi                     2             
+ * vertical_align                   4 + 5           4
+ * visibility                       2             
+ * white_space                      3             
+ * width                            2 + 5           4
+ * z_index                          2               4
+ * 
+ * Encode font family as an array of string objects, terminated with a blank
+ * entry.
+ * 
+ * font_family                      3             sizeof(ptr)
+ * 
+ * Encode quotes as an array of string objects, terminated with a blank entry.
+ * 
+ * quotes                           1             sizeof(ptr)
+ * ---                            ---             ---
+ *                                329 bits        160 + 4sizeof(ptr) bytes
  */
 /**
  * Take a new reference to a computed style
  *
  * \param style  The style to take a new reference to.
- * 
eturn The new computed style reference
+ * \return The new computed style reference
  */
 static inline css_computed_style * css__computed_style_ref(
                css_computed_style *style)
diff --git a/src/select/select_config.py b/src/select/select_config.py
index 27b2dc9..e63dc8b 100644
--- a/src/select/select_config.py
+++ b/src/select/select_config.py
@@ -121,7 +121,7 @@ uncommon = {
     ('break_after', 4, None, None, 'CSS_BREAK_AFTER_AUTO'),
     ('break_before', 4, None, None, 'CSS_BREAK_BEFORE_AUTO'),
     ('break_inside', 4, None, None, 'CSS_BREAK_INSIDE_AUTO'),
-    ('clip', 6, ('length, length, length, length'),
+    ('clip', 6, ('length', 'length', 'length', 'length'),
         'CSS_CLIP_RECT', None, None, ('get', 'set')),
     ('column_count', 2, 'integer', None, 'CSS_COLUMN_COUNT_AUTO'),
     ('column_fill', 2, None, None, 'CSS_COLUMN_FILL_BALANCE'),
diff --git a/src/select/select_generator.py b/src/select/select_generator.py
index a1af7a5..31fe613 100644
--- a/src/select/select_generator.py
+++ b/src/select/select_generator.py
@@ -12,6 +12,9 @@ class Text:
         self._comment = False
         self._indent = 0
 
+    name_width = 31
+    bits_width = 16
+
     def indent(self, value, absolute=False):
         if absolute:
             self._indent = value
@@ -25,11 +28,16 @@ class Text:
         self._comment = not comm
 
     def append(self, text=None, pre_formatted=False):
-        if text is None:
+        if not text:
             self._lines.append('\t' * self._indent + ' * '
                     if self._comment else '')
             return
 
+        if isinstance(text, list):
+            for t in text:
+                self.append(t, pre_formatted)
+            return
+
         if pre_formatted:
             self._lines.append(text)
             return
@@ -46,7 +54,7 @@ class Text:
                 line += text
                 text = ''
             else:
-                break_index = text[:text[:column_max - prefix_size].rfind(' ')]
+                break_index = text[:column_max - prefix_size].rfind(' ')
                 line += text[:break_index].rstrip()
                 text = text[break_index:].lstrip()
             self._lines.append(line)
@@ -57,6 +65,16 @@ class Text:
         if multiline:
             self._indent(-2)
 
+    def table_line(self):
+        self.append('{0:{n}}{0:{b}}{0}'.format(
+            '---', n=self.name_width, b=self.bits_width))
+
+    def table_header(self):
+        self.append('{:{n}}{:{b}}{}'.format(
+            'Property', 'Size (bits)', 'Size (bytes)', 
+            n=self.name_width, b=self.bits_width))
+        self.table_line()
+
     def to_string(self):
         return '\n'.join(self._lines)
 
@@ -108,15 +126,24 @@ class CSSProperty:
             if v.bits is not None ])
 
     @property
+    def bytes_size(self):
+        return sum([ v.size for v in self.values if v.size is not None ])
+
+    @property
+    def ptr_size(self):
+        return sum([ 1 for v in self.values if v.size is None ])
+
+    @property
     def size_line(self):
-        name = '{:31}'.format(self.name)
-        type_size = str(self.type_size)
+        name = '{:{width}}'.format(self.name, width=Text.name_width)
+        type_size = '{:>3}'.format(str(self.type_size))
         extra_size = sum([ v.bits['size'] for v in self.values
                 if v.bits is not None ])
-        bits_size = '{:16}'.format(type_size +
-                (' + ' + str(extra_size) if extra_size else ''))
-        vars_size = sum([ v.size for v in self.values if v.size is not None ])
-        vars_size = str(vars_size) if vars_size else ''
+        bits_size = '{:{width}}'.format(type_size +
+                (' + ' + str(extra_size) if extra_size else ''),
+                width=Text.bits_width)
+        vars_size = '{:>3}'.format(
+                str(self.bytes_size)) if self.bytes_size else ''
         ptr = ''
         for v in self.values:
             if v.size is None:
@@ -145,6 +172,18 @@ class CSSGroup:
         self.__bits_array = None
 
     @property
+    def bits_size(self):
+        return sum([ p.bits_size for p in self.props ])
+
+    @property
+    def bytes_size(self):
+        return sum([ p.bytes_size for p in self.props ])
+
+    @property
+    def ptr_size(self):
+        return sum([ p.ptr_size for p in self.props ])
+
+    @property
     def bits_array(self):
         '''Implements a `best fit first` heuristics for the bin packing of
         property bits in the bits array'''
@@ -173,9 +212,23 @@ class CSSGroup:
         t = Text()
         t.append()
         t.comment()
+        commented = []
+        t.table_header()
         for prop in sorted(self.props, key=(lambda x: x.name)):
-            t.append(prop.size_line)
+            if prop.comments is None:
+                t.append(prop.size_line)
+            else:
+                commented.extend(( '', prop.comments, '', prop.size_line ))
+        t.append(commented)
+        t.table_line()
+        t.append('{:{len_1}}{:>3}{:{len_2}}{:>3}{}{}'.format('',
+            str(self.bits_size), ' bits', str(self.bytes_size),
+            ' + ' + str(self.ptr_size) + 'sizeof(ptr)'
+                    if self.ptr_size else '',
+            ' bytes',
+            len_1=Text.name_width, len_2=(Text.bits_width - 3)))
         t.comment()
+
         return t.to_string()
 
     def make_text(self, filename):
@@ -187,7 +240,7 @@ class CSSGroup:
 css_groups = [ CSSGroup(g) for g in groups['others'] ]
 css_groups.append(CSSGroup(groups['main'], is_main=True))
 
-for k, v in assets:
+for k, v in assets.items():
     # Key is filename string (e.g. "computed.h") without autogenerated_ prefix
     body = '\n'.join([ g.make_text(k) for g in css_groups ])
     text = '\n'.join([ v['header'], body, v['footer'] ])


-- 
Cascading Style Sheets library

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to