summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <Michael Drake tlsa@netsurf-browser.org>2021-05-08 18:03:21 +0100
committerMichael Drake <Michael Drake tlsa@netsurf-browser.org>2021-05-08 18:03:21 +0100
commitbfb92e00a220fc46dab265d5958d017c62d54351 (patch)
tree843795835aabdc39f16da3e9502c143b998b5ae6
parentbe9acc6c80dfc41974425824b77585e45e4498e9 (diff)
downloadlibcss-bfb92e00a220fc46dab265d5958d017c62d54351.tar.gz
libcss-bfb92e00a220fc46dab265d5958d017c62d54351.tar.bz2
Add regression test for system font callback units.
Thanks to Ralf Junker.
-rw-r--r--test/data/select/tests1.dat109
-rw-r--r--test/select.c35
2 files changed, 143 insertions, 1 deletions
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index 33ba589..1a91e82 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -14069,3 +14069,112 @@ word-spacing: normal
writing-mode: horizontal-tb
z-index: auto
#reset
+
+#tree
+| p*
+#ua
+p { font: special-system-font }
+#errors
+#expected
+align-content: stretch
+align-items: stretch
+align-self: auto
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: content-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+flex-basis: auto
+flex-direction: row
+flex-grow: 0.000
+flex-shrink: 1.000
+flex-wrap: nowrap
+float: none
+font-family: "special-system-font" sans-serif
+font-size: 22pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+justify-content: flex-start
+left: auto
+letter-spacing: normal
+line-height: 33em
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+order: 0
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
diff --git a/test/select.c b/test/select.c
index 664994e..33f31dd 100644
--- a/test/select.c
+++ b/test/select.c
@@ -509,6 +509,39 @@ void css__parse_tree_data(line_ctx *ctx, const char *data, size_t len)
}
}
+static css_error css_font_resolution_func(void *pw, lwc_string *name,
+ css_system_font *system_font)
+{
+ lwc_error err;
+
+ if (system_font == NULL) {
+ return CSS_BADPARM;
+ }
+
+ (void)(pw);
+
+ if (strncmp(lwc_string_data(name), "special-system-font",
+ lwc_string_length(name)) != 0) {
+ return CSS_INVALID;
+ }
+
+ system_font->style = CSS_FONT_STYLE_NORMAL;
+ system_font->variant = CSS_FONT_VARIANT_NORMAL;
+ system_font->weight = CSS_FONT_WEIGHT_NORMAL;
+ system_font->size.size = INTTOFIX(22);
+ system_font->size.unit = CSS_UNIT_PT;
+ system_font->line_height.size = INTTOFIX(33);
+ system_font->line_height.unit = CSS_UNIT_EM;
+ err = lwc_intern_string("special-system-font",
+ strlen("special-system-font"),
+ &system_font->family);
+ if (err != lwc_error_ok) {
+ return CSS_NOMEM;
+ }
+
+ return CSS_OK;
+}
+
void css__parse_sheet(line_ctx *ctx, const char *data, size_t len)
{
css_stylesheet_params params;
@@ -559,7 +592,7 @@ void css__parse_sheet(line_ctx *ctx, const char *data, size_t len)
params.import_pw = NULL;
params.color = NULL;
params.color_pw = NULL;
- params.font = NULL;
+ params.font = css_font_resolution_func;
params.font_pw = NULL;
/** \todo How are we going to handle @import? */