summaryrefslogtreecommitdiff
path: root/src/parse/properties
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse/properties')
-rw-r--r--src/parse/properties/Makefile1
-rw-r--r--src/parse/properties/overflow.c97
-rw-r--r--src/parse/properties/properties.c2
-rw-r--r--src/parse/properties/properties.gen4
-rw-r--r--src/parse/properties/properties.h8
5 files changed, 110 insertions, 2 deletions
diff --git a/src/parse/properties/Makefile b/src/parse/properties/Makefile
index 2b84354..0e29d1c 100644
--- a/src/parse/properties/Makefile
+++ b/src/parse/properties/Makefile
@@ -53,6 +53,7 @@ DIR_SOURCES := \
margin.c \
opacity.c \
outline.c \
+ overflow.c \
padding.c \
pause.c \
play_during.c \
diff --git a/src/parse/properties/overflow.c b/src/parse/properties/overflow.c
new file mode 100644
index 0000000..ca133ed
--- /dev/null
+++ b/src/parse/properties/overflow.c
@@ -0,0 +1,97 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "parse/properties/properties.h"
+#include "parse/properties/utils.h"
+
+/**
+ * Parse overflow shorthand
+ *
+ * \param c Parsing context
+ * \param vector Vector of tokens to process
+ * \param ctx Pointer to vector iteration context
+ * \param result Pointer to location to receive resulting style
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_INVALID if the input is not valid
+ *
+ * Post condition: \a *ctx is updated with the next token to process
+ * If the input is invalid, then \a *ctx remains unchanged.
+ */
+css_error css__parse_overflow(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result)
+{
+ int orig_ctx = *ctx;
+ css_error error1, error2 = CSS_OK;
+ const css_token *token;
+ bool match;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT))) {
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+
+ if ((lwc_string_caseless_isequal(token->idata,
+ c->strings[INHERIT], &match) == lwc_error_ok &&
+ match)) {
+ error1 = css_stylesheet_style_inherit(result,
+ CSS_PROP_OVERFLOW_X);
+ error2 = css_stylesheet_style_inherit(result,
+ CSS_PROP_OVERFLOW_Y);
+
+ } else if ((lwc_string_caseless_isequal(token->idata,
+ c->strings[VISIBLE], &match) == lwc_error_ok &&
+ match)) {
+ error1 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_X, 0, OVERFLOW_VISIBLE);
+ error2 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_Y, 0, OVERFLOW_VISIBLE);
+
+ } else if ((lwc_string_caseless_isequal(token->idata,
+ c->strings[HIDDEN], &match) == lwc_error_ok &&
+ match)) {
+ error1 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_X, 0, OVERFLOW_HIDDEN);
+ error2 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_Y, 0, OVERFLOW_HIDDEN);
+
+ } else if ((lwc_string_caseless_isequal(token->idata,
+ c->strings[SCROLL], &match) == lwc_error_ok &&
+ match)) {
+ error1 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_X, 0, OVERFLOW_SCROLL);
+ error2 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_Y, 0, OVERFLOW_SCROLL);
+
+ } else if ((lwc_string_caseless_isequal(token->idata,
+ c->strings[AUTO], &match) == lwc_error_ok &&
+ match)) {
+ error1 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_X, 0, OVERFLOW_AUTO);
+ error2 = css__stylesheet_style_appendOPV(result,
+ CSS_PROP_OVERFLOW_Y, 0, OVERFLOW_AUTO);
+
+ } else {
+ error1 = CSS_INVALID;
+ }
+
+ if (error2 != CSS_OK)
+ error1 = error2;
+
+ if (error1 != CSS_OK)
+ *ctx = orig_ctx;
+
+ return error1;
+}
+
diff --git a/src/parse/properties/properties.c b/src/parse/properties/properties.c
index c4e939a..49933cd 100644
--- a/src/parse/properties/properties.c
+++ b/src/parse/properties/properties.c
@@ -101,6 +101,8 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_outline_style,
css__parse_outline_width,
css__parse_overflow,
+ css__parse_overflow_x,
+ css__parse_overflow_y,
css__parse_padding,
css__parse_padding_bottom,
css__parse_padding_left,
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index 80f1a30..4417cb6 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -129,7 +129,9 @@ outline_style:CSS_PROP_OUTLINE_STYLE IDENT:( INHERIT: NONE:0,BORDER_STYLE_NONE D
outline_width:CSS_PROP_OUTLINE_WIDTH WRAP:css__parse_border_side_width
-overflow:CSS_PROP_OVERFLOW IDENT:( INHERIT: VISIBLE:0,OVERFLOW_VISIBLE HIDDEN:0,OVERFLOW_HIDDEN SCROLL:0,OVERFLOW_SCROLL AUTO:0,OVERFLOW_AUTO IDENT:)
+overflow_x:CSS_PROP_OVERFLOW_X IDENT:( INHERIT: VISIBLE:0,OVERFLOW_VISIBLE HIDDEN:0,OVERFLOW_HIDDEN SCROLL:0,OVERFLOW_SCROLL AUTO:0,OVERFLOW_AUTO IDENT:)
+
+overflow_y:CSS_PROP_OVERFLOW_Y IDENT:( INHERIT: VISIBLE:0,OVERFLOW_VISIBLE HIDDEN:0,OVERFLOW_HIDDEN SCROLL:0,OVERFLOW_SCROLL AUTO:0,OVERFLOW_AUTO IDENT:)
page_break_after:CSS_PROP_PAGE_BREAK_AFTER IDENT:( INHERIT: AUTO:0,PAGE_BREAK_AFTER_AUTO ALWAYS:0,PAGE_BREAK_AFTER_ALWAYS AVOID:0,PAGE_BREAK_AFTER_AVOID LEFT:0,PAGE_BREAK_AFTER_LEFT RIGHT:0,PAGE_BREAK_AFTER_RIGHT IDENT:)
diff --git a/src/parse/properties/properties.h b/src/parse/properties/properties.h
index 7c4d8a1..cf80761 100644
--- a/src/parse/properties/properties.h
+++ b/src/parse/properties/properties.h
@@ -287,7 +287,13 @@ css_error css__parse_outline_width(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
css_error css__parse_overflow(css_language *c,
- const parserutils_vector *vector, int *ctx,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_overflow_x(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_overflow_y(css_language *c,
+ const parserutils_vector *vector, int *ctx,
css_style *result);
css_error css__parse_padding(css_language *c,
const parserutils_vector *vector, int *ctx,