summaryrefslogtreecommitdiff
path: root/src/stylesheet.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-15 01:59:58 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-15 01:59:58 +0000
commit90e05332d329663b9616bae2792b7cb36d03e13f (patch)
tree9ce4334e8293e546ee6fb95730465dd18723c4d6 /src/stylesheet.c
parent59cfdab5159981b97cd5b3b3cfd1d22f0600f5db (diff)
downloadlibcss-90e05332d329663b9616bae2792b7cb36d03e13f.tar.gz
libcss-90e05332d329663b9616bae2792b7cb36d03e13f.tar.bz2
Quirks mode parsing
svn path=/trunk/libcss/; revision=6519
Diffstat (limited to 'src/stylesheet.c')
-rw-r--r--src/stylesheet.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/stylesheet.c b/src/stylesheet.c
index 0344e47..e6dd5d9 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -26,6 +26,8 @@ static css_error _remove_selectors(css_stylesheet *sheet, css_rule *rule);
* \param title Title of stylesheet
* \param origin Origin of stylesheet
* \param media Media stylesheet applies to
+ * \param allow_quirks Permit quirky parsing of stylesheets
+ * \param dict Dictionary in which to intern strings
* \param alloc Memory (de)allocation function
* \param alloc_pw Client private data for alloc
* \param stylesheet Pointer to location to receive stylesheet
@@ -35,10 +37,11 @@ static css_error _remove_selectors(css_stylesheet *sheet, css_rule *rule);
*/
css_error css_stylesheet_create(css_language_level level,
const char *charset, const char *url, const char *title,
- css_origin origin, uint64_t media, lwc_context *dict,
- css_allocator_fn alloc, void *alloc_pw,
+ css_origin origin, uint64_t media, bool allow_quirks,
+ lwc_context *dict, css_allocator_fn alloc, void *alloc_pw,
css_stylesheet **stylesheet)
{
+ css_parser_optparams params;
css_error error;
css_stylesheet *sheet;
size_t len;
@@ -62,6 +65,19 @@ css_error css_stylesheet_create(css_language_level level,
return error;
}
+ sheet->quirks_allowed = allow_quirks;
+ if (allow_quirks) {
+ params.quirks = true;
+
+ error = css_parser_setopt(sheet->parser, CSS_PARSER_QUIRKS,
+ &params);
+ if (error != CSS_OK) {
+ css_parser_destroy(sheet->parser);
+ alloc(sheet, 0, alloc_pw);
+ return error;
+ }
+ }
+
sheet->level = level;
error = css_language_create(sheet, sheet->parser, alloc, alloc_pw,
&sheet->parser_frontend);
@@ -399,6 +415,41 @@ css_error css_stylesheet_get_media(css_stylesheet *sheet, uint64_t *media)
}
/**
+ * Determine whether quirky parsing was permitted on a stylesheet
+ *
+ * \param sheet The stylesheet to consider
+ * \param quirks Pointer to location to receive quirkyness
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_quirks_allowed(css_stylesheet *sheet, bool *allowed)
+{
+ if (sheet == NULL || allowed == NULL)
+ return CSS_BADPARM;
+
+ *allowed = sheet->quirks_allowed;
+
+ return CSS_OK;
+}
+
+
+/**
+ * Determine whether quirky parsing was used on a stylesheet
+ *
+ * \param sheet The stylesheet to consider
+ * \param quirks Pointer to location to receive quirkyness
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error css_stylesheet_used_quirks(css_stylesheet *sheet, bool *quirks)
+{
+ if (sheet == NULL || quirks == NULL)
+ return CSS_BADPARM;
+
+ *quirks = sheet->quirks_used;
+
+ return CSS_OK;
+}
+
+/**
* Get disabled status of a stylesheet
*
* \param sheet The stylesheet to consider