r5433 jmb - in /trunk/libcss: include/libcss/errors.h include/libcss/functypes.h include/libcss/libcss.h include/libcss/stylesheet.h include/libcss/types.h src/stylesheet.c src/stylesheet.h

netsurf at semichrome.net netsurf at semichrome.net
Thu Sep 25 01:19:16 BST 2008


Author: jmb
Date: Wed Sep 24 19:19:16 2008
New Revision: 5433

URL: http://source.netsurf-browser.org?rev=5433&view=rev
Log:
Public stylesheet API & stubbed out implementations.
Make public headers use libcss_ as their guard macro prefix.

Added:
    trunk/libcss/include/libcss/stylesheet.h
Modified:
    trunk/libcss/include/libcss/errors.h
    trunk/libcss/include/libcss/functypes.h
    trunk/libcss/include/libcss/libcss.h
    trunk/libcss/include/libcss/types.h
    trunk/libcss/src/stylesheet.c
    trunk/libcss/src/stylesheet.h

Modified: trunk/libcss/include/libcss/errors.h
URL: http://source.netsurf-browser.org/trunk/libcss/include/libcss/errors.h?rev=5433&r1=5432&r2=5433&view=diff
==============================================================================
--- trunk/libcss/include/libcss/errors.h (original)
+++ trunk/libcss/include/libcss/errors.h Wed Sep 24 19:19:16 2008
@@ -5,8 +5,8 @@
  * Copyright 2007 John-Mark Bell <jmb at netsurf-browser.org>
  */
 
-#ifndef css_errors_h_
-#define css_errors_h_
+#ifndef libcss_errors_h_
+#define libcss_errors_h_
 
 #include <stddef.h>
 

Modified: trunk/libcss/include/libcss/functypes.h
URL: http://source.netsurf-browser.org/trunk/libcss/include/libcss/functypes.h?rev=5433&r1=5432&r2=5433&view=diff
==============================================================================
--- trunk/libcss/include/libcss/functypes.h (original)
+++ trunk/libcss/include/libcss/functypes.h Wed Sep 24 19:19:16 2008
@@ -5,8 +5,8 @@
  * Copyright 2007-8 John-Mark Bell <jmb at netsurf-browser.org>
  */
 
-#ifndef css_functypes_h_
-#define css_functypes_h_
+#ifndef libcss_functypes_h_
+#define libcss_functypes_h_
 
 #include <stdbool.h>
 #include <stdint.h>

Modified: trunk/libcss/include/libcss/libcss.h
URL: http://source.netsurf-browser.org/trunk/libcss/include/libcss/libcss.h?rev=5433&r1=5432&r2=5433&view=diff
==============================================================================
--- trunk/libcss/include/libcss/libcss.h (original)
+++ trunk/libcss/include/libcss/libcss.h Wed Sep 24 19:19:16 2008
@@ -5,8 +5,8 @@
  * Copyright 2007 John-Mark Bell <jmb at netsurf-browser.org>
  */
 
-#ifndef css_h_
-#define css_h_
+#ifndef libcss_h_
+#define libcss_h_
 
 #include <libcss/errors.h>
 #include <libcss/functypes.h>

Added: trunk/libcss/include/libcss/stylesheet.h
URL: http://source.netsurf-browser.org/trunk/libcss/include/libcss/stylesheet.h?rev=5433&view=auto
==============================================================================
--- trunk/libcss/include/libcss/stylesheet.h (added)
+++ trunk/libcss/include/libcss/stylesheet.h Wed Sep 24 19:19:16 2008
@@ -1,0 +1,36 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ *                http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 John-Mark Bell <jmb at netsurf-browser.org>
+ */
+
+#ifndef libcss_stylesheet_h_
+#define libcss_stylesheet_h_
+
+#include <libcss/errors.h>
+#include <libcss/types.h>
+
+/**
+ * Type of stylesheet import handler
+ */
+typedef css_error (*css_import_handler)(void *pw, const char *url,
+		css_stylesheet *sheet);
+
+css_stylesheet *css_stylesheet_create(const char *url, const char *title,
+		css_origin origin, uint32_t media,
+		css_import_handler import_callback, void *import_pw,
+		css_alloc alloc, void *alloc_pw);
+void css_stylesheet_destroy(css_stylesheet *sheet);
+
+css_error css_stylesheet_append_data(css_stylesheet *sheet,
+		const uint8_t *data, size_t len);
+css_error css_stylesheet_data_done(css_stylesheet *sheet);
+
+css_error css_stylesheet_get_url(css_stylesheet *sheet, const char **url);
+css_error css_stylesheet_get_title(css_stylesheet *sheet, const char **title);
+css_error css_stylesheet_get_origin(css_stylesheet *sheet, css_origin *origin);
+css_error css_stylesheet_get_media(css_stylesheet *sheet, uint32_t *media);
+
+#endif
+

Modified: trunk/libcss/include/libcss/types.h
URL: http://source.netsurf-browser.org/trunk/libcss/include/libcss/types.h?rev=5433&r1=5432&r2=5433&view=diff
==============================================================================
--- trunk/libcss/include/libcss/types.h (original)
+++ trunk/libcss/include/libcss/types.h Wed Sep 24 19:19:16 2008
@@ -5,8 +5,8 @@
  * Copyright 2007 John-Mark Bell <jmb at netsurf-browser.org>
  */
 
-#ifndef css_types_h_
-#define css_types_h_
+#ifndef libcss_types_h_
+#define libcss_types_h_
 
 #include <stdbool.h>
 #include <inttypes.h>
@@ -32,4 +32,13 @@
 
 typedef struct css_stylesheet css_stylesheet;
 
