summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcss/computed.h41
-rw-r--r--src/select/computed.c56
-rw-r--r--src/select/properties.c4
-rw-r--r--test/data/select/tests1.dat2
-rw-r--r--test/dump_computed.h2
5 files changed, 45 insertions, 60 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
diff --git a/src/select/computed.c b/src/select/computed.c
index 9c146da..9bbaa52 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -13,8 +13,6 @@
#include "utils/utils.h"
static css_error compute_border_colors(css_computed_style *style);
-static css_error compute_display(const css_computed_style *parent,
- css_computed_style *style);
static css_error compute_float(css_computed_style *style);
static css_error compute_absolute_border_width(css_computed_style *style,
@@ -325,11 +323,6 @@ css_error compute_absolute_values(const css_computed_style *parent,
if (error != CSS_OK)
return error;
- /* Fix up display */
- error = compute_display(parent, style);
- if (error != CSS_OK)
- return error;
-
/* Fix up float */
error = compute_float(style);
if (error != CSS_OK)
@@ -502,55 +495,6 @@ css_error compute_border_colors(css_computed_style *style)
}
/**
- * Compute display, considering position and float ($9.7)
- *
- * \param parent Parent style
- * \param style Style to process
- * \return CSS_OK on success
- */
-css_error compute_display(const css_computed_style *parent,
- css_computed_style *style)
-{
- uint8_t display;
- uint8_t pos;
- css_error error;
-
- display = css_computed_display(style);
- if (display == CSS_DISPLAY_NONE)
- return CSS_OK; /*1*/
-
- pos = css_computed_position(style);
-
- if ((pos == CSS_POSITION_ABSOLUTE || pos == CSS_POSITION_FIXED)/*2*/ ||
- css_computed_float(style) != CSS_FLOAT_NONE /*3*/ ||
- parent == NULL/*4*/) {
- if (display == CSS_DISPLAY_INLINE_TABLE) {
- display = CSS_DISPLAY_TABLE;
- } else if (display == CSS_DISPLAY_INLINE ||
- display == CSS_DISPLAY_RUN_IN ||
- display == CSS_DISPLAY_TABLE_ROW_GROUP ||
- display == CSS_DISPLAY_TABLE_COLUMN ||
- display == CSS_DISPLAY_TABLE_COLUMN_GROUP ||
- display == CSS_DISPLAY_TABLE_HEADER_GROUP ||
- display == CSS_DISPLAY_TABLE_FOOTER_GROUP ||
- display == CSS_DISPLAY_TABLE_ROW ||
- display == CSS_DISPLAY_TABLE_CELL ||
- display == CSS_DISPLAY_TABLE_CAPTION ||
- display == CSS_DISPLAY_INLINE_BLOCK) {
- display = CSS_DISPLAY_BLOCK;
- }
-
- error = set_display(style, display);
- if (error != CSS_OK)
- return error;
- }
-
- /*5*/
-
- return CSS_OK;
-}
-
-/**
* Compute float, considering position ($9.7)
*
* \param style Style to process
diff --git a/src/select/properties.c b/src/select/properties.c
index c6d1f75..b62dcb1 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -2029,8 +2029,8 @@ css_error compose_display(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_display(child) == CSS_DISPLAY_INHERIT) {
- return set_display(result, css_computed_display(parent));
+ if (css_computed_display_static(child) == CSS_DISPLAY_INHERIT) {
+ return set_display(result, css_computed_display_static(parent));
}
return CSS_OK;
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index 34ae7bf..9d1a4cb 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -341,7 +341,7 @@ counter-increment: none
counter-reset: none
cursor: auto
direction: ltr
-display: block
+display: inline
empty-cells: show
float: none
font-family: sans-serif
diff --git a/test/dump_computed.h b/test/dump_computed.h
index 8269b3a..b3423d7 100644
--- a/test/dump_computed.h
+++ b/test/dump_computed.h
@@ -1023,7 +1023,7 @@ static void dump_computed_style(const css_computed_style *style, char *buf,
*len -= wrote;
/* display */
- val = css_computed_display(style);
+ val = css_computed_display_static(style);
switch (val) {
case CSS_DISPLAY_INLINE:
wrote = snprintf(ptr, *len, "display: inline\n");