From 3b1a80cbb138c9c714efc0f32729506060c78c81 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 4 Jul 2009 13:21:28 +0000 Subject: Move quotes property into common style block. svn path=/trunk/libcss/; revision=8307 --- include/libcss/computed.h | 80 ++++++++++++++++++++------------------------- src/select/computed.c | 8 ++--- src/select/dispatch.c | 2 +- src/select/properties.c | 4 +-- src/select/propset.h | 46 ++++++++++++-------------- test/data/select/tests1.dat | 4 --- test/dump_computed.h | 3 ++ 7 files changed, 66 insertions(+), 81 deletions(-) diff --git a/include/libcss/computed.h b/include/libcss/computed.h index e0e3526..672d504 100644 --- a/include/libcss/computed.h +++ b/include/libcss/computed.h @@ -87,12 +87,6 @@ typedef struct css_computed_uncommon { * --- --- * 2 bits 2sizeof(ptr) bytes * - * Encode quotes as an array of string objects, terminated with a blank entry. - * - * quotes 1 sizeof(ptr) - * --- --- - * 1 bit sizeof(ptr) bytes - * * Encode cursor uri(s) as an array of string objects, terminated with a * blank entry. * @@ -105,11 +99,11 @@ typedef struct css_computed_uncommon { * 2 bits sizeof(ptr) * * ___ ___ - * 62 bits 40 + 5sizeof(ptr) bytes + * 61 bits 40 + 4sizeof(ptr) bytes * - * 8 bytes 40 + 5sizeof(ptr) bytes + * 8 bytes 40 + 4sizeof(ptr) bytes * =================== - * 48 + 5sizeof(ptr) bytes + * 48 + 4sizeof(ptr) bytes * * Bit allocations: * @@ -118,7 +112,7 @@ typedef struct css_computed_uncommon { * 2 ooooooob outline-width | border-spacing * 3 bbbbbbbb border-spacing * 4 wwwwwwir word-spacing | counter-increment | counter-reset - * 5 uuuuuq.. cursor | quotes | + * 5 uuuuu... cursor | * 6 cccccccc clip * 7 cccccccc clip * 8 ccccccoo clip | content @@ -139,8 +133,6 @@ typedef struct css_computed_uncommon { css_computed_counter *counter_increment; css_computed_counter *counter_reset; - lwc_string **quotes; - lwc_string **cursor; css_computed_content_item *content; @@ -228,12 +220,18 @@ struct css_computed_style { * --- --- * 3 bits sizeof(ptr) * + * Encode quotes as an array of string objects, terminated with a blank entry. + * + * quotes 1 sizeof(ptr) + * --- --- + * 1 bit sizeof(ptr) bytes + * * ___ ___ - * 267 bits 140 + 3sizeof(ptr) bytes + * 268 bits 140 + 4sizeof(ptr) bytes * - * 34 bytes 140 + 3sizeof(ptr) bytes + * 34 bytes 140 + 4sizeof(ptr) bytes * =================== - * 174 + 3sizeof(ptr) bytes + * 174 + 4sizeof(ptr) bytes * * Bit allocations: * @@ -243,7 +241,7 @@ struct css_computed_style { * 3 ttttttti border-top-width | background-image * 4 rrrrrrrc border-right-width | color * 5 bbbbbbbl border-bottom-width | list-style-image - * 6 lllllll. border-left-width | + * 6 lllllllq border-left-width | quotes * 7 ttttttcc top | border-top-color * 8 rrrrrrcc right | border-right-color * 9 bbbbbbcc bottom | border-bottom-color @@ -319,6 +317,8 @@ struct css_computed_style { lwc_string **font_family; + lwc_string **quotes; + css_computed_uncommon *uncommon;/**< Uncommon properties */ void *aural; /**< Aural properties */ void *page; /**< Page properties */ @@ -568,34 +568,6 @@ static inline uint8_t css_computed_cursor( #undef CURSOR_SHIFT #undef CURSOR_INDEX -#define QUOTES_INDEX 4 -#define QUOTES_SHIFT 2 -#define QUOTES_MASK 0x4 -static inline uint8_t css_computed_quotes( - const css_computed_style *style, - lwc_string ***quotes) -{ - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[QUOTES_INDEX]; - bits &= QUOTES_MASK; - bits >>= QUOTES_SHIFT; - - /* 1bit: type */ - *quotes = style->uncommon->quotes; - - return bits; - } - - /** \todo This should be the UA default. Quotes probably needs moving - * into the main style block, so we don't need to look up the initial - * value after selection. - */ - return CSS_QUOTES_NONE; -} -#undef QUOTES_MASK -#undef QUOTES_SHIFT -#undef QUOTES_INDEX - #define CLIP_INDEX 7 #define CLIP_SHIFT 2 #define CLIP_MASK 0xfc @@ -893,6 +865,26 @@ static inline uint8_t css_computed_list_style_image( #undef LIST_STYLE_IMAGE_SHIFT #undef LIST_STYLE_IMAGE_INDEX +#define QUOTES_INDEX 5 +#define QUOTES_SHIFT 0 +#define QUOTES_MASK 0x1 +static inline uint8_t css_computed_quotes( + const css_computed_style *style, + lwc_string ***quotes) +{ + uint8_t bits = style->bits[QUOTES_INDEX]; + bits &= QUOTES_MASK; + bits >>= QUOTES_SHIFT; + + /* 1bit: type */ + *quotes = style->quotes; + + return bits; +} +#undef QUOTES_MASK +#undef QUOTES_SHIFT +#undef QUOTES_INDEX + #define TOP_INDEX 6 #define TOP_SHIFT 2 #define TOP_MASK 0xfc diff --git a/src/select/computed.c b/src/select/computed.c index 7829b23..d8007c1 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -65,10 +65,7 @@ css_error css_computed_style_destroy(css_computed_style *style) style->alloc(style->uncommon->counter_reset, 0, style->pw); } - - if (style->uncommon->quotes != NULL) - style->alloc(style->uncommon->quotes, 0, style->pw); - + if (style->uncommon->cursor != NULL) style->alloc(style->uncommon->cursor, 0, style->pw); @@ -86,6 +83,9 @@ css_error css_computed_style_destroy(css_computed_style *style) if (style->font_family != NULL) style->alloc(style->font_family, 0, style->pw); + if (style->quotes != NULL) + style->alloc(style->quotes, 0, style->pw); + style->alloc(style, 0, style->pw); return CSS_OK; diff --git a/src/select/dispatch.c b/src/select/dispatch.c index 10eb0ed..c15465b 100644 --- a/src/select/dispatch.c +++ b/src/select/dispatch.c @@ -610,7 +610,7 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = { initial_quotes, compose_quotes, 1, - GROUP_UNCOMMON + GROUP_NORMAL }, { cascade_richness, diff --git a/src/select/properties.c b/src/select/properties.c index c607bf0..cb9ed02 100644 --- a/src/select/properties.c +++ b/src/select/properties.c @@ -4126,9 +4126,7 @@ css_error compose_quotes(const css_computed_style *parent, css_error error; lwc_string **quotes = NULL; - if ((child->uncommon == NULL && parent->uncommon != NULL) || - css_computed_quotes(child, "es) == - CSS_QUOTES_INHERIT) { + if (css_computed_quotes(child, "es) == CSS_QUOTES_INHERIT) { uint8_t p = css_computed_quotes(parent, "es); size_t n_quotes = 0; lwc_string **copy = NULL; diff --git a/src/select/propset.h b/src/select/propset.h index 743297b..c98d47b 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -241,31 +241,6 @@ static inline css_error set_cursor( #undef CURSOR_SHIFT #undef CURSOR_INDEX -#define QUOTES_INDEX 4 -#define QUOTES_SHIFT 2 -#define QUOTES_MASK 0x4 -static inline css_error set_quotes( - css_computed_style *style, uint8_t type, - lwc_string **quotes) -{ - uint8_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->uncommon->bits[QUOTES_INDEX]; - - /* 1bit: type */ - *bits = (*bits & ~QUOTES_MASK) | - ((type & 0x1) << QUOTES_SHIFT); - - style->uncommon->quotes = quotes; - - return CSS_OK; -} -#undef QUOTES_MASK -#undef QUOTES_SHIFT -#undef QUOTES_INDEX - #define CLIP_INDEX 7 #define CLIP_SHIFT 2 #define CLIP_MASK 0xfc @@ -548,6 +523,27 @@ static inline css_error set_list_style_image( #undef LIST_STYLE_IMAGE_SHIFT #undef LIST_STYLE_IMAGE_INDEX +#define QUOTES_INDEX 5 +#define QUOTES_SHIFT 0 +#define QUOTES_MASK 0x1 +static inline css_error set_quotes( + css_computed_style *style, uint8_t type, + lwc_string **quotes) +{ + uint8_t *bits = &style->bits[QUOTES_INDEX]; + + /* 1bit: type */ + *bits = (*bits & ~QUOTES_MASK) | + ((type & 0x1) << QUOTES_SHIFT); + + style->quotes = quotes; + + return CSS_OK; +} +#undef QUOTES_MASK +#undef QUOTES_SHIFT +#undef QUOTES_INDEX + #define TOP_INDEX 6 #define TOP_SHIFT 2 #define TOP_MASK 0xfc diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat index 09f9ef0..dace3f7 100644 --- a/test/data/select/tests1.dat +++ b/test/data/select/tests1.dat @@ -60,7 +60,6 @@ padding-right: 0px padding-bottom: 0px padding-left: 0px position: static -quotes: none right: auto table-layout: auto text-decoration: none @@ -135,7 +134,6 @@ padding-right: 0px padding-bottom: 0px padding-left: 0px position: static -quotes: none right: auto table-layout: auto text-decoration: none @@ -210,7 +208,6 @@ padding-right: 0px padding-bottom: 0px padding-left: 0px position: static -quotes: none right: auto table-layout: auto text-decoration: none @@ -447,7 +444,6 @@ padding-right: 0px padding-bottom: 0px padding-left: 0px position: static -quotes: none right: auto table-layout: auto text-decoration: none diff --git a/test/dump_computed.h b/test/dump_computed.h index a9e2d88..8269b3a 100644 --- a/test/dump_computed.h +++ b/test/dump_computed.h @@ -1899,6 +1899,9 @@ static void dump_computed_style(const css_computed_style *style, char *buf, case CSS_QUOTES_NONE: wrote = snprintf(ptr, *len, "quotes: none\n"); break; + default: + wrote = 0; + break; } } ptr += wrote; -- cgit v1.2.3