xbintsc 0.5.45 → 0.5.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +5 -4
- package/README.zh-CN.md +4 -3
- package/dist/src/cli/extensions.d.ts +24 -0
- package/dist/src/cli/extensions.js +62 -0
- package/dist/src/cli/extensions.js.map +1 -0
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/help.js +3 -1
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/hints.js +8 -3
- package/dist/src/cli/hints.js.map +1 -1
- package/dist/src/cli/main.js +21 -28
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.d.ts +3 -1
- package/dist/src/diagnostics/diagnostic.js +2 -0
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +2 -0
- package/dist/src/driver/build-key.js +1 -0
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/compiler.js +61 -8
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/config.d.ts +4 -0
- package/dist/src/driver/config.js +2 -0
- package/dist/src/driver/config.js.map +1 -1
- package/dist/src/driver/link-features.d.ts +37 -0
- package/dist/src/driver/link-features.js +123 -0
- package/dist/src/driver/link-features.js.map +1 -0
- package/dist/src/driver/options.d.ts +10 -0
- package/dist/src/driver/runtime-objects.d.ts +5 -0
- package/dist/src/driver/runtime-objects.js +20 -1
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/usage.d.ts +23 -0
- package/dist/src/driver/usage.js +353 -0
- package/dist/src/driver/usage.js.map +1 -0
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/catalog.js +1 -2
- package/dist/src/extensions/catalog.js.map +1 -1
- package/dist/src/extensions/gui/features.d.ts +34 -0
- package/dist/src/extensions/gui/features.js +165 -0
- package/dist/src/extensions/gui/features.js.map +1 -0
- package/dist/src/extensions/gui/index.js +10 -4
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/link-feature.d.ts +70 -0
- package/dist/src/extensions/link-feature.js +18 -0
- package/dist/src/extensions/link-feature.js.map +1 -0
- package/dist/src/extensions/registry.d.ts +24 -4
- package/dist/src/extensions/registry.js +26 -3
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/tests/cli/hints.test.js +5 -7
- package/dist/tests/cli/hints.test.js.map +1 -1
- package/dist/tests/driver/link-features.test.js +105 -0
- package/dist/tests/driver/link-features.test.js.map +1 -0
- package/dist/tests/driver/usage.test.d.ts +1 -0
- package/dist/tests/driver/usage.test.js +88 -0
- package/dist/tests/driver/usage.test.js.map +1 -0
- package/dist/tests/e2e/gui-audio.test.js +4 -4
- package/dist/tests/e2e/gui-audio.test.js.map +1 -1
- package/dist/tests/e2e/gui-css-coverage.test.d.ts +9 -0
- package/dist/tests/e2e/gui-css-coverage.test.js +333 -0
- package/dist/tests/e2e/gui-css-coverage.test.js.map +1 -0
- package/dist/tests/e2e/gui-css-features.test.d.ts +6 -0
- package/dist/tests/e2e/gui-css-features.test.js +270 -0
- package/dist/tests/e2e/gui-css-features.test.js.map +1 -0
- package/dist/tests/e2e/gui-effects.test.js +92 -11
- package/dist/tests/e2e/gui-effects.test.js.map +1 -1
- package/dist/tests/e2e/gui-feature-linking.test.d.ts +9 -0
- package/dist/tests/e2e/gui-feature-linking.test.js +68 -0
- package/dist/tests/e2e/gui-feature-linking.test.js.map +1 -0
- package/dist/tests/e2e/gui-font-face.test.d.ts +10 -0
- package/dist/tests/e2e/gui-font-face.test.js +142 -0
- package/dist/tests/e2e/gui-font-face.test.js.map +1 -0
- package/dist/tests/e2e/gui-fonts.test.d.ts +10 -0
- package/dist/tests/e2e/gui-fonts.test.js +150 -0
- package/dist/tests/e2e/gui-fonts.test.js.map +1 -0
- package/dist/tests/e2e/gui-helpers.d.ts +10 -1
- package/dist/tests/e2e/gui-helpers.js +6 -0
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +7 -3
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-media-disabled.test.d.ts +5 -4
- package/dist/tests/e2e/gui-media-disabled.test.js +7 -6
- package/dist/tests/e2e/gui-media-disabled.test.js.map +1 -1
- package/dist/tests/e2e/gui-media.test.d.ts +5 -4
- package/dist/tests/e2e/gui-media.test.js +9 -9
- package/dist/tests/e2e/gui-media.test.js.map +1 -1
- package/dist/tests/e2e/gui-paint.test.js +5 -2
- package/dist/tests/e2e/gui-paint.test.js.map +1 -1
- package/dist/tests/e2e/gui-shaping.test.d.ts +5 -0
- package/dist/tests/e2e/gui-shaping.test.js +47 -0
- package/dist/tests/e2e/gui-shaping.test.js.map +1 -0
- package/dist/tests/e2e/gui-track-sizing.test.d.ts +6 -0
- package/dist/tests/e2e/gui-track-sizing.test.js +173 -0
- package/dist/tests/e2e/gui-track-sizing.test.js.map +1 -0
- package/dist/tests/e2e/gui-transform.test.js +3 -2
- package/dist/tests/e2e/gui-transform.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-pipeline-cache.test.d.ts +18 -0
- package/dist/tests/e2e/gui-webgl-pipeline-cache.test.js +120 -0
- package/dist/tests/e2e/gui-webgl-pipeline-cache.test.js.map +1 -0
- package/dist/tests/extensions/gui-features.test.d.ts +1 -0
- package/dist/tests/extensions/gui-features.test.js +175 -0
- package/dist/tests/extensions/gui-features.test.js.map +1 -0
- package/doc/ai/cli.md +5 -1
- package/doc/ai/extensions.md +56 -26
- package/doc/ai/troubleshooting.md +10 -7
- package/doc/ai/zh-CN/cli.md +5 -1
- package/doc/ai/zh-CN/extensions.md +48 -22
- package/doc/ai/zh-CN/troubleshooting.md +6 -5
- package/doc/gui/animation.md +39 -9
- package/doc/gui/api.md +2 -1
- package/doc/gui/build.md +137 -19
- package/doc/gui/canvas.md +1 -1
- package/doc/gui/dom.md +20 -4
- package/doc/gui/known-issues.md +63 -26
- package/doc/gui/layout.md +31 -8
- package/doc/gui/media.md +13 -7
- package/doc/gui/rendering.md +114 -39
- package/doc/gui/runtime.md +5 -0
- package/doc/gui/webgl.md +24 -6
- package/doc/gui.md +110 -47
- package/doc/implemented/cli.md +2 -0
- package/doc/implemented/extensions.md +9 -3
- package/doc/npm-package.md +4 -4
- package/doc/xbintsc.config.schema.json +10 -0
- package/doc/zh-CN/gui/animation.md +33 -10
- package/doc/zh-CN/gui/api.md +2 -1
- package/doc/zh-CN/gui/build.md +110 -16
- package/doc/zh-CN/gui/canvas.md +1 -1
- package/doc/zh-CN/gui/dom.md +16 -3
- package/doc/zh-CN/gui/known-issues.md +45 -15
- package/doc/zh-CN/gui/layout.md +23 -6
- package/doc/zh-CN/gui/media.md +11 -6
- package/doc/zh-CN/gui/rendering.md +84 -26
- package/doc/zh-CN/gui/runtime.md +3 -0
- package/doc/zh-CN/gui/webgl.md +3 -3
- package/doc/zh-CN/gui.md +92 -41
- package/doc/zh-CN/implemented/cli.md +2 -0
- package/doc/zh-CN/implemented/extensions.md +9 -3
- package/doc/zh-CN/npm-package.md +4 -3
- package/package.json +7 -7
- package/runtime/ext_gui/animation_values.cpp +425 -0
- package/runtime/ext_gui/animation_values.h +64 -0
- package/runtime/ext_gui/browser.cpp +22 -15
- package/runtime/ext_gui/browser_loop.cpp +13 -1
- package/runtime/ext_gui/canvas.h +1 -1
- package/runtime/ext_gui/canvas_raster.cpp +1 -1
- package/runtime/ext_gui/canvas_text.cpp +1 -1
- package/runtime/ext_gui/css.cpp +172 -21
- package/runtime/ext_gui/css.h +75 -4
- package/runtime/ext_gui/css_match.cpp +4 -0
- package/runtime/ext_gui/css_sheet.cpp +218 -2
- package/runtime/ext_gui/document.cpp +42 -192
- package/runtime/ext_gui/document.h +25 -12
- package/runtime/ext_gui/document_animation.cpp +428 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +15 -8
- package/runtime/ext_gui/dom_api_canvas_extra.cpp +44 -20
- package/runtime/ext_gui/dom_api_canvas_image.cpp +3 -1
- package/runtime/ext_gui/dom_api_node_read.cpp +10 -0
- package/runtime/ext_gui/dom_api_offscreen.cpp +3 -1
- package/runtime/ext_gui/dom_api_style.cpp +7 -0
- package/runtime/ext_gui/dom_api_webgl_internal.h +4 -0
- package/runtime/ext_gui/dom_api_webgl_source.cpp +5 -2
- package/runtime/ext_gui/effect_values.cpp +245 -21
- package/runtime/ext_gui/gpu_bridge.c +28 -0
- package/runtime/ext_gui/gpu_feature.cpp +30 -0
- package/runtime/ext_gui/gpu_shader.cpp +22 -0
- package/runtime/ext_gui/gpu_shader_api.h +50 -0
- package/runtime/ext_gui/gradient_values.cpp +24 -0
- package/runtime/ext_gui/grid_values.cpp +23 -0
- package/runtime/ext_gui/gui.cpp +6 -37
- package/runtime/ext_gui/gui_canvas.cpp +14 -6
- package/runtime/ext_gui/gui_cursor.cpp +50 -0
- package/runtime/ext_gui/gui_engine.h +1 -18
- package/runtime/ext_gui/gui_events.cpp +19 -6
- package/runtime/ext_gui/gui_internal.h +3 -0
- package/runtime/ext_gui/gui_webgl.cpp +25 -10
- package/runtime/ext_gui/image_api.cpp +18 -0
- package/runtime/ext_gui/image_api.h +43 -0
- package/runtime/ext_gui/image_bitmap_browser.cpp +20 -11
- package/runtime/ext_gui/image_bridge.c +22 -0
- package/runtime/ext_gui/image_feature.cpp +107 -0
- package/runtime/ext_gui/inline_svg.cpp +95 -8
- package/runtime/ext_gui/inline_svg.h +5 -1
- package/runtime/ext_gui/layout.cpp +15 -9
- package/runtime/ext_gui/layout.h +8 -2
- package/runtime/ext_gui/layout_flex.cpp +134 -29
- package/runtime/ext_gui/layout_flow.cpp +58 -7
- package/runtime/ext_gui/layout_flow_internal.h +39 -4
- package/runtime/ext_gui/layout_grid.cpp +31 -0
- package/runtime/ext_gui/layout_inline.cpp +26 -2
- package/runtime/ext_gui/layout_vertical.cpp +196 -0
- package/runtime/ext_gui/media.cpp +4 -2
- package/runtime/ext_gui/media.h +3 -3
- package/runtime/ext_gui/media_api.h +7 -6
- package/runtime/ext_gui/paint.cpp +67 -9
- package/runtime/ext_gui/paint.h +61 -8
- package/runtime/ext_gui/paint_backdrop.cpp +211 -0
- package/runtime/ext_gui/paint_background.cpp +175 -97
- package/runtime/ext_gui/paint_effects.cpp +12 -6
- package/runtime/ext_gui/paint_internal.h +27 -0
- package/runtime/ext_gui/paint_outline.cpp +44 -0
- package/runtime/ext_gui/paint_shadow.cpp +368 -0
- package/runtime/ext_gui/renderer.cpp +15 -7
- package/runtime/ext_gui/renderer.h +11 -2
- package/runtime/ext_gui/renderer_backdrop.cpp +374 -0
- package/runtime/ext_gui/renderer_bitmap.cpp +82 -0
- package/runtime/ext_gui/renderer_gradient.cpp +51 -17
- package/runtime/ext_gui/renderer_image.cpp +19 -7
- package/runtime/ext_gui/renderer_internal.h +21 -0
- package/runtime/ext_gui/renderer_layer.cpp +37 -6
- package/runtime/ext_gui/renderer_text.cpp +2 -1
- package/runtime/ext_gui/stb_truetype.h +5077 -0
- package/runtime/ext_gui/style.cpp +62 -8
- package/runtime/ext_gui/style.h +111 -4
- package/runtime/ext_gui/style_cascade.cpp +83 -0
- package/runtime/ext_gui/style_internal.h +13 -1
- package/runtime/ext_gui/style_length.cpp +92 -0
- package/runtime/ext_gui/style_print.cpp +83 -2
- package/runtime/ext_gui/style_svg.cpp +40 -0
- package/runtime/ext_gui/style_text.cpp +302 -0
- package/runtime/ext_gui/style_ui.cpp +150 -0
- package/runtime/ext_gui/style_values.cpp +76 -62
- package/runtime/ext_gui/style_values_internal.h +23 -0
- package/runtime/ext_gui/text.cpp +27 -499
- package/runtime/ext_gui/text.h +18 -9
- package/runtime/ext_gui/text_api.h +45 -0
- package/runtime/ext_gui/text_bridge.c +23 -0
- package/runtime/ext_gui/text_cache.cpp +12 -3
- package/runtime/ext_gui/text_font_db.cpp +427 -0
- package/runtime/ext_gui/text_font_paths.cpp +250 -0
- package/runtime/ext_gui/text_font_paths.h +39 -0
- package/runtime/ext_gui/text_font_sfnt.cpp +396 -0
- package/runtime/ext_gui/text_font_sfnt.h +44 -0
- package/runtime/ext_gui/text_fonts.cpp +348 -0
- package/runtime/ext_gui/text_fonts.h +78 -0
- package/runtime/ext_gui/text_fonts_internal.h +77 -0
- package/runtime/ext_gui/text_glyph_cache.cpp +2 -2
- package/runtime/ext_gui/text_hb.cpp +438 -0
- package/runtime/ext_gui/text_stb.cpp +369 -0
- package/runtime/ext_gui/transform.cpp +107 -9
- package/runtime/ext_gui/transform.h +5 -0
- package/runtime/ext_gui/webgl_api.cpp +19 -0
- package/runtime/ext_gui/webgl_api.h +53 -0
- package/runtime/ext_gui/webgl_bridge.c +25 -0
- package/runtime/ext_gui/webgl_draw_setup.cpp +42 -1
- package/runtime/ext_gui/webgl_feature.cpp +82 -0
- package/runtime/ext_gui/webgl_feature.h +28 -0
- package/runtime/ext_gui/webgl_msl.cpp +41 -0
- package/runtime/ext_gui/webgl_msl.h +6 -0
- package/runtime/ext_gui/webgl_shader.cpp +40 -32
- package/runtime/ext_gui/window.cpp +7 -7
- package/runtime/ext_media/decode_audio.cpp +1 -1
- package/runtime/ext_media/media.cpp +1 -1
- package/runtime/ext_media/media_bridge.c +7 -7
- package/scripts/build-gui.ts +97 -98
- package/scripts/check-file-length.ts +1 -0
- package/scripts/gui-build-options.ts +122 -0
- package/src/cli/extensions.ts +72 -0
- package/src/cli/help.ts +3 -1
- package/src/cli/hints.ts +9 -3
- package/src/cli/main.ts +21 -27
- package/src/diagnostics/diagnostic.ts +2 -0
- package/src/driver/build-key.ts +3 -0
- package/src/driver/compiler.ts +63 -8
- package/src/driver/config.ts +6 -0
- package/src/driver/link-features.ts +163 -0
- package/src/driver/options.ts +10 -0
- package/src/driver/runtime-objects.ts +26 -1
- package/src/driver/usage.ts +376 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/catalog.ts +1 -2
- package/src/extensions/gui/features.ts +166 -0
- package/src/extensions/gui/index.ts +10 -4
- package/src/extensions/link-feature.ts +72 -0
- package/src/extensions/registry.ts +45 -4
- package/src/index.ts +3 -2
- package/dist/src/extensions/media/index.d.ts +0 -28
- package/dist/src/extensions/media/index.js +0 -59
- package/dist/src/extensions/media/index.js.map +0 -1
- package/dist/tests/extensions/media.test.js +0 -63
- package/dist/tests/extensions/media.test.js.map +0 -1
- package/src/extensions/media/index.ts +0 -65
- /package/dist/tests/{extensions/media.test.d.ts → driver/link-features.test.d.ts} +0 -0
|
@@ -124,52 +124,15 @@ static bool assignLength(Length *target, const std::string &value) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
case Unit::Min: {
|
|
138
|
-
float best = 0.0f;
|
|
139
|
-
bool first = true;
|
|
140
|
-
for (const Length &arg : length.args) {
|
|
141
|
-
float value = xt_style_resolve_absolute(arg, base, em, root, vw, vh);
|
|
142
|
-
if (first || value < best) best = value;
|
|
143
|
-
first = false;
|
|
144
|
-
}
|
|
145
|
-
return best;
|
|
146
|
-
}
|
|
147
|
-
case Unit::Max: {
|
|
148
|
-
float best = 0.0f;
|
|
149
|
-
bool first = true;
|
|
150
|
-
for (const Length &arg : length.args) {
|
|
151
|
-
float value = xt_style_resolve_absolute(arg, base, em, root, vw, vh);
|
|
152
|
-
if (first || value > best) best = value;
|
|
153
|
-
first = false;
|
|
154
|
-
}
|
|
155
|
-
return best;
|
|
156
|
-
}
|
|
157
|
-
case Unit::Px:
|
|
158
|
-
case Unit::Number:
|
|
159
|
-
return length.value;
|
|
160
|
-
case Unit::Percent:
|
|
161
|
-
return base * length.value / 100.0f;
|
|
162
|
-
case Unit::Em:
|
|
163
|
-
return em * length.value;
|
|
164
|
-
case Unit::Rem:
|
|
165
|
-
return root * length.value;
|
|
166
|
-
case Unit::Vw:
|
|
167
|
-
return vw * length.value / 100.0f;
|
|
168
|
-
case Unit::Vh:
|
|
169
|
-
return vh * length.value / 100.0f;
|
|
170
|
-
default:
|
|
171
|
-
return 0.0f;
|
|
172
|
-
}
|
|
127
|
+
/** A unitless declaration value, accepting `calc()` arithmetic (which resolves
|
|
128
|
+
* against the element's font and the viewport). */
|
|
129
|
+
static bool parseNumeric(const std::string &value, const ApplyContext &context, float *out) {
|
|
130
|
+
if (xt_css_parse_number(value, out)) return true;
|
|
131
|
+
Length length = xt_css_parse_length(value);
|
|
132
|
+
if (length.unit != Unit::Calc) return false;
|
|
133
|
+
*out = xt_style_resolve_absolute(length, 0.0f, context.parentFontSize, context.rootFontSize,
|
|
134
|
+
context.viewportWidth, context.viewportHeight);
|
|
135
|
+
return true;
|
|
173
136
|
}
|
|
174
137
|
|
|
175
138
|
static bool parseEnum(const std::string &value, const char *const *names, int count, int *out) {
|
|
@@ -193,15 +156,31 @@ static bool assignColor(Color *target, bool *has, const std::string &value) {
|
|
|
193
156
|
|
|
194
157
|
/* -- declaration application ---------------------------------------------- */
|
|
195
158
|
|
|
196
|
-
void xt_style_apply_declaration(XtStyle *style, const std::string &
|
|
159
|
+
void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
197
160
|
const std::string &rawValue, const ApplyContext &context) {
|
|
198
161
|
std::string value = xt_css_trim(rawValue);
|
|
162
|
+
/* Vendor aliases of properties the engine does implement. */
|
|
163
|
+
std::string property = rawProperty;
|
|
164
|
+
if (property == "-webkit-backdrop-filter") property = "backdrop-filter";
|
|
165
|
+
else if (property == "-webkit-user-select") property = "user-select";
|
|
199
166
|
|
|
200
167
|
if (property == "display") {
|
|
168
|
+
std::string text = xt_css_lower(value);
|
|
169
|
+
style->inline_level = false;
|
|
170
|
+
if (text == "inline-flex") {
|
|
171
|
+
style->display = Display::Flex;
|
|
172
|
+
style->inline_level = true;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (text == "inline-grid") {
|
|
176
|
+
style->display = Display::Grid;
|
|
177
|
+
style->inline_level = true;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
201
180
|
static const char *const names[] = {"none", "block", "inline", "inline-block", "flex", "grid",
|
|
202
181
|
"list-item"};
|
|
203
182
|
int index = 0;
|
|
204
|
-
if (parseEnum(
|
|
183
|
+
if (parseEnum(text, names, 7, &index)) style->display = (Display)index;
|
|
205
184
|
return;
|
|
206
185
|
}
|
|
207
186
|
if (property == "visibility") {
|
|
@@ -245,12 +224,36 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
245
224
|
return;
|
|
246
225
|
}
|
|
247
226
|
|
|
248
|
-
if (property == "margin") {
|
|
227
|
+
if (property == "margin") {
|
|
228
|
+
if (parseEdgeLengths(value, &style->margin)) {
|
|
229
|
+
style->margin_top_auto = style->margin.top.unit == Unit::Auto;
|
|
230
|
+
style->margin_right_auto = style->margin.right.unit == Unit::Auto;
|
|
231
|
+
style->margin_bottom_auto = style->margin.bottom.unit == Unit::Auto;
|
|
232
|
+
style->margin_left_auto = style->margin.left.unit == Unit::Auto;
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
249
236
|
if (property == "padding") { parseEdgeLengths(value, &style->padding); return; }
|
|
250
|
-
if (property == "margin-top") {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
237
|
+
if (property == "margin-top") {
|
|
238
|
+
setEdge(&style->margin, "top", xt_css_parse_length(value));
|
|
239
|
+
style->margin_top_auto = style->margin.top.unit == Unit::Auto;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (property == "margin-right") {
|
|
243
|
+
setEdge(&style->margin, "right", xt_css_parse_length(value));
|
|
244
|
+
style->margin_right_auto = style->margin.right.unit == Unit::Auto;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (property == "margin-bottom") {
|
|
248
|
+
setEdge(&style->margin, "bottom", xt_css_parse_length(value));
|
|
249
|
+
style->margin_bottom_auto = style->margin.bottom.unit == Unit::Auto;
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (property == "margin-left") {
|
|
253
|
+
setEdge(&style->margin, "left", xt_css_parse_length(value));
|
|
254
|
+
style->margin_left_auto = style->margin.left.unit == Unit::Auto;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
254
257
|
if (property == "padding-top") { setEdge(&style->padding, "top", xt_css_parse_length(value)); return; }
|
|
255
258
|
if (property == "padding-right") { setEdge(&style->padding, "right", xt_css_parse_length(value)); return; }
|
|
256
259
|
if (property == "padding-bottom") { setEdge(&style->padding, "bottom", xt_css_parse_length(value)); return; }
|
|
@@ -262,8 +265,12 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
262
265
|
if (property == "border-bottom-width") { setEdge(&style->border_width, "bottom", xt_css_parse_length(value)); return; }
|
|
263
266
|
if (property == "border-left-width") { setEdge(&style->border_width, "left", xt_css_parse_length(value)); return; }
|
|
264
267
|
if (property == "border-radius") {
|
|
268
|
+
/* `%` stays symbolic: layout resolves it against the box's smaller side. */
|
|
265
269
|
Length length = xt_css_parse_length(value);
|
|
266
|
-
if (length.unit
|
|
270
|
+
if (length.unit != Unit::Invalid && length.unit != Unit::Auto &&
|
|
271
|
+
length.unit != Unit::None) {
|
|
272
|
+
style->border_radius = length;
|
|
273
|
+
}
|
|
267
274
|
return;
|
|
268
275
|
}
|
|
269
276
|
if (property == "border-style" || property == "border-top-style" || property == "border-right-style" ||
|
|
@@ -280,9 +287,10 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
280
287
|
}
|
|
281
288
|
if (property == "border" || property == "border-top" || property == "border-right" ||
|
|
282
289
|
property == "border-bottom" || property == "border-left") {
|
|
283
|
-
for (const std::string &token :
|
|
290
|
+
for (const std::string &token : splitEdgeTokens(value)) {
|
|
284
291
|
Length length = xt_css_parse_length(token);
|
|
285
|
-
if (length.unit
|
|
292
|
+
if (length.unit != Unit::Invalid && length.unit != Unit::Auto &&
|
|
293
|
+
length.unit != Unit::None) {
|
|
286
294
|
if (property == "border") style->border_width.set(length);
|
|
287
295
|
else setEdge(&style->border_width, property.substr(7), length);
|
|
288
296
|
continue;
|
|
@@ -308,6 +316,7 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
308
316
|
return;
|
|
309
317
|
}
|
|
310
318
|
if (property == "background-color") { assignColor(&style->background, &style->has_background, value); return; }
|
|
319
|
+
if (property == "background-size") { xt_style_apply_background_size(style, value); return; }
|
|
311
320
|
if (property == "background-image") {
|
|
312
321
|
xt_style_apply_background_image(style, value);
|
|
313
322
|
return;
|
|
@@ -398,6 +407,9 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
398
407
|
if (parseEnum(value, names, 5, &index)) style->white_space = (WhiteSpace)index;
|
|
399
408
|
return;
|
|
400
409
|
}
|
|
410
|
+
if (xt_style_apply_text_property(style, property, value, context)) return;
|
|
411
|
+
if (xt_style_apply_ui_property(style, property, value)) return;
|
|
412
|
+
if (xt_style_apply_svg_property(style, property, value)) return;
|
|
401
413
|
|
|
402
414
|
if (xt_style_apply_grid_property(style, property, value)) return;
|
|
403
415
|
|
|
@@ -447,12 +459,12 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
447
459
|
if (property == "column-gap") { assignLength(&style->column_gap, value); return; }
|
|
448
460
|
if (property == "flex-grow") {
|
|
449
461
|
float number = 0;
|
|
450
|
-
if (
|
|
462
|
+
if (parseNumeric(value, context, &number)) style->flex_grow = number;
|
|
451
463
|
return;
|
|
452
464
|
}
|
|
453
465
|
if (property == "flex-shrink") {
|
|
454
466
|
float number = 0;
|
|
455
|
-
if (
|
|
467
|
+
if (parseNumeric(value, context, &number)) style->flex_shrink = number;
|
|
456
468
|
return;
|
|
457
469
|
}
|
|
458
470
|
if (property == "flex-basis") { assignLength(&style->flex_basis, value); return; }
|
|
@@ -476,7 +488,7 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
476
488
|
style->flex_basis = {0.0f, Unit::Auto};
|
|
477
489
|
return;
|
|
478
490
|
}
|
|
479
|
-
std::vector<std::string> parts =
|
|
491
|
+
std::vector<std::string> parts = splitEdgeTokens(text);
|
|
480
492
|
style->flex_grow = 0;
|
|
481
493
|
style->flex_shrink = 1;
|
|
482
494
|
style->flex_basis = {0.0f, Unit::Auto};
|
|
@@ -504,7 +516,7 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
504
516
|
/* One or two values plus an optional z offset (ignored: the engine is 2D).
|
|
505
517
|
* The keywords carry an axis, so `top` alone means `center top` and
|
|
506
518
|
* `top center` is the same as `center top`. */
|
|
507
|
-
std::vector<std::string> parts =
|
|
519
|
+
std::vector<std::string> parts = splitEdgeTokens(value);
|
|
508
520
|
Length values[2] = {Length{50.0f, Unit::Percent}, Length{50.0f, Unit::Percent}};
|
|
509
521
|
bool vertical[2] = {false, false};
|
|
510
522
|
size_t used = 0;
|
|
@@ -540,7 +552,8 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
540
552
|
}
|
|
541
553
|
if (property == "opacity") {
|
|
542
554
|
float number = 0;
|
|
543
|
-
if (
|
|
555
|
+
if (parseNumeric(value, context, &number))
|
|
556
|
+
style->opacity = number < 0 ? 0 : (number > 1 ? 1 : number);
|
|
544
557
|
return;
|
|
545
558
|
}
|
|
546
559
|
if (property == "mix-blend-mode") {
|
|
@@ -561,7 +574,7 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
561
574
|
}
|
|
562
575
|
if (property == "z-index") {
|
|
563
576
|
float number = 0;
|
|
564
|
-
if (
|
|
577
|
+
if (parseNumeric(value, context, &number)) {
|
|
565
578
|
style->z_index = (int)number;
|
|
566
579
|
style->has_z_index = true;
|
|
567
580
|
}
|
|
@@ -580,6 +593,7 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &property,
|
|
|
580
593
|
return;
|
|
581
594
|
}
|
|
582
595
|
if (xt_style_apply_transition(style, property, value)) return;
|
|
596
|
+
if (xt_style_apply_animation(style, property, value)) return;
|
|
583
597
|
|
|
584
598
|
}
|
|
585
599
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <string>
|
|
5
5
|
|
|
6
6
|
struct XtStyle;
|
|
7
|
+
struct ApplyContext;
|
|
7
8
|
|
|
8
9
|
namespace xtgui {
|
|
9
10
|
|
|
@@ -30,6 +31,28 @@ bool xt_style_apply_grid_property(XtStyle *style, const std::string &property,
|
|
|
30
31
|
bool xt_style_apply_transition(XtStyle *style, const std::string &property,
|
|
31
32
|
const std::string &value);
|
|
32
33
|
|
|
34
|
+
/** Apply an `animation`/`animation-*` declaration. */
|
|
35
|
+
bool xt_style_apply_animation(XtStyle *style, const std::string &property,
|
|
36
|
+
const std::string &value);
|
|
37
|
+
|
|
38
|
+
/** Apply text declarations (`letter-spacing`, `text-transform`,
|
|
39
|
+
* `writing-mode`, `vertical-align`, the `font` shorthand, …). */
|
|
40
|
+
bool xt_style_apply_text_property(XtStyle *style, const std::string &property,
|
|
41
|
+
const std::string &value, const ApplyContext &context);
|
|
42
|
+
|
|
43
|
+
/** Apply UI/interaction declarations (`outline`, `cursor`, `isolation`, and
|
|
44
|
+
* the platform hints the engine accepts but does not act on). */
|
|
45
|
+
bool xt_style_apply_ui_property(XtStyle *style, const std::string &property,
|
|
46
|
+
const std::string &value);
|
|
47
|
+
|
|
48
|
+
/** Record an SVG presentation property (`fill`, `stroke`, …) for the inline
|
|
49
|
+
* `<svg>` serializer. Returns false for unrelated properties. */
|
|
50
|
+
bool xt_style_apply_svg_property(XtStyle *style, const std::string &property,
|
|
51
|
+
const std::string &value);
|
|
52
|
+
|
|
53
|
+
/** Apply `background-size` (a comma-separated list, one per layer). */
|
|
54
|
+
bool xt_style_apply_background_size(XtStyle *style, const std::string &value);
|
|
55
|
+
|
|
33
56
|
} // namespace xtgui
|
|
34
57
|
|
|
35
58
|
#endif /* XT_GUI_STYLE_VALUES_INTERNAL_H */
|