+/**
+ * Stylesheet origin
+ */
+typedef enum css_origin {
+	CSS_ORIGIN_UA                = 0,	/**< User agent stylesheet */
+	CSS_ORIGIN_USER              = 1,	/**< User stylesheet */
+	CSS_ORIGIN_AUTHOR            = 2	/**< Author stylesheet */
+} css_origin;
+
 #endif

Modified: trunk/libcss/src/stylesheet.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/stylesheet.c?rev=5433&r1=5432&r2=5433&view=diff
==============================================================================
--- trunk/libcss/src/stylesheet.c (original)
+++ trunk/libcss/src/stylesheet.c Wed Sep 24 19:19:16 2008
@@ -9,6 +9,141 @@
 
 #include "stylesheet.h"
 #include "utils/utils.h"
+
+/**
+ * Create a stylesheet
+ *
+ * \param url              URL of stylesheet
+ * \param title            Title of stylesheet
+ * \param origin           Origin of stylesheet
+ * \param media            Media stylesheet applies to
+ * \param import_callback  Handler for imported stylesheets
+ * \param import_pw        Client private data for import_callback
+ * \param alloc            Memory (de)allocation function
+ * \param alloc_pw         Client private data for alloc
+ * \return Pointer to stylesheet on success, NULL otherwise
+ */
+css_stylesheet *css_stylesheet_create(const char *url, const char *title,
+		css_origin origin, uint32_t media,
+		css_import_handler import_callback, void *import_pw,
+		css_alloc alloc, void *alloc_pw)
+{
+	UNUSED(url);
+	UNUSED(title);
+	UNUSED(origin);
+	UNUSED(media);
+	UNUSED(import_callback);
+	UNUSED(import_pw);
+	UNUSED(alloc);
+	UNUSED(alloc_pw);
+
+	return NULL;
+}
+
+/**
+ * Destroy a stylesheet
+ *
+ * \param sheet  The stylesheet to destroy
+ */
+void css_stylesheet_destroy(css_stylesheet *sheet)
+{
+	UNUSED(sheet);
+}
+
+/**
+ * Append source data to a stylesheet
+ *
+ * \param sheet  The stylesheet to append data to
+ * \param data   Pointer to data to append
+ * \param len    Length, in bytes, of data to append
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_append_data(css_stylesheet *sheet,
+		const uint8_t *data, size_t len)
+{
+	UNUSED(sheet);
+	UNUSED(data);
+	UNUSED(len);
+
+	return CSS_OK;
+}
+
+/**
+ * Flag that the last of a stylesheet's data has been seen
+ *
+ * \param sheet  The stylesheet in question
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_data_done(css_stylesheet *sheet)
+{
+	UNUSED(sheet);
+
+	return CSS_OK;
+}
+
+/**
+ * Retrieve the URL associated with a stylesheet
+ *
+ * \param sheet  The stylesheet to retrieve the URL from
+ * \param url    Pointer to location to receive pointer to URL
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_get_url(css_stylesheet *sheet, const char **url)
+{
+	UNUSED(sheet);
+	UNUSED(url);
+
+	return CSS_OK;
+}
+
+/**
+ * Retrieve the title associated with a stylesheet
+ *
+ * \param sheet  The stylesheet to retrieve the title from
+ * \param title  Pointer to location to receive pointer to title
+ * \return CSS_Ok on success, appropriate error otherwise
+ */
+css_error css_stylesheet_get_title(css_stylesheet *sheet, const char **title)
+{
+	UNUSED(sheet);
+	UNUSED(title);
+
+	return CSS_OK;
+}
+
+/**
+ * Retrieve the origin of a stylesheet
+ *
+ * \param sheet   The stylesheet to retrieve the origin of
+ * \param origin  Pointer to location to receive origin
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_get_origin(css_stylesheet *sheet, css_origin *origin)
+{
+	UNUSED(sheet);
+	UNUSED(origin);
+
+	return CSS_OK;
+}
+
+/**
+ * Retrieve the media types associated with a stylesheet
+ *
+ * \param sheet  The stylesheet to retrieve the media types for
+ * \param media  Pointer to location to receive media types
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_get_media(css_stylesheet *sheet, uint32_t *media)
+{
+	UNUSED(sheet);
+	UNUSED(media);
+
+	return CSS_OK;
+}
+
+/******************************************************************************
+ * Private API below here                                                     *
+ ******************************************************************************/
 
 /**
  * Create a selector

Modified: trunk/libcss/src/stylesheet.h
URL: http://source.netsurf-browser.org/trunk/libcss/src/stylesheet.h?rev=5433&r1=5432&r2=5433&view=diff
==============================================================================
--- trunk/libcss/src/stylesheet.h (original)
+++ trunk/libcss/src/stylesheet.h Wed Sep 24 19:19:16 2008
@@ -12,6 +12,7 @@
 
 #include <libcss/errors.h>
 #include <libcss/functypes.h>
+#include <libcss/stylesheet.h>
 #include <libcss/types.h>
 
 typedef struct css_rule css_rule;
@@ -122,6 +123,7 @@
 	char *url;				/**< URL of this sheet */
 	char *title;				/**< Title of this sheet */
 
+	css_origin origin;			/**< Origin of stylesheet */
 	uint32_t media;				/**< Bitfield of media types */
 
 	void *ownerNode;			/**< Owning node in document */
@@ -132,6 +134,9 @@
 	css_stylesheet *last_child;		/**< Last in child list */
 	css_stylesheet *next;			/**< Next in sibling list */
 	css_stylesheet *prev;			/**< Previous in sibling list */
+
+	css_import_handler import;		/**< Import callback */
+	void *import_pw;			/**< Import handler data */
 
 	css_alloc alloc;			/**< Allocation function */
 	void *pw;				/**< Private word */




More information about the netsurf-commits mailing list