summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 15:10:56 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 15:10:56 +0000
commit08d4a63ce511519ed61ddf1851de630464929bd7 (patch)
tree798b0f4d0b2e9755bcbd5dab7c579986dd0e738b
parent1235822bb3d22b0935a14a45e9e740fcab854eb4 (diff)
downloadlibcss-08d4a63ce511519ed61ddf1851de630464929bd7.tar.gz
libcss-08d4a63ce511519ed61ddf1851de630464929bd7.tar.bz2
Change the representation of any data that includes a css_string. They're now either embedded directly in the computed style object, or are comprised of an array of objects (rather than pointers to objects)
svn path=/trunk/libcss/; revision=6432
-rw-r--r--include/libcss/computed.h56
-rw-r--r--src/select/computed.c16
-rw-r--r--src/select/properties.c7
-rw-r--r--src/select/propset.h29
4 files changed, 44 insertions, 64 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index f47c523..2f7f9de 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -24,7 +24,7 @@ typedef struct css_computed_page {
} css_computed_page;
typedef struct css_computed_counter {
- const css_string *name;
+ css_string name;
int32_t value;
} css_computed_counter;
@@ -51,21 +51,22 @@ typedef struct css_computed_uncommon {
* --- ---
* 48 bits 40 bytes
*
- * Encode counter_increment and _reset as a NULL-terminated array of
- * name, value pairs.
+ * Encode counter_increment and _reset as an array of name, value pairs,
+ * terminated with a blank entry.
*
* counter_increment 1 sizeof(ptr)
* counter_reset 1 sizeof(ptr)
* --- ---
* 2 bits 2sizeof(ptr) bytes
*
- * Encode quotes as a NULL-terminated array of string pointers
+ * 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 a NULL-terminated array of string pointers
+ * Encode cursor uri(s) as an array of string objects, terminated with a
+ * blank entry.
*
* cursor 5 sizeof(ptr)
* --- ---
@@ -106,12 +107,12 @@ typedef struct css_computed_uncommon {
css_fixed word_spacing;
- css_computed_counter **counter_increment;
- css_computed_counter **counter_reset;
+ css_computed_counter *counter_increment;
+ css_computed_counter *counter_reset;
- const css_string **quotes;
+ css_string *quotes;
- const css_string **cursor;
+ css_string *cursor;
} css_computed_uncommon;
struct css_computed_style {
@@ -151,7 +152,7 @@ struct css_computed_style {
* Dimensions are encoded as a fixed point value + 4 bits of unit data
*
* background_color 2 4
- * background_image 1 sizeof(ptr)
+ * background_image 1 sizeof(css_string)
* background_position 1 + 2(4) 2(4)
* border_top_color 2 4
* border_right_color 2 4
@@ -169,7 +170,7 @@ struct css_computed_style {
* font_size 4 + 4 4
* height 2 + 4 4
* line_height 2 + 4 4
- * list_style_image 1 sizeof(ptr)
+ * list_style_image 1 sizeof(css_string)
* margin_top 2 + 4 4
* margin_right 2 + 4 4
* margin_bottom 2 + 4 4
@@ -187,20 +188,23 @@ struct css_computed_style {
* width 2 + 4 4
* z_index 2 4
* --- ---
- * 181 bits 140 + 2sizeof(ptr) bytes
+ * 181 bits 140 + 2sizeof(css_string) bytes
*
- * Encode font family as a NULL-terminated array of string pointers
+ * Encode font family as an array of string objects, terminated with a
+ * blank entry.
*
* font_family 1 sizeof(ptr)
* --- ---
* 1 bit sizeof(ptr)
*
* ___ ___
- * 265 bits 140 + 3sizeof(ptr) bytes
+ * 265 bits 140 + 2sizeof(css_string) +
+ * sizeof(ptr) bytes
*
- * 34 bytes 140 + 3sizeof(ptr) bytes
+ * 34 bytes 140 + 2sizeof(css_string) +
+ * sizeof(ptr) bytes
* ===================
- * 174 + 3sizeof(ptr) bytes
+ * 174 + 2sizeof(css_string) + sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -245,7 +249,7 @@ struct css_computed_style {
uint8_t unused[2];
css_color background_color;
- const css_string *background_image;
+ css_string background_image;
css_fixed background_position[2];
css_color border_color[4];
@@ -264,7 +268,7 @@ struct css_computed_style {
css_fixed line_height;
- const css_string *list_style_image;
+ css_string list_style_image;
css_fixed margin[4];
@@ -284,7 +288,7 @@ struct css_computed_style {
int32_t z_index;
- const css_string **font_family;
+ css_string *font_family;
css_computed_uncommon *uncommon;/**< Uncommon properties */
css_computed_aural *aural; /**< Aural properties */
@@ -468,7 +472,7 @@ static inline uint8_t css_computed_word_spacing(
#define COUNTER_INCREMENT_MASK 0x2
static inline uint8_t css_computed_counter_increment(
const css_computed_style *style,
- css_computed_counter ***counters)
+ css_computed_counter **counters)
{
if (style->uncommon != NULL) {
uint8_t bits = style->uncommon->bits[COUNTER_INCREMENT_INDEX];
@@ -492,7 +496,7 @@ static inline uint8_t css_computed_counter_increment(
#define COUNTER_RESET_MASK 0x1
static inline uint8_t css_computed_counter_reset(
const css_computed_style *style,
- css_computed_counter ***counters)
+ css_computed_counter **counters)
{
if (style->uncommon != NULL) {
uint8_t bits = style->uncommon->bits[COUNTER_RESET_INDEX];
@@ -516,7 +520,7 @@ static inline uint8_t css_computed_counter_reset(
#define CURSOR_MASK 0xf8
static inline uint8_t css_computed_cursor(
const css_computed_style *style,
- const css_string ***urls)
+ const css_string **urls)
{
if (style->uncommon != NULL) {
uint8_t bits = style->uncommon->bits[CURSOR_INDEX];
@@ -540,7 +544,7 @@ static inline uint8_t css_computed_cursor(
#define QUOTES_MASK 0x4
static inline uint8_t css_computed_quotes(
const css_computed_style *style,
- const css_string ***quotes)
+ const css_string **quotes)
{
if (style->uncommon != NULL) {
uint8_t bits = style->uncommon->bits[QUOTES_INDEX];
@@ -768,7 +772,7 @@ static inline uint8_t css_computed_background_image(
bits >>= BACKGROUND_IMAGE_SHIFT;
/* 1bit: type */
- *url = style->background_image;
+ *url = &style->background_image;
return bits;
}
@@ -808,7 +812,7 @@ static inline uint8_t css_computed_list_style_image(
bits >>= LIST_STYLE_IMAGE_SHIFT;
/* 1bit: type */
- *url = style->list_style_image;
+ *url = &style->list_style_image;
return bits;
}
@@ -821,7 +825,7 @@ static inline uint8_t css_computed_list_style_image(
#define FONT_FAMILY_MASK 0x1
static inline uint8_t css_computed_font_family(
const css_computed_style *style,
- const css_string ***names)
+ const css_string **names)
{
uint8_t bits = style->bits[FONT_FAMILY_INDEX];
bits &= FONT_FAMILY_MASK;
diff --git a/src/select/computed.c b/src/select/computed.c
index a12e10f..cb7e173 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -53,27 +53,11 @@ css_error css_computed_style_destroy(css_computed_style *style)
if (style->uncommon != NULL) {
if (style->uncommon->counter_increment != NULL) {
- css_computed_counter **c =
- style->uncommon->counter_increment;
-
- while (*c != NULL) {
- style->alloc(*c, 0, style->pw);
- c++;
- }
-
style->alloc(style->uncommon->counter_increment, 0,
style->pw);
}
if (style->uncommon->counter_reset != NULL) {
- css_computed_counter **c =
- style->uncommon->counter_reset;
-
- while (*c != NULL) {
- style->alloc(*c, 0, style->pw);
- c++;
- }
-
style->alloc(style->uncommon->counter_reset, 0,
style->pw);
}
diff --git a/src/select/properties.c b/src/select/properties.c
index cc3fda3..21ef8b5 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -11,7 +11,7 @@ static css_error cascade_bg_border_color(uint32_t opv, css_style *style,
static css_error cascade_uri_none(uint32_t opv, css_style *style,
css_select_state *state,
css_error (*fun)(css_computed_style *, uint8_t,
- const css_string *));
+ const parserutils_hash_entry *));
static css_error cascade_border_style(uint32_t opv, css_style *style,
css_select_state *state,
css_error (*fun)(css_computed_style *, uint8_t));
@@ -2457,7 +2457,7 @@ css_error cascade_bg_border_color(uint32_t opv, css_style *style,
css_error cascade_uri_none(uint32_t opv, css_style *style,
css_select_state *state,
css_error (*fun)(css_computed_style *, uint8_t,
- const css_string *))
+ const parserutils_hash_entry *))
{
uint16_t value = CSS_BACKGROUND_IMAGE_INHERIT;
parserutils_hash_entry *uri = NULL;
@@ -2478,8 +2478,7 @@ css_error cascade_uri_none(uint32_t opv, css_style *style,
/** \todo lose fun != NULL once all properties have set routines */
if (fun != NULL && outranks_existing(getOpcode(opv),
isImportant(opv), state)) {
- /** \todo fix this mess -- it's seriously unsafe */
- return fun(state->result, value, (css_string *) uri);
+ return fun(state->result, value, uri);
}
return CSS_OK;
diff --git a/src/select/propset.h b/src/select/propset.h
index 7f397d7..c60d7e5 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -169,7 +169,7 @@ static inline css_error set_word_spacing(
#define COUNTER_INCREMENT_MASK 0x2
static inline css_error set_counter_increment(
css_computed_style *style, uint8_t type,
- css_computed_counter **counters)
+ css_computed_counter *counters)
{
uint8_t *bits;
@@ -181,8 +181,6 @@ static inline css_error set_counter_increment(
*bits = (*bits & ~COUNTER_INCREMENT_MASK) |
((type & 0x1) << COUNTER_INCREMENT_SHIFT);
- /** \todo Is this remotely sane? Would it be better to have this
- * function append entries to the array, instead? */
style->uncommon->counter_increment = counters;
return CSS_OK;
@@ -196,7 +194,7 @@ static inline css_error set_counter_increment(
#define COUNTER_RESET_MASK 0x1
static inline css_error set_counter_reset(
css_computed_style *style, uint8_t type,
- css_computed_counter **counters)
+ css_computed_counter *counters)
{
uint8_t *bits;
@@ -208,8 +206,6 @@ static inline css_error set_counter_reset(
*bits = (*bits & ~COUNTER_RESET_MASK) |
((type & 0x1) << COUNTER_RESET_SHIFT);
- /** \todo Is this remotely sane? Would it be better to have this
- * function append entries to the array, instead? */
style->uncommon->counter_reset = counters;
return CSS_OK;
@@ -223,7 +219,7 @@ static inline css_error set_counter_reset(
#define CURSOR_MASK 0xf8
static inline css_error set_cursor(
css_computed_style *style, uint8_t type,
- const css_string **urls)
+ css_string *urls)
{
uint8_t *bits;
@@ -235,8 +231,6 @@ static inline css_error set_cursor(
*bits = (*bits & ~CURSOR_MASK) |
((type & 0x1f) << CURSOR_SHIFT);
- /** \todo Is this remotely sane? Would it be better to have this
- * function append entries to the array, instead? */
style->uncommon->cursor = urls;
return CSS_OK;
@@ -250,7 +244,7 @@ static inline css_error set_cursor(
#define QUOTES_MASK 0x4
static inline css_error set_quotes(
css_computed_style *style, uint8_t type,
- const css_string **quotes)
+ css_string *quotes)
{
uint8_t *bits;
@@ -262,8 +256,6 @@ static inline css_error set_quotes(
*bits = (*bits & ~QUOTES_MASK) |
((type & 0x1) << QUOTES_SHIFT);
- /** \todo Is this remotely sane? Would it be better to have this
- * function append entries to the array, instead? */
style->uncommon->quotes = quotes;
return CSS_OK;
@@ -457,7 +449,7 @@ static inline css_error set_border_left_width(
#define BACKGROUND_IMAGE_MASK 0x1
static inline css_error set_background_image(
css_computed_style *style, uint8_t type,
- const css_string *url)
+ const parserutils_hash_entry *url)
{
uint8_t *bits = &style->bits[BACKGROUND_IMAGE_INDEX];
@@ -465,7 +457,8 @@ static inline css_error set_background_image(
*bits = (*bits & ~BACKGROUND_IMAGE_MASK) |
((type & 0x1) << BACKGROUND_IMAGE_SHIFT);
- style->background_image = url;
+ style->background_image.data = (uint8_t *) url->data;
+ style->background_image.len = url->len;
return CSS_OK;
}
@@ -499,7 +492,7 @@ static inline css_error set_color(
#define LIST_STYLE_IMAGE_MASK 0x1
static inline css_error set_list_style_image(
css_computed_style *style, uint8_t type,
- const css_string *url)
+ const parserutils_hash_entry *url)
{
uint8_t *bits = &style->bits[LIST_STYLE_IMAGE_INDEX];
@@ -507,7 +500,8 @@ static inline css_error set_list_style_image(
*bits = (*bits & ~LIST_STYLE_IMAGE_MASK) |
((type & 0x1) << LIST_STYLE_IMAGE_SHIFT);
- style->list_style_image = url;
+ style->list_style_image.data = (uint8_t *) url->data;
+ style->list_style_image.len = url->len;
return CSS_OK;
}
@@ -520,7 +514,7 @@ static inline css_error set_list_style_image(
#define FONT_FAMILY_MASK 0x1
static inline css_error set_font_family(
css_computed_style *style, uint8_t type,
- const css_string **names)
+ css_string *names)
{
uint8_t *bits = &style->bits[FONT_FAMILY_INDEX];
@@ -528,7 +522,6 @@ static inline css_error set_font_family(
*bits = (*bits & ~FONT_FAMILY_MASK) |
((type & 0x1) << FONT_FAMILY_SHIFT);
- /** \todo This probably wants to append to the array */
style->font_family = names;
return CSS_OK;