libcss: branch tlsa/shared-styles updated. release/0.5.0-11-g587abbb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/587abbb7775f4b7a7ba742...
...commit http://git.netsurf-browser.org/libcss.git/commit/587abbb7775f4b7a7ba742eb...
...tree http://git.netsurf-browser.org/libcss.git/tree/587abbb7775f4b7a7ba742ebe6...
The branch, tlsa/shared-styles has been updated
discards 97fe02b248e663ece83d03fbc463121ee7edbafb (commit)
discards ec111670d1a5bf076eea29a10f11cab649317f12 (commit)
discards 1f1e3dc135e4e0bd305b0214f3946a673640b5f9 (commit)
discards 5499be4bdc8a3242cd7ca8290e57860693eba5c6 (commit)
discards 5d6539ae25350459cd54aa8af3748ea29c1a4a1c (commit)
via 587abbb7775f4b7a7ba742ebe6522daa84de1d4c (commit)
via 5d0585d07a6b0e5c1a4c172f1554eccd5e6a0091 (commit)
via 2dd3b25490eecf7896263619d626d19c9bdf80b2 (commit)
via 4e58c29cd29a49184dd8bd505baa60b277b427fe (commit)
via cfeb4560892e0814eb969f33032733b918ad7a44 (commit)
via 6d145cf69c139c1cc369966f3b256026a995f7c3 (commit)
via dc9547360c5dabc82cc2893048e9cda8020dbaa7 (commit)
via 120ed97a5e2d808931537a8075f5ce4275586042 (commit)
via 316e60ef9801031e70611a3d111916c2aea88de8 (commit)
via 8b9470af9d5237f425e6a00e1253f04990de3aa9 (commit)
via 9a3112f46fcfce9952134fa230b5879ac33b8e3c (commit)
via 2294f5adfd40bb3a778dad1d6e335f733f845404 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (97fe02b248e663ece83d03fbc463121ee7edbafb)
\
N -- N -- N (587abbb7775f4b7a7ba742ebe6522daa84de1d4c)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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=587abbb7775f4b7a7ba7...
commit 587abbb7775f4b7a7ba742ebe6522daa84de1d4c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Change how presentational hints are handled.
Previously, we performed normal selection from CSS sources, and then iterated
over all the properties in the populated computed style. If the properties were
unset or their values were not from either a UA stylesheet or user stylesheet
with !important set, then we asked the client program (e.g. NetSurf) if there
were any presentational hints for that node, for each such property.
In the worst case this triggered N_PROPERTIES * N_NODES calls back to the client
program, even for properties that can't be set via HTML attributes.
The new API asks the client to supply a list of all the presentational hints
that apply to the given node. For most nodes on modern documents, this is 0.
Any presentational hints are applied before selection from CSS sources.
diff --git a/include/libcss/hint.h b/include/libcss/hint.h
index c3e928d..629d2f6 100644
--- a/include/libcss/hint.h
+++ b/include/libcss/hint.h
@@ -49,7 +49,8 @@ typedef struct css_hint {
lwc_string **strings;
} data;
- uint8_t status;
+ uint32_t prop; /**< Property index */
+ uint8_t status; /**< Property value */
} css_hint;
#ifdef __cplusplus
diff --git a/include/libcss/select.h b/include/libcss/select.h
index d504e81..bd2fed2 100644
--- a/include/libcss/select.h
+++ b/include/libcss/select.h
@@ -117,8 +117,8 @@ typedef struct css_select_handler {
css_error (*node_is_lang)(void *pw, void *node,
lwc_string *lang, bool *match);
- css_error (*node_presentational_hint)(void *pw, void *node,
- uint32_t property, css_hint *hint);
+ css_error (*node_presentational_hint)(void *pw, void *node,
+ uint32_t *nhints, css_hint **hints);
css_error (*ua_default_for_property)(void *pw, uint32_t property,
css_hint *hint);
diff --git a/src/select/select.c b/src/select/select.c
index d484cc8..6c20b60 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -110,7 +110,7 @@ typedef struct css_select_rule_source {
} css_select_rule_source;
-static css_error set_hint(css_select_state *state, uint32_t prop);
+static css_error set_hint(css_select_state *state, css_hint *hint);
static css_error set_initial(css_select_state *state,
uint32_t prop, css_pseudo_element pseudo,
void *parent);
@@ -433,10 +433,11 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
css_select_handler *handler, void *pw,
css_select_results **result)
{
- uint32_t i, j;
+ uint32_t i, j, nhints;
css_error error;
css_select_state state;
void *parent = NULL;
+ css_hint *hints = NULL;
css_bloom *bloom = NULL;
css_bloom *parent_bloom = NULL;
@@ -536,6 +537,29 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
if (error != CSS_OK)
goto cleanup;
+ /* Apply presentational hints */
+ error = handler->node_presentational_hint(pw, node, &nhints, &hints);
+ if (error != CSS_OK)
+ goto cleanup;
+ if (nhints > 0) {
+ /* Ensure that the appropriate computed style exists */
+ struct css_computed_style *computed_style =
+ state.results->styles[CSS_PSEUDO_ELEMENT_NONE];
+ if (computed_style == NULL) {
+ error = css_computed_style_create(&computed_style);
+ if (error != CSS_OK)
+ return error;
+ }
+ state.results->styles[CSS_PSEUDO_ELEMENT_NONE] = computed_style;
+ state.computed = computed_style;
+
+ for (i = 0; i < nhints; i++) {
+ error = set_hint(&state, &hints[i]);
+ if (error != CSS_OK)
+ goto cleanup;
+ }
+ }
+
/* Iterate through the top-level stylesheets, selecting styles
* from those which apply to our current media requirements and
* are not disabled */
@@ -577,8 +601,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
}
}
- /* Take account of presentational hints and fix up any remaining
- * unset properties. */
+ /* Fix up any remaining unset properties. */
/* Base element */
state.current_pseudo = CSS_PSEUDO_ELEMENT_NONE;
@@ -587,17 +610,6 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
const prop_state *prop =
&state.props[i][CSS_PSEUDO_ELEMENT_NONE];
- /* Apply presentational hints if the property is unset or
- * the existing property value did not come from an author
- * stylesheet or a user sheet using !important. */
- if (prop->set == false ||
- (prop->origin != CSS_ORIGIN_AUTHOR &&
- prop->important == false)) {
- error = set_hint(&state, i);
- if (error != CSS_OK)
- goto cleanup;
- }
-
/* If the property is still unset or it's set to inherit
* and we're the root element, then set it to its initial
* value. */
@@ -1118,32 +1130,23 @@ void destroy_strings(css_select_ctx *ctx)
lwc_string_unref(ctx->after);
}
-css_error set_hint(css_select_state *state, uint32_t prop)
+css_error set_hint(css_select_state *state, css_hint *hint)
{
- css_hint hint;
+ uint32_t prop = hint->prop;
+ prop_state *existing = &state->props[prop][CSS_PSEUDO_ELEMENT_NONE];
css_error error;
- /* Initialise hint */
- memset(&hint, 0, sizeof(css_hint));
-
- /* Retrieve this property's hint from the client */
- error = state->handler->node_presentational_hint(state->pw,
- state->node, prop, &hint);
- if (error != CSS_OK)
- return (error == CSS_PROPERTY_NOT_SET) ? CSS_OK : error;
-
/* Hint defined -- set it in the result */
- error = prop_dispatch[prop].set_from_hint(&hint, state->computed);
+ error = prop_dispatch[prop].set_from_hint(hint, state->computed);
if (error != CSS_OK)
return error;
/* Keep selection state in sync with reality */
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].set = 1;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].specificity = 0;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].origin = CSS_ORIGIN_AUTHOR;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].important = 0;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].inherit =
- (hint.status == 0);
+ existing->set = 1;
+ existing->specificity = 0;
+ existing->origin = CSS_ORIGIN_AUTHOR;
+ existing->important = 0;
+ existing->inherit = (hint->status == 0);
return CSS_OK;
}
diff --git a/test/select-common.c b/test/select-common.c
index 42cdb76..c6d33c0 100644
--- a/test/select-common.c
+++ b/test/select-common.c
@@ -156,9 +156,9 @@ static css_error node_is_target(void *pw, void *node, bool *match);
static css_error node_is_lang(void *pw, void *node,
lwc_string *lang, bool *match);
static css_error node_presentational_hint(void *pw, void *node,
- uint32_t property, css_hint *hint);
+ uint32_t *nhints, css_hint **hints);
static css_error ua_default_for_property(void *pw, uint32_t property,
- css_hint *hint);
+ css_hint *hints);
static css_error compute_font_size(void *pw, const css_hint *parent,
css_hint *size);
static css_error set_libcss_node_data(void *pw, void *n,
@@ -1566,14 +1566,15 @@ css_error node_is_lang(void *pw, void *n,
}
css_error node_presentational_hint(void *pw, void *node,
- uint32_t property, css_hint *hint)
+ uint32_t *nhints, css_hint **hints)
{
UNUSED(pw);
UNUSED(node);
- UNUSED(property);
- UNUSED(hint);
- return CSS_PROPERTY_NOT_SET;
+ *nhints = 0;
+ *hints = NULL;
+
+ return CSS_OK;
}
css_error ua_default_for_property(void *pw, uint32_t property, css_hint *hint)
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=5d0585d07a6b0e5c1a4c...
commit 5d0585d07a6b0e5c1a4c172f1554eccd5e6a0091
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Change arena hash from FNV-1 to 32-bit MurmurHash2.
diff --git a/src/select/arena.c b/src/select/arena.c
index 8f5a319..1b0ea57 100644
--- a/src/select/arena.c
+++ b/src/select/arena.c
@@ -9,6 +9,7 @@
#include <string.h>
#include "select/arena.h"
+#include "select/arena_hash.h"
#include "select/computed.h"
#define TU_SIZE 3037
@@ -18,23 +19,6 @@ struct css_computed_uncommon *table_u[TU_SIZE];
struct css_computed_style *table_s[TS_SIZE];
-/**
- * FNV-1 hash
- */
-static inline uint32_t css__arena_hash(const uint8_t *data, size_t len)
-{
- lwc_hash h = 0x811c9dc5;
-
- while (len > 0) {
- h *= 0x01000193;
- h ^= *data++;
- len--;
- }
-
- return h;
-}
-
-
static inline uint32_t css__arena_hash_uncommon(struct css_computed_uncommon *u)
{
return css__arena_hash((const uint8_t *) &u->i, sizeof(u->i));
diff --git a/src/select/arena_hash.h b/src/select/arena_hash.h
new file mode 100644
index 0000000..58abcd4
--- /dev/null
+++ b/src/select/arena_hash.h
@@ -0,0 +1,67 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#ifndef css_select_arena_hash_h_
+#define css_select_arena_hash_h_
+
+#include <stdint.h>
+
+/**
+ * Currently 32-bit MurmurHash2.
+ *
+ * Created by Austin Appleby, and placed in the public domain.
+ * https://sites.google.com/site/murmurhash/
+ *
+ * Refactored and adapted a little for libcss.
+ */
+static inline uint32_t css__arena_hash(const uint8_t *data, size_t len)
+{
+ /* Hashing constants */
+ const uint32_t m = 0x5bd1e995;
+ const int r = 24;
+
+ /* Start with length */
+ uint32_t h = len;
+
+ /* Hash four bytes at a time */
+ while (len >= 4) {
+ /* If we could ensure 4-byte alignment of the input, this
+ * could be faster. */
+ uint32_t k =
+ (((uint32_t) data[0]) ) |
+ (((uint32_t) data[1]) << 8) |
+ (((uint32_t) data[2]) << 16) |
+ (((uint32_t) data[3]) << 24);
+
+ k *= m;
+ k ^= k >> r;
+ k *= m;
+ h *= m;
+ h ^= k;
+ data += 4;
+ len -= 4;
+ }
+
+ /* Hash any left over bytes */
+ switch (len) {
+ case 3: h ^= data[2] << 16;
+ case 2: h ^= data[1] << 8;
+ case 1: h ^= data[0];
+ h *= m;
+ }
+
+ /* Finalise */
+ h ^= h >> 13;
+ h *= m;
+ h ^= h >> 15;
+
+ return h;
+}
+
+#endif
+
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=2dd3b25490eecf789626...
commit 2dd3b25490eecf7896263619d626d19c9bdf80b2
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
After composing styles, intern the result in the style sharing arena.
Note this changes the API.
Selection tests updated.
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index 233265c..f8f3391 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -83,12 +83,12 @@ css_error css_computed_style_initialise(css_computed_style *style,
struct css_select_handler *handler, void *pw);
css_error css_computed_style_compose(const css_computed_style *parent,
- const css_computed_style *child,
+ css_computed_style *child,
css_error (*compute_font_size)(void *pw,
const struct css_hint *parent,
struct css_hint *size),
void *pw,
- css_computed_style *result);
+ css_computed_style **result);
/******************************************************************************
* Property accessors below here *
diff --git a/src/select/computed.c b/src/select/computed.c
index 817da31..182a7e7 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -7,6 +7,7 @@
#include <string.h>
+#include "select/arena.h"
#include "select/computed.h"
#include "select/dispatch.h"
#include "select/propget.h"
@@ -92,6 +93,13 @@ css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon)
if (uncommon == NULL)
return CSS_BADPARM;
+ if (uncommon->count > 1) {
+ uncommon->count--;
+ return CSS_OK;
+
+ } else if (uncommon->count == 1) {
+ css__arena_remove_uncommon_style(uncommon);
+ }
if (uncommon != NULL) {
if (uncommon->counter_increment != NULL) {
@@ -176,6 +184,13 @@ css_error css_computed_style_destroy(css_computed_style *style)
css__computed_uncommon_destroy(style->i.uncommon);
+ if (style->count > 1) {
+ style->count--;
+ return CSS_OK;
+
+ } else if (style->count == 1) {
+ css__arena_remove_style(style);
+ }
if (style->page != NULL) {
free(style->page);
@@ -270,11 +285,11 @@ css_error css_computed_style_initialise(css_computed_style *style,
* \note \a child and \a result may point at the same object
*/
css_error css_computed_style_compose(const css_computed_style *parent,
- const css_computed_style *child,
+ css_computed_style *child,
css_error (*compute_font_size)(void *pw,
const css_hint *parent, css_hint *size),
void *pw,
- css_computed_style *result)
+ css_computed_style **result)
{
css_error error = CSS_OK;
size_t i;
@@ -297,13 +312,19 @@ css_error css_computed_style_compose(const css_computed_style *parent,
continue;
/* Compose the property */
- error = prop_dispatch[i].compose(parent, child, result);
+ error = prop_dispatch[i].compose(parent, child, *result);
if (error != CSS_OK)
break;
}
/* Finally, compute absolute values for everything */
- return css__compute_absolute_values(parent, result, compute_font_size, pw);
+ error = css__compute_absolute_values(parent, *result,
+ compute_font_size, pw);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ return css__arena_intern_style(result);
}
/******************************************************************************
diff --git a/test/select-common.c b/test/select-common.c
index f1762a6..42cdb76 100644
--- a/test/select-common.c
+++ b/test/select-common.c
@@ -773,7 +773,7 @@ static void run_test_select_tree(css_select_ctx *select,
node->parent->sr->styles[ctx->pseudo_element],
sr->styles[ctx->pseudo_element],
compute_font_size, NULL,
- sr->styles[ctx->pseudo_element]) == CSS_OK);
+ &(sr->styles[ctx->pseudo_element])) == CSS_OK);
}
node->sr = sr;
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=4e58c29cd29a49184dd8...
commit 4e58c29cd29a49184dd8bd505baa60b277b427fe
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add arena module for interning computed styles.
Builds, but currently unused.
diff --git a/src/select/Makefile b/src/select/Makefile
index eb89c1f..e937191 100644
--- a/src/select/Makefile
+++ b/src/select/Makefile
@@ -1,4 +1,4 @@
# Sources
-DIR_SOURCES := computed.c dispatch.c hash.c select.c font_face.c
+DIR_SOURCES := arena.c computed.c dispatch.c hash.c select.c font_face.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/select/arena.c b/src/select/arena.c
new file mode 100644
index 0000000..8f5a319
--- /dev/null
+++ b/src/select/arena.c
@@ -0,0 +1,377 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <string.h>
+
+#include "select/arena.h"
+#include "select/computed.h"
+
+#define TU_SIZE 3037
+#define TS_SIZE 5101
+
+struct css_computed_uncommon *table_u[TU_SIZE];
+struct css_computed_style *table_s[TS_SIZE];
+
+
+/**
+ * FNV-1 hash
+ */
+static inline uint32_t css__arena_hash(const uint8_t *data, size_t len)
+{
+ lwc_hash h = 0x811c9dc5;
+
+ while (len > 0) {
+ h *= 0x01000193;
+ h ^= *data++;
+ len--;
+ }
+
+ return h;
+}
+
+
+static inline uint32_t css__arena_hash_uncommon(struct css_computed_uncommon *u)
+{
+ return css__arena_hash((const uint8_t *) &u->i, sizeof(u->i));
+}
+
+
+static inline uint32_t css__arena_hash_style(struct css_computed_style *s)
+{
+ return css__arena_hash((const uint8_t *) &s->i, sizeof(s->i));
+}
+
+
+static inline bool arena__compare_computed_page(
+ const struct css_computed_page *a,
+ const struct css_computed_page *b)
+{
+ if (a == NULL && b == NULL) {
+ return true;
+
+ } else if (a == NULL || b == NULL) {
+ return false;
+ }
+
+ return memcmp(a, b, sizeof(struct css_computed_page)) == 0;
+}
+
+
+static inline bool arena__compare_computed_content_item(
+ const struct css_computed_content_item *a,
+ const struct css_computed_content_item *b)
+{
+ if (a == NULL && b == NULL) {
+ return true;
+
+ } else if (a == NULL || b == NULL) {
+ return false;
+ }
+
+ if (a->type != b->type) {
+ return false;
+ }
+
+ return memcmp(a, b, sizeof(struct css_computed_content_item)) == 0;
+}
+
+
+static inline bool arena__compare_css_computed_counter(
+ const struct css_computed_counter *a,
+ const struct css_computed_counter *b)
+{
+ bool match;
+
+ if (a == NULL && b == NULL) {
+ return true;
+
+ } else if (a == NULL || b == NULL) {
+ return false;
+ }
+
+ if (a->value == b->value &&
+ lwc_string_isequal(a->name, b->name,
+ &match) == lwc_error_ok &&
+ match == true) {
+ return true;
+ }
+
+ return false;
+}
+
+static inline bool arena__compare_string_list(
+ lwc_string **a,
+ lwc_string **b)
+{
+ if (a == NULL && b == NULL) {
+ return true;
+
+ } else if (a == NULL || b == NULL) {
+ return false;
+ }
+
+ while (*a != NULL && *b != NULL) {
+ bool match;
+
+ if (lwc_string_isequal(*a, *b, &match) != lwc_error_ok ||
+ match == false) {
+ return false;
+ }
+
+ a++;
+ b++;
+ }
+
+ if (*a != *b) {
+ return false;
+ }
+
+ return true;
+}
+
+
+static inline bool css__arena_uncommon_is_equal(
+ struct css_computed_uncommon *a,
+ struct css_computed_uncommon *b)
+{
+ if (memcmp(&a->i, &b->i, sizeof(struct css_computed_uncommon_i)) != 0) {
+ return false;
+ }
+
+ if (!arena__compare_css_computed_counter(
+ a->counter_increment,
+ b->counter_increment)) {
+ return false;
+ }
+
+ if (!arena__compare_css_computed_counter(
+ a->counter_reset,
+ b->counter_reset)) {
+ return false;
+ }
+
+ if (!arena__compare_computed_content_item(
+ a->content,
+ b->content)) {
+ return false;
+ }
+
+ if (!arena__compare_string_list(
+ a->cursor,
+ b->cursor)) {
+ return false;
+ }
+
+ return true;
+}
+
+
+static inline bool css__arena_style_is_equal(
+ struct css_computed_style *a,
+ struct css_computed_style *b)
+{
+ if (memcmp(&a->i, &b->i, sizeof(struct css_computed_style_i)) != 0) {
+ return false;
+ }
+
+ if (!arena__compare_string_list(
+ a->font_family,
+ b->font_family)) {
+ return false;
+ }
+
+ if (!arena__compare_string_list(
+ a->quotes,
+ b->quotes)) {
+ return false;
+ }
+
+ if (!arena__compare_computed_page(
+ a->page,
+ b->page)) {
+ return false;
+ }
+
+ return true;
+}
+
+
+static void css__arena_intern_uncommon(
+ struct css_computed_uncommon **uncommon)
+{
+ struct css_computed_uncommon *u = *uncommon;
+ uint32_t hash, index;
+
+ /* Need to intern the uncommon block */
+ hash = css__arena_hash_uncommon(u);
+ index = hash % TU_SIZE;
+ u->bin = index;
+
+ if (table_u[index] == NULL) {
+ /* Can just insert */
+ table_u[index] = u;
+ u->count = 1;
+ } else {
+ /* Check for existing */
+ struct css_computed_uncommon *l = table_u[index];
+ struct css_computed_uncommon *existing = NULL;
+
+ do {
+ if (css__arena_uncommon_is_equal(l, u)) {
+ existing = l;
+ break;
+ }
+ l = l->next;
+ } while (l != NULL);
+
+ if (existing != NULL) {
+ css__computed_uncommon_destroy(u);
+ existing->count++;
+ *uncommon = existing;
+ } else {
+ /* Add to list */
+ u->next = table_u[index];
+ table_u[index] = u;
+ u->count = 1;
+ }
+ }
+}
+
+
+/* Internally exported function, documented in src/select/arena.h */
+css_error css__arena_intern_style(struct css_computed_style **style)
+{
+ struct css_computed_style *s = *style;
+ uint32_t hash, index;
+
+ if (s->count != 0) {
+ return CSS_BADPARM;
+ }
+
+ if (s->i.uncommon != NULL) {
+ if (s->i.uncommon->count != 0) {
+ return CSS_BADPARM;
+ }
+ css__arena_intern_uncommon(&s->i.uncommon);
+ }
+
+ /* Need to intern the style block */
+ hash = css__arena_hash_style(s);
+ index = hash % TS_SIZE;
+ s->bin = index;
+
+ if (table_s[index] == NULL) {
+ /* Can just insert */
+ table_s[index] = s;
+ s->count = 1;
+ } else {
+ /* Check for existing */
+ struct css_computed_style *l = table_s[index];
+ struct css_computed_style *existing = NULL;
+
+ do {
+ if (css__arena_style_is_equal(l, s)) {
+ existing = l;
+ break;
+ }
+ l = l->next;
+ } while (l != NULL);
+
+ if (existing != NULL) {
+ s->i.uncommon = NULL;
+ css_computed_style_destroy(s);
+ existing->count++;
+ *style = existing;
+ } else {
+ /* Add to list */
+ s->next = table_s[index];
+ table_s[index] = s;
+ s->count = 1;
+ }
+ }
+
+ return CSS_OK;
+}
+
+
+/* Internally exported function, documented in src/select/arena.h */
+enum css_error css__arena_remove_style(struct css_computed_style *style)
+{
+ uint32_t index = style->bin;
+
+ if (table_s[index] == NULL) {
+ return CSS_BADPARM;
+
+ } else {
+ /* Check for existing */
+ struct css_computed_style *l = table_s[index];
+ struct css_computed_style *existing = NULL;
+ struct css_computed_style *prev = NULL;
+
+ do {
+ if (css__arena_style_is_equal(l, style)) {
+ existing = l;
+ break;
+ }
+ prev = l;
+ l = l->next;
+ } while (l != NULL);
+
+ if (existing != NULL) {
+ if (prev != NULL) {
+ prev->next = existing->next;
+ } else {
+ table_s[index] = existing->next;
+ }
+ } else {
+ return CSS_BADPARM;
+ }
+ }
+
+ return CSS_OK;
+}
+
+
+/* Internally exported function, documented in src/select/arena.h */
+enum css_error css__arena_remove_uncommon_style(
+ struct css_computed_uncommon *uncommon)
+{
+ uint32_t index = uncommon->bin;
+
+ if (table_u[index] == NULL) {
+ return CSS_BADPARM;
+
+ } else {
+ /* Check for existing */
+ struct css_computed_uncommon *l = table_u[index];
+ struct css_computed_uncommon *existing = NULL;
+ struct css_computed_uncommon *prev = NULL;
+
+ do {
+ if (css__arena_uncommon_is_equal(l, uncommon)) {
+ existing = l;
+ break;
+ }
+ prev = l;
+ l = l->next;
+ } while (l != NULL);
+
+ if (existing != NULL) {
+ if (prev != NULL) {
+ prev->next = existing->next;
+ } else {
+ table_u[index] = existing->next;
+ }
+ } else {
+ return CSS_BADPARM;
+ }
+ }
+
+ return CSS_OK;
+}
+
diff --git a/src/select/arena.h b/src/select/arena.h
new file mode 100644
index 0000000..af06050
--- /dev/null
+++ b/src/select/arena.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#ifndef css_select_arena_h_
+#define css_select_arena_h_
+
+struct css_computed_style;
+struct css_computed_uncommon;
+
+/*
+ * Add computed style to the style sharing arena, or exchange for existing
+ *
+ * This takes a computed style. Note that the original computed style
+ * may be freed by this call and all future usage should be via the
+ * updated computed style parameter.
+ *
+ * \params style The style to intern; possibly freed and updated
+ * \return CSS_OK on success or appropriate error otherwise.
+ */
+enum css_error css__arena_intern_style(struct css_computed_style **style);
+
+/*
+ * Remove a computed style from the style sharing arena
+ *
+ * \params style The style to remove from the style sharing arena
+ * \return CSS_OK on success or appropriate error otherwise.
+ */
+enum css_error css__arena_remove_style(struct css_computed_style *style);
+
+/*
+ * Remove a computed style's uncommon block from the style sharing arena
+ *
+ * \params uncommon The uncommon style to remove from the style sharing arena
+ * \return CSS_OK on success or appropriate error otherwise.
+ */
+enum css_error css__arena_remove_uncommon_style(
+ struct css_computed_uncommon *uncommon);
+
+#endif
+
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=cfeb4560892e0814eb96...
commit cfeb4560892e0814eb969f33032733b918ad7a44
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Ensure computed content items are initialised to zero.
This allows comparing them with memcmp.
diff --git a/src/select/properties/content.c b/src/select/properties/content.c
index a9dd211..472a66a 100644
--- a/src/select/properties/content.c
+++ b/src/select/properties/content.c
@@ -49,6 +49,7 @@ css_error css__cascade_content(uint32_t opv, css_style *style,
}
content = temp;
+ memset(content + n_contents, 0, sizeof(css_computed_content_item));
switch (v & 0xff) {
case CONTENT_COUNTER:
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=6d145cf69c139c1cc369...
commit 6d145cf69c139c1cc369966f3b256026a995f7c3
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Move trivially compared parts of computed styles to sub-structures.
diff --git a/src/select/computed.c b/src/select/computed.c
index dc632f9..817da31 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -75,59 +75,61 @@ css_error css_computed_style_create(css_computed_style **result)
if (s == NULL)
return CSS_NOMEM;
+ s->bin = UINT32_MAX;
*result = s;
return CSS_OK;
}
/**
- * Destroy a computed style
+ * Destroy an uncommon computed style section
*
* \param style Style to destroy
* \return CSS_OK on success, appropriate error otherwise
*/
-css_error css_computed_style_destroy(css_computed_style *style)
+css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon)
{
- if (style == NULL)
+ if (uncommon == NULL)
return CSS_BADPARM;
- if (style->uncommon != NULL) {
- if (style->uncommon->counter_increment != NULL) {
+
+ if (uncommon != NULL) {
+ if (uncommon->counter_increment != NULL) {
css_computed_counter *c;
- for (c = style->uncommon->counter_increment;
+ for (c = uncommon->counter_increment;
c->name != NULL; c++) {
lwc_string_unref(c->name);
}
- free(style->uncommon->counter_increment);
+ free(uncommon->counter_increment);
}
- if (style->uncommon->counter_reset != NULL) {
+ if (uncommon->counter_reset != NULL) {
css_computed_counter *c;
- for (c = style->uncommon->counter_reset;
+ for (c = uncommon->counter_reset;
c->name != NULL; c++) {
lwc_string_unref(c->name);
}
- free(style->uncommon->counter_reset);
+ free(uncommon->counter_reset);
}
- if (style->uncommon->cursor != NULL) {
+ if (uncommon->cursor != NULL) {
lwc_string **s;
- for (s = style->uncommon->cursor; *s != NULL; s++) {
+ for (s = uncommon->cursor; *s != NULL; s++) {
lwc_string_unref(*s);
}
- free(style->uncommon->cursor);
+ free(uncommon->cursor);
}
- if (style->uncommon->content != NULL) {
+ if (uncommon->content != NULL) {
css_computed_content_item *c;
- for (c = style->uncommon->content;
+ for (c = uncommon->content;
c->type != CSS_COMPUTED_CONTENT_NONE;
c++) {
switch (c->type) {
@@ -152,18 +154,35 @@ css_error css_computed_style_destroy(css_computed_style *style)
}
}
- free(style->uncommon->content);
+ free(uncommon->content);
}
- free(style->uncommon);
+ free(uncommon);
}
+ return CSS_OK;
+}
+
+/**
+ * Destroy a computed style
+ *
+ * \param style Style to destroy
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_computed_style_destroy(css_computed_style *style)
+{
+ if (style == NULL)
+ return CSS_BADPARM;
+
+ css__computed_uncommon_destroy(style->i.uncommon);
+
+
if (style->page != NULL) {
free(style->page);
}
- if (style->aural != NULL) {
- free(style->aural);
+ if (style->i.aural != NULL) {
+ free(style->i.aural);
}
if (style->font_family != NULL) {
@@ -186,11 +205,11 @@ css_error css_computed_style_destroy(css_computed_style *style)
free(style->quotes);
}
- if (style->list_style_image != NULL)
- lwc_string_unref(style->list_style_image);
+ if (style->i.list_style_image != NULL)
+ lwc_string_unref(style->i.list_style_image);
- if (style->background_image != NULL)
- lwc_string_unref(style->background_image);
+ if (style->i.background_image != NULL)
+ lwc_string_unref(style->i.background_image);
free(style);
@@ -264,8 +283,8 @@ css_error css_computed_style_compose(const css_computed_style *parent,
for (i = 0; i < CSS_N_PROPERTIES; i++) {
/* Skip any in extension blocks if the block does not exist */
if (prop_dispatch[i].group == GROUP_UNCOMMON &&
- parent->uncommon == NULL &&
- child->uncommon == NULL)
+ parent->i.uncommon == NULL &&
+ child->i.uncommon == NULL)
continue;
if (prop_dispatch[i].group == GROUP_PAGE &&
@@ -273,7 +292,8 @@ css_error css_computed_style_compose(const css_computed_style *parent,
continue;
if (prop_dispatch[i].group == GROUP_AURAL &&
- parent->aural == NULL && child->aural == NULL)
+ parent->i.aural == NULL &&
+ child->i.aural == NULL)
continue;
/* Compose the property */
@@ -444,7 +464,7 @@ uint8_t css_computed_top(const css_computed_style *style,
*unit = CSS_UNIT_PX;
} else if (top == CSS_TOP_AUTO) {
/* Top is auto => -bottom */
- *length = -style->bottom;
+ *length = -style->i.bottom;
*unit = (css_unit) (bottom >> 2);
}
@@ -474,7 +494,7 @@ uint8_t css_computed_right(const css_computed_style *style,
*unit = CSS_UNIT_PX;
} else if (right == CSS_RIGHT_AUTO) {
/* Right is auto => -left */
- *length = -style->left;
+ *length = -style->i.left;
*unit = (css_unit) (left >> 2);
} else {
/** \todo Consider containing block's direction
@@ -508,7 +528,7 @@ uint8_t css_computed_bottom(const css_computed_style *style,
} else if (bottom == CSS_BOTTOM_AUTO ||
(top & 0x3) != CSS_TOP_AUTO) {
/* Bottom is auto or top is not auto => -top */
- *length = -style->top;
+ *length = -style->i.top;
*unit = (css_unit) (top >> 2);
}
@@ -538,7 +558,7 @@ uint8_t css_computed_left(const css_computed_style *style,
*unit = CSS_UNIT_PX;
} else if (left == CSS_LEFT_AUTO) {
/* Left is auto => -right */
- *length = -style->right;
+ *length = -style->i.right;
*unit = (css_unit) (right >> 2);
} else {
/** \todo Consider containing block's direction
@@ -1144,7 +1164,7 @@ css_error css__compute_absolute_values(const css_computed_style *parent,
return error;
/* Uncommon properties */
- if (style->uncommon != NULL) {
+ if (style->i.uncommon != NULL) {
/* Fix up border-spacing */
error = compute_absolute_length_pair(style,
&ex_size.data.length,
diff --git a/src/select/computed.h b/src/select/computed.h
index 0ca01d9..f965993 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -13,7 +13,7 @@
-typedef struct css_computed_uncommon {
+struct css_computed_uncommon_i {
/*
* border_spacing 1 + 2(4) 2(4)
* break_before 4 0
@@ -99,13 +99,20 @@ typedef struct css_computed_uncommon {
css_color column_rule_color;
css_fixed column_rule_width;
css_fixed column_width;
+};
+
+typedef struct css_computed_uncommon {
+ struct css_computed_uncommon_i i;
css_computed_counter *counter_increment;
css_computed_counter *counter_reset;
- lwc_string **cursor;
-
css_computed_content_item *content;
+
+ lwc_string **cursor;
+ struct css_computed_uncommon *next;
+ uint32_t count;
+ uint32_t bin;
} css_computed_uncommon;
typedef struct css_computed_page {
@@ -122,7 +129,7 @@ typedef struct css_computed_page {
int32_t orphans;
} css_computed_page;
-struct css_computed_style {
+struct css_computed_style_i {
/*
* background_attachment 2
* background_repeat 3
@@ -302,15 +309,24 @@ struct css_computed_style {
int32_t z_index;
+ css_computed_uncommon *uncommon;/**< Uncommon properties */
+ void *aural; /**< Aural properties */
+};
+
+struct css_computed_style {
+ struct css_computed_style_i i;
+
lwc_string **font_family;
lwc_string **quotes;
-
- css_computed_uncommon *uncommon;/**< Uncommon properties */
- void *aural; /**< Aural properties */
css_computed_page *page; /**< Page properties */
+ struct css_computed_style *next;
+ uint32_t count;
+ uint32_t bin;
};
+css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon);
+
css_error css__compute_absolute_values(const css_computed_style *parent,
css_computed_style *style,
css_error (*compute_font_size)(void *pw,
diff --git a/src/select/properties/border_spacing.c b/src/select/properties/border_spacing.c
index 1b32747..db7b1f2 100644
--- a/src/select/properties/border_spacing.c
+++ b/src/select/properties/border_spacing.c
@@ -71,10 +71,10 @@ css_error css__compose_border_spacing(const css_computed_style *parent,
uint8_t type = get_border_spacing(child, &hlength, &hunit,
&vlength, &vunit);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_BORDER_SPACING_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_BORDER_SPACING_INHERIT) {
type = get_border_spacing(parent,
&hlength, &hunit, &vlength, &vunit);
diff --git a/src/select/properties/clip.c b/src/select/properties/clip.c
index d98c7eb..cc39d99 100644
--- a/src/select/properties/clip.c
+++ b/src/select/properties/clip.c
@@ -102,10 +102,10 @@ css_error css__compose_clip(const css_computed_style *parent,
false, false, false, false };
uint8_t type = get_clip(child, &rect);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_CLIP_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_CLIP_INHERIT) {
type = get_clip(parent, &rect);
}
diff --git a/src/select/properties/column_count.c b/src/select/properties/column_count.c
index 92fdec2..4ded377 100644
--- a/src/select/properties/column_count.c
+++ b/src/select/properties/column_count.c
@@ -59,10 +59,10 @@ css_error css__compose_column_count(const css_computed_style *parent,
int32_t count = 0;
uint8_t type = get_column_count(child, &count);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COLUMN_COUNT_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COLUMN_COUNT_INHERIT) {
type = get_column_count(parent, &count);
}
diff --git a/src/select/properties/column_gap.c b/src/select/properties/column_gap.c
index 641f529..f544f44 100644
--- a/src/select/properties/column_gap.c
+++ b/src/select/properties/column_gap.c
@@ -41,10 +41,10 @@ css_error css__compose_column_gap(const css_computed_style *parent,
css_unit unit = CSS_UNIT_EM;
uint8_t type = get_column_gap(child, &length, &unit);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COLUMN_GAP_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COLUMN_GAP_INHERIT) {
type = get_column_gap(parent, &length, &unit);
}
diff --git a/src/select/properties/column_width.c b/src/select/properties/column_width.c
index 45eb7fc..b6550ab 100644
--- a/src/select/properties/column_width.c
+++ b/src/select/properties/column_width.c
@@ -41,10 +41,10 @@ css_error css__compose_column_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_EM;
uint8_t type = get_column_width(child, &length, &unit);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COLUMN_WIDTH_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COLUMN_WIDTH_INHERIT) {
type = get_column_width(parent, &length, &unit);
}
diff --git a/src/select/properties/content.c b/src/select/properties/content.c
index c79dd0d..a9dd211 100644
--- a/src/select/properties/content.c
+++ b/src/select/properties/content.c
@@ -206,13 +206,13 @@ css_error css__compose_content(const css_computed_style *parent,
const css_computed_content_item *items = NULL;
uint8_t type = get_content(child, &items);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_CONTENT_INHERIT ||
- (child->uncommon != NULL && result != child)) {
+ (child->i.uncommon != NULL && result != child)) {
size_t n_items = 0;
css_computed_content_item *copy = NULL;
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_CONTENT_INHERIT) {
type = get_content(parent, &items);
}
diff --git a/src/select/properties/counter_increment.c b/src/select/properties/counter_increment.c
index 429e558..644607b 100644
--- a/src/select/properties/counter_increment.c
+++ b/src/select/properties/counter_increment.c
@@ -56,13 +56,13 @@ css_error css__compose_counter_increment(const css_computed_style *parent,
const css_computed_counter *items = NULL;
uint8_t type = get_counter_increment(child, &items);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COUNTER_INCREMENT_INHERIT ||
- (child->uncommon != NULL && result != child)) {
+ (child->i.uncommon != NULL && result != child)) {
size_t n_items = 0;
css_computed_counter *copy = NULL;
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COUNTER_INCREMENT_INHERIT) {
type = get_counter_increment(parent, &items);
}
diff --git a/src/select/properties/counter_reset.c b/src/select/properties/counter_reset.c
index ddf54aa..05559f5 100644
--- a/src/select/properties/counter_reset.c
+++ b/src/select/properties/counter_reset.c
@@ -55,13 +55,13 @@ css_error css__compose_counter_reset(const css_computed_style *parent,
const css_computed_counter *items = NULL;
uint8_t type = get_counter_reset(child, &items);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COUNTER_RESET_INHERIT ||
- (child->uncommon != NULL && result != child)) {
+ (child->i.uncommon != NULL && result != child)) {
size_t n_items = 0;
css_computed_counter *copy = NULL;
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_COUNTER_RESET_INHERIT) {
type = get_counter_reset(parent, &items);
}
diff --git a/src/select/properties/cursor.c b/src/select/properties/cursor.c
index a77d21b..1ca497f 100644
--- a/src/select/properties/cursor.c
+++ b/src/select/properties/cursor.c
@@ -172,13 +172,13 @@ css_error css__compose_cursor(const css_computed_style *parent,
lwc_string **urls = NULL;
uint8_t type = get_cursor(child, &urls);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_CURSOR_INHERIT ||
- (child->uncommon != NULL && result != child)) {
+ (child->i.uncommon != NULL && result != child)) {
size_t n_urls = 0;
lwc_string **copy = NULL;
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_CURSOR_INHERIT) {
type = get_cursor(parent, &urls);
}
diff --git a/src/select/properties/letter_spacing.c b/src/select/properties/letter_spacing.c
index 322efef..cc00100 100644
--- a/src/select/properties/letter_spacing.c
+++ b/src/select/properties/letter_spacing.c
@@ -41,10 +41,10 @@ css_error css__compose_letter_spacing(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_letter_spacing(child, &length, &unit);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_LETTER_SPACING_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_LETTER_SPACING_INHERIT) {
type = get_letter_spacing(parent, &length, &unit);
}
diff --git a/src/select/properties/outline_color.c b/src/select/properties/outline_color.c
index 36aafd7..2613839 100644
--- a/src/select/properties/outline_color.c
+++ b/src/select/properties/outline_color.c
@@ -65,10 +65,10 @@ css_error css__compose_outline_color(const css_computed_style *parent,
css_color color = 0;
uint8_t type = get_outline_color(child, &color);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_OUTLINE_COLOR_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_OUTLINE_COLOR_INHERIT) {
type = get_outline_color(parent, &color);
}
diff --git a/src/select/properties/outline_width.c b/src/select/properties/outline_width.c
index 5380179..547c42a 100644
--- a/src/select/properties/outline_width.c
+++ b/src/select/properties/outline_width.c
@@ -41,10 +41,10 @@ css_error css__compose_outline_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_outline_width(child, &length, &unit);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_OUTLINE_WIDTH_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_OUTLINE_WIDTH_INHERIT) {
type = get_outline_width(parent, &length, &unit);
}
diff --git a/src/select/properties/word_spacing.c b/src/select/properties/word_spacing.c
index dd4e1d7..24eda89 100644
--- a/src/select/properties/word_spacing.c
+++ b/src/select/properties/word_spacing.c
@@ -41,10 +41,10 @@ css_error css__compose_word_spacing(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
uint8_t type = get_word_spacing(child, &length, &unit);
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_WORD_SPACING_INHERIT ||
- (child->uncommon != NULL && result != child)) {
- if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ (child->i.uncommon != NULL && result != child)) {
+ if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
type == CSS_WORD_SPACING_INHERIT) {
type = get_word_spacing(parent, &length, &unit);
}
diff --git a/src/select/propget.h b/src/select/propget.h
index 2a263aa..5552e39 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -21,15 +21,15 @@ static inline uint8_t get_letter_spacing(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[LETTER_SPACING_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[LETTER_SPACING_INDEX];
bits &= LETTER_SPACING_MASK;
bits >>= LETTER_SPACING_SHIFT;
/* 6bits: uuuutt : unit | type */
if ((bits & 3) == CSS_LETTER_SPACING_SET) {
- *length = style->uncommon->letter_spacing;
+ *length = style->i.uncommon->i.letter_spacing;
*unit = bits >> 2;
}
@@ -49,15 +49,15 @@ static inline uint8_t get_letter_spacing(
static inline uint8_t get_outline_color(
const css_computed_style *style, css_color *color)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[OUTLINE_COLOR_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[OUTLINE_COLOR_INDEX];
bits &= OUTLINE_COLOR_MASK;
bits >>= OUTLINE_COLOR_SHIFT;
/* 2bits: tt : type */
if ((bits & 3) == CSS_OUTLINE_COLOR_COLOR) {
- *color = style->uncommon->outline_color;
+ *color = style->i.uncommon->i.outline_color;
}
return (bits & 3);
@@ -77,15 +77,15 @@ static inline uint8_t get_outline_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[OUTLINE_WIDTH_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[OUTLINE_WIDTH_INDEX];
bits &= OUTLINE_WIDTH_MASK;
bits >>= OUTLINE_WIDTH_SHIFT;
/* 7bits: uuuuttt : unit | type */
if ((bits & 7) == CSS_OUTLINE_WIDTH_WIDTH) {
- *length = style->uncommon->outline_width;
+ *length = style->i.uncommon->i.outline_width;
*unit = bits >> 3;
}
@@ -110,24 +110,24 @@ static inline uint8_t get_border_spacing(
css_fixed *hlength, css_unit *hunit,
css_fixed *vlength, css_unit *vunit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[BORDER_SPACING_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[BORDER_SPACING_INDEX];
bits &= BORDER_SPACING_MASK;
bits >>= BORDER_SPACING_SHIFT;
/* 1 bit: type */
if (bits == CSS_BORDER_SPACING_SET) {
uint8_t bits1 =
- style->uncommon->bits[BORDER_SPACING_INDEX1];
+ style->i.uncommon->i.bits[BORDER_SPACING_INDEX1];
bits1 &= BORDER_SPACING_MASK1;
bits1 >>= BORDER_SPACING_SHIFT1;
/* 8bits: hhhhvvvv : hunit | vunit */
- *hlength = style->uncommon->border_spacing[0];
+ *hlength = style->i.uncommon->i.border_spacing[0];
*hunit = bits1 >> 4;
- *vlength = style->uncommon->border_spacing[1];
+ *vlength = style->i.uncommon->i.border_spacing[1];
*vunit = bits1 & 0xf;
}
@@ -152,8 +152,8 @@ static inline uint8_t get_border_spacing(
static inline uint8_t get_break_after(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[BREAK_AFTER_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[BREAK_AFTER_INDEX];
bits &= BREAK_AFTER_MASK;
bits >>= BREAK_AFTER_SHIFT;
@@ -174,8 +174,8 @@ static inline uint8_t get_break_after(
static inline uint8_t get_break_before(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[BREAK_BEFORE_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[BREAK_BEFORE_INDEX];
bits &= BREAK_BEFORE_MASK;
bits >>= BREAK_BEFORE_SHIFT;
@@ -196,8 +196,8 @@ static inline uint8_t get_break_before(
static inline uint8_t get_break_inside(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[BREAK_INSIDE_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[BREAK_INSIDE_INDEX];
bits &= BREAK_INSIDE_MASK;
bits >>= BREAK_INSIDE_SHIFT;
@@ -219,15 +219,15 @@ static inline uint8_t get_word_spacing(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[WORD_SPACING_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[WORD_SPACING_INDEX];
bits &= WORD_SPACING_MASK;
bits >>= WORD_SPACING_SHIFT;
/* 6bits: uuuutt : unit | type */
if ((bits & 3) == CSS_WORD_SPACING_SET) {
- *length = style->uncommon->word_spacing;
+ *length = style->i.uncommon->i.word_spacing;
*unit = bits >> 2;
}
@@ -247,8 +247,8 @@ static inline uint8_t get_word_spacing(
static inline uint8_t get_writing_mode(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[WRITING_MODE_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[WRITING_MODE_INDEX];
bits &= WRITING_MODE_MASK;
bits >>= WRITING_MODE_SHIFT;
@@ -270,13 +270,13 @@ static inline uint8_t get_counter_increment(
const css_computed_style *style,
const css_computed_counter **counters)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COUNTER_INCREMENT_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COUNTER_INCREMENT_INDEX];
bits &= COUNTER_INCREMENT_MASK;
bits >>= COUNTER_INCREMENT_SHIFT;
/* 1bit: type */
- *counters = style->uncommon->counter_increment;
+ *counters = style->i.uncommon->counter_increment;
return bits;
}
@@ -295,13 +295,13 @@ static inline uint8_t get_counter_reset(
const css_computed_style *style,
const css_computed_counter **counters)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COUNTER_RESET_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COUNTER_RESET_INDEX];
bits &= COUNTER_RESET_MASK;
bits >>= COUNTER_RESET_SHIFT;
/* 1bit: type */
- *counters = style->uncommon->counter_reset;
+ *counters = style->i.uncommon->counter_reset;
return bits;
}
@@ -320,13 +320,13 @@ static inline uint8_t get_cursor(
const css_computed_style *style,
lwc_string ***urls)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[CURSOR_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[CURSOR_INDEX];
bits &= CURSOR_MASK;
bits >>= CURSOR_SHIFT;
/* 5bits: type */
- *urls = style->uncommon->cursor;
+ *urls = style->i.uncommon->cursor;
return bits;
}
@@ -351,8 +351,8 @@ static inline uint8_t get_clip(
const css_computed_style *style,
css_computed_clip_rect *rect)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[CLIP_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[CLIP_INDEX];
bits &= CLIP_MASK;
bits >>= CLIP_SHIFT;
@@ -368,33 +368,33 @@ static inline uint8_t get_clip(
if (rect->top_auto == false ||
rect->right_auto == false) {
/* 8bits: ttttrrrr : top | right */
- bits1 = style->uncommon->bits[CLIP_INDEX1];
+ bits1 = style->i.uncommon->i.bits[CLIP_INDEX1];
bits1 &= CLIP_MASK1;
bits1 >>= CLIP_SHIFT1;
} else {
bits1 = 0;
}
- rect->top = style->uncommon->clip[0];
+ rect->top = style->i.uncommon->i.clip[0];
rect->tunit = bits1 >> 4;
- rect->right = style->uncommon->clip[1];
+ rect->right = style->i.uncommon->i.clip[1];
rect->runit = bits1 & 0xf;
if (rect->bottom_auto == false ||
rect->left_auto == false) {
/* 8bits: bbbbllll : bottom | left */
- bits1 = style->uncommon->bits[CLIP_INDEX2];
+ bits1 = style->i.uncommon->i.bits[CLIP_INDEX2];
bits1 &= CLIP_MASK2;
bits1 >>= CLIP_SHIFT2;
} else {
bits1 = 0;
}
- rect->bottom = style->uncommon->clip[2];
+ rect->bottom = style->i.uncommon->i.clip[2];
rect->bunit = bits1 >> 4;
- rect->left = style->uncommon->clip[3];
+ rect->left = style->i.uncommon->i.clip[3];
rect->lunit = bits1 & 0xf;
}
@@ -420,13 +420,13 @@ static inline uint8_t get_clip(
static inline uint8_t get_column_count(
const css_computed_style *style, int32_t *count)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_COUNT_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_COUNT_INDEX];
bits &= COLUMN_COUNT_MASK;
bits >>= COLUMN_COUNT_SHIFT;
/* 2bits: tt : type */
- *count = style->uncommon->column_count;
+ *count = style->i.uncommon->i.column_count;
return bits;
}
@@ -444,8 +444,8 @@ static inline uint8_t get_column_count(
static inline uint8_t get_column_fill(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_FILL_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_FILL_INDEX];
bits &= COLUMN_FILL_MASK;
bits >>= COLUMN_FILL_SHIFT;
@@ -467,14 +467,14 @@ static inline uint8_t get_column_gap(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_GAP_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_GAP_INDEX];
bits &= COLUMN_GAP_MASK;
bits >>= COLUMN_GAP_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_COLUMN_GAP_SET) {
- *length = style->uncommon->column_gap;
+ *length = style->i.uncommon->i.column_gap;
*unit = bits >> 2;
}
@@ -495,13 +495,13 @@ static inline uint8_t get_column_rule_color(
const css_computed_style *style,
css_color *color)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_RULE_COLOR_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_RULE_COLOR_INDEX];
bits &= COLUMN_RULE_COLOR_MASK;
bits >>= COLUMN_RULE_COLOR_SHIFT;
/* 2bits: type */
- *color = style->uncommon->column_rule_color;
+ *color = style->i.uncommon->i.column_rule_color;
return bits;
}
@@ -520,8 +520,8 @@ static inline uint8_t get_column_rule_color(
static inline uint8_t get_column_rule_style(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_RULE_STYLE_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_RULE_STYLE_INDEX];
bits &= COLUMN_RULE_STYLE_MASK;
bits >>= COLUMN_RULE_STYLE_SHIFT;
@@ -543,14 +543,14 @@ static inline uint8_t get_column_rule_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_RULE_WIDTH_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_RULE_WIDTH_INDEX];
bits &= COLUMN_RULE_WIDTH_MASK;
bits >>= COLUMN_RULE_WIDTH_SHIFT;
/* 7bits: uuuuttt : units | type */
if ((bits & 0x7) == CSS_COLUMN_RULE_WIDTH_WIDTH) {
- *length = style->uncommon->column_rule_width;
+ *length = style->i.uncommon->i.column_rule_width;
*unit = bits >> 3;
}
@@ -570,8 +570,8 @@ static inline uint8_t get_column_rule_width(
static inline uint8_t get_column_span(
const css_computed_style *style)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_SPAN_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_SPAN_INDEX];
bits &= COLUMN_SPAN_MASK;
bits >>= COLUMN_SPAN_SHIFT;
@@ -593,14 +593,14 @@ static inline uint8_t get_column_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[COLUMN_WIDTH_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[COLUMN_WIDTH_INDEX];
bits &= COLUMN_WIDTH_MASK;
bits >>= COLUMN_WIDTH_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_COLUMN_WIDTH_SET) {
- *length = style->uncommon->column_width;
+ *length = style->i.uncommon->i.column_width;
*unit = bits >> 2;
}
@@ -621,13 +621,13 @@ static inline uint8_t get_content(
const css_computed_style *style,
const css_computed_content_item **content)
{
- if (style->uncommon != NULL) {
- uint8_t bits = style->uncommon->bits[CONTENT_INDEX];
+ if (style->i.uncommon != NULL) {
+ uint8_t bits = style->i.uncommon->i.bits[CONTENT_INDEX];
bits &= CONTENT_MASK;
bits >>= CONTENT_SHIFT;
/* 2bits: type */
- *content = style->uncommon->content;
+ *content = style->i.uncommon->content;
return bits;
}
@@ -646,13 +646,13 @@ static inline uint8_t get_vertical_align(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[VERTICAL_ALIGN_INDEX];
+ uint8_t bits = style->i.bits[VERTICAL_ALIGN_INDEX];
bits &= VERTICAL_ALIGN_MASK;
bits >>= VERTICAL_ALIGN_SHIFT;
/* 8bits: uuuutttt : units | type */
if ((bits & 0xf) == CSS_VERTICAL_ALIGN_SET) {
- *length = style->vertical_align;
+ *length = style->i.vertical_align;
*unit = bits >> 4;
}
@@ -669,13 +669,13 @@ static inline uint8_t get_font_size(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[FONT_SIZE_INDEX];
+ uint8_t bits = style->i.bits[FONT_SIZE_INDEX];
bits &= FONT_SIZE_MASK;
bits >>= FONT_SIZE_SHIFT;
/* 8bits: uuuutttt : units | type */
if ((bits & 0xf) == CSS_FONT_SIZE_DIMENSION) {
- *length = style->font_size;
+ *length = style->i.font_size;
*unit = bits >> 4;
}
@@ -692,13 +692,13 @@ static inline uint8_t get_border_top_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[BORDER_TOP_WIDTH_INDEX];
+ uint8_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX];
bits &= BORDER_TOP_WIDTH_MASK;
bits >>= BORDER_TOP_WIDTH_SHIFT;
/* 7bits: uuuuttt : units | type */
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
- *length = style->border_width[0];
+ *length = style->i.border_width[0];
*unit = bits >> 3;
}
@@ -715,13 +715,13 @@ static inline uint8_t get_border_right_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[BORDER_RIGHT_WIDTH_INDEX];
+ uint8_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
bits &= BORDER_RIGHT_WIDTH_MASK;
bits >>= BORDER_RIGHT_WIDTH_SHIFT;
/* 7bits: uuuuttt : units | type */
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
- *length = style->border_width[1];
+ *length = style->i.border_width[1];
*unit = bits >> 3;
}
@@ -738,13 +738,13 @@ static inline uint8_t get_border_bottom_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[BORDER_BOTTOM_WIDTH_INDEX];
+ uint8_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
bits &= BORDER_BOTTOM_WIDTH_MASK;
bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
/* 7bits: uuuuttt : units | type */
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
- *length = style->border_width[2];
+ *length = style->i.border_width[2];
*unit = bits >> 3;
}
@@ -761,13 +761,13 @@ static inline uint8_t get_border_left_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[BORDER_LEFT_WIDTH_INDEX];
+ uint8_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX];
bits &= BORDER_LEFT_WIDTH_MASK;
bits >>= BORDER_LEFT_WIDTH_SHIFT;
/* 7bits: uuuuttt : units | type */
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
- *length = style->border_width[3];
+ *length = style->i.border_width[3];
*unit = bits >> 3;
}
@@ -784,12 +784,12 @@ static inline uint8_t get_background_image(
const css_computed_style *style,
lwc_string **url)
{
- uint8_t bits = style->bits[BACKGROUND_IMAGE_INDEX];
+ uint8_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX];
bits &= BACKGROUND_IMAGE_MASK;
bits >>= BACKGROUND_IMAGE_SHIFT;
/* 1bit: type */
- *url = style->background_image;
+ *url = style->i.background_image;
return bits;
}
@@ -804,12 +804,12 @@ static inline uint8_t get_color(
const css_computed_style *style,
css_color *color)
{
- uint8_t bits = style->bits[COLOR_INDEX];
+ uint8_t bits = style->i.bits[COLOR_INDEX];
bits &= COLOR_MASK;
bits >>= COLOR_SHIFT;
/* 1bit: type */
- *color = style->color;
+ *color = style->i.color;
return bits;
}
@@ -824,12 +824,12 @@ static inline uint8_t get_list_style_image(
const css_computed_style *style,
lwc_string **url)
{
- uint8_t bits = style->bits[LIST_STYLE_IMAGE_INDEX];
+ uint8_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
bits &= LIST_STYLE_IMAGE_MASK;
bits >>= LIST_STYLE_IMAGE_SHIFT;
/* 1bit: type */
- *url = style->list_style_image;
+ *url = style->i.list_style_image;
return bits;
}
@@ -844,7 +844,7 @@ static inline uint8_t get_quotes(
const css_computed_style *style,
lwc_string ***quotes)
{
- uint8_t bits = style->bits[QUOTES_INDEX];
+ uint8_t bits = style->i.bits[QUOTES_INDEX];
bits &= QUOTES_MASK;
bits >>= QUOTES_SHIFT;
@@ -864,13 +864,13 @@ static inline uint8_t get_top(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[TOP_INDEX];
+ uint8_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_TOP_SET) {
- *length = style->top;
+ *length = style->i.top;
*unit = bits >> 2;
}
@@ -879,7 +879,7 @@ static inline uint8_t get_top(
static inline uint8_t get_top_bits(
const css_computed_style *style)
{
- uint8_t bits = style->bits[TOP_INDEX];
+ uint8_t bits = style->i.bits[TOP_INDEX];
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
@@ -897,13 +897,13 @@ static inline uint8_t get_right(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[RIGHT_INDEX];
+ uint8_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_RIGHT_SET) {
- *length = style->right;
+ *length = style->i.right;
*unit = bits >> 2;
}
@@ -912,7 +912,7 @@ static inline uint8_t get_right(
static inline uint8_t get_right_bits(
const css_computed_style *style)
{
- uint8_t bits = style->bits[RIGHT_INDEX];
+ uint8_t bits = style->i.bits[RIGHT_INDEX];
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
@@ -930,13 +930,13 @@ static inline uint8_t get_bottom(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[BOTTOM_INDEX];
+ uint8_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_BOTTOM_SET) {
- *length = style->bottom;
+ *length = style->i.bottom;
*unit = bits >> 2;
}
@@ -945,7 +945,7 @@ static inline uint8_t get_bottom(
static inline uint8_t get_bottom_bits(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BOTTOM_INDEX];
+ uint8_t bits = style->i.bits[BOTTOM_INDEX];
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
@@ -963,13 +963,13 @@ static inline uint8_t get_left(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[LEFT_INDEX];
+ uint8_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_LEFT_SET) {
- *length = style->left;
+ *length = style->i.left;
*unit = bits >> 2;
}
@@ -978,7 +978,7 @@ static inline uint8_t get_left(
static inline uint8_t get_left_bits(
const css_computed_style *style)
{
- uint8_t bits = style->bits[LEFT_INDEX];
+ uint8_t bits = style->i.bits[LEFT_INDEX];
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
@@ -996,12 +996,12 @@ static inline uint8_t get_border_top_color(
const css_computed_style *style,
css_color *color)
{
- uint8_t bits = style->bits[BORDER_TOP_COLOR_INDEX];
+ uint8_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX];
bits &= BORDER_TOP_COLOR_MASK;
bits >>= BORDER_TOP_COLOR_SHIFT;
/* 2bits: type */
- *color = style->border_color[0];
+ *color = style->i.border_color[0];
return bits;
}
@@ -1016,12 +1016,12 @@ static inline uint8_t get_border_right_color(
const css_computed_style *style,
css_color *color)
{
- uint8_t bits = style->bits[BORDER_RIGHT_COLOR_INDEX];
+ uint8_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX];
bits &= BORDER_RIGHT_COLOR_MASK;
bits >>= BORDER_RIGHT_COLOR_SHIFT;
/* 2bits: type */
- *color = style->border_color[1];
+ *color = style->i.border_color[1];
return bits;
}
@@ -1036,12 +1036,12 @@ static inline uint8_t get_border_bottom_color(
const css_computed_style *style,
css_color *color)
{
- uint8_t bits = style->bits[BORDER_BOTTOM_COLOR_INDEX];
+ uint8_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
bits &= BORDER_BOTTOM_COLOR_MASK;
bits >>= BORDER_BOTTOM_COLOR_SHIFT;
/* 2bits: type */
- *color = style->border_color[2];
+ *color = style->i.border_color[2];
return bits;
}
@@ -1056,12 +1056,12 @@ static inline uint8_t get_border_left_color(
const css_computed_style *style,
css_color *color)
{
- uint8_t bits = style->bits[BORDER_LEFT_COLOR_INDEX];
+ uint8_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX];
bits &= BORDER_LEFT_COLOR_MASK;
bits >>= BORDER_LEFT_COLOR_SHIFT;
/* 2bits: type */
- *color = style->border_color[3];
+ *color = style->i.border_color[3];
return bits;
}
@@ -1076,13 +1076,13 @@ static inline uint8_t get_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[HEIGHT_INDEX];
+ uint8_t bits = style->i.bits[HEIGHT_INDEX];
bits &= HEIGHT_MASK;
bits >>= HEIGHT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_HEIGHT_SET) {
- *length = style->height;
+ *length = style->i.height;
*unit = bits >> 2;
}
@@ -1099,14 +1099,14 @@ static inline uint8_t get_line_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[LINE_HEIGHT_INDEX];
+ uint8_t bits = style->i.bits[LINE_HEIGHT_INDEX];
bits &= LINE_HEIGHT_MASK;
bits >>= LINE_HEIGHT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_LINE_HEIGHT_NUMBER ||
(bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) {
- *length = style->line_height;
+ *length = style->i.line_height;
}
if ((bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) {
@@ -1126,12 +1126,12 @@ static inline uint8_t get_background_color(
const css_computed_style *style,
css_color *color)
{
- uint8_t bits = style->bits[BACKGROUND_COLOR_INDEX];
+ uint8_t bits = style->i.bits[BACKGROUND_COLOR_INDEX];
bits &= BACKGROUND_COLOR_MASK;
bits >>= BACKGROUND_COLOR_SHIFT;
/* 2bits: type */
- *color = style->background_color;
+ *color = style->i.background_color;
return bits;
}
@@ -1146,12 +1146,12 @@ static inline uint8_t get_z_index(
const css_computed_style *style,
int32_t *z_index)
{
- uint8_t bits = style->bits[Z_INDEX_INDEX];
+ uint8_t bits = style->i.bits[Z_INDEX_INDEX];
bits &= Z_INDEX_MASK;
bits >>= Z_INDEX_SHIFT;
/* 2bits: type */
- *z_index = style->z_index;
+ *z_index = style->i.z_index;
return bits;
}
@@ -1166,13 +1166,13 @@ static inline uint8_t get_margin_top(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MARGIN_TOP_INDEX];
+ uint8_t bits = style->i.bits[MARGIN_TOP_INDEX];
bits &= MARGIN_TOP_MASK;
bits >>= MARGIN_TOP_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_MARGIN_SET) {
- *length = style->margin[0];
+ *length = style->i.margin[0];
*unit = bits >> 2;
}
@@ -1189,13 +1189,13 @@ static inline uint8_t get_margin_right(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MARGIN_RIGHT_INDEX];
+ uint8_t bits = style->i.bits[MARGIN_RIGHT_INDEX];
bits &= MARGIN_RIGHT_MASK;
bits >>= MARGIN_RIGHT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_MARGIN_SET) {
- *length = style->margin[1];
+ *length = style->i.margin[1];
*unit = bits >> 2;
}
@@ -1212,13 +1212,13 @@ static inline uint8_t get_margin_bottom(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MARGIN_BOTTOM_INDEX];
+ uint8_t bits = style->i.bits[MARGIN_BOTTOM_INDEX];
bits &= MARGIN_BOTTOM_MASK;
bits >>= MARGIN_BOTTOM_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_MARGIN_SET) {
- *length = style->margin[2];
+ *length = style->i.margin[2];
*unit = bits >> 2;
}
@@ -1235,13 +1235,13 @@ static inline uint8_t get_margin_left(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MARGIN_LEFT_INDEX];
+ uint8_t bits = style->i.bits[MARGIN_LEFT_INDEX];
bits &= MARGIN_LEFT_MASK;
bits >>= MARGIN_LEFT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_MARGIN_SET) {
- *length = style->margin[3];
+ *length = style->i.margin[3];
*unit = bits >> 2;
}
@@ -1257,7 +1257,7 @@ static inline uint8_t get_margin_left(
static inline uint8_t get_background_attachment(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BACKGROUND_ATTACHMENT_INDEX];
+ uint8_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
bits &= BACKGROUND_ATTACHMENT_MASK;
bits >>= BACKGROUND_ATTACHMENT_SHIFT;
@@ -1274,7 +1274,7 @@ static inline uint8_t get_background_attachment(
static inline uint8_t get_border_collapse(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BORDER_COLLAPSE_INDEX];
+ uint8_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
bits &= BORDER_COLLAPSE_MASK;
bits >>= BORDER_COLLAPSE_SHIFT;
@@ -1291,7 +1291,7 @@ static inline uint8_t get_border_collapse(
static inline uint8_t get_caption_side(
const css_computed_style *style)
{
- uint8_t bits = style->bits[CAPTION_SIDE_INDEX];
+ uint8_t bits = style->i.bits[CAPTION_SIDE_INDEX];
bits &= CAPTION_SIDE_MASK;
bits >>= CAPTION_SIDE_SHIFT;
@@ -1308,7 +1308,7 @@ static inline uint8_t get_caption_side(
static inline uint8_t get_direction(
const css_computed_style *style)
{
- uint8_t bits = style->bits[DIRECTION_INDEX];
+ uint8_t bits = style->i.bits[DIRECTION_INDEX];
bits &= DIRECTION_MASK;
bits >>= DIRECTION_SHIFT;
@@ -1326,13 +1326,13 @@ static inline uint8_t get_max_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MAX_HEIGHT_INDEX];
+ uint8_t bits = style->i.bits[MAX_HEIGHT_INDEX];
bits &= MAX_HEIGHT_MASK;
bits >>= MAX_HEIGHT_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_MAX_HEIGHT_SET) {
- *length = style->max_height;
+ *length = style->i.max_height;
*unit = bits >> 2;
}
@@ -1349,13 +1349,13 @@ static inline uint8_t get_max_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MAX_WIDTH_INDEX];
+ uint8_t bits = style->i.bits[MAX_WIDTH_INDEX];
bits &= MAX_WIDTH_MASK;
bits >>= MAX_WIDTH_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_MAX_WIDTH_SET) {
- *length = style->max_width;
+ *length = style->i.max_width;
*unit = bits >> 2;
}
@@ -1372,13 +1372,13 @@ static inline uint8_t get_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[WIDTH_INDEX];
+ uint8_t bits = style->i.bits[WIDTH_INDEX];
bits &= WIDTH_MASK;
bits >>= WIDTH_SHIFT;
/* 6bits: uuuutt : units | type */
if ((bits & 0x3) == CSS_WIDTH_SET) {
- *length = style->width;
+ *length = style->i.width;
*unit = bits >> 2;
}
@@ -1394,7 +1394,7 @@ static inline uint8_t get_width(
static inline uint8_t get_empty_cells(
const css_computed_style *style)
{
- uint8_t bits = style->bits[EMPTY_CELLS_INDEX];
+ uint8_t bits = style->i.bits[EMPTY_CELLS_INDEX];
bits &= EMPTY_CELLS_MASK;
bits >>= EMPTY_CELLS_SHIFT;
@@ -1411,7 +1411,7 @@ static inline uint8_t get_empty_cells(
static inline uint8_t get_float(
const css_computed_style *style)
{
- uint8_t bits = style->bits[FLOAT_INDEX];
+ uint8_t bits = style->i.bits[FLOAT_INDEX];
bits &= FLOAT_MASK;
bits >>= FLOAT_SHIFT;
@@ -1428,7 +1428,7 @@ static inline uint8_t get_float(
static inline uint8_t get_font_style(
const css_computed_style *style)
{
- uint8_t bits = style->bits[FONT_STYLE_INDEX];
+ uint8_t bits = style->i.bits[FONT_STYLE_INDEX];
bits &= FONT_STYLE_MASK;
bits >>= FONT_STYLE_SHIFT;
@@ -1446,13 +1446,13 @@ static inline uint8_t get_min_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MIN_HEIGHT_INDEX];
+ uint8_t bits = style->i.bits[MIN_HEIGHT_INDEX];
bits &= MIN_HEIGHT_MASK;
bits >>= MIN_HEIGHT_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_MIN_HEIGHT_SET) {
- *length = style->min_height;
+ *length = style->i.min_height;
*unit = bits >> 1;
}
@@ -1469,13 +1469,13 @@ static inline uint8_t get_min_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[MIN_WIDTH_INDEX];
+ uint8_t bits = style->i.bits[MIN_WIDTH_INDEX];
bits &= MIN_WIDTH_MASK;
bits >>= MIN_WIDTH_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_MIN_WIDTH_SET) {
- *length = style->min_width;
+ *length = style->i.min_width;
*unit = bits >> 1;
}
@@ -1491,7 +1491,7 @@ static inline uint8_t get_min_width(
static inline uint8_t get_background_repeat(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BACKGROUND_REPEAT_INDEX];
+ uint8_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
bits &= BACKGROUND_REPEAT_MASK;
bits >>= BACKGROUND_REPEAT_SHIFT;
@@ -1508,7 +1508,7 @@ static inline uint8_t get_background_repeat(
static inline uint8_t get_clear(
const css_computed_style *style)
{
- uint8_t bits = style->bits[CLEAR_INDEX];
+ uint8_t bits = style->i.bits[CLEAR_INDEX];
bits &= CLEAR_MASK;
bits >>= CLEAR_SHIFT;
@@ -1526,13 +1526,13 @@ static inline uint8_t get_padding_top(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[PADDING_TOP_INDEX];
+ uint8_t bits = style->i.bits[PADDING_TOP_INDEX];
bits &= PADDING_TOP_MASK;
bits >>= PADDING_TOP_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_PADDING_SET) {
- *length = style->padding[0];
+ *length = style->i.padding[0];
*unit = bits >> 1;
}
@@ -1549,13 +1549,13 @@ static inline uint8_t get_padding_right(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[PADDING_RIGHT_INDEX];
+ uint8_t bits = style->i.bits[PADDING_RIGHT_INDEX];
bits &= PADDING_RIGHT_MASK;
bits >>= PADDING_RIGHT_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_PADDING_SET) {
- *length = style->padding[1];
+ *length = style->i.padding[1];
*unit = bits >> 1;
}
@@ -1572,13 +1572,13 @@ static inline uint8_t get_padding_bottom(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[PADDING_BOTTOM_INDEX];
+ uint8_t bits = style->i.bits[PADDING_BOTTOM_INDEX];
bits &= PADDING_BOTTOM_MASK;
bits >>= PADDING_BOTTOM_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_PADDING_SET) {
- *length = style->padding[2];
+ *length = style->i.padding[2];
*unit = bits >> 1;
}
@@ -1595,13 +1595,13 @@ static inline uint8_t get_padding_left(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[PADDING_LEFT_INDEX];
+ uint8_t bits = style->i.bits[PADDING_LEFT_INDEX];
bits &= PADDING_LEFT_MASK;
bits >>= PADDING_LEFT_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_PADDING_SET) {
- *length = style->padding[3];
+ *length = style->i.padding[3];
*unit = bits >> 1;
}
@@ -1617,7 +1617,7 @@ static inline uint8_t get_padding_left(
static inline uint8_t get_overflow_x(
const css_computed_style *style)
{
- uint8_t bits = style->bits[OVERFLOW_X_INDEX];
+ uint8_t bits = style->i.bits[OVERFLOW_X_INDEX];
bits &= OVERFLOW_X_MASK;
bits >>= OVERFLOW_X_SHIFT;
@@ -1634,7 +1634,7 @@ static inline uint8_t get_overflow_x(
static inline uint8_t get_overflow_y(
const css_computed_style *style)
{
- uint8_t bits = style->bits[OVERFLOW_Y_INDEX];
+ uint8_t bits = style->i.bits[OVERFLOW_Y_INDEX];
bits &= OVERFLOW_Y_MASK;
bits >>= OVERFLOW_Y_SHIFT;
@@ -1651,7 +1651,7 @@ static inline uint8_t get_overflow_y(
static inline uint8_t get_position(
const css_computed_style *style)
{
- uint8_t bits = style->bits[POSITION_INDEX];
+ uint8_t bits = style->i.bits[POSITION_INDEX];
bits &= POSITION_MASK;
bits >>= POSITION_SHIFT;
@@ -1669,13 +1669,13 @@ static inline uint8_t get_opacity(
const css_computed_style *style,
css_fixed *opacity)
{
- uint8_t bits = style->bits[OPACITY_INDEX];
+ uint8_t bits = style->i.bits[OPACITY_INDEX];
bits &= OPACITY_MASK;
bits >>= OPACITY_SHIFT;
/* 1bit: t : type */
if ((bits & 0x1) == CSS_OPACITY_SET) {
- *opacity = style->opacity;
+ *opacity = style->i.opacity;
}
return (bits & 0x1);
@@ -1690,7 +1690,7 @@ static inline uint8_t get_opacity(
static inline uint8_t get_text_transform(
const css_computed_style *style)
{
- uint8_t bits = style->bits[TEXT_TRANSFORM_INDEX];
+ uint8_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
bits &= TEXT_TRANSFORM_MASK;
bits >>= TEXT_TRANSFORM_SHIFT;
@@ -1708,13 +1708,13 @@ static inline uint8_t get_text_indent(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- uint8_t bits = style->bits[TEXT_INDENT_INDEX];
+ uint8_t bits = style->i.bits[TEXT_INDENT_INDEX];
bits &= TEXT_INDENT_MASK;
bits >>= TEXT_INDENT_SHIFT;
/* 5bits: uuuut : units | type */
if ((bits & 0x1) == CSS_TEXT_INDENT_SET) {
- *length = style->text_indent;
+ *length = style->i.text_indent;
*unit = bits >> 1;
}
@@ -1730,7 +1730,7 @@ static inline uint8_t get_text_indent(
static inline uint8_t get_white_space(
const css_computed_style *style)
{
- uint8_t bits = style->bits[WHITE_SPACE_INDEX];
+ uint8_t bits = style->i.bits[WHITE_SPACE_INDEX];
bits &= WHITE_SPACE_MASK;
bits >>= WHITE_SPACE_SHIFT;
@@ -1752,21 +1752,21 @@ static inline uint8_t get_background_position(
css_fixed *hlength, css_unit *hunit,
css_fixed *vlength, css_unit *vunit)
{
- uint8_t bits = style->bits[BACKGROUND_POSITION_INDEX];
+ uint8_t bits = style->i.bits[BACKGROUND_POSITION_INDEX];
bits &= BACKGROUND_POSITION_MASK;
bits >>= BACKGROUND_POSITION_SHIFT;
/* 1bit: type */
if (bits == CSS_BACKGROUND_POSITION_SET) {
- uint8_t bits1 = style->bits[BACKGROUND_POSITION_INDEX1];
+ uint8_t bits1 = style->i.bits[BACKGROUND_POSITION_INDEX1];
bits1 &= BACKGROUND_POSITION_MASK1;
bits1 >>= BACKGROUND_POSITION_SHIFT1;
/* 8bits: hhhhvvvv : hunit | vunit */
- *hlength = style->background_position[0];
+ *hlength = style->i.background_position[0];
*hunit = bits1 >> 4;
- *vlength = style->background_position[1];
+ *vlength = style->i.background_position[1];
*vunit = bits1 & 0xf;
}
@@ -1785,7 +1785,7 @@ static inline uint8_t get_background_position(
static inline uint8_t get_display(
const css_computed_style *style)
{
- uint8_t bits = style->bits[DISPLAY_INDEX];
+ uint8_t bits = style->i.bits[DISPLAY_INDEX];
bits &= DISPLAY_MASK;
bits >>= DISPLAY_SHIFT;
@@ -1802,7 +1802,7 @@ static inline uint8_t get_display(
static inline uint8_t get_font_variant(
const css_computed_style *style)
{
- uint8_t bits = style->bits[FONT_VARIANT_INDEX];
+ uint8_t bits = style->i.bits[FONT_VARIANT_INDEX];
bits &= FONT_VARIANT_MASK;
bits >>= FONT_VARIANT_SHIFT;
@@ -1819,7 +1819,7 @@ static inline uint8_t get_font_variant(
static inline uint8_t get_text_decoration(
const css_computed_style *style)
{
- uint8_t bits = style->bits[TEXT_DECORATION_INDEX];
+ uint8_t bits = style->i.bits[TEXT_DECORATION_INDEX];
bits &= TEXT_DECORATION_MASK;
bits >>= TEXT_DECORATION_SHIFT;
@@ -1837,7 +1837,7 @@ static inline uint8_t get_font_family(
const css_computed_style *style,
lwc_string ***names)
{
- uint8_t bits = style->bits[FONT_FAMILY_INDEX];
+ uint8_t bits = style->i.bits[FONT_FAMILY_INDEX];
bits &= FONT_FAMILY_MASK;
bits >>= FONT_FAMILY_SHIFT;
@@ -1856,7 +1856,7 @@ static inline uint8_t get_font_family(
static inline uint8_t get_border_top_style(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BORDER_TOP_STYLE_INDEX];
+ uint8_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX];
bits &= BORDER_TOP_STYLE_MASK;
bits >>= BORDER_TOP_STYLE_SHIFT;
@@ -1873,7 +1873,7 @@ static inline uint8_t get_border_top_style(
static inline uint8_t get_border_right_style(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BORDER_RIGHT_STYLE_INDEX];
+ uint8_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX];
bits &= BORDER_RIGHT_STYLE_MASK;
bits >>= BORDER_RIGHT_STYLE_SHIFT;
@@ -1890,7 +1890,7 @@ static inline uint8_t get_border_right_style(
static inline uint8_t get_border_bottom_style(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BORDER_BOTTOM_STYLE_INDEX];
+ uint8_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
bits &= BORDER_BOTTOM_STYLE_MASK;
bits >>= BORDER_BOTTOM_STYLE_SHIFT;
@@ -1907,7 +1907,7 @@ static inline uint8_t get_border_bottom_style(
static inline uint8_t get_border_left_style(
const css_computed_style *style)
{
- uint8_t bits = style->bits[BORDER_LEFT_STYLE_INDEX];
+ uint8_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
bits &= BORDER_LEFT_STYLE_MASK;
bits >>= BORDER_LEFT_STYLE_SHIFT;
@@ -1924,7 +1924,7 @@ static inline uint8_t get_border_left_style(
static inline uint8_t get_font_weight(
const css_computed_style *style)
{
- uint8_t bits = style->bits[FONT_WEIGHT_INDEX];
+ uint8_t bits = style->i.bits[FONT_WEIGHT_INDEX];
bits &= FONT_WEIGHT_MASK;
bits >>= FONT_WEIGHT_SHIFT;
@@ -1941,7 +1941,7 @@ static inline uint8_t get_font_weight(
static inline uint8_t get_list_style_type(
const css_computed_style *style)
{
- uint8_t bits = style->bits[LIST_STYLE_TYPE_INDEX];
+ uint8_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX];
bits &= LIST_STYLE_TYPE_MASK;
bits >>= LIST_STYLE_TYPE_SHIFT;
@@ -1958,7 +1958,7 @@ static inline uint8_t get_list_style_type(
static inline uint8_t get_outline_style(
const css_computed_style *style)
{
- uint8_t bits = style->bits[OUTLINE_STYLE_INDEX];
+ uint8_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
bits &= OUTLINE_STYLE_MASK;
bits >>= OUTLINE_STYLE_SHIFT;
@@ -1975,7 +1975,7 @@ static inline uint8_t get_outline_style(
static inline uint8_t get_table_layout(
const css_computed_style *style)
{
- uint8_t bits = style->bits[TABLE_LAYOUT_INDEX];
+ uint8_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
bits &= TABLE_LAYOUT_MASK;
bits >>= TABLE_LAYOUT_SHIFT;
@@ -1992,7 +1992,7 @@ static inline uint8_t get_table_layout(
static inline uint8_t get_unicode_bidi(
const css_computed_style *style)
{
- uint8_t bits = style->bits[UNICODE_BIDI_INDEX];
+ uint8_t bits = style->i.bits[UNICODE_BIDI_INDEX];
bits &= UNICODE_BIDI_MASK;
bits >>= UNICODE_BIDI_SHIFT;
@@ -2009,7 +2009,7 @@ static inline uint8_t get_unicode_bidi(
static inline uint8_t get_visibility(
const css_computed_style *style)
{
- uint8_t bits = style->bits[VISIBILITY_INDEX];
+ uint8_t bits = style->i.bits[VISIBILITY_INDEX];
bits &= VISIBILITY_MASK;
bits >>= VISIBILITY_SHIFT;
@@ -2026,7 +2026,7 @@ static inline uint8_t get_visibility(
static inline uint8_t get_list_style_position(
const css_computed_style *style)
{
- uint8_t bits = style->bits[LIST_STYLE_POSITION_INDEX];
+ uint8_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
bits &= LIST_STYLE_POSITION_MASK;
bits >>= LIST_STYLE_POSITION_SHIFT;
@@ -2043,7 +2043,7 @@ static inline uint8_t get_list_style_position(
static inline uint8_t get_text_align(
const css_computed_style *style)
{
- uint8_t bits = style->bits[TEXT_ALIGN_INDEX];
+ uint8_t bits = style->i.bits[TEXT_ALIGN_INDEX];
bits &= TEXT_ALIGN_MASK;
bits >>= TEXT_ALIGN_SHIFT;
diff --git a/src/select/propset.h b/src/select/propset.h
index 928b9e3..76e4fe6 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -19,54 +19,60 @@
/** Default values are 'initial value', unless the property is inherited,
* in which case it is 'inherit'. */
static const css_computed_uncommon default_uncommon = {
- .bits = {
- (CSS_LETTER_SPACING_INHERIT << 2) |
- CSS_OUTLINE_COLOR_INVERT,
- (CSS_OUTLINE_WIDTH_MEDIUM << 1) |
- CSS_BORDER_SPACING_INHERIT,
- 0,
- (CSS_WORD_SPACING_INHERIT << 2) |
- (CSS_COUNTER_INCREMENT_NONE << 1) |
- CSS_COUNTER_RESET_NONE,
- (CSS_CURSOR_INHERIT << 3) |
- (CSS_WRITING_MODE_INHERIT << 1),
- 0,
- 0,
- (CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL,
- (CSS_COLUMN_COUNT_AUTO << 6) |
- (CSS_COLUMN_FILL_BALANCE << 4) |
- (CSS_COLUMN_RULE_STYLE_NONE << 0),
- (CSS_COLUMN_GAP_NORMAL << 2) |
- (CSS_COLUMN_RULE_COLOR_CURRENT_COLOR),
- (CSS_COLUMN_RULE_WIDTH_MEDIUM << 1),
- (CSS_COLUMN_SPAN_NONE << 6) | CSS_COLUMN_WIDTH_AUTO,
- (CSS_BREAK_BEFORE_AUTO << 4) | CSS_BREAK_AFTER_AUTO,
- (CSS_BREAK_INSIDE_AUTO)
+ .i = {
+ .bits = {
+ (CSS_LETTER_SPACING_INHERIT << 2) |
+ CSS_OUTLINE_COLOR_INVERT,
+ (CSS_OUTLINE_WIDTH_MEDIUM << 1) |
+ CSS_BORDER_SPACING_INHERIT,
+ 0,
+ (CSS_WORD_SPACING_INHERIT << 2) |
+ (CSS_COUNTER_INCREMENT_NONE << 1) |
+ CSS_COUNTER_RESET_NONE,
+ (CSS_CURSOR_INHERIT << 3) |
+ (CSS_WRITING_MODE_INHERIT << 1),
+ 0,
+ 0,
+ (CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL,
+ (CSS_COLUMN_COUNT_AUTO << 6) |
+ (CSS_COLUMN_FILL_BALANCE << 4) |
+ (CSS_COLUMN_RULE_STYLE_NONE << 0),
+ (CSS_COLUMN_GAP_NORMAL << 2) |
+ (CSS_COLUMN_RULE_COLOR_CURRENT_COLOR),
+ (CSS_COLUMN_RULE_WIDTH_MEDIUM << 1),
+ (CSS_COLUMN_SPAN_NONE << 6) | CSS_COLUMN_WIDTH_AUTO,
+ (CSS_BREAK_BEFORE_AUTO << 4) | CSS_BREAK_AFTER_AUTO,
+ (CSS_BREAK_INSIDE_AUTO)
+ },
+ .border_spacing = { 0, 0 },
+ .clip = { 0, 0, 0, 0 },
+ .letter_spacing = 0,
+ .outline_color = 0x0,
+ .outline_width = 0,
+ .word_spacing = 0,
+ .column_count = 0,
+ .column_gap = 0,
+ .column_rule_color = 0,
+ .column_rule_width = 0,
+ .column_width = 0
},
- .border_spacing = { 0, 0 },
- .clip = { 0, 0, 0, 0 },
- .letter_spacing = 0,
- .outline_color = 0x0,
- .outline_width = 0,
- .word_spacing = 0,
- .column_count = 0,
- .column_gap = 0,
- .column_rule_color = 0,
- .column_rule_width = 0,
- .column_width = 0,
.counter_increment = NULL,
.counter_reset = NULL,
.content = NULL,
- .cursor = NULL
+ .cursor = NULL,
+ .next = NULL,
+ .count = 0,
+ .bin = UINT32_MAX
};
#define ENSURE_UNCOMMON do { \
- if (style->uncommon == NULL) { \
- style->uncommon = malloc(sizeof(css_computed_uncommon));\
- if (style->uncommon == NULL) \
+ if (style->i.uncommon == NULL) { \
+ style->i.uncommon = malloc( \
+ sizeof(css_computed_uncommon)); \
+ if (style->i.uncommon == NULL) \
return CSS_NOMEM; \
\
- memcpy(style->uncommon, &default_uncommon, \
+ memcpy(style->i.uncommon, &default_uncommon, \
sizeof(css_computed_uncommon)); \
} \
} while(0)
@@ -105,13 +111,13 @@ static inline css_error set_letter_spacing(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[LETTER_SPACING_INDEX];
+ bits = &style->i.uncommon->i.bits[LETTER_SPACING_INDEX];
/* 6bits: uuuutt : unit | type */
*bits = (*bits & ~LETTER_SPACING_MASK) |
(((type & 0x3) | unit << 2) << LETTER_SPACING_SHIFT);
- style->uncommon->letter_spacing = length;
+ style->i.uncommon->i.letter_spacing = length;
return CSS_OK;
}
@@ -129,13 +135,13 @@ static inline css_error set_outline_color(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[OUTLINE_COLOR_INDEX];
+ bits = &style->i.uncommon->i.bits[OUTLINE_COLOR_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~OUTLINE_COLOR_MASK) |
((type & 0x3) << OUTLINE_COLOR_SHIFT);
- style->uncommon->outline_color = color;
+ style->i.uncommon->i.outline_color = color;
return CSS_OK;
}
@@ -154,13 +160,13 @@ static inline css_error set_outline_width(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[OUTLINE_WIDTH_INDEX];
+ bits = &style->i.uncommon->i.bits[OUTLINE_WIDTH_INDEX];
/* 7bits: uuuuttt : unit | type */
*bits = (*bits & ~OUTLINE_WIDTH_MASK) |
(((type & 0x7) | (unit << 3)) << OUTLINE_WIDTH_SHIFT);
- style->uncommon->outline_width = length;
+ style->i.uncommon->i.outline_width = length;
return CSS_OK;
}
@@ -182,20 +188,20 @@ static inline css_error set_border_spacing(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[BORDER_SPACING_INDEX];
+ bits = &style->i.uncommon->i.bits[BORDER_SPACING_INDEX];
/* 1 bit: type */
*bits = (*bits & ~BORDER_SPACING_MASK) |
((type & 0x1) << BORDER_SPACING_SHIFT);
- bits = &style->uncommon->bits[BORDER_SPACING_INDEX1];
+ bits = &style->i.uncommon->i.bits[BORDER_SPACING_INDEX1];
/* 8bits: hhhhvvvv : hunit | vunit */
*bits = (((hunit << 4) | vunit) << BORDER_SPACING_SHIFT1);
- style->uncommon->border_spacing[0] = hlength;
- style->uncommon->border_spacing[1] = vlength;
+ style->i.uncommon->i.border_spacing[0] = hlength;
+ style->i.uncommon->i.border_spacing[1] = vlength;
return CSS_OK;
}
@@ -215,7 +221,7 @@ static inline css_error set_break_after(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[BREAK_AFTER_INDEX];
+ bits = &style->i.uncommon->i.bits[BREAK_AFTER_INDEX];
/* 4bits: type */
*bits = (*bits & ~BREAK_AFTER_MASK) |
@@ -237,7 +243,7 @@ static inline css_error set_break_before(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[BREAK_BEFORE_INDEX];
+ bits = &style->i.uncommon->i.bits[BREAK_BEFORE_INDEX];
/* 4bits: type */
*bits = (*bits & ~BREAK_BEFORE_MASK) |
@@ -259,7 +265,7 @@ static inline css_error set_break_inside(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[BREAK_INSIDE_INDEX];
+ bits = &style->i.uncommon->i.bits[BREAK_INSIDE_INDEX];
/* 4bits: type */
*bits = (*bits & ~BREAK_INSIDE_MASK) |
@@ -282,13 +288,13 @@ static inline css_error set_word_spacing(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[WORD_SPACING_INDEX];
+ bits = &style->i.uncommon->i.bits[WORD_SPACING_INDEX];
/* 6bits: uuuutt : unit | type */
*bits = (*bits & ~WORD_SPACING_MASK) |
(((type & 0x3) | (unit << 2)) << WORD_SPACING_SHIFT);
- style->uncommon->word_spacing = length;
+ style->i.uncommon->i.word_spacing = length;
return CSS_OK;
}
@@ -306,7 +312,7 @@ static inline css_error set_writing_mode(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[WRITING_MODE_INDEX];
+ bits = &style->i.uncommon->i.bits[WRITING_MODE_INDEX];
/* 2bits: type */
*bits = (*bits & ~WRITING_MODE_MASK) |
@@ -331,8 +337,8 @@ static inline css_error set_counter_increment(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COUNTER_INCREMENT_INDEX];
- oldcounters = style->uncommon->counter_increment;
+ bits = &style->i.uncommon->i.bits[COUNTER_INCREMENT_INDEX];
+ oldcounters = style->i.uncommon->counter_increment;
/* 1bit: type */
*bits = (*bits & ~COUNTER_INCREMENT_MASK) |
@@ -341,7 +347,7 @@ static inline css_error set_counter_increment(
for (c = counters; c != NULL && c->name != NULL; c++)
c->name = lwc_string_ref(c->name);
- style->uncommon->counter_increment = counters;
+ style->i.uncommon->counter_increment = counters;
/* Free existing array */
if (oldcounters != NULL) {
@@ -371,8 +377,8 @@ static inline css_error set_counter_reset(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COUNTER_RESET_INDEX];
- oldcounters = style->uncommon->counter_reset;
+ bits = &style->i.uncommon->i.bits[COUNTER_RESET_INDEX];
+ oldcounters = style->i.uncommon->counter_reset;
/* 1bit: type */
*bits = (*bits & ~COUNTER_RESET_MASK) |
@@ -381,7 +387,7 @@ static inline css_error set_counter_reset(
for (c = counters; c != NULL && c->name != NULL; c++)
c->name = lwc_string_ref(c->name);
- style->uncommon->counter_reset = counters;
+ style->i.uncommon->counter_reset = counters;
/* Free existing array */
if (oldcounters != NULL) {
@@ -411,8 +417,8 @@ static inline css_error set_cursor(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[CURSOR_INDEX];
- oldurls = style->uncommon->cursor;
+ bits = &style->i.uncommon->i.bits[CURSOR_INDEX];
+ oldurls = style->i.uncommon->cursor;
/* 5bits: type */
*bits = (*bits & ~CURSOR_MASK) |
@@ -421,7 +427,7 @@ static inline css_error set_cursor(
for (s = urls; s != NULL && *s != NULL; s++)
*s = lwc_string_ref(*s);
- style->uncommon->cursor = urls;
+ style->i.uncommon->cursor = urls;
/* Free existing array */
if (oldurls != NULL) {
@@ -453,7 +459,7 @@ static inline css_error set_clip(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[CLIP_INDEX];
+ bits = &style->i.uncommon->i.bits[CLIP_INDEX];
/* 6bits: trblyy : top | right | bottom | left | type */
*bits = (*bits & ~CLIP_MASK) |
@@ -465,20 +471,20 @@ static inline css_error set_clip(
(rect->bottom_auto ? 0x8 : 0) |
(rect->left_auto ? 0x4 : 0)) << CLIP_SHIFT);
- bits = &style->uncommon->bits[CLIP_INDEX1];
+ bits = &style->i.uncommon->i.bits[CLIP_INDEX1];
/* 8bits: ttttrrrr : top | right */
*bits = (((rect->tunit << 4) | rect->runit) << CLIP_SHIFT1);
- bits = &style->uncommon->bits[CLIP_INDEX2];
+ bits = &style->i.uncommon->i.bits[CLIP_INDEX2];
/* 8bits: bbbbllll : bottom | left */
*bits = (((rect->bunit << 4) | rect->lunit) << CLIP_SHIFT2);
- style->uncommon->clip[0] = rect->top;
- style->uncommon->clip[1] = rect->right;
- style->uncommon->clip[2] = rect->bottom;
- style->uncommon->clip[3] = rect->left;
+ style->i.uncommon->i.clip[0] = rect->top;
+ style->i.uncommon->i.clip[1] = rect->right;
+ style->i.uncommon->i.clip[2] = rect->bottom;
+ style->i.uncommon->i.clip[3] = rect->left;
}
return CSS_OK;
@@ -501,13 +507,13 @@ static inline css_error set_column_count(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_COUNT_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_COUNT_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_COUNT_MASK) |
((type & 0x3) << COLUMN_COUNT_SHIFT);
- style->uncommon->column_count = count;
+ style->i.uncommon->i.column_count = count;
return CSS_OK;
}
@@ -525,7 +531,7 @@ static inline css_error set_column_fill(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_FILL_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_FILL_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_FILL_MASK) |
@@ -548,13 +554,13 @@ static inline css_error set_column_gap(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_GAP_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_GAP_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~COLUMN_GAP_MASK) |
(((type & 0x3) | (unit << 2)) << COLUMN_GAP_SHIFT);
- style->uncommon->column_gap = length;
+ style->i.uncommon->i.column_gap = length;
return CSS_OK;
}
@@ -573,13 +579,13 @@ static inline css_error set_column_rule_color(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_RULE_COLOR_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_RULE_COLOR_INDEX];
/* 2bits: type */
*bits = (*bits & ~COLUMN_RULE_COLOR_MASK) |
((type & 0x3) << COLUMN_RULE_COLOR_SHIFT);
- style->uncommon->column_rule_color = color;
+ style->i.uncommon->i.column_rule_color = color;
return CSS_OK;
}
@@ -597,7 +603,7 @@ static inline css_error set_column_rule_style(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_RULE_STYLE_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_RULE_STYLE_INDEX];
/* 4bits: type */
*bits = (*bits & ~COLUMN_RULE_STYLE_MASK) |
@@ -620,13 +626,13 @@ static inline css_error set_column_rule_width(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_RULE_WIDTH_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_RULE_WIDTH_INDEX];
/* 7bits: uuuuttt : units | type */
*bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) |
(((type & 0x7) | (unit << 3)) << COLUMN_RULE_WIDTH_SHIFT);
- style->uncommon->column_rule_width = length;
+ style->i.uncommon->i.column_rule_width = length;
return CSS_OK;
}
@@ -644,7 +650,7 @@ static inline css_error set_column_span(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_SPAN_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_SPAN_INDEX];
/* 2bits: tt : type */
*bits = (*bits & ~COLUMN_SPAN_MASK) |
@@ -667,13 +673,13 @@ static inline css_error set_column_width(
ENSURE_UNCOMMON;
- bits = &style->uncommon->bits[COLUMN_WIDTH_INDEX];
+ bits = &style->i.uncommon->i.bits[COLUMN_WIDTH_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~COLUMN_WIDTH_MASK) |
(((type & 0x3) | (unit << 2)) << COLUMN_WIDTH_SHIFT);
- style->uncommon->column_width = length;
+ style->i.uncommon->i.column_width = length;
return CSS_OK;
}
@@ -695,8 +701,8 @@ static inline css_error set_content(
ENSURE_UNCOMMON;
/* 2bits: type */
- bits = &style->uncommon->bits[CONTENT_INDEX];
- oldcontent = style->uncommon->content;
+ bits = &style->i.uncommon->i.bits[CONTENT_INDEX];
+ oldcontent = style->i.uncommon->content;
*bits = (*bits & ~CONTENT_MASK) |
((type & 0x3) << CONTENT_SHIFT);
@@ -728,7 +734,7 @@ static inline css_error set_content(
}
}
- style->uncommon->content = content;
+ style->i.uncommon->content = content;
/* Free existing array */
if (oldcontent != NULL) {
@@ -773,12 +779,12 @@ static inline css_error set_vertical_align(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[VERTICAL_ALIGN_INDEX];
+ uint8_t *bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
/* 8bits: uuuutttt : units | type */
*bits = (((type & 0xf) | (unit << 4)) << VERTICAL_ALIGN_SHIFT);
- style->vertical_align = length;
+ style->i.vertical_align = length;
return CSS_OK;
}
@@ -791,12 +797,12 @@ static inline css_error set_font_size(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[FONT_SIZE_INDEX];
+ uint8_t *bits = &style->i.bits[FONT_SIZE_INDEX];
/* 8bits: uuuutttt : units | type */
*bits = (((type & 0xf) | (unit << 4)) << FONT_SIZE_SHIFT);
- style->font_size = length;
+ style->i.font_size = length;
return CSS_OK;
}
@@ -810,13 +816,13 @@ static inline css_error set_border_top_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[BORDER_TOP_WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
/* 7bits: uuuuttt : units | type */
*bits = (*bits & ~BORDER_TOP_WIDTH_MASK) |
(((type & 0x7) | (unit << 3)) << BORDER_TOP_WIDTH_SHIFT);
- style->border_width[0] = length;
+ style->i.border_width[0] = length;
return CSS_OK;
}
@@ -831,13 +837,13 @@ static inline css_error set_border_right_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[BORDER_RIGHT_WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
/* 7bits: uuuuttt : units | type */
*bits = (*bits & ~BORDER_RIGHT_WIDTH_MASK) |
(((type & 0x7) | (unit << 3)) << BORDER_RIGHT_WIDTH_SHIFT);
- style->border_width[1] = length;
+ style->i.border_width[1] = length;
return CSS_OK;
}
@@ -852,13 +858,13 @@ static inline css_error set_border_bottom_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[BORDER_BOTTOM_WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
/* 7bits: uuuuttt : units | type */
*bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) |
(((type & 0x7) | (unit << 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
- style->border_width[2] = length;
+ style->i.border_width[2] = length;
return CSS_OK;
}
@@ -873,13 +879,13 @@ static inline css_error set_border_left_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[BORDER_LEFT_WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
/* 7bits: uuuuttt : units | type */
*bits = (*bits & ~BORDER_LEFT_WIDTH_MASK) |
(((type & 0x7) | (unit << 3)) << BORDER_LEFT_WIDTH_SHIFT);
- style->border_width[3] = length;
+ style->i.border_width[3] = length;
return CSS_OK;
}
@@ -894,17 +900,17 @@ static inline css_error set_background_image(
css_computed_style *style, uint8_t type,
lwc_string *url)
{
- uint8_t *bits = &style->bits[BACKGROUND_IMAGE_INDEX];
- lwc_string *oldurl = style->background_image;
+ uint8_t *bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
+ lwc_string *oldurl = style->i.background_image;
/* 1bit: type */
*bits = (*bits & ~BACKGROUND_IMAGE_MASK) |
((type & 0x1) << BACKGROUND_IMAGE_SHIFT);
if (url != NULL) {
- style->background_image = lwc_string_ref(url);
+ style->i.background_image = lwc_string_ref(url);
} else {
- style->background_image = NULL;
+ style->i.background_image = NULL;
}
if (oldurl != NULL)
@@ -923,13 +929,13 @@ static inline css_error set_color(
css_computed_style *style, uint8_t type,
css_color color)
{
- uint8_t *bits = &style->bits[COLOR_INDEX];
+ uint8_t *bits = &style->i.bits[COLOR_INDEX];
/* 1bit: type */
*bits = (*bits & ~COLOR_MASK) |
((type & 0x1) << COLOR_SHIFT);
- style->color = color;
+ style->i.color = color;
return CSS_OK;
}
@@ -944,17 +950,17 @@ static inline css_error set_list_style_image(
css_computed_style *style, uint8_t type,
lwc_string *url)
{
- uint8_t *bits = &style->bits[LIST_STYLE_IMAGE_INDEX];
- lwc_string *oldurl = style->list_style_image;
+ uint8_t *bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ lwc_string *oldurl = style->i.list_style_image;
/* 1bit: type */
*bits = (*bits & ~LIST_STYLE_IMAGE_MASK) |
((type & 0x1) << LIST_STYLE_IMAGE_SHIFT);
if (url != NULL) {
- style->list_style_image = lwc_string_ref(url);
+ style->i.list_style_image = lwc_string_ref(url);
} else {
- style->list_style_image = NULL;
+ style->i.list_style_image = NULL;
}
if (oldurl != NULL)
@@ -973,7 +979,7 @@ static inline css_error set_quotes(
css_computed_style *style, uint8_t type,
lwc_string **quotes)
{
- uint8_t *bits = &style->bits[QUOTES_INDEX];
+ uint8_t *bits = &style->i.bits[QUOTES_INDEX];
lwc_string **oldquotes = style->quotes;
lwc_string **s;
@@ -1008,13 +1014,13 @@ static inline css_error set_top(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[TOP_INDEX];
+ uint8_t *bits = &style->i.bits[TOP_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~TOP_MASK) |
(((type & 0x3) | (unit << 2)) << TOP_SHIFT);
- style->top = length;
+ style->i.top = length;
return CSS_OK;
}
@@ -1029,13 +1035,13 @@ static inline css_error set_right(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[RIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[RIGHT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~RIGHT_MASK) |
(((type & 0x3) | (unit << 2)) << RIGHT_SHIFT);
- style->right = length;
+ style->i.right = length;
return CSS_OK;
}
@@ -1050,13 +1056,13 @@ static inline css_error set_bottom(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[BOTTOM_INDEX];
+ uint8_t *bits = &style->i.bits[BOTTOM_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~BOTTOM_MASK) |
(((type & 0x3) | (unit << 2)) << BOTTOM_SHIFT);
- style->bottom = length;
+ style->i.bottom = length;
return CSS_OK;
}
@@ -1071,13 +1077,13 @@ static inline css_error set_left(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[LEFT_INDEX];
+ uint8_t *bits = &style->i.bits[LEFT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~LEFT_MASK) |
(((type & 0x3) | (unit << 2)) << LEFT_SHIFT);
- style->left = length;
+ style->i.left = length;
return CSS_OK;
}
@@ -1092,13 +1098,13 @@ static inline css_error set_border_top_color(
css_computed_style *style, uint8_t type,
css_color color)
{
- uint8_t *bits = &style->bits[BORDER_TOP_COLOR_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
/* 2bits: type */
*bits = (*bits & ~BORDER_TOP_COLOR_MASK) |
((type & 0x3) << BORDER_TOP_COLOR_SHIFT);
- style->border_color[0] = color;
+ style->i.border_color[0] = color;
return CSS_OK;
}
@@ -1113,13 +1119,13 @@ static inline css_error set_border_right_color(
css_computed_style *style, uint8_t type,
css_color color)
{
- uint8_t *bits = &style->bits[BORDER_RIGHT_COLOR_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
/* 2bits: type */
*bits = (*bits & ~BORDER_RIGHT_COLOR_MASK) |
((type & 0x3) << BORDER_RIGHT_COLOR_SHIFT);
- style->border_color[1] = color;
+ style->i.border_color[1] = color;
return CSS_OK;
}
@@ -1134,13 +1140,13 @@ static inline css_error set_border_bottom_color(
css_computed_style *style, uint8_t type,
css_color color)
{
- uint8_t *bits = &style->bits[BORDER_BOTTOM_COLOR_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
/* 2bits: type */
*bits = (*bits & ~BORDER_BOTTOM_COLOR_MASK) |
((type & 0x3) << BORDER_BOTTOM_COLOR_SHIFT);
- style->border_color[2] = color;
+ style->i.border_color[2] = color;
return CSS_OK;
}
@@ -1155,13 +1161,13 @@ static inline css_error set_border_left_color(
css_computed_style *style, uint8_t type,
css_color color)
{
- uint8_t *bits = &style->bits[BORDER_LEFT_COLOR_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
/* 2bits: type */
*bits = (*bits & ~BORDER_LEFT_COLOR_MASK) |
((type & 0x3) << BORDER_LEFT_COLOR_SHIFT);
- style->border_color[3] = color;
+ style->i.border_color[3] = color;
return CSS_OK;
}
@@ -1176,13 +1182,13 @@ static inline css_error set_height(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[HEIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[HEIGHT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~HEIGHT_MASK) |
(((type & 0x3) | (unit << 2)) << HEIGHT_SHIFT);
- style->height = length;
+ style->i.height = length;
return CSS_OK;
}
@@ -1197,13 +1203,13 @@ static inline css_error set_line_height(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[LINE_HEIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[LINE_HEIGHT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~LINE_HEIGHT_MASK) |
(((type & 0x3) | (unit << 2)) << LINE_HEIGHT_SHIFT);
- style->line_height = length;
+ style->i.line_height = length;
return CSS_OK;
}
@@ -1218,13 +1224,13 @@ static inline css_error set_background_color(
css_computed_style *style, uint8_t type,
css_color color)
{
- uint8_t *bits = &style->bits[BACKGROUND_COLOR_INDEX];
+ uint8_t *bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
/* 2bits: type */
*bits = (*bits & ~BACKGROUND_COLOR_MASK) |
((type & 0x3) << BACKGROUND_COLOR_SHIFT);
- style->background_color = color;
+ style->i.background_color = color;
return CSS_OK;
}
@@ -1239,13 +1245,13 @@ static inline css_error set_z_index(
css_computed_style *style, uint8_t type,
int32_t z_index)
{
- uint8_t *bits = &style->bits[Z_INDEX_INDEX];
+ uint8_t *bits = &style->i.bits[Z_INDEX_INDEX];
/* 2bits: type */
*bits = (*bits & ~Z_INDEX_MASK) |
((type & 0x3) << Z_INDEX_SHIFT);
- style->z_index = z_index;
+ style->i.z_index = z_index;
return CSS_OK;
}
@@ -1260,13 +1266,13 @@ static inline css_error set_margin_top(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MARGIN_TOP_INDEX];
+ uint8_t *bits = &style->i.bits[MARGIN_TOP_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~MARGIN_TOP_MASK) |
(((type & 0x3) | (unit << 2)) << MARGIN_TOP_SHIFT);
- style->margin[0] = length;
+ style->i.margin[0] = length;
return CSS_OK;
}
@@ -1281,13 +1287,13 @@ static inline css_error set_margin_right(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MARGIN_RIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[MARGIN_RIGHT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~MARGIN_RIGHT_MASK) |
(((type & 0x3) | (unit << 2)) << MARGIN_RIGHT_SHIFT);
- style->margin[1] = length;
+ style->i.margin[1] = length;
return CSS_OK;
}
@@ -1302,13 +1308,13 @@ static inline css_error set_margin_bottom(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MARGIN_BOTTOM_INDEX];
+ uint8_t *bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~MARGIN_BOTTOM_MASK) |
(((type & 0x3) | (unit << 2)) << MARGIN_BOTTOM_SHIFT);
- style->margin[2] = length;
+ style->i.margin[2] = length;
return CSS_OK;
}
@@ -1323,13 +1329,13 @@ static inline css_error set_margin_left(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MARGIN_LEFT_INDEX];
+ uint8_t *bits = &style->i.bits[MARGIN_LEFT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~MARGIN_LEFT_MASK) |
(((type & 0x3) | (unit << 2)) << MARGIN_LEFT_SHIFT);
- style->margin[3] = length;
+ style->i.margin[3] = length;
return CSS_OK;
}
@@ -1343,7 +1349,7 @@ static inline css_error set_margin_left(
static inline css_error set_background_attachment(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BACKGROUND_ATTACHMENT_INDEX];
+ uint8_t *bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
/* 2bits: type */
*bits = (*bits & ~BACKGROUND_ATTACHMENT_MASK) |
@@ -1361,7 +1367,7 @@ static inline css_error set_background_attachment(
static inline css_error set_border_collapse(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BORDER_COLLAPSE_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
/* 2bits: type */
*bits = (*bits & ~BORDER_COLLAPSE_MASK) |
@@ -1379,7 +1385,7 @@ static inline css_error set_border_collapse(
static inline css_error set_caption_side(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[CAPTION_SIDE_INDEX];
+ uint8_t *bits = &style->i.bits[CAPTION_SIDE_INDEX];
/* 2bits: type */
*bits = (*bits & ~CAPTION_SIDE_MASK) |
@@ -1397,7 +1403,7 @@ static inline css_error set_caption_side(
static inline css_error set_direction(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[DIRECTION_INDEX];
+ uint8_t *bits = &style->i.bits[DIRECTION_INDEX];
/* 2bits: type */
*bits = (*bits & ~DIRECTION_MASK) |
@@ -1416,13 +1422,13 @@ static inline css_error set_max_height(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MAX_HEIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[MAX_HEIGHT_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~MAX_HEIGHT_MASK) |
(((type & 0x3) | (unit << 2)) << MAX_HEIGHT_SHIFT);
- style->max_height = length;
+ style->i.max_height = length;
return CSS_OK;
}
@@ -1437,13 +1443,13 @@ static inline css_error set_max_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MAX_WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[MAX_WIDTH_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~MAX_WIDTH_MASK) |
(((type & 0x3) | (unit << 2)) << MAX_WIDTH_SHIFT);
- style->max_width = length;
+ style->i.max_width = length;
return CSS_OK;
}
@@ -1458,13 +1464,13 @@ static inline css_error set_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[WIDTH_INDEX];
/* 6bits: uuuutt : units | type */
*bits = (*bits & ~WIDTH_MASK) |
(((type & 0x3) | (unit << 2)) << WIDTH_SHIFT);
- style->width = length;
+ style->i.width = length;
return CSS_OK;
}
@@ -1478,7 +1484,7 @@ static inline css_error set_width(
static inline css_error set_empty_cells(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[EMPTY_CELLS_INDEX];
+ uint8_t *bits = &style->i.bits[EMPTY_CELLS_INDEX];
/* 2bits: type */
*bits = (*bits & ~EMPTY_CELLS_MASK) |
@@ -1496,7 +1502,7 @@ static inline css_error set_empty_cells(
static inline css_error set_float(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[FLOAT_INDEX];
+ uint8_t *bits = &style->i.bits[FLOAT_INDEX];
/* 2bits: type */
*bits = (*bits & ~FLOAT_MASK) |
@@ -1514,7 +1520,7 @@ static inline css_error set_float(
static inline css_error set_font_style(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[FONT_STYLE_INDEX];
+ uint8_t *bits = &style->i.bits[FONT_STYLE_INDEX];
/* 2bits: type */
*bits = (*bits & ~FONT_STYLE_MASK) |
@@ -1533,13 +1539,13 @@ static inline css_error set_min_height(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MIN_HEIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[MIN_HEIGHT_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~MIN_HEIGHT_MASK) |
(((type & 0x1) | (unit << 1)) << MIN_HEIGHT_SHIFT);
- style->min_height = length;
+ style->i.min_height = length;
return CSS_OK;
}
@@ -1554,13 +1560,13 @@ static inline css_error set_min_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[MIN_WIDTH_INDEX];
+ uint8_t *bits = &style->i.bits[MIN_WIDTH_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~MIN_WIDTH_MASK) |
(((type & 0x1) | (unit << 1)) << MIN_WIDTH_SHIFT);
- style->min_width = length;
+ style->i.min_width = length;
return CSS_OK;
}
@@ -1574,7 +1580,7 @@ static inline css_error set_min_width(
static inline css_error set_background_repeat(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BACKGROUND_REPEAT_INDEX];
+ uint8_t *bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
/* 3bits: type */
*bits = (*bits & ~BACKGROUND_REPEAT_MASK) |
@@ -1592,7 +1598,7 @@ static inline css_error set_background_repeat(
static inline css_error set_clear(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[CLEAR_INDEX];
+ uint8_t *bits = &style->i.bits[CLEAR_INDEX];
/* 3bits: type */
*bits = (*bits & ~CLEAR_MASK) |
@@ -1611,13 +1617,13 @@ static inline css_error set_padding_top(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[PADDING_TOP_INDEX];
+ uint8_t *bits = &style->i.bits[PADDING_TOP_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~PADDING_TOP_MASK) |
(((type & 0x1) | (unit << 1)) << PADDING_TOP_SHIFT);
- style->padding[0] = length;
+ style->i.padding[0] = length;
return CSS_OK;
}
@@ -1632,13 +1638,13 @@ static inline css_error set_padding_right(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[PADDING_RIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[PADDING_RIGHT_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~PADDING_RIGHT_MASK) |
(((type & 0x1) | (unit << 1)) << PADDING_RIGHT_SHIFT);
- style->padding[1] = length;
+ style->i.padding[1] = length;
return CSS_OK;
}
@@ -1653,13 +1659,13 @@ static inline css_error set_padding_bottom(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[PADDING_BOTTOM_INDEX];
+ uint8_t *bits = &style->i.bits[PADDING_BOTTOM_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~PADDING_BOTTOM_MASK) |
(((type & 0x1) | (unit << 1)) << PADDING_BOTTOM_SHIFT);
- style->padding[2] = length;
+ style->i.padding[2] = length;
return CSS_OK;
}
@@ -1674,13 +1680,13 @@ static inline css_error set_padding_left(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[PADDING_LEFT_INDEX];
+ uint8_t *bits = &style->i.bits[PADDING_LEFT_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~PADDING_LEFT_MASK) |
(((type & 0x1) | (unit << 1)) << PADDING_LEFT_SHIFT);
- style->padding[3] = length;
+ style->i.padding[3] = length;
return CSS_OK;
}
@@ -1694,7 +1700,7 @@ static inline css_error set_padding_left(
static inline css_error set_overflow_x(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[OVERFLOW_X_INDEX];
+ uint8_t *bits = &style->i.bits[OVERFLOW_X_INDEX];
/* 3bits: type */
*bits = (*bits & ~OVERFLOW_X_MASK) |
@@ -1712,7 +1718,7 @@ static inline css_error set_overflow_x(
static inline css_error set_overflow_y(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[OVERFLOW_Y_INDEX];
+ uint8_t *bits = &style->i.bits[OVERFLOW_Y_INDEX];
/* 3bits: type */
*bits = (*bits & ~OVERFLOW_Y_MASK) |
@@ -1730,7 +1736,7 @@ static inline css_error set_overflow_y(
static inline css_error set_position(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[POSITION_INDEX];
+ uint8_t *bits = &style->i.bits[POSITION_INDEX];
/* 3bits: type */
*bits = (*bits & ~POSITION_MASK) |
@@ -1749,13 +1755,13 @@ static inline css_error set_opacity(
css_computed_style *style,
uint8_t type, css_fixed opacity)
{
- uint8_t *bits = &style->bits[OPACITY_INDEX];
+ uint8_t *bits = &style->i.bits[OPACITY_INDEX];
/* 1bit: t : type */
*bits = (*bits & ~OPACITY_MASK) |
((type & 0x1) << OPACITY_SHIFT);
- style->opacity = opacity;
+ style->i.opacity = opacity;
return CSS_OK;
}
@@ -1769,7 +1775,7 @@ static inline css_error set_opacity(
static inline css_error set_text_transform(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[TEXT_TRANSFORM_INDEX];
+ uint8_t *bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
/* 3bits: type */
*bits = (*bits & ~TEXT_TRANSFORM_MASK) |
@@ -1788,13 +1794,13 @@ static inline css_error set_text_indent(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
- uint8_t *bits = &style->bits[TEXT_INDENT_INDEX];
+ uint8_t *bits = &style->i.bits[TEXT_INDENT_INDEX];
/* 5bits: uuuut : units | type */
*bits = (*bits & ~TEXT_INDENT_MASK) |
(((type & 0x1) | (unit << 1)) << TEXT_INDENT_SHIFT);
- style->text_indent = length;
+ style->i.text_indent = length;
return CSS_OK;
}
@@ -1808,7 +1814,7 @@ static inline css_error set_text_indent(
static inline css_error set_white_space(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[WHITE_SPACE_INDEX];
+ uint8_t *bits = &style->i.bits[WHITE_SPACE_INDEX];
/* 3bits: type */
*bits = (*bits & ~WHITE_SPACE_MASK) |
@@ -1832,19 +1838,19 @@ static inline css_error set_background_position(
{
uint8_t *bits;
- bits = &style->bits[BACKGROUND_POSITION_INDEX];
+ bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
/* 1 bit: type */
*bits = (*bits & ~BACKGROUND_POSITION_MASK) |
((type & 0x1) << BACKGROUND_POSITION_SHIFT);
- bits = &style->bits[BACKGROUND_POSITION_INDEX1];
+ bits = &style->i.bits[BACKGROUND_POSITION_INDEX1];
/* 8bits: hhhhvvvv : hunit | vunit */
*bits = (((hunit << 4) | vunit) << BACKGROUND_POSITION_SHIFT1);
- style->background_position[0] = hlength;
- style->background_position[1] = vlength;
+ style->i.background_position[0] = hlength;
+ style->i.background_position[1] = vlength;
return CSS_OK;
}
@@ -1860,7 +1866,7 @@ static inline css_error set_background_position(
static inline css_error set_display(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[DISPLAY_INDEX];
+ uint8_t *bits = &style->i.bits[DISPLAY_INDEX];
/* 5bits: type */
*bits = (*bits & ~DISPLAY_MASK) |
@@ -1878,7 +1884,7 @@ static inline css_error set_display(
static inline css_error set_font_variant(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[FONT_VARIANT_INDEX];
+ uint8_t *bits = &style->i.bits[FONT_VARIANT_INDEX];
/* 2bits: type */
*bits = (*bits & ~FONT_VARIANT_MASK) |
@@ -1896,7 +1902,7 @@ static inline css_error set_font_variant(
static inline css_error set_text_decoration(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[TEXT_DECORATION_INDEX];
+ uint8_t *bits = &style->i.bits[TEXT_DECORATION_INDEX];
/* 5bits: type */
*bits = (*bits & ~TEXT_DECORATION_MASK) |
@@ -1915,7 +1921,7 @@ static inline css_error set_font_family(
css_computed_style *style, uint8_t type,
lwc_string **names)
{
- uint8_t *bits = &style->bits[FONT_FAMILY_INDEX];
+ uint8_t *bits = &style->i.bits[FONT_FAMILY_INDEX];
lwc_string **oldnames = style->font_family;
lwc_string **s;
@@ -1949,7 +1955,7 @@ static inline css_error set_font_family(
static inline css_error set_border_top_style(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BORDER_TOP_STYLE_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
/* 4bits: type */
*bits = (*bits & ~BORDER_TOP_STYLE_MASK) |
@@ -1967,7 +1973,7 @@ static inline css_error set_border_top_style(
static inline css_error set_border_right_style(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BORDER_RIGHT_STYLE_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
/* 4bits: type */
*bits = (*bits & ~BORDER_RIGHT_STYLE_MASK) |
@@ -1985,7 +1991,7 @@ static inline css_error set_border_right_style(
static inline css_error set_border_bottom_style(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BORDER_BOTTOM_STYLE_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
/* 4bits: type */
*bits = (*bits & ~BORDER_BOTTOM_STYLE_MASK) |
@@ -2003,7 +2009,7 @@ static inline css_error set_border_bottom_style(
static inline css_error set_border_left_style(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[BORDER_LEFT_STYLE_INDEX];
+ uint8_t *bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
/* 4bits: type */
*bits = (*bits & ~BORDER_LEFT_STYLE_MASK) |
@@ -2021,7 +2027,7 @@ static inline css_error set_border_left_style(
static inline css_error set_font_weight(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[FONT_WEIGHT_INDEX];
+ uint8_t *bits = &style->i.bits[FONT_WEIGHT_INDEX];
/* 4bits: type */
*bits = (*bits & ~FONT_WEIGHT_MASK) |
@@ -2039,7 +2045,7 @@ static inline css_error set_font_weight(
static inline css_error set_list_style_type(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[LIST_STYLE_TYPE_INDEX];
+ uint8_t *bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
/* 4bits: type */
*bits = (*bits & ~LIST_STYLE_TYPE_MASK) |
@@ -2057,7 +2063,7 @@ static inline css_error set_list_style_type(
static inline css_error set_outline_style(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[OUTLINE_STYLE_INDEX];
+ uint8_t *bits = &style->i.bits[OUTLINE_STYLE_INDEX];
/* 4bits: type */
*bits = (*bits & ~OUTLINE_STYLE_MASK) |
@@ -2075,7 +2081,7 @@ static inline css_error set_outline_style(
static inline css_error set_table_layout(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[TABLE_LAYOUT_INDEX];
+ uint8_t *bits = &style->i.bits[TABLE_LAYOUT_INDEX];
/* 2bits: type */
*bits = (*bits & ~TABLE_LAYOUT_MASK) |
@@ -2093,7 +2099,7 @@ static inline css_error set_table_layout(
static inline css_error set_unicode_bidi(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[UNICODE_BIDI_INDEX];
+ uint8_t *bits = &style->i.bits[UNICODE_BIDI_INDEX];
/* 2bits: type */
*bits = (*bits & ~UNICODE_BIDI_MASK) |
@@ -2111,7 +2117,7 @@ static inline css_error set_unicode_bidi(
static inline css_error set_visibility(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[VISIBILITY_INDEX];
+ uint8_t *bits = &style->i.bits[VISIBILITY_INDEX];
/* 2bits: type */
*bits = (*bits & ~VISIBILITY_MASK) |
@@ -2129,7 +2135,7 @@ static inline css_error set_visibility(
static inline css_error set_list_style_position(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[LIST_STYLE_POSITION_INDEX];
+ uint8_t *bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
/* 2bits: type */
*bits = (*bits & ~LIST_STYLE_POSITION_MASK) |
@@ -2147,7 +2153,7 @@ static inline css_error set_list_style_position(
static inline uint8_t set_text_align(
css_computed_style *style, uint8_t type)
{
- uint8_t *bits = &style->bits[TEXT_ALIGN_INDEX];
+ uint8_t *bits = &style->i.bits[TEXT_ALIGN_INDEX];
/* 4bits: type */
*bits = (*bits & ~TEXT_ALIGN_MASK) |
diff --git a/src/select/select.c b/src/select/select.c
index 92696ff..d484cc8 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -1178,7 +1178,7 @@ css_error set_initial(css_select_state *state,
if (error != CSS_OK)
return error;
} else if (group == GROUP_UNCOMMON &&
- state->computed->uncommon != NULL) {
+ state->computed->i.uncommon != NULL) {
error = prop_dispatch[prop].initial(state);
if (error != CSS_OK)
return error;
@@ -1188,7 +1188,7 @@ css_error set_initial(css_select_state *state,
if (error != CSS_OK)
return error;
} else if (group == GROUP_AURAL &&
- state->computed->aural != NULL) {
+ state->computed->i.aural != NULL) {
error = prop_dispatch[prop].initial(state);
if (error != CSS_OK)
return error;
-----------------------------------------------------------------------
Summary of changes:
Makefile | 16 ++++++++---
include/libcss/hint.h | 3 ++-
include/libcss/select.h | 4 +--
libcss.pc.in | 2 +-
src/select/select.c | 69 ++++++++++++++++++++++++-----------------------
test/dump.h | 7 ++---
test/select-common.c | 13 ++++-----
7 files changed, 64 insertions(+), 50 deletions(-)
diff --git a/Makefile b/Makefile
index 6fb7772..4a556ef 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,12 @@
+#!/bin/make
+#
+# Makefile for libcss
+#
+# Copyright 2009-1015 John-Mark Bell <jmb(a)netsurf-browser.org>
+
# Component settings
COMPONENT := css
-COMPONENT_VERSION := 0.4.0
+COMPONENT_VERSION := 0.5.0
# Default to a static library
COMPONENT_TYPE ?= lib-static
@@ -21,8 +27,10 @@ ifneq ($(HOST),i586-pc-haiku)
WARNFLAGS := $(WARNFLAGS) -Werror
endif
endif
-CFLAGS := -D_BSD_SOURCE -I$(CURDIR)/include/ \
- -I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS)
+
+CFLAGS := -D_BSD_SOURCE -D_DEFAULT_SOURCE \
+ -I$(CURDIR)/include/ -I$(CURDIR)/src \
+ $(WARNFLAGS) $(CFLAGS)
ifneq ($(GCCVER),2)
CFLAGS := $(CFLAGS) -std=c99
else
@@ -44,7 +52,7 @@ endif
include $(NSBUILD)/Makefile.top
# Extra installation rules
-I := /include/libcss
+I := /$(INCLUDEDIR)/libcss
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/libcss/computed.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/libcss/errors.h
diff --git a/include/libcss/hint.h b/include/libcss/hint.h
index c3e928d..629d2f6 100644
--- a/include/libcss/hint.h
+++ b/include/libcss/hint.h
@@ -49,7 +49,8 @@ typedef struct css_hint {
lwc_string **strings;
} data;
- uint8_t status;
+ uint32_t prop; /**< Property index */
+ uint8_t status; /**< Property value */
} css_hint;
#ifdef __cplusplus
diff --git a/include/libcss/select.h b/include/libcss/select.h
index d504e81..bd2fed2 100644
--- a/include/libcss/select.h
+++ b/include/libcss/select.h
@@ -117,8 +117,8 @@ typedef struct css_select_handler {
css_error (*node_is_lang)(void *pw, void *node,
lwc_string *lang, bool *match);
- css_error (*node_presentational_hint)(void *pw, void *node,
- uint32_t property, css_hint *hint);
+ css_error (*node_presentational_hint)(void *pw, void *node,
+ uint32_t *nhints, css_hint **hints);
css_error (*ua_default_for_property)(void *pw, uint32_t property,
css_hint *hint);
diff --git a/libcss.pc.in b/libcss.pc.in
index 695aa76..8df11b4 100644
--- a/libcss.pc.in
+++ b/libcss.pc.in
@@ -1,7 +1,7 @@
prefix=PREFIX
exec_prefix=${prefix}
libdir=${exec_prefix}/LIBDIR
-includedir=${prefix}/include
+includedir=${prefix}/INCLUDEDIR
Name: libcss
Description: CSS parsing and selection library
diff --git a/src/select/select.c b/src/select/select.c
index d484cc8..6c20b60 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -110,7 +110,7 @@ typedef struct css_select_rule_source {
} css_select_rule_source;
-static css_error set_hint(css_select_state *state, uint32_t prop);
+static css_error set_hint(css_select_state *state, css_hint *hint);
static css_error set_initial(css_select_state *state,
uint32_t prop, css_pseudo_element pseudo,
void *parent);
@@ -433,10 +433,11 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
css_select_handler *handler, void *pw,
css_select_results **result)
{
- uint32_t i, j;
+ uint32_t i, j, nhints;
css_error error;
css_select_state state;
void *parent = NULL;
+ css_hint *hints = NULL;
css_bloom *bloom = NULL;
css_bloom *parent_bloom = NULL;
@@ -536,6 +537,29 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
if (error != CSS_OK)
goto cleanup;
+ /* Apply presentational hints */
+ error = handler->node_presentational_hint(pw, node, &nhints, &hints);
+ if (error != CSS_OK)
+ goto cleanup;
+ if (nhints > 0) {
+ /* Ensure that the appropriate computed style exists */
+ struct css_computed_style *computed_style =
+ state.results->styles[CSS_PSEUDO_ELEMENT_NONE];
+ if (computed_style == NULL) {
+ error = css_computed_style_create(&computed_style);
+ if (error != CSS_OK)
+ return error;
+ }
+ state.results->styles[CSS_PSEUDO_ELEMENT_NONE] = computed_style;
+ state.computed = computed_style;
+
+ for (i = 0; i < nhints; i++) {
+ error = set_hint(&state, &hints[i]);
+ if (error != CSS_OK)
+ goto cleanup;
+ }
+ }
+
/* Iterate through the top-level stylesheets, selecting styles
* from those which apply to our current media requirements and
* are not disabled */
@@ -577,8 +601,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
}
}
- /* Take account of presentational hints and fix up any remaining
- * unset properties. */
+ /* Fix up any remaining unset properties. */
/* Base element */
state.current_pseudo = CSS_PSEUDO_ELEMENT_NONE;
@@ -587,17 +610,6 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
const prop_state *prop =
&state.props[i][CSS_PSEUDO_ELEMENT_NONE];
- /* Apply presentational hints if the property is unset or
- * the existing property value did not come from an author
- * stylesheet or a user sheet using !important. */
- if (prop->set == false ||
- (prop->origin != CSS_ORIGIN_AUTHOR &&
- prop->important == false)) {
- error = set_hint(&state, i);
- if (error != CSS_OK)
- goto cleanup;
- }
-
/* If the property is still unset or it's set to inherit
* and we're the root element, then set it to its initial
* value. */
@@ -1118,32 +1130,23 @@ void destroy_strings(css_select_ctx *ctx)
lwc_string_unref(ctx->after);
}
-css_error set_hint(css_select_state *state, uint32_t prop)
+css_error set_hint(css_select_state *state, css_hint *hint)
{
- css_hint hint;
+ uint32_t prop = hint->prop;
+ prop_state *existing = &state->props[prop][CSS_PSEUDO_ELEMENT_NONE];
css_error error;
- /* Initialise hint */
- memset(&hint, 0, sizeof(css_hint));
-
- /* Retrieve this property's hint from the client */
- error = state->handler->node_presentational_hint(state->pw,
- state->node, prop, &hint);
- if (error != CSS_OK)
- return (error == CSS_PROPERTY_NOT_SET) ? CSS_OK : error;
-
/* Hint defined -- set it in the result */
- error = prop_dispatch[prop].set_from_hint(&hint, state->computed);
+ error = prop_dispatch[prop].set_from_hint(hint, state->computed);
if (error != CSS_OK)
return error;
/* Keep selection state in sync with reality */
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].set = 1;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].specificity = 0;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].origin = CSS_ORIGIN_AUTHOR;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].important = 0;
- state->props[prop][CSS_PSEUDO_ELEMENT_NONE].inherit =
- (hint.status == 0);
+ existing->set = 1;
+ existing->specificity = 0;
+ existing->origin = CSS_ORIGIN_AUTHOR;
+ existing->important = 0;
+ existing->inherit = (hint->status == 0);
return CSS_OK;
}
diff --git a/test/dump.h b/test/dump.h
index 7ffec4f..fe53f69 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -734,13 +734,14 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
opcode_t op;
uint32_t value;
uint32_t opv = *((uint32_t *) bytecode);
+ uint32_t i;
ADVANCE(sizeof(opv));
op = getOpcode(opv);
*((*ptr)++) = '|';
- for (uint32_t i = 0; i < depth; i++)
+ for (i = 0; i < depth; i++)
*((*ptr)++) = ' ';
*ptr += sprintf(*ptr, "%s: ", opcode_names[op]);
@@ -2659,10 +2660,10 @@ void dump_font_face(css_font_face *font_face, char **ptr)
uint32_t i;
css_font_face_src *srcs = font_face->srcs;
for (i = 0; i < font_face->n_srcs; ++i) {
+ css_font_face_format format;
*ptr += sprintf(*ptr, "\n| src: ");
- css_font_face_format format =
- css_font_face_src_format(&srcs[i]);
+ format = css_font_face_src_format(&srcs[i]);
*ptr += sprintf(*ptr, "\n| format: ");
diff --git a/test/select-common.c b/test/select-common.c
index 42cdb76..c6d33c0 100644
--- a/test/select-common.c
+++ b/test/select-common.c
@@ -156,9 +156,9 @@ static css_error node_is_target(void *pw, void *node, bool *match);
static css_error node_is_lang(void *pw, void *node,
lwc_string *lang, bool *match);
static css_error node_presentational_hint(void *pw, void *node,
- uint32_t property, css_hint *hint);
+ uint32_t *nhints, css_hint **hints);
static css_error ua_default_for_property(void *pw, uint32_t property,
- css_hint *hint);
+ css_hint *hints);
static css_error compute_font_size(void *pw, const css_hint *parent,
css_hint *size);
static css_error set_libcss_node_data(void *pw, void *n,
@@ -1566,14 +1566,15 @@ css_error node_is_lang(void *pw, void *n,
}
css_error node_presentational_hint(void *pw, void *node,
- uint32_t property, css_hint *hint)
+ uint32_t *nhints, css_hint **hints)
{
UNUSED(pw);
UNUSED(node);
- UNUSED(property);
- UNUSED(hint);
- return CSS_PROPERTY_NOT_SET;
+ *nhints = 0;
+ *hints = NULL;
+
+ return CSS_OK;
}
css_error ua_default_for_property(void *pw, uint32_t property, css_hint *hint)
--
Cascading Style Sheets library
7 years, 10 months
netsurf: branch master updated. release/3.3-221-g3f3ac6e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3f3ac6e909e24d648417a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3f3ac6e909e24d648417ade...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3f3ac6e909e24d648417ade0a...
The branch, master has been updated
via 3f3ac6e909e24d648417ade0afa2de3e0ac9c1df (commit)
from 956283366b3fb2e91adffed6e66e21668d11747e (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/netsurf.git/commit/?id=3f3ac6e909e24d64841...
commit 3f3ac6e909e24d648417ade0afa2de3e0ac9c1df
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add some more nsurl compare unit tests to improve coverage
diff --git a/test/nsurl.c b/test/nsurl.c
index 514f3a6..d7faab3 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -532,6 +532,26 @@ static const struct test_compare compare_tests[] = {
"http://a/b/c/d;p?q",
NSURL_WITH_FRAGMENT,
true },
+
+ { "http://a.b.c/d?a",
+ "http://a.b.c/e?a",
+ NSURL_WITH_FRAGMENT,
+ false },
+
+ { "http://a.b.c/",
+ "http://g.h.i/",
+ NSURL_WITH_FRAGMENT,
+ false },
+
+ { "http://a.b.c/d?a",
+ "http://a.b.c/d?b",
+ NSURL_WITH_FRAGMENT,
+ false },
+
+ { "http://a.b.c/d?a",
+ "https://a.b.c/d?a",
+ NSURL_WITH_FRAGMENT,
+ false },
};
/**
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/test/nsurl.c b/test/nsurl.c
index 514f3a6..d7faab3 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -532,6 +532,26 @@ static const struct test_compare compare_tests[] = {
"http://a/b/c/d;p?q",
NSURL_WITH_FRAGMENT,
true },
+
+ { "http://a.b.c/d?a",
+ "http://a.b.c/e?a",
+ NSURL_WITH_FRAGMENT,
+ false },
+
+ { "http://a.b.c/",
+ "http://g.h.i/",
+ NSURL_WITH_FRAGMENT,
+ false },
+
+ { "http://a.b.c/d?a",
+ "http://a.b.c/d?b",
+ NSURL_WITH_FRAGMENT,
+ false },
+
+ { "http://a.b.c/d?a",
+ "https://a.b.c/d?a",
+ NSURL_WITH_FRAGMENT,
+ false },
};
/**
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-220-g9562833
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/956283366b3fb2e91adff...
...commit http://git.netsurf-browser.org/netsurf.git/commit/956283366b3fb2e91adffed...
...tree http://git.netsurf-browser.org/netsurf.git/tree/956283366b3fb2e91adffed6e...
The branch, master has been updated
via 956283366b3fb2e91adffed6e66e21668d11747e (commit)
from 22023d616a57286cb9d99489957489ba103e07c0 (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/netsurf.git/commit/?id=956283366b3fb2e91ad...
commit 956283366b3fb2e91adffed6e66e21668d11747e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Complete API coverage in nsurl unit test
diff --git a/test/nsurl.c b/test/nsurl.c
index 08e6a82..514f3a6 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -630,6 +630,120 @@ START_TEST(nsurl_has_component_test)
}
END_TEST
+static const struct test_pairs fragment_tests[] = {
+ { "http://www.f.org/a/b/c#def", "http://www.f.org/a/b/c" },
+};
+
+/**
+ * defragment url
+ */
+START_TEST(nsurl_defragment_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct test_pairs *tst = &fragment_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_defragment(url, &res_url);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res_url), tst->res);
+
+ nsurl_unref(res_url);
+ }
+ nsurl_unref(url);
+
+}
+END_TEST
+
+/**
+ * refragment url
+ */
+START_TEST(nsurl_refragment_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct test_pairs *tst = &fragment_tests[_i];
+ lwc_string *frag;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &url);
+ ck_assert(err == NSERROR_OK);
+
+ /* grab the fragment - not testing should succeed */
+ frag = nsurl_get_component(url, NSURL_FRAGMENT);
+ ck_assert(frag != NULL);
+ nsurl_unref(url);
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->res, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_refragment(url, frag, &res_url);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res_url), tst->test);
+
+ nsurl_unref(res_url);
+ }
+
+ lwc_string_unref(frag);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+static const struct test_pairs parent_tests[] = {
+ { "http://www.f.org/a/b/c", "http://www.f.org/a/b/" },
+};
+
+/**
+ * generate parent url
+ */
+START_TEST(nsurl_parent_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct test_pairs *tst = &parent_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_parent(url, &res_url);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res_url), tst->res);
+
+ nsurl_unref(res_url);
+ }
+ nsurl_unref(url);
+
+}
+END_TEST
+
+
/**
* url reference (copy) and unreference(free)
*/
@@ -1043,7 +1157,9 @@ Suite *nsurl_suite(void)
TCase *tc_replace_query;
TCase *tc_join;
TCase *tc_compare;
+ TCase *tc_fragment;
TCase *tc_component;
+ TCase *tc_parent;
s = suite_create("nsurl");
@@ -1183,7 +1299,6 @@ Suite *nsurl_suite(void)
tcase_add_loop_test(tc_join,
nsurl_join_test,
0, NELEMS(join_tests));
-
tcase_add_loop_test(tc_join,
nsurl_join_complex_test,
0, NELEMS(join_complex_tests));
@@ -1204,6 +1319,23 @@ Suite *nsurl_suite(void)
suite_add_tcase(s, tc_compare);
+ /* fragment */
+ tc_fragment = tcase_create("Fragment");
+
+ tcase_add_unchecked_fixture(tc_fragment,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_fragment,
+ nsurl_defragment_test,
+ 0, NELEMS(parent_tests));
+ tcase_add_loop_test(tc_fragment,
+ nsurl_refragment_test,
+ 0, NELEMS(parent_tests));
+
+ suite_add_tcase(s, tc_fragment);
+
+
/* component */
tc_component = tcase_create("Component");
@@ -1214,13 +1346,26 @@ Suite *nsurl_suite(void)
tcase_add_loop_test(tc_component,
nsurl_get_component_test,
0, NELEMS(component_tests));
-
tcase_add_loop_test(tc_component,
nsurl_has_component_test,
0, NELEMS(component_tests));
suite_add_tcase(s, tc_component);
+
+ /* parent */
+ tc_parent = tcase_create("Parent");
+
+ tcase_add_unchecked_fixture(tc_parent,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_parent,
+ nsurl_parent_test,
+ 0, NELEMS(parent_tests));
+
+ suite_add_tcase(s, tc_parent);
+
return s;
}
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 147 insertions(+), 2 deletions(-)
diff --git a/test/nsurl.c b/test/nsurl.c
index 08e6a82..514f3a6 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -630,6 +630,120 @@ START_TEST(nsurl_has_component_test)
}
END_TEST
+static const struct test_pairs fragment_tests[] = {
+ { "http://www.f.org/a/b/c#def", "http://www.f.org/a/b/c" },
+};
+
+/**
+ * defragment url
+ */
+START_TEST(nsurl_defragment_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct test_pairs *tst = &fragment_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_defragment(url, &res_url);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res_url), tst->res);
+
+ nsurl_unref(res_url);
+ }
+ nsurl_unref(url);
+
+}
+END_TEST
+
+/**
+ * refragment url
+ */
+START_TEST(nsurl_refragment_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct test_pairs *tst = &fragment_tests[_i];
+ lwc_string *frag;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &url);
+ ck_assert(err == NSERROR_OK);
+
+ /* grab the fragment - not testing should succeed */
+ frag = nsurl_get_component(url, NSURL_FRAGMENT);
+ ck_assert(frag != NULL);
+ nsurl_unref(url);
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->res, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_refragment(url, frag, &res_url);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res_url), tst->test);
+
+ nsurl_unref(res_url);
+ }
+
+ lwc_string_unref(frag);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+static const struct test_pairs parent_tests[] = {
+ { "http://www.f.org/a/b/c", "http://www.f.org/a/b/" },
+};
+
+/**
+ * generate parent url
+ */
+START_TEST(nsurl_parent_test)
+{
+ nserror err;
+ nsurl *url;
+ nsurl *res_url;
+ const struct test_pairs *tst = &parent_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_parent(url, &res_url);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res_url), tst->res);
+
+ nsurl_unref(res_url);
+ }
+ nsurl_unref(url);
+
+}
+END_TEST
+
+
/**
* url reference (copy) and unreference(free)
*/
@@ -1043,7 +1157,9 @@ Suite *nsurl_suite(void)
TCase *tc_replace_query;
TCase *tc_join;
TCase *tc_compare;
+ TCase *tc_fragment;
TCase *tc_component;
+ TCase *tc_parent;
s = suite_create("nsurl");
@@ -1183,7 +1299,6 @@ Suite *nsurl_suite(void)
tcase_add_loop_test(tc_join,
nsurl_join_test,
0, NELEMS(join_tests));
-
tcase_add_loop_test(tc_join,
nsurl_join_complex_test,
0, NELEMS(join_complex_tests));
@@ -1204,6 +1319,23 @@ Suite *nsurl_suite(void)
suite_add_tcase(s, tc_compare);
+ /* fragment */
+ tc_fragment = tcase_create("Fragment");
+
+ tcase_add_unchecked_fixture(tc_fragment,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_fragment,
+ nsurl_defragment_test,
+ 0, NELEMS(parent_tests));
+ tcase_add_loop_test(tc_fragment,
+ nsurl_refragment_test,
+ 0, NELEMS(parent_tests));
+
+ suite_add_tcase(s, tc_fragment);
+
+
/* component */
tc_component = tcase_create("Component");
@@ -1214,13 +1346,26 @@ Suite *nsurl_suite(void)
tcase_add_loop_test(tc_component,
nsurl_get_component_test,
0, NELEMS(component_tests));
-
tcase_add_loop_test(tc_component,
nsurl_has_component_test,
0, NELEMS(component_tests));
suite_add_tcase(s, tc_component);
+
+ /* parent */
+ tc_parent = tcase_create("Parent");
+
+ tcase_add_unchecked_fixture(tc_parent,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_parent,
+ nsurl_parent_test,
+ 0, NELEMS(parent_tests));
+
+ suite_add_tcase(s, tc_parent);
+
return s;
}
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-219-g22023d6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/22023d616a57286cb9d99...
...commit http://git.netsurf-browser.org/netsurf.git/commit/22023d616a57286cb9d9948...
...tree http://git.netsurf-browser.org/netsurf.git/tree/22023d616a57286cb9d994899...
The branch, master has been updated
via 22023d616a57286cb9d99489957489ba103e07c0 (commit)
from e5ff82ff529b66a278c4489a7ef107000b0eb540 (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/netsurf.git/commit/?id=22023d616a57286cb9d...
commit 22023d616a57286cb9d99489957489ba103e07c0
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add nsurl unit tests for the component handling parts of the API
diff --git a/test/nsurl.c b/test/nsurl.c
index 1f4111b..08e6a82 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -562,6 +562,74 @@ START_TEST(nsurl_compare_test)
}
END_TEST
+
+/**
+ * url component tests
+ *
+ * each test1 parameter is converted to a url and
+ * nsurl[get|has]_component called on it with the given part. The
+ * result is checked against test1 and res as approprite.
+ */
+static const struct test_compare component_tests[] = {
+ { "http://a/b/c/d;p?q",
+ "http",
+ NSURL_SCHEME,
+ true },
+
+ { "file:///",
+ NULL,
+ NSURL_HOST,
+ false },
+
+};
+
+/**
+ * get component
+ */
+START_TEST(nsurl_get_component_test)
+{
+ nserror err;
+ nsurl *url1;
+ const struct test_compare *tst = &component_tests[_i];
+ lwc_string *cmpnt;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &url1);
+ ck_assert(err == NSERROR_OK);
+
+ cmpnt = nsurl_get_component(url1, tst->parts);
+ if (cmpnt == NULL) {
+ ck_assert(tst->test2 == NULL);
+ } else {
+ ck_assert_str_eq(lwc_string_data(cmpnt), tst->test2);
+ lwc_string_unref(cmpnt);
+ }
+
+ nsurl_unref(url1);
+}
+END_TEST
+
+/**
+ * has component
+ */
+START_TEST(nsurl_has_component_test)
+{
+ nserror err;
+ nsurl *url1;
+ const struct test_compare *tst = &component_tests[_i];
+ bool status;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &url1);
+ ck_assert(err == NSERROR_OK);
+
+ status = nsurl_has_component(url1, tst->parts);
+ ck_assert(status == tst->res);
+
+ nsurl_unref(url1);
+}
+END_TEST
+
/**
* url reference (copy) and unreference(free)
*/
@@ -975,6 +1043,7 @@ Suite *nsurl_suite(void)
TCase *tc_replace_query;
TCase *tc_join;
TCase *tc_compare;
+ TCase *tc_component;
s = suite_create("nsurl");
@@ -1135,6 +1204,23 @@ Suite *nsurl_suite(void)
suite_add_tcase(s, tc_compare);
+ /* component */
+ tc_component = tcase_create("Component");
+
+ tcase_add_unchecked_fixture(tc_component,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_component,
+ nsurl_get_component_test,
+ 0, NELEMS(component_tests));
+
+ tcase_add_loop_test(tc_component,
+ nsurl_has_component_test,
+ 0, NELEMS(component_tests));
+
+ suite_add_tcase(s, tc_component);
+
return s;
}
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/test/nsurl.c b/test/nsurl.c
index 1f4111b..08e6a82 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -562,6 +562,74 @@ START_TEST(nsurl_compare_test)
}
END_TEST
+
+/**
+ * url component tests
+ *
+ * each test1 parameter is converted to a url and
+ * nsurl[get|has]_component called on it with the given part. The
+ * result is checked against test1 and res as approprite.
+ */
+static const struct test_compare component_tests[] = {
+ { "http://a/b/c/d;p?q",
+ "http",
+ NSURL_SCHEME,
+ true },
+
+ { "file:///",
+ NULL,
+ NSURL_HOST,
+ false },
+
+};
+
+/**
+ * get component
+ */
+START_TEST(nsurl_get_component_test)
+{
+ nserror err;
+ nsurl *url1;
+ const struct test_compare *tst = &component_tests[_i];
+ lwc_string *cmpnt;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &url1);
+ ck_assert(err == NSERROR_OK);
+
+ cmpnt = nsurl_get_component(url1, tst->parts);
+ if (cmpnt == NULL) {
+ ck_assert(tst->test2 == NULL);
+ } else {
+ ck_assert_str_eq(lwc_string_data(cmpnt), tst->test2);
+ lwc_string_unref(cmpnt);
+ }
+
+ nsurl_unref(url1);
+}
+END_TEST
+
+/**
+ * has component
+ */
+START_TEST(nsurl_has_component_test)
+{
+ nserror err;
+ nsurl *url1;
+ const struct test_compare *tst = &component_tests[_i];
+ bool status;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &url1);
+ ck_assert(err == NSERROR_OK);
+
+ status = nsurl_has_component(url1, tst->parts);
+ ck_assert(status == tst->res);
+
+ nsurl_unref(url1);
+}
+END_TEST
+
/**
* url reference (copy) and unreference(free)
*/
@@ -975,6 +1043,7 @@ Suite *nsurl_suite(void)
TCase *tc_replace_query;
TCase *tc_join;
TCase *tc_compare;
+ TCase *tc_component;
s = suite_create("nsurl");
@@ -1135,6 +1204,23 @@ Suite *nsurl_suite(void)
suite_add_tcase(s, tc_compare);
+ /* component */
+ tc_component = tcase_create("Component");
+
+ tcase_add_unchecked_fixture(tc_component,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_component,
+ nsurl_get_component_test,
+ 0, NELEMS(component_tests));
+
+ tcase_add_loop_test(tc_component,
+ nsurl_has_component_test,
+ 0, NELEMS(component_tests));
+
+ suite_add_tcase(s, tc_component);
+
return s;
}
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-218-ge5ff82f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e5ff82ff529b66a278c44...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e5ff82ff529b66a278c4489...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e5ff82ff529b66a278c4489a7...
The branch, master has been updated
via e5ff82ff529b66a278c4489a7ef107000b0eb540 (commit)
from 2e7b69be0a7e2000f2a40c0607f1def6c9c92ca1 (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/netsurf.git/commit/?id=e5ff82ff529b66a278c...
commit e5ff82ff529b66a278c4489a7ef107000b0eb540
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Improve nsurl unit test to exercise the compare API
diff --git a/test/nsurl.c b/test/nsurl.c
index 87058f2..1f4111b 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -46,6 +46,13 @@ struct test_triplets {
const char* res;
};
+struct test_compare {
+ const char* test1;
+ const char* test2;
+ nsurl_component parts;
+ bool res;
+};
+
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
fprintf(stderr,
@@ -518,6 +525,44 @@ END_TEST
/**
+ * url comparison tests
+ */
+static const struct test_compare compare_tests[] = {
+ { "http://a/b/c/d;p?q",
+ "http://a/b/c/d;p?q",
+ NSURL_WITH_FRAGMENT,
+ true },
+};
+
+/**
+ * compare
+ */
+START_TEST(nsurl_compare_test)
+{
+ nserror err;
+ nsurl *url1;
+ nsurl *url2;
+ const struct test_compare *tst = &compare_tests[_i];
+ bool status;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &url1);
+ ck_assert(err == NSERROR_OK);
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test2, &url2);
+ ck_assert(err == NSERROR_OK);
+
+ status = nsurl_compare(url1, url2, tst->parts);
+ ck_assert(status == tst->res);
+
+ nsurl_unref(url1);
+ nsurl_unref(url2);
+
+}
+END_TEST
+
+/**
* url reference (copy) and unreference(free)
*/
START_TEST(nsurl_ref_test)
@@ -929,6 +974,7 @@ Suite *nsurl_suite(void)
TCase *tc_nice_strip;
TCase *tc_replace_query;
TCase *tc_join;
+ TCase *tc_compare;
s = suite_create("nsurl");
@@ -1075,6 +1121,20 @@ Suite *nsurl_suite(void)
suite_add_tcase(s, tc_join);
+
+ /* url compare */
+ tc_compare = tcase_create("Compare");
+
+ tcase_add_unchecked_fixture(tc_compare,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_compare,
+ nsurl_compare_test,
+ 0, NELEMS(compare_tests));
+
+ suite_add_tcase(s, tc_compare);
+
return s;
}
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/test/nsurl.c b/test/nsurl.c
index 87058f2..1f4111b 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -46,6 +46,13 @@ struct test_triplets {
const char* res;
};
+struct test_compare {
+ const char* test1;
+ const char* test2;
+ nsurl_component parts;
+ bool res;
+};
+
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
fprintf(stderr,
@@ -518,6 +525,44 @@ END_TEST
/**
+ * url comparison tests
+ */
+static const struct test_compare compare_tests[] = {
+ { "http://a/b/c/d;p?q",
+ "http://a/b/c/d;p?q",
+ NSURL_WITH_FRAGMENT,
+ true },
+};
+
+/**
+ * compare
+ */
+START_TEST(nsurl_compare_test)
+{
+ nserror err;
+ nsurl *url1;
+ nsurl *url2;
+ const struct test_compare *tst = &compare_tests[_i];
+ bool status;
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &url1);
+ ck_assert(err == NSERROR_OK);
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test2, &url2);
+ ck_assert(err == NSERROR_OK);
+
+ status = nsurl_compare(url1, url2, tst->parts);
+ ck_assert(status == tst->res);
+
+ nsurl_unref(url1);
+ nsurl_unref(url2);
+
+}
+END_TEST
+
+/**
* url reference (copy) and unreference(free)
*/
START_TEST(nsurl_ref_test)
@@ -929,6 +974,7 @@ Suite *nsurl_suite(void)
TCase *tc_nice_strip;
TCase *tc_replace_query;
TCase *tc_join;
+ TCase *tc_compare;
s = suite_create("nsurl");
@@ -1075,6 +1121,20 @@ Suite *nsurl_suite(void)
suite_add_tcase(s, tc_join);
+
+ /* url compare */
+ tc_compare = tcase_create("Compare");
+
+ tcase_add_unchecked_fixture(tc_compare,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_compare,
+ nsurl_compare_test,
+ 0, NELEMS(compare_tests));
+
+ suite_add_tcase(s, tc_compare);
+
return s;
}
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-217-g2e7b69b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2e7b69be0a7e2000f2a40...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2e7b69be0a7e2000f2a40c0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2e7b69be0a7e2000f2a40c060...
The branch, master has been updated
via 2e7b69be0a7e2000f2a40c0607f1def6c9c92ca1 (commit)
from 94b5c956766a3f1ee916f2bb946c3d9273c90ae1 (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/netsurf.git/commit/?id=2e7b69be0a7e2000f2a...
commit 2e7b69be0a7e2000f2a40c0607f1def6c9c92ca1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Extend bloom filter test to check item count is correct
diff --git a/test/bloom.c b/test/bloom.c
index dd3220e..8d8c21c 100644
--- a/test/bloom.c
+++ b/test/bloom.c
@@ -77,9 +77,13 @@ START_TEST(bloom_create_test)
{
struct bloom_filter *b;
b = bloom_create(BLOOM_SIZE);
+
bloom_insert_str(b, "NetSurf", 7);
ck_assert(bloom_search_str(b, "NetSurf", 7));
ck_assert(!bloom_search_str(b, "NotSurf", 7));
+
+ ck_assert(bloom_items(b) == 1);
+
bloom_destroy(b);
}
END_TEST
-----------------------------------------------------------------------
Summary of changes:
test/bloom.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/test/bloom.c b/test/bloom.c
index dd3220e..8d8c21c 100644
--- a/test/bloom.c
+++ b/test/bloom.c
@@ -77,9 +77,13 @@ START_TEST(bloom_create_test)
{
struct bloom_filter *b;
b = bloom_create(BLOOM_SIZE);
+
bloom_insert_str(b, "NetSurf", 7);
ck_assert(bloom_search_str(b, "NetSurf", 7));
ck_assert(!bloom_search_str(b, "NotSurf", 7));
+
+ ck_assert(bloom_items(b) == 1);
+
bloom_destroy(b);
}
END_TEST
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-216-g94b5c95
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/94b5c956766a3f1ee916f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/94b5c956766a3f1ee916f2b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/94b5c956766a3f1ee916f2bb9...
The branch, master has been updated
via 94b5c956766a3f1ee916f2bb946c3d9273c90ae1 (commit)
from 7b2d15a036bf4ef67eb88cfee23272d564c4a766 (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/netsurf.git/commit/?id=94b5c956766a3f1ee91...
commit 94b5c956766a3f1ee916f2bb946c3d9273c90ae1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add unit test for bloom filter
Adds check based unit test for teh bloom filter implementation. This
is based on Roberts original test code in utils/bloom.c and uses
/usr/share/dict as a source of strings to check bloom creation, no
false negatives and the false positive rate is below 15%.
diff --git a/test/Makefile b/test/Makefile
index 9db5030..06f6943 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,7 +1,7 @@
#
# NetSurf unit tests
-TESTS := nsurl urldbtest nsoption #llcache
+TESTS := nsurl urldbtest nsoption bloom #llcache
# nsurl sources and flags
nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
@@ -28,7 +28,8 @@ llcache_SRCS := content/fetch.c content/fetchers/curl.c \
nsoption_SRCS := utils/nsoption.c \
test/log.c test/nsoption.c
-
+bloom_SRCS := utils/bloom.c \
+ test/bloom.c
# Coverage builds need additional flags
ifeq ($(MAKECMDGOALS),coverage)
diff --git a/test/bloom.c b/test/bloom.c
new file mode 100644
index 0000000..dd3220e
--- /dev/null
+++ b/test/bloom.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
+ * Copyright 2013 Rob Kendrick <rjek(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Test bloom filter operations.
+ *
+ * Implementation taken from original test rig in bloom filter code
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <check.h>
+
+#include "utils/bloom.h"
+
+#define BLOOM_SIZE 8192
+#define FALSE_POSITIVE_RATE 15 /* acceptable false positive percentage rate */
+
+static struct bloom_filter *dict_bloom;
+
+/* Fixtures */
+
+
+/**
+ * create dictionary bloom
+ *
+ * bloom constructed from the first BLOOM_SIZE entries of the
+ * dictionary
+ */
+static void dict_bloom_create(void)
+{
+ FILE *dictf;
+ char buf[BUFSIZ];
+ int i;
+
+ dictf = fopen("/usr/share/dict/words", "r");
+ ck_assert(dictf != NULL);
+
+ dict_bloom = bloom_create(BLOOM_SIZE);
+ ck_assert(dict_bloom != NULL);
+
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ bloom_insert_str(dict_bloom, buf, strlen(buf));
+ }
+
+ fclose(dictf);
+}
+
+static void dict_bloom_teardown(void)
+{
+ bloom_destroy(dict_bloom);
+}
+
+/* Tests */
+
+START_TEST(bloom_create_test)
+{
+ struct bloom_filter *b;
+ b = bloom_create(BLOOM_SIZE);
+ bloom_insert_str(b, "NetSurf", 7);
+ ck_assert(bloom_search_str(b, "NetSurf", 7));
+ ck_assert(!bloom_search_str(b, "NotSurf", 7));
+ bloom_destroy(b);
+}
+END_TEST
+
+START_TEST(bloom_match_test)
+{
+ FILE *dictf;
+ char buf[BUFSIZ];
+ int i;
+
+ dictf = fopen("/usr/share/dict/words", "r");
+ ck_assert(dictf != NULL);
+
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ ck_assert(bloom_search_str(dict_bloom, buf, strlen(buf)));
+ }
+ fclose(dictf);
+}
+END_TEST
+
+START_TEST(bloom_falsepositive_test)
+{
+ FILE *dictf;
+ char buf[BUFSIZ];
+ int i;
+ int false_positives = 0;
+
+ dictf = fopen("/usr/share/dict/words", "r");
+ ck_assert(dictf != NULL);
+
+ /* skip elements known presnent */
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ }
+
+ /* false positives are possible we are checking for low rate */
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ if (bloom_search_str(dict_bloom, buf, strlen(buf)) == true)
+ false_positives++;
+ }
+ fclose(dictf);
+
+ printf("false positive rate %d%%/%d%%\n",
+ (false_positives * 100)/BLOOM_SIZE,
+ FALSE_POSITIVE_RATE);
+ ck_assert(false_positives < ((BLOOM_SIZE * FALSE_POSITIVE_RATE) / 100));
+}
+END_TEST
+
+
+/* Suite */
+
+Suite *bloom_suite(void)
+{
+ Suite *s;
+ TCase *tc_create;
+ TCase *tc_match;
+ TCase *tc_falsepositive;
+
+ s = suite_create("Bloom filter");
+
+ /* Basic API creation */
+ tc_create = tcase_create("Creation");
+
+ tcase_add_test(tc_create, bloom_create_test);
+
+ suite_add_tcase(s, tc_create);
+
+
+ /* Matching entry tests */
+ tc_match = tcase_create("Match");
+
+ tcase_add_checked_fixture(tc_match,
+ dict_bloom_create,
+ dict_bloom_teardown);
+
+ tcase_add_test(tc_match, bloom_match_test);
+
+ suite_add_tcase(s, tc_match);
+
+
+ /* Not matching tests */
+ tc_falsepositive = tcase_create("False positive rate");
+
+ tcase_add_checked_fixture(tc_falsepositive,
+ dict_bloom_create,
+ dict_bloom_teardown);
+
+ tcase_add_test(tc_falsepositive, bloom_falsepositive_test);
+
+ suite_add_tcase(s, tc_falsepositive);
+
+ return s;
+}
+
+int main(int argc, char **argv)
+{
+ int number_failed;
+ Suite *s;
+ SRunner *sr;
+
+ s = bloom_suite();
+
+ sr = srunner_create(s);
+ srunner_run_all(sr, CK_ENV);
+
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/utils/bloom.c b/utils/bloom.c
index df9e76e..e51ee63 100644
--- a/utils/bloom.c
+++ b/utils/bloom.c
@@ -16,8 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Trivial bloom filter */
+/**
+ * \file
+ * Trivial bloom filter
+ */
#include <stdlib.h>
#include "utils/bloom.h"
@@ -107,58 +109,3 @@ uint32_t bloom_items(struct bloom_filter *b)
return b->items;
}
-#ifdef TEST_RIG
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-int main(int argc, char *arg[])
-{
- struct bloom_filter *b = bloom_create(8192);
- FILE *dict = fopen("/usr/share/dict/words", "r");
- char buf[BUFSIZ];
- int false_positives = 0, total = 0;
-
- for (int i = 0; i < 8192; i++) {
- fscanf(dict, "%s", buf);
- printf("adding %s\n", buf);
- bloom_insert_str(b, buf, strlen(buf));
- }
-
- printf("adding NetSurf\n");
-
- bloom_insert_str(b, "NetSurf", 7);
- printf("checking NetSurf (should be true)\n");
- assert(bloom_search_str(b, "NetSurf", 7));
-
- fseek(dict, 0, SEEK_SET);
-
- for (int i = 0; i < 8192; i++) {
- fscanf(dict, "%s", buf);
- printf("checking %s (should be true)\n", buf);
- assert(bloom_search_str(b, buf, strlen(buf)));
-
- total++;
- }
-
- for (int i = 0; i < 8192; i++) {
- fscanf(dict, "%s", buf);
- printf("checking %s (should be false)\n", buf);
- if (bloom_search_str(b, buf, strlen(buf)) == true)
- false_positives++;
- total++;
- }
-
- printf("false positives: %d of %d, %f%%\n",
- false_positives, total,
- ((float)false_positives / total) * 100);
-
- fclose(dict);
- bloom_destroy(b);
-
- return 0;
-}
-
-#endif /* TEST_RIG */
-
-----------------------------------------------------------------------
Summary of changes:
test/Makefile | 5 +-
test/bloom.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
utils/bloom.c | 61 ++----------------
3 files changed, 202 insertions(+), 59 deletions(-)
create mode 100644 test/bloom.c
diff --git a/test/Makefile b/test/Makefile
index 9db5030..06f6943 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,7 +1,7 @@
#
# NetSurf unit tests
-TESTS := nsurl urldbtest nsoption #llcache
+TESTS := nsurl urldbtest nsoption bloom #llcache
# nsurl sources and flags
nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
@@ -28,7 +28,8 @@ llcache_SRCS := content/fetch.c content/fetchers/curl.c \
nsoption_SRCS := utils/nsoption.c \
test/log.c test/nsoption.c
-
+bloom_SRCS := utils/bloom.c \
+ test/bloom.c
# Coverage builds need additional flags
ifeq ($(MAKECMDGOALS),coverage)
diff --git a/test/bloom.c b/test/bloom.c
new file mode 100644
index 0000000..dd3220e
--- /dev/null
+++ b/test/bloom.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
+ * Copyright 2013 Rob Kendrick <rjek(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Test bloom filter operations.
+ *
+ * Implementation taken from original test rig in bloom filter code
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <check.h>
+
+#include "utils/bloom.h"
+
+#define BLOOM_SIZE 8192
+#define FALSE_POSITIVE_RATE 15 /* acceptable false positive percentage rate */
+
+static struct bloom_filter *dict_bloom;
+
+/* Fixtures */
+
+
+/**
+ * create dictionary bloom
+ *
+ * bloom constructed from the first BLOOM_SIZE entries of the
+ * dictionary
+ */
+static void dict_bloom_create(void)
+{
+ FILE *dictf;
+ char buf[BUFSIZ];
+ int i;
+
+ dictf = fopen("/usr/share/dict/words", "r");
+ ck_assert(dictf != NULL);
+
+ dict_bloom = bloom_create(BLOOM_SIZE);
+ ck_assert(dict_bloom != NULL);
+
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ bloom_insert_str(dict_bloom, buf, strlen(buf));
+ }
+
+ fclose(dictf);
+}
+
+static void dict_bloom_teardown(void)
+{
+ bloom_destroy(dict_bloom);
+}
+
+/* Tests */
+
+START_TEST(bloom_create_test)
+{
+ struct bloom_filter *b;
+ b = bloom_create(BLOOM_SIZE);
+ bloom_insert_str(b, "NetSurf", 7);
+ ck_assert(bloom_search_str(b, "NetSurf", 7));
+ ck_assert(!bloom_search_str(b, "NotSurf", 7));
+ bloom_destroy(b);
+}
+END_TEST
+
+START_TEST(bloom_match_test)
+{
+ FILE *dictf;
+ char buf[BUFSIZ];
+ int i;
+
+ dictf = fopen("/usr/share/dict/words", "r");
+ ck_assert(dictf != NULL);
+
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ ck_assert(bloom_search_str(dict_bloom, buf, strlen(buf)));
+ }
+ fclose(dictf);
+}
+END_TEST
+
+START_TEST(bloom_falsepositive_test)
+{
+ FILE *dictf;
+ char buf[BUFSIZ];
+ int i;
+ int false_positives = 0;
+
+ dictf = fopen("/usr/share/dict/words", "r");
+ ck_assert(dictf != NULL);
+
+ /* skip elements known presnent */
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ }
+
+ /* false positives are possible we are checking for low rate */
+ for (i = 0; i < BLOOM_SIZE; i++) {
+ fscanf(dictf, "%s", buf);
+ if (bloom_search_str(dict_bloom, buf, strlen(buf)) == true)
+ false_positives++;
+ }
+ fclose(dictf);
+
+ printf("false positive rate %d%%/%d%%\n",
+ (false_positives * 100)/BLOOM_SIZE,
+ FALSE_POSITIVE_RATE);
+ ck_assert(false_positives < ((BLOOM_SIZE * FALSE_POSITIVE_RATE) / 100));
+}
+END_TEST
+
+
+/* Suite */
+
+Suite *bloom_suite(void)
+{
+ Suite *s;
+ TCase *tc_create;
+ TCase *tc_match;
+ TCase *tc_falsepositive;
+
+ s = suite_create("Bloom filter");
+
+ /* Basic API creation */
+ tc_create = tcase_create("Creation");
+
+ tcase_add_test(tc_create, bloom_create_test);
+
+ suite_add_tcase(s, tc_create);
+
+
+ /* Matching entry tests */
+ tc_match = tcase_create("Match");
+
+ tcase_add_checked_fixture(tc_match,
+ dict_bloom_create,
+ dict_bloom_teardown);
+
+ tcase_add_test(tc_match, bloom_match_test);
+
+ suite_add_tcase(s, tc_match);
+
+
+ /* Not matching tests */
+ tc_falsepositive = tcase_create("False positive rate");
+
+ tcase_add_checked_fixture(tc_falsepositive,
+ dict_bloom_create,
+ dict_bloom_teardown);
+
+ tcase_add_test(tc_falsepositive, bloom_falsepositive_test);
+
+ suite_add_tcase(s, tc_falsepositive);
+
+ return s;
+}
+
+int main(int argc, char **argv)
+{
+ int number_failed;
+ Suite *s;
+ SRunner *sr;
+
+ s = bloom_suite();
+
+ sr = srunner_create(s);
+ srunner_run_all(sr, CK_ENV);
+
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/utils/bloom.c b/utils/bloom.c
index df9e76e..e51ee63 100644
--- a/utils/bloom.c
+++ b/utils/bloom.c
@@ -16,8 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Trivial bloom filter */
+/**
+ * \file
+ * Trivial bloom filter
+ */
#include <stdlib.h>
#include "utils/bloom.h"
@@ -107,58 +109,3 @@ uint32_t bloom_items(struct bloom_filter *b)
return b->items;
}
-#ifdef TEST_RIG
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-int main(int argc, char *arg[])
-{
- struct bloom_filter *b = bloom_create(8192);
- FILE *dict = fopen("/usr/share/dict/words", "r");
- char buf[BUFSIZ];
- int false_positives = 0, total = 0;
-
- for (int i = 0; i < 8192; i++) {
- fscanf(dict, "%s", buf);
- printf("adding %s\n", buf);
- bloom_insert_str(b, buf, strlen(buf));
- }
-
- printf("adding NetSurf\n");
-
- bloom_insert_str(b, "NetSurf", 7);
- printf("checking NetSurf (should be true)\n");
- assert(bloom_search_str(b, "NetSurf", 7));
-
- fseek(dict, 0, SEEK_SET);
-
- for (int i = 0; i < 8192; i++) {
- fscanf(dict, "%s", buf);
- printf("checking %s (should be true)\n", buf);
- assert(bloom_search_str(b, buf, strlen(buf)));
-
- total++;
- }
-
- for (int i = 0; i < 8192; i++) {
- fscanf(dict, "%s", buf);
- printf("checking %s (should be false)\n", buf);
- if (bloom_search_str(b, buf, strlen(buf)) == true)
- false_positives++;
- total++;
- }
-
- printf("false positives: %d of %d, %f%%\n",
- false_positives, total,
- ((float)false_positives / total) * 100);
-
- fclose(dict);
- bloom_destroy(b);
-
- return 0;
-}
-
-#endif /* TEST_RIG */
-
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-215-g7b2d15a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7b2d15a036bf4ef67eb88...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7b2d15a036bf4ef67eb88cf...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7b2d15a036bf4ef67eb88cfee...
The branch, master has been updated
via 7b2d15a036bf4ef67eb88cfee23272d564c4a766 (commit)
from 5b09363597d9586ec421817459efe8a242c953c8 (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/netsurf.git/commit/?id=7b2d15a036bf4ef67eb...
commit 7b2d15a036bf4ef67eb88cfee23272d564c4a766
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add tests for all asserts in nsurl API and for access and access_leaf
diff --git a/test/nsurl.c b/test/nsurl.c
index 66a3c8f..87058f2 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -1,4 +1,5 @@
/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
* Copyright 2011 John Mark Bell <jmb(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
@@ -109,6 +110,108 @@ static const struct test_pairs create_tests[] = {
};
+/**
+ * url creation test
+ */
+START_TEST(nsurl_create_test)
+{
+ nserror err;
+ nsurl *res;
+ const struct test_pairs *tst = &create_tests[_i];
+
+ err = nsurl_create(tst->test, &res);
+ if (tst->res == NULL) {
+ /* result must be invalid */
+ ck_assert(err != NSERROR_OK);
+
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res), tst->res);
+
+ nsurl_unref(res);
+ }
+}
+END_TEST
+
+static const struct test_triplets access_tests[] = {
+ { "http://www.netsurf-browser.org/a/big/tree",
+ "http://www.netsurf-browser.org/a/big/tree",
+ "tree" },
+
+ { "HTTP://ci.netsurf-browser.org/jenkins/view/Unit Tests/job/coverage-netsurf/11/cobertura/utils/nsurl_c/",
+ "http://ci.netsurf-browser.org/jenkins/view/Unit%20Tests/job/coverage-nets...",
+ "" },
+
+ { "FILE:///",
+ "file:///",
+ "/" },
+};
+
+/**
+ * url access test
+ */
+START_TEST(nsurl_access_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ /* The url accessed string must match the input */
+ ck_assert_str_eq(nsurl_access(res_url), tst->test2);
+
+ nsurl_unref(res_url);
+}
+END_TEST
+
+/**
+ * url access leaf test
+ */
+START_TEST(nsurl_access_leaf_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access_leaf(res_url), tst->res);
+
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+/**
+ * url length test
+ *
+ * uses access dataset and test unit
+ */
+START_TEST(nsurl_length_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_int_eq(nsurl_length(res_url), strlen(tst->test2));
+
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+
static const struct test_pairs nice_tests[] = {
{ "about:", NULL },
{ "www.foo.org", "www_foo_org" },
@@ -122,6 +225,38 @@ static const struct test_pairs nice_tests[] = {
{ "http://www.f.org//index.en", "www_f_org" },
};
+/**
+ * url nice filename without stripping
+ */
+START_TEST(nsurl_nice_nostrip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, false);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(res_str, tst->res);
+
+ free(res_str);
+ }
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+
static const struct test_pairs nice_strip_tests[] = {
{ "about:", NULL },
{ "www.foo.org", "www_foo_org" },
@@ -136,6 +271,38 @@ static const struct test_pairs nice_strip_tests[] = {
};
/**
+ * url nice filename with stripping
+ */
+START_TEST(nsurl_nice_strip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_strip_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, true);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(res_str, tst->res);
+
+ free(res_str);
+ }
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+
+/**
* simple joins that all use http://a/b/c/d;p?q as a base
*/
static const struct test_pairs join_tests[] = {
@@ -211,79 +378,22 @@ static const struct test_pairs join_tests[] = {
};
/**
- * more complex joins that specify a base to join to
- */
-static const struct test_triplets join_complex_tests[] = {
- /* problematic real world urls for regression */
- { "http://www.bridgetmckenna.com/blog/self-editing-for-everyone-part-1-the-m...",
- "http://The%20Old%20Organ%20Trail%20http://www.amazon.com/gp/product/B007B...",
- "http://the old organ trail http:" },
-};
-
-/**
- * query replacement tests
- */
-static const struct test_triplets replace_query_tests[] = {
- { "http://netsurf-browser.org/?magical=true",
- "?magical=true&result=win",
- "http://netsurf-browser.org/?magical=true&result=win"},
-
- { "http://netsurf-browser.org/?magical=true#fragment",
- "?magical=true&result=win",
- "http://netsurf-browser.org/?magical=true&result=win#fragment"},
-
- { "http://netsurf-browser.org/#fragment",
- "?magical=true&result=win",
- "http://netsurf-browser.org/?magical=true&result=win#fragment"},
-
- { "http://netsurf-browser.org/path",
- "?magical=true",
- "http://netsurf-browser.org/path?magical=true"},
-
-};
-
-
-
-/**
- * url creation test
- */
-START_TEST(nsurl_create_test)
-{
- nserror err;
- nsurl *res;
- const struct test_pairs *tst = &create_tests[_i];
-
- err = nsurl_create(tst->test, &res);
- if (tst->res == NULL) {
- /* result must be invalid */
- ck_assert(err != NSERROR_OK);
-
- } else {
- /* result must be valid */
- ck_assert(err == NSERROR_OK);
-
- ck_assert_str_eq(nsurl_access(res), tst->res);
-
- nsurl_unref(res);
- }
-}
-END_TEST
-
-/**
- * url nice filename without stripping
+ * url joining
*/
-START_TEST(nsurl_nice_nostrip_test)
+START_TEST(nsurl_join_test)
{
nserror err;
- nsurl *res_url;
- char *res_str;
- const struct test_pairs *tst = &nice_tests[_i];
+ nsurl *base_url;
+ nsurl *joined;
+ char *string;
+ size_t len;
+ const struct test_pairs *tst = &join_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create(tst->test, &res_url);
+ err = nsurl_create(base_str, &base_url);
ck_assert(err == NSERROR_OK);
- err = nsurl_nice(res_url, &res_str, false);
+ err = nsurl_join(base_url, tst->test, &joined);
if (tst->res == NULL) {
/* result must be invalid (bad input) */
ck_assert(err != NSERROR_OK);
@@ -291,94 +401,47 @@ START_TEST(nsurl_nice_nostrip_test)
/* result must be valid */
ck_assert(err == NSERROR_OK);
- ck_assert_str_eq(res_str, tst->res);
-
- free(res_str);
- }
- nsurl_unref(res_url);
-
-}
-END_TEST
-
-/**
- * url nice filename with stripping
- */
-START_TEST(nsurl_nice_strip_test)
-{
- nserror err;
- nsurl *res_url;
- char *res_str;
- const struct test_pairs *tst = &nice_strip_tests[_i];
-
- /* not testing create, this should always succeed */
- err = nsurl_create(tst->test, &res_url);
- ck_assert(err == NSERROR_OK);
-
- err = nsurl_nice(res_url, &res_str, true);
- if (tst->res == NULL) {
- /* result must be invalid (bad input) */
- ck_assert(err != NSERROR_OK);
- } else {
- /* result must be valid */
+ err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
ck_assert(err == NSERROR_OK);
- ck_assert_str_eq(res_str, tst->res);
+ ck_assert_str_eq(string, tst->res);
- free(res_str);
+ free(string);
+ nsurl_unref(joined);
}
- nsurl_unref(res_url);
+ nsurl_unref(base_url);
}
END_TEST
+
/**
- * replace query
+ * more complex joins that specify a base to join to
*/
-START_TEST(nsurl_replace_query_test)
-{
- nserror err;
- nsurl *res_url;
- nsurl *joined;
- const struct test_triplets *tst = &replace_query_tests[_i];
-
- /* not testing create, this should always succeed */
- err = nsurl_create(tst->test1, &res_url);
- ck_assert(err == NSERROR_OK);
-
- err = nsurl_replace_query(res_url, tst->test2, &joined);
- if (tst->res == NULL) {
- /* result must be invalid (bad input) */
- ck_assert(err != NSERROR_OK);
- } else {
- /* result must be valid */
- ck_assert(err == NSERROR_OK);
-
- ck_assert_str_eq(nsurl_access(joined), tst->res);
-
- nsurl_unref(joined);
- }
- nsurl_unref(res_url);
-
-}
-END_TEST
+static const struct test_triplets join_complex_tests[] = {
+ /* problematic real world urls for regression */
+ { "http://www.bridgetmckenna.com/blog/self-editing-for-everyone-part-1-the-m...",
+ "http://The%20Old%20Organ%20Trail%20http://www.amazon.com/gp/product/B007B...",
+ "http://the old organ trail http:" },
+};
/**
- * url joining
+ * complex url joining
*/
-START_TEST(nsurl_join_test)
+START_TEST(nsurl_join_complex_test)
{
nserror err;
nsurl *base_url;
nsurl *joined;
char *string;
size_t len;
- const struct test_pairs *tst = &join_tests[_i];
+ const struct test_triplets *tst = &join_complex_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create(base_str, &base_url);
+ err = nsurl_create(tst->test1, &base_url);
ck_assert(err == NSERROR_OK);
- err = nsurl_join(base_url, tst->test, &joined);
+ err = nsurl_join(base_url, tst->test2, &joined);
if (tst->res == NULL) {
/* result must be invalid (bad input) */
ck_assert(err != NSERROR_OK);
@@ -399,23 +462,44 @@ START_TEST(nsurl_join_test)
}
END_TEST
+
/**
- * complex url joining
+ * query replacement tests
*/
-START_TEST(nsurl_join_complex_test)
+static const struct test_triplets replace_query_tests[] = {
+ { "http://netsurf-browser.org/?magical=true",
+ "?magical=true&result=win",
+ "http://netsurf-browser.org/?magical=true&result=win"},
+
+ { "http://netsurf-browser.org/?magical=true#fragment",
+ "?magical=true&result=win",
+ "http://netsurf-browser.org/?magical=true&result=win#fragment"},
+
+ { "http://netsurf-browser.org/#fragment",
+ "?magical=true&result=win",
+ "http://netsurf-browser.org/?magical=true&result=win#fragment"},
+
+ { "http://netsurf-browser.org/path",
+ "?magical=true",
+ "http://netsurf-browser.org/path?magical=true"},
+
+};
+
+/**
+ * replace query
+ */
+START_TEST(nsurl_replace_query_test)
{
nserror err;
- nsurl *base_url;
+ nsurl *res_url;
nsurl *joined;
- char *string;
- size_t len;
- const struct test_triplets *tst = &join_complex_tests[_i];
+ const struct test_triplets *tst = &replace_query_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create(tst->test1, &base_url);
+ err = nsurl_create(tst->test1, &res_url);
ck_assert(err == NSERROR_OK);
- err = nsurl_join(base_url, tst->test2, &joined);
+ err = nsurl_replace_query(res_url, tst->test2, &joined);
if (tst->res == NULL) {
/* result must be invalid (bad input) */
ck_assert(err != NSERROR_OK);
@@ -423,15 +507,11 @@ START_TEST(nsurl_join_complex_test)
/* result must be valid */
ck_assert(err == NSERROR_OK);
- err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
- ck_assert(err == NSERROR_OK);
-
- ck_assert_str_eq(string, tst->res);
+ ck_assert_str_eq(nsurl_access(joined), tst->res);
- free(string);
nsurl_unref(joined);
}
- nsurl_unref(base_url);
+ nsurl_unref(res_url);
}
END_TEST
@@ -461,10 +541,11 @@ START_TEST(nsurl_ref_test)
}
END_TEST
+
/**
* check creation asserts on NULL parameter
*/
-START_TEST(nsurl_api_create_test)
+START_TEST(nsurl_api_assert_create_test)
{
nserror err;
nsurl *res1;
@@ -477,7 +558,7 @@ END_TEST
/**
* check ref asserts on NULL parameter
*/
-START_TEST(nsurl_api_ref_test)
+START_TEST(nsurl_api_assert_ref_test)
{
nsurl_ref(NULL);
}
@@ -486,7 +567,7 @@ END_TEST
/**
* check unref asserts on NULL parameter
*/
-START_TEST(nsurl_api_unref_test)
+START_TEST(nsurl_api_assert_unref_test)
{
nsurl_unref(NULL);
}
@@ -495,7 +576,7 @@ END_TEST
/**
* check compare asserts on NULL parameter
*/
-START_TEST(nsurl_api_compare1_test)
+START_TEST(nsurl_api_assert_compare1_test)
{
nserror err;
nsurl *res;
@@ -515,7 +596,7 @@ END_TEST
/**
* check compare asserts on NULL parameter
*/
-START_TEST(nsurl_api_compare2_test)
+START_TEST(nsurl_api_assert_compare2_test)
{
nserror err;
nsurl *res;
@@ -533,7 +614,7 @@ END_TEST
/**
* check get asserts on NULL parameter
*/
-START_TEST(nsurl_api_get_test)
+START_TEST(nsurl_api_assert_get_test)
{
nserror err;
char *url_s = NULL;
@@ -549,7 +630,7 @@ END_TEST
/**
* check get component asserts on NULL parameter
*/
-START_TEST(nsurl_api_get_component1_test)
+START_TEST(nsurl_api_assert_get_component1_test)
{
lwc_string *lwcs;
@@ -561,7 +642,7 @@ END_TEST
/**
* check get component asserts on bad component parameter
*/
-START_TEST(nsurl_api_get_component2_test)
+START_TEST(nsurl_api_assert_get_component2_test)
{
nserror err;
nsurl *res;
@@ -580,7 +661,7 @@ END_TEST
/**
* check has component asserts on NULL parameter
*/
-START_TEST(nsurl_api_has_component1_test)
+START_TEST(nsurl_api_assert_has_component1_test)
{
bool has;
@@ -592,7 +673,7 @@ END_TEST
/**
* check has component asserts on bad component parameter
*/
-START_TEST(nsurl_api_has_component2_test)
+START_TEST(nsurl_api_assert_has_component2_test)
{
nserror err;
nsurl *res;
@@ -612,7 +693,7 @@ END_TEST
/**
* check access asserts on NULL parameter
*/
-START_TEST(nsurl_api_access_test)
+START_TEST(nsurl_api_assert_access_test)
{
const char *res_s = NULL;
@@ -625,7 +706,7 @@ END_TEST
/**
* check access asserts on NULL parameter
*/
-START_TEST(nsurl_api_access_leaf_test)
+START_TEST(nsurl_api_assert_access_leaf_test)
{
const char *res_s = NULL;
@@ -638,7 +719,7 @@ END_TEST
/**
* check length asserts on NULL parameter
*/
-START_TEST(nsurl_api_length_test)
+START_TEST(nsurl_api_assert_length_test)
{
size_t res = 0;
@@ -651,7 +732,7 @@ END_TEST
/**
* check hash asserts on NULL parameter
*/
-START_TEST(nsurl_api_hash_test)
+START_TEST(nsurl_api_assert_hash_test)
{
uint32_t res = 0;
@@ -661,6 +742,168 @@ START_TEST(nsurl_api_hash_test)
}
END_TEST
+/**
+ * check join asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_join1_test)
+{
+ const char *rel = "moo";
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_join(NULL, rel, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check join asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_join2_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_join(url, NULL, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check defragment asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_defragment_test)
+{
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_defragment(NULL, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+
+/**
+ * check refragment join asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_refragment1_test)
+{
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_refragment(NULL, corestring_lwc_http, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check refragment asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_refragment2_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_refragment(url, NULL, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check query replacement asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_replace_query1_test)
+{
+ const char *rel = "moo";
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_replace_query(NULL, rel, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check query replacement asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_replace_query2_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_replace_query(url, NULL, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check query replacement asserts on bad parameter
+ */
+START_TEST(nsurl_api_assert_replace_query3_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+ const char *rel = "moo";
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_replace_query(url, rel, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check nice asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_nice_test)
+{
+ char *res_s = NULL;
+ nserror err;
+
+ err = nsurl_nice(NULL, &res_s, false);
+ ck_assert(err != NSERROR_OK);
+
+ ck_assert(res_s == NULL);
+}
+END_TEST
+
+/**
+ * check parent asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_parent_test)
+{
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_parent(NULL, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+
+/* Fixtures */
static void corestring_create(void)
{
@@ -674,11 +917,14 @@ static void corestring_teardown(void)
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
}
+/* suite generation */
+
Suite *nsurl_suite(void)
{
Suite *s;
- TCase *tc_api;
+ TCase *tc_api_assert;
TCase *tc_create;
+ TCase *tc_access;
TCase *tc_nice_nostrip;
TCase *tc_nice_strip;
TCase *tc_replace_query;
@@ -686,28 +932,63 @@ Suite *nsurl_suite(void)
s = suite_create("nsurl");
- /* Basic API operation sanity checks e.g. passing NULL parameters */
- tc_api = tcase_create("API");
+ /* Basic API operation assert checks */
+ tc_api_assert = tcase_create("API asserts");
- tcase_add_unchecked_fixture(tc_api,
+ tcase_add_unchecked_fixture(tc_api_assert,
corestring_create,
corestring_teardown);
- tcase_add_test_raise_signal(tc_api, nsurl_api_create_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_ref_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_unref_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_compare1_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_compare2_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_get_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_get_component1_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_get_component2_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_has_component1_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_has_component2_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_access_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_access_leaf_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_length_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_hash_test, 6);
- suite_add_tcase(s, tc_api);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_create_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_ref_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_unref_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_compare1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_compare2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_get_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_get_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_get_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_has_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_has_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_access_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_access_leaf_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_length_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_hash_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_join1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_join2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_defragment_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_refragment1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_refragment2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_replace_query1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_replace_query2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_replace_query3_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_nice_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_parent_test, 6);
+
+ suite_add_tcase(s, tc_api_assert);
/* url creation */
tc_create = tcase_create("Create");
@@ -716,12 +997,29 @@ Suite *nsurl_suite(void)
corestring_create,
corestring_teardown);
- tcase_add_test(tc_create, nsurl_ref_test);
tcase_add_loop_test(tc_create,
nsurl_create_test,
0, NELEMS(create_tests));
+ tcase_add_test(tc_create, nsurl_ref_test);
suite_add_tcase(s, tc_create);
+ /* url access and length */
+ tc_access = tcase_create("Access");
+
+ tcase_add_unchecked_fixture(tc_access,
+ corestring_create,
+ corestring_teardown);
+ tcase_add_loop_test(tc_access,
+ nsurl_access_test,
+ 0, NELEMS(access_tests));
+ tcase_add_loop_test(tc_access,
+ nsurl_access_leaf_test,
+ 0, NELEMS(access_tests));
+ tcase_add_loop_test(tc_access,
+ nsurl_length_test,
+ 0, NELEMS(access_tests));
+ suite_add_tcase(s, tc_access);
+
/* nice filename without strip */
tc_nice_nostrip = tcase_create("Nice (nostrip)");
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 8431916..8d53be8 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -2004,6 +2004,8 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
size_t length;
char *pos;
+ assert(url != NULL);
+
/* check for source url having no fragment already */
if (url->components.fragment == NULL) {
*no_frag = (nsurl *)url;
@@ -2226,6 +2228,8 @@ nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
bool match;
char *name;
+ assert(url != NULL);
+
*result = 0;
/* extract the last component of the path, if possible */
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 656 +++++++++++++++++++++++++++++++++++++++++----------------
utils/nsurl.c | 4 +
2 files changed, 481 insertions(+), 179 deletions(-)
diff --git a/test/nsurl.c b/test/nsurl.c
index 66a3c8f..87058f2 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -1,4 +1,5 @@
/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
* Copyright 2011 John Mark Bell <jmb(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
@@ -109,6 +110,108 @@ static const struct test_pairs create_tests[] = {
};
+/**
+ * url creation test
+ */
+START_TEST(nsurl_create_test)
+{
+ nserror err;
+ nsurl *res;
+ const struct test_pairs *tst = &create_tests[_i];
+
+ err = nsurl_create(tst->test, &res);
+ if (tst->res == NULL) {
+ /* result must be invalid */
+ ck_assert(err != NSERROR_OK);
+
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access(res), tst->res);
+
+ nsurl_unref(res);
+ }
+}
+END_TEST
+
+static const struct test_triplets access_tests[] = {
+ { "http://www.netsurf-browser.org/a/big/tree",
+ "http://www.netsurf-browser.org/a/big/tree",
+ "tree" },
+
+ { "HTTP://ci.netsurf-browser.org/jenkins/view/Unit Tests/job/coverage-netsurf/11/cobertura/utils/nsurl_c/",
+ "http://ci.netsurf-browser.org/jenkins/view/Unit%20Tests/job/coverage-nets...",
+ "" },
+
+ { "FILE:///",
+ "file:///",
+ "/" },
+};
+
+/**
+ * url access test
+ */
+START_TEST(nsurl_access_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ /* The url accessed string must match the input */
+ ck_assert_str_eq(nsurl_access(res_url), tst->test2);
+
+ nsurl_unref(res_url);
+}
+END_TEST
+
+/**
+ * url access leaf test
+ */
+START_TEST(nsurl_access_leaf_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access_leaf(res_url), tst->res);
+
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+/**
+ * url length test
+ *
+ * uses access dataset and test unit
+ */
+START_TEST(nsurl_length_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_int_eq(nsurl_length(res_url), strlen(tst->test2));
+
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+
static const struct test_pairs nice_tests[] = {
{ "about:", NULL },
{ "www.foo.org", "www_foo_org" },
@@ -122,6 +225,38 @@ static const struct test_pairs nice_tests[] = {
{ "http://www.f.org//index.en", "www_f_org" },
};
+/**
+ * url nice filename without stripping
+ */
+START_TEST(nsurl_nice_nostrip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, false);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(res_str, tst->res);
+
+ free(res_str);
+ }
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+
static const struct test_pairs nice_strip_tests[] = {
{ "about:", NULL },
{ "www.foo.org", "www_foo_org" },
@@ -136,6 +271,38 @@ static const struct test_pairs nice_strip_tests[] = {
};
/**
+ * url nice filename with stripping
+ */
+START_TEST(nsurl_nice_strip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_strip_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, true);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(res_str, tst->res);
+
+ free(res_str);
+ }
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+
+/**
* simple joins that all use http://a/b/c/d;p?q as a base
*/
static const struct test_pairs join_tests[] = {
@@ -211,79 +378,22 @@ static const struct test_pairs join_tests[] = {
};
/**
- * more complex joins that specify a base to join to
- */
-static const struct test_triplets join_complex_tests[] = {
- /* problematic real world urls for regression */
- { "http://www.bridgetmckenna.com/blog/self-editing-for-everyone-part-1-the-m...",
- "http://The%20Old%20Organ%20Trail%20http://www.amazon.com/gp/product/B007B...",
- "http://the old organ trail http:" },
-};
-
-/**
- * query replacement tests
- */
-static const struct test_triplets replace_query_tests[] = {
- { "http://netsurf-browser.org/?magical=true",
- "?magical=true&result=win",
- "http://netsurf-browser.org/?magical=true&result=win"},
-
- { "http://netsurf-browser.org/?magical=true#fragment",
- "?magical=true&result=win",
- "http://netsurf-browser.org/?magical=true&result=win#fragment"},
-
- { "http://netsurf-browser.org/#fragment",
- "?magical=true&result=win",
- "http://netsurf-browser.org/?magical=true&result=win#fragment"},
-
- { "http://netsurf-browser.org/path",
- "?magical=true",
- "http://netsurf-browser.org/path?magical=true"},
-
-};
-
-
-
-/**
- * url creation test
- */
-START_TEST(nsurl_create_test)
-{
- nserror err;
- nsurl *res;
- const struct test_pairs *tst = &create_tests[_i];
-
- err = nsurl_create(tst->test, &res);
- if (tst->res == NULL) {
- /* result must be invalid */
- ck_assert(err != NSERROR_OK);
-
- } else {
- /* result must be valid */
- ck_assert(err == NSERROR_OK);
-
- ck_assert_str_eq(nsurl_access(res), tst->res);
-
- nsurl_unref(res);
- }
-}
-END_TEST
-
-/**
- * url nice filename without stripping
+ * url joining
*/
-START_TEST(nsurl_nice_nostrip_test)
+START_TEST(nsurl_join_test)
{
nserror err;
- nsurl *res_url;
- char *res_str;
- const struct test_pairs *tst = &nice_tests[_i];
+ nsurl *base_url;
+ nsurl *joined;
+ char *string;
+ size_t len;
+ const struct test_pairs *tst = &join_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create(tst->test, &res_url);
+ err = nsurl_create(base_str, &base_url);
ck_assert(err == NSERROR_OK);
- err = nsurl_nice(res_url, &res_str, false);
+ err = nsurl_join(base_url, tst->test, &joined);
if (tst->res == NULL) {
/* result must be invalid (bad input) */
ck_assert(err != NSERROR_OK);
@@ -291,94 +401,47 @@ START_TEST(nsurl_nice_nostrip_test)
/* result must be valid */
ck_assert(err == NSERROR_OK);
- ck_assert_str_eq(res_str, tst->res);
-
- free(res_str);
- }
- nsurl_unref(res_url);
-
-}
-END_TEST
-
-/**
- * url nice filename with stripping
- */
-START_TEST(nsurl_nice_strip_test)
-{
- nserror err;
- nsurl *res_url;
- char *res_str;
- const struct test_pairs *tst = &nice_strip_tests[_i];
-
- /* not testing create, this should always succeed */
- err = nsurl_create(tst->test, &res_url);
- ck_assert(err == NSERROR_OK);
-
- err = nsurl_nice(res_url, &res_str, true);
- if (tst->res == NULL) {
- /* result must be invalid (bad input) */
- ck_assert(err != NSERROR_OK);
- } else {
- /* result must be valid */
+ err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
ck_assert(err == NSERROR_OK);
- ck_assert_str_eq(res_str, tst->res);
+ ck_assert_str_eq(string, tst->res);
- free(res_str);
+ free(string);
+ nsurl_unref(joined);
}
- nsurl_unref(res_url);
+ nsurl_unref(base_url);
}
END_TEST
+
/**
- * replace query
+ * more complex joins that specify a base to join to
*/
-START_TEST(nsurl_replace_query_test)
-{
- nserror err;
- nsurl *res_url;
- nsurl *joined;
- const struct test_triplets *tst = &replace_query_tests[_i];
-
- /* not testing create, this should always succeed */
- err = nsurl_create(tst->test1, &res_url);
- ck_assert(err == NSERROR_OK);
-
- err = nsurl_replace_query(res_url, tst->test2, &joined);
- if (tst->res == NULL) {
- /* result must be invalid (bad input) */
- ck_assert(err != NSERROR_OK);
- } else {
- /* result must be valid */
- ck_assert(err == NSERROR_OK);
-
- ck_assert_str_eq(nsurl_access(joined), tst->res);
-
- nsurl_unref(joined);
- }
- nsurl_unref(res_url);
-
-}
-END_TEST
+static const struct test_triplets join_complex_tests[] = {
+ /* problematic real world urls for regression */
+ { "http://www.bridgetmckenna.com/blog/self-editing-for-everyone-part-1-the-m...",
+ "http://The%20Old%20Organ%20Trail%20http://www.amazon.com/gp/product/B007B...",
+ "http://the old organ trail http:" },
+};
/**
- * url joining
+ * complex url joining
*/
-START_TEST(nsurl_join_test)
+START_TEST(nsurl_join_complex_test)
{
nserror err;
nsurl *base_url;
nsurl *joined;
char *string;
size_t len;
- const struct test_pairs *tst = &join_tests[_i];
+ const struct test_triplets *tst = &join_complex_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create(base_str, &base_url);
+ err = nsurl_create(tst->test1, &base_url);
ck_assert(err == NSERROR_OK);
- err = nsurl_join(base_url, tst->test, &joined);
+ err = nsurl_join(base_url, tst->test2, &joined);
if (tst->res == NULL) {
/* result must be invalid (bad input) */
ck_assert(err != NSERROR_OK);
@@ -399,23 +462,44 @@ START_TEST(nsurl_join_test)
}
END_TEST
+
/**
- * complex url joining
+ * query replacement tests
*/
-START_TEST(nsurl_join_complex_test)
+static const struct test_triplets replace_query_tests[] = {
+ { "http://netsurf-browser.org/?magical=true",
+ "?magical=true&result=win",
+ "http://netsurf-browser.org/?magical=true&result=win"},
+
+ { "http://netsurf-browser.org/?magical=true#fragment",
+ "?magical=true&result=win",
+ "http://netsurf-browser.org/?magical=true&result=win#fragment"},
+
+ { "http://netsurf-browser.org/#fragment",
+ "?magical=true&result=win",
+ "http://netsurf-browser.org/?magical=true&result=win#fragment"},
+
+ { "http://netsurf-browser.org/path",
+ "?magical=true",
+ "http://netsurf-browser.org/path?magical=true"},
+
+};
+
+/**
+ * replace query
+ */
+START_TEST(nsurl_replace_query_test)
{
nserror err;
- nsurl *base_url;
+ nsurl *res_url;
nsurl *joined;
- char *string;
- size_t len;
- const struct test_triplets *tst = &join_complex_tests[_i];
+ const struct test_triplets *tst = &replace_query_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create(tst->test1, &base_url);
+ err = nsurl_create(tst->test1, &res_url);
ck_assert(err == NSERROR_OK);
- err = nsurl_join(base_url, tst->test2, &joined);
+ err = nsurl_replace_query(res_url, tst->test2, &joined);
if (tst->res == NULL) {
/* result must be invalid (bad input) */
ck_assert(err != NSERROR_OK);
@@ -423,15 +507,11 @@ START_TEST(nsurl_join_complex_test)
/* result must be valid */
ck_assert(err == NSERROR_OK);
- err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
- ck_assert(err == NSERROR_OK);
-
- ck_assert_str_eq(string, tst->res);
+ ck_assert_str_eq(nsurl_access(joined), tst->res);
- free(string);
nsurl_unref(joined);
}
- nsurl_unref(base_url);
+ nsurl_unref(res_url);
}
END_TEST
@@ -461,10 +541,11 @@ START_TEST(nsurl_ref_test)
}
END_TEST
+
/**
* check creation asserts on NULL parameter
*/
-START_TEST(nsurl_api_create_test)
+START_TEST(nsurl_api_assert_create_test)
{
nserror err;
nsurl *res1;
@@ -477,7 +558,7 @@ END_TEST
/**
* check ref asserts on NULL parameter
*/
-START_TEST(nsurl_api_ref_test)
+START_TEST(nsurl_api_assert_ref_test)
{
nsurl_ref(NULL);
}
@@ -486,7 +567,7 @@ END_TEST
/**
* check unref asserts on NULL parameter
*/
-START_TEST(nsurl_api_unref_test)
+START_TEST(nsurl_api_assert_unref_test)
{
nsurl_unref(NULL);
}
@@ -495,7 +576,7 @@ END_TEST
/**
* check compare asserts on NULL parameter
*/
-START_TEST(nsurl_api_compare1_test)
+START_TEST(nsurl_api_assert_compare1_test)
{
nserror err;
nsurl *res;
@@ -515,7 +596,7 @@ END_TEST
/**
* check compare asserts on NULL parameter
*/
-START_TEST(nsurl_api_compare2_test)
+START_TEST(nsurl_api_assert_compare2_test)
{
nserror err;
nsurl *res;
@@ -533,7 +614,7 @@ END_TEST
/**
* check get asserts on NULL parameter
*/
-START_TEST(nsurl_api_get_test)
+START_TEST(nsurl_api_assert_get_test)
{
nserror err;
char *url_s = NULL;
@@ -549,7 +630,7 @@ END_TEST
/**
* check get component asserts on NULL parameter
*/
-START_TEST(nsurl_api_get_component1_test)
+START_TEST(nsurl_api_assert_get_component1_test)
{
lwc_string *lwcs;
@@ -561,7 +642,7 @@ END_TEST
/**
* check get component asserts on bad component parameter
*/
-START_TEST(nsurl_api_get_component2_test)
+START_TEST(nsurl_api_assert_get_component2_test)
{
nserror err;
nsurl *res;
@@ -580,7 +661,7 @@ END_TEST
/**
* check has component asserts on NULL parameter
*/
-START_TEST(nsurl_api_has_component1_test)
+START_TEST(nsurl_api_assert_has_component1_test)
{
bool has;
@@ -592,7 +673,7 @@ END_TEST
/**
* check has component asserts on bad component parameter
*/
-START_TEST(nsurl_api_has_component2_test)
+START_TEST(nsurl_api_assert_has_component2_test)
{
nserror err;
nsurl *res;
@@ -612,7 +693,7 @@ END_TEST
/**
* check access asserts on NULL parameter
*/
-START_TEST(nsurl_api_access_test)
+START_TEST(nsurl_api_assert_access_test)
{
const char *res_s = NULL;
@@ -625,7 +706,7 @@ END_TEST
/**
* check access asserts on NULL parameter
*/
-START_TEST(nsurl_api_access_leaf_test)
+START_TEST(nsurl_api_assert_access_leaf_test)
{
const char *res_s = NULL;
@@ -638,7 +719,7 @@ END_TEST
/**
* check length asserts on NULL parameter
*/
-START_TEST(nsurl_api_length_test)
+START_TEST(nsurl_api_assert_length_test)
{
size_t res = 0;
@@ -651,7 +732,7 @@ END_TEST
/**
* check hash asserts on NULL parameter
*/
-START_TEST(nsurl_api_hash_test)
+START_TEST(nsurl_api_assert_hash_test)
{
uint32_t res = 0;
@@ -661,6 +742,168 @@ START_TEST(nsurl_api_hash_test)
}
END_TEST
+/**
+ * check join asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_join1_test)
+{
+ const char *rel = "moo";
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_join(NULL, rel, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check join asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_join2_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_join(url, NULL, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check defragment asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_defragment_test)
+{
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_defragment(NULL, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+
+/**
+ * check refragment join asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_refragment1_test)
+{
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_refragment(NULL, corestring_lwc_http, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check refragment asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_refragment2_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_refragment(url, NULL, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check query replacement asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_replace_query1_test)
+{
+ const char *rel = "moo";
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_replace_query(NULL, rel, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check query replacement asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_replace_query2_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_replace_query(url, NULL, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check query replacement asserts on bad parameter
+ */
+START_TEST(nsurl_api_assert_replace_query3_test)
+{
+ nsurl *url;
+ nsurl *res;
+ nserror err;
+ const char *rel = "moo";
+
+ err = nsurl_create(base_str, &url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_replace_query(url, rel, &res);
+ ck_assert(err != NSERROR_OK);
+
+ nsurl_unref(url);
+}
+END_TEST
+
+/**
+ * check nice asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_nice_test)
+{
+ char *res_s = NULL;
+ nserror err;
+
+ err = nsurl_nice(NULL, &res_s, false);
+ ck_assert(err != NSERROR_OK);
+
+ ck_assert(res_s == NULL);
+}
+END_TEST
+
+/**
+ * check parent asserts on NULL parameter
+ */
+START_TEST(nsurl_api_assert_parent_test)
+{
+ nsurl *res;
+ nserror err;
+
+ err = nsurl_parent(NULL, &res);
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+
+/* Fixtures */
static void corestring_create(void)
{
@@ -674,11 +917,14 @@ static void corestring_teardown(void)
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
}
+/* suite generation */
+
Suite *nsurl_suite(void)
{
Suite *s;
- TCase *tc_api;
+ TCase *tc_api_assert;
TCase *tc_create;
+ TCase *tc_access;
TCase *tc_nice_nostrip;
TCase *tc_nice_strip;
TCase *tc_replace_query;
@@ -686,28 +932,63 @@ Suite *nsurl_suite(void)
s = suite_create("nsurl");
- /* Basic API operation sanity checks e.g. passing NULL parameters */
- tc_api = tcase_create("API");
+ /* Basic API operation assert checks */
+ tc_api_assert = tcase_create("API asserts");
- tcase_add_unchecked_fixture(tc_api,
+ tcase_add_unchecked_fixture(tc_api_assert,
corestring_create,
corestring_teardown);
- tcase_add_test_raise_signal(tc_api, nsurl_api_create_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_ref_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_unref_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_compare1_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_compare2_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_get_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_get_component1_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_get_component2_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_has_component1_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_has_component2_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_access_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_access_leaf_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_length_test, 6);
- tcase_add_test_raise_signal(tc_api, nsurl_api_hash_test, 6);
- suite_add_tcase(s, tc_api);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_create_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_ref_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_unref_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_compare1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_compare2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_get_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_get_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_get_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_has_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_has_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_access_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_access_leaf_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_length_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_hash_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_join1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_join2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_defragment_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_refragment1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_refragment2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_replace_query1_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_replace_query2_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_replace_query3_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_nice_test, 6);
+ tcase_add_test_raise_signal(tc_api_assert,
+ nsurl_api_assert_parent_test, 6);
+
+ suite_add_tcase(s, tc_api_assert);
/* url creation */
tc_create = tcase_create("Create");
@@ -716,12 +997,29 @@ Suite *nsurl_suite(void)
corestring_create,
corestring_teardown);
- tcase_add_test(tc_create, nsurl_ref_test);
tcase_add_loop_test(tc_create,
nsurl_create_test,
0, NELEMS(create_tests));
+ tcase_add_test(tc_create, nsurl_ref_test);
suite_add_tcase(s, tc_create);
+ /* url access and length */
+ tc_access = tcase_create("Access");
+
+ tcase_add_unchecked_fixture(tc_access,
+ corestring_create,
+ corestring_teardown);
+ tcase_add_loop_test(tc_access,
+ nsurl_access_test,
+ 0, NELEMS(access_tests));
+ tcase_add_loop_test(tc_access,
+ nsurl_access_leaf_test,
+ 0, NELEMS(access_tests));
+ tcase_add_loop_test(tc_access,
+ nsurl_length_test,
+ 0, NELEMS(access_tests));
+ suite_add_tcase(s, tc_access);
+
/* nice filename without strip */
tc_nice_nostrip = tcase_create("Nice (nostrip)");
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 8431916..8d53be8 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -2004,6 +2004,8 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
size_t length;
char *pos;
+ assert(url != NULL);
+
/* check for source url having no fragment already */
if (url->components.fragment == NULL) {
*no_frag = (nsurl *)url;
@@ -2226,6 +2228,8 @@ nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
bool match;
char *name;
+ assert(url != NULL);
+
*result = 0;
/* extract the last component of the path, if possible */
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-214-g5b09363
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5b09363597d9586ec4218...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5b09363597d9586ec421817...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5b09363597d9586ec42181745...
The branch, master has been updated
via 5b09363597d9586ec421817459efe8a242c953c8 (commit)
from cd1949bc964d2b1846f9745d914213548217d2e1 (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/netsurf.git/commit/?id=5b09363597d9586ec42...
commit 5b09363597d9586ec421817459efe8a242c953c8
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add asserts to ensure operations not passed bad pointers
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 9e19275..8431916 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1554,6 +1554,8 @@ nserror nsurl_get(const nsurl *url, nsurl_component parts,
struct nsurl_component_lengths str_len = { 0, 0, 0, 0, 0, 0, 0, 0 };
enum nsurl_string_flags str_flags = 0;
+ assert(url != NULL);
+
/* Get the string length and find which parts of url need copied */
nsurl__get_string_data(&(url->components), parts, url_l,
&str_len, &str_flags);
@@ -1704,6 +1706,8 @@ const char *nsurl_access_leaf(const nsurl *url)
const char *path;
const char *leaf;
+ assert(url != NULL);
+
if (url->components.path == NULL)
return "";
-----------------------------------------------------------------------
Summary of changes:
utils/nsurl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 9e19275..8431916 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1554,6 +1554,8 @@ nserror nsurl_get(const nsurl *url, nsurl_component parts,
struct nsurl_component_lengths str_len = { 0, 0, 0, 0, 0, 0, 0, 0 };
enum nsurl_string_flags str_flags = 0;
+ assert(url != NULL);
+
/* Get the string length and find which parts of url need copied */
nsurl__get_string_data(&(url->components), parts, url_l,
&str_len, &str_flags);
@@ -1704,6 +1706,8 @@ const char *nsurl_access_leaf(const nsurl *url)
const char *path;
const char *leaf;
+ assert(url != NULL);
+
if (url->components.path == NULL)
return "";
--
NetSurf Browser
7 years, 10 months
netsurf: branch master updated. release/3.3-213-gcd1949b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/cd1949bc964d2b1846f97...
...commit http://git.netsurf-browser.org/netsurf.git/commit/cd1949bc964d2b1846f9745...
...tree http://git.netsurf-browser.org/netsurf.git/tree/cd1949bc964d2b1846f9745d9...
The branch, master has been updated
via cd1949bc964d2b1846f9745d914213548217d2e1 (commit)
from eb962f94c3247c6b64802f12197ac9567315f371 (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/netsurf.git/commit/?id=cd1949bc964d2b1846f...
commit cd1949bc964d2b1846f9745d914213548217d2e1
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Improve component documentation.
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 4454ba8..9e19275 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -150,7 +150,18 @@ enum scheme_type {
};
-/** nsurl components */
+/**
+ * nsurl components
+ *
+ * [scheme]://[username]:[password]@[host]:[port][path][?query]#[fragment]
+ *
+ * Note:
+ * "path" string includes preceding '/', if needed for the scheme
+ * "query" string always includes preceding '?'
+ *
+ * The other spanned punctuation is to be inserted when building URLs from
+ * components.
+ */
struct nsurl_components {
lwc_string *scheme;
lwc_string *username;
@@ -167,8 +178,6 @@ struct nsurl_components {
/**
* NetSurf URL object
- *
- * [scheme]://[username][:password]@[host]:[port][/path][?query][#fragment]
*/
struct nsurl {
struct nsurl_components components;
-----------------------------------------------------------------------
Summary of changes:
utils/nsurl.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 4454ba8..9e19275 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -150,7 +150,18 @@ enum scheme_type {
};
-/** nsurl components */
+/**
+ * nsurl components
+ *
+ * [scheme]://[username]:[password]@[host]:[port][path][?query]#[fragment]
+ *
+ * Note:
+ * "path" string includes preceding '/', if needed for the scheme
+ * "query" string always includes preceding '?'
+ *
+ * The other spanned punctuation is to be inserted when building URLs from
+ * components.
+ */
struct nsurl_components {
lwc_string *scheme;
lwc_string *username;
@@ -167,8 +178,6 @@ struct nsurl_components {
/**
* NetSurf URL object
- *
- * [scheme]://[username][:password]@[host]:[port][/path][?query][#fragment]
*/
struct nsurl {
struct nsurl_components components;
--
NetSurf Browser
7 years, 10 months