summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 17:46:32 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 17:46:32 +0000
commit1617f3813486071779fe3ff6c724dcd6ae3f6223 (patch)
tree2692d0d051773ef6f9a81d93caf838c7074654f0
parent95106ec57637a13990f644f2a0c574164ac9a20a (diff)
downloadlibcss-1617f3813486071779fe3ff6c724dcd6ae3f6223.tar.gz
libcss-1617f3813486071779fe3ff6c724dcd6ae3f6223.tar.bz2
Change encoding of font-family
Move list-style-position to make room for it. svn path=/trunk/libcss/; revision=6440
-rw-r--r--include/libcss/computed.h76
-rw-r--r--include/libcss/properties.h8
-rw-r--r--src/select/propset.h66
3 files changed, 78 insertions, 72 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index df7a004..7f5ab34 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -193,12 +193,12 @@ struct css_computed_style {
* Encode font family as an array of string objects, terminated with a
* blank entry.
*
- * font_family 1 sizeof(ptr)
+ * font_family 3 sizeof(ptr)
* --- ---
- * 1 bit sizeof(ptr)
+ * 3 bits sizeof(ptr)
*
* ___ ___
- * 265 bits 140 + 2sizeof(css_string) +
+ * 267 bits 140 + 2sizeof(css_string) +
* sizeof(ptr) bytes
*
* 34 bytes 140 + 2sizeof(css_string) +
@@ -214,7 +214,7 @@ struct css_computed_style {
* 3 ttttttti border-top-width | background-image
* 4 rrrrrrrc border-right-width | color
* 5 bbbbbbbl border-bottom-width | list-style-image
- * 6 lllllllf border-left-width | font-family
+ * 6 lllllll. border-left-width | <unused>
* 7 ttttttcc top | border-top-color
* 8 rrrrrrcc right | border-right-color
* 9 bbbbbbcc bottom | border-bottom-color
@@ -237,12 +237,12 @@ struct css_computed_style {
* 26 tttttwww text-indent | white-space
* 27 bbbbbbbb background-position
* 28 bdddddff background-position | display | font-variant
- * 29 tttttll. text-decoration | list-style-position | <unused>
+ * 29 tttttfff text-decoration | font-family
* 30 ttttrrrr border-top-style | border-right-style
* 31 bbbbllll border-bottom-style | border-left-style
* 32 ffffllll font-weight | list-style-type
* 33 oooottuu outline-style | table-layout | unicode-bidi
- * 34 vv...... visibility | <unused>
+ * 34 vvll.... visibility | list-style-position | <unused>
*/
uint8_t bits[34];
@@ -820,26 +820,6 @@ static inline uint8_t css_computed_list_style_image(
#undef LIST_STYLE_IMAGE_SHIFT
#undef LIST_STYLE_IMAGE_INDEX
-#define FONT_FAMILY_INDEX 5
-#define FONT_FAMILY_SHIFT 0
-#define FONT_FAMILY_MASK 0x1
-static inline uint8_t css_computed_font_family(
- const css_computed_style *style,
- const css_string **names)
-{
- uint8_t bits = style->bits[FONT_FAMILY_INDEX];
- bits &= FONT_FAMILY_MASK;
- bits >>= FONT_FAMILY_SHIFT;
-
- /* 1bit: type */
- *names = style->font_family;
-
- return bits;
-}
-#undef FONT_FAMILY_MASK
-#undef FONT_FAMILY_SHIFT
-#undef FONT_FAMILY_INDEX
-
#define TOP_INDEX 6
#define TOP_SHIFT 2
#define TOP_MASK 0xfc
@@ -1751,22 +1731,25 @@ static inline uint8_t css_computed_text_decoration(
#undef TEXT_DECORATION_SHIFT
#undef TEXT_DECORATION_INDEX
-#define LIST_STYLE_POSITION_INDEX 28
-#define LIST_STYLE_POSITION_SHIFT 1
-#define LIST_STYLE_POSITION_MASK 0x3
-static inline uint8_t css_computed_list_style_position(
- const css_computed_style *style)
+#define FONT_FAMILY_INDEX 28
+#define FONT_FAMILY_SHIFT 0
+#define FONT_FAMILY_MASK 0x7
+static inline uint8_t css_computed_font_family(
+ const css_computed_style *style,
+ const css_string **names)
{
- uint8_t bits = style->bits[LIST_STYLE_POSITION_INDEX];
- bits &= LIST_STYLE_POSITION_MASK;
- bits >>= LIST_STYLE_POSITION_SHIFT;
+ uint8_t bits = style->bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: type */
+ *names = style->font_family;
- /* 2bits: type */
return bits;
}
-#undef LIST_STYLE_POSITION_MASK
-#undef LIST_STYLE_POSITION_SHIFT
-#undef LIST_STYLE_POSITION_INDEX
+#undef FONT_FAMILY_MASK
+#undef FONT_FAMILY_SHIFT
+#undef FONT_FAMILY_INDEX
#define BORDER_TOP_STYLE_INDEX 29
#define BORDER_TOP_STYLE_SHIFT 4
@@ -1938,4 +1921,21 @@ static inline uint8_t css_computed_visibility(
#undef VISIBILITY_SHIFT
#undef VISIBILITY_INDEX
+#define LIST_STYLE_POSITION_INDEX 33
+#define LIST_STYLE_POSITION_SHIFT 4
+#define LIST_STYLE_POSITION_MASK 0x30
+static inline uint8_t css_computed_list_style_position(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef LIST_STYLE_POSITION_MASK
+#undef LIST_STYLE_POSITION_SHIFT
+#undef LIST_STYLE_POSITION_INDEX
+
#endif
diff --git a/include/libcss/properties.h b/include/libcss/properties.h
index 6d12c14..1d0dd72 100644
--- a/include/libcss/properties.h
+++ b/include/libcss/properties.h
@@ -192,7 +192,13 @@ enum css_float {
enum css_font_family {
CSS_FONT_FAMILY_INHERIT = 0x0,
- CSS_FONT_FAMILY_SET = 0x1
+ /* Named fonts exist if pointer is non-NULL */
+ CSS_FONT_FAMILY_SERIF = 0x1,
+ CSS_FONT_FAMILY_SANS_SERIF = 0x2,
+ CSS_FONT_FAMILY_CURSIVE = 0x3,
+ CSS_FONT_FAMILY_FANTASY = 0x4,
+ CSS_FONT_FAMILY_MONOSPACE = 0x5,
+ CSS_FONT_FAMILY_DEFAULT = 0x6
};
enum css_font_size {
diff --git a/src/select/propset.h b/src/select/propset.h
index c60d7e5..3a73044 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -509,27 +509,6 @@ static inline css_error set_list_style_image(
#undef LIST_STYLE_IMAGE_SHIFT
#undef LIST_STYLE_IMAGE_INDEX
-#define FONT_FAMILY_INDEX 5
-#define FONT_FAMILY_SHIFT 0
-#define FONT_FAMILY_MASK 0x1
-static inline css_error set_font_family(
- css_computed_style *style, uint8_t type,
- css_string *names)
-{
- uint8_t *bits = &style->bits[FONT_FAMILY_INDEX];
-
- /* 1bit: type */
- *bits = (*bits & ~FONT_FAMILY_MASK) |
- ((type & 0x1) << FONT_FAMILY_SHIFT);
-
- style->font_family = names;
-
- return CSS_OK;
-}
-#undef FONT_FAMILY_MASK
-#undef FONT_FAMILY_SHIFT
-#undef FONT_FAMILY_INDEX
-
#define TOP_INDEX 6
#define TOP_SHIFT 2
#define TOP_MASK 0xfc
@@ -1419,23 +1398,26 @@ static inline css_error set_text_decoration(
#undef TEXT_DECORATION_SHIFT
#undef TEXT_DECORATION_INDEX
-#define LIST_STYLE_POSITION_INDEX 28
-#define LIST_STYLE_POSITION_SHIFT 1
-#define LIST_STYLE_POSITION_MASK 0x3
-static inline css_error set_list_style_position(
- css_computed_style *style, uint8_t type)
+#define FONT_FAMILY_INDEX 28
+#define FONT_FAMILY_SHIFT 0
+#define FONT_FAMILY_MASK 0x7
+static inline css_error set_font_family(
+ css_computed_style *style, uint8_t type,
+ css_string *names)
{
- uint8_t *bits = &style->bits[LIST_STYLE_POSITION_INDEX];
+ uint8_t *bits = &style->bits[FONT_FAMILY_INDEX];
- /* 2bits: type */
- *bits = (*bits & ~LIST_STYLE_POSITION_MASK) |
- ((type & 0x3) << LIST_STYLE_POSITION_SHIFT);
+ /* 3bits: type */
+ *bits = (*bits & ~FONT_FAMILY_MASK) |
+ ((type & 0x7) << FONT_FAMILY_SHIFT);
+
+ style->font_family = names;
return CSS_OK;
}
-#undef LIST_STYLE_POSITION_MASK
-#undef LIST_STYLE_POSITION_SHIFT
-#undef LIST_STYLE_POSITION_INDEX
+#undef FONT_FAMILY_MASK
+#undef FONT_FAMILY_SHIFT
+#undef FONT_FAMILY_INDEX
#define BORDER_TOP_STYLE_INDEX 29
#define BORDER_TOP_STYLE_SHIFT 4
@@ -1617,4 +1599,22 @@ static inline css_error set_visibility(
#undef VISIBILITY_SHIFT
#undef VISIBILITY_INDEX
+#define LIST_STYLE_POSITION_INDEX 33
+#define LIST_STYLE_POSITION_SHIFT 4
+#define LIST_STYLE_POSITION_MASK 0x30
+static inline css_error set_list_style_position(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->bits[LIST_STYLE_POSITION_INDEX];
+
+ /* 2bits: type */
+ *bits = (*bits & ~LIST_STYLE_POSITION_MASK) |
+ ((type & 0x3) << LIST_STYLE_POSITION_SHIFT);
+
+ return CSS_OK;
+}
+#undef LIST_STYLE_POSITION_MASK
+#undef LIST_STYLE_POSITION_SHIFT
+#undef LIST_STYLE_POSITION_INDEX
+
#endif