@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
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
// Custom-property containers and dependency caches need whole-source proof.
|
|
5
|
+
#ifndef GEA_CSS_CUSTOM_PROPERTIES
|
|
6
|
+
#define GEA_CSS_CUSTOM_PROPERTIES 1
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
// v17 default-field reachability facts; only a whole-source proof disables them.
|
|
10
|
+
#ifndef GEA_CSS_MARGINS
|
|
11
|
+
#define GEA_CSS_MARGINS 1
|
|
12
|
+
#endif
|
|
13
|
+
#ifndef GEA_CSS_PADDING
|
|
14
|
+
#define GEA_CSS_PADDING 1
|
|
15
|
+
#endif
|
|
16
|
+
#ifndef GEA_CSS_FLEX_FACTORS
|
|
17
|
+
#define GEA_CSS_FLEX_FACTORS 1
|
|
18
|
+
#endif
|
|
19
|
+
#ifndef GEA_CSS_GAP
|
|
20
|
+
#define GEA_CSS_GAP 1
|
|
21
|
+
#endif
|
|
22
|
+
#ifndef GEA_CSS_BORDER_WIDTHS
|
|
23
|
+
#define GEA_CSS_BORDER_WIDTHS 1
|
|
24
|
+
#endif
|
|
25
|
+
#ifndef GEA_CSS_BORDER_COLORS
|
|
26
|
+
#define GEA_CSS_BORDER_COLORS 1
|
|
27
|
+
#endif
|
|
28
|
+
#ifndef GEA_CSS_FONT_WEIGHT
|
|
29
|
+
#define GEA_CSS_FONT_WEIGHT 1
|
|
30
|
+
#endif
|
|
31
|
+
#ifndef GEA_CSS_TEXT_ALIGN
|
|
32
|
+
#define GEA_CSS_TEXT_ALIGN 1
|
|
33
|
+
#endif
|
|
34
|
+
#ifndef GEA_CSS_WHITE_SPACE
|
|
35
|
+
#define GEA_CSS_WHITE_SPACE 1
|
|
36
|
+
#endif
|
|
37
|
+
#ifndef GEA_CSS_TEXT_OVERFLOW
|
|
38
|
+
#define GEA_CSS_TEXT_OVERFLOW 1
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
// v16 common-style reachability facts. Unknown builds keep native defaults.
|
|
42
|
+
#ifndef GEA_CSS_FLEX_DIRECTION
|
|
43
|
+
#define GEA_CSS_FLEX_DIRECTION 1
|
|
44
|
+
#endif
|
|
45
|
+
#ifndef GEA_CSS_JUSTIFY_CONTENT
|
|
46
|
+
#define GEA_CSS_JUSTIFY_CONTENT 1
|
|
47
|
+
#endif
|
|
48
|
+
#ifndef GEA_CSS_ALIGN_ITEMS
|
|
49
|
+
#define GEA_CSS_ALIGN_ITEMS 1
|
|
50
|
+
#endif
|
|
51
|
+
#ifndef GEA_CSS_BOX_SIZING
|
|
52
|
+
#define GEA_CSS_BOX_SIZING 1
|
|
53
|
+
#endif
|
|
54
|
+
#ifndef GEA_CSS_MARGIN_AUTO
|
|
55
|
+
#define GEA_CSS_MARGIN_AUTO 1
|
|
56
|
+
#endif
|
|
57
|
+
#ifndef GEA_CSS_LINE_HEIGHT_MULTIPLIER
|
|
58
|
+
#define GEA_CSS_LINE_HEIGHT_MULTIPLIER 1
|
|
59
|
+
#endif
|
|
60
|
+
// Automatic whole-source percentage reachability. Older builds retain fields.
|
|
61
|
+
#ifndef GEA_CSS_WIDTH_PERCENT
|
|
62
|
+
#define GEA_CSS_WIDTH_PERCENT 1
|
|
63
|
+
#endif
|
|
64
|
+
#ifndef GEA_CSS_HEIGHT_PERCENT
|
|
65
|
+
#define GEA_CSS_HEIGHT_PERCENT 1
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#ifndef GEA_CSS_WIDTH_EXPRESSIONS
|
|
69
|
+
#define GEA_CSS_WIDTH_EXPRESSIONS 1
|
|
70
|
+
#endif
|
|
71
|
+
#ifndef GEA_CSS_MIN_HEIGHT
|
|
72
|
+
#define GEA_CSS_MIN_HEIGHT 1
|
|
73
|
+
#endif
|
|
74
|
+
#ifndef GEA_CSS_MAX_WIDTH
|
|
75
|
+
#define GEA_CSS_MAX_WIDTH 1
|
|
76
|
+
#endif
|
|
77
|
+
#ifndef GEA_CSS_ACTIVE_BACKGROUND
|
|
78
|
+
#define GEA_CSS_ACTIVE_BACKGROUND 1
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
#ifndef GEA_CSS_PSEUDO_ELEMENTS
|
|
83
|
+
#define GEA_CSS_PSEUDO_ELEMENTS 1
|
|
84
|
+
#endif
|
|
85
|
+
|
|
86
|
+
// Opaque/default colour proof, generated from the complete source graph.
|
|
87
|
+
#ifndef GEA_CSS_TEXT_ALPHA
|
|
88
|
+
#define GEA_CSS_TEXT_ALPHA 1
|
|
89
|
+
#endif
|
|
90
|
+
#ifndef GEA_CSS_BORDER_ALPHA
|
|
91
|
+
#define GEA_CSS_BORDER_ALPHA 1
|
|
92
|
+
#endif
|
|
93
|
+
|
|
94
|
+
// Whole-source animation reachability; older/opaque builds retain support.
|
|
95
|
+
#ifndef GEA_CSS_ANIMATIONS
|
|
96
|
+
#define GEA_CSS_ANIMATIONS 1
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
// Build-generated reachability facts. The application does not configure these.
|
|
100
|
+
// A driver without CSS analysis retains every feature. All translation units
|
|
101
|
+
// must receive the same facts, because they specialize per-node storage too.
|
|
102
|
+
#ifndef GEA_CSS_TRANSFORMS
|
|
103
|
+
#define GEA_CSS_TRANSFORMS 1
|
|
104
|
+
#endif
|
|
105
|
+
#ifndef GEA_CSS_GRID
|
|
106
|
+
#define GEA_CSS_GRID 1
|
|
107
|
+
#endif
|
|
108
|
+
#ifndef GEA_CSS_FLOATS
|
|
109
|
+
#define GEA_CSS_FLOATS 1
|
|
110
|
+
#endif
|
|
111
|
+
#ifndef GEA_CSS_WRITING_MODE
|
|
112
|
+
#define GEA_CSS_WRITING_MODE 1
|
|
113
|
+
#endif
|
|
114
|
+
#ifndef GEA_CSS_PERCENT_RADIUS
|
|
115
|
+
#define GEA_CSS_PERCENT_RADIUS 1
|
|
116
|
+
#endif
|
|
117
|
+
#ifndef GEA_CSS_PERCENT_GAP
|
|
118
|
+
#define GEA_CSS_PERCENT_GAP 1
|
|
119
|
+
#endif
|
|
120
|
+
#ifndef GEA_CSS_BLINK
|
|
121
|
+
#define GEA_CSS_BLINK 1
|
|
122
|
+
#endif
|
|
123
|
+
#ifndef GEA_CSS_ORDER
|
|
124
|
+
#define GEA_CSS_ORDER 1
|
|
125
|
+
#endif
|
|
126
|
+
#ifndef GEA_CSS_BORDER_RELIEF
|
|
127
|
+
#define GEA_CSS_BORDER_RELIEF 1
|
|
128
|
+
#endif
|
|
129
|
+
|
|
130
|
+
#ifndef GEA_CSS_OPACITY
|
|
131
|
+
#define GEA_CSS_OPACITY 1
|
|
132
|
+
#endif
|
|
133
|
+
|
|
134
|
+
#ifndef GEA_CSS_TEXT_DECORATION
|
|
135
|
+
#define GEA_CSS_TEXT_DECORATION 1
|
|
136
|
+
#endif
|
|
137
|
+
|
|
138
|
+
#ifndef GEA_CSS_TEXT_TRANSFORM
|
|
139
|
+
#define GEA_CSS_TEXT_TRANSFORM 1
|
|
140
|
+
#endif
|
|
141
|
+
|
|
142
|
+
#ifndef GEA_CSS_VISIBILITY
|
|
143
|
+
#define GEA_CSS_VISIBILITY 1
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
#ifndef GEA_CSS_POINTER_EVENTS
|
|
147
|
+
#define GEA_CSS_POINTER_EVENTS 1
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
#ifndef GEA_CSS_MASK
|
|
151
|
+
#define GEA_CSS_MASK 1
|
|
152
|
+
#endif
|
|
153
|
+
|
|
154
|
+
#ifndef GEA_CSS_IMAGE_FIT
|
|
155
|
+
#define GEA_CSS_IMAGE_FIT 1
|
|
156
|
+
#endif
|
|
157
|
+
|
|
158
|
+
#ifndef GEA_CSS_FILTERS
|
|
159
|
+
#define GEA_CSS_FILTERS 1
|
|
160
|
+
#endif
|
|
161
|
+
|
|
162
|
+
#ifndef GEA_CSS_BOX_SHADOW
|
|
163
|
+
#define GEA_CSS_BOX_SHADOW 1
|
|
164
|
+
#endif
|
|
165
|
+
|
|
166
|
+
#ifndef GEA_CSS_FLEX_WRAP
|
|
167
|
+
#define GEA_CSS_FLEX_WRAP 1
|
|
168
|
+
#endif
|
|
169
|
+
|
|
170
|
+
#ifndef GEA_CSS_JUSTIFY_ITEMS
|
|
171
|
+
#define GEA_CSS_JUSTIFY_ITEMS 1
|
|
172
|
+
#endif
|
|
173
|
+
|
|
174
|
+
#ifndef GEA_CSS_ALIGN_CONTENT
|
|
175
|
+
#define GEA_CSS_ALIGN_CONTENT 1
|
|
176
|
+
#endif
|
|
177
|
+
|
|
178
|
+
#ifndef GEA_CSS_ALIGN_SELF
|
|
179
|
+
#define GEA_CSS_ALIGN_SELF 1
|
|
180
|
+
#endif
|
|
181
|
+
|
|
182
|
+
#ifndef GEA_CSS_MIN_WIDTH
|
|
183
|
+
#define GEA_CSS_MIN_WIDTH 1
|
|
184
|
+
#endif
|
|
185
|
+
|
|
186
|
+
#ifndef GEA_CSS_HEIGHT_EXPRESSIONS
|
|
187
|
+
#define GEA_CSS_HEIGHT_EXPRESSIONS 1
|
|
188
|
+
#endif
|
|
189
|
+
|
|
190
|
+
#ifndef GEA_CSS_Z_INDEX
|
|
191
|
+
#define GEA_CSS_Z_INDEX 1
|
|
192
|
+
#endif
|
|
193
|
+
|
|
194
|
+
#ifndef GEA_CSS_ASPECT_RATIO
|
|
195
|
+
#define GEA_CSS_ASPECT_RATIO 1
|
|
196
|
+
#endif
|
|
197
|
+
|
|
198
|
+
#ifndef GEA_CSS_MARGIN_TRIM
|
|
199
|
+
#define GEA_CSS_MARGIN_TRIM 1
|
|
200
|
+
#endif
|
|
201
|
+
|
|
202
|
+
#ifndef GEA_CSS_CONTAINMENT
|
|
203
|
+
#define GEA_CSS_CONTAINMENT 1
|
|
204
|
+
#endif
|
|
205
|
+
|
|
206
|
+
#ifndef GEA_CSS_JUSTIFY_SELF
|
|
207
|
+
#define GEA_CSS_JUSTIFY_SELF 1
|
|
208
|
+
#endif
|
|
209
|
+
|
|
210
|
+
#ifndef GEA_CSS_FLEX_LINE_COUNT
|
|
211
|
+
#define GEA_CSS_FLEX_LINE_COUNT 1
|
|
212
|
+
#endif
|
|
213
|
+
|
|
214
|
+
#ifndef GEA_CSS_BOX_EXPRESSIONS
|
|
215
|
+
#define GEA_CSS_BOX_EXPRESSIONS 1
|
|
216
|
+
#endif
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
#ifndef GEA_CSS_AXIS_GAP
|
|
220
|
+
#define GEA_CSS_AXIS_GAP 1
|
|
221
|
+
#endif
|
|
222
|
+
|
|
223
|
+
#ifndef GEA_CSS_CORNER_RADIUS
|
|
224
|
+
#define GEA_CSS_CORNER_RADIUS 1
|
|
225
|
+
#endif
|
|
226
|
+
|
|
227
|
+
// Uniform-corner applications retain a real array with a single element.
|
|
228
|
+
// Every index becomes the constant zero before C++ compilation: no accessor,
|
|
229
|
+
// branch, decoding or additional load. Arguments must be side-effect free.
|
|
230
|
+
#if GEA_CSS_CORNER_RADIUS
|
|
231
|
+
#define GEA_CSS_RADIUS_COUNT 4
|
|
232
|
+
#define GEA_CSS_RADIUS_INDEX(index) (index)
|
|
233
|
+
#else
|
|
234
|
+
#define GEA_CSS_RADIUS_COUNT 1
|
|
235
|
+
#define GEA_CSS_RADIUS_INDEX(index) 0
|
|
236
|
+
#endif
|
|
237
|
+
|
|
238
|
+
#ifndef GEA_CSS_FIRST_LINE
|
|
239
|
+
#define GEA_CSS_FIRST_LINE 1
|
|
240
|
+
#endif
|
|
241
|
+
|
|
242
|
+
#ifndef GEA_CSS_SIDE_BORDERS
|
|
243
|
+
#define GEA_CSS_SIDE_BORDERS 1
|
|
244
|
+
#endif
|
|
245
|
+
|
|
246
|
+
#ifndef GEA_CSS_BACKGROUND_LAYERS
|
|
247
|
+
#define GEA_CSS_BACKGROUND_LAYERS 1
|
|
248
|
+
#endif
|
|
249
|
+
|
|
250
|
+
#ifndef GEA_CSS_LINE_HEIGHT_EXPRESSIONS
|
|
251
|
+
#define GEA_CSS_LINE_HEIGHT_EXPRESSIONS 1
|
|
252
|
+
#endif
|
|
253
|
+
|
|
254
|
+
#ifndef GEA_CSS_SCROLLING
|
|
255
|
+
#define GEA_CSS_SCROLLING 1
|
|
256
|
+
#endif
|
|
257
|
+
|
|
258
|
+
#ifndef GEA_CSS_FLEX_BASIS_EXPRESSIONS
|
|
259
|
+
#define GEA_CSS_FLEX_BASIS_EXPRESSIONS 1
|
|
260
|
+
#endif
|
|
261
|
+
#ifndef GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
262
|
+
#define GEA_CSS_CUSTOM_PROPERTY_LENGTHS 1
|
|
263
|
+
#endif
|
|
264
|
+
|
|
265
|
+
#ifndef GEA_CSS_MAX_HEIGHT
|
|
266
|
+
#define GEA_CSS_MAX_HEIGHT 1
|
|
267
|
+
#endif
|
|
268
|
+
#ifndef GEA_CSS_FLEX_BASIS
|
|
269
|
+
#define GEA_CSS_FLEX_BASIS 1
|
|
270
|
+
#endif
|
|
271
|
+
#ifndef GEA_CSS_OVERFLOW_AXES
|
|
272
|
+
#define GEA_CSS_OVERFLOW_AXES 1
|
|
273
|
+
#endif
|
|
274
|
+
|
|
275
|
+
// Positive range proofs supplied by the build; unknown inputs retain 16 bits.
|
|
276
|
+
#ifndef GEA_CSS_U8_PADDING
|
|
277
|
+
#define GEA_CSS_U8_PADDING 0
|
|
278
|
+
#endif
|
|
279
|
+
#ifndef GEA_CSS_U8_GAP
|
|
280
|
+
#define GEA_CSS_U8_GAP 0
|
|
281
|
+
#endif
|
|
282
|
+
#ifndef GEA_CSS_U8_BORDER
|
|
283
|
+
#define GEA_CSS_U8_BORDER 0
|
|
284
|
+
#endif
|
|
285
|
+
#ifndef GEA_CSS_U8_RADIUS
|
|
286
|
+
#define GEA_CSS_U8_RADIUS 0
|
|
287
|
+
#endif
|
|
288
|
+
#ifndef GEA_CSS_U8_FONT
|
|
289
|
+
#define GEA_CSS_U8_FONT 0
|
|
290
|
+
#endif
|
|
291
|
+
#ifndef GEA_CSS_U8_LINE_HEIGHT
|
|
292
|
+
#define GEA_CSS_U8_LINE_HEIGHT 0
|
|
293
|
+
#endif
|
|
294
|
+
#ifndef GEA_CSS_U8_FLEX
|
|
295
|
+
#define GEA_CSS_U8_FLEX 0
|
|
296
|
+
#endif
|
|
297
|
+
|
|
298
|
+
#define GEA_CSS_U8_BORDER_FLAGS (!GEA_CSS_SIDE_BORDERS && (GEA_CSS_U8_PADDING || GEA_CSS_U8_GAP || GEA_CSS_U8_BORDER || GEA_CSS_U8_RADIUS || GEA_CSS_U8_FONT || GEA_CSS_U8_LINE_HEIGHT || GEA_CSS_U8_FLEX))
|
|
299
|
+
|
|
300
|
+
// Per-edge reachability. Opaque/older builds keep the original four-edge arrays.
|
|
301
|
+
#ifndef GEA_CSS_POSITION_TOP
|
|
302
|
+
#define GEA_CSS_POSITION_TOP 1
|
|
303
|
+
#endif
|
|
304
|
+
#ifndef GEA_CSS_POSITION_TOP_PERCENT
|
|
305
|
+
#define GEA_CSS_POSITION_TOP_PERCENT 1
|
|
306
|
+
#endif
|
|
307
|
+
#ifndef GEA_CSS_POSITION_RIGHT
|
|
308
|
+
#define GEA_CSS_POSITION_RIGHT 1
|
|
309
|
+
#endif
|
|
310
|
+
#ifndef GEA_CSS_POSITION_RIGHT_PERCENT
|
|
311
|
+
#define GEA_CSS_POSITION_RIGHT_PERCENT 1
|
|
312
|
+
#endif
|
|
313
|
+
#ifndef GEA_CSS_POSITION_BOTTOM
|
|
314
|
+
#define GEA_CSS_POSITION_BOTTOM 1
|
|
315
|
+
#endif
|
|
316
|
+
#ifndef GEA_CSS_POSITION_BOTTOM_PERCENT
|
|
317
|
+
#define GEA_CSS_POSITION_BOTTOM_PERCENT 1
|
|
318
|
+
#endif
|
|
319
|
+
#ifndef GEA_CSS_POSITION_LEFT
|
|
320
|
+
#define GEA_CSS_POSITION_LEFT 1
|
|
321
|
+
#endif
|
|
322
|
+
#ifndef GEA_CSS_POSITION_LEFT_PERCENT
|
|
323
|
+
#define GEA_CSS_POSITION_LEFT_PERCENT 1
|
|
324
|
+
#endif
|
|
325
|
+
|
|
326
|
+
#define GEA_CSS_POSITION_PX_ALL (GEA_CSS_POSITION_TOP && GEA_CSS_POSITION_RIGHT && GEA_CSS_POSITION_BOTTOM && GEA_CSS_POSITION_LEFT)
|
|
327
|
+
#if GEA_CSS_POSITION_PX_ALL
|
|
328
|
+
#define GEA_CSS_POSITION_PX_0(style) ((style).pos_offsets[0])
|
|
329
|
+
#define GEA_CSS_POSITION_PX_1(style) ((style).pos_offsets[1])
|
|
330
|
+
#define GEA_CSS_POSITION_PX_2(style) ((style).pos_offsets[2])
|
|
331
|
+
#define GEA_CSS_POSITION_PX_3(style) ((style).pos_offsets[3])
|
|
332
|
+
#else
|
|
333
|
+
#define GEA_CSS_POSITION_PX_0(style) ((style).pos_top)
|
|
334
|
+
#define GEA_CSS_POSITION_PX_1(style) ((style).pos_right)
|
|
335
|
+
#define GEA_CSS_POSITION_PX_2(style) ((style).pos_bottom)
|
|
336
|
+
#define GEA_CSS_POSITION_PX_3(style) ((style).pos_left)
|
|
337
|
+
#endif
|
|
338
|
+
// The selector must be a compile-time constant: no runtime edge mapping.
|
|
339
|
+
#define GEA_CSS_POSITION_PX(style, side) \
|
|
340
|
+
(std::integral_constant<int, (side)>::value == 0 ? GEA_CSS_POSITION_PX_0(style) : \
|
|
341
|
+
std::integral_constant<int, (side)>::value == 1 ? GEA_CSS_POSITION_PX_1(style) : \
|
|
342
|
+
std::integral_constant<int, (side)>::value == 2 ? GEA_CSS_POSITION_PX_2(style) : GEA_CSS_POSITION_PX_3(style))
|
|
343
|
+
|
|
344
|
+
#define GEA_CSS_POSITION_PERCENT_ALL (GEA_CSS_POSITION_TOP_PERCENT && GEA_CSS_POSITION_RIGHT_PERCENT && GEA_CSS_POSITION_BOTTOM_PERCENT && GEA_CSS_POSITION_LEFT_PERCENT)
|
|
345
|
+
#if GEA_CSS_POSITION_PERCENT_ALL
|
|
346
|
+
#define GEA_CSS_POSITION_PERCENT_0(style) ((style).pos_offset_percent[0])
|
|
347
|
+
#define GEA_CSS_POSITION_PERCENT_1(style) ((style).pos_offset_percent[1])
|
|
348
|
+
#define GEA_CSS_POSITION_PERCENT_2(style) ((style).pos_offset_percent[2])
|
|
349
|
+
#define GEA_CSS_POSITION_PERCENT_3(style) ((style).pos_offset_percent[3])
|
|
350
|
+
#else
|
|
351
|
+
#define GEA_CSS_POSITION_PERCENT_0(style) ((style).pos_percent_top)
|
|
352
|
+
#define GEA_CSS_POSITION_PERCENT_1(style) ((style).pos_percent_right)
|
|
353
|
+
#define GEA_CSS_POSITION_PERCENT_2(style) ((style).pos_percent_bottom)
|
|
354
|
+
#define GEA_CSS_POSITION_PERCENT_3(style) ((style).pos_percent_left)
|
|
355
|
+
#endif
|
|
356
|
+
// The selector must be a compile-time constant: no runtime edge mapping.
|
|
357
|
+
#define GEA_CSS_POSITION_PERCENT(style, side) \
|
|
358
|
+
(std::integral_constant<int, (side)>::value == 0 ? GEA_CSS_POSITION_PERCENT_0(style) : \
|
|
359
|
+
std::integral_constant<int, (side)>::value == 1 ? GEA_CSS_POSITION_PERCENT_1(style) : \
|
|
360
|
+
std::integral_constant<int, (side)>::value == 2 ? GEA_CSS_POSITION_PERCENT_2(style) : GEA_CSS_POSITION_PERCENT_3(style))
|
|
361
|
+
|
|
362
|
+
// Optional default-valued fields: only a complete compact-style source proof
|
|
363
|
+
// can omit them. Layout uses these constants directly in a pruned application.
|
|
364
|
+
#ifndef GEA_CSS_LINE_HEIGHT
|
|
365
|
+
#define GEA_CSS_LINE_HEIGHT 1
|
|
366
|
+
#endif
|
|
367
|
+
#ifndef GEA_CSS_DISPLAY_EXPLICIT
|
|
368
|
+
#define GEA_CSS_DISPLAY_EXPLICIT 1
|
|
369
|
+
#endif
|
package/ui/document.cpp
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
#include <algorithm>
|
|
10
10
|
#include <cctype>
|
|
11
|
+
#include <cstdlib>
|
|
11
12
|
#include <cstring>
|
|
12
13
|
#include <utility>
|
|
13
14
|
#include <vector>
|
|
@@ -268,7 +269,15 @@ int Document::preferredMountHeight() { return g_preferred_mount_h; }
|
|
|
268
269
|
ViewElement Document::ensureAppRoot(const char *id) const
|
|
269
270
|
{
|
|
270
271
|
const char *rootId = (id && id[0] != '\0') ? id : "app";
|
|
272
|
+
#if GEA_UI_NODE_ATTRIBUTES
|
|
271
273
|
NodeHandle existing = findElementById(Tree::instance(), rootId);
|
|
274
|
+
#else
|
|
275
|
+
// With no authored attributes or ID selectors, the framework's implicit
|
|
276
|
+
// #app is just the mounted root. Its built-in identity needs no per-node
|
|
277
|
+
// attribute owner. Authored DOM lookups retain the ordinary path above.
|
|
278
|
+
if (std::strcmp(rootId, "app") != 0) std::abort();
|
|
279
|
+
NodeHandle existing(Tree::instance().mountedRoot());
|
|
280
|
+
#endif
|
|
272
281
|
ViewElement root = existing ? ViewElement(existing.id()) : createView();
|
|
273
282
|
Tree &tree = Tree::instance();
|
|
274
283
|
const int rootW = g_preferred_mount_w > 0 ? g_preferred_mount_w
|
|
@@ -278,7 +287,9 @@ ViewElement Document::ensureAppRoot(const char *id) const
|
|
|
278
287
|
: tree.mountedHeight() > 0 ? tree.mountedHeight()
|
|
279
288
|
: gea::platform::display::kHeight;
|
|
280
289
|
if (!existing) {
|
|
290
|
+
#if GEA_UI_NODE_ATTRIBUTES
|
|
281
291
|
root.setAttribute("id", rootId);
|
|
292
|
+
#endif
|
|
282
293
|
root.style().width(rootW);
|
|
283
294
|
root.style().height(rootH);
|
|
284
295
|
}
|
package/ui/image_node.cpp
CHANGED
|
@@ -19,16 +19,16 @@ class ImageFitResolver {
|
|
|
19
19
|
public:
|
|
20
20
|
static ImageFitRect resolve(const Node &node, int imageWidth, int imageHeight)
|
|
21
21
|
{
|
|
22
|
-
const int contentWidth = node.layout.width - boxInsets(node.
|
|
23
|
-
const int contentHeight = node.layout.height - boxInsets(node.
|
|
22
|
+
const int contentWidth = node.layout.width - boxInsets(node.computedStyle(), true);
|
|
23
|
+
const int contentHeight = node.layout.height - boxInsets(node.computedStyle(), false);
|
|
24
24
|
ImageFitRect rect{
|
|
25
|
-
node.layout.x + boxInset(node.
|
|
26
|
-
node.layout.y + boxInset(node.
|
|
25
|
+
node.layout.x + boxInset(node.computedStyle(), 3),
|
|
26
|
+
node.layout.y + boxInset(node.computedStyle(), 0),
|
|
27
27
|
contentWidth,
|
|
28
28
|
contentHeight,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
if (node.
|
|
31
|
+
if (node.computedStyle().image_fit == 1 || node.computedStyle().image_fit == 4) {
|
|
32
32
|
const int scaledWidth = (imageWidth * contentHeight) / imageHeight;
|
|
33
33
|
const int scaledHeight = (imageHeight * contentWidth) / imageWidth;
|
|
34
34
|
if (scaledWidth <= contentWidth) {
|
|
@@ -38,12 +38,12 @@ public:
|
|
|
38
38
|
rect.width = contentWidth;
|
|
39
39
|
rect.height = scaledHeight;
|
|
40
40
|
}
|
|
41
|
-
if (node.
|
|
41
|
+
if (node.computedStyle().image_fit == 4 && rect.width >= imageWidth && rect.height >= imageHeight) {
|
|
42
42
|
rect.width = imageWidth;
|
|
43
43
|
rect.height = imageHeight;
|
|
44
44
|
}
|
|
45
45
|
center(node, rect);
|
|
46
|
-
} else if (node.
|
|
46
|
+
} else if (node.computedStyle().image_fit == 2) {
|
|
47
47
|
const int scaledWidth = (imageWidth * contentHeight) / imageHeight;
|
|
48
48
|
const int scaledHeight = (imageHeight * contentWidth) / imageWidth;
|
|
49
49
|
if (scaledWidth >= contentWidth) {
|
|
@@ -54,7 +54,7 @@ public:
|
|
|
54
54
|
rect.height = scaledHeight;
|
|
55
55
|
}
|
|
56
56
|
center(node, rect);
|
|
57
|
-
} else if (node.
|
|
57
|
+
} else if (node.computedStyle().image_fit == 3) {
|
|
58
58
|
rect.width = imageWidth;
|
|
59
59
|
rect.height = imageHeight;
|
|
60
60
|
center(node, rect);
|
|
@@ -66,25 +66,25 @@ public:
|
|
|
66
66
|
private:
|
|
67
67
|
static void center(const Node &node, ImageFitRect &rect)
|
|
68
68
|
{
|
|
69
|
-
rect.x = node.layout.x + boxInset(node.
|
|
70
|
-
rect.y = node.layout.y + boxInset(node.
|
|
69
|
+
rect.x = node.layout.x + boxInset(node.computedStyle(), 3) + (node.layout.width - boxInsets(node.computedStyle(), true) - rect.width) / 2;
|
|
70
|
+
rect.y = node.layout.y + boxInset(node.computedStyle(), 0) + (node.layout.height - boxInsets(node.computedStyle(), false) - rect.height) / 2;
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
bool hasImageRadius(const Node &node)
|
|
75
75
|
{
|
|
76
|
-
return node.
|
|
77
|
-
node.
|
|
78
|
-
node.
|
|
79
|
-
node.
|
|
76
|
+
return node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)] > 0 ||
|
|
77
|
+
node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)] > 0 ||
|
|
78
|
+
node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)] > 0 ||
|
|
79
|
+
node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)] > 0;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
void setScaledBlitRadius(DisplayCommand *cmd, const Node &node)
|
|
83
83
|
{
|
|
84
|
-
cmd->scaledBlit.tl = node.
|
|
85
|
-
cmd->scaledBlit.tr = node.
|
|
86
|
-
cmd->scaledBlit.br = node.
|
|
87
|
-
cmd->scaledBlit.bl = node.
|
|
84
|
+
cmd->scaledBlit.tl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)];
|
|
85
|
+
cmd->scaledBlit.tr = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)];
|
|
86
|
+
cmd->scaledBlit.br = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)];
|
|
87
|
+
cmd->scaledBlit.bl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
bool applyAxisAlignedTransform(const Node &node, ImageFitRect &rect)
|
|
@@ -106,17 +106,18 @@ bool applyAxisAlignedTransform(const Node &node, ImageFitRect &rect)
|
|
|
106
106
|
|
|
107
107
|
void ImageRenderer::layout(int id)
|
|
108
108
|
{
|
|
109
|
+
if (!GEA_UI_IMAGE_NODES) return;
|
|
109
110
|
Node *n = &Tree::instance().nodes()[id];
|
|
110
111
|
auto &images = gea::framework::graphics::ImageStore::instance();
|
|
111
112
|
int iw = images.width(n->image_id);
|
|
112
113
|
int ih = images.height(n->image_id);
|
|
113
114
|
|
|
114
|
-
if (n->
|
|
115
|
-
n->layout.width = iw + boxInsets(n->
|
|
116
|
-
if (n->
|
|
117
|
-
n->layout.height = ih + boxInsets(n->
|
|
118
|
-
n->layout.width = clampBorderBoxSize(n->
|
|
119
|
-
n->layout.height = clampBorderBoxSize(n->
|
|
115
|
+
if (n->computedStyle().width == kUnset && n->computedStyle().width_percent == kUnset && n->computedStyle().width_expression < 0 && iw > 0)
|
|
116
|
+
n->layout.width = iw + boxInsets(n->computedStyle(), true);
|
|
117
|
+
if (n->computedStyle().height == kUnset && n->computedStyle().height_percent == kUnset && n->computedStyle().height_expression < 0 && ih > 0)
|
|
118
|
+
n->layout.height = ih + boxInsets(n->computedStyle(), false);
|
|
119
|
+
n->layout.width = clampBorderBoxSize(n->computedStyle(), n->layout.width, true);
|
|
120
|
+
n->layout.height = clampBorderBoxSize(n->computedStyle(), n->layout.height, false);
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
void ImageRenderer::record(const Node &node)
|