@geastack/engine 0.1.6 → 0.1.8
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/README.md +70 -0
- package/canvas.cpp +105 -48
- package/css/declarative.h +6 -0
- package/css/engine.h +20 -0
- package/image_store.cpp +136 -33
- package/package.json +4 -3
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +77 -62
- package/ui/core.cpp +26 -3
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +369 -0
- package/ui/document.cpp +11 -0
- package/ui/image_node.cpp +25 -24
- package/ui/input.cpp +46 -26
- package/ui/input_render.cpp +31 -27
- package/ui/internal.h +22 -0
- package/ui/layout.cpp +899 -613
- package/ui/layout_snapshot.cpp +29 -2
- package/ui/node_features.h +36 -0
- package/ui/node_lifecycle.cpp +358 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +816 -96
- package/ui/node_text.h +84 -0
- package/ui/refresh_perf.h +19 -17
- package/ui/render.cpp +341 -259
- package/ui/renderer_features.h +24 -0
- package/ui/root_scroll_refresh.cpp +86 -69
- package/ui/storage_usage.h +45 -0
- package/ui/style.cpp +1398 -349
- package/ui/style_values.h +2 -2
- package/ui/text.cpp +172 -154
- package/ui/tree_events.cpp +218 -92
- package/ui/tree_events.h +44 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +51 -19
- package/ui/tree_render.cpp +159 -126
- package/ui/tree_scroll_mirror.cpp +30 -4
- package/ui/tree_state.cpp +334 -115
- package/ui/tree_state.h +118 -22
- package/ui/tree_style.cpp +679 -303
- package/ui/view.cpp +268 -208
- package/ui/virtual_keyboard.cpp +18 -11
package/ui/node_model.h
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
#pragma once
|
|
3
3
|
|
|
4
4
|
#include "pixel.h"
|
|
5
|
+
#include "css_features.h"
|
|
6
|
+
#include "renderer_features.h"
|
|
7
|
+
#include "node_text.h"
|
|
8
|
+
#include "node_features.h"
|
|
5
9
|
|
|
6
10
|
#include <algorithm>
|
|
7
11
|
#include <cstdint>
|
|
8
12
|
#include <cstddef>
|
|
9
13
|
#include <deque>
|
|
10
14
|
#include <string>
|
|
15
|
+
#include <type_traits>
|
|
11
16
|
|
|
12
17
|
namespace gea::embedded::ui {
|
|
13
18
|
|
|
@@ -108,7 +113,7 @@ inline int usedAlignment(int alignment, int freeSpace, bool reversed = false)
|
|
|
108
113
|
return keyword;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
|
-
enum class NodeType :
|
|
116
|
+
enum class NodeType : uint8_t {
|
|
112
117
|
View = 0,
|
|
113
118
|
Text = 1,
|
|
114
119
|
Image = 2,
|
|
@@ -133,27 +138,73 @@ inline bool isNativeButtonNodeType(NodeType type)
|
|
|
133
138
|
// or embedded inline in ComputedStyle when GEA_EMBEDDED_RARE_STYLE_INLINE is set (defined
|
|
134
139
|
// BEFORE ComputedStyle so it can be a by-value member).
|
|
135
140
|
struct RareStyle {
|
|
141
|
+
bool operator==(const RareStyle &) const = default;
|
|
136
142
|
// Logical edges: block-start/end, inline-start/end.
|
|
143
|
+
#if GEA_CSS_MARGIN_TRIM
|
|
137
144
|
uint8_t margin_trim = 0;
|
|
145
|
+
#else
|
|
146
|
+
static constexpr uint8_t margin_trim = 0;
|
|
147
|
+
#endif
|
|
138
148
|
// IEEE float bits travel through the existing integer style-value transport.
|
|
139
149
|
// Negative ratios mean `auto <ratio>` (prefer a replaced element's natural ratio).
|
|
150
|
+
#if GEA_CSS_ASPECT_RATIO
|
|
140
151
|
int32_t aspect_ratio = 0;
|
|
152
|
+
#else
|
|
153
|
+
static constexpr int32_t aspect_ratio = 0;
|
|
154
|
+
#endif
|
|
155
|
+
#if GEA_CSS_FLEX_LINE_COUNT
|
|
141
156
|
int32_t flex_line_count = 1;
|
|
157
|
+
#else
|
|
158
|
+
static constexpr int32_t flex_line_count = 1;
|
|
159
|
+
#endif
|
|
160
|
+
#if GEA_CSS_FLEX_BASIS_EXPRESSIONS
|
|
142
161
|
int32_t flex_basis_expression = -1;
|
|
162
|
+
#else
|
|
163
|
+
static constexpr int32_t flex_basis_expression = -1;
|
|
164
|
+
#endif
|
|
165
|
+
#if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
|
|
143
166
|
int32_t line_height_expression = -1;
|
|
167
|
+
#else
|
|
168
|
+
static constexpr int32_t line_height_expression = -1;
|
|
169
|
+
#endif
|
|
144
170
|
// Individual grid item alignment; auto defers to the parent's justify-items.
|
|
171
|
+
#if GEA_CSS_JUSTIFY_SELF
|
|
145
172
|
int8_t justify_self = -1;
|
|
173
|
+
#else
|
|
174
|
+
static constexpr int8_t justify_self = -1;
|
|
175
|
+
#endif
|
|
146
176
|
// Computed contain flags: size, inline-size, layout, style, paint.
|
|
147
177
|
// Currently consumed by document background propagation.
|
|
178
|
+
#if GEA_CSS_CONTAINMENT
|
|
148
179
|
uint8_t containment = 0;
|
|
180
|
+
#else
|
|
181
|
+
static constexpr uint8_t containment = 0;
|
|
182
|
+
#endif
|
|
183
|
+
#if GEA_CSS_BACKGROUND_LAYERS
|
|
149
184
|
uint16_t bg_clip = 0; // Interned clip list; zero is border-box.
|
|
185
|
+
#else
|
|
186
|
+
static constexpr uint16_t bg_clip = 0; // Interned clip list; zero is border-box.
|
|
187
|
+
#endif
|
|
150
188
|
// row-start, column-start, row-end, column-end; zero is auto. Positive
|
|
151
189
|
// spans carry kGridLineSpan, while signed integers retain explicit lines.
|
|
190
|
+
#if GEA_CSS_GRID
|
|
152
191
|
int32_t grid_line[4] = {};
|
|
192
|
+
#else
|
|
193
|
+
static constexpr int32_t grid_line[4] = {};
|
|
194
|
+
#endif
|
|
153
195
|
// Deferred box edges; absent expressions do not allocate a rare-style record.
|
|
196
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
154
197
|
int32_t margin_expression[4] = {-1, -1, -1, -1};
|
|
198
|
+
#else
|
|
199
|
+
static constexpr int32_t margin_expression[4] = {-1, -1, -1, -1};
|
|
200
|
+
#endif
|
|
201
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
155
202
|
int32_t padding_expression[4] = {-1, -1, -1, -1};
|
|
203
|
+
#else
|
|
204
|
+
static constexpr int32_t padding_expression[4] = {-1, -1, -1, -1};
|
|
205
|
+
#endif
|
|
156
206
|
// --- grid (display:grid track templates) ---
|
|
207
|
+
#if GEA_CSS_GRID
|
|
157
208
|
int8_t grid_column_count = 0;
|
|
158
209
|
int8_t grid_row_count = 0;
|
|
159
210
|
int8_t grid_column_type[kMaxGridTracks] = {};
|
|
@@ -161,9 +212,20 @@ struct RareStyle {
|
|
|
161
212
|
int16_t grid_column_value[kMaxGridTracks] = {};
|
|
162
213
|
int16_t grid_row_value[kMaxGridTracks] = {};
|
|
163
214
|
|
|
215
|
+
#else
|
|
216
|
+
static constexpr int8_t grid_column_count = 0;
|
|
217
|
+
static constexpr int8_t grid_row_count = 0;
|
|
218
|
+
static constexpr int8_t grid_column_type[kMaxGridTracks] = {};
|
|
219
|
+
static constexpr int8_t grid_row_type[kMaxGridTracks] = {};
|
|
220
|
+
static constexpr int16_t grid_column_value[kMaxGridTracks] = {};
|
|
221
|
+
static constexpr int16_t grid_row_value[kMaxGridTracks] = {};
|
|
222
|
+
|
|
223
|
+
#endif
|
|
224
|
+
|
|
164
225
|
// --- transform / perspective (defaults must match NodeLifecycle::init:
|
|
165
226
|
// scale 1000 = 1.0x, origins 500 = 50% center; the rest 0) ---
|
|
166
227
|
// Authored identity effects still establish positioning containing blocks.
|
|
228
|
+
#if GEA_CSS_TRANSFORMS
|
|
167
229
|
uint8_t transform_present = 0;
|
|
168
230
|
uint8_t transform_preserve_3d = 0;
|
|
169
231
|
uint8_t rotate_present = 0;
|
|
@@ -175,7 +237,6 @@ struct RareStyle {
|
|
|
175
237
|
uint8_t transform_translate_outer_axes = 0;
|
|
176
238
|
int16_t translate_x = 0, translate_y = 0, translate_z = 0;
|
|
177
239
|
int16_t translate_x_percent = 0, translate_y_percent = 0;
|
|
178
|
-
uint8_t filter_present = 0;
|
|
179
240
|
int16_t transform_rotate = 0;
|
|
180
241
|
int16_t transform_rotate_x = 0;
|
|
181
242
|
int16_t transform_rotate_y = 0;
|
|
@@ -193,24 +254,97 @@ struct RareStyle {
|
|
|
193
254
|
int16_t perspective_origin_x = 500;
|
|
194
255
|
int16_t perspective_origin_y = 500;
|
|
195
256
|
|
|
257
|
+
#else
|
|
258
|
+
static constexpr uint8_t transform_present = 0;
|
|
259
|
+
static constexpr uint8_t transform_preserve_3d = 0;
|
|
260
|
+
static constexpr uint8_t rotate_present = 0;
|
|
261
|
+
static constexpr int16_t rotate_angle = 0;
|
|
262
|
+
static constexpr int32_t rotate_axis_x = 0, rotate_axis_y = 0, rotate_axis_z = 1000000;
|
|
263
|
+
static constexpr int16_t scale_x = 1000, scale_y = 1000, scale_z = 1000;
|
|
264
|
+
static constexpr uint8_t scale_present = 0;
|
|
265
|
+
static constexpr uint8_t translate_present = 0;
|
|
266
|
+
static constexpr uint8_t transform_translate_outer_axes = 0;
|
|
267
|
+
static constexpr int16_t translate_x = 0, translate_y = 0, translate_z = 0;
|
|
268
|
+
static constexpr int16_t translate_x_percent = 0, translate_y_percent = 0;
|
|
269
|
+
static constexpr int16_t transform_rotate = 0;
|
|
270
|
+
static constexpr int16_t transform_rotate_x = 0;
|
|
271
|
+
static constexpr int16_t transform_rotate_y = 0;
|
|
272
|
+
static constexpr int16_t transform_translate_x = 0;
|
|
273
|
+
static constexpr int16_t transform_translate_y = 0;
|
|
274
|
+
static constexpr int16_t transform_translate_z = 0;
|
|
275
|
+
static constexpr int16_t transform_translate_x_percent = 0;
|
|
276
|
+
static constexpr int16_t transform_translate_y_percent = 0;
|
|
277
|
+
static constexpr int16_t transform_scale_x = 1000;
|
|
278
|
+
static constexpr int16_t transform_scale_y = 1000;
|
|
279
|
+
static constexpr int16_t transform_scale_z = 1000;
|
|
280
|
+
static constexpr int16_t transform_origin_x = 500;
|
|
281
|
+
static constexpr int16_t transform_origin_y = 500;
|
|
282
|
+
static constexpr int16_t perspective = 0;
|
|
283
|
+
static constexpr int16_t perspective_origin_x = 500;
|
|
284
|
+
static constexpr int16_t perspective_origin_y = 500;
|
|
285
|
+
#endif
|
|
286
|
+
#if GEA_CSS_FILTERS
|
|
287
|
+
uint8_t filter_present = 0;
|
|
288
|
+
#else
|
|
289
|
+
static constexpr uint8_t filter_present = 0;
|
|
290
|
+
#endif
|
|
291
|
+
|
|
196
292
|
// --- filter / box-shadow (all default 0 = no effect) ---
|
|
293
|
+
#if GEA_CSS_FILTERS
|
|
197
294
|
int16_t filter_blur_radius = 0;
|
|
295
|
+
#else
|
|
296
|
+
static constexpr int16_t filter_blur_radius = 0;
|
|
297
|
+
#endif
|
|
298
|
+
#if GEA_CSS_BOX_SHADOW
|
|
198
299
|
uint8_t box_shadow_inset = 0;
|
|
300
|
+
#else
|
|
301
|
+
static constexpr uint8_t box_shadow_inset = 0;
|
|
302
|
+
#endif
|
|
303
|
+
#if GEA_CSS_BOX_SHADOW
|
|
199
304
|
int16_t box_shadow_offset_x = 0;
|
|
305
|
+
#else
|
|
306
|
+
static constexpr int16_t box_shadow_offset_x = 0;
|
|
307
|
+
#endif
|
|
308
|
+
#if GEA_CSS_BOX_SHADOW
|
|
200
309
|
int16_t box_shadow_offset_y = 0;
|
|
310
|
+
#else
|
|
311
|
+
static constexpr int16_t box_shadow_offset_y = 0;
|
|
312
|
+
#endif
|
|
313
|
+
#if GEA_CSS_BOX_SHADOW
|
|
201
314
|
int16_t box_shadow_blur_radius = 0;
|
|
315
|
+
#else
|
|
316
|
+
static constexpr int16_t box_shadow_blur_radius = 0;
|
|
317
|
+
#endif
|
|
318
|
+
#if GEA_CSS_BOX_SHADOW
|
|
202
319
|
int16_t box_shadow_spread = 0;
|
|
320
|
+
#else
|
|
321
|
+
static constexpr int16_t box_shadow_spread = 0;
|
|
322
|
+
#endif
|
|
323
|
+
#if GEA_CSS_BOX_SHADOW
|
|
203
324
|
style_color_t box_shadow_color = 0;
|
|
325
|
+
#else
|
|
326
|
+
static constexpr style_color_t box_shadow_color = 0;
|
|
327
|
+
#endif
|
|
328
|
+
#if GEA_CSS_BOX_SHADOW
|
|
204
329
|
uint8_t box_shadow_alpha = 0;
|
|
330
|
+
#else
|
|
331
|
+
static constexpr uint8_t box_shadow_alpha = 0;
|
|
332
|
+
#endif
|
|
205
333
|
|
|
206
334
|
// --- per-side borders (default white/opaque, matching NodeLifecycle::init;
|
|
207
335
|
// only relevant when a side width > 0, which is rare) ---
|
|
336
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
208
337
|
int16_t border_side_width[4] = {};
|
|
338
|
+
#else
|
|
339
|
+
static constexpr int16_t border_side_width[4] = {};
|
|
340
|
+
#endif
|
|
209
341
|
// 0: flat; 1: groove; 2: ridge; 3: inset; 4: outset.
|
|
342
|
+
#if GEA_CSS_BORDER_RELIEF
|
|
210
343
|
uint8_t border_relief[4] = {};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
344
|
+
#else
|
|
345
|
+
static constexpr uint8_t border_relief[4] = {};
|
|
346
|
+
#endif
|
|
347
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
214
348
|
style_color_t border_side_color[4] = {
|
|
215
349
|
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
216
350
|
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
@@ -218,14 +352,31 @@ struct RareStyle {
|
|
|
218
352
|
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
219
353
|
};
|
|
220
354
|
|
|
221
|
-
|
|
355
|
+
uint8_t border_side_alpha[4] = {255, 255, 255, 255};
|
|
356
|
+
#else
|
|
357
|
+
static constexpr style_color_t border_side_color[4] = {
|
|
358
|
+
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
359
|
+
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
360
|
+
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
361
|
+
gea::framework::graphics::pixel::nativeColor(255, 255, 255),
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
static constexpr uint8_t border_side_alpha[4] = {255, 255, 255, 255};
|
|
365
|
+
#endif
|
|
222
366
|
|
|
223
367
|
// --- linear / overlay / radial gradients + background grid (defaults match
|
|
224
368
|
// NodeLifecycle::init: alphas 255, stops 500/1000, angle 1800, radial
|
|
225
369
|
// center/extent 500/1000) ---
|
|
370
|
+
#if GEA_CSS_BACKGROUND_LAYERS
|
|
226
371
|
uint16_t bg_image_layer_count = 1; // Includes none layers.
|
|
227
372
|
int32_t bg_size_list = -1, bg_position_list = -1, bg_repeat_list = -1;
|
|
228
373
|
int32_t bg_attachment_list = -1, bg_origin_list = -1;
|
|
374
|
+
#else
|
|
375
|
+
static constexpr uint16_t bg_image_layer_count = 1; // Includes none layers.
|
|
376
|
+
static constexpr int32_t bg_size_list = -1, bg_position_list = -1, bg_repeat_list = -1;
|
|
377
|
+
static constexpr int32_t bg_attachment_list = -1, bg_origin_list = -1;
|
|
378
|
+
#endif
|
|
379
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
229
380
|
uint16_t bg_gradient_layer = 0, bg_overlay_gradient_layer = 0, bg_radial_gradient_layer = 0;
|
|
230
381
|
style_color_t bg_gradient_from_color = 0;
|
|
231
382
|
style_color_t bg_gradient_mid_color = 0;
|
|
@@ -265,6 +416,47 @@ struct RareStyle {
|
|
|
265
416
|
uint16_t bg_grid_step_y = 0;
|
|
266
417
|
uint8_t bg_grid_line_x = 0;
|
|
267
418
|
uint8_t bg_grid_line_y = 0;
|
|
419
|
+
#else
|
|
420
|
+
static constexpr uint16_t bg_gradient_layer = 0, bg_overlay_gradient_layer = 0, bg_radial_gradient_layer = 0;
|
|
421
|
+
static constexpr style_color_t bg_gradient_from_color = 0;
|
|
422
|
+
static constexpr style_color_t bg_gradient_mid_color = 0;
|
|
423
|
+
static constexpr style_color_t bg_gradient_to_color = 0;
|
|
424
|
+
static constexpr uint8_t bg_gradient_from_alpha = 255;
|
|
425
|
+
static constexpr uint8_t bg_gradient_mid_alpha = 255;
|
|
426
|
+
static constexpr uint8_t bg_gradient_to_alpha = 255;
|
|
427
|
+
static constexpr uint16_t bg_gradient_mid_stop = 500;
|
|
428
|
+
static constexpr uint16_t bg_gradient_to_stop = 1000;
|
|
429
|
+
static constexpr uint8_t bg_gradient_has_mid = 0;
|
|
430
|
+
static constexpr int16_t bg_gradient_angle = 1800;
|
|
431
|
+
static constexpr uint8_t bg_overlay_gradient = 0;
|
|
432
|
+
static constexpr style_color_t bg_overlay_gradient_from_color = 0;
|
|
433
|
+
static constexpr style_color_t bg_overlay_gradient_mid_color = 0;
|
|
434
|
+
static constexpr style_color_t bg_overlay_gradient_to_color = 0;
|
|
435
|
+
static constexpr uint8_t bg_overlay_gradient_from_alpha = 255;
|
|
436
|
+
static constexpr uint8_t bg_overlay_gradient_mid_alpha = 255;
|
|
437
|
+
static constexpr uint8_t bg_overlay_gradient_to_alpha = 255;
|
|
438
|
+
static constexpr uint16_t bg_overlay_gradient_mid_stop = 500;
|
|
439
|
+
static constexpr uint16_t bg_overlay_gradient_to_stop = 1000;
|
|
440
|
+
static constexpr uint8_t bg_overlay_gradient_has_mid = 0;
|
|
441
|
+
static constexpr int16_t bg_overlay_gradient_angle = 1800;
|
|
442
|
+
static constexpr uint8_t bg_radial_gradient = 0;
|
|
443
|
+
static constexpr style_color_t bg_radial_gradient_from_color = 0;
|
|
444
|
+
static constexpr style_color_t bg_radial_gradient_to_color = 0;
|
|
445
|
+
static constexpr uint8_t bg_radial_gradient_from_alpha = 255;
|
|
446
|
+
static constexpr uint8_t bg_radial_gradient_to_alpha = 255;
|
|
447
|
+
static constexpr uint16_t bg_radial_gradient_stop = 1000;
|
|
448
|
+
static constexpr int16_t bg_radial_gradient_cx = 500;
|
|
449
|
+
static constexpr int16_t bg_radial_gradient_cy = 500;
|
|
450
|
+
static constexpr int16_t bg_radial_gradient_rx = 1000;
|
|
451
|
+
static constexpr int16_t bg_radial_gradient_ry = 1000;
|
|
452
|
+
static constexpr uint8_t bg_grid_axes = 0;
|
|
453
|
+
static constexpr style_color_t bg_grid_color = 0;
|
|
454
|
+
static constexpr uint8_t bg_grid_alpha = 255;
|
|
455
|
+
static constexpr uint16_t bg_grid_step_x = 0;
|
|
456
|
+
static constexpr uint16_t bg_grid_step_y = 0;
|
|
457
|
+
static constexpr uint8_t bg_grid_line_x = 0;
|
|
458
|
+
static constexpr uint8_t bg_grid_line_y = 0;
|
|
459
|
+
#endif
|
|
268
460
|
};
|
|
269
461
|
|
|
270
462
|
// Individual translation is applied outside the transform list. Its translation
|
|
@@ -280,126 +472,461 @@ inline int composedTranslateZ(const RareStyle &s) { return int(s.transform_trans
|
|
|
280
472
|
inline int composedTranslateXPercent(const RareStyle &s) { return int(s.transform_translate_x_percent) + s.translate_x_percent; }
|
|
281
473
|
inline int composedTranslateYPercent(const RareStyle &s) { return int(s.transform_translate_y_percent) + s.translate_y_percent; }
|
|
282
474
|
|
|
475
|
+
#define GEA_CSS_RARE_STYLE (GEA_CSS_ASPECT_RATIO || GEA_CSS_BACKGROUND_LAYERS || GEA_CSS_BORDER_RELIEF || GEA_CSS_BOX_EXPRESSIONS || GEA_CSS_BOX_SHADOW || GEA_CSS_CONTAINMENT || GEA_CSS_FILTERS || GEA_CSS_FLEX_BASIS_EXPRESSIONS || GEA_CSS_FLEX_LINE_COUNT || GEA_CSS_GRID || GEA_CSS_JUSTIFY_SELF || GEA_CSS_LINE_HEIGHT_EXPRESSIONS || GEA_CSS_MARGIN_TRIM || GEA_CSS_SIDE_BORDERS || GEA_CSS_TRANSFORMS || GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS)
|
|
476
|
+
static_assert(GEA_CSS_RARE_STYLE || std::is_empty<RareStyle>::value, "An unguarded rare field requires a reachability family");
|
|
477
|
+
|
|
283
478
|
struct ComputedStyle {
|
|
284
|
-
|
|
479
|
+
bool operator==(const ComputedStyle &) const = default;
|
|
480
|
+
uint8_t display : 2;
|
|
285
481
|
// True iff the `display` property was explicitly authored (a CSS rule or
|
|
286
482
|
// inline style set it), as opposed to the kDisplayBlock default. Lets the
|
|
287
483
|
// inline-formatting heuristic distinguish an explicit `display:block` on an
|
|
288
484
|
// inline-level tag (e.g. <span style="display:block">, which is block-level
|
|
289
485
|
// and stacks) from a span's default inline behaviour. Mirrors
|
|
290
486
|
// flex_direction_explicit.
|
|
291
|
-
|
|
487
|
+
#if GEA_CSS_DISPLAY_EXPLICIT
|
|
488
|
+
uint8_t display_explicit : 1;
|
|
489
|
+
#else
|
|
490
|
+
static constexpr uint8_t display_explicit = 0;
|
|
491
|
+
#endif
|
|
492
|
+
#if GEA_CSS_TEXT_ALIGN
|
|
493
|
+
int8_t text_align;
|
|
494
|
+
#else
|
|
495
|
+
static constexpr int8_t text_align = 0;
|
|
496
|
+
#endif
|
|
497
|
+
int8_t overflow : 3;
|
|
498
|
+
uint8_t position : 2;
|
|
499
|
+
uint8_t has_bg : 1;
|
|
500
|
+
#if GEA_CSS_Z_INDEX
|
|
501
|
+
uint8_t z_index_auto : 1;
|
|
502
|
+
#else
|
|
503
|
+
static constexpr int8_t z_index_auto = 1;
|
|
504
|
+
#endif
|
|
505
|
+
// A proven single byte radius fills the leading text-alignment slot when
|
|
506
|
+
// that field is absent. Its read remains one ordinary byte load.
|
|
507
|
+
#if GEA_CSS_U8_RADIUS && GEA_CSS_RADIUS_COUNT == 1 && !GEA_CSS_TEXT_ALIGN
|
|
508
|
+
uint8_t border_radius[1];
|
|
509
|
+
#endif
|
|
510
|
+
#if GEA_CSS_FLEX_DIRECTION
|
|
292
511
|
int8_t flex_direction;
|
|
512
|
+
#else
|
|
513
|
+
static constexpr int8_t flex_direction = 0;
|
|
514
|
+
#endif
|
|
515
|
+
#if GEA_CSS_FLEX_DIRECTION
|
|
293
516
|
int8_t flex_direction_explicit;
|
|
294
|
-
|
|
517
|
+
#else
|
|
518
|
+
static constexpr int8_t flex_direction_explicit = 0;
|
|
519
|
+
#endif
|
|
520
|
+
#if GEA_CSS_FLEX_WRAP
|
|
521
|
+
int8_t flex_wrap;
|
|
522
|
+
#else
|
|
523
|
+
static constexpr int8_t flex_wrap = 0;
|
|
524
|
+
#endif // low bits: 0 nowrap, 1 wrap, 2 wrap-reverse; bit 2: balance
|
|
525
|
+
#if GEA_CSS_JUSTIFY_CONTENT
|
|
295
526
|
int8_t justify_content;
|
|
527
|
+
#else
|
|
528
|
+
static constexpr int8_t justify_content = 0;
|
|
529
|
+
#endif
|
|
530
|
+
#if GEA_CSS_ALIGN_ITEMS
|
|
296
531
|
int8_t align_items;
|
|
532
|
+
#else
|
|
533
|
+
static constexpr int8_t align_items = 0;
|
|
534
|
+
#endif
|
|
535
|
+
#if GEA_CSS_JUSTIFY_ITEMS
|
|
297
536
|
int8_t justify_items;
|
|
537
|
+
#else
|
|
538
|
+
static constexpr int8_t justify_items = 0;
|
|
539
|
+
#endif
|
|
540
|
+
#if GEA_CSS_ALIGN_CONTENT
|
|
298
541
|
int8_t align_content;
|
|
542
|
+
#else
|
|
543
|
+
static constexpr int8_t align_content = 0;
|
|
544
|
+
#endif
|
|
545
|
+
#if GEA_CSS_ALIGN_SELF
|
|
299
546
|
int8_t align_self;
|
|
547
|
+
#else
|
|
548
|
+
static constexpr int8_t align_self = -1;
|
|
549
|
+
#endif
|
|
550
|
+
#if GEA_CSS_GAP && !GEA_CSS_U8_GAP
|
|
300
551
|
int16_t gap;
|
|
552
|
+
#endif
|
|
553
|
+
#if GEA_CSS_BOX_SIZING
|
|
301
554
|
int8_t box_sizing; // 0: content-box (CSS initial), 1: border-box
|
|
302
|
-
|
|
303
|
-
int8_t
|
|
304
|
-
|
|
305
|
-
|
|
555
|
+
#else
|
|
556
|
+
static constexpr int8_t box_sizing = 0;
|
|
557
|
+
#endif
|
|
558
|
+
#if GEA_CSS_FLOATS
|
|
559
|
+
int8_t float_side;
|
|
560
|
+
#else
|
|
561
|
+
static constexpr int8_t float_side = 0;
|
|
562
|
+
#endif // 0: none, 1: left, 2: right
|
|
563
|
+
#if GEA_CSS_FLOATS
|
|
564
|
+
int8_t clear_side;
|
|
565
|
+
#else
|
|
566
|
+
static constexpr int8_t clear_side = 0;
|
|
567
|
+
#endif // 0: none, 1: left, 2: right, 3: both
|
|
568
|
+
#if GEA_CSS_WRITING_MODE
|
|
569
|
+
int8_t writing_mode;
|
|
570
|
+
#else
|
|
571
|
+
static constexpr int8_t writing_mode = 0;
|
|
572
|
+
#endif // -1: inherit, 0: horizontal-tb, 1: vertical-lr, 2: vertical-rl, 3: sideways-rl, 4: sideways-lr
|
|
573
|
+
#if GEA_CSS_WRITING_MODE
|
|
574
|
+
int8_t direction;
|
|
575
|
+
#else
|
|
576
|
+
static constexpr int8_t direction = 0;
|
|
577
|
+
#endif // -1: inherit, 0: ltr, 1: rtl
|
|
578
|
+
#if GEA_CSS_MARGIN_AUTO
|
|
306
579
|
uint8_t margin_auto; // TRBL bit mask; numeric margins remain zero for auto
|
|
580
|
+
#else
|
|
581
|
+
static constexpr uint8_t margin_auto = 0;
|
|
582
|
+
#endif
|
|
583
|
+
#if GEA_CSS_AXIS_GAP
|
|
307
584
|
int16_t row_gap, column_gap; // kUnset falls back to native gap
|
|
585
|
+
#else
|
|
586
|
+
static constexpr int16_t row_gap = kUnset, column_gap = kUnset;
|
|
587
|
+
#endif
|
|
588
|
+
#if GEA_CSS_PERCENT_GAP
|
|
308
589
|
int16_t row_gap_percent, column_gap_percent;
|
|
590
|
+
#else
|
|
591
|
+
static constexpr int16_t row_gap_percent = kUnset, column_gap_percent = kUnset;
|
|
592
|
+
#endif
|
|
593
|
+
// Fits the alignment gap before the 32-bit fields. A literal common border
|
|
594
|
+
// color must not allocate a rare-style record merely for its binding flags.
|
|
595
|
+
// Bits 0..3: explicit side colors; bit 4: literal common color;
|
|
596
|
+
// bits 5..8: explicit side currentColor. Unspecified colors use currentColor.
|
|
597
|
+
#if GEA_CSS_BORDER_COLORS && !GEA_CSS_U8_BORDER_FLAGS
|
|
598
|
+
uint16_t border_color_flags = 0;
|
|
599
|
+
#endif
|
|
600
|
+
#if GEA_CSS_ORDER
|
|
309
601
|
int32_t order; // Stable ordering of flex/grid items; never changes tree order.
|
|
602
|
+
#else
|
|
603
|
+
static constexpr int32_t order = 0;
|
|
604
|
+
#endif
|
|
310
605
|
// Inherited unitless line-height number as IEEE float bits; -1 means length/normal.
|
|
311
606
|
// Keep this common inherited value out of the much larger rare-style allocation.
|
|
607
|
+
#if GEA_CSS_LINE_HEIGHT_MULTIPLIER
|
|
312
608
|
int32_t line_height_multiplier;
|
|
609
|
+
#else
|
|
610
|
+
static constexpr int32_t line_height_multiplier = -1;
|
|
611
|
+
#endif
|
|
313
612
|
|
|
314
|
-
|
|
613
|
+
#if GEA_CSS_WIDTH_EXPRESSIONS
|
|
614
|
+
int32_t width_expression;
|
|
615
|
+
#else
|
|
616
|
+
static constexpr int32_t width_expression = -1;
|
|
617
|
+
#endif
|
|
618
|
+
#if GEA_CSS_HEIGHT_EXPRESSIONS
|
|
619
|
+
int32_t height_expression;
|
|
620
|
+
#else
|
|
621
|
+
static constexpr int32_t height_expression = -1;
|
|
622
|
+
#endif
|
|
315
623
|
int16_t width, height;
|
|
316
|
-
|
|
317
|
-
int16_t
|
|
318
|
-
|
|
624
|
+
#if GEA_CSS_WIDTH_PERCENT
|
|
625
|
+
int16_t width_percent;
|
|
626
|
+
#else
|
|
627
|
+
static constexpr int16_t width_percent = kUnset;
|
|
628
|
+
#endif
|
|
629
|
+
#if GEA_CSS_HEIGHT_PERCENT
|
|
630
|
+
int16_t height_percent;
|
|
631
|
+
#else
|
|
632
|
+
static constexpr int16_t height_percent = kUnset;
|
|
633
|
+
#endif
|
|
634
|
+
#if GEA_CSS_MIN_WIDTH
|
|
635
|
+
int16_t min_width;
|
|
636
|
+
#else
|
|
637
|
+
static constexpr int16_t min_width = kUnset;
|
|
638
|
+
#endif
|
|
639
|
+
#if GEA_CSS_MIN_HEIGHT
|
|
640
|
+
int16_t min_height;
|
|
641
|
+
#else
|
|
642
|
+
static constexpr int16_t min_height = kUnset;
|
|
643
|
+
#endif
|
|
644
|
+
#if GEA_CSS_MAX_WIDTH
|
|
645
|
+
int16_t max_width;
|
|
646
|
+
#else
|
|
647
|
+
static constexpr int16_t max_width = kUnset;
|
|
648
|
+
#endif
|
|
649
|
+
#if GEA_CSS_MAX_HEIGHT
|
|
650
|
+
int16_t max_height;
|
|
651
|
+
#else
|
|
652
|
+
static constexpr int16_t max_height = kUnset;
|
|
653
|
+
#endif
|
|
654
|
+
#if GEA_CSS_FLEX_FACTORS && !GEA_CSS_U8_FLEX
|
|
319
655
|
int16_t flex;
|
|
320
656
|
int16_t flex_shrink;
|
|
657
|
+
#endif
|
|
321
658
|
// CSS `flex-basis` as a definite main-axis length in px, or kUnset for `auto`
|
|
322
659
|
// (the default — main size comes from content / flex-grow). When definite, the
|
|
323
660
|
// flex item's main-axis size is set to this basis before grow/shrink, so
|
|
324
661
|
// `flex: 0 0 26px` yields a 26px item instead of stretching to fill or sizing
|
|
325
662
|
// to content. Percentage and `auto` bases resolve to kUnset (content-sized).
|
|
663
|
+
#if GEA_CSS_FLEX_BASIS
|
|
326
664
|
int16_t flex_basis;
|
|
665
|
+
#else
|
|
666
|
+
static constexpr int16_t flex_basis = kUnset;
|
|
667
|
+
#endif
|
|
327
668
|
|
|
669
|
+
#if GEA_CSS_PADDING && !GEA_CSS_U8_PADDING
|
|
328
670
|
int16_t padding[4];
|
|
671
|
+
#endif
|
|
672
|
+
#if GEA_CSS_MARGINS
|
|
329
673
|
int16_t margin[4];
|
|
674
|
+
#else
|
|
675
|
+
static constexpr int16_t margin[4] = {};
|
|
676
|
+
#endif
|
|
330
677
|
|
|
331
|
-
|
|
332
|
-
int8_t z_index_auto;
|
|
678
|
+
#if GEA_CSS_POSITION_PX_ALL
|
|
333
679
|
int16_t pos_offsets[4];
|
|
680
|
+
#else
|
|
681
|
+
#if GEA_CSS_POSITION_TOP
|
|
682
|
+
int16_t pos_top;
|
|
683
|
+
#else
|
|
684
|
+
static constexpr int16_t pos_top = kUnset;
|
|
685
|
+
#endif
|
|
686
|
+
#if GEA_CSS_POSITION_RIGHT
|
|
687
|
+
int16_t pos_right;
|
|
688
|
+
#else
|
|
689
|
+
static constexpr int16_t pos_right = kUnset;
|
|
690
|
+
#endif
|
|
691
|
+
#if GEA_CSS_POSITION_BOTTOM
|
|
692
|
+
int16_t pos_bottom;
|
|
693
|
+
#else
|
|
694
|
+
static constexpr int16_t pos_bottom = kUnset;
|
|
695
|
+
#endif
|
|
696
|
+
#if GEA_CSS_POSITION_LEFT
|
|
697
|
+
int16_t pos_left;
|
|
698
|
+
#else
|
|
699
|
+
static constexpr int16_t pos_left = kUnset;
|
|
700
|
+
#endif
|
|
701
|
+
#endif
|
|
702
|
+
#if GEA_CSS_POSITION_PERCENT_ALL
|
|
334
703
|
int16_t pos_offset_percent[4];
|
|
704
|
+
#else
|
|
705
|
+
#if GEA_CSS_POSITION_TOP_PERCENT
|
|
706
|
+
int16_t pos_percent_top;
|
|
707
|
+
#else
|
|
708
|
+
static constexpr int16_t pos_percent_top = kUnset;
|
|
709
|
+
#endif
|
|
710
|
+
#if GEA_CSS_POSITION_RIGHT_PERCENT
|
|
711
|
+
int16_t pos_percent_right;
|
|
712
|
+
#else
|
|
713
|
+
static constexpr int16_t pos_percent_right = kUnset;
|
|
714
|
+
#endif
|
|
715
|
+
#if GEA_CSS_POSITION_BOTTOM_PERCENT
|
|
716
|
+
int16_t pos_percent_bottom;
|
|
717
|
+
#else
|
|
718
|
+
static constexpr int16_t pos_percent_bottom = kUnset;
|
|
719
|
+
#endif
|
|
720
|
+
#if GEA_CSS_POSITION_LEFT_PERCENT
|
|
721
|
+
int16_t pos_percent_left;
|
|
722
|
+
#else
|
|
723
|
+
static constexpr int16_t pos_percent_left = kUnset;
|
|
724
|
+
#endif
|
|
725
|
+
#endif
|
|
726
|
+
#if GEA_CSS_Z_INDEX
|
|
335
727
|
int16_t z_index;
|
|
728
|
+
#else
|
|
729
|
+
static constexpr int16_t z_index = 0;
|
|
730
|
+
#endif
|
|
336
731
|
|
|
337
|
-
|
|
338
|
-
|
|
732
|
+
// Group byte-sized paint flags before native colours. Keep natural alignment
|
|
733
|
+
// without paying padding between each RGB565 colour and its flags.
|
|
339
734
|
uint8_t bg_alpha;
|
|
735
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
340
736
|
int8_t bg_fill;
|
|
737
|
+
#else
|
|
738
|
+
static constexpr int8_t bg_fill = 0;
|
|
739
|
+
#endif
|
|
740
|
+
#if GEA_CSS_ACTIVE_BACKGROUND
|
|
741
|
+
int8_t has_active_bg;
|
|
742
|
+
#else
|
|
743
|
+
static constexpr int8_t has_active_bg = 0;
|
|
744
|
+
#endif
|
|
745
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
746
|
+
uint8_t text_alpha;
|
|
747
|
+
#else
|
|
748
|
+
static constexpr uint8_t text_alpha = 255;
|
|
749
|
+
#endif
|
|
750
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
751
|
+
uint8_t border_alpha;
|
|
752
|
+
#else
|
|
753
|
+
static constexpr uint8_t border_alpha = 255;
|
|
754
|
+
#endif
|
|
755
|
+
#if GEA_CSS_LINE_HEIGHT && GEA_CSS_U8_LINE_HEIGHT
|
|
756
|
+
uint8_t line_height;
|
|
757
|
+
#endif
|
|
758
|
+
style_color_t bg_color;
|
|
341
759
|
// linear/overlay/radial gradients + background-grid moved to RareStyle (rare).
|
|
760
|
+
#if GEA_CSS_ACTIVE_BACKGROUND
|
|
342
761
|
style_color_t active_bg_color;
|
|
343
|
-
|
|
762
|
+
#else
|
|
763
|
+
static constexpr style_color_t active_bg_color = 0;
|
|
764
|
+
#endif
|
|
344
765
|
style_color_t text_color;
|
|
345
|
-
|
|
766
|
+
#if GEA_CSS_OPACITY
|
|
346
767
|
uint8_t opacity;
|
|
768
|
+
#else
|
|
769
|
+
static constexpr uint8_t opacity = 255;
|
|
770
|
+
#endif
|
|
771
|
+
#if GEA_CSS_BLINK
|
|
347
772
|
int16_t blink_interval_ms;
|
|
348
773
|
int32_t blink_started_ms;
|
|
349
774
|
uint8_t blink_visible;
|
|
775
|
+
#else
|
|
776
|
+
static constexpr int16_t blink_interval_ms = 0;
|
|
777
|
+
static constexpr int32_t blink_started_ms = 0;
|
|
778
|
+
static constexpr uint8_t blink_visible = 1;
|
|
779
|
+
#endif
|
|
350
780
|
|
|
781
|
+
#if GEA_CSS_BORDER_WIDTHS && !GEA_CSS_U8_BORDER
|
|
351
782
|
int16_t border_width;
|
|
783
|
+
#endif
|
|
784
|
+
#if GEA_CSS_BORDER_COLORS
|
|
352
785
|
style_color_t border_color;
|
|
353
|
-
|
|
786
|
+
#else
|
|
787
|
+
static constexpr style_color_t border_color = gea::framework::graphics::pixel::nativeColor(255, 255, 255);
|
|
788
|
+
#endif
|
|
354
789
|
// per-side border width/color/alpha moved to RareStyle (rare); border_radius
|
|
355
790
|
// stays here (rounded rects are common).
|
|
356
|
-
|
|
357
|
-
int16_t
|
|
791
|
+
#if !GEA_CSS_U8_RADIUS
|
|
792
|
+
int16_t border_radius[GEA_CSS_RADIUS_COUNT];
|
|
793
|
+
#endif
|
|
794
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
795
|
+
int16_t border_radius_percent[GEA_CSS_RADIUS_COUNT];
|
|
796
|
+
#else
|
|
797
|
+
static constexpr int16_t border_radius_percent[4] = {kUnset, kUnset, kUnset, kUnset};
|
|
798
|
+
#endif
|
|
358
799
|
|
|
359
800
|
// transform / perspective / filter / box-shadow moved to RareStyle (rare).
|
|
360
801
|
|
|
361
802
|
int16_t font_id;
|
|
803
|
+
#if !GEA_CSS_U8_FONT
|
|
362
804
|
int16_t font_size;
|
|
805
|
+
#endif
|
|
806
|
+
#if GEA_CSS_FONT_WEIGHT
|
|
363
807
|
int16_t font_weight;
|
|
808
|
+
#else
|
|
809
|
+
static constexpr int16_t font_weight = 400;
|
|
810
|
+
#endif
|
|
811
|
+
#if !GEA_CSS_LINE_HEIGHT
|
|
812
|
+
static constexpr int16_t line_height = 0;
|
|
813
|
+
#elif !GEA_CSS_U8_LINE_HEIGHT
|
|
364
814
|
int16_t line_height;
|
|
365
|
-
|
|
366
|
-
|
|
815
|
+
#endif
|
|
816
|
+
|
|
817
|
+
#if GEA_CSS_OVERFLOW_AXES
|
|
367
818
|
int8_t overflow_x;
|
|
368
819
|
int8_t overflow_y;
|
|
820
|
+
#else
|
|
821
|
+
static constexpr int8_t overflow_x = 0, overflow_y = 0;
|
|
822
|
+
#endif
|
|
823
|
+
#if GEA_CSS_MASK
|
|
369
824
|
int16_t mask_right_fade_width;
|
|
825
|
+
#else
|
|
826
|
+
static constexpr int16_t mask_right_fade_width = 0;
|
|
827
|
+
#endif
|
|
828
|
+
#if GEA_CSS_IMAGE_FIT
|
|
370
829
|
int8_t image_fit;
|
|
830
|
+
#else
|
|
831
|
+
static constexpr int8_t image_fit = 0;
|
|
832
|
+
#endif
|
|
371
833
|
// CSS `backface-visibility`: 0 = visible (default), 1 = hidden. When hidden, a
|
|
372
834
|
// flat element's entire painted subtree is culled when its back faces the viewer.
|
|
373
835
|
// A preserve-3d element keeps its descendants' individual visibility.
|
|
836
|
+
#if GEA_CSS_TRANSFORMS
|
|
374
837
|
int8_t backface_hidden;
|
|
375
|
-
|
|
838
|
+
#else
|
|
839
|
+
static constexpr int8_t backface_hidden = 0;
|
|
840
|
+
#endif
|
|
841
|
+
#if GEA_CSS_VISIBILITY
|
|
842
|
+
int8_t visibility;
|
|
843
|
+
#else
|
|
844
|
+
static constexpr int8_t visibility = 0;
|
|
845
|
+
#endif // 0 visible, 1 hidden, 2 collapse (inherited)
|
|
376
846
|
// CSS `text-decoration` — 0 = none (default), 1 = underline, 2 =
|
|
377
847
|
// line-through. The text renderer paints a font-size-relative line at
|
|
378
848
|
// the appropriate y-offset for each decorated run.
|
|
849
|
+
#if GEA_CSS_TEXT_DECORATION
|
|
379
850
|
int8_t text_decoration;
|
|
851
|
+
#else
|
|
852
|
+
static constexpr int8_t text_decoration = 0;
|
|
853
|
+
#endif
|
|
380
854
|
// CSS `text-transform` — 0 = none, 1 = uppercase, 2 = lowercase,
|
|
381
855
|
// 3 = capitalize. Rendering applies this without mutating Node::text.
|
|
856
|
+
#if GEA_CSS_TEXT_TRANSFORM
|
|
382
857
|
int8_t text_transform;
|
|
858
|
+
#else
|
|
859
|
+
static constexpr int8_t text_transform = 0;
|
|
860
|
+
#endif
|
|
383
861
|
// CSS `white-space`: 0 normal, 1 nowrap, 2 pre, 3 pre-wrap, 4 pre-line,
|
|
384
862
|
// 5 break-spaces. Inherited; space preservation and soft wrapping differ.
|
|
863
|
+
#if GEA_CSS_WHITE_SPACE
|
|
385
864
|
int8_t white_space;
|
|
865
|
+
#else
|
|
866
|
+
static constexpr int8_t white_space = 0;
|
|
867
|
+
#endif
|
|
386
868
|
// CSS `text-overflow` — 0 = clip (default), 1 = ellipsis. Only consulted
|
|
387
869
|
// when the line cannot wrap (white-space: nowrap): an overflowing single
|
|
388
870
|
// line is truncated at a glyph boundary and an ASCII "..." is appended so
|
|
389
871
|
// the visible run fits within the content width. Not inherited.
|
|
872
|
+
#if GEA_CSS_TEXT_OVERFLOW
|
|
390
873
|
int8_t text_overflow;
|
|
874
|
+
#else
|
|
875
|
+
static constexpr int8_t text_overflow = 0;
|
|
876
|
+
#endif
|
|
877
|
+
// Compiler-proven unsigned ranges need one byte load, with no unpacking.
|
|
878
|
+
// Group these bytes so narrowing does not merely create alignment holes.
|
|
879
|
+
#if GEA_CSS_BORDER_COLORS && GEA_CSS_U8_BORDER_FLAGS
|
|
880
|
+
uint8_t border_color_flags = 0;
|
|
881
|
+
#elif !GEA_CSS_BORDER_COLORS
|
|
882
|
+
static constexpr uint8_t border_color_flags = 0;
|
|
883
|
+
#endif
|
|
884
|
+
#if GEA_CSS_GAP && GEA_CSS_U8_GAP
|
|
885
|
+
uint8_t gap;
|
|
886
|
+
#elif !GEA_CSS_GAP
|
|
887
|
+
static constexpr int16_t gap = 0;
|
|
888
|
+
#endif
|
|
889
|
+
#if GEA_CSS_FLEX_FACTORS && GEA_CSS_U8_FLEX
|
|
890
|
+
uint8_t flex, flex_shrink;
|
|
891
|
+
#elif !GEA_CSS_FLEX_FACTORS
|
|
892
|
+
static constexpr int16_t flex = 0, flex_shrink = 1;
|
|
893
|
+
#endif
|
|
894
|
+
#if GEA_CSS_PADDING && GEA_CSS_U8_PADDING
|
|
895
|
+
uint8_t padding[4];
|
|
896
|
+
#elif !GEA_CSS_PADDING
|
|
897
|
+
static constexpr int16_t padding[4] = {};
|
|
898
|
+
#endif
|
|
899
|
+
#if GEA_CSS_BORDER_WIDTHS && GEA_CSS_U8_BORDER
|
|
900
|
+
uint8_t border_width;
|
|
901
|
+
#elif !GEA_CSS_BORDER_WIDTHS
|
|
902
|
+
static constexpr int16_t border_width = 0;
|
|
903
|
+
#endif
|
|
904
|
+
#if GEA_CSS_U8_RADIUS && (GEA_CSS_RADIUS_COUNT != 1 || GEA_CSS_TEXT_ALIGN)
|
|
905
|
+
uint8_t border_radius[GEA_CSS_RADIUS_COUNT];
|
|
906
|
+
#endif
|
|
907
|
+
#if GEA_CSS_U8_FONT
|
|
908
|
+
uint8_t font_size;
|
|
909
|
+
#endif
|
|
910
|
+
|
|
911
|
+
|
|
391
912
|
// CSS `pointer-events` — 0 = auto (default), 1 = none. A `none` node is never
|
|
392
913
|
// the target of a pointer event and its subtree is skipped in hit-testing, so
|
|
393
914
|
// clicks pass through to whatever is painted behind it (e.g. a decorative
|
|
394
915
|
// overlay image over interactive controls). Default 0 via zero-init.
|
|
916
|
+
#if GEA_CSS_POINTER_EVENTS
|
|
395
917
|
int8_t pointer_events;
|
|
918
|
+
#else
|
|
919
|
+
static constexpr int8_t pointer_events = 0;
|
|
920
|
+
#endif
|
|
396
921
|
|
|
397
922
|
// Handle into the shared RareStyle pool for cold/rarely-used style fields
|
|
398
923
|
// (grid tracks, gradients, transforms, shadows, …) that most nodes never set.
|
|
399
924
|
// -1 = none, so a plain styled node pays 2 bytes instead of inlining ~200 B.
|
|
400
925
|
// Read via rstyle(style), write via rstyleMut(style). Aggregate-friendly: this
|
|
401
926
|
// is the only member with a default initializer; the rest stay zero-init.
|
|
402
|
-
#if
|
|
927
|
+
#if !GEA_CSS_RARE_STYLE
|
|
928
|
+
static constexpr int16_t rare_style = -1;
|
|
929
|
+
#elif GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
403
930
|
// Compiler-driven hot placement: the rare fields live inline (direct load, same cache
|
|
404
931
|
// line — spine's access pattern), no rstyle() pool indirection per node. rare_style is
|
|
405
932
|
// kept but vestigial (always -1) so pool-handle call sites compile as harmless no-ops;
|
|
@@ -483,7 +1010,10 @@ struct ComputedStyle {
|
|
|
483
1010
|
// RareStyle split moved transform/gradient fields off the hot ComputedStyle struct, so
|
|
484
1011
|
// every `style.transform_*` read became a function call. The static local is one shared
|
|
485
1012
|
// instance across TUs (inline-function rule); rstyleMut/release/reset (style.cpp) use it.
|
|
486
|
-
#if
|
|
1013
|
+
#if !GEA_CSS_RARE_STYLE
|
|
1014
|
+
inline constexpr RareStyle kRareStyleZero{};
|
|
1015
|
+
inline const RareStyle &rstyle(const ComputedStyle &style) { (void)style; return kRareStyleZero; }
|
|
1016
|
+
#elif GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
487
1017
|
// Inline-embedded rare fields: rstyle() is a direct member access — no pool, no branch, no
|
|
488
1018
|
// separate cache line (spine's access pattern). rstyleMut/release/reset are still defined
|
|
489
1019
|
// out-of-line in style.cpp (their bodies #if'd) because rstyleMut also invalidates the
|
|
@@ -519,12 +1049,19 @@ inline bool styleHasBackgroundImage(const ComputedStyle &style)
|
|
|
519
1049
|
inline constexpr int kInheritedBorderWidth = -1;
|
|
520
1050
|
inline int computedBorderWidth(const ComputedStyle &style, int side)
|
|
521
1051
|
{
|
|
1052
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
522
1053
|
const int specific = rstyle(style).border_side_width[side];
|
|
523
1054
|
return specific > style.border_width ? specific : style.border_width;
|
|
1055
|
+
#else
|
|
1056
|
+
(void)side;
|
|
1057
|
+
return style.border_width;
|
|
1058
|
+
#endif
|
|
524
1059
|
}
|
|
525
1060
|
|
|
526
1061
|
inline bool setComputedBorderWidth(ComputedStyle &style, int side, int value, const ComputedStyle *parent)
|
|
527
1062
|
{
|
|
1063
|
+
#if GEA_CSS_BORDER_WIDTHS
|
|
1064
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
528
1065
|
int widths[4];
|
|
529
1066
|
for (int i = 0; i < 4; ++i) {
|
|
530
1067
|
widths[i] = computedBorderWidth(style, i);
|
|
@@ -550,11 +1087,24 @@ inline bool setComputedBorderWidth(ComputedStyle &style, int side, int value, co
|
|
|
550
1087
|
for (int i = 0; i < 4; ++i) rare.border_side_width[i] = stored[i];
|
|
551
1088
|
}
|
|
552
1089
|
return true;
|
|
1090
|
+
#else
|
|
1091
|
+
if (side >= 0) return false;
|
|
1092
|
+
const int width = value == kInheritedBorderWidth ? (parent ? parent->border_width : 0) : value;
|
|
1093
|
+
if (width == style.border_width) return false;
|
|
1094
|
+
style.border_width = width;
|
|
1095
|
+
return true;
|
|
1096
|
+
#endif
|
|
1097
|
+
#else
|
|
1098
|
+
(void)style; (void)side; (void)value; (void)parent;
|
|
1099
|
+
return false;
|
|
1100
|
+
#endif
|
|
553
1101
|
}
|
|
554
1102
|
|
|
555
1103
|
inline bool setBorderColorBinding(ComputedStyle &style, int side, bool current)
|
|
556
1104
|
{
|
|
557
|
-
|
|
1105
|
+
#if GEA_CSS_BORDER_COLORS
|
|
1106
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
1107
|
+
const unsigned previous = style.border_color_flags;
|
|
558
1108
|
unsigned next;
|
|
559
1109
|
if (side < 0) next = current ? 0u : 16u; // shorthand resets every side
|
|
560
1110
|
else {
|
|
@@ -563,52 +1113,89 @@ inline bool setBorderColorBinding(ComputedStyle &style, int side, bool current)
|
|
|
563
1113
|
else next &= ~(1u << (side + 5));
|
|
564
1114
|
}
|
|
565
1115
|
if (next == previous) return false;
|
|
566
|
-
|
|
1116
|
+
style.border_color_flags = static_cast<uint16_t>(next);
|
|
567
1117
|
return true;
|
|
1118
|
+
#else
|
|
1119
|
+
if (side >= 0) return false;
|
|
1120
|
+
const unsigned next = current ? 0u : 16u;
|
|
1121
|
+
if (next == style.border_color_flags) return false;
|
|
1122
|
+
style.border_color_flags = static_cast<uint16_t>(next);
|
|
1123
|
+
return true;
|
|
1124
|
+
#endif
|
|
1125
|
+
#else
|
|
1126
|
+
(void)style; (void)side; (void)current;
|
|
1127
|
+
return false;
|
|
1128
|
+
#endif
|
|
568
1129
|
}
|
|
569
1130
|
|
|
570
1131
|
inline bool borderColorIsCurrent(const ComputedStyle &style, int side = -1)
|
|
571
1132
|
{
|
|
572
|
-
|
|
1133
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
1134
|
+
const unsigned flags = style.border_color_flags;
|
|
573
1135
|
if (side >= 0 && (flags & (1u << side))) return flags & (1u << (side + 5));
|
|
574
1136
|
return !(flags & 16u);
|
|
1137
|
+
#else
|
|
1138
|
+
(void)side;
|
|
1139
|
+
return !(style.border_color_flags & 16u);
|
|
1140
|
+
#endif
|
|
575
1141
|
}
|
|
576
1142
|
|
|
577
1143
|
inline style_color_t borderPaintColor(const ComputedStyle &style, int side = -1)
|
|
578
1144
|
{
|
|
1145
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
579
1146
|
if (borderColorIsCurrent(style, side)) return style.text_color;
|
|
580
|
-
return side >= 0 && (
|
|
1147
|
+
return side >= 0 && (style.border_color_flags & (1u << side))
|
|
581
1148
|
? rstyle(style).border_side_color[side] : style.border_color;
|
|
1149
|
+
#else
|
|
1150
|
+
return borderColorIsCurrent(style, side) ? style.text_color : style.border_color;
|
|
1151
|
+
#endif
|
|
582
1152
|
}
|
|
583
1153
|
|
|
584
1154
|
inline uint8_t borderPaintAlpha(const ComputedStyle &style, int side = -1)
|
|
585
1155
|
{
|
|
1156
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
586
1157
|
if (borderColorIsCurrent(style, side)) return style.text_alpha;
|
|
587
|
-
return side >= 0 && (
|
|
1158
|
+
return side >= 0 && (style.border_color_flags & (1u << side))
|
|
588
1159
|
? rstyle(style).border_side_alpha[side] : style.border_alpha;
|
|
1160
|
+
#else
|
|
1161
|
+
return borderColorIsCurrent(style, side) ? style.text_alpha : style.border_alpha;
|
|
1162
|
+
#endif
|
|
589
1163
|
}
|
|
590
1164
|
|
|
591
1165
|
inline bool borderColorsDiffer(const ComputedStyle &style)
|
|
592
1166
|
{
|
|
1167
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
593
1168
|
for (int side = 1; side < 4; ++side)
|
|
594
1169
|
if (borderPaintColor(style, side) != borderPaintColor(style, 0) ||
|
|
595
1170
|
borderPaintAlpha(style, side) != borderPaintAlpha(style, 0)) return true;
|
|
596
1171
|
return false;
|
|
1172
|
+
#else
|
|
1173
|
+
(void)style;
|
|
1174
|
+
return false;
|
|
1175
|
+
#endif
|
|
597
1176
|
}
|
|
598
1177
|
|
|
599
1178
|
inline bool borderUsesCurrentColor(const ComputedStyle &style)
|
|
600
1179
|
{
|
|
1180
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
601
1181
|
for (int side = 0; side < 4; ++side)
|
|
602
1182
|
if ((style.border_width > 0 || rstyle(style).border_side_width[side] > 0) && borderColorIsCurrent(style, side)) return true;
|
|
603
1183
|
return false;
|
|
1184
|
+
#else
|
|
1185
|
+
return style.border_width > 0 && borderColorIsCurrent(style);
|
|
1186
|
+
#endif
|
|
604
1187
|
}
|
|
605
1188
|
|
|
606
1189
|
// Layout boxes include padding and borders. CSS width/height can select either
|
|
607
1190
|
// the content box or border box, but child origins always use these insets.
|
|
608
1191
|
inline int boxInset(const ComputedStyle &style, int side)
|
|
609
1192
|
{
|
|
1193
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
610
1194
|
const int sideWidth = rstyle(style).border_side_width[side];
|
|
611
1195
|
return style.padding[side] + (sideWidth > style.border_width ? sideWidth : style.border_width);
|
|
1196
|
+
#else
|
|
1197
|
+
return style.padding[side] + style.border_width;
|
|
1198
|
+
#endif
|
|
612
1199
|
}
|
|
613
1200
|
inline int boxInsets(const ComputedStyle &style, bool horizontal)
|
|
614
1201
|
{
|
|
@@ -640,7 +1227,7 @@ inline bool isDisplayNone(const ComputedStyle &style)
|
|
|
640
1227
|
|
|
641
1228
|
inline bool isDisplayGrid(const ComputedStyle &style)
|
|
642
1229
|
{
|
|
643
|
-
return style.display == kDisplayGrid;
|
|
1230
|
+
return GEA_CSS_GRID && style.display == kDisplayGrid;
|
|
644
1231
|
}
|
|
645
1232
|
|
|
646
1233
|
inline bool usesRowLayout(const ComputedStyle &style)
|
|
@@ -670,8 +1257,15 @@ inline int usedOverflow(int axis, int other)
|
|
|
670
1257
|
{
|
|
671
1258
|
return isScrollableOverflow(other) ? (axis == 0 ? 2 : axis == 3 ? 1 : axis) : axis;
|
|
672
1259
|
}
|
|
1260
|
+
#if GEA_CSS_OVERFLOW_AXES
|
|
673
1261
|
inline int overflowX(const ComputedStyle &style) { return usedOverflow(style.overflow_x, style.overflow_y); }
|
|
674
1262
|
inline int overflowY(const ComputedStyle &style) { return usedOverflow(style.overflow_y, style.overflow_x); }
|
|
1263
|
+
#else
|
|
1264
|
+
// A single-axis shorthand gives both axes exactly this value. The existing
|
|
1265
|
+
// helpers become one direct field read, with no axis-coupling computation.
|
|
1266
|
+
inline int overflowX(const ComputedStyle &style) { return style.overflow; }
|
|
1267
|
+
inline int overflowY(const ComputedStyle &style) { return style.overflow; }
|
|
1268
|
+
#endif
|
|
675
1269
|
inline int8_t aggregateOverflow(int8_t overflowX, int8_t overflowY)
|
|
676
1270
|
{
|
|
677
1271
|
const int x = usedOverflow(overflowX, overflowY), y = usedOverflow(overflowY, overflowX);
|
|
@@ -686,23 +1280,49 @@ inline bool overflowEstablishesContext(const ComputedStyle &style)
|
|
|
686
1280
|
// Grouping effects force the used transform-style to flat.
|
|
687
1281
|
inline bool preserves3D(const ComputedStyle &style)
|
|
688
1282
|
{
|
|
1283
|
+
#if GEA_CSS_TRANSFORMS
|
|
689
1284
|
const auto &rare = rstyle(style);
|
|
690
1285
|
return rare.transform_preserve_3d && style.opacity == 255 &&
|
|
691
1286
|
!isScrollableOverflow(overflowX(style)) && !isScrollableOverflow(overflowY(style)) &&
|
|
692
1287
|
!rare.filter_present && !rare.filter_blur_radius && !(rare.containment & 16) &&
|
|
693
1288
|
!style.mask_right_fade_width;
|
|
1289
|
+
#else
|
|
1290
|
+
(void)style;
|
|
1291
|
+
return false;
|
|
1292
|
+
#endif
|
|
1293
|
+
}
|
|
1294
|
+
inline bool scrollsOverflowX(const ComputedStyle &style)
|
|
1295
|
+
{
|
|
1296
|
+
#if GEA_CSS_SCROLLING
|
|
1297
|
+
return overflowX(style) == 2;
|
|
1298
|
+
#else
|
|
1299
|
+
(void)style;
|
|
1300
|
+
return false;
|
|
1301
|
+
#endif
|
|
1302
|
+
}
|
|
1303
|
+
inline bool scrollsOverflowY(const ComputedStyle &style)
|
|
1304
|
+
{
|
|
1305
|
+
#if GEA_CSS_SCROLLING
|
|
1306
|
+
return overflowY(style) == 2;
|
|
1307
|
+
#else
|
|
1308
|
+
(void)style;
|
|
1309
|
+
return false;
|
|
1310
|
+
#endif
|
|
694
1311
|
}
|
|
695
|
-
inline bool scrollsOverflowX(const ComputedStyle &style) { return overflowX(style) == 2; }
|
|
696
|
-
inline bool scrollsOverflowY(const ComputedStyle &style) { return overflowY(style) == 2; }
|
|
697
1312
|
|
|
698
1313
|
inline bool hasSideBorder(const ComputedStyle &style)
|
|
699
1314
|
{
|
|
1315
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
700
1316
|
if (style.rare_style < 0) return false; // no RareStyle => no per-side borders
|
|
701
1317
|
const RareStyle &r = rstyle(style);
|
|
702
1318
|
return r.border_side_width[0] > 0 ||
|
|
703
1319
|
r.border_side_width[1] > 0 ||
|
|
704
1320
|
r.border_side_width[2] > 0 ||
|
|
705
1321
|
r.border_side_width[3] > 0;
|
|
1322
|
+
#else
|
|
1323
|
+
(void)style;
|
|
1324
|
+
return false;
|
|
1325
|
+
#endif
|
|
706
1326
|
}
|
|
707
1327
|
|
|
708
1328
|
inline bool hasAnyBorder(const ComputedStyle &style)
|
|
@@ -716,9 +1336,12 @@ inline bool hasBorderRelief(const ComputedStyle &style)
|
|
|
716
1336
|
return r.border_relief[0] || r.border_relief[1] || r.border_relief[2] || r.border_relief[3];
|
|
717
1337
|
}
|
|
718
1338
|
|
|
1339
|
+
#ifndef GEA_EMBEDDED_SHARED_STYLES
|
|
1340
|
+
#define GEA_EMBEDDED_SHARED_STYLES 0
|
|
1341
|
+
#endif
|
|
1342
|
+
|
|
719
1343
|
struct LayoutBox {
|
|
720
1344
|
int16_t x, y;
|
|
721
|
-
int32_t width_expression, height_expression;
|
|
722
1345
|
int16_t width, height;
|
|
723
1346
|
|
|
724
1347
|
// Inline formatting: x offset, inside this box's content area, at which the
|
|
@@ -732,8 +1355,9 @@ struct LayoutBox {
|
|
|
732
1355
|
// The hypothetical block-start margin edge of an out-of-flow child,
|
|
733
1356
|
// relative to its static-position parent. Capture before relative offsets
|
|
734
1357
|
// and absolute-coordinate conversion; retained refresh reuses this anchor.
|
|
1358
|
+
#if !GEA_EMBEDDED_SHARED_STYLES
|
|
735
1359
|
int16_t static_block_start = 0;
|
|
736
|
-
|
|
1360
|
+
#endif
|
|
737
1361
|
|
|
738
1362
|
int16_t previous_x, previous_y;
|
|
739
1363
|
int16_t previous_width, previous_height;
|
|
@@ -742,12 +1366,21 @@ struct LayoutBox {
|
|
|
742
1366
|
// content height of itemCount * rowHeight (e.g. 5000 * 259 ≈ 1.29M px),
|
|
743
1367
|
// which overflows int16_t. Truncation made scroll_content_height wrap
|
|
744
1368
|
// negative, so scrollMaxY clamped to 0 and the list refused to scroll.
|
|
1369
|
+
#if GEA_CSS_SCROLLING
|
|
745
1370
|
int32_t scroll_x;
|
|
746
1371
|
int32_t scroll_y;
|
|
747
1372
|
int32_t scroll_content_width;
|
|
748
1373
|
int32_t scroll_content_height;
|
|
749
1374
|
int32_t previous_scroll_x;
|
|
750
1375
|
int32_t previous_scroll_y;
|
|
1376
|
+
#else
|
|
1377
|
+
static constexpr int32_t scroll_x = 0;
|
|
1378
|
+
static constexpr int32_t scroll_y = 0;
|
|
1379
|
+
static constexpr int32_t scroll_content_width = 0;
|
|
1380
|
+
static constexpr int32_t scroll_content_height = 0;
|
|
1381
|
+
static constexpr int32_t previous_scroll_x = 0;
|
|
1382
|
+
static constexpr int32_t previous_scroll_y = 0;
|
|
1383
|
+
#endif
|
|
751
1384
|
|
|
752
1385
|
// Intra-pass layout memo: the flex engine re-measures whole subtrees after
|
|
753
1386
|
// every parent resize (repositionChildren -> measureChildren -> layoutNode),
|
|
@@ -755,27 +1388,22 @@ struct LayoutBox {
|
|
|
755
1388
|
// node already laid out THIS pass with the same available box. Two slots
|
|
756
1389
|
// (MRU order) because flex items alternate between the parent's measure
|
|
757
1390
|
// avail and their basis/grown avail — a single slot thrashes on exactly
|
|
758
|
-
// that pattern.
|
|
759
|
-
// so
|
|
760
|
-
//
|
|
761
|
-
//
|
|
762
|
-
//
|
|
763
|
-
//
|
|
764
|
-
|
|
765
|
-
// byte-identical — child avails derive from the node's own box).
|
|
1391
|
+
// that pattern. Both hit-validity bytes live in scratch cleared on every
|
|
1392
|
+
// beginLayoutPass(), so there is no generation counter or rollover scan.
|
|
1393
|
+
// Only the last available box and its validity survive the pass: scoped
|
|
1394
|
+
// relayout and absolute containing blocks need them across frames. The
|
|
1395
|
+
// legacy memo_pass field stores that validity (0 or 1), not a generation.
|
|
1396
|
+
// Result dimensions and the second available box remain pass-local.
|
|
1397
|
+
#if !GEA_EMBEDDED_SHARED_STYLES
|
|
766
1398
|
int16_t memo_avail_w;
|
|
767
1399
|
int16_t memo_avail_h;
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
int16_t memo2_avail_w;
|
|
772
|
-
int16_t memo2_avail_h;
|
|
773
|
-
int16_t memo2_result_w;
|
|
774
|
-
int16_t memo2_result_h;
|
|
775
|
-
uint32_t memo2_pass;
|
|
1400
|
+
uint16_t memo_pass;
|
|
1401
|
+
uint8_t static_block_axis = 0; // 0: unavailable, 1: y, 2: x
|
|
1402
|
+
#endif
|
|
776
1403
|
};
|
|
777
1404
|
|
|
778
1405
|
struct RenderState {
|
|
1406
|
+
#if GEA_CSS_TRANSFORMS
|
|
779
1407
|
int16_t previous_rotate_angle;
|
|
780
1408
|
int32_t previous_rotate_axis_x, previous_rotate_axis_y, previous_rotate_axis_z;
|
|
781
1409
|
int16_t previous_scale_x, previous_scale_y, previous_scale_z;
|
|
@@ -799,46 +1427,96 @@ struct RenderState {
|
|
|
799
1427
|
int16_t previous_perspective_origin_x;
|
|
800
1428
|
int16_t previous_perspective_origin_y;
|
|
801
1429
|
uint8_t previous_transformable_box;
|
|
1430
|
+
#else
|
|
1431
|
+
static constexpr int16_t previous_rotate_angle = 0;
|
|
1432
|
+
static constexpr int32_t previous_rotate_axis_x = 0;
|
|
1433
|
+
static constexpr int32_t previous_rotate_axis_y = 0;
|
|
1434
|
+
static constexpr int32_t previous_rotate_axis_z = 1000000;
|
|
1435
|
+
static constexpr int16_t previous_scale_x = 1000;
|
|
1436
|
+
static constexpr int16_t previous_scale_y = 1000;
|
|
1437
|
+
static constexpr int16_t previous_scale_z = 1000;
|
|
1438
|
+
static constexpr int16_t previous_transform_rotate = 0;
|
|
1439
|
+
static constexpr int16_t previous_transform_rotate_x = 0;
|
|
1440
|
+
static constexpr int16_t previous_transform_rotate_y = 0;
|
|
1441
|
+
static constexpr int16_t previous_translate_x = 0;
|
|
1442
|
+
static constexpr int16_t previous_translate_y = 0;
|
|
1443
|
+
static constexpr int16_t previous_translate_z = 0;
|
|
1444
|
+
static constexpr int16_t previous_translate_x_percent = 0;
|
|
1445
|
+
static constexpr int16_t previous_translate_y_percent = 0;
|
|
1446
|
+
static constexpr uint8_t previous_transform_translate_outer_axes = 0;
|
|
1447
|
+
static constexpr int32_t previous_transform_translate_x = 0;
|
|
1448
|
+
static constexpr int32_t previous_transform_translate_y = 0;
|
|
1449
|
+
static constexpr int32_t previous_transform_translate_z = 0;
|
|
1450
|
+
static constexpr int32_t previous_transform_translate_x_percent = 0;
|
|
1451
|
+
static constexpr int32_t previous_transform_translate_y_percent = 0;
|
|
1452
|
+
static constexpr int16_t previous_transform_scale_x = 1000;
|
|
1453
|
+
static constexpr int16_t previous_transform_scale_y = 1000;
|
|
1454
|
+
static constexpr int16_t previous_transform_scale_z = 1000;
|
|
1455
|
+
static constexpr int16_t previous_transform_origin_x = 500;
|
|
1456
|
+
static constexpr int16_t previous_transform_origin_y = 500;
|
|
1457
|
+
static constexpr int16_t previous_perspective = 0;
|
|
1458
|
+
static constexpr int16_t previous_perspective_origin_x = 500;
|
|
1459
|
+
static constexpr int16_t previous_perspective_origin_y = 500;
|
|
1460
|
+
static constexpr uint8_t previous_transformable_box = 0;
|
|
1461
|
+
#endif
|
|
1462
|
+
#if GEA_CSS_FILTERS
|
|
802
1463
|
int16_t previous_filter_blur_radius;
|
|
1464
|
+
#else
|
|
1465
|
+
static constexpr int16_t previous_filter_blur_radius = 0;
|
|
1466
|
+
#endif
|
|
803
1467
|
|
|
804
|
-
uint8_t dirty;
|
|
805
|
-
|
|
806
|
-
uint8_t
|
|
1468
|
+
uint8_t dirty : 1;
|
|
1469
|
+
#if GEA_CSS_SCROLLING
|
|
1470
|
+
uint8_t scroll_dirty : 1;
|
|
1471
|
+
#else
|
|
1472
|
+
static constexpr uint8_t scroll_dirty = 0;
|
|
1473
|
+
#endif
|
|
1474
|
+
#if GEA_CSS_SCROLLING
|
|
1475
|
+
uint8_t non_scroll_dirty : 1;
|
|
1476
|
+
#else
|
|
1477
|
+
static constexpr uint8_t non_scroll_dirty = 0;
|
|
1478
|
+
#endif
|
|
807
1479
|
// Set alongside `dirty` when the change can affect GEOMETRY (layout
|
|
808
1480
|
// property, box-changing text, structural mutation). Paint-only dirt (a
|
|
809
1481
|
// background/color class toggle, stable-box text) leaves it clear, letting
|
|
810
1482
|
// the refresh skip the relayout pass entirely and letting the scoped
|
|
811
1483
|
// relayout compute its LCA over geometry-relevant nodes only. Cleared with
|
|
812
1484
|
// `dirty`.
|
|
813
|
-
uint8_t layout_dirty;
|
|
814
|
-
|
|
815
|
-
uint8_t
|
|
816
|
-
|
|
817
|
-
|
|
1485
|
+
uint8_t layout_dirty : 1;
|
|
1486
|
+
#if GEA_CSS_TRANSFORMS
|
|
1487
|
+
uint8_t transform_dirty : 1;
|
|
1488
|
+
#else
|
|
1489
|
+
static constexpr uint8_t transform_dirty = 0;
|
|
1490
|
+
#endif
|
|
1491
|
+
uint8_t bg_recolor_pending : 1;
|
|
818
1492
|
// Tree::setText pre-measures incoming text and sets this flag when the
|
|
819
1493
|
// update is safe for the retained/direct-replay path: absolute text may
|
|
820
1494
|
// update its measured bbox out of flow, while in-flow text must keep the
|
|
821
1495
|
// same layout box (e.g. fixed-width temperature readouts). Cleared on
|
|
822
1496
|
// LayoutSnapshot::capture() so it's always either freshly set by setText
|
|
823
1497
|
// in the current frame or absent.
|
|
824
|
-
uint8_t text_layout_stable;
|
|
1498
|
+
uint8_t text_layout_stable : 1;
|
|
825
1499
|
// Glyph-incremental text dirty (set by Tree::setText): when a content-only text
|
|
826
1500
|
// change keeps the same layout box and only a middle run of glyphs differs
|
|
827
1501
|
// (e.g. a ticking counter "58"->"57", a clock), the dirty collector flushes only
|
|
828
|
-
// [
|
|
1502
|
+
// [text_dirty.x0, text_dirty.x1] across the node's height instead of the whole
|
|
829
1503
|
// box. A 26vmin badge re-render then copies just the changed digits (~one glyph)
|
|
830
1504
|
// rather than ~the whole panel width, so it fits a TE-locked frame's slack.
|
|
831
1505
|
// Cleared with text_layout_stable each frame (LayoutSnapshot::capture).
|
|
832
|
-
uint8_t text_partial_dirty;
|
|
833
|
-
int16_t text_dirty_x0;
|
|
834
|
-
int16_t text_dirty_x1;
|
|
1506
|
+
uint8_t text_partial_dirty : 1;
|
|
835
1507
|
// This box SHARES a line box with other inline content, so it was placed on
|
|
836
1508
|
// that line's baseline (FlexLayoutPass::placeLineItems). TextRenderer::record
|
|
837
1509
|
// then draws the run at its baseline instead of centring the string's ink in
|
|
838
1510
|
// the line advance: ink centring shifts by however far that particular string's
|
|
839
1511
|
// glyphs reach, so runs of different words — or different fonts — on one line
|
|
840
1512
|
// end up at different heights. A run that owns its line keeps the centring.
|
|
841
|
-
uint8_t inline_baseline;
|
|
1513
|
+
uint8_t inline_baseline : 1;
|
|
1514
|
+
// Only one paint shortcut may own this scratch space. Mixed changes use
|
|
1515
|
+
// the ordinary dirty-region replay. The recolor destination is bg_color.
|
|
1516
|
+
union {
|
|
1517
|
+
style_color_t bg_recolor_from;
|
|
1518
|
+
struct { int16_t x0, x1; } text_dirty;
|
|
1519
|
+
};
|
|
842
1520
|
};
|
|
843
1521
|
|
|
844
1522
|
inline bool hadIndividualLinearTransform(const RenderState &s)
|
|
@@ -847,45 +1525,87 @@ inline bool hadIndividualLinearTransform(const RenderState &s)
|
|
|
847
1525
|
s.previous_scale_x != 1000 || s.previous_scale_y != 1000 || s.previous_scale_z != 1000;
|
|
848
1526
|
}
|
|
849
1527
|
|
|
1528
|
+
// A/B experiment only; the default keeps the existing native Node.style API.
|
|
1529
|
+
#if GEA_EMBEDDED_SHARED_STYLES
|
|
1530
|
+
struct SharedStyleRecord {
|
|
1531
|
+
ComputedStyle value;
|
|
1532
|
+
uint32_t references;
|
|
1533
|
+
SharedStyleRecord *next;
|
|
1534
|
+
};
|
|
1535
|
+
class NodeStyleStorage {
|
|
1536
|
+
SharedStyleRecord *record_;
|
|
1537
|
+
ComputedStyle &detach();
|
|
1538
|
+
public:
|
|
1539
|
+
NodeStyleStorage();
|
|
1540
|
+
~NodeStyleStorage();
|
|
1541
|
+
NodeStyleStorage(const NodeStyleStorage &other);
|
|
1542
|
+
NodeStyleStorage &operator=(const NodeStyleStorage &other);
|
|
1543
|
+
NodeStyleStorage(NodeStyleStorage &&other) noexcept;
|
|
1544
|
+
NodeStyleStorage &operator=(NodeStyleStorage &&other) noexcept;
|
|
1545
|
+
const ComputedStyle &read() const { return record_->value; }
|
|
1546
|
+
ComputedStyle &write() {
|
|
1547
|
+
if (record_->references == 1) return record_->value;
|
|
1548
|
+
return detach();
|
|
1549
|
+
}
|
|
1550
|
+
void reset();
|
|
1551
|
+
void intern();
|
|
1552
|
+
static std::size_t allocatedBytes();
|
|
1553
|
+
static std::size_t allocatedRecords();
|
|
1554
|
+
static std::size_t allocatedHeapBytes();
|
|
1555
|
+
};
|
|
1556
|
+
#endif
|
|
1557
|
+
|
|
850
1558
|
struct Node {
|
|
851
|
-
|
|
852
|
-
|
|
1559
|
+
#if GEA_EMBEDDED_SHARED_STYLES
|
|
1560
|
+
NodeStyleStorage sharedStyle_;
|
|
1561
|
+
// Group the four-byte ownership handles before the two-byte fields.
|
|
1562
|
+
NodeText text;
|
|
1563
|
+
const ComputedStyle &computedStyle() const { return sharedStyle_.read(); }
|
|
1564
|
+
ComputedStyle &mutableStyle() { return sharedStyle_.write(); }
|
|
1565
|
+
void resetComputedStyle() { sharedStyle_.reset(); }
|
|
1566
|
+
void internComputedStyle() { sharedStyle_.intern(); }
|
|
1567
|
+
#else
|
|
1568
|
+
[[no_unique_address]] ComputedStyle style;
|
|
1569
|
+
const ComputedStyle &computedStyle() const { return style; }
|
|
1570
|
+
ComputedStyle &mutableStyle() { return style; }
|
|
1571
|
+
void resetComputedStyle();
|
|
1572
|
+
void internComputedStyle() {}
|
|
1573
|
+
#endif
|
|
1574
|
+
// Interned tag id; zero is the empty tag. Fits in style's tail padding
|
|
1575
|
+
// when the source proof removes the unused alpha fields.
|
|
1576
|
+
int16_t tag_id = 0;
|
|
853
1577
|
|
|
854
1578
|
int16_t parent;
|
|
855
1579
|
int16_t first_child, last_child;
|
|
856
1580
|
int16_t next_sibling, prev_sibling;
|
|
857
1581
|
|
|
858
|
-
//
|
|
859
|
-
//
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
//
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
std::string text;
|
|
1582
|
+
// Index into the shared pool for optional listeners/attributes/styles.
|
|
1583
|
+
// -1 means absent and is restored by Node{} / node reuse.
|
|
1584
|
+
int16_t rare_data = -1;
|
|
1585
|
+
#if !GEA_EMBEDDED_SHARED_STYLES
|
|
1586
|
+
// Empty structural nodes retain only the four-byte text ownership handle.
|
|
1587
|
+
NodeText text;
|
|
1588
|
+
#endif
|
|
1589
|
+
#if GEA_UI_IMAGE_NODES
|
|
867
1590
|
int16_t image_id;
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
1591
|
+
#else
|
|
1592
|
+
static constexpr int16_t image_id = -1;
|
|
1593
|
+
#endif
|
|
1594
|
+
[[no_unique_address]] LayoutBox layout;
|
|
1595
|
+
NodeType type;
|
|
1596
|
+
#if GEA_EMBEDDED_SHARED_STYLES && !GEA_CSS_CUSTOM_PROPERTIES
|
|
1597
|
+
// Occupies the alignment byte before RenderState, with direct field access.
|
|
1598
|
+
// No separate per-node dependency array is needed when variables are absent.
|
|
1599
|
+
bool class_style_tracked = false;
|
|
1600
|
+
#endif
|
|
875
1601
|
RenderState render;
|
|
876
|
-
|
|
877
|
-
// Blink-style "rare data" handle: index into the shared NodeRareData pool for
|
|
878
|
-
// the cold/optional per-node state most nodes never have (event listeners, and
|
|
879
|
-
// later attributes/custom-properties/etc.). -1 = none, so the common node pays
|
|
880
|
-
// 2 bytes instead of inlining those tables. Reset to -1 by Node{} / node reuse.
|
|
881
|
-
int16_t rare_data = -1;
|
|
882
1602
|
};
|
|
883
1603
|
|
|
884
1604
|
// Overflow clips the padding edge on each non-visible axis. Open axes span
|
|
885
1605
|
// the positive display coordinate range and remain stationary during replay.
|
|
886
1606
|
inline void overflowClipBounds(const Node &node, int &x, int &y, int &w, int &h)
|
|
887
1607
|
{
|
|
888
|
-
const auto &s = node.
|
|
1608
|
+
const auto &s = node.computedStyle();
|
|
889
1609
|
const int left = boxInset(s, 3) - s.padding[3], right = boxInset(s, 1) - s.padding[1];
|
|
890
1610
|
const int top = boxInset(s, 0) - s.padding[0], bottom = boxInset(s, 2) - s.padding[2];
|
|
891
1611
|
x = overflowX(s) ? node.layout.x + left : 0;
|