summaryrefslogtreecommitdiff
path: root/include/libcss/computed.h
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-15 23:05:02 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-15 23:05:02 +0000
commit85f7d81cfb45c8804507f175b1c3a05b717f589c (patch)
treedf6a57e3a9554e8661ef83cea5ed77fd6a4d36e6 /include/libcss/computed.h
parent1ebed74cd8be22ff805bffb10f6d1e55f2a9866f (diff)
downloadlibcss-85f7d81cfb45c8804507f175b1c3a05b717f589c.tar.gz
libcss-85f7d81cfb45c8804507f175b1c3a05b717f589c.tar.bz2
Provide accessor for computed value of display assuming static position.
Modify css_computed_display to follow $9.7. svn path=/trunk/libcss/; revision=8568
Diffstat (limited to 'include/libcss/computed.h')
-rw-r--r--include/libcss/computed.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index d754bae..a55cc4b 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -1762,6 +1762,46 @@ static inline uint8_t css_computed_background_position(
#define DISPLAY_SHIFT 2
#define DISPLAY_MASK 0x7c
static inline uint8_t css_computed_display(
+ const css_computed_style *style, bool root)
+{
+ uint8_t position;
+ uint8_t bits = style->bits[DISPLAY_INDEX];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* Return computed display as per $9.7 */
+ position = css_computed_position(style);
+
+ /* 5bits: type */
+ if (bits == CSS_DISPLAY_NONE)
+ return bits; /* 1. */
+
+ if ((position == CSS_POSITION_ABSOLUTE ||
+ position == CSS_POSITION_FIXED) /* 2. */ ||
+ css_computed_float(style) != CSS_FLOAT_NONE /* 3. */ ||
+ root /* 4. */) {
+ if (bits == CSS_DISPLAY_INLINE_TABLE) {
+ return CSS_DISPLAY_TABLE;
+ } else if (bits == CSS_DISPLAY_INLINE ||
+ bits == CSS_DISPLAY_RUN_IN ||
+ bits == CSS_DISPLAY_TABLE_ROW_GROUP ||
+ bits == CSS_DISPLAY_TABLE_COLUMN ||
+ bits == CSS_DISPLAY_TABLE_COLUMN_GROUP ||
+ bits == CSS_DISPLAY_TABLE_HEADER_GROUP ||
+ bits == CSS_DISPLAY_TABLE_FOOTER_GROUP ||
+ bits == CSS_DISPLAY_TABLE_ROW ||
+ bits == CSS_DISPLAY_TABLE_CELL ||
+ bits == CSS_DISPLAY_TABLE_CAPTION ||
+ bits == CSS_DISPLAY_INLINE_BLOCK) {
+ return CSS_DISPLAY_BLOCK;
+ }
+ }
+
+ /* 5. */
+ return bits;
+}
+
+static inline uint8_t css_computed_display_static(
const css_computed_style *style)
{
uint8_t bits = style->bits[DISPLAY_INDEX];
@@ -1771,6 +1811,7 @@ static inline uint8_t css_computed_display(
/* 5bits: type */
return bits;
}
+
#undef DISPLAY_MASK
#undef DISPLAY_SHIFT
#undef DISPLAY_INDEX