summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-06-01 18:32:37 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-06-01 18:32:37 +0100
commitc6d7f24987a90bc61e408c4249a6a212276b4174 (patch)
tree75a3f5478618e0e583db6f168193e7645c012dda /src/parse
parent89a4d061a46490d5fad3792a565a1a0114c400e0 (diff)
downloadlibcss-c6d7f24987a90bc61e408c4249a6a212276b4174.tar.gz
libcss-c6d7f24987a90bc61e408c4249a6a212276b4174.tar.bz2
Add support for CSS3 overflow-x and overflow-y properties.
Now, overflow is a shorthand property setting both overflow-x and overflow-y. The getter for the computed overflow has been removed, and replaced with two for overflow-x and overflow-y.
Diffstat (limited to 'src/parse')
-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
-rw-r--r--src/parse/propstrings.c2
-rw-r--r--src/parse/propstrings.h18
7 files changed, 121 insertions, 11 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,
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index 913241c..2c166a0 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -171,6 +171,8 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "outline-style", SLEN("outline-style") },
{ "outline-width", SLEN("outline-width") },
{ "overflow", SLEN("overflow") },
+ { "overflow-x", SLEN("overflow-x") },
+ { "overflow-y", SLEN("overflow-y") },
{ "padding", SLEN("padding") },
{ "padding-bottom", SLEN("padding-bottom") },
{ "padding-left", SLEN("padding-left") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index 72a60ae..c686a91 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -57,15 +57,15 @@ enum {
LIST_STYLE_POSITION, LIST_STYLE_TYPE, MARGIN, MARGIN_BOTTOM,
MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, MAX_HEIGHT, MAX_WIDTH,
MIN_HEIGHT, MIN_WIDTH, OPACITY, ORPHANS, OUTLINE, OUTLINE_COLOR,
- OUTLINE_STYLE, OUTLINE_WIDTH, OVERFLOW, PADDING, PADDING_BOTTOM,
- PADDING_LEFT, PADDING_RIGHT, PADDING_TOP, PAGE_BREAK_AFTER,
- PAGE_BREAK_BEFORE, PAGE_BREAK_INSIDE, PAUSE, PAUSE_AFTER, PAUSE_BEFORE,
- PITCH_RANGE, PITCH, PLAY_DURING, POSITION, QUOTES, RICHNESS, RIGHT,
- SPEAK_HEADER, SPEAK_NUMERAL, SPEAK_PUNCTUATION, SPEAK, SPEECH_RATE,
- STRESS, TABLE_LAYOUT, TEXT_ALIGN, TEXT_DECORATION, TEXT_INDENT,
- TEXT_TRANSFORM, TOP, UNICODE_BIDI, VERTICAL_ALIGN, VISIBILITY,
- VOICE_FAMILY, VOLUME, WHITE_SPACE, WIDOWS, WIDTH, WORD_SPACING,
- WRITING_MODE, Z_INDEX,
+ OUTLINE_STYLE, OUTLINE_WIDTH, OVERFLOW, OVERFLOW_X, OVERFLOW_Y, PADDING,
+ PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP,
+ PAGE_BREAK_AFTER, PAGE_BREAK_BEFORE, PAGE_BREAK_INSIDE, PAUSE,
+ PAUSE_AFTER, PAUSE_BEFORE, PITCH_RANGE, PITCH, PLAY_DURING, POSITION,
+ QUOTES, RICHNESS, RIGHT, SPEAK_HEADER, SPEAK_NUMERAL, SPEAK_PUNCTUATION,
+ SPEAK, SPEECH_RATE, STRESS, TABLE_LAYOUT, TEXT_ALIGN, TEXT_DECORATION,
+ TEXT_INDENT, TEXT_TRANSFORM, TOP, UNICODE_BIDI, VERTICAL_ALIGN,
+ VISIBILITY, VOICE_FAMILY, VOLUME, WHITE_SPACE, WIDOWS, WIDTH,
+ WORD_SPACING, WRITING_MODE, Z_INDEX,
LAST_PROP = Z_INDEX,