summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2018-01-20 17:35:20 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2018-01-20 17:35:20 +0000
commit131b33a2d7ee34e0c4113b7f3e62388bd7654282 (patch)
tree342af13aaf6700d0733368cd0b153c5e4a48a0c2
parent0dd48e83fbc246a881609b4c18ce10001ba1cc1a (diff)
downloadlibcss-131b33a2d7ee34e0c4113b7f3e62388bd7654282.tar.gz
libcss-131b33a2d7ee34e0c4113b7f3e62388bd7654282.tar.bz2
Selection: Add debug logging for pre-selection style sharing.tlsa/logging
-rw-r--r--src/select/select.c95
1 files changed, 42 insertions, 53 deletions
diff --git a/src/select/select.c b/src/select/select.c
index 6b5225a..6a34e69 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -22,6 +22,7 @@
#include "select/propset.h"
#include "select/font_face.h"
#include "select/select.h"
+#include "utils/log.h"
#include "utils/parserutilserror.h"
#include "utils/utils.h"
@@ -744,20 +745,18 @@ static css_error css_select_style__get_sharable_node_data_for_candidate(
error = state->handler->get_libcss_node_data(state->pw,
share_candidate_node, (void **) (void *) &node_data);
if (error != CSS_OK || node_data == NULL) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: no candidate node data\n",
- lwc_string_data(state->element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: no candidate node data",
+ lwc_string_data(state->element.name));
return error;
}
/* If one node has hints and other doesn't then can't share */
if ((node_data->flags & CSS_NODE_FLAGS_HAS_HINTS) !=
(state->node_data->flags & CSS_NODE_FLAGS_HAS_HINTS)) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: have hints mismatch\n",
- lwc_string_data(state->element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: have hints mismatch",
+ lwc_string_data(state->element.name));
return CSS_OK;
}
@@ -766,10 +765,9 @@ static css_error css_select_style__get_sharable_node_data_for_candidate(
if ((node_data->flags & CSS_NODE_FLAGS__PSEUDO_CLASSES_MASK) !=
(state->node_data->flags &
CSS_NODE_FLAGS__PSEUDO_CLASSES_MASK)) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: different pseudo classes\n",
- lwc_string_data(state->element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: different pseudo classes",
+ lwc_string_data(state->element.name));
return CSS_OK;
}
@@ -781,22 +779,17 @@ static css_error css_select_style__get_sharable_node_data_for_candidate(
CSS_NODE_FLAGS_TAINT_ATTRIBUTE |
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%s\n",
- lwc_string_data(state->element.name),
- (node_data->flags &
- CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS) ?
- "PSEUDOCLASS" : "",
- (node_data->flags &
- CSS_NODE_FLAGS_TAINT_ATTRIBUTE) ?
- " ATTRIBUTE" : "",
- (node_data->flags &
- CSS_NODE_FLAGS_TAINT_SIBLING) ?
- " SIBLING" : "",
- (node_data->flags &
- CSS_NODE_FLAGS_HAS_INLINE_STYLE) ?
- " INLINE_STYLE" : "");
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: candidate flags: %s%s%s%s",
+ lwc_string_data(state->element.name),
+ (node_data->flags & CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS) ?
+ "PSEUDOCLASS" : "",
+ (node_data->flags & CSS_NODE_FLAGS_TAINT_ATTRIBUTE) ?
+ " ATTRIBUTE" : "",
+ (node_data->flags & CSS_NODE_FLAGS_TAINT_SIBLING) ?
+ " SIBLING" : "",
+ (node_data->flags & CSS_NODE_FLAGS_HAS_INLINE_STYLE) ?
+ " INLINE_STYLE" : "");
return CSS_OK;
}
@@ -809,10 +802,9 @@ static css_error css_select_style__get_sharable_node_data_for_candidate(
} else if (share_candidate_id != NULL) {
lwc_string_unref(share_candidate_id);
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: candidate id\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: candidate id",
lwc_string_data(state->element.name));
-#endif
return CSS_OK;
}
@@ -826,10 +818,9 @@ static css_error css_select_style__get_sharable_node_data_for_candidate(
}
if (state->n_classes != share_candidate_n_classes) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: class count mismatch\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: class count mismatch",
lwc_string_data(state->element.name));
-#endif
goto cleanup;
}
@@ -843,20 +834,18 @@ static css_error css_select_style__get_sharable_node_data_for_candidate(
share_candidate_classes[i],
&match) == lwc_error_ok &&
match == false) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: class mismatch\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: class mismatch",
lwc_string_data(state->element.name));
-#endif
goto cleanup;
}
}
if (node_data->flags & CSS_NODE_FLAGS_HAS_HINTS) {
/* TODO: check hints match. For now, just prevent sharing */
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: hints\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: hints",
lwc_string_data(state->element.name));
-#endif
goto cleanup;
}
@@ -929,15 +918,16 @@ static css_error css_select_style__get_sharable_node_data(
* and if we get a non-NULL "matched" then return.
*
* 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
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: node id (%s)",
+ lwc_string_data(state->element.name),
+ lwc_string_data(state->id));
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
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: inline style",
+ lwc_string_data(state->element.name));
return CSS_OK;
}
@@ -977,7 +967,7 @@ printf(" \t%s\tno share: inline style\n");
}
if (*sharable_node_data != NULL) {
- /* Found style date we can share */
+ /* Found style data we can share */
break;
}
@@ -1204,15 +1194,14 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
state.results->styles[i] =
css__computed_style_ref(styles[i]);
}
-#ifdef DEBUG_STYLE_SHARING
- printf("style:\t%s\tSHARED!\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tSHARED existing style!",
lwc_string_data(state.element.name));
-#endif
goto complete;
}
-#ifdef DEBUG_STYLE_SHARING
- printf("style:\t%s\tSELECTED\n", lwc_string_data(state.element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: Have to do selection.",
+ lwc_string_data(state.element.name));
/* Not sharing; need to select.
* Base element style is guaranteed to exist