xbintsc 0.6.9 → 0.6.12
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/checker/globals.js +2 -1
- package/dist/src/checker/globals.js.map +1 -1
- 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/codegen/generator/state.js +3 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +3 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/compiler.js +1 -1
- package/dist/src/driver/compiler.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/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +2 -0
- package/dist/src/driver/runtime-objects.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/src/extensions/node/crypto/index.js +12 -1
- package/dist/src/extensions/node/crypto/index.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/compile-builtins.test.js +26 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-node.test.js +37 -1
- package/dist/tests/e2e/compile-node.test.js.map +1 -1
- package/dist/tests/e2e/crypto-random.test.d.ts +9 -0
- package/dist/tests/e2e/crypto-random.test.js +63 -0
- package/dist/tests/e2e/crypto-random.test.js.map +1 -0
- package/dist/tests/e2e/date-parse.test.js +27 -1
- package/dist/tests/e2e/date-parse.test.js.map +1 -1
- package/dist/tests/e2e/gui-css-coverage.test.js +1 -1
- package/dist/tests/e2e/gui-dom.test.js +29 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-form.test.d.ts +9 -0
- package/dist/tests/e2e/gui-form.test.js +359 -0
- package/dist/tests/e2e/gui-form.test.js.map +1 -0
- 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-script-import-order.test.js +6 -1
- package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
- package/dist/tests/e2e/gui-style.test.js +82 -0
- package/dist/tests/e2e/gui-style.test.js.map +1 -1
- package/dist/tests/e2e/gui-unsupported.test.d.ts +6 -0
- package/dist/tests/e2e/gui-unsupported.test.js +124 -0
- package/dist/tests/e2e/gui-unsupported.test.js.map +1 -0
- package/dist/tests/e2e/json-parse-errors.test.d.ts +9 -0
- package/dist/tests/e2e/json-parse-errors.test.js +48 -0
- package/dist/tests/e2e/json-parse-errors.test.js.map +1 -0
- package/doc/ai/extensions.md +7 -4
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/zh-CN/extensions.md +6 -3
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/gui/api.md +8 -2
- package/doc/gui/dom.md +81 -4
- package/doc/gui/input.md +74 -3
- package/doc/gui/known-issues.md +12 -5
- package/doc/gui/layout.md +19 -6
- package/doc/gui/rendering.md +16 -9
- package/doc/implemented/node/crypto.md +8 -0
- package/doc/implemented/node/fs.md +1 -1
- package/doc/implemented/stdlib.md +10 -2
- package/doc/zh-CN/gui/api.md +8 -2
- package/doc/zh-CN/gui/dom.md +70 -4
- package/doc/zh-CN/gui/input.md +65 -4
- 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/doc/zh-CN/implemented/node/crypto.md +6 -0
- package/doc/zh-CN/implemented/node/fs.md +1 -1
- package/doc/zh-CN/implemented/stdlib.md +10 -2
- 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_match.cpp +21 -1
- package/runtime/ext_gui/css_selector.cpp +23 -0
- package/runtime/ext_gui/css_sheet.cpp +7 -0
- package/runtime/ext_gui/document.cpp +15 -0
- package/runtime/ext_gui/document_animation.cpp +4 -1
- package/runtime/ext_gui/dom.h +41 -2
- package/runtime/ext_gui/dom_api.cpp +3 -0
- package/runtime/ext_gui/dom_api_document.cpp +28 -0
- package/runtime/ext_gui/dom_api_events.cpp +17 -14
- package/runtime/ext_gui/dom_api_form.cpp +567 -0
- package/runtime/ext_gui/dom_api_internal.h +46 -214
- package/runtime/ext_gui/dom_api_mutation.cpp +1 -1
- package/runtime/ext_gui/dom_api_node.cpp +10 -3
- package/runtime/ext_gui/dom_api_node_read.cpp +1 -1
- package/runtime/ext_gui/dom_api_proto.cpp +45 -0
- package/runtime/ext_gui/dom_api_webgl_methods.h +217 -0
- package/runtime/ext_gui/dom_parse.cpp +118 -1
- package/runtime/ext_gui/effect_values.cpp +28 -7
- package/runtime/ext_gui/form_focus.cpp +293 -0
- package/runtime/ext_gui/form_input.cpp +448 -0
- package/runtime/ext_gui/form_internal.h +30 -0
- package/runtime/ext_gui/form_shared.cpp +126 -0
- package/runtime/ext_gui/form_state.cpp +536 -0
- package/runtime/ext_gui/form_state.h +97 -0
- package/runtime/ext_gui/gradient_values.cpp +25 -5
- package/runtime/ext_gui/gui_engine.h +40 -4
- package/runtime/ext_gui/gui_events.cpp +63 -48
- package/runtime/ext_gui/inline_svg.cpp +3 -0
- package/runtime/ext_gui/layout.cpp +6 -0
- package/runtime/ext_gui/layout.h +4 -0
- package/runtime/ext_gui/layout_flow.cpp +35 -3
- package/runtime/ext_gui/layout_inline.cpp +80 -7
- package/runtime/ext_gui/media_query.cpp +7 -1
- package/runtime/ext_gui/paint.cpp +62 -24
- package/runtime/ext_gui/paint.h +7 -4
- package/runtime/ext_gui/paint_clip.cpp +74 -19
- package/runtime/ext_gui/paint_form.cpp +389 -0
- package/runtime/ext_gui/paint_internal.h +13 -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 +33 -0
- package/runtime/ext_gui/style_text.cpp +11 -0
- package/runtime/ext_gui/style_ua.cpp +42 -0
- package/runtime/ext_gui/style_values.cpp +89 -90
- package/runtime/ext_gui/transform.cpp +2 -0
- package/runtime/ext_gui/warnings.cpp +298 -0
- package/runtime/ext_gui/warnings.h +59 -0
- package/runtime/ext_gui/window.cpp +31 -55
- package/runtime/ext_gui/window_diagnostics.cpp +58 -0
- package/runtime/ext_gui/window_emit.cpp +51 -0
- package/runtime/ext_node/crypto/crypto.c +3 -2
- package/runtime/ext_node/crypto/crypto_hash.h +13 -0
- package/runtime/ext_node/crypto/crypto_random.c +339 -0
- package/runtime/ext_node/fs/async_worker.c +1 -1
- package/runtime/ext_node/fs/fs_ops.c +1 -1
- package/runtime/ext_node/fs/parts/platform.inc +65 -0
- package/runtime/rt.h +27 -0
- package/runtime/xt_crypto.c +132 -0
- package/runtime/xt_random.c +143 -0
- package/runtime/xt_regex/matcher.inc +9 -28
- package/runtime/xt_regex/parser.inc +65 -2
- package/runtime/xt_regex/types.inc +11 -1
- package/runtime/xt_regex.h +6 -2
- package/runtime/xt_stdlib/dispatch.inc +2 -0
- package/runtime/xt_stdlib/math.inc +1 -1
- package/runtime/xt_stdlib2/date.inc +204 -4
- package/runtime/xt_stdlib2/json.inc +4 -546
- package/runtime/xt_stdlib2/json_parse.inc +347 -0
- package/runtime/xt_stdlib2/json_stringify.inc +368 -0
- package/runtime/xt_stdlib2/regexp-match.inc +6 -11
- package/runtime/xt_stdlib2.c +0 -4
- package/runtime/xt_typed_array/elements.inc +6 -1
- package/src/checker/globals.ts +2 -0
- package/src/cli/main.ts +1 -0
- package/src/codegen/generator/state.ts +3 -0
- package/src/codegen/generator/tables.ts +3 -0
- package/src/driver/compiler.ts +1 -1
- package/src/driver/config.ts +1 -0
- package/src/driver/runtime-objects.ts +2 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/node/crypto/index.ts +12 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
#include "style_internal.h"
|
|
16
16
|
#include "style_values_internal.h"
|
|
17
|
+
#include "warnings.h"
|
|
17
18
|
|
|
18
19
|
namespace xtgui {
|
|
19
20
|
|
|
@@ -384,8 +385,22 @@ bool parseRadialGradient(const std::string &body, BackgroundLayer *layer) {
|
|
|
384
385
|
return true;
|
|
385
386
|
}
|
|
386
387
|
|
|
388
|
+
/** Image functions a browser accepts but this engine does not paint. */
|
|
389
|
+
bool isUnsupportedImageFunction(const std::string &name) {
|
|
390
|
+
static const char *const names[] = {
|
|
391
|
+
"-webkit-conic-gradient", "-webkit-cross-fade", "-webkit-image-set",
|
|
392
|
+
"conic-gradient", "cross-fade", "element",
|
|
393
|
+
"image", "image-set", "paint",
|
|
394
|
+
"repeating-conic-gradient",
|
|
395
|
+
};
|
|
396
|
+
for (const char *candidate : names) {
|
|
397
|
+
if (name == candidate) return true;
|
|
398
|
+
}
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
|
|
387
402
|
/** Parse one layer, appending it when it is a supported gradient or image. */
|
|
388
|
-
bool parseLayer(const std::string &part, BackgroundLayer *layer) {
|
|
403
|
+
bool parseLayer(const std::string &part, BackgroundLayer *layer, const char *property) {
|
|
389
404
|
std::string body;
|
|
390
405
|
/* The repeating prefix is checked first: a plain substring search for
|
|
391
406
|
* `linear-gradient(` would also match inside `repeating-linear-gradient(`. */
|
|
@@ -410,19 +425,24 @@ bool parseLayer(const std::string &part, BackgroundLayer *layer) {
|
|
|
410
425
|
layer->image_src = source;
|
|
411
426
|
return true;
|
|
412
427
|
}
|
|
428
|
+
const size_t open = part.find('(');
|
|
429
|
+
if (open != std::string::npos) {
|
|
430
|
+
const std::string name = xt_css_lower(xt_css_trim(part.substr(0, open)));
|
|
431
|
+
if (isUnsupportedImageFunction(name)) xt_warn_unsupported_function(property, name);
|
|
432
|
+
}
|
|
413
433
|
return false;
|
|
414
434
|
}
|
|
415
435
|
|
|
416
436
|
/** Parse the layer list. `allowColor` is true for the `background` shorthand. */
|
|
417
437
|
bool parseLayers(const std::string &value, std::vector<BackgroundLayer> *layers, Color *color,
|
|
418
|
-
bool *hasColor, bool allowColor) {
|
|
438
|
+
bool *hasColor, bool allowColor, const char *property) {
|
|
419
439
|
layers->clear();
|
|
420
440
|
std::string text = xt_css_trim(value);
|
|
421
441
|
std::string lower = xt_css_lower(text);
|
|
422
442
|
if (lower == "none") return true;
|
|
423
443
|
for (const std::string &part : splitCommas(text)) {
|
|
424
444
|
BackgroundLayer layer;
|
|
425
|
-
if (parseLayer(part, &layer)) {
|
|
445
|
+
if (parseLayer(part, &layer, property)) {
|
|
426
446
|
layers->push_back(layer);
|
|
427
447
|
/* `background: linear-gradient(...) #fff` mixes the final colour with the
|
|
428
448
|
* image layer; the gradient itself is one token, so a colour scan cannot
|
|
@@ -460,7 +480,7 @@ void xt_style_apply_background_image(XtStyle *style, const std::string &value) {
|
|
|
460
480
|
Color color;
|
|
461
481
|
bool hasColor = false;
|
|
462
482
|
std::vector<BackgroundLayer> layers;
|
|
463
|
-
parseLayers(value, &layers, &color, &hasColor, false);
|
|
483
|
+
parseLayers(value, &layers, &color, &hasColor, false, "background-image");
|
|
464
484
|
style->background_layers = std::move(layers);
|
|
465
485
|
}
|
|
466
486
|
|
|
@@ -472,7 +492,7 @@ void xt_style_apply_background(XtStyle *style, const std::string &value) {
|
|
|
472
492
|
Color color;
|
|
473
493
|
bool hasColor = false;
|
|
474
494
|
std::vector<BackgroundLayer> layers;
|
|
475
|
-
parseLayers(value, &layers, &color, &hasColor, true);
|
|
495
|
+
parseLayers(value, &layers, &color, &hasColor, true, "background");
|
|
476
496
|
style->background_layers = std::move(layers);
|
|
477
497
|
style->background_sizes.clear();
|
|
478
498
|
if (hasColor) {
|
|
@@ -255,11 +255,14 @@ xt_value xt_gui_node_handle(XtGuiWindow *win, const xtgui::Node *node);
|
|
|
255
255
|
void xt_gui_node_handle_forget(XtGuiWindow *win, const xtgui::Node *node);
|
|
256
256
|
/** Drop every cached handle/listener and bump the document generation. */
|
|
257
257
|
void xt_gui_handles_reset(XtGuiWindow *win);
|
|
258
|
-
/** Deliver `type` to element listeners along the propagation path.
|
|
259
|
-
|
|
258
|
+
/** Deliver `type` to element listeners along the propagation path. Returns
|
|
259
|
+
* true when a listener called `preventDefault()` (the caller then skips the
|
|
260
|
+
* default action). */
|
|
261
|
+
bool xt_gui_emit_dom_event(XtGuiWindow *win, const char *type, const xtgui::Node *target,
|
|
260
262
|
xt_value legacy_payload);
|
|
261
|
-
/** Synthesise a DOM event whose target is `target` (used by element.click()).
|
|
262
|
-
|
|
263
|
+
/** Synthesise a DOM event whose target is `target` (used by element.click()).
|
|
264
|
+
* Returns true when a listener called `preventDefault()`. */
|
|
265
|
+
bool xt_gui_dispatch_to_node(XtGuiWindow *win, const xtgui::Node *target, const char *type);
|
|
263
266
|
/** Apply any pending DOM mutation (restyle/relayout) before a synchronous read. */
|
|
264
267
|
void xt_gui_flush_dom(XtGuiWindow *win);
|
|
265
268
|
/** Run every registered `<script data-xt-id>` body found in the document, in
|
|
@@ -311,6 +314,39 @@ void xt_gui_dispatch_pointer(XtGuiWindow *win, const char *type, float x, float
|
|
|
311
314
|
void xt_gui_dispatch_wheel(XtGuiWindow *win, float x, float y, float delta_x, float delta_y);
|
|
312
315
|
/** Synthesise a key event (`keydown`/`keyup`). */
|
|
313
316
|
void xt_gui_dispatch_key(XtGuiWindow *win, const char *type, const char *key, const char *code);
|
|
317
|
+
/** Synthesise a key event with explicit modifier/repeat flags. */
|
|
318
|
+
void xt_gui_dispatch_key_with_modifiers(XtGuiWindow *win, const char *type, const char *key,
|
|
319
|
+
const char *code, bool repeat, bool ctrl, bool shift,
|
|
320
|
+
bool alt, bool meta);
|
|
321
|
+
|
|
322
|
+
/* -- form controls (`form_input.cpp`) ------------------------------------ */
|
|
323
|
+
|
|
324
|
+
/** Focus `node` (or clear focus when null). Updates the control's focused flag,
|
|
325
|
+
* starts/stops SDL text input and repaints. Returns true when the focus moved. */
|
|
326
|
+
bool xt_gui_set_focus(XtGuiWindow *win, xtgui::Node *node);
|
|
327
|
+
/** Commit `text` as typed input to the focused editable control, dispatching
|
|
328
|
+
* `keypress` then `input`. */
|
|
329
|
+
void xt_gui_text_input(XtGuiWindow *win, const char *text);
|
|
330
|
+
/** IME composing text update (`SDL_EVENT_TEXT_EDITING`): shows `text` at the
|
|
331
|
+
* caret until the commit. */
|
|
332
|
+
void xt_gui_text_editing(XtGuiWindow *win, const char *text, int start, int length);
|
|
333
|
+
/** Synthesise a composition event (`compositionstart`/`update`/`end`). */
|
|
334
|
+
void xt_gui_composition_event(XtGuiWindow *win, const char *type, const char *data);
|
|
335
|
+
/** Default keydown action for the focused editable control (text editing,
|
|
336
|
+
* clipboard, caret movement). Called after the DOM listeners did not cancel. */
|
|
337
|
+
void xt_gui_form_key_down(XtGuiWindow *win, xt_value payload);
|
|
338
|
+
/** Pointer default action (focus/caret placement, checkbox toggle, range drag). */
|
|
339
|
+
void xt_gui_form_pointer(XtGuiWindow *win, const char *type, xtgui::Node *node, float x, float y);
|
|
340
|
+
/** Run a control's activation behaviour (checkbox/radio toggle, select cycle). */
|
|
341
|
+
void xt_gui_form_activate(XtGuiWindow *win, xtgui::Node *node);
|
|
342
|
+
/** Move focus to the next (`forward`) / previous tabbable element. */
|
|
343
|
+
void xt_gui_focus_step(XtGuiWindow *win, bool forward);
|
|
344
|
+
/** Fire `submit` on a `<form>` (no navigation); `submitter` may be null. */
|
|
345
|
+
void xt_gui_form_submit_request(XtGuiWindow *win, xtgui::Node *form, xtgui::Node *submitter);
|
|
346
|
+
/** Reset every control in a `<form>` to its default value/checked state. */
|
|
347
|
+
void xt_gui_form_reset(XtGuiWindow *win, xtgui::Node *form);
|
|
348
|
+
/** Set a control's caret from a viewport x coordinate (click positioning). */
|
|
349
|
+
void xt_gui_form_focus_at(XtGuiWindow *win, xtgui::Node *node, float x);
|
|
314
350
|
/** Translate one physical key (SDL scancode/keycode + modifiers) to the browser
|
|
315
351
|
* `key`/`code` names and dispatch it to the DOM and window listeners. */
|
|
316
352
|
void xt_gui_dispatch_physical_key(XtGuiWindow *win, const char *type, int scancode, int keycode,
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include "gui_keymap.h"
|
|
8
8
|
#include "listener_options.h"
|
|
9
9
|
|
|
10
|
+
#include "form_state.h"
|
|
10
11
|
#include "paint.h"
|
|
11
12
|
#include "perf.h"
|
|
12
13
|
|
|
@@ -18,48 +19,6 @@
|
|
|
18
19
|
|
|
19
20
|
using namespace guidev;
|
|
20
21
|
|
|
21
|
-
/* -- window events -------------------------------------------------------- */
|
|
22
|
-
|
|
23
|
-
void xt_gui_emit(XtGuiWindow *win, const char *event) {
|
|
24
|
-
xt_gui_emit_payload(win, event, XT_UNDEFINED);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Drop one window listener (by identity: type + fn + capture). */
|
|
28
|
-
static void remove_window_listener(XtGuiWindow *win, const XtGuiWindowListener &listener) {
|
|
29
|
-
std::vector<XtGuiWindowListener> &listeners = win->window_listeners;
|
|
30
|
-
for (auto it = listeners.begin(); it != listeners.end(); ++it) {
|
|
31
|
-
if (it->type == listener.type && it->capture == listener.capture &&
|
|
32
|
-
xt_truthy(xt_seq(it->fn, listener.fn))) {
|
|
33
|
-
listeners.erase(it);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
void xt_gui_emit_payload(XtGuiWindow *win, const char *event, xt_value payload) {
|
|
40
|
-
if (win == NULL || !XT_IS_OBJECT(win->object)) return;
|
|
41
|
-
xt_value args[1];
|
|
42
|
-
int32_t count = 0;
|
|
43
|
-
if (!XT_IS_UNDEFINED(payload)) {
|
|
44
|
-
args[0] = payload;
|
|
45
|
-
count = 1;
|
|
46
|
-
}
|
|
47
|
-
/* Snapshot the list: a handler may register or remove listeners while it
|
|
48
|
-
* runs, and the DOM runs the batch as it stood when dispatch started. */
|
|
49
|
-
std::vector<XtGuiWindowListener> snapshot = win->window_listeners;
|
|
50
|
-
for (const XtGuiWindowListener &listener : snapshot) {
|
|
51
|
-
if (listener.type != event) continue;
|
|
52
|
-
/* `{ signal }` removes the listener at abort time (checked here, so no
|
|
53
|
-
* callback plumbing is needed inside the signal). */
|
|
54
|
-
if (xt_gui_signal_aborted(listener.signal)) {
|
|
55
|
-
remove_window_listener(win, listener);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (listener.once) remove_window_listener(win, listener);
|
|
59
|
-
if (XT_IS_FUNCTION(listener.fn)) xt_call_with_this(listener.fn, win->object, count, args);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
22
|
void xt_gui_flush_dom(XtGuiWindow *win) {
|
|
64
23
|
if (win == NULL || win->document == nullptr) return;
|
|
65
24
|
bool mutated = win->struct_dirty != 0;
|
|
@@ -187,27 +146,45 @@ void xt_gui_dispatch_pointer(XtGuiWindow *win, const char *type, float x, float
|
|
|
187
146
|
int clicks) {
|
|
188
147
|
if (win == NULL || !win->open) return;
|
|
189
148
|
const xtgui::Node *node = xt_gui_hit_node(win, x, y);
|
|
149
|
+
xtgui::Node *target = const_cast<xtgui::Node *>(node);
|
|
190
150
|
xt_gui_update_hover(win, node);
|
|
151
|
+
bool prevented = false;
|
|
191
152
|
if (win->document != nullptr) {
|
|
192
153
|
if (strcmp(type, "mousedown") == 0) {
|
|
193
|
-
if (
|
|
194
|
-
win
|
|
195
|
-
|
|
154
|
+
if (target != nullptr && xtgui::xt_form_is_focusable(target)) {
|
|
155
|
+
xt_gui_form_pointer(win, "mousedown", target, x, y);
|
|
156
|
+
} else if (target != nullptr && xtgui::xt_form_is_control(target)) {
|
|
157
|
+
/* A disabled/hidden control is not focusable and does not take focus. */
|
|
158
|
+
xt_gui_set_focus(win, nullptr);
|
|
159
|
+
} else {
|
|
160
|
+
xt_gui_set_focus(win, target);
|
|
196
161
|
}
|
|
197
162
|
if (win->document->setActive(node)) {
|
|
198
163
|
win->geometry.dirty = 1;
|
|
199
164
|
win->present_dirty = 1;
|
|
200
165
|
}
|
|
201
166
|
} else if (strcmp(type, "mouseup") == 0) {
|
|
167
|
+
const xtgui::Node *active = win->document->active();
|
|
168
|
+
if (active != nullptr && active->form && active->form->dragging) {
|
|
169
|
+
xt_gui_form_pointer(win, "mouseup", const_cast<xtgui::Node *>(active), x, y);
|
|
170
|
+
}
|
|
202
171
|
if (win->document->setActive(nullptr)) {
|
|
203
172
|
win->geometry.dirty = 1;
|
|
204
173
|
win->present_dirty = 1;
|
|
205
174
|
}
|
|
175
|
+
} else if (strcmp(type, "mousemove") == 0) {
|
|
176
|
+
const xtgui::Node *active = win->document->active();
|
|
177
|
+
if (active != nullptr && active->form && active->form->dragging) {
|
|
178
|
+
xt_gui_form_pointer(win, "mousemove", const_cast<xtgui::Node *>(active), x, y);
|
|
179
|
+
}
|
|
206
180
|
}
|
|
207
181
|
}
|
|
208
182
|
xt_value payload = xt_gui_pointer_payload(type, win, x, y, button, clicks, node);
|
|
209
|
-
if (node != nullptr) xt_gui_emit_dom_event(win, type, node, payload);
|
|
183
|
+
if (node != nullptr) prevented = xt_gui_emit_dom_event(win, type, node, payload);
|
|
210
184
|
xt_gui_emit_payload(win, type, payload);
|
|
185
|
+
if (!prevented && node != nullptr && strcmp(type, "click") == 0) {
|
|
186
|
+
xt_gui_form_pointer(win, "click", target, x, y);
|
|
187
|
+
}
|
|
211
188
|
}
|
|
212
189
|
|
|
213
190
|
void xt_gui_dispatch_wheel(XtGuiWindow *win, float x, float y, float delta_x, float delta_y) {
|
|
@@ -262,12 +239,26 @@ static const xtgui::Node *xt_gui_key_target(XtGuiWindow *win) {
|
|
|
262
239
|
}
|
|
263
240
|
|
|
264
241
|
/** Deliver one fully built keyboard payload to the DOM (bubbling from the
|
|
265
|
-
* focused element / body to `document`) and then to `window` listeners.
|
|
242
|
+
* focused element / body to `document`) and then to `window` listeners. When
|
|
243
|
+
* the DOM did not cancel a `keydown`, run the focused control's editing
|
|
244
|
+
* default action. */
|
|
266
245
|
static void xt_gui_dispatch_key_payload(XtGuiWindow *win, const char *type, xt_value payload) {
|
|
267
246
|
if (win == NULL || !win->open) return;
|
|
268
247
|
const xtgui::Node *node = xt_gui_key_target(win);
|
|
269
|
-
|
|
248
|
+
bool prevented = false;
|
|
249
|
+
if (node != nullptr) prevented = xt_gui_emit_dom_event(win, type, node, payload);
|
|
270
250
|
xt_gui_emit_payload(win, type, payload);
|
|
251
|
+
if (!prevented && strcmp(type, "keydown") == 0) {
|
|
252
|
+
xt_gui_form_key_down(win, payload);
|
|
253
|
+
/* Tab is the one editing command that works from any element, not only a
|
|
254
|
+
* focused text field: move focus along the tabbable order. */
|
|
255
|
+
xt_value key = xt_object_get_cstr(payload, "key");
|
|
256
|
+
if (XT_IS_STRING(key) && strcmp(xt_string_data(key), "Tab") == 0) {
|
|
257
|
+
bool shift = xt_truthy(xt_object_get_cstr(payload, "shiftKey")) ||
|
|
258
|
+
xt_truthy(xt_object_get_cstr(payload, "shift"));
|
|
259
|
+
xt_gui_focus_step(win, !shift);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
271
262
|
}
|
|
272
263
|
|
|
273
264
|
void xt_gui_dispatch_key(XtGuiWindow *win, const char *type, const char *key, const char *code) {
|
|
@@ -275,6 +266,13 @@ void xt_gui_dispatch_key(XtGuiWindow *win, const char *type, const char *key, co
|
|
|
275
266
|
xt_gui_dispatch_key_payload(win, type, payload);
|
|
276
267
|
}
|
|
277
268
|
|
|
269
|
+
void xt_gui_dispatch_key_with_modifiers(XtGuiWindow *win, const char *type, const char *key,
|
|
270
|
+
const char *code, bool repeat, bool ctrl, bool shift,
|
|
271
|
+
bool alt, bool meta) {
|
|
272
|
+
xt_value payload = xt_gui_key_payload(type, key, code, repeat, ctrl, shift, alt, meta);
|
|
273
|
+
xt_gui_dispatch_key_payload(win, type, payload);
|
|
274
|
+
}
|
|
275
|
+
|
|
278
276
|
void xt_gui_dispatch_physical_key(XtGuiWindow *win, const char *type, int scancode, int keycode,
|
|
279
277
|
bool repeat, bool ctrl, bool shift, bool alt, bool meta,
|
|
280
278
|
bool caps_lock) {
|
|
@@ -284,6 +282,10 @@ void xt_gui_dispatch_physical_key(XtGuiWindow *win, const char *type, int scanco
|
|
|
284
282
|
caps_lock, &key, &code);
|
|
285
283
|
xt_value payload = xt_gui_key_payload(type, key.c_str(), code.c_str(), repeat, ctrl, shift, alt,
|
|
286
284
|
meta);
|
|
285
|
+
/* Mark the payload so the editing default action knows the produced text will
|
|
286
|
+
* arrive separately as `SDL_EVENT_TEXT_INPUT` (inserting the US `key` here too
|
|
287
|
+
* would double every character on an IME or non-US layout). */
|
|
288
|
+
xt_object_set(payload, xt_string_from_cstr("__xt_gui_physical"), XT_TRUE);
|
|
287
289
|
xt_gui_dispatch_key_payload(win, type, payload);
|
|
288
290
|
}
|
|
289
291
|
|
|
@@ -327,6 +329,19 @@ void handle_event(const SDL_Event *event) {
|
|
|
327
329
|
return;
|
|
328
330
|
}
|
|
329
331
|
|
|
332
|
+
if (event->type == SDL_EVENT_TEXT_INPUT) {
|
|
333
|
+
XtGuiWindow *win = xt_gui_find_by_window_id(event->text.windowID);
|
|
334
|
+
if (win == NULL || !win->open) return;
|
|
335
|
+
xt_gui_text_input(win, event->text.text);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (event->type == SDL_EVENT_TEXT_EDITING) {
|
|
339
|
+
XtGuiWindow *win = xt_gui_find_by_window_id(event->edit.windowID);
|
|
340
|
+
if (win == NULL || !win->open) return;
|
|
341
|
+
xt_gui_text_editing(win, event->edit.text, event->edit.start, event->edit.length);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
330
345
|
if (event->type == SDL_EVENT_MOUSE_MOTION) {
|
|
331
346
|
XtGuiWindow *win = xt_gui_find_by_window_id(event->motion.windowID);
|
|
332
347
|
xt_gui_dispatch_pointer(win, "mousemove", event->motion.x, event->motion.y, -1, 0);
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
#include "inline_svg.h"
|
|
6
6
|
|
|
7
|
+
#include "warnings.h"
|
|
8
|
+
|
|
7
9
|
#include <cctype>
|
|
8
10
|
#include <cstdio>
|
|
9
11
|
#include <string>
|
|
@@ -239,6 +241,7 @@ void serializeStyleText(const Node *node, const std::unordered_map<const Node *,
|
|
|
239
241
|
void serializeNode(const Node *node, const std::unordered_map<const Node *, XtStyle> *styles,
|
|
240
242
|
std::string *out) {
|
|
241
243
|
if (node == nullptr || !node->isElement()) return;
|
|
244
|
+
xt_warn_unsupported_svg_element(node->tag);
|
|
242
245
|
const XtStyle *computed = nullptr;
|
|
243
246
|
if (styles != nullptr) {
|
|
244
247
|
auto found = styles->find(node);
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
#include "image.h"
|
|
24
24
|
#include "inline_svg.h"
|
|
25
25
|
#include "perf.h"
|
|
26
|
+
#include "form_state.h"
|
|
26
27
|
#include "style_internal.h"
|
|
27
28
|
|
|
28
29
|
namespace xtgui {
|
|
@@ -128,7 +129,12 @@ std::unique_ptr<LayoutBox> buildBoxTree(const Node *node,
|
|
|
128
129
|
}
|
|
129
130
|
if (box->intrinsic_width <= 0.0f) box->intrinsic_width = 300.0f;
|
|
130
131
|
if (box->intrinsic_height <= 0.0f) box->intrinsic_height = 150.0f;
|
|
132
|
+
} else if (node->isElement() && xt_form_is_control(node)) {
|
|
133
|
+
/* A form control is a leaf: its `<option>`/text children are the model, not
|
|
134
|
+
* laid-out boxes (the value is painted from `Node::form`). */
|
|
135
|
+
box->is_control = true;
|
|
131
136
|
}
|
|
137
|
+
if (box->is_control) return box;
|
|
132
138
|
if (box->is_inline_svg) return box;
|
|
133
139
|
|
|
134
140
|
/* `::before` / `::after` boxes are emitted around the DOM children. Only a
|
package/runtime/ext_gui/layout.h
CHANGED
|
@@ -89,6 +89,10 @@ struct LayoutBox {
|
|
|
89
89
|
bool is_canvas = false;
|
|
90
90
|
uint64_t canvas_id = 0;
|
|
91
91
|
|
|
92
|
+
/* `<input>` / `<textarea>` / `<select>`: a leaf box whose content is painted
|
|
93
|
+
* from the node's `FormState` (value, caret, decorations). */
|
|
94
|
+
bool is_control = false;
|
|
95
|
+
|
|
92
96
|
/* Inline `<svg>`: a replaced element whose pixels are the serialized subtree
|
|
93
97
|
* (`svg_markup`), rasterised like an SVG file at the drawn device size. The
|
|
94
98
|
* normal box walk does not descend into its children — they are vector art,
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
#include "layout_flow_internal.h"
|
|
10
10
|
|
|
11
|
+
#include "form_state.h"
|
|
12
|
+
|
|
11
13
|
namespace xtgui {
|
|
12
14
|
namespace layout_flow_detail {
|
|
13
15
|
|
|
@@ -44,6 +46,13 @@ float Layouter::verticalEdges(const LayoutBox *box) const {
|
|
|
44
46
|
float Layouter::preferredContentWidth(const LayoutBox *box, float available) const {
|
|
45
47
|
const XtStyle &style = *box->style;
|
|
46
48
|
if (!isAuto(style.width)) return px(style.width, available, style.font_size, 0.0f);
|
|
49
|
+
if (box->is_control) {
|
|
50
|
+
float width = 0.0f;
|
|
51
|
+
float height = 0.0f;
|
|
52
|
+
xt_form_intrinsic_size(box->node, style, &width, &height);
|
|
53
|
+
(void)height;
|
|
54
|
+
if (width > 0.0f) return width;
|
|
55
|
+
}
|
|
47
56
|
if ((box->is_image || box->is_canvas || box->is_inline_svg) && box->intrinsic_width > 0)
|
|
48
57
|
return box->intrinsic_width;
|
|
49
58
|
if (box->is_text) {
|
|
@@ -322,7 +331,20 @@ float Layouter::layoutBlock(LayoutBox *box, float x, float y, float availableWid
|
|
|
322
331
|
}
|
|
323
332
|
|
|
324
333
|
float contentHeight;
|
|
325
|
-
if (
|
|
334
|
+
if (box->is_control) {
|
|
335
|
+
/* Controls are leaves with an intrinsic content height (a line, a textarea's
|
|
336
|
+
* rows, 13px for a checkbox, …); their children are not boxes. */
|
|
337
|
+
float intrinsic_width = 0.0f;
|
|
338
|
+
float intrinsic_height = 0.0f;
|
|
339
|
+
xt_form_intrinsic_size(box->node, style, &intrinsic_width, &intrinsic_height);
|
|
340
|
+
(void)intrinsic_width;
|
|
341
|
+
contentHeight = forcedContentHeight >= 0
|
|
342
|
+
? forcedContentHeight
|
|
343
|
+
: (definiteHeight >= 0 ? definiteHeight : intrinsic_height);
|
|
344
|
+
contentHeight = clampSize(contentHeight, style.min_height, style.max_height,
|
|
345
|
+
availableHeight < 0 ? contentHeight : availableHeight, em);
|
|
346
|
+
if (contentHeight < 0) contentHeight = 0;
|
|
347
|
+
} else if (forcedContentHeight >= 0) {
|
|
326
348
|
layoutChildren(box, contentWidth, availableHeight, forcedContentHeight);
|
|
327
349
|
contentHeight = forcedContentHeight;
|
|
328
350
|
} else {
|
|
@@ -390,6 +412,16 @@ float Layouter::layoutChildren(LayoutBox *block, float contentWidth, float avail
|
|
|
390
412
|
if (block->style->display == Display::Grid)
|
|
391
413
|
return layoutGrid(block, contentWidth, definiteHeight);
|
|
392
414
|
|
|
415
|
+
/* A percentage height on a child resolves against this block's *content*
|
|
416
|
+
* height. `definiteHeight` is that height when it is known (an explicit
|
|
417
|
+
* `height`, a clamp()/aspect-ratio result, or a flex/grid stretch); a box
|
|
418
|
+
* whose height came from `clamp()` must hand that value down, because the
|
|
419
|
+
* `availableHeight` it received is only the containing block's height from
|
|
420
|
+
* further up (or -1 when that chain is indefinite). Without this, a
|
|
421
|
+
* `height: 100%` portrait inside a sized frame was treated as `auto` and
|
|
422
|
+
* collapsed to its zero-height absolutely positioned artwork. */
|
|
423
|
+
float childHeight = definiteHeight >= 0 ? definiteHeight : availableHeight;
|
|
424
|
+
|
|
393
425
|
float y = block->content_y;
|
|
394
426
|
float startY = y;
|
|
395
427
|
/* The bottom margin of the last in-flow block, waiting to collapse with the
|
|
@@ -458,7 +490,7 @@ float Layouter::layoutChildren(LayoutBox *block, float contentWidth, float avail
|
|
|
458
490
|
: block->content_x + contentWidth - outerWidth;
|
|
459
491
|
setContainingBlock(child.get(), containingBlockAncestor(block));
|
|
460
492
|
float height =
|
|
461
|
-
layoutBlock(child.get(), floatX, y, contentWidth,
|
|
493
|
+
layoutBlock(child.get(), floatX, y, contentWidth, childHeight, contentW);
|
|
462
494
|
ActiveFloat entry;
|
|
463
495
|
entry.left = childStyle->float_side == FloatSide::Left;
|
|
464
496
|
entry.x = child->x;
|
|
@@ -489,7 +521,7 @@ float Layouter::layoutChildren(LayoutBox *block, float contentWidth, float avail
|
|
|
489
521
|
}
|
|
490
522
|
y = desired;
|
|
491
523
|
setContainingBlock(child.get(), containingBlockAncestor(block));
|
|
492
|
-
y += layoutBlock(child.get(), block->content_x, y, contentWidth,
|
|
524
|
+
y += layoutBlock(child.get(), block->content_x, y, contentWidth, childHeight);
|
|
493
525
|
pending = child->margin_bottom;
|
|
494
526
|
hasBlock = true;
|
|
495
527
|
} else {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
#include "layout_flow_internal.h"
|
|
10
10
|
|
|
11
|
+
#include <utility>
|
|
12
|
+
|
|
11
13
|
namespace xtgui {
|
|
12
14
|
namespace layout_flow_detail {
|
|
13
15
|
|
|
@@ -24,12 +26,23 @@ void Layouter::flattenInline(LayoutBox *box, float contentWidth,
|
|
|
24
26
|
const std::string &text = box->text;
|
|
25
27
|
size_t i = 0;
|
|
26
28
|
while (i < text.size()) {
|
|
27
|
-
if (text[i] == '\n') {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (text[i] == '\n' || text[i] == '\r') {
|
|
30
|
+
/* `nowrap` collapses a source newline to a space; the other modes keep
|
|
31
|
+
* the engine's existing forced break (notably `pre`, which must). */
|
|
32
|
+
bool preserveNewline = style.white_space != WhiteSpace::NoWrap;
|
|
33
|
+
InlineItem item;
|
|
34
|
+
item.box = box;
|
|
35
|
+
item.style = &style;
|
|
36
|
+
if (preserveNewline) {
|
|
37
|
+
item.force_break = true;
|
|
38
|
+
} else {
|
|
39
|
+
item.text = " ";
|
|
40
|
+
item.is_space = true;
|
|
41
|
+
item.width = textWidth(" ", style);
|
|
42
|
+
item.height = height;
|
|
43
|
+
item.ascent = ascent;
|
|
44
|
+
}
|
|
45
|
+
out.push_back(std::move(item));
|
|
33
46
|
i++;
|
|
34
47
|
continue;
|
|
35
48
|
}
|
|
@@ -143,12 +156,34 @@ float Layouter::layoutInlineRun(LayoutBox *container, const std::vector<LayoutBo
|
|
|
143
156
|
for (LayoutBox *box : run) computeInlineGeometry(box);
|
|
144
157
|
return height;
|
|
145
158
|
}
|
|
159
|
+
/* `nowrap`/`pre` keep the run on one line (a preserved newline still breaks
|
|
160
|
+
* it); without that, `text-overflow: ellipsis` would never see an overflowing
|
|
161
|
+
* line on ordinary prose. */
|
|
162
|
+
const bool wrap = containerStyle.white_space == WhiteSpace::Normal ||
|
|
163
|
+
containerStyle.white_space == WhiteSpace::PreWrap ||
|
|
164
|
+
containerStyle.white_space == WhiteSpace::PreLine;
|
|
165
|
+
const bool ellipsis = containerStyle.text_overflow == TextOverflow::Ellipsis &&
|
|
166
|
+
containerStyle.overflow != Overflow::Visible;
|
|
146
167
|
float cursorY = y;
|
|
147
168
|
std::vector<InlineItem *> line;
|
|
148
169
|
float lineWidth = 0;
|
|
149
170
|
float lineAscent = 0;
|
|
150
171
|
float lineDescent = 0;
|
|
151
172
|
|
|
173
|
+
/* Byte length of the longest UTF-8 prefix of `text` that fits in `budget`
|
|
174
|
+
* when measured with `style`, without splitting a multi-byte code point. */
|
|
175
|
+
auto fittingPrefix = [&](const std::string &text, const XtStyle &style, float budget) {
|
|
176
|
+
size_t best = 0;
|
|
177
|
+
for (size_t i = 0; i < text.size();) {
|
|
178
|
+
size_t next = i + 1;
|
|
179
|
+
while (next < text.size() && ((unsigned char)text[next] & 0xC0) == 0x80) next++;
|
|
180
|
+
if (textWidth(text.substr(0, next), style) > budget + 0.001f) break;
|
|
181
|
+
best = next;
|
|
182
|
+
i = next;
|
|
183
|
+
}
|
|
184
|
+
return best;
|
|
185
|
+
};
|
|
186
|
+
|
|
152
187
|
/* Horizontal band left free by the floats overlapping [top, top + height). */
|
|
153
188
|
auto band = [&](float top, float height, float *x0, float *x1) {
|
|
154
189
|
*x0 = container->content_x;
|
|
@@ -171,6 +206,44 @@ float Layouter::layoutInlineRun(LayoutBox *container, const std::vector<LayoutBo
|
|
|
171
206
|
float x1 = 0;
|
|
172
207
|
band(cursorY, height, &x0, &x1);
|
|
173
208
|
float available = x1 - x0;
|
|
209
|
+
if (ellipsis && lineWidth > available + 0.001f) {
|
|
210
|
+
/* Replace the part of the line that does not fit with one ellipsis. The
|
|
211
|
+
* ellipsis gets the style of the run it terminates, so a smaller/larger
|
|
212
|
+
* inline span keeps its own metrics. */
|
|
213
|
+
const std::string dots = "\xE2\x80\xA6"; // U+2026 HORIZONTAL ELLIPSIS
|
|
214
|
+
float dotsWidth = textWidth(dots, containerStyle);
|
|
215
|
+
float budget = available - dotsWidth;
|
|
216
|
+
if (budget < 0.0f) budget = 0.0f;
|
|
217
|
+
std::vector<InlineItem *> kept;
|
|
218
|
+
float used = 0.0f;
|
|
219
|
+
for (InlineItem *item : line) {
|
|
220
|
+
if (used + item->width <= budget + 0.001f) {
|
|
221
|
+
kept.push_back(item);
|
|
222
|
+
used += item->width;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (item->atomic) {
|
|
226
|
+
/* An atomic inline box cannot carry the ellipsis itself; append it to
|
|
227
|
+
* the last text run when one still fits, otherwise drop the box. */
|
|
228
|
+
if (!kept.empty() && !kept.back()->atomic && !kept.back()->is_space) {
|
|
229
|
+
kept.back()->text += dots;
|
|
230
|
+
kept.back()->width += dotsWidth;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
size_t prefix = fittingPrefix(item->text, *item->style, budget - used);
|
|
235
|
+
std::string text = item->text.substr(0, prefix);
|
|
236
|
+
while (!text.empty() && (text.back() == ' ' || text.back() == '\t')) text.pop_back();
|
|
237
|
+
item->text = text + dots;
|
|
238
|
+
item->width = textWidth(text, *item->style) + dotsWidth;
|
|
239
|
+
kept.push_back(item);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
line = std::move(kept);
|
|
243
|
+
lineWidth = 0.0f;
|
|
244
|
+
for (InlineItem *item : line) lineWidth += item->width;
|
|
245
|
+
if (line.empty()) return;
|
|
246
|
+
}
|
|
174
247
|
float x = x0;
|
|
175
248
|
if (containerStyle.text_align == TextAlign::Center) {
|
|
176
249
|
x += (available - lineWidth) / 2.0f;
|
|
@@ -213,7 +286,7 @@ float Layouter::layoutInlineRun(LayoutBox *container, const std::vector<LayoutBo
|
|
|
213
286
|
float x1 = 0;
|
|
214
287
|
band(cursorY, pendingHeight, &x0, &x1);
|
|
215
288
|
float available = x1 - x0;
|
|
216
|
-
if (lineWidth + item.width > available && !line.empty()) finalize();
|
|
289
|
+
if (wrap && lineWidth + item.width > available && !line.empty()) finalize();
|
|
217
290
|
if (item.is_space && line.empty()) continue;
|
|
218
291
|
line.push_back(&item);
|
|
219
292
|
lineWidth += item.width;
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
#include "css_internal.h"
|
|
11
11
|
|
|
12
|
+
#include "warnings.h"
|
|
13
|
+
|
|
12
14
|
#include <cmath>
|
|
13
15
|
#include <string>
|
|
14
16
|
#include <vector>
|
|
@@ -113,7 +115,10 @@ bool evaluateRange(const std::string &inner, float vw, float vh, bool *matched)
|
|
|
113
115
|
float actual = 0.0f;
|
|
114
116
|
if (feature == "width") actual = vw;
|
|
115
117
|
else if (feature == "height") actual = vh;
|
|
116
|
-
else
|
|
118
|
+
else {
|
|
119
|
+
xt_warn_unsupported_media_feature(feature);
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
117
122
|
float value = 0.0f;
|
|
118
123
|
if (!mediaLength(valueText, vw, vh, &value)) return false;
|
|
119
124
|
if (flipped) {
|
|
@@ -159,6 +164,7 @@ bool evaluateFeature(const std::string &inner, float vw, float vh) {
|
|
|
159
164
|
if (name == "prefers-contrast") return value == "no-preference";
|
|
160
165
|
if (name == "scripting") return value == "enabled";
|
|
161
166
|
if (name == "display-mode") return value == "browser";
|
|
167
|
+
xt_warn_unsupported_media_feature(name);
|
|
162
168
|
return false;
|
|
163
169
|
}
|
|
164
170
|
|