summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/Doxyfile3
-rw-r--r--Makefile7
-rw-r--r--content/handlers/Makefile7
-rw-r--r--content/handlers/css/Makefile (renamed from css/Makefile)1
-rw-r--r--content/handlers/css/css.c (renamed from css/css.c)61
-rw-r--r--content/handlers/css/css.h (renamed from css/css.h)20
-rw-r--r--content/handlers/css/dump.c (renamed from css/dump.c)201
-rw-r--r--content/handlers/css/dump.h (renamed from css/dump.h)8
-rw-r--r--content/handlers/css/hints.c (renamed from css/hints.c)17
-rw-r--r--content/handlers/css/hints.h (renamed from css/hints.h)12
-rw-r--r--content/handlers/css/internal.c (renamed from css/internal.c)20
-rw-r--r--content/handlers/css/internal.h (renamed from css/internal.h)16
-rw-r--r--content/handlers/css/select.c (renamed from css/select.c)82
-rw-r--r--content/handlers/css/select.h (renamed from css/select.h)3
-rw-r--r--content/handlers/css/utils.c (renamed from css/utils.c)43
-rw-r--r--content/handlers/css/utils.h49
-rw-r--r--content/handlers/image/Makefile2
-rw-r--r--content/handlers/image/svg.c2
-rw-r--r--desktop/browser.c2
-rw-r--r--desktop/browser_history.c1
-rw-r--r--desktop/font_haru.c3
-rw-r--r--desktop/netsurf.c2
-rw-r--r--desktop/print.c2
-rw-r--r--desktop/print.h3
-rw-r--r--desktop/save_complete.c2
-rw-r--r--desktop/save_pdf.c11
-rw-r--r--desktop/system_colour.c4
-rw-r--r--desktop/textarea.c2
-rw-r--r--desktop/tree.c1
-rw-r--r--desktop/treeview.c2
-rw-r--r--frontends/amiga/plotters.c2
-rw-r--r--include/netsurf/css.h (renamed from css/utils.h)17
-rw-r--r--render/box.c5
-rw-r--r--render/box.h3
-rw-r--r--render/box_construct.c7
-rw-r--r--render/box_normalise.c8
-rw-r--r--render/font.c3
-rw-r--r--render/form.c3
-rw-r--r--render/html.h1
-rw-r--r--render/html_css.c1
-rw-r--r--render/html_internal.h5
-rw-r--r--render/html_object.c2
-rw-r--r--render/html_redraw.c3
-rw-r--r--render/layout.c5
-rw-r--r--render/table.c9
-rw-r--r--render/textplain.c3
46 files changed, 341 insertions, 325 deletions
diff --git a/Docs/Doxyfile b/Docs/Doxyfile
index 5b8b25316..24cc3da77 100644
--- a/Docs/Doxyfile
+++ b/Docs/Doxyfile
@@ -672,12 +672,13 @@ INPUT = frontends/amiga \
frontends/riscos/templates \
frontends/riscos/scripts \
frontends/windows \
- css \
+ include/netsurf \
render \
desktop \
content \
content/fetchers \
content/handlers/image \
+ content/handlers/css \
javascript \
javascript/jsapi \
utils \
diff --git a/Makefile b/Makefile
index 35e734e60..fe97f1c4d 100644
--- a/Makefile
+++ b/Makefile
@@ -539,8 +539,8 @@ $(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG))
$(eval $(call pkg_config_find_and_add_enabled,ROSPRITE,librosprite,Sprite))
# add top level and build directory to include search path
-CFLAGS += -I. -Ifrontends -I$(OBJROOT)
-CXXFLAGS += -I. -Ifrontends -I$(OBJROOT)
+CFLAGS += -I. -Iinclude -Ifrontends -I$(OBJROOT)
+CXXFLAGS += -I. -Iinclude -Ifrontends -I$(OBJROOT)
# export the user agent format
CFLAGS += -DNETSURF_UA_FORMAT_STRING=\"$(NETSURF_UA_FORMAT_STRING)\"
@@ -585,9 +585,6 @@ include frontends/Makefile
# Content sources
include content/Makefile
-# CSS sources
-include css/Makefile
-
# render sources
include render/Makefile
diff --git a/content/handlers/Makefile b/content/handlers/Makefile
index 97d2813b4..a12d8cc21 100644
--- a/content/handlers/Makefile
+++ b/content/handlers/Makefile
@@ -1,4 +1,9 @@
# Image content handler sources
include content/handlers/image/Makefile
-S_IMAGE := $(addprefix content/handlers/,$(S_IMAGE))
+S_IMAGE := $(addprefix content/handlers/image/,$(S_IMAGE))
+
+# CSS sources
+include content/handlers/css/Makefile
+
+S_CSS := $(addprefix content/handlers/css/,$(S_CSS))
diff --git a/css/Makefile b/content/handlers/css/Makefile
index 127dbaa32..bbfc8d7b4 100644
--- a/css/Makefile
+++ b/content/handlers/css/Makefile
@@ -2,4 +2,3 @@
S_CSS := css.c dump.c internal.c hints.c select.c utils.c
-S_CSS := $(addprefix css/,$(S_CSS))
diff --git a/css/css.c b/content/handlers/css/css.c
index 66dc6d4ba..4c0cb7a4c 100644
--- a/css/css.c
+++ b/content/handlers/css/css.c
@@ -30,9 +30,9 @@
#include "utils/log.h"
#include "utils/messages.h"
-#include "css/css.h"
-#include "css/hints.h"
-#include "css/internal.h"
+#include "css.h"
+#include "hints.h"
+#include "internal.h"
/* Define to trace import fetches */
#undef NSCSS_IMPORT_TRACE
@@ -76,11 +76,11 @@ typedef struct nscss_content
*/
typedef struct {
struct content_css_data *css; /**< Object containing import */
- uint32_t index; /**< Index into parent sheet's
+ uint32_t index; /**< Index into parent sheet's
* imports array */
} nscss_import_ctx;
-static bool nscss_process_data(struct content *c, const char *data,
+static bool nscss_process_data(struct content *c, const char *data,
unsigned int size);
static bool nscss_convert(struct content *c);
static void nscss_destroy(struct content *c);
@@ -91,13 +91,13 @@ static content_type nscss_content_type(void);
static nserror nscss_create_css_data(struct content_css_data *c,
const char *url, const char *charset, bool quirks,
nscss_done_callback done, void *pw);
-static css_error nscss_process_css_data(struct content_css_data *c, const char *data,
+static css_error nscss_process_css_data(struct content_css_data *c, const char *data,
unsigned int size);
static css_error nscss_convert_css_data(struct content_css_data *c);
static void nscss_destroy_css_data(struct content_css_data *c);
static void nscss_content_done(struct content_css_data *css, void *pw);
-static css_error nscss_handle_import(void *pw, css_stylesheet *parent,
+static css_error nscss_handle_import(void *pw, css_stylesheet *parent,
lwc_string *url, uint64_t media);
static nserror nscss_import(hlcache_handle *handle,
const hlcache_event *event, void *pw);
@@ -151,7 +151,7 @@ nscss_create(const content_handler *handler,
}
/* Find charset specified on HTTP layer, if any */
- error = http_parameter_list_find_item(params, corestring_lwc_charset,
+ error = http_parameter_list_find_item(params, corestring_lwc_charset,
&charset_value);
if (error != NSERROR_OK || lwc_string_length(charset_value) == 0) {
/* No charset specified, use fallback, if any */
@@ -167,8 +167,8 @@ nscss_create(const content_handler *handler,
xnsbase = nsurl_access(content_get_url(&result->base));
}
- error = nscss_create_css_data(&result->data,
- xnsbase, charset, result->base.quirks,
+ error = nscss_create_css_data(&result->data,
+ xnsbase, charset, result->base.quirks,
nscss_content_done, result);
if (error != NSERROR_OK) {
msg_data.error = messages_get("NoMemory");
@@ -273,7 +273,7 @@ bool nscss_process_data(struct content *c, const char *data, unsigned int size)
static css_error nscss_process_css_data(struct content_css_data *c,
const char *data, unsigned int size)
{
- return css_stylesheet_append_data(c->sheet,
+ return css_stylesheet_append_data(c->sheet,
(const uint8_t *) data, size);
}
@@ -316,7 +316,7 @@ static css_error nscss_convert_css_data(struct content_css_data *c)
/* We must not have registered any imports yet */
assert(c->next_to_register == (uint32_t) -1);
- /* Start registering, until we find one that
+ /* Start registering, until we find one that
* hasn't finished fetching */
c->next_to_register = 0;
error = nscss_register_imports(c);
@@ -396,7 +396,7 @@ nserror nscss_clone(const struct content *old, struct content **newc)
/* Simply replay create/process/convert */
error = nscss_create_css_data(&new_css->data,
nsurl_access(content_get_url(&new_css->base)),
- old_css->data.charset,
+ old_css->data.charset,
new_css->base.quirks,
nscss_content_done, new_css);
if (error != NSERROR_OK) {
@@ -430,12 +430,7 @@ bool nscss_matches_quirks(const struct content *c, bool quirks)
return c->quirks == quirks;
}
-/**
- * Retrieve the stylesheet object associated with a CSS content
- *
- * \param h Stylesheet content
- * \return Pointer to stylesheet object
- */
+/* exported interface documented in netsurf/css.h */
css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h)
{
nscss_content *c = (nscss_content *) hlcache_handle_get_content(h);
@@ -445,13 +440,7 @@ css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h)
return c->data.sheet;
}
-/**
- * Retrieve imported stylesheets
- *
- * \param h Stylesheet containing imports
- * \param n Pointer to location to receive number of imports
- * \return Pointer to array of imported stylesheets
- */
+/* exported interface documented in netsurf/css.h */
struct nscss_import *nscss_get_imports(hlcache_handle *h, uint32_t *n)
{
nscss_content *c = (nscss_content *) hlcache_handle_get_content(h);
@@ -562,7 +551,7 @@ css_error nscss_handle_import(void *pw, css_stylesheet *parent,
ctx->index = c->import_count;
/* Increase space in table */
- imports = realloc(c->imports, (c->import_count + 1) *
+ imports = realloc(c->imports, (c->import_count + 1) *
sizeof(struct nscss_import));
if (imports == NULL) {
free(ctx);
@@ -710,12 +699,12 @@ css_error nscss_register_imports(struct content_css_data *c)
/* Register imported sheets */
for (index = c->next_to_register; index < c->import_count; index++) {
- /* Stop registering if we encounter one whose fetch hasn't
- * completed yet. We'll resume at this point when it has
+ /* Stop registering if we encounter one whose fetch hasn't
+ * completed yet. We'll resume at this point when it has
* completed.
*/
- if (c->imports[index].c != NULL &&
- content_get_status(c->imports[index].c) !=
+ if (c->imports[index].c != NULL &&
+ content_get_status(c->imports[index].c) !=
CONTENT_STATUS_DONE) {
break;
}
@@ -751,7 +740,7 @@ css_error nscss_register_import(struct content_css_data *c,
css_error error;
if (import != NULL) {
- nscss_content *s =
+ nscss_content *s =
(nscss_content *) hlcache_handle_get_content(import);
sheet = s->data.sheet;
} else {
@@ -822,16 +811,14 @@ static const content_handler css_content_handler = {
.no_share = false,
};
-/**
- * Initialise the CSS content handler
- */
+/* exported interface documented in netsurf/css.h */
nserror nscss_init(void)
{
nserror error;
- error = content_factory_register_handler("text/css",
+ error = content_factory_register_handler("text/css",
&css_content_handler);
- if (error != NSERROR_OK)
+ if (error != NSERROR_OK)
goto error;
error = css_hint_init();
diff --git a/css/css.h b/content/handlers/css/css.h
index be8d4bcd8..4b38829f0 100644
--- a/css/css.h
+++ b/content/handlers/css/css.h
@@ -35,10 +35,28 @@ struct nscss_import {
uint64_t media; /**< Media types that sheet applies to */
};
+/**
+ * Initialise the CSS content handler
+ *
+ * \return NSERROR_OK on success or error code on faliure
+ */
nserror nscss_init(void);
+/**
+ * Retrieve the stylesheet object associated with a CSS content
+ *
+ * \param h Stylesheet content
+ * \return Pointer to stylesheet object
+ */
css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h);
+
+/**
+ * Retrieve imported stylesheets
+ *
+ * \param h Stylesheet containing imports
+ * \param n Pointer to location to receive number of imports
+ * \return Pointer to array of imported stylesheets
+ */
struct nscss_import *nscss_get_imports(struct hlcache_handle *h, uint32_t *n);
#endif
-
diff --git a/css/dump.c b/content/handlers/css/dump.c
index d3ebc9481..125b133cf 100644
--- a/css/dump.c
+++ b/content/handlers/css/dump.c
@@ -17,19 +17,105 @@
*/
#include <stdio.h>
+#include <libcss/libcss.h>
-#include "css/dump.h"
+#include "dump.h"
-static void dump_css_fixed(FILE *stream, css_fixed f);
-static void dump_css_number(FILE *stream, css_fixed val);
-static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit);
+/**
+ * Dump a fixed point value to the stream in a textual form.
+ *
+ * \param stream Stream to write to
+ * \param f Value to write
+ */
+static void dump_css_fixed(FILE *stream, css_fixed f)
+{
+#define NSCSS_ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
+ uint32_t uintpart = FIXTOINT(NSCSS_ABS(f));
+ /* + 500 to ensure round to nearest (division will truncate) */
+ uint32_t fracpart = ((NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);
+#undef NSCSS_ABS
+
+ fprintf(stream, "%s%d.%03d", f < 0 ? "-" : "", uintpart, fracpart);
+}
/**
- * Dump a computed style \a style to the give file handle \a stream.
+ * Dump a numeric value to the stream in a textual form.
*
* \param stream Stream to write to
- * \param style Computed style to dump
+ * \param val Value to write
*/
+static void dump_css_number(FILE *stream, css_fixed val)
+{
+ if (INTTOFIX(FIXTOINT(val)) == val)
+ fprintf(stream, "%d", FIXTOINT(val));
+ else
+ dump_css_fixed(stream, val);
+}
+
+/**
+ * Dump a dimension to the stream in a textual form.
+ *
+ * \param stream Stream to write to
+ * \param val Value to write
+ * \param unit Unit to write
+ */
+static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
+{
+ dump_css_number(stream, val);
+
+ switch (unit) {
+ case CSS_UNIT_PX:
+ fprintf(stream, "px");
+ break;
+ case CSS_UNIT_EX:
+ fprintf(stream, "ex");
+ break;
+ case CSS_UNIT_EM:
+ fprintf(stream, "em");
+ break;
+ case CSS_UNIT_IN:
+ fprintf(stream, "in");
+ break;
+ case CSS_UNIT_CM:
+ fprintf(stream, "cm");
+ break;
+ case CSS_UNIT_MM:
+ fprintf(stream, "mm");
+ break;
+ case CSS_UNIT_PT:
+ fprintf(stream, "pt");
+ break;
+ case CSS_UNIT_PC:
+ fprintf(stream, "pc");
+ break;
+ case CSS_UNIT_PCT:
+ fprintf(stream, "%%");
+ break;
+ case CSS_UNIT_DEG:
+ fprintf(stream, "deg");
+ break;
+ case CSS_UNIT_GRAD:
+ fprintf(stream, "grad");
+ break;
+ case CSS_UNIT_RAD:
+ fprintf(stream, "rad");
+ break;
+ case CSS_UNIT_MS:
+ fprintf(stream, "ms");
+ break;
+ case CSS_UNIT_S:
+ fprintf(stream, "s");
+ break;
+ case CSS_UNIT_HZ:
+ fprintf(stream, "Hz");
+ break;
+ case CSS_UNIT_KHZ:
+ fprintf(stream, "kHz");
+ break;
+ }
+}
+
+/* exported interface documented in content/handlers/css/dump.h */
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
{
uint8_t val;
@@ -74,7 +160,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
val = css_computed_background_image(style, &url);
if (val == CSS_BACKGROUND_IMAGE_IMAGE && url != NULL) {
fprintf(stream, "background-image: url('%.*s') ",
- (int) lwc_string_length(url),
+ (int) lwc_string_length(url),
lwc_string_data(url));
} else if (val == CSS_BACKGROUND_IMAGE_NONE) {
fprintf(stream, "background-image: none ");
@@ -1008,7 +1094,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
val = css_computed_list_style_image(style, &url);
if (url != NULL) {
fprintf(stream, "list-style-image: url('%.*s') ",
- (int) lwc_string_length(url),
+ (int) lwc_string_length(url),
lwc_string_data(url));
} else if (val == CSS_LIST_STYLE_IMAGE_NONE) {
fprintf(stream, "list-style-image: none ");
@@ -1705,102 +1791,3 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
fprintf(stream, "}");
}
-
-/******************************************************************************
- * Helper functions for nscss_dump_computed_style *
- ******************************************************************************/
-
-/**
- * Dump a fixed point value to the stream in a textual form.
- *
- * \param stream Stream to write to
- * \param f Value to write
- */
-void dump_css_fixed(FILE *stream, css_fixed f)
-{
-#define NSCSS_ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
- uint32_t uintpart = FIXTOINT(NSCSS_ABS(f));
- /* + 500 to ensure round to nearest (division will truncate) */
- uint32_t fracpart = ((NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);
-#undef NSCSS_ABS
-
- fprintf(stream, "%s%d.%03d", f < 0 ? "-" : "", uintpart, fracpart);
-}
-
-/**
- * Dump a numeric value to the stream in a textual form.
- *
- * \param stream Stream to write to
- * \param val Value to write
- */
-void dump_css_number(FILE *stream, css_fixed val)
-{
- if (INTTOFIX(FIXTOINT(val)) == val)
- fprintf(stream, "%d", FIXTOINT(val));
- else
- dump_css_fixed(stream, val);
-}
-
-/**
- * Dump a dimension to the stream in a textual form.
- *
- * \param stream Stream to write to
- * \param val Value to write
- * \param unit Unit to write
- */
-void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
-{
- dump_css_number(stream, val);
-
- switch (unit) {
- case CSS_UNIT_PX:
- fprintf(stream, "px");
- break;
- case CSS_UNIT_EX:
- fprintf(stream, "ex");
- break;
- case CSS_UNIT_EM:
- fprintf(stream, "em");
- break;
- case CSS_UNIT_IN:
- fprintf(stream, "in");
- break;
- case CSS_UNIT_CM:
- fprintf(stream, "cm");
- break;
- case CSS_UNIT_MM:
- fprintf(stream, "mm");
- break;
- case CSS_UNIT_PT:
- fprintf(stream, "pt");
- break;
- case CSS_UNIT_PC:
- fprintf(stream, "pc");
- break;
- case CSS_UNIT_PCT:
- fprintf(stream, "%%");
- break;
- case CSS_UNIT_DEG:
- fprintf(stream, "deg");
- break;
- case CSS_UNIT_GRAD:
- fprintf(stream, "grad");
- break;
- case CSS_UNIT_RAD:
- fprintf(stream, "rad");
- break;
- case CSS_UNIT_MS:
- fprintf(stream, "ms");
- break;
- case CSS_UNIT_S:
- fprintf(stream, "s");
- break;
- case CSS_UNIT_HZ:
- fprintf(stream, "Hz");
- break;
- case CSS_UNIT_KHZ:
- fprintf(stream, "kHz");
- break;
- }
-}
-
diff --git a/css/dump.h b/content/handlers/css/dump.h
index 25d283e9e..470e56481 100644
--- a/css/dump.h
+++ b/content/handlers/css/dump.h
@@ -19,8 +19,12 @@
#ifndef NETSURF_CSS_DUMP_H_
#define NETSURF_CSS_DUMP_H_
-#include "css/css.h"
-
+/**
+ * Dump a computed style \a style to the give file handle \a stream.
+ *
+ * \param stream Stream to write to
+ * \param style Computed style to dump
+ */
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style);
#endif
diff --git a/css/hints.c b/content/handlers/css/hints.c
index 356153983..f394ea836 100644
--- a/css/hints.c
+++ b/content/handlers/css/hints.c
@@ -25,8 +25,8 @@
#include "utils/nsurl.h"
#include "utils/utils.h"
-#include "css/hints.h"
-#include "css/select.h"
+#include "hints.h"
+#include "select.h"
#define LOG_STATS
#undef LOG_STATS
@@ -445,13 +445,7 @@ static bool parse_named_colour(const char *name, css_color *result)
return entry != NULL;
}
-/**
- * Parser for colours specified in attribute values.
- *
- * \param data Data to parse (NUL-terminated)
- * \param result Pointer to location to receive resulting css_color
- * \return true on success, false on invalid input
- */
+/* exported interface documented in content/handlers/css/hints.h */
bool nscss_parse_colour(const char *data, css_color *result)
{
size_t len = strlen(data);
@@ -512,7 +506,7 @@ bool nscss_parse_colour(const char *data, css_color *result)
* \param unit Pointer to location to receive unit
* \return True on success, false on failure
*/
-static bool parse_font_size(const char *size, uint8_t *val,
+static bool parse_font_size(const char *size, uint8_t *val,
css_fixed *len, css_unit *unit)
{
static const uint8_t size_map[] = {
@@ -564,7 +558,7 @@ static bool parse_font_size(const char *size, uint8_t *val,
if (value == 7) {
/* Manufacture xxx-large */
- *len = FDIV(FMUL(INTTOFIX(3), INTTOFIX(nsoption_int(font_size))),
+ *len = FDIV(FMUL(INTTOFIX(3), INTTOFIX(nsoption_int(font_size))),
F_10);
} else {
/* Len is irrelevant */
@@ -1608,4 +1602,3 @@ css_error node_presentational_hint(void *pw, void *node,
return CSS_OK;
}
-
diff --git a/css/hints.h b/content/handlers/css/hints.h
index fda1bec7e..2c1835970 100644
--- a/css/hints.h
+++ b/content/handlers/css/hints.h
@@ -21,18 +21,17 @@
#include <stdint.h>
-#include "css/css.h"
+#include <libcss/libcss.h>
nserror css_hint_init(void);
void css_hint_fini(void);
-
/**
* Callback to retrieve presentational hints for a node
*
* \param[in] pw HTML document
* \param[in] node DOM node
- * \param[out] nhints number of hints retrived
+ * \param[out] nhints number of hints retrived
* \param[out] hints retrived hints
* \return CSS_OK on success,
* CSS_PROPERTY_NOT_SET if there is no hint for the requested property,
@@ -44,6 +43,13 @@ css_error node_presentational_hint(
uint32_t *nhints,
css_hint **hints);
+/**
+ * Parser for colours specified in attribute values.
+ *
+ * \param data Data to parse (NUL-terminated)
+ * \param result Pointer to location to receive resulting css_color
+ * \return true on success, false on invalid input
+ */
bool nscss_parse_colour(const char *data, css_color *result);
#endif
diff --git a/css/internal.c b/content/handlers/css/internal.c
index 46c529b03..d66b87a54 100644
--- a/css/internal.c
+++ b/content/handlers/css/internal.c
@@ -17,23 +17,14 @@
*/
#include <string.h>
-
-#include "css/internal.h"
+#include <libcss/libcss.h>
#include "utils/nsurl.h"
-/**
- * URL resolution callback for libcss
- *
- * \param pw Resolution context
- * \param base Base URI
- * \param rel Relative URL
- * \param abs Pointer to location to receive resolved URL
- * \return CSS_OK on success,
- * CSS_NOMEM on memory exhaustion,
- * CSS_INVALID if resolution failed.
- */
-css_error nscss_resolve_url(void *pw, const char *base,
+#include "internal.h"
+
+/* exported interface documented in content/handlers/css/internal.h */
+css_error nscss_resolve_url(void *pw, const char *base,
lwc_string *rel, lwc_string **abs)
{
lwc_error lerror;
@@ -70,4 +61,3 @@ css_error nscss_resolve_url(void *pw, const char *base,
return CSS_OK;
}
-
diff --git a/css/internal.h b/content/handlers/css/internal.h
index 0344d6b32..5c539c843 100644
--- a/css/internal.h
+++ b/content/handlers/css/internal.h
@@ -19,9 +19,17 @@
#ifndef NETSURF_CSS_INTERNAL_H_
#define NETSURF_CSS_INTERNAL_H_
-#include "css/css.h"
-
-css_error nscss_resolve_url(void *pw, const char *base,
- lwc_string *rel, lwc_string **abs);
+/**
+ * URL resolution callback for libcss
+ *
+ * \param pw Resolution context
+ * \param base Base URI
+ * \param rel Relative URL
+ * \param abs Pointer to location to receive resolved URL
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_INVALID if resolution failed.
+ */
+css_error nscss_resolve_url(void *pw, const char *base, lwc_string *rel, lwc_string **abs);
#endif
diff --git a/css/select.c b/content/handlers/css/select.c
index a929cf10a..ea324e773 100644
--- a/css/select.c
+++ b/content/handlers/css/select.c
@@ -26,9 +26,9 @@
#include "utils/corestrings.h"
#include "utils/log.h"
-#include "css/internal.h"
-#include "css/hints.h"
-#include "css/select.h"
+#include "internal.h"
+#include "hints.h"
+#include "select.h"
static css_error node_name(void *pw, void *node, css_qname *qname);
static css_error node_classes(void *pw, void *node,
@@ -265,7 +265,7 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
return NULL;
}
- /* If there's a parent style, compose with partial to obtain
+ /* If there's a parent style, compose with partial to obtain
* complete computed style for element */
if (ctx->parent_style != NULL) {
/* Complete the computed style, by composing with the parent
@@ -498,7 +498,7 @@ css_error node_name(void *pw, void *node, css_qname *qname)
* be allocated using the same allocator as used by libcss during style
* selection.
*/
-css_error node_classes(void *pw, void *node,
+css_error node_classes(void *pw, void *node,
lwc_string ***classes, uint32_t *n_classes)
{
dom_node *n = node;
@@ -697,7 +697,7 @@ css_error named_generic_sibling_node(void *pw, void *node,
return CSS_OK;
}
- if (dom_string_caseless_lwc_isequal(name,
+ if (dom_string_caseless_lwc_isequal(name,
qname->name)) {
dom_string_unref(name);
dom_node_unref(n);
@@ -844,7 +844,7 @@ css_error node_has_class(void *pw, void *node,
dom_node *n = node;
dom_exception err;
- /** \todo: Ensure that libdom performs case-insensitive
+ /** \todo: Ensure that libdom performs case-insensitive
* matching in quirks mode */
err = dom_element_has_class(n, name, match);
@@ -907,7 +907,7 @@ css_error node_has_attribute(void *pw, void *node,
dom_exception err;
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -953,7 +953,7 @@ css_error node_has_attribute_equal(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1005,7 +1005,7 @@ css_error node_has_attribute_dashmatch(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1073,7 +1073,7 @@ css_error node_has_attribute_includes(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1141,7 +1141,7 @@ css_error node_has_attribute_prefix(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1163,7 +1163,7 @@ css_error node_has_attribute_prefix(void *pw, void *node,
const char *data = (const char *) dom_string_data(atr_val);
size_t len = dom_string_byte_length(atr_val);
- if ((len >= vlen) &&
+ if ((len >= vlen) &&
(strncasecmp(data, lwc_string_data(value), vlen) == 0)) {
*match = true;
}
@@ -1205,7 +1205,7 @@ css_error node_has_attribute_suffix(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1226,10 +1226,10 @@ css_error node_has_attribute_suffix(void *pw, void *node,
if (*match == false) {
const char *data = (const char *) dom_string_data(atr_val);
size_t len = dom_string_byte_length(atr_val);
-
+
const char *start = (char *) data + len - vlen;
- if ((len >= vlen) &&
+ if ((len >= vlen) &&
(strncasecmp(start, lwc_string_data(value), vlen) == 0)) {
*match = true;
}
@@ -1273,7 +1273,7 @@ css_error node_has_attribute_substring(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1299,7 +1299,7 @@ css_error node_has_attribute_substring(void *pw, void *node,
if (len >= vlen) {
while (start <= last_start) {
- if (strncasecmp(start, vdata,
+ if (strncasecmp(start, vdata,
vlen) == 0) {
*match = true;
break;
@@ -1348,38 +1348,38 @@ css_error node_is_root(void *pw, void *node, bool *match)
if (type != DOM_DOCUMENT_NODE) {
*match = false;
return CSS_OK;
- }
+ }
}
-
+
*match = true;
return CSS_OK;
}
-static int
-node_count_siblings_check(dom_node *node,
- bool check_name,
+static int
+node_count_siblings_check(dom_node *node,
+ bool check_name,
dom_string *name)
{
dom_node_type type;
int ret = 0;
dom_exception exc;
- if (node == NULL)
+ if (node == NULL)
return 0;
exc = dom_node_get_node_type(node, &type);
if ((exc != DOM_NO_ERR) || (type != DOM_ELEMENT_NODE)) {
return 0;
}
-
+
if (check_name) {
dom_string *node_name = NULL;
exc = dom_node_get_node_name(node, &node_name);
if ((exc == DOM_NO_ERR) && (node_name != NULL)) {
- if (dom_string_caseless_isequal(name,
+ if (dom_string_caseless_isequal(name,
node_name)) {
ret = 1;
}
@@ -1388,10 +1388,10 @@ node_count_siblings_check(dom_node *node,
} else {
ret = 1;
}
-
+
return ret;
}
-
+
/**
* Callback to count a node's siblings.
*
@@ -1418,16 +1418,16 @@ css_error node_count_siblings(void *pw, void *n, bool same_name,
return CSS_NOMEM;
}
}
-
+
if (after) {
dom_node *node = dom_node_ref(n);
dom_node *next;
-
+
do {
exc = dom_node_get_next_sibling(node, &next);
if ((exc != DOM_NO_ERR))
break;
-
+
dom_node_unref(node);
node = next;
@@ -1436,12 +1436,12 @@ css_error node_count_siblings(void *pw, void *n, bool same_name,
} else {
dom_node *node = dom_node_ref(n);
dom_node *next;
-
+
do {
exc = dom_node_get_previous_sibling(node, &next);
if ((exc != DOM_NO_ERR))
break;
-
+
dom_node_unref(node);
node = next;
@@ -1451,7 +1451,7 @@ css_error node_count_siblings(void *pw, void *n, bool same_name,
}
if (node_name != NULL) {
- dom_string_unref(node_name);
+ dom_string_unref(node_name);
}
*count = cnt;
@@ -1472,14 +1472,14 @@ css_error node_is_empty(void *pw, void *node, bool *match)
{
dom_node *n = node, *next;
dom_exception err;
-
+
*match = true;
-
+
err = dom_node_get_first_child(n, &n);
if (err != DOM_NO_ERR) {
return CSS_BADPARM;
}
-
+
while (n != NULL) {
dom_node_type ntype;
err = dom_node_get_node_type(n, &ntype);
@@ -1487,14 +1487,14 @@ css_error node_is_empty(void *pw, void *node, bool *match)
dom_node_unref(n);
return CSS_BADPARM;
}
-
+
if (ntype == DOM_ELEMENT_NODE ||
ntype == DOM_TEXT_NODE) {
*match = false;
dom_node_unref(n);
break;
}
-
+
err = dom_node_get_next_sibling(n, &next);
if (err != DOM_NO_ERR) {
dom_node_unref(n);
@@ -1503,7 +1503,7 @@ css_error node_is_empty(void *pw, void *node, bool *match)
dom_node_unref(n);
n = next;
}
-
+
return CSS_OK;
}
@@ -1531,7 +1531,7 @@ css_error node_is_link(void *pw, void *n, bool *match)
if (dom_string_caseless_lwc_isequal(node_name, corestring_lwc_a)) {
bool has_href;
exc = dom_element_has_attribute(node, corestring_dom_href,
- &has_href);
+ &has_href);
if ((exc == DOM_NO_ERR) && (has_href)) {
*match = true;
} else {
diff --git a/css/select.h b/content/handlers/css/select.h
index 0e0be9578..abfb85814 100644
--- a/css/select.h
+++ b/content/handlers/css/select.h
@@ -23,7 +23,7 @@
#include <dom/dom.h>
-#include "css/css.h"
+#include <libcss/libcss.h>
struct content;
struct nsurl;
@@ -52,6 +52,7 @@ css_computed_style *nscss_get_blank_style(nscss_select_ctx *ctx,
css_error named_ancestor_node(void *pw, void *node,
const css_qname *qname, void **ancestor);
+
css_error node_is_visited(void *pw, void *node, bool *match);
#endif
diff --git a/css/utils.c b/content/handlers/css/utils.c
index 9bf743cac..59ad41216 100644
--- a/css/utils.c
+++ b/content/handlers/css/utils.c
@@ -19,21 +19,15 @@
#include <assert.h>
-#include "css/utils.h"
-
#include "utils/nsoption.h"
#include "utils/log.h"
+#include "utils.h"
+
/** Screen DPI in fixed point units: defaults to 90, which RISC OS uses */
css_fixed nscss_screen_dpi = F_90;
-/**
- * Convert an absolute CSS length to points.
- *
- * \param length Length to convert
- * \param unit Corresponding unit
- * \return length in points
- */
+/* exported interface documented in content/handlers/css/utils.h */
css_fixed nscss_len2pt(css_fixed length, css_unit unit)
{
/* Length must not be relative */
@@ -46,10 +40,10 @@ css_fixed nscss_len2pt(css_fixed length, css_unit unit)
/* 1in = 72pt */
case CSS_UNIT_IN: return FMUL(length, F_72);
/* 1in = 2.54cm => 1cm = (72/2.54)pt */
- case CSS_UNIT_CM: return FMUL(length,
+ case CSS_UNIT_CM: return FMUL(length,
FDIV(F_72, FLTTOFIX(2.54)));
/* 1in = 25.4mm => 1mm = (72/25.4)pt */
- case CSS_UNIT_MM: return FMUL(length,
+ case CSS_UNIT_MM: return FMUL(length,
FDIV(F_72, FLTTOFIX(25.4)));
case CSS_UNIT_PT: return length;
/* 1pc = 12pt */
@@ -61,16 +55,8 @@ css_fixed nscss_len2pt(css_fixed length, css_unit unit)
}
-/**
- * Convert a CSS length to pixels.
- *
- * \param length Length to convert
- * \param unit Corresponding unit
- * \param style Computed style applying to length. May be NULL if unit is
- * neither em nor ex
- * \return length in pixels
- */
-css_fixed nscss_len2px(css_fixed length, css_unit unit,
+/* exported interface documented in content/handlers/css/utils.h */
+css_fixed nscss_len2px(css_fixed length, css_unit unit,
const css_computed_style *style)
{
/* We assume the screen and any other output has the same dpi */
@@ -95,7 +81,7 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit,
font_size = FDIV(INTTOFIX(nsoption_int(font_min_size)), F_10);
}
- /* Convert to pixels (manually, to maximise precision)
+ /* Convert to pixels (manually, to maximise precision)
* 1in = 72pt => 1pt = (DPI/72)px */
px_per_unit = FDIV(FMUL(font_size, nscss_screen_dpi), F_72);
@@ -104,27 +90,27 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit,
px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.6));
}
break;
- case CSS_UNIT_PX:
+ case CSS_UNIT_PX:
px_per_unit = F_1;
break;
/* 1in = DPIpx */
- case CSS_UNIT_IN:
+ case CSS_UNIT_IN:
px_per_unit = nscss_screen_dpi;
break;
/* 1in = 2.54cm => 1cm = (DPI/2.54)px */
- case CSS_UNIT_CM:
+ case CSS_UNIT_CM:
px_per_unit = FDIV(nscss_screen_dpi, FLTTOFIX(2.54));
break;
/* 1in = 25.4mm => 1mm = (DPI/25.4)px */
- case CSS_UNIT_MM:
+ case CSS_UNIT_MM:
px_per_unit = FDIV(nscss_screen_dpi, FLTTOFIX(25.4));
break;
/* 1in = 72pt => 1pt = (DPI/72)px */
- case CSS_UNIT_PT:
+ case CSS_UNIT_PT:
px_per_unit = FDIV(nscss_screen_dpi, F_72);
break;
/* 1pc = 12pt => 1in = 6pc => 1pc = (DPI/6)px */
- case CSS_UNIT_PC:
+ case CSS_UNIT_PC:
px_per_unit = FDIV(nscss_screen_dpi, INTTOFIX(6));
break;
default:
@@ -139,4 +125,3 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit,
/* Calculate total number of pixels */
return FMUL(length, TRUNCATEFIX(px_per_unit));
}
-
diff --git a/content/handlers/css/utils.h b/content/handlers/css/utils.h
new file mode 100644
index 000000000..58a5ea6e6
--- /dev/null
+++ b/content/handlers/css/utils.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009 John-Mark Bell <jmb@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/>.
+ */
+
+#ifndef NETSURF_CSS_UTILS_H_
+#define NETSURF_CSS_UTILS_H_
+
+#include <libcss/libcss.h>
+
+#include "netsurf/css.h"
+
+/** DPI of the screen, in fixed point units */
+extern css_fixed nscss_screen_dpi;
+
+/**
+ * Convert an absolute CSS length to points.
+ *
+ * \param[in] length Absolute CSS length.
+ * \param[in] unit Unit of the length.
+ * \return length in points
+ */
+css_fixed nscss_len2pt(css_fixed length, css_unit unit);
+
+/**
+ * Convert a CSS length to pixels.
+ *
+ * \param length Length to convert
+ * \param unit Corresponding unit
+ * \param style Computed style applying to length. May be NULL if unit is
+ * neither em nor ex
+ * \return length in pixels
+ */
+css_fixed nscss_len2px(css_fixed length, css_unit unit, const css_computed_style *style);
+
+#endif
diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile
index 5851a1c43..541cd2cf9 100644
--- a/content/handlers/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -12,4 +12,4 @@ S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
S_IMAGE_$(NETSURF_USE_RSVG) += rsvg.c
S_IMAGE_$(NETSURF_USE_VIDEO) += video.c
-S_IMAGE := $(addprefix image/,$(S_IMAGE_YES))
+S_IMAGE := $(S_IMAGE_YES)
diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c
index c91b00650..3eff684fd 100644
--- a/content/handlers/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -23,13 +23,13 @@
#include <assert.h>
#include <limits.h>
#include <string.h>
+#include <stdlib.h>
#include <svgtiny.h>
#include "utils/messages.h"
#include "utils/utils.h"
#include "content/content_protected.h"
-#include "css/css.h"
#include "desktop/plotters.h"
#include "svg.h"
diff --git a/desktop/browser.c b/desktop/browser.c
index 4cd017d57..2ee36fd7d 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -52,11 +52,11 @@
#include "content/fetch.h"
#include "content/hlcache.h"
#include "content/urldb.h"
+#include "content/handlers/css/utils.h"
#include "render/form_internal.h"
#include "render/html.h"
#include "render/box.h"
#include "curl/curl.h"
-#include "css/utils.h"
#include "javascript/js.h"
#include "desktop/browser_history.h"
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index b90884e04..b3d12d525 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -34,7 +34,6 @@
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "css/css.h"
#include "content/handlers/image/bitmap.h"
#include "desktop/gui_layout.h"
diff --git a/desktop/font_haru.c b/desktop/font_haru.c
index d2d7efdaf..caa751bcb 100644
--- a/desktop/font_haru.c
+++ b/desktop/font_haru.c
@@ -36,9 +36,6 @@
#include <hpdf.h>
-#include "css/css.h"
-#include "css/utils.h"
-
#include "utils/nsoption.h"
#include "desktop/save_pdf/font_haru.h"
#include "desktop/font.h"
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 440e14081..d3d45ca66 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -37,7 +37,7 @@
#include "content/hlcache.h"
#include "content/mimesniff.h"
#include "content/urldb.h"
-#include "css/css.h"
+#include "content/handlers/css/css.h"
#include "content/handlers/image/image.h"
#include "content/handlers/image/image_cache.h"
#include "javascript/js.h"
diff --git a/desktop/print.c b/desktop/print.c
index 711e907e2..c3cfefc0b 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -32,7 +32,7 @@
#include "utils/talloc.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "css/utils.h"
+#include "content/handlers/css/utils.h"
#include "render/box.h"
#include "desktop/plotters.h"
diff --git a/desktop/print.h b/desktop/print.h
index 5c51981d1..fb1fd63ac 100644
--- a/desktop/print.h
+++ b/desktop/print.h
@@ -33,8 +33,7 @@
#define NETSURF_DESKTOP_PRINT_H
#include <stdbool.h>
-
-#include "css/css.h"
+#include <libcss/libcss.h>
struct hlcache_handle;
struct printer;
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 98b0304f8..6f63960aa 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -41,7 +41,7 @@
#include "utils/messages.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "css/css.h"
+#include "content/handlers/css/css.h"
#include "render/box.h"
#include "render/html.h"
diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c
index 0168d0203..40082f23c 100644
--- a/desktop/save_pdf.c
+++ b/desktop/save_pdf.c
@@ -44,6 +44,7 @@
*/
#include "utils/config.h"
+#include "utils/errors.h"
#include "desktop/save_pdf.h"
@@ -52,18 +53,18 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-
#include <hpdf.h>
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/useragent.h"
#include "content/hlcache.h"
#include "utils/nsoption.h"
+#include "content/handlers/image/bitmap.h"
+
#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
-#include "content/handlers/image/bitmap.h"
-#include "utils/log.h"
-#include "utils/utils.h"
-#include "utils/useragent.h"
#include "font_haru.h"
diff --git a/desktop/system_colour.c b/desktop/system_colour.c
index 178c03536..f33b57a37 100644
--- a/desktop/system_colour.c
+++ b/desktop/system_colour.c
@@ -26,10 +26,10 @@
#include "utils/config.h"
#include "utils/utils.h"
#include "utils/log.h"
-#include "css/utils.h"
-#include "desktop/system_colour.h"
#include "utils/nsoption.h"
+#include "netsurf/css.h"
+#include "desktop/system_colour.h"
#define colour_list_len ((NSOPTION_SYS_COLOUR_END - NSOPTION_SYS_COLOUR_START) + 1)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 467965d39..96a1713ef 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -26,10 +26,10 @@
#include <stdint.h>
#include <string.h>
-#include "css/utils.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "content/handlers/css/utils.h"
#include "desktop/browser.h"
#include "desktop/mouse.h"
diff --git a/desktop/tree.c b/desktop/tree.c
index c5bca61da..e9a2dfdcc 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -32,7 +32,6 @@
#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "css/utils.h"
#include "utils/nsoption.h"
#include "desktop/browser.h"
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 6b04eacb9..c12ecd98e 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -23,9 +23,9 @@
*/
#include "utils/log.h"
-#include "css/utils.h"
#include "content/handlers/image/bitmap.h"
#include "content/hlcache.h"
+#include "content/handlers/css/utils.h"
#include "desktop/system_colour.h"
#include "desktop/knockout.h"
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 23a73f84a..fb9c92394 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -37,7 +37,7 @@
#include "utils/nsoption.h"
#include "utils/utils.h"
#include "utils/log.h"
-#include "css/utils.h"
+#include "netsurf/css.h"
#include "desktop/mouse.h"
#include "desktop/gui_window.h"
diff --git a/css/utils.h b/include/netsurf/css.h
index e9650db97..bd95eaeeb 100644
--- a/css/utils.h
+++ b/include/netsurf/css.h
@@ -16,14 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NETSURF_CSS_UTILS_H_
-#define NETSURF_CSS_UTILS_H_
-
-#include "css/css.h"
-#include "desktop/plot_style.h"
+/**
+ * \file
+ * Netsurf core css API
+ */
-/* DPI of the screen, in fixed point units */
-extern css_fixed nscss_screen_dpi;
+#ifndef NETSURF_CSS_H_
+#define NETSURF_CSS_H_
/**
* Convert a CSS color to a NetSurf colour primitive
@@ -63,8 +62,4 @@ extern css_fixed nscss_screen_dpi;
#define nscss_color_is_transparent(color) \
(((color) >> 24) == 0)
-css_fixed nscss_len2pt(css_fixed length, css_unit unit);
-css_fixed nscss_len2px(css_fixed length, css_unit unit,
- const css_computed_style *style);
-
#endif
diff --git a/render/box.c b/render/box.c
index bb1800b00..07ea114d4 100644
--- a/render/box.c
+++ b/render/box.c
@@ -35,9 +35,8 @@
#include "utils/utils.h"
#include "content/content_protected.h"
#include "content/hlcache.h"
-#include "css/css.h"
-#include "css/utils.h"
-#include "css/dump.h"
+#include "content/handlers/css/utils.h"
+#include "content/handlers/css/dump.h"
#include "desktop/scrollbar.h"
#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
diff --git a/render/box.h b/render/box.h
index 4ac3453aa..c3f95c21c 100644
--- a/render/box.h
+++ b/render/box.h
@@ -89,8 +89,7 @@
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
-
-#include "css/css.h"
+#include <libcss/libcss.h>
struct content;
struct box;
diff --git a/render/box_construct.c b/render/box_construct.c
index 7e982d7a3..6dce5c690 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -43,10 +43,9 @@
#include "utils/utils.h"
#include "utils/string.h"
#include "content/content_protected.h"
-#include "css/css.h"
-#include "css/hints.h"
-#include "css/select.h"
-#include "css/utils.h"
+#include "content/handlers/css/hints.h"
+#include "content/handlers/css/select.h"
+#include "netsurf/css.h"
#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
diff --git a/render/box_normalise.c b/render/box_normalise.c
index 1010c408b..76767a2a9 100644
--- a/render/box_normalise.c
+++ b/render/box_normalise.c
@@ -26,12 +26,14 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
-#include "css/css.h"
-#include "css/select.h"
+
+#include "utils/log.h"
+#include "utils/errors.h"
+#include "content/handlers/css/select.h"
+
#include "render/box.h"
#include "render/html_internal.h"
#include "render/table.h"
-#include "utils/log.h"
/* Define to enable box normalise debug */
#undef BOX_NORMALISE_DEBUG
diff --git a/render/font.c b/render/font.c
index 0b059a218..831097e21 100644
--- a/render/font.c
+++ b/render/font.c
@@ -22,9 +22,8 @@
* Renderer internal font handling implementation.
*/
-#include "css/css.h"
-#include "css/utils.h"
#include "utils/nsoption.h"
+#include "content/handlers/css/utils.h"
#include "render/font.h"
diff --git a/render/form.c b/render/form.c
index dce906437..75d16d83b 100644
--- a/render/form.c
+++ b/render/form.c
@@ -42,8 +42,7 @@
#include "utils/utils.h"
#include "content/fetch.h"
#include "content/hlcache.h"
-#include "css/css.h"
-#include "css/utils.h"
+#include "content/handlers/css/utils.h"
#include "desktop/browser.h"
#include "desktop/mouse.h"
#include "desktop/knockout.h"
diff --git a/render/html.h b/render/html.h
index ee204d3d6..215bfbbe6 100644
--- a/render/html.h
+++ b/render/html.h
@@ -31,7 +31,6 @@
#include <dom/bindings/hubbub/parser.h>
#include "content/content_type.h"
-#include "css/css.h"
#include "desktop/browser.h"
#include "desktop/mouse.h"
#include "desktop/plot_style.h"
diff --git a/render/html_css.c b/render/html_css.c
index 6761a6502..0c8ee3351 100644
--- a/render/html_css.c
+++ b/render/html_css.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include "content/hlcache.h"
+#include "content/handlers/css/css.h"
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/config.h"
diff --git a/render/html_internal.h b/render/html_internal.h
index de28726fb..f0e98158f 100644
--- a/render/html_internal.h
+++ b/render/html_internal.h
@@ -16,13 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Content for text/html (private data).
*/
#ifndef NETSURF_RENDER_HTML_INTERNAL_H_
#define NETSURF_RENDER_HTML_INTERNAL_H_
+#include <libcss/libcss.h>
+
#include "content/content_protected.h"
#include "desktop/selection.h"
#include "render/html.h"
diff --git a/render/html_object.c b/render/html_object.c
index 22c9b712a..9e5e26730 100644
--- a/render/html_object.c
+++ b/render/html_object.c
@@ -33,7 +33,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "content/hlcache.h"
-#include "css/utils.h"
+#include "content/handlers/css/utils.h"
#include "desktop/scrollbar.h"
#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
diff --git a/render/html_redraw.c b/render/html_redraw.c
index 93c136fb0..7f8391cf9 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -41,8 +41,7 @@
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "content/content_protected.h"
-#include "css/css.h"
-#include "css/utils.h"
+#include "content/handlers/css/utils.h"
#include "desktop/browser.h"
#include "desktop/plotters.h"
#include "desktop/selection.h"
diff --git a/render/layout.c b/render/layout.c
index e80ec994a..a7f2e8db5 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -46,10 +46,9 @@
#include "utils/log.h"
#include "utils/talloc.h"
#include "utils/utils.h"
-#include "css/css.h"
-#include "css/utils.h"
-#include "content/content_protected.h"
#include "utils/nsoption.h"
+#include "content/content_protected.h"
+#include "content/handlers/css/utils.h"
#include "desktop/browser.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
diff --git a/render/table.c b/render/table.c
index 656386491..62553ecdd 100644
--- a/render/table.c
+++ b/render/table.c
@@ -22,15 +22,14 @@
*/
#include <assert.h>
-
#include <dom/dom.h>
-#include "css/css.h"
-#include "css/utils.h"
-#include "render/box.h"
-#include "render/table.h"
#include "utils/log.h"
#include "utils/talloc.h"
+#include "content/handlers/css/utils.h"
+
+#include "render/box.h"
+#include "render/table.h"
/* Define to enable verbose table debug */
#undef TABLE_DEBUG
diff --git a/render/textplain.c b/render/textplain.c
index c825b7946..5ecf1436d 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -39,8 +39,7 @@
#include "utils/utf8.h"
#include "content/content_protected.h"
#include "content/hlcache.h"
-#include "css/css.h"
-#include "css/utils.h"
+#include "content/handlers/css/utils.h"
#include "desktop/browser.h"
#include "utils/nsoption.h"
#include "desktop/plotters.h"