Gitweb links:
...log
http://git.netsurf-browser.org/libcss.git/shortlog/10f5daa91de724edafd79094100787ad3a73a7c4
...commit
http://git.netsurf-browser.org/libcss.git/commit/10f5daa91de724edafd79094100787ad3a73a7c4
...tree
http://git.netsurf-browser.org/libcss.git/tree/10f5daa91de724edafd79094100787ad3a73a7c4
The branch, lcneves/units has been updated
via 10f5daa91de724edafd79094100787ad3a73a7c4 (commit)
via 577f2f370a636953cc57485cf5cc3e3887c691c9 (commit)
via 544fbf9858593f585e8c4796ca09914027f7103a (commit)
via b8a7b88d3fa476bc2b808e826de91182bf60ebf6 (commit)
via 0e5d03c7d6ec6827d9e69c333484b7eee2ee6563 (commit)
from c9accc062acbe9d7e174d66423485af013ed9fbc (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=10f5daa91de724edafd79094100787ad3a73a7c4
commit 10f5daa91de724edafd79094100787ad3a73a7c4
Author: Lucas Neves <[email protected]>
Commit: Lucas Neves <[email protected]>
Add override getter and setter functions for the clip property.
diff --git a/src/select/computed_properties.py
b/src/select/computed_properties.py
index a9fc0e7..3f87bed 100644
--- a/src/select/computed_properties.py
+++ b/src/select/computed_properties.py
@@ -11,13 +11,13 @@ def get_tuple(from_var):
else:
return ()
-def make_type(name, css_type, size = 0, default = 'NULL',
+def make_type(name, css_type, size = None, default = 'NULL',
bits_name = None, bits_type = None,
bits_size = None, bits_default = 0):
return {
'name': name,
'type': css_type,
- 'size': size,
+ 'size': size, # `None` means sizeof(ptr)
'default': default,
'bits': None if bits_name is None else {
'name': bits_name,
@@ -51,12 +51,12 @@ def make_property(name, opcode_size, values = None,
'name': name,
'size': opcode_size,
'values': [ types[x] for x in value_tuple ] or None,
- 'defaults': default_tuple or None,
+ 'defaults': default_tuple or None, # May be `None` only for main group
'comments': comments
}
# Configuration of properties
-prop_config = {
+style_config = {
# Style group, only opcode
('align_content', 3),
('align_items', 3),
@@ -140,13 +140,19 @@ prop_config = {
'\n' 'blank entry.'),
('quotes', 1, 'string_arr', None,
'Encode quotes as an array of string objects, terminated with a '
- 'blank entry.'),
+ 'blank entry.')
+}
+
+page_config = {
# Page group
('page_break_after', 3, None, 'CSS_PAGE_BREAK_AFTER_AUTO'),
('page_break_before', 3, None, 'CSS_PAGE_BREAK_BEFORE_AUTO'),
('page_break_inside', 2, None, 'CSS_PAGE_BREAK_INSIDE_AUTO'),
('widows', 1, 'integer', ('CSS_WIDOWS_SET', 2)),
- ('orphans', 1, 'integer', ('CSS_ORPHANS_SET', 2)),
+ ('orphans', 1, 'integer', ('CSS_ORPHANS_SET', 2))
+}
+
+uncommon_config = {
# Uncommon group
('border_spacing', 1, ('length', 'length'),
('CSS_BORDER_SPACING_SET', 0, 'CSS_UNIT_PX', 0, 'CSS_UNIT_PX')),
@@ -181,121 +187,11 @@ prop_config = {
'a blank entry.')
}
-properties = [ make_property(*x) for x in prop_config ]
+uncommon = [ make_property(*x) for x in uncommon_config ]
+page = [ make_property(*x) for x in page_config ]
+style = [ make_property(*x) for x in style_config ]
-uncommon_config = {
- 'border_spacing',
- 'break_before',
- 'break_after',
- 'break_inside',
- 'clip',
- 'column_count',
- 'column_fill',
- 'column_gap',
- 'column_rule_color',
- 'column_rule_style',
- 'column_rule_width',
- 'content',
- 'counter_increment',
- 'counter_reset',
- 'cursor',
- 'letter_spacing',
- 'outline_color',
- 'outline_width',
- 'word_spacing'
+properties = {
+ groups: [ uncommon, page, style ],
+ default_group: style
}
-
-page_config = {
- 'page_break_after',
- 'page_break_before',
- 'page_break_inside',
- 'orphans',
- 'windows'
-}
-
-style_config = {
- 'align_content',
- 'align_items',
- 'align_self',
- 'background_attachment',
- 'background_repeat',
- 'background_color',
- 'background_image',
- 'background_position',
- 'border_collapse',
- 'border_top_style',
- 'border_right_style',
- 'border_bottom_style',
- 'border_left_style',
- 'border_top_color',
- 'border_right_color',
- 'border_bottom_color',
- 'border_left_color',
- 'border_top_width',
- 'border_right_width',
- 'border_bottom_width',
- 'border_left_width',
- 'top',
- 'right',
- 'bottom',
- 'left',
- 'box_sizing',
- 'caption_side',
- 'clear',
- 'color',
- 'direction',
- 'display',
- 'empty_cells',
- 'flex_basis',
- 'flex_direction',
- 'flex_grow',
- 'flex_shrink',
- 'flex_wrap',
- 'float',
- 'font_family',
- 'font_size',
- 'font_style',
- 'font_variant',
- 'font_weight',
- 'height',
- 'justify_content',
- 'line_height',
- 'list_style_image',
- 'list_style_position',
- 'list_style_type',
- 'margin_top',
- 'margin_right',
- 'margin_bottom',
- 'margin_left',
- 'max_height',
- 'max_width',
- 'min_height',
- 'min_width',
- 'order',
- 'outline_style',
- 'overflow',
- 'padding_top',
- 'padding_right',
- 'padding_bottom',
- 'padding_left',
- 'position',
- 'quotes',
- 'table_layout',
- 'text_align',
- 'text_decoration',
- 'text_indent',
- 'text_transform',
- 'unicode_bidi',
- 'vertical_align',
- 'visibility',
- 'white_space',
- 'width',
- 'z_index'
-}
-
-uncommon = [ x for x in properties if x['name'] in uncommon_config ]
-page = [ x for x in properties if x['name'] in page_config ]
-style = [ x for x in properties if x['name'] in style_config ]
-
-groups = [ uncommon, page, style ]
-
diff --git a/src/select/overrides.py b/src/select/overrides.py
new file mode 100644
index 0000000..930bd4a
--- /dev/null
+++ b/src/select/overrides.py
@@ -0,0 +1,88 @@
+# This file is part of LibCSS.
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Copyright 2017 Lucas Neves <[email protected]>
+
+clip = {}
+clip['get'] = '''\
+static inline uint32_t get_clip(
+ const css_computed_style *style,
+ css_computed_clip_rect *rect)
+{
+ if (style->i.uncommon != NULL) {
+ uint32_t bits = style->i.uncommon->i.bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= CLIP_SHIFT;
+
+ /*
+ 26bits: tt tttr rrrr bbbb blll llTR BLyy:
+ units: top | right | bottom | left
+ opcodes: top | right | bottom | left | type
+ */
+
+ if ((bits & 0x3) == CSS_CLIP_RECT) {
+ rect->left_auto = (bits & 0x4);
+ rect->bottom_auto = (bits & 0x8);
+ rect->right_auto = (bits & 0x10);
+ rect->top_auto = (bits & 0x20);
+
+ rect->top = style->i.uncommon->i.clip_a;
+ rect->tunit = bits & 0x3e00000;
+
+ rect->right = style->i.uncommon->i.clip_b;
+ rect->runit = bits & 0x1f0000;
+
+ rect->bottom = style->i.uncommon->i.clip_c;
+ rect->bunit = bits & 0xf800;
+
+ rect->left = style->i.uncommon->i.clip_d;
+ rect->lunit = bits & 0x7c0;
+ }
+
+ return (bits & 0x3);
+ }
+
+ /* Initial value */
+ return CSS_CLIP_AUTO;
+}
+'''
+clip['set'] = '''\
+static inline css_error set_clip(
+ css_computed_style *style, uint8_t type,
+ css_computed_clip_rect *rect)
+{
+ uint32_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->i.uncommon->i.bits[CLIP_INDEX];
+
+ /*
+ 26bits: tt tttr rrrr bbbb blll llTR BLyy:
+ units: top | right | bottom | left
+ opcodes: top | right | bottom | left | type
+ */
+ *bits = (*bits & ~CLIP_MASK) |
+ ((type & 0x3) << CLIP_SHIFT);
+
+ if (type == CSS_CLIP_RECT) {
+ *bits |= (((rect->top_auto ? 0x20 : 0) |
+ (rect->right_auto ? 0x10 : 0) |
+ (rect->bottom_auto ? 0x8 : 0) |
+ (rect->left_auto ? 0x4 : 0)) << CLIP_SHIFT);
+
+ *bits |= (((rect->tunit << 5) | rect->runit)
+ << (CLIP_SHIFT + 16));
+
+ *bits |= (((rect->bunit << 5) | rect->lunit)
+ << (CLIP_SHIFT + 6));
+
+ style->i.uncommon->i.clip_a = rect->top;
+ style->i.uncommon->i.clip_b = rect->right;
+ style->i.uncommon->i.clip_c = rect->bottom;
+ style->i.uncommon->i.clip_d = rect->left;
+ }
+
+ return CSS_OK;
+}
+'''
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=577f2f370a636953cc57485cf5cc3e3887c691c9
commit 577f2f370a636953cc57485cf5cc3e3887c691c9
Merge: 544fbf9 c9accc0
Author: Lucas Neves <[email protected]>
Commit: Lucas Neves <[email protected]>
Merge branch 'lcneves/units' of ssh://git.netsurf-browser.org/libcss into
lcneves/units
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=544fbf9858593f585e8c4796ca09914027f7103a
commit 544fbf9858593f585e8c4796ca09914027f7103a
Merge: b8a7b88 c1ccd83
Author: Lucas Neves <[email protected]>
Commit: Lucas Neves <[email protected]>
Merge branch 'lcneves/units' of ssh://git.netsurf-browser.org/libcss into
lcneves/units
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=b8a7b88d3fa476bc2b808e826de91182bf60ebf6
commit b8a7b88d3fa476bc2b808e826de91182bf60ebf6
Author: Lucas Neves <[email protected]>
Commit: Lucas Neves <[email protected]>
Update documentation
diff --git a/docs/Bytecode b/docs/Bytecode
index 852a918..ac1bc35 100644
--- a/docs/Bytecode
+++ b/docs/Bytecode
@@ -44,6 +44,19 @@ Length is a 32bit numeric value (as described above) and
unit is as follows:
00000101 => mm
00000110 => pt
00000111 => pc
+ 00001000 => cap
+ 00001001 => ch
+ 00001010 => ic
+ 00001011 => rem
+ 00001100 => lh
+ 00001101 => rlh
+ 00001110 => vh
+ 00001111 => vw
+ 00010000 => vi
+ 00010001 => vb
+ 00010010 => vmin
+ 00010011 => vmax
+ 00010100 => q
bit 8 set => percentage unit
bits 9-31: MBZ
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=0e5d03c7d6ec6827d9e69c333484b7eee2ee6563
commit 0e5d03c7d6ec6827d9e69c333484b7eee2ee6563
Author: Lucas Neves <[email protected]>
Commit: Lucas Neves <[email protected]>
WIP: Add new length units
diff --git a/include/libcss/types.h b/include/libcss/types.h
index ffaf13c..4f35737 100644
--- a/include/libcss/types.h
+++ b/include/libcss/types.h
@@ -80,26 +80,39 @@ typedef uint32_t css_color;
/* CSS unit */
typedef enum css_unit {
- CSS_UNIT_PX = 0x0,
- CSS_UNIT_EX = 0x1,
- CSS_UNIT_EM = 0x2,
- CSS_UNIT_IN = 0x3,
- CSS_UNIT_CM = 0x4,
- CSS_UNIT_MM = 0x5,
- CSS_UNIT_PT = 0x6,
- CSS_UNIT_PC = 0x7,
-
- CSS_UNIT_PCT = 0x8, /* Percentage */
-
- CSS_UNIT_DEG = 0x9,
- CSS_UNIT_GRAD = 0xa,
- CSS_UNIT_RAD = 0xb,
-
- CSS_UNIT_MS = 0xc,
- CSS_UNIT_S = 0xd,
-
- CSS_UNIT_HZ = 0xe,
- CSS_UNIT_KHZ = 0xf
+ CSS_UNIT_PX = 0x00,
+ CSS_UNIT_EX = 0x01,
+ CSS_UNIT_EM = 0x02,
+ CSS_UNIT_IN = 0x03,
+ CSS_UNIT_CM = 0x04,
+ CSS_UNIT_MM = 0x05,
+ CSS_UNIT_PT = 0x06,
+ CSS_UNIT_PC = 0x07,
+ CSS_UNIT_CAP = 0x08,
+ CSS_UNIT_CH = 0x09,
+ CSS_UNIT_IC = 0x0a,
+ CSS_UNIT_REM = 0x0b,
+ CSS_UNIT_LH = 0x0c,
+ CSS_UNIT_RLH = 0x0d,
+ CSS_UNIT_VH = 0x0e,
+ CSS_UNIT_VW = 0x0f,
+ CSS_UNIT_VI = 0x10,
+ CSS_UNIT_VB = 0x11,
+ CSS_UNIT_VMIN = 0x12,
+ CSS_UNIT_VMAX = 0x13,
+ CSS_UNIT_Q = 0x14,
+
+ CSS_UNIT_PCT = 0x15, /* Percentage */
+
+ CSS_UNIT_DEG = 0x16,
+ CSS_UNIT_GRAD = 0x17,
+ CSS_UNIT_RAD = 0x18,
+
+ CSS_UNIT_MS = 0x19,
+ CSS_UNIT_S = 0x1a,
+
+ CSS_UNIT_HZ = 0x1b,
+ CSS_UNIT_KHZ = 0x1c
} css_unit;
/**
diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h
index 656d7a5..422f141 100644
--- a/src/bytecode/bytecode.h
+++ b/src/bytecode/bytecode.h
@@ -32,6 +32,19 @@ typedef enum unit {
UNIT_MM = 5,
UNIT_PT = 6,
UNIT_PC = 7,
+ UNIT_CAP = 8,
+ UNIT_CH = 9,
+ UNIT_IC = 10,
+ UNIT_REM = 11,
+ UNIT_LH = 12,
+ UNIT_RLH = 13,
+ UNIT_VH = 14,
+ UNIT_VW = 15,
+ UNIT_VI = 16,
+ UNIT_VB = 17,
+ UNIT_VMIN = 18,
+ UNIT_VMAX = 19,
+ UNIT_Q = 20,
UNIT_PCT = (1 << 8),
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index 47b06e3..76b406b 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -1007,6 +1007,10 @@ css_error css__parse_unit_keyword(const char *ptr,
size_t len, uint32_t *unit)
if (len == 4) {
if (strncasecmp(ptr, "grad", 4) == 0)
*unit = UNIT_GRAD;
+ else if (strncasecmp(ptr, "vmin", 4) == 0)
+ *unit = UNIT_VMIN;
+ else if (strncasecmp(ptr, "vmax", 4) == 0)
+ *unit = UNIT_VMAX;
else
return CSS_INVALID;
} else if (len == 3) {
@@ -1016,6 +1020,12 @@ css_error css__parse_unit_keyword(const char *ptr,
size_t len, uint32_t *unit)
*unit = UNIT_DEG;
else if (strncasecmp(ptr, "rad", 3) == 0)
*unit = UNIT_RAD;
+ else if (strncasecmp(ptr, "cap", 3) == 0)
+ *unit = UNIT_CAP;
+ else if (strncasecmp(ptr, "rem", 3) == 0)
+ *unit = UNIT_REM;
+ else if (strncasecmp(ptr, "rlh", 3) == 0)
+ *unit = UNIT_RLH;
else
return CSS_INVALID;
} else if (len == 2) {
@@ -1039,11 +1049,27 @@ css_error css__parse_unit_keyword(const char *ptr,
size_t len, uint32_t *unit)
*unit = UNIT_PT;
else if (strncasecmp(ptr, "pc", 2) == 0)
*unit = UNIT_PC;
+ else if (strncasecmp(ptr, "ch", 2) == 0)
+ *unit = UNIT_CH;
+ else if (strncasecmp(ptr, "ic", 2) == 0)
+ *unit = UNIT_IC;
+ else if (strncasecmp(ptr, "lh", 2) == 0)
+ *unit = UNIT_LH;
+ else if (strncasecmp(ptr, "vh", 2) == 0)
+ *unit = UNIT_VH;
+ else if (strncasecmp(ptr, "vw", 2) == 0)
+ *unit = UNIT_VW;
+ else if (strncasecmp(ptr, "vi", 2) == 0)
+ *unit = UNIT_VI;
+ else if (strncasecmp(ptr, "vb", 2) == 0)
+ *unit = UNIT_VB;
else
return CSS_INVALID;
} else if (len == 1) {
if (strncasecmp(ptr, "s", 1) == 0)
*unit = UNIT_S;
+ else if (strncasecmp(ptr, "q", 1) == 0)
+ *unit = UNIT_Q;
else
return CSS_INVALID;
} else
diff --git a/src/select/properties/helpers.c b/src/select/properties/helpers.c
index 36c3cba..5893919 100644
--- a/src/select/properties/helpers.c
+++ b/src/select/properties/helpers.c
@@ -29,6 +29,19 @@ css_unit css__to_css_unit(uint32_t u)
case UNIT_MM: return CSS_UNIT_MM;
case UNIT_PT: return CSS_UNIT_PT;
case UNIT_PC: return CSS_UNIT_PC;
+ case UNIT_CAP: return CSS_UNIT_CAP;
+ case UNIT_CH: return CSS_UNIT_CH;
+ case UNIT_IC: return CSS_UNIT_IC;
+ case UNIT_REM: return CSS_UNIT_REM;
+ case UNIT_LH: return CSS_UNIT_LH;
+ case UNIT_RLH: return CSS_UNIT_RLH;
+ case UNIT_VH: return CSS_UNIT_VH;
+ case UNIT_VW: return CSS_UNIT_VW;
+ case UNIT_VI: return CSS_UNIT_VI;
+ case UNIT_VB: return CSS_UNIT_VB;
+ case UNIT_VMIN: return CSS_UNIT_VMIN;
+ case UNIT_VMAX: return CSS_UNIT_VMAX;
+ case UNIT_Q: return CSS_UNIT_Q;
case UNIT_PCT: return CSS_UNIT_PCT;
case UNIT_DEG: return CSS_UNIT_DEG;
case UNIT_GRAD: return CSS_UNIT_GRAD;
diff --git a/test/dump.h b/test/dump.h
index 0159b19..8d74ce6 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -574,6 +574,45 @@ static void dump_unit(css_fixed val, uint32_t unit, char
**ptr)
case UNIT_PC:
*ptr += sprintf(*ptr, "pc");
break;
+ case UNIT_CAP:
+ *ptr += sprintf(*ptr, "cap");
+ break;
+ case UNIT_CH:
+ *ptr += sprintf(*ptr, "ch");
+ break;
+ case UNIT_IC:
+ *ptr += sprintf(*ptr, "ic");
+ break;
+ case UNIT_REM:
+ *ptr += sprintf(*ptr, "rem");
+ break;
+ case UNIT_LH:
+ *ptr += sprintf(*ptr, "lh");
+ break;
+ case UNIT_RLH:
+ *ptr += sprintf(*ptr, "rlh");
+ break;
+ case UNIT_VH:
+ *ptr += sprintf(*ptr, "vh");
+ break;
+ case UNIT_VW:
+ *ptr += sprintf(*ptr, "vw");
+ break;
+ case UNIT_VI:
+ *ptr += sprintf(*ptr, "vi");
+ break;
+ case UNIT_VB:
+ *ptr += sprintf(*ptr, "vb");
+ break;
+ case UNIT_VMIN:
+ *ptr += sprintf(*ptr, "vmin");
+ break;
+ case UNIT_VMAX:
+ *ptr += sprintf(*ptr, "vmax");
+ break;
+ case UNIT_Q:
+ *ptr += sprintf(*ptr, "q");
+ break;
case UNIT_PCT:
*ptr += sprintf(*ptr, "%%");
break;
diff --git a/test/dump_computed.h b/test/dump_computed.h
index c9d699d..bcddc3d 100644
--- a/test/dump_computed.h
+++ b/test/dump_computed.h
@@ -105,6 +105,45 @@ static size_t dump_css_unit(css_fixed val, css_unit unit,
char *ptr, size_t len)
case CSS_UNIT_PC:
ret += snprintf(ptr + ret, len - ret, "pc");
break;
+ case CSS_UNIT_CAP:
+ ret += snprintf(ptr + ret, len - ret, "cap");
+ break;
+ case CSS_UNIT_CH:
+ ret += snprintf(ptr + ret, len - ret, "ch");
+ break;
+ case CSS_UNIT_IC:
+ ret += snprintf(ptr + ret, len - ret, "ic");
+ break;
+ case CSS_UNIT_REM:
+ ret += snprintf(ptr + ret, len - ret, "rem");
+ break;
+ case CSS_UNIT_LH:
+ ret += snprintf(ptr + ret, len - ret, "lh");
+ break;
+ case CSS_UNIT_RLH:
+ ret += snprintf(ptr + ret, len - ret, "rlh");
+ break;
+ case CSS_UNIT_VH:
+ ret += snprintf(ptr + ret, len - ret, "vh");
+ break;
+ case CSS_UNIT_VW:
+ ret += snprintf(ptr + ret, len - ret, "vh");
+ break;
+ case CSS_UNIT_VI:
+ ret += snprintf(ptr + ret, len - ret, "vi");
+ break;
+ case CSS_UNIT_VB:
+ ret += snprintf(ptr + ret, len - ret, "vb");
+ break;
+ case CSS_UNIT_VMIN:
+ ret += snprintf(ptr + ret, len - ret, "vmin");
+ break;
+ case CSS_UNIT_VMAX:
+ ret += snprintf(ptr + ret, len - ret, "vmax");
+ break;
+ case CSS_UNIT_Q:
+ ret += snprintf(ptr + ret, len - ret, "q");
+ break;
case CSS_UNIT_PCT:
ret += snprintf(ptr + ret, len - ret, "%%");
break;
-----------------------------------------------------------------------
Summary of changes:
src/select/computed_properties.py | 140 +++++--------------------------------
src/select/overrides.py | 88 +++++++++++++++++++++++
2 files changed, 106 insertions(+), 122 deletions(-)
create mode 100644 src/select/overrides.py
diff --git a/src/select/computed_properties.py
b/src/select/computed_properties.py
index a9fc0e7..3f87bed 100644
--- a/src/select/computed_properties.py
+++ b/src/select/computed_properties.py
@@ -11,13 +11,13 @@ def get_tuple(from_var):
else:
return ()
-def make_type(name, css_type, size = 0, default = 'NULL',
+def make_type(name, css_type, size = None, default = 'NULL',
bits_name = None, bits_type = None,
bits_size = None, bits_default = 0):
return {
'name': name,
'type': css_type,
- 'size': size,
+ 'size': size, # `None` means sizeof(ptr)
'default': default,
'bits': None if bits_name is None else {
'name': bits_name,
@@ -51,12 +51,12 @@ def make_property(name, opcode_size, values = None,
'name': name,
'size': opcode_size,
'values': [ types[x] for x in value_tuple ] or None,
- 'defaults': default_tuple or None,
+ 'defaults': default_tuple or None, # May be `None` only for main group
'comments': comments
}
# Configuration of properties
-prop_config = {
+style_config = {
# Style group, only opcode
('align_content', 3),
('align_items', 3),
@@ -140,13 +140,19 @@ prop_config = {
'\n' 'blank entry.'),
('quotes', 1, 'string_arr', None,
'Encode quotes as an array of string objects, terminated with a '
- 'blank entry.'),
+ 'blank entry.')
+}
+
+page_config = {
# Page group
('page_break_after', 3, None, 'CSS_PAGE_BREAK_AFTER_AUTO'),
('page_break_before', 3, None, 'CSS_PAGE_BREAK_BEFORE_AUTO'),
('page_break_inside', 2, None, 'CSS_PAGE_BREAK_INSIDE_AUTO'),
('widows', 1, 'integer', ('CSS_WIDOWS_SET', 2)),
- ('orphans', 1, 'integer', ('CSS_ORPHANS_SET', 2)),
+ ('orphans', 1, 'integer', ('CSS_ORPHANS_SET', 2))
+}
+
+uncommon_config = {
# Uncommon group
('border_spacing', 1, ('length', 'length'),
('CSS_BORDER_SPACING_SET', 0, 'CSS_UNIT_PX', 0, 'CSS_UNIT_PX')),
@@ -181,121 +187,11 @@ prop_config = {
'a blank entry.')
}
-properties = [ make_property(*x) for x in prop_config ]
+uncommon = [ make_property(*x) for x in uncommon_config ]
+page = [ make_property(*x) for x in page_config ]
+style = [ make_property(*x) for x in style_config ]
-uncommon_config = {
- 'border_spacing',
- 'break_before',
- 'break_after',
- 'break_inside',
- 'clip',
- 'column_count',
- 'column_fill',
- 'column_gap',
- 'column_rule_color',
- 'column_rule_style',
- 'column_rule_width',
- 'content',
- 'counter_increment',
- 'counter_reset',
- 'cursor',
- 'letter_spacing',
- 'outline_color',
- 'outline_width',
- 'word_spacing'
+properties = {
+ groups: [ uncommon, page, style ],
+ default_group: style
}
-
-page_config = {
- 'page_break_after',
- 'page_break_before',
- 'page_break_inside',
- 'orphans',
- 'windows'
-}
-
-style_config = {
- 'align_content',
- 'align_items',
- 'align_self',
- 'background_attachment',
- 'background_repeat',
- 'background_color',
- 'background_image',
- 'background_position',
- 'border_collapse',
- 'border_top_style',
- 'border_right_style',
- 'border_bottom_style',
- 'border_left_style',
- 'border_top_color',
- 'border_right_color',
- 'border_bottom_color',
- 'border_left_color',
- 'border_top_width',
- 'border_right_width',
- 'border_bottom_width',
- 'border_left_width',
- 'top',
- 'right',
- 'bottom',
- 'left',
- 'box_sizing',
- 'caption_side',
- 'clear',
- 'color',
- 'direction',
- 'display',
- 'empty_cells',
- 'flex_basis',
- 'flex_direction',
- 'flex_grow',
- 'flex_shrink',
- 'flex_wrap',
- 'float',
- 'font_family',
- 'font_size',
- 'font_style',
- 'font_variant',
- 'font_weight',
- 'height',
- 'justify_content',
- 'line_height',
- 'list_style_image',
- 'list_style_position',
- 'list_style_type',
- 'margin_top',
- 'margin_right',
- 'margin_bottom',
- 'margin_left',
- 'max_height',
- 'max_width',
- 'min_height',
- 'min_width',
- 'order',
- 'outline_style',
- 'overflow',
- 'padding_top',
- 'padding_right',
- 'padding_bottom',
- 'padding_left',
- 'position',
- 'quotes',
- 'table_layout',
- 'text_align',
- 'text_decoration',
- 'text_indent',
- 'text_transform',
- 'unicode_bidi',
- 'vertical_align',
- 'visibility',
- 'white_space',
- 'width',
- 'z_index'
-}
-
-uncommon = [ x for x in properties if x['name'] in uncommon_config ]
-page = [ x for x in properties if x['name'] in page_config ]
-style = [ x for x in properties if x['name'] in style_config ]
-
-groups = [ uncommon, page, style ]
-
diff --git a/src/select/overrides.py b/src/select/overrides.py
new file mode 100644
index 0000000..930bd4a
--- /dev/null
+++ b/src/select/overrides.py
@@ -0,0 +1,88 @@
+# This file is part of LibCSS.
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Copyright 2017 Lucas Neves <[email protected]>
+
+clip = {}
+clip['get'] = '''\
+static inline uint32_t get_clip(
+ const css_computed_style *style,
+ css_computed_clip_rect *rect)
+{
+ if (style->i.uncommon != NULL) {
+ uint32_t bits = style->i.uncommon->i.bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= CLIP_SHIFT;
+
+ /*
+ 26bits: tt tttr rrrr bbbb blll llTR BLyy:
+ units: top | right | bottom | left
+ opcodes: top | right | bottom | left | type
+ */
+
+ if ((bits & 0x3) == CSS_CLIP_RECT) {
+ rect->left_auto = (bits & 0x4);
+ rect->bottom_auto = (bits & 0x8);
+ rect->right_auto = (bits & 0x10);
+ rect->top_auto = (bits & 0x20);
+
+ rect->top = style->i.uncommon->i.clip_a;
+ rect->tunit = bits & 0x3e00000;
+
+ rect->right = style->i.uncommon->i.clip_b;
+ rect->runit = bits & 0x1f0000;
+
+ rect->bottom = style->i.uncommon->i.clip_c;
+ rect->bunit = bits & 0xf800;
+
+ rect->left = style->i.uncommon->i.clip_d;
+ rect->lunit = bits & 0x7c0;
+ }
+
+ return (bits & 0x3);
+ }
+
+ /* Initial value */
+ return CSS_CLIP_AUTO;
+}
+'''
+clip['set'] = '''\
+static inline css_error set_clip(
+ css_computed_style *style, uint8_t type,
+ css_computed_clip_rect *rect)
+{
+ uint32_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->i.uncommon->i.bits[CLIP_INDEX];
+
+ /*
+ 26bits: tt tttr rrrr bbbb blll llTR BLyy:
+ units: top | right | bottom | left
+ opcodes: top | right | bottom | left | type
+ */
+ *bits = (*bits & ~CLIP_MASK) |
+ ((type & 0x3) << CLIP_SHIFT);
+
+ if (type == CSS_CLIP_RECT) {
+ *bits |= (((rect->top_auto ? 0x20 : 0) |
+ (rect->right_auto ? 0x10 : 0) |
+ (rect->bottom_auto ? 0x8 : 0) |
+ (rect->left_auto ? 0x4 : 0)) << CLIP_SHIFT);
+
+ *bits |= (((rect->tunit << 5) | rect->runit)
+ << (CLIP_SHIFT + 16));
+
+ *bits |= (((rect->bunit << 5) | rect->lunit)
+ << (CLIP_SHIFT + 6));
+
+ style->i.uncommon->i.clip_a = rect->top;
+ style->i.uncommon->i.clip_b = rect->right;
+ style->i.uncommon->i.clip_c = rect->bottom;
+ style->i.uncommon->i.clip_d = rect->left;
+ }
+
+ return CSS_OK;
+}
+'''
--
Cascading Style Sheets library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org