summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-08-21 09:45:13 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-08-21 09:45:13 +0000
commit5c20bde8b544d23fd024dad7ace9b46849336ebf (patch)
tree07dc508d51d281b7553e471a42ba3684018fe512 /src/select
parent5bd907c74151d0bbe1859c37cb2bde898ab72e2f (diff)
downloadlibcss-5c20bde8b544d23fd024dad7ace9b46849336ebf.tar.gz
libcss-5c20bde8b544d23fd024dad7ace9b46849336ebf.tar.bz2
-libcss-align
svn path=/trunk/libcss/; revision=9378
Diffstat (limited to 'src/select')
-rw-r--r--src/select/dispatch.c8
-rw-r--r--src/select/properties.c56
-rw-r--r--src/select/properties.h8
-rw-r--r--src/select/propget.h17
-rw-r--r--src/select/propset.h18
5 files changed, 107 insertions, 0 deletions
diff --git a/src/select/dispatch.c b/src/select/dispatch.c
index c15465b..11345e2 100644
--- a/src/select/dispatch.c
+++ b/src/select/dispatch.c
@@ -803,5 +803,13 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
compose_z_index,
0,
GROUP_NORMAL
+ },
+ {
+ cascade_libcss_align,
+ set_libcss_align_from_hint,
+ initial_libcss_align,
+ compose_libcss_align,
+ 1,
+ GROUP_NORMAL
}
};
diff --git a/src/select/properties.c b/src/select/properties.c
index 4b7b8a7..b83a29d 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -5452,6 +5452,62 @@ css_error compose_z_index(const css_computed_style *parent,
return set_z_index(result, type, index);
}
+css_error cascade_libcss_align(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_LIBCSS_ALIGN_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case LIBCSS_ALIGN_LEFT:
+ value = CSS_LIBCSS_ALIGN_LEFT;
+ break;
+ case LIBCSS_ALIGN_RIGHT:
+ value = CSS_LIBCSS_ALIGN_RIGHT;
+ break;
+ case LIBCSS_ALIGN_CENTER:
+ value = CSS_LIBCSS_ALIGN_CENTER;
+ break;
+ case LIBCSS_ALIGN_JUSTIFY:
+ value = CSS_LIBCSS_ALIGN_JUSTIFY;
+ break;
+ }
+ }
+
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_libcss_align(state->result, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error set_libcss_align_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_libcss_align(style, hint->status);
+}
+
+css_error initial_libcss_align(css_select_state *state)
+{
+ return set_libcss_align(state->result, CSS_LIBCSS_ALIGN_DEFAULT);
+}
+
+css_error compose_libcss_align(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_libcss_align(child);
+
+ if (type == CSS_LIBCSS_ALIGN_INHERIT) {
+ type = get_libcss_align(parent);
+ }
+
+ return set_libcss_align(result, type);
+}
+
/******************************************************************************
* Utilities below here *
******************************************************************************/
diff --git a/src/select/properties.h b/src/select/properties.h
index 9c98e10..75b6f8d 100644
--- a/src/select/properties.h
+++ b/src/select/properties.h
@@ -806,6 +806,14 @@ css_error initial_z_index(css_select_state *state);
css_error compose_z_index(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result);
+css_error cascade_libcss_align(uint32_t opv, css_style *style,
+ css_select_state *state);
+css_error set_libcss_align_from_hint(const css_hint *hint,
+ css_computed_style *style);
+css_error initial_libcss_align(css_select_state *state);
+css_error compose_libcss_align(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result);
#endif
diff --git a/src/select/propget.h b/src/select/propget.h
index 23c7cdf..39f6300 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -1721,4 +1721,21 @@ static inline uint8_t get_list_style_position(
#undef LIST_STYLE_POSITION_SHIFT
#undef LIST_STYLE_POSITION_INDEX
+#define LIBCSS_ALIGN_INDEX 33
+#define LIBCSS_ALIGN_SHIFT 1
+#define LIBCSS_ALIGN_MASK 0xe
+static inline uint8_t get_libcss_align(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[LIBCSS_ALIGN_INDEX];
+ bits &= LIBCSS_ALIGN_MASK;
+ bits >>= LIBCSS_ALIGN_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef LIBCSS_ALIGN_MASK
+#undef LIBCSS_ALIGN_SHIFT
+#undef LIBCSS_ALIGN_INDEX
+
#endif
diff --git a/src/select/propset.h b/src/select/propset.h
index ac860fd..cc4121a 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -1679,4 +1679,22 @@ static inline css_error set_list_style_position(
#undef LIST_STYLE_POSITION_SHIFT
#undef LIST_STYLE_POSITION_INDEX
+#define LIBCSS_ALIGN_INDEX 33
+#define LIBCSS_ALIGN_SHIFT 1
+#define LIBCSS_ALIGN_MASK 0xe
+static inline uint8_t set_libcss_align(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->bits[LIBCSS_ALIGN_INDEX];
+
+ /* 3bits: type */
+ *bits = (*bits & ~LIBCSS_ALIGN_MASK) |
+ ((type & 0x7) << LIBCSS_ALIGN_SHIFT);
+
+ return CSS_OK;
+}
+#undef LIBCSS_ALIGN_MASK
+#undef LIBCSS_ALIGN_SHIFT
+#undef LIBCSS_ALIGN_INDEX
+
#endif