From cb99ab8db4246f28e4bbf25f4e1ef7716473602a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 29 Nov 2016 12:12:38 +0000 Subject: Selection: Inline styles prevent computed style sharing. --- src/select/select.c | 22 ++++++++++++++++++---- src/select/select.h | 17 +++++++++-------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/select/select.c b/src/select/select.c index 8488b74..a44ef4a 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -775,13 +775,14 @@ static css_error css_select_style__get_sharable_node_data_for_candidate( } /* If the node was affected by attribute or pseudo class rules, - * it's not a candidate for sharing */ + * or had an inline style, it's not a candidate for sharing */ if (node_data->flags & ( CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS | CSS_NODE_FLAGS_TAINT_ATTRIBUTE | - CSS_NODE_FLAGS_TAINT_SIBLING)) { + CSS_NODE_FLAGS_TAINT_SIBLING | + CSS_NODE_FLAGS_HAS_INLINE_STYLE)) { #ifdef DEBUG_STYLE_SHARING - printf(" \t%s\tno share: candidate flags: %s%s%s\n", + printf(" \t%s\tno share: candidate flags: %s%s%s%s\n", lwc_string_data(state->element.name), (node_data->flags & CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS) ? @@ -791,7 +792,10 @@ static css_error css_select_style__get_sharable_node_data_for_candidate( " ATTRIBUTE" : "", (node_data->flags & CSS_NODE_FLAGS_TAINT_SIBLING) ? - " SIBLING" : ""); + " SIBLING" : "", + (node_data->flags & + CSS_NODE_FLAGS_HAS_INLINE_STYLE) ? + " INLINE_STYLE" : ""); #endif return CSS_OK; } @@ -927,6 +931,12 @@ static css_error css_select_style__get_sharable_node_data( * Check overhead is worth cost. */ #ifdef DEBUG_STYLE_SHARING printf(" \t%s\tno share: node id (%s)\n", lwc_string_data(state->element.name), lwc_string_data(state->id)); +#endif + return CSS_OK; + } + if (state->node_data->flags & CSS_NODE_FLAGS_HAS_INLINE_STYLE) { +#ifdef DEBUG_STYLE_SHARING +printf(" \t%s\tno share: inline style\n"); #endif return CSS_OK; } @@ -1180,6 +1190,10 @@ css_error css_select_style(css_select_ctx *ctx, void *node, state.node_data->flags |= CSS_NODE_FLAGS_HAS_HINTS; } + if (inline_style != NULL) { + state.node_data->flags |= CSS_NODE_FLAGS_HAS_INLINE_STYLE; + } + /* Check if we can share another node's style */ error = css_select_style__get_sharable_node_data(node, &state, &share); if (error != CSS_OK) { diff --git a/src/select/select.h b/src/select/select.h index 1d9a813..70f1ced 100644 --- a/src/select/select.h +++ b/src/select/select.h @@ -35,14 +35,15 @@ typedef struct prop_state { typedef enum css_node_flags { CSS_NODE_FLAGS_NONE = 0, CSS_NODE_FLAGS_HAS_HINTS = (1 << 0), - CSS_NODE_FLAGS_PSEUDO_CLASS_ACTIVE = (1 << 1), - CSS_NODE_FLAGS_PSEUDO_CLASS_FOCUS = (1 << 2), - CSS_NODE_FLAGS_PSEUDO_CLASS_HOVER = (1 << 3), - CSS_NODE_FLAGS_PSEUDO_CLASS_LINK = (1 << 4), - CSS_NODE_FLAGS_PSEUDO_CLASS_VISITED = (1 << 5), - CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS = (1 << 6), - CSS_NODE_FLAGS_TAINT_ATTRIBUTE = (1 << 7), - CSS_NODE_FLAGS_TAINT_SIBLING = (1 << 8), + CSS_NODE_FLAGS_HAS_INLINE_STYLE = (1 << 1), + CSS_NODE_FLAGS_PSEUDO_CLASS_ACTIVE = (1 << 2), + CSS_NODE_FLAGS_PSEUDO_CLASS_FOCUS = (1 << 3), + CSS_NODE_FLAGS_PSEUDO_CLASS_HOVER = (1 << 4), + CSS_NODE_FLAGS_PSEUDO_CLASS_LINK = (1 << 5), + CSS_NODE_FLAGS_PSEUDO_CLASS_VISITED = (1 << 6), + CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS = (1 << 7), + CSS_NODE_FLAGS_TAINT_ATTRIBUTE = (1 << 8), + CSS_NODE_FLAGS_TAINT_SIBLING = (1 << 9), CSS_NODE_FLAGS__PSEUDO_CLASSES_MASK = (CSS_NODE_FLAGS_PSEUDO_CLASS_ACTIVE | CSS_NODE_FLAGS_PSEUDO_CLASS_FOCUS | -- cgit v1.2.3