xbintsc 0.6.9 → 0.6.10
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/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +1 -0
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/driver/config.js +1 -0
- package/dist/src/driver/config.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/driver/version.js.map +1 -1
- package/dist/tests/driver/config.test.js +15 -2
- package/dist/tests/driver/config.test.js.map +1 -1
- package/dist/tests/e2e/gui-helpers.d.ts +2 -0
- package/dist/tests/e2e/gui-helpers.js +1 -0
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +47 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-paint.test.js +108 -0
- package/dist/tests/e2e/gui-paint.test.js.map +1 -1
- package/dist/tests/e2e/gui-unsupported.test.d.ts +6 -0
- package/dist/tests/e2e/gui-unsupported.test.js +123 -0
- package/dist/tests/e2e/gui-unsupported.test.js.map +1 -0
- package/doc/ai/extensions.md +7 -4
- package/doc/ai/zh-CN/extensions.md +6 -3
- package/doc/gui/dom.md +69 -1
- package/doc/gui/known-issues.md +12 -5
- package/doc/gui/layout.md +19 -6
- package/doc/gui/rendering.md +16 -9
- package/doc/zh-CN/gui/dom.md +61 -1
- package/doc/zh-CN/gui/known-issues.md +11 -4
- package/doc/zh-CN/gui/layout.md +14 -4
- package/doc/zh-CN/gui/rendering.md +13 -10
- package/package.json +7 -7
- package/runtime/ext_gui/clip_values.cpp +11 -0
- package/runtime/ext_gui/css.cpp +27 -2
- package/runtime/ext_gui/css_selector.cpp +23 -0
- package/runtime/ext_gui/css_sheet.cpp +7 -0
- package/runtime/ext_gui/document.cpp +3 -0
- package/runtime/ext_gui/document_animation.cpp +4 -1
- package/runtime/ext_gui/dom_api.cpp +3 -0
- package/runtime/ext_gui/dom_parse.cpp +4 -0
- package/runtime/ext_gui/effect_values.cpp +28 -7
- package/runtime/ext_gui/gradient_values.cpp +25 -5
- package/runtime/ext_gui/inline_svg.cpp +3 -0
- package/runtime/ext_gui/layout_flow.cpp +12 -2
- package/runtime/ext_gui/layout_inline.cpp +80 -7
- package/runtime/ext_gui/media_query.cpp +7 -1
- package/runtime/ext_gui/paint.cpp +58 -23
- package/runtime/ext_gui/paint.h +7 -4
- package/runtime/ext_gui/paint_clip.cpp +74 -19
- package/runtime/ext_gui/paint_internal.h +7 -1
- package/runtime/ext_gui/renderer_clip.cpp +19 -17
- package/runtime/ext_gui/style.cpp +5 -1
- package/runtime/ext_gui/style.h +5 -0
- package/runtime/ext_gui/style_cascade.cpp +2 -0
- package/runtime/ext_gui/style_internal.h +7 -2
- package/runtime/ext_gui/style_print.cpp +3 -0
- package/runtime/ext_gui/style_text.cpp +11 -0
- package/runtime/ext_gui/style_values.cpp +89 -90
- package/runtime/ext_gui/transform.cpp +2 -0
- package/runtime/ext_gui/warnings.cpp +300 -0
- package/runtime/ext_gui/warnings.h +59 -0
- package/src/cli/main.ts +1 -0
- package/src/driver/config.ts +1 -0
- package/src/driver/version.ts +1 -1
|
@@ -81,7 +81,6 @@ static bool parseEdgeLengths(const std::string &value, Edges *edges) {
|
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
84
|
/** `inset: <top> <right> <bottom> <left>` (1-4 values, like margin). */
|
|
86
85
|
static bool parseInsetLengths(const std::string &value, Length *top, Length *right, Length *bottom,
|
|
87
86
|
Length *left) {
|
|
@@ -123,7 +122,6 @@ static bool assignLength(Length *target, const std::string &value) {
|
|
|
123
122
|
return true;
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
|
|
127
125
|
/** A unitless declaration value, accepting `calc()` arithmetic (which resolves
|
|
128
126
|
* against the element's font and the viewport). */
|
|
129
127
|
static bool parseNumeric(const std::string &value, const ApplyContext &context, float *out) {
|
|
@@ -156,7 +154,7 @@ static bool assignColor(Color *target, bool *has, const std::string &value) {
|
|
|
156
154
|
|
|
157
155
|
/* -- declaration application ---------------------------------------------- */
|
|
158
156
|
|
|
159
|
-
|
|
157
|
+
bool xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
160
158
|
const std::string &rawValue, const ApplyContext &context) {
|
|
161
159
|
std::string value = xt_css_trim(rawValue);
|
|
162
160
|
/* Vendor aliases of properties the engine does implement. */
|
|
@@ -170,24 +168,24 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
170
168
|
if (text == "inline-flex") {
|
|
171
169
|
style->display = Display::Flex;
|
|
172
170
|
style->inline_level = true;
|
|
173
|
-
return;
|
|
171
|
+
return true;
|
|
174
172
|
}
|
|
175
173
|
if (text == "inline-grid") {
|
|
176
174
|
style->display = Display::Grid;
|
|
177
175
|
style->inline_level = true;
|
|
178
|
-
return;
|
|
176
|
+
return true;
|
|
179
177
|
}
|
|
180
178
|
static const char *const names[] = {"none", "block", "inline", "inline-block", "flex", "grid",
|
|
181
179
|
"list-item"};
|
|
182
180
|
int index = 0;
|
|
183
181
|
if (parseEnum(text, names, 7, &index)) style->display = (Display)index;
|
|
184
|
-
return;
|
|
182
|
+
return true;
|
|
185
183
|
}
|
|
186
184
|
if (property == "visibility") {
|
|
187
185
|
std::string text = xt_css_lower(xt_css_trim(value));
|
|
188
186
|
if (text == "hidden" || text == "collapse") style->visible = false;
|
|
189
187
|
else if (text == "visible") style->visible = true;
|
|
190
|
-
return;
|
|
188
|
+
return true;
|
|
191
189
|
}
|
|
192
190
|
if (property == "pointer-events") {
|
|
193
191
|
std::string text = xt_css_lower(xt_css_trim(value));
|
|
@@ -195,33 +193,33 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
195
193
|
else if (text == "auto" || text == "all" || text == "visiblepainted" ||
|
|
196
194
|
text == "visiblefill" || text == "visiblestroke")
|
|
197
195
|
style->pointer_events = true;
|
|
198
|
-
return;
|
|
196
|
+
return true;
|
|
199
197
|
}
|
|
200
198
|
if (property == "box-sizing") {
|
|
201
199
|
std::string text = xt_css_lower(xt_css_trim(value));
|
|
202
200
|
if (text == "border-box") style->box_sizing = BoxSizing::BorderBox;
|
|
203
201
|
else if (text == "content-box") style->box_sizing = BoxSizing::ContentBox;
|
|
204
|
-
return;
|
|
202
|
+
return true;
|
|
205
203
|
}
|
|
206
204
|
if (property == "position") {
|
|
207
205
|
static const char *const names[] = {"static", "relative", "absolute", "fixed"};
|
|
208
206
|
int index = 0;
|
|
209
207
|
if (parseEnum(value, names, 4, &index)) style->position = (Position)index;
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (property == "width") { assignLength(&style->width, value); return; }
|
|
213
|
-
if (property == "height") { assignLength(&style->height, value); return; }
|
|
214
|
-
if (property == "min-width") { assignLength(&style->min_width, value); return; }
|
|
215
|
-
if (property == "min-height") { assignLength(&style->min_height, value); return; }
|
|
216
|
-
if (property == "max-width") { assignLength(&style->max_width, value); return; }
|
|
217
|
-
if (property == "max-height") { assignLength(&style->max_height, value); return; }
|
|
218
|
-
if (property == "top") { assignLength(&style->top, value); return; }
|
|
219
|
-
if (property == "right") { assignLength(&style->right, value); return; }
|
|
220
|
-
if (property == "bottom") { assignLength(&style->bottom, value); return; }
|
|
221
|
-
if (property == "left") { assignLength(&style->left, value); return; }
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
if (property == "width") { assignLength(&style->width, value); return true; }
|
|
211
|
+
if (property == "height") { assignLength(&style->height, value); return true; }
|
|
212
|
+
if (property == "min-width") { assignLength(&style->min_width, value); return true; }
|
|
213
|
+
if (property == "min-height") { assignLength(&style->min_height, value); return true; }
|
|
214
|
+
if (property == "max-width") { assignLength(&style->max_width, value); return true; }
|
|
215
|
+
if (property == "max-height") { assignLength(&style->max_height, value); return true; }
|
|
216
|
+
if (property == "top") { assignLength(&style->top, value); return true; }
|
|
217
|
+
if (property == "right") { assignLength(&style->right, value); return true; }
|
|
218
|
+
if (property == "bottom") { assignLength(&style->bottom, value); return true; }
|
|
219
|
+
if (property == "left") { assignLength(&style->left, value); return true; }
|
|
222
220
|
if (property == "inset") {
|
|
223
221
|
parseInsetLengths(value, &style->top, &style->right, &style->bottom, &style->left);
|
|
224
|
-
return;
|
|
222
|
+
return true;
|
|
225
223
|
}
|
|
226
224
|
|
|
227
225
|
if (property == "margin") {
|
|
@@ -231,39 +229,39 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
231
229
|
style->margin_bottom_auto = style->margin.bottom.unit == Unit::Auto;
|
|
232
230
|
style->margin_left_auto = style->margin.left.unit == Unit::Auto;
|
|
233
231
|
}
|
|
234
|
-
return;
|
|
232
|
+
return true;
|
|
235
233
|
}
|
|
236
|
-
if (property == "padding") { parseEdgeLengths(value, &style->padding); return; }
|
|
234
|
+
if (property == "padding") { parseEdgeLengths(value, &style->padding); return true; }
|
|
237
235
|
if (property == "margin-top") {
|
|
238
236
|
setEdge(&style->margin, "top", xt_css_parse_length(value));
|
|
239
237
|
style->margin_top_auto = style->margin.top.unit == Unit::Auto;
|
|
240
|
-
return;
|
|
238
|
+
return true;
|
|
241
239
|
}
|
|
242
240
|
if (property == "margin-right") {
|
|
243
241
|
setEdge(&style->margin, "right", xt_css_parse_length(value));
|
|
244
242
|
style->margin_right_auto = style->margin.right.unit == Unit::Auto;
|
|
245
|
-
return;
|
|
243
|
+
return true;
|
|
246
244
|
}
|
|
247
245
|
if (property == "margin-bottom") {
|
|
248
246
|
setEdge(&style->margin, "bottom", xt_css_parse_length(value));
|
|
249
247
|
style->margin_bottom_auto = style->margin.bottom.unit == Unit::Auto;
|
|
250
|
-
return;
|
|
248
|
+
return true;
|
|
251
249
|
}
|
|
252
250
|
if (property == "margin-left") {
|
|
253
251
|
setEdge(&style->margin, "left", xt_css_parse_length(value));
|
|
254
252
|
style->margin_left_auto = style->margin.left.unit == Unit::Auto;
|
|
255
|
-
return;
|
|
253
|
+
return true;
|
|
256
254
|
}
|
|
257
|
-
if (property == "padding-top") { setEdge(&style->padding, "top", xt_css_parse_length(value)); return; }
|
|
258
|
-
if (property == "padding-right") { setEdge(&style->padding, "right", xt_css_parse_length(value)); return; }
|
|
259
|
-
if (property == "padding-bottom") { setEdge(&style->padding, "bottom", xt_css_parse_length(value)); return; }
|
|
260
|
-
if (property == "padding-left") { setEdge(&style->padding, "left", xt_css_parse_length(value)); return; }
|
|
255
|
+
if (property == "padding-top") { setEdge(&style->padding, "top", xt_css_parse_length(value)); return true; }
|
|
256
|
+
if (property == "padding-right") { setEdge(&style->padding, "right", xt_css_parse_length(value)); return true; }
|
|
257
|
+
if (property == "padding-bottom") { setEdge(&style->padding, "bottom", xt_css_parse_length(value)); return true; }
|
|
258
|
+
if (property == "padding-left") { setEdge(&style->padding, "left", xt_css_parse_length(value)); return true; }
|
|
261
259
|
|
|
262
|
-
if (property == "border-width") { parseEdgeLengths(value, &style->border_width); return; }
|
|
263
|
-
if (property == "border-top-width") { setEdge(&style->border_width, "top", xt_css_parse_length(value)); return; }
|
|
264
|
-
if (property == "border-right-width") { setEdge(&style->border_width, "right", xt_css_parse_length(value)); return; }
|
|
265
|
-
if (property == "border-bottom-width") { setEdge(&style->border_width, "bottom", xt_css_parse_length(value)); return; }
|
|
266
|
-
if (property == "border-left-width") { setEdge(&style->border_width, "left", xt_css_parse_length(value)); return; }
|
|
260
|
+
if (property == "border-width") { parseEdgeLengths(value, &style->border_width); return true; }
|
|
261
|
+
if (property == "border-top-width") { setEdge(&style->border_width, "top", xt_css_parse_length(value)); return true; }
|
|
262
|
+
if (property == "border-right-width") { setEdge(&style->border_width, "right", xt_css_parse_length(value)); return true; }
|
|
263
|
+
if (property == "border-bottom-width") { setEdge(&style->border_width, "bottom", xt_css_parse_length(value)); return true; }
|
|
264
|
+
if (property == "border-left-width") { setEdge(&style->border_width, "left", xt_css_parse_length(value)); return true; }
|
|
267
265
|
if (property == "border-radius") {
|
|
268
266
|
/* `%` stays symbolic: layout resolves it against the box's smaller side. */
|
|
269
267
|
Length length = xt_css_parse_length(value);
|
|
@@ -271,19 +269,19 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
271
269
|
length.unit != Unit::None) {
|
|
272
270
|
style->border_radius = length;
|
|
273
271
|
}
|
|
274
|
-
return;
|
|
272
|
+
return true;
|
|
275
273
|
}
|
|
276
274
|
if (property == "border-style" || property == "border-top-style" || property == "border-right-style" ||
|
|
277
275
|
property == "border-bottom-style" || property == "border-left-style") {
|
|
278
276
|
static const char *const names[] = {"none", "solid", "dashed", "dotted"};
|
|
279
277
|
int index = 0;
|
|
280
278
|
if (parseEnum(value, names, 4, &index)) style->border_style = (BorderStyle)index;
|
|
281
|
-
return;
|
|
279
|
+
return true;
|
|
282
280
|
}
|
|
283
281
|
if (property == "border-color" || property == "border-top-color" || property == "border-right-color" ||
|
|
284
282
|
property == "border-bottom-color" || property == "border-left-color") {
|
|
285
283
|
assignColor(&style->border_color, &style->has_border_color, value);
|
|
286
|
-
return;
|
|
284
|
+
return true;
|
|
287
285
|
}
|
|
288
286
|
if (property == "border" || property == "border-top" || property == "border-right" ||
|
|
289
287
|
property == "border-bottom" || property == "border-left") {
|
|
@@ -307,39 +305,39 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
307
305
|
style->has_border_color = true;
|
|
308
306
|
}
|
|
309
307
|
}
|
|
310
|
-
return;
|
|
308
|
+
return true;
|
|
311
309
|
}
|
|
312
310
|
|
|
313
311
|
if (property == "color") {
|
|
314
312
|
Color color = xt_css_parse_color(value);
|
|
315
313
|
if (color.valid) style->color = color;
|
|
316
|
-
return;
|
|
314
|
+
return true;
|
|
317
315
|
}
|
|
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; }
|
|
316
|
+
if (property == "background-color") { assignColor(&style->background, &style->has_background, value); return true; }
|
|
317
|
+
if (property == "background-size") { xt_style_apply_background_size(style, value); return true; }
|
|
320
318
|
if (property == "background-image") {
|
|
321
319
|
xt_style_apply_background_image(style, value);
|
|
322
|
-
return;
|
|
320
|
+
return true;
|
|
323
321
|
}
|
|
324
322
|
if (property == "background") {
|
|
325
323
|
xt_style_apply_background(style, value);
|
|
326
|
-
return;
|
|
324
|
+
return true;
|
|
327
325
|
}
|
|
328
326
|
if (property == "clip-path") {
|
|
329
327
|
xt_style_apply_clip_path(style, property, value);
|
|
330
|
-
return;
|
|
328
|
+
return true;
|
|
331
329
|
}
|
|
332
|
-
if (xt_style_apply_effect(style, property, value)) return;
|
|
330
|
+
if (xt_style_apply_effect(style, property, value)) return true;
|
|
333
331
|
|
|
334
332
|
if (property == "font-size") {
|
|
335
333
|
Length length = xt_css_parse_length(value);
|
|
336
|
-
if (length.unit == Unit::Invalid) return;
|
|
334
|
+
if (length.unit == Unit::Invalid) return true;
|
|
337
335
|
/* `em`/`%` resolve against the *parent* font size, never the element's own
|
|
338
336
|
* (possibly UA-set) size. */
|
|
339
337
|
style->font_size = xt_style_resolve_absolute(length, context.parentFontSize, context.parentFontSize,
|
|
340
338
|
context.rootFontSize, context.viewportWidth, context.viewportHeight);
|
|
341
339
|
if (style->font_size <= 0.0f) style->font_size = 16.0f;
|
|
342
|
-
return;
|
|
340
|
+
return true;
|
|
343
341
|
}
|
|
344
342
|
if (property == "font-weight") {
|
|
345
343
|
std::string text = xt_css_lower(value);
|
|
@@ -351,21 +349,21 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
351
349
|
float number = 0;
|
|
352
350
|
if (xt_css_parse_number(text, &number)) style->font_weight = (int)number;
|
|
353
351
|
}
|
|
354
|
-
return;
|
|
352
|
+
return true;
|
|
355
353
|
}
|
|
356
354
|
if (property == "font-family") {
|
|
357
355
|
style->font_family = value;
|
|
358
|
-
return;
|
|
356
|
+
return true;
|
|
359
357
|
}
|
|
360
358
|
if (property == "font-style") {
|
|
361
359
|
style->font_style = (xt_css_lower(value) == "italic") ? FontStyle::Italic : FontStyle::Normal;
|
|
362
|
-
return;
|
|
360
|
+
return true;
|
|
363
361
|
}
|
|
364
362
|
if (property == "line-height") {
|
|
365
363
|
std::string text = xt_css_lower(value);
|
|
366
364
|
if (text == "normal") {
|
|
367
365
|
style->line_height = {};
|
|
368
|
-
return;
|
|
366
|
+
return true;
|
|
369
367
|
}
|
|
370
368
|
/* A unitless `line-height` is a multiplier, not a length in pixels. The
|
|
371
369
|
* generic length parser maps a bare number to `px`, which collapsed
|
|
@@ -383,15 +381,15 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
383
381
|
float number = 0;
|
|
384
382
|
if (xt_css_parse_number(text, &number)) {
|
|
385
383
|
style->line_height = {number, Unit::Number};
|
|
386
|
-
return;
|
|
384
|
+
return true;
|
|
387
385
|
}
|
|
388
386
|
}
|
|
389
387
|
Length length = xt_css_parse_length(text);
|
|
390
|
-
if (length.unit == Unit::Invalid) return;
|
|
388
|
+
if (length.unit == Unit::Invalid) return true;
|
|
391
389
|
/* Relative units are resolved in `finalizeStyle`, once the element's own
|
|
392
390
|
* font size is settled. */
|
|
393
391
|
style->line_height = length;
|
|
394
|
-
return;
|
|
392
|
+
return true;
|
|
395
393
|
}
|
|
396
394
|
if (property == "text-align") {
|
|
397
395
|
std::string text = xt_css_lower(value);
|
|
@@ -399,31 +397,31 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
399
397
|
else if (text == "right" || text == "end") style->text_align = TextAlign::End;
|
|
400
398
|
else if (text == "center") style->text_align = TextAlign::Center;
|
|
401
399
|
else if (text == "justify") style->text_align = TextAlign::Justify;
|
|
402
|
-
return;
|
|
400
|
+
return true;
|
|
403
401
|
}
|
|
404
402
|
if (property == "white-space") {
|
|
405
403
|
static const char *const names[] = {"normal", "nowrap", "pre", "pre-wrap", "pre-line"};
|
|
406
404
|
int index = 0;
|
|
407
405
|
if (parseEnum(value, names, 5, &index)) style->white_space = (WhiteSpace)index;
|
|
408
|
-
return;
|
|
406
|
+
return true;
|
|
409
407
|
}
|
|
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;
|
|
408
|
+
if (xt_style_apply_text_property(style, property, value, context)) return true;
|
|
409
|
+
if (xt_style_apply_ui_property(style, property, value)) return true;
|
|
410
|
+
if (xt_style_apply_svg_property(style, property, value)) return true;
|
|
413
411
|
|
|
414
|
-
if (xt_style_apply_grid_property(style, property, value)) return;
|
|
412
|
+
if (xt_style_apply_grid_property(style, property, value)) return true;
|
|
415
413
|
|
|
416
414
|
if (property == "flex-direction") {
|
|
417
415
|
static const char *const names[] = {"row", "row-reverse", "column", "column-reverse"};
|
|
418
416
|
int index = 0;
|
|
419
417
|
if (parseEnum(value, names, 4, &index)) style->flex_direction = (FlexDirection)index;
|
|
420
|
-
return;
|
|
418
|
+
return true;
|
|
421
419
|
}
|
|
422
420
|
if (property == "flex-wrap") {
|
|
423
421
|
static const char *const names[] = {"nowrap", "wrap", "wrap-reverse"};
|
|
424
422
|
int index = 0;
|
|
425
423
|
if (parseEnum(value, names, 3, &index)) style->flex_wrap = (FlexWrap)index;
|
|
426
|
-
return;
|
|
424
|
+
return true;
|
|
427
425
|
}
|
|
428
426
|
if (property == "flex-flow") {
|
|
429
427
|
/* `flex-flow: <direction> || <wrap>` in either order. */
|
|
@@ -434,59 +432,59 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
434
432
|
if (parseEnum(token, dirs, 4, &index)) style->flex_direction = (FlexDirection)index;
|
|
435
433
|
else if (parseEnum(token, wraps, 3, &index)) style->flex_wrap = (FlexWrap)index;
|
|
436
434
|
}
|
|
437
|
-
return;
|
|
435
|
+
return true;
|
|
438
436
|
}
|
|
439
437
|
if (property == "justify-content") {
|
|
440
438
|
static const char *const names[] = {"flex-start", "flex-end", "center", "space-between",
|
|
441
439
|
"space-around", "space-evenly"};
|
|
442
440
|
int index = 0;
|
|
443
441
|
if (parseEnum(value, names, 6, &index)) style->justify_content = (JustifyContent)index;
|
|
444
|
-
return;
|
|
442
|
+
return true;
|
|
445
443
|
}
|
|
446
444
|
if (property == "align-content") {
|
|
447
445
|
static const char *const names[] = {"stretch", "flex-start", "flex-end", "center",
|
|
448
446
|
"space-between", "space-around"};
|
|
449
447
|
int index = 0;
|
|
450
448
|
if (parseEnum(value, names, 6, &index)) style->align_content = (AlignContent)index;
|
|
451
|
-
return;
|
|
449
|
+
return true;
|
|
452
450
|
}
|
|
453
451
|
if (property == "gap") {
|
|
454
452
|
assignLength(&style->gap, value);
|
|
455
453
|
style->row_gap = style->column_gap = style->gap;
|
|
456
|
-
return;
|
|
454
|
+
return true;
|
|
457
455
|
}
|
|
458
|
-
if (property == "row-gap") { assignLength(&style->row_gap, value); return; }
|
|
459
|
-
if (property == "column-gap") { assignLength(&style->column_gap, value); return; }
|
|
456
|
+
if (property == "row-gap") { assignLength(&style->row_gap, value); return true; }
|
|
457
|
+
if (property == "column-gap") { assignLength(&style->column_gap, value); return true; }
|
|
460
458
|
if (property == "flex-grow") {
|
|
461
459
|
float number = 0;
|
|
462
460
|
if (parseNumeric(value, context, &number)) style->flex_grow = number;
|
|
463
|
-
return;
|
|
461
|
+
return true;
|
|
464
462
|
}
|
|
465
463
|
if (property == "flex-shrink") {
|
|
466
464
|
float number = 0;
|
|
467
465
|
if (parseNumeric(value, context, &number)) style->flex_shrink = number;
|
|
468
|
-
return;
|
|
466
|
+
return true;
|
|
469
467
|
}
|
|
470
|
-
if (property == "flex-basis") { assignLength(&style->flex_basis, value); return; }
|
|
468
|
+
if (property == "flex-basis") { assignLength(&style->flex_basis, value); return true; }
|
|
471
469
|
if (property == "flex") {
|
|
472
470
|
std::string text = xt_css_lower(value);
|
|
473
471
|
if (text == "none") {
|
|
474
472
|
style->flex_grow = 0;
|
|
475
473
|
style->flex_shrink = 0;
|
|
476
474
|
style->flex_basis = {0.0f, Unit::Auto};
|
|
477
|
-
return;
|
|
475
|
+
return true;
|
|
478
476
|
}
|
|
479
477
|
if (text == "auto") {
|
|
480
478
|
style->flex_grow = 1;
|
|
481
479
|
style->flex_shrink = 1;
|
|
482
480
|
style->flex_basis = {0.0f, Unit::Auto};
|
|
483
|
-
return;
|
|
481
|
+
return true;
|
|
484
482
|
}
|
|
485
483
|
if (text == "initial") {
|
|
486
484
|
style->flex_grow = 0;
|
|
487
485
|
style->flex_shrink = 1;
|
|
488
486
|
style->flex_basis = {0.0f, Unit::Auto};
|
|
489
|
-
return;
|
|
487
|
+
return true;
|
|
490
488
|
}
|
|
491
489
|
std::vector<std::string> parts = splitEdgeTokens(text);
|
|
492
490
|
style->flex_grow = 0;
|
|
@@ -504,13 +502,13 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
504
502
|
if (index >= parts.size()) style->flex_basis = {0.0f, Unit::Px};
|
|
505
503
|
}
|
|
506
504
|
if (index < parts.size()) assignLength(&style->flex_basis, parts[index]);
|
|
507
|
-
return;
|
|
505
|
+
return true;
|
|
508
506
|
}
|
|
509
507
|
|
|
510
508
|
if (property == "transform") {
|
|
511
509
|
std::vector<TransformOp> ops;
|
|
512
510
|
if (xt_transform_parse(value, &ops)) style->transform = ops;
|
|
513
|
-
return;
|
|
511
|
+
return true;
|
|
514
512
|
}
|
|
515
513
|
if (property == "transform-origin") {
|
|
516
514
|
/* One or two values plus an optional z offset (ignored: the engine is 2D).
|
|
@@ -528,12 +526,12 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
528
526
|
if (keyword == "left" || keyword == "top") length = {0.0f, Unit::Percent};
|
|
529
527
|
else if (keyword == "center") length = {50.0f, Unit::Percent};
|
|
530
528
|
else if (keyword == "right" || keyword == "bottom") length = {100.0f, Unit::Percent};
|
|
531
|
-
else return;
|
|
529
|
+
else return true;
|
|
532
530
|
vertical[used] = keyword == "top" || keyword == "bottom";
|
|
533
531
|
}
|
|
534
532
|
values[used++] = length;
|
|
535
533
|
}
|
|
536
|
-
if (used == 0) return;
|
|
534
|
+
if (used == 0) return true;
|
|
537
535
|
Length x = values[0];
|
|
538
536
|
Length y = used > 1 ? values[1] : Length{50.0f, Unit::Percent};
|
|
539
537
|
if (used > 1) {
|
|
@@ -548,13 +546,13 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
548
546
|
}
|
|
549
547
|
style->transform_origin_x = x;
|
|
550
548
|
style->transform_origin_y = y;
|
|
551
|
-
return;
|
|
549
|
+
return true;
|
|
552
550
|
}
|
|
553
551
|
if (property == "opacity") {
|
|
554
552
|
float number = 0;
|
|
555
553
|
if (parseNumeric(value, context, &number))
|
|
556
554
|
style->opacity = number < 0 ? 0 : (number > 1 ? 1 : number);
|
|
557
|
-
return;
|
|
555
|
+
return true;
|
|
558
556
|
}
|
|
559
557
|
if (property == "mix-blend-mode") {
|
|
560
558
|
static const char *const names[] = {
|
|
@@ -564,13 +562,13 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
564
562
|
"luminosity"};
|
|
565
563
|
int index = 0;
|
|
566
564
|
if (parseEnum(value, names, 16, &index)) style->mix_blend_mode = (MixBlendMode)index;
|
|
567
|
-
return;
|
|
565
|
+
return true;
|
|
568
566
|
}
|
|
569
567
|
if (property == "overflow" || property == "overflow-x" || property == "overflow-y") {
|
|
570
568
|
static const char *const names[] = {"visible", "hidden", "scroll", "auto"};
|
|
571
569
|
int index = 0;
|
|
572
570
|
if (parseEnum(value, names, 4, &index)) style->overflow = (Overflow)index;
|
|
573
|
-
return;
|
|
571
|
+
return true;
|
|
574
572
|
}
|
|
575
573
|
if (property == "z-index") {
|
|
576
574
|
float number = 0;
|
|
@@ -578,23 +576,24 @@ void xt_style_apply_declaration(XtStyle *style, const std::string &rawProperty,
|
|
|
578
576
|
style->z_index = (int)number;
|
|
579
577
|
style->has_z_index = true;
|
|
580
578
|
}
|
|
581
|
-
return;
|
|
579
|
+
return true;
|
|
582
580
|
}
|
|
583
581
|
if (property == "float") {
|
|
584
582
|
static const char *const names[] = {"none", "left", "right"};
|
|
585
583
|
int index = 0;
|
|
586
584
|
if (parseEnum(value, names, 3, &index)) style->float_side = (FloatSide)index;
|
|
587
|
-
return;
|
|
585
|
+
return true;
|
|
588
586
|
}
|
|
589
587
|
if (property == "clear") {
|
|
590
588
|
static const char *const names[] = {"none", "left", "right", "both"};
|
|
591
589
|
int index = 0;
|
|
592
590
|
if (parseEnum(value, names, 4, &index)) style->clear = (Clear)index;
|
|
593
|
-
return;
|
|
591
|
+
return true;
|
|
594
592
|
}
|
|
595
|
-
if (xt_style_apply_transition(style, property, value)) return;
|
|
596
|
-
if (xt_style_apply_animation(style, property, value)) return;
|
|
593
|
+
if (xt_style_apply_transition(style, property, value)) return true;
|
|
594
|
+
if (xt_style_apply_animation(style, property, value)) return true;
|
|
597
595
|
|
|
596
|
+
return false;
|
|
598
597
|
}
|
|
599
598
|
|
|
600
599
|
} // namespace xtgui
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#include "css_internal.h"
|
|
19
19
|
#include "style_internal.h"
|
|
20
|
+
#include "warnings.h"
|
|
20
21
|
|
|
21
22
|
namespace xtgui {
|
|
22
23
|
|
|
@@ -169,6 +170,7 @@ bool applyFunction(const std::string &name, const std::vector<std::string> &args
|
|
|
169
170
|
}
|
|
170
171
|
return true;
|
|
171
172
|
}
|
|
173
|
+
xt_warn_unsupported_function("transform", name);
|
|
172
174
|
return false; // perspective/… are not supported yet
|
|
173
175
|
}
|
|
174
176
|
|