r5439 jmb - in /trunk/libcss: include/libcss/types.h src/stylesheet.c test/css21.c

netsurf at semichrome.net netsurf at semichrome.net
Thu Sep 25 09:38:52 BST 2008


Author: jmb
Date: Thu Sep 25 03:38:52 2008
New Revision: 5439

URL: http://source.netsurf-browser.org?rev=5439&view=rev
Log:
Modify CSS2.1 frontend test driver to use the public stylesheet API.
Media type handling may need to change -- 32bits may not be large enough in the long term, and there's no sensible way of extending this without causing ABI breakage in the future.

Modified:
    trunk/libcss/include/libcss/types.h
    trunk/libcss/src/stylesheet.c
    trunk/libcss/test/css21.c

Modified: trunk/libcss/include/libcss/types.h
URL: http://source.netsurf-browser.org/trunk/libcss/include/libcss/types.h?rev=5439&r1=5438&r2=5439&view=diff
==============================================================================
--- trunk/libcss/include/libcss/types.h (original)
+++ trunk/libcss/include/libcss/types.h Thu Sep 25 03:38:52 2008
@@ -34,6 +34,14 @@
 } css_language_level;
 
 /**
+ * Stylesheet media types
+ */
+typedef enum css_media_type {
+	CSS_MEDIA_SCREEN            = (1<<0),
+	CSS_MEDIA_ALL               = CSS_MEDIA_SCREEN
+} css_media_type;
+
+/**
  * Stylesheet origin
  */
 typedef enum css_origin {

Modified: trunk/libcss/src/stylesheet.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/stylesheet.c?rev=5439&r1=5438&r2=5439&view=diff
==============================================================================
--- trunk/libcss/src/stylesheet.c (original)
+++ trunk/libcss/src/stylesheet.c Thu Sep 25 03:38:52 2008
@@ -20,7 +20,7 @@
  * \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_callback  Handler for imported stylesheets, or NULL
  * \param import_pw        Client private data for import_callback
  * \param alloc            Memory (de)allocation function
  * \param alloc_pw         Client private data for alloc

Modified: trunk/libcss/test/css21.c
URL: http://source.netsurf-browser.org/trunk/libcss/test/css21.c?rev=5439&r1=5438&r2=5439&view=diff
==============================================================================
--- trunk/libcss/test/css21.c (original)
+++ trunk/libcss/test/css21.c Thu Sep 25 03:38:52 2008
@@ -2,13 +2,7 @@
 #include <stdio.h>
 
 #include <libcss/libcss.h>
-
-#include "charset/detect.h"
-#include "utils/utils.h"
-
-#include "lex/lex.h"
-#include "parse/parse.h"
-#include "parse/css21.h"
+#include <libcss/stylesheet.h>
 
 #include "testutils.h"
 
@@ -21,8 +15,7 @@
 
 int main(int argc, char **argv)
 {
-	css_parser *parser;
-	css_css21 *css21;
+	css_stylesheet *sheet;
 	FILE *fp;
 	size_t len, origlen;
 #define CHUNK_SIZE (4096)
@@ -37,13 +30,10 @@
 	/* Initialise library */
 	assert(css_initialise(argv[1], myrealloc, NULL) == CSS_OK);
 
-	parser = css_parser_create("UTF-8", CSS_CHARSET_DICTATED, 
+	sheet = css_stylesheet_create(CSS_LEVEL_21, "UTF-8", argv[2], NULL,
+			CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, NULL, NULL,
 			myrealloc, NULL);
-	assert(parser != NULL);
-
-	css21 = css_css21_create((css_stylesheet *) 10, parser, 
-			myrealloc, NULL);
-	assert(css21 != NULL);
+	assert(sheet != NULL);
 
 	fp = fopen(argv[2], "rb");
 	if (fp == NULL) {
@@ -58,7 +48,7 @@
 	while (len >= CHUNK_SIZE) {
 		fread(buf, 1, CHUNK_SIZE, fp);
 
-		error = css_parser_parse_chunk(parser, buf, CHUNK_SIZE);
+		error = css_stylesheet_append_data(sheet, buf, CHUNK_SIZE);
 		assert(error == CSS_OK || error == CSS_NEEDDATA);
 
 		len -= CHUNK_SIZE;
@@ -67,7 +57,7 @@
 	if (len > 0) {
 		fread(buf, 1, len, fp);
 
-		error = css_parser_parse_chunk(parser, buf, len);
+		error = css_stylesheet_append_data(sheet, buf, len);
 		assert(error == CSS_OK || error == CSS_NEEDDATA);
 
 		len = 0;
@@ -75,11 +65,9 @@
 
 	fclose(fp);
 
-	assert(css_parser_completed(parser) == CSS_OK);
+	assert(css_stylesheet_data_done(sheet) == CSS_OK);
 
-	css_css21_destroy(css21);
-
-	css_parser_destroy(parser);
+	css_stylesheet_destroy(sheet);
 
 	assert(css_finalise(myrealloc, NULL) == CSS_OK);
 




More information about the netsurf-commits mailing list