@geastack/engine 0.1.5 → 0.1.6
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/canvas.cpp +34 -0
- package/css/animation.h +64 -0
- package/css/engine.h +6 -1
- package/package.json +2 -2
- package/ui/absolute_leaf_refresh.cpp +32 -31
- package/ui/core.cpp +9 -1
- package/ui/display_invalidation.cpp +29 -0
- package/ui/flex_balance.h +73 -0
- package/ui/image_node.cpp +24 -20
- package/ui/input.cpp +66 -36
- package/ui/input_render.cpp +13 -13
- package/ui/internal.h +51 -5
- package/ui/layout.cpp +2472 -400
- package/ui/layout_snapshot.cpp +21 -5
- package/ui/node_lifecycle.cpp +28 -3
- package/ui/node_model.h +323 -23
- package/ui/render.cpp +638 -265
- package/ui/root_scroll_refresh.cpp +15 -10
- package/ui/style.cpp +3254 -935
- package/ui/style.h +143 -6
- package/ui/style_values.h +16 -0
- package/ui/text.cpp +378 -103
- package/ui/tree_events.cpp +6 -3
- package/ui/tree_events.h +1 -0
- package/ui/tree_internal.h +19 -0
- package/ui/tree_nodes.cpp +6 -0
- package/ui/tree_render.cpp +71 -21
- package/ui/tree_state.h +54 -0
- package/ui/tree_style.cpp +287 -27
- package/ui/view.cpp +612 -251
package/ui/tree_events.cpp
CHANGED
|
@@ -57,7 +57,7 @@ void applyAudioAttribute(Tree &tree, int node, const char *name, const char *val
|
|
|
57
57
|
// Index order mirrors NodeEventListeners' slots and is kept in sync by
|
|
58
58
|
// setEventListener (on the empty->set transition) and NodeEventListeners::clear()
|
|
59
59
|
// (which every removal path calls).
|
|
60
|
-
constexpr int kEventTypeCount =
|
|
60
|
+
constexpr int kEventTypeCount = 7;
|
|
61
61
|
int g_listenerTypeCounts[kEventTypeCount] = {};
|
|
62
62
|
EventListenerId g_nextEventListenerId = 1;
|
|
63
63
|
|
|
@@ -75,6 +75,7 @@ int eventTypeIndex(const char *type)
|
|
|
75
75
|
if (sameName(type, "touchend") || sameName(type, "pointerup")) return 3;
|
|
76
76
|
if (sameName(type, "input")) return 4;
|
|
77
77
|
if (sameName(type, "keydown")) return 5;
|
|
78
|
+
if (sameName(type, "scroll")) return 6;
|
|
78
79
|
return -1;
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -276,6 +277,7 @@ void NodeEventListeners::clear()
|
|
|
276
277
|
release(touchend, 3);
|
|
277
278
|
release(input, 4);
|
|
278
279
|
release(keydown, 5);
|
|
280
|
+
release(scroll, 6);
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
NodeEventListenerList *NodeEventListeners::listenersFor(const char *type)
|
|
@@ -287,6 +289,7 @@ NodeEventListenerList *NodeEventListeners::listenersFor(const char *type)
|
|
|
287
289
|
if (sameName(type, "touchend") || sameName(type, "pointerup")) return &touchend;
|
|
288
290
|
if (sameName(type, "input")) return &input;
|
|
289
291
|
if (sameName(type, "keydown")) return &keydown;
|
|
292
|
+
if (sameName(type, "scroll")) return &scroll;
|
|
290
293
|
return nullptr;
|
|
291
294
|
}
|
|
292
295
|
|
|
@@ -298,7 +301,7 @@ const NodeEventListenerList *NodeEventListeners::listenersFor(const char *type)
|
|
|
298
301
|
bool NodeEventListeners::hasAny() const
|
|
299
302
|
{
|
|
300
303
|
return !click.empty() || !touchstart.empty() || !touchmove.empty() ||
|
|
301
|
-
!touchend.empty() || !input.empty() || !keydown.empty();
|
|
304
|
+
!touchend.empty() || !input.empty() || !keydown.empty() || !scroll.empty();
|
|
302
305
|
}
|
|
303
306
|
|
|
304
307
|
EventListenerId Tree::setEventListener(int node, const char *type, gea::framework::events::EventListener listener)
|
|
@@ -367,6 +370,7 @@ bool Tree::dispatchEvent(gea::framework::events::PointerEvent &event)
|
|
|
367
370
|
event.target = gea::framework::events::EventTarget(event.targetId);
|
|
368
371
|
bool dispatched = false;
|
|
369
372
|
for (int node = event.targetId; node >= 0 && node < state.nodeCount; node = state.nodes[node].parent) {
|
|
373
|
+
if (!event.bubbles && node != event.targetId) break;
|
|
370
374
|
NodeRareData *rd = rareDataFor(node);
|
|
371
375
|
if (!rd) continue;
|
|
372
376
|
auto *initialList = rd->listeners.listenersFor(event.typeName());
|
|
@@ -408,7 +412,6 @@ bool Tree::dispatchEvent(gea::framework::events::PointerEvent &event)
|
|
|
408
412
|
cursor = nextId;
|
|
409
413
|
(*callback)(event);
|
|
410
414
|
dispatched = true;
|
|
411
|
-
if (event.propagationStopped || !event.bubbles) break;
|
|
412
415
|
}
|
|
413
416
|
if (event.propagationStopped || !event.bubbles) break;
|
|
414
417
|
}
|
package/ui/tree_events.h
CHANGED
package/ui/tree_internal.h
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include "style.h"
|
|
8
8
|
|
|
9
9
|
#include <string>
|
|
10
|
+
#include <string_view>
|
|
10
11
|
|
|
11
12
|
namespace gea::embedded::ui {
|
|
12
13
|
|
|
@@ -105,6 +106,10 @@ public:
|
|
|
105
106
|
|
|
106
107
|
int hitTest(int x, int y);
|
|
107
108
|
int hitTestNode(int x, int y);
|
|
109
|
+
// Hover-capable pointing devices only; touch dragging remains pointerMove.
|
|
110
|
+
// Negative coordinates clear hover when the pointer leaves the surface.
|
|
111
|
+
int pointerHover(int x, int y);
|
|
112
|
+
bool isHovered(int node) const;
|
|
108
113
|
void pointerDown(int x, int y);
|
|
109
114
|
int pointerMove(int x, int y);
|
|
110
115
|
int pointerUp();
|
|
@@ -176,6 +181,20 @@ bool dispatchDocumentPointer(gea::framework::events::PointerEvent &event);
|
|
|
176
181
|
int16_t internTag(const char *tag);
|
|
177
182
|
const char *tagFromId(int16_t id);
|
|
178
183
|
|
|
184
|
+
inline bool isDocumentCanvasRoot(const Node &node)
|
|
185
|
+
{
|
|
186
|
+
return node.parent < 0 && std::string_view(tagFromId(node.tag_id)) == "html";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
// HTML importers mark DOM text separately from Gea's styleable TextElement.
|
|
191
|
+
// The former inherits text properties but is never an element selector target.
|
|
192
|
+
inline bool isAnonymousTextNode(const Node &node)
|
|
193
|
+
{
|
|
194
|
+
if (node.type != NodeType::Text) return false;
|
|
195
|
+
return std::string_view(tagFromId(node.tag_id)) == "#text";
|
|
196
|
+
}
|
|
197
|
+
|
|
179
198
|
// Blink-style rare-data pool accessors. A node's cold/optional state lives in a
|
|
180
199
|
// pooled NodeRareData block referenced by Node::rare_data (-1 = none).
|
|
181
200
|
struct NodeRareData;
|
package/ui/tree_nodes.cpp
CHANGED
|
@@ -176,6 +176,7 @@ void Tree::clear()
|
|
|
176
176
|
// switch and bounded at kMaxNodes (~512).
|
|
177
177
|
for (int i = 0; i < kMaxNodes; i++) state.nodes[i] = Node{};
|
|
178
178
|
state.nodeCount = 0;
|
|
179
|
+
state.fixedPositionUsed = false;
|
|
179
180
|
state.mountedRoot = -1;
|
|
180
181
|
state.mountedWidth = 0;
|
|
181
182
|
state.mountedHeight = 0;
|
|
@@ -258,6 +259,10 @@ int Tree::cloneNode(int sourceId, bool deep)
|
|
|
258
259
|
cloneRd.customProperties = srcRd->customProperties;
|
|
259
260
|
cloneRd.defaultStyles = srcRd->defaultStyles;
|
|
260
261
|
cloneRd.inlineStyles = srcRd->inlineStyles;
|
|
262
|
+
cloneRd.inlineCustomProperties = srcRd->inlineCustomProperties;
|
|
263
|
+
cloneRd.inlineGridTemplates[0] = srcRd->inlineGridTemplates[0];
|
|
264
|
+
cloneRd.inlineGridTemplates[1] = srcRd->inlineGridTemplates[1];
|
|
265
|
+
cloneRd.inlineGridShorthandMask = srcRd->inlineGridShorthandMask;
|
|
261
266
|
}
|
|
262
267
|
state.classLists[id] = state.classLists[sourceId];
|
|
263
268
|
// Listeners deliberately NOT copied (DOM cloneNode semantics) — compiled
|
|
@@ -596,6 +601,7 @@ void Tree::removeNode(int id)
|
|
|
596
601
|
{
|
|
597
602
|
auto &state = treeState();
|
|
598
603
|
if (id < 0 || id >= state.nodeCount || !state.nodeActive[id]) return;
|
|
604
|
+
if (containsNode(id, state.hoveredNodeId)) pointerHover(-1, -1);
|
|
599
605
|
while (state.nodes[id].first_child >= 0) {
|
|
600
606
|
removeNode(state.nodes[id].first_child);
|
|
601
607
|
if (id >= state.nodeCount || !state.nodeActive[id]) return;
|
package/ui/tree_render.cpp
CHANGED
|
@@ -408,37 +408,44 @@ namespace gea::embedded::ui
|
|
|
408
408
|
bool hasTransformState(const Node &node)
|
|
409
409
|
{
|
|
410
410
|
const RareStyle &rs = rstyle(node.style); // one pool lookup, not 11
|
|
411
|
-
return rs
|
|
411
|
+
return hasIndividualLinearTransform(rs) || hadIndividualLinearTransform(node.render) ||
|
|
412
|
+
rs.transform_rotate != 0 ||
|
|
412
413
|
node.render.previous_transform_rotate != 0 ||
|
|
413
414
|
rs.transform_rotate_x != 0 ||
|
|
414
415
|
node.render.previous_transform_rotate_x != 0 ||
|
|
415
416
|
rs.transform_rotate_y != 0 ||
|
|
416
417
|
node.render.previous_transform_rotate_y != 0 ||
|
|
417
|
-
rs
|
|
418
|
+
composedTranslateX(rs) != 0 ||
|
|
418
419
|
node.render.previous_transform_translate_x != 0 ||
|
|
419
|
-
rs
|
|
420
|
+
composedTranslateY(rs) != 0 ||
|
|
420
421
|
node.render.previous_transform_translate_y != 0 ||
|
|
421
|
-
rs
|
|
422
|
+
composedTranslateZ(rs) != 0 ||
|
|
422
423
|
node.render.previous_transform_translate_z != 0 ||
|
|
423
|
-
rs
|
|
424
|
+
composedTranslateXPercent(rs) != 0 ||
|
|
424
425
|
node.render.previous_transform_translate_x_percent != 0 ||
|
|
425
|
-
rs
|
|
426
|
+
composedTranslateYPercent(rs) != 0 ||
|
|
426
427
|
node.render.previous_transform_translate_y_percent != 0 ||
|
|
427
428
|
rs.transform_scale_x != 1000 ||
|
|
428
429
|
node.render.previous_transform_scale_x != 1000 ||
|
|
429
430
|
rs.transform_scale_y != 1000 ||
|
|
431
|
+
rs.transform_scale_z != 1000 ||
|
|
430
432
|
node.render.previous_transform_scale_y != 1000 ||
|
|
433
|
+
node.render.previous_transform_scale_z != 1000 ||
|
|
431
434
|
rs.perspective > 0 ||
|
|
432
435
|
node.render.previous_perspective > 0;
|
|
433
436
|
}
|
|
434
437
|
|
|
435
438
|
bool hasThreeDimensionalTransformState(const Node &node)
|
|
436
439
|
{
|
|
437
|
-
|
|
440
|
+
const auto &r = rstyle(node.style);
|
|
441
|
+
return ((r.rotate_angle % 3600) && (r.rotate_axis_x || r.rotate_axis_y)) ||
|
|
442
|
+
((node.render.previous_rotate_angle % 3600) && (node.render.previous_rotate_axis_x || node.render.previous_rotate_axis_y)) ||
|
|
443
|
+
r.scale_z != 1000 || node.render.previous_scale_z != 1000 ||
|
|
444
|
+
rstyle(node.style).transform_rotate_x != 0 ||
|
|
438
445
|
node.render.previous_transform_rotate_x != 0 ||
|
|
439
446
|
rstyle(node.style).transform_rotate_y != 0 ||
|
|
440
447
|
node.render.previous_transform_rotate_y != 0 ||
|
|
441
|
-
rstyle(node.style)
|
|
448
|
+
composedTranslateZ(rstyle(node.style)) != 0 ||
|
|
442
449
|
node.render.previous_transform_translate_z != 0 ||
|
|
443
450
|
rstyle(node.style).perspective > 0 ||
|
|
444
451
|
node.render.previous_perspective > 0;
|
|
@@ -1158,16 +1165,17 @@ namespace gea::embedded::ui
|
|
|
1158
1165
|
|
|
1159
1166
|
bool panNodeHasTransform(const Node &n)
|
|
1160
1167
|
{
|
|
1161
|
-
return rstyle(n.style)
|
|
1168
|
+
return hasIndividualLinearTransform(rstyle(n.style)) || hadIndividualLinearTransform(n.render) ||
|
|
1169
|
+
rstyle(n.style).transform_rotate != 0 || n.render.previous_transform_rotate != 0 ||
|
|
1162
1170
|
rstyle(n.style).transform_rotate_x != 0 || n.render.previous_transform_rotate_x != 0 ||
|
|
1163
1171
|
rstyle(n.style).transform_rotate_y != 0 || n.render.previous_transform_rotate_y != 0 ||
|
|
1164
|
-
rstyle(n.style)
|
|
1165
|
-
rstyle(n.style)
|
|
1166
|
-
rstyle(n.style)
|
|
1167
|
-
rstyle(n.style)
|
|
1168
|
-
rstyle(n.style)
|
|
1172
|
+
composedTranslateX(rstyle(n.style)) != 0 || n.render.previous_transform_translate_x != 0 ||
|
|
1173
|
+
composedTranslateY(rstyle(n.style)) != 0 || n.render.previous_transform_translate_y != 0 ||
|
|
1174
|
+
composedTranslateZ(rstyle(n.style)) != 0 || n.render.previous_transform_translate_z != 0 ||
|
|
1175
|
+
composedTranslateXPercent(rstyle(n.style)) != 0 || n.render.previous_transform_translate_x_percent != 0 ||
|
|
1176
|
+
composedTranslateYPercent(rstyle(n.style)) != 0 || n.render.previous_transform_translate_y_percent != 0 ||
|
|
1169
1177
|
rstyle(n.style).transform_scale_x != 1000 || n.render.previous_transform_scale_x != 1000 ||
|
|
1170
|
-
rstyle(n.style).transform_scale_y != 1000 || n.render.previous_transform_scale_y != 1000 ||
|
|
1178
|
+
rstyle(n.style).transform_scale_y != 1000 || rstyle(n.style).transform_scale_z != 1000 || n.render.previous_transform_scale_y != 1000 || n.render.previous_transform_scale_z != 1000 ||
|
|
1171
1179
|
rstyle(n.style).perspective > 0 || n.render.previous_perspective > 0;
|
|
1172
1180
|
}
|
|
1173
1181
|
|
|
@@ -1187,7 +1195,7 @@ namespace gea::embedded::ui
|
|
|
1187
1195
|
// that paints nothing or a single solid background color, with no gradient/grid,
|
|
1188
1196
|
// border, radius, shadow, blur, mask, or partial opacity. Images/text/canvas and
|
|
1189
1197
|
// anything non-uniform return false → they get repainted after the shift.
|
|
1190
|
-
bool panNodeIsHorizontallyScrollSafe(const Node &n)
|
|
1198
|
+
bool panNodeIsHorizontallyScrollSafe(const Node &n, int viewportX, int viewportWidth)
|
|
1191
1199
|
{
|
|
1192
1200
|
if (n.type != NodeType::View)
|
|
1193
1201
|
return false;
|
|
@@ -1212,7 +1220,18 @@ namespace gea::embedded::ui
|
|
|
1212
1220
|
return false;
|
|
1213
1221
|
if (n.style.has_bg)
|
|
1214
1222
|
{
|
|
1215
|
-
|
|
1223
|
+
// A narrow solid rectangle still has horizontal edges: scrolling
|
|
1224
|
+
// it creates a ghost just like scrolling text or a rounded control.
|
|
1225
|
+
if (n.style.bg_alpha != 255 || panNodeHasTransform(n) ||
|
|
1226
|
+
n.layout.x > viewportX || n.layout.x + n.layout.width < viewportX + viewportWidth)
|
|
1227
|
+
return false;
|
|
1228
|
+
for (int parent = n.parent; parent >= 0; parent = treeState().nodes[parent].parent) {
|
|
1229
|
+
const Node &clip = treeState().nodes[parent];
|
|
1230
|
+
if (panNodeHasTransform(clip) || (clip.style.overflow &&
|
|
1231
|
+
(clip.layout.x > viewportX || clip.layout.x + clip.layout.width < viewportX + viewportWidth)))
|
|
1232
|
+
return false;
|
|
1233
|
+
}
|
|
1234
|
+
if (styleHasBackgroundImage(n.style))
|
|
1216
1235
|
return false; // gradient fill (linear/radial/overlay)
|
|
1217
1236
|
if (rstyle(n.style).bg_grid_axes != 0)
|
|
1218
1237
|
return false; // grid overlay
|
|
@@ -1259,7 +1278,7 @@ namespace gea::embedded::ui
|
|
|
1259
1278
|
resetPanCoverage();
|
|
1260
1279
|
return false;
|
|
1261
1280
|
}
|
|
1262
|
-
if (gHorizontalPanFastPathDisabled)
|
|
1281
|
+
if (gHorizontalPanFastPathDisabled || LayoutEngine::containsViewportFixed(root))
|
|
1263
1282
|
{
|
|
1264
1283
|
resetPanCoverage();
|
|
1265
1284
|
return false;
|
|
@@ -1340,6 +1359,13 @@ namespace gea::embedded::ui
|
|
|
1340
1359
|
if (absDx >= vw)
|
|
1341
1360
|
return false; // teleport — a full repaint is simpler and safer
|
|
1342
1361
|
|
|
1362
|
+
// Shifting the viewport is useful for a camera/world that spans it,
|
|
1363
|
+
// not a small floating subtree (drag previews, tooltips). For those,
|
|
1364
|
+
// the shift corrupts every stationary sibling and step 5 repaints
|
|
1365
|
+
// nearly the entire screen instead of just the old/new card bounds.
|
|
1366
|
+
if (W->layout.width < vw || W->layout.height < vh)
|
|
1367
|
+
return false;
|
|
1368
|
+
|
|
1343
1369
|
// 3. Decide what the memcpy can't reproduce and must be repainted explicitly:
|
|
1344
1370
|
// every wrapper descendant that did NOT translate uniformly with the camera.
|
|
1345
1371
|
// A descendant needs repainting when it is dirty (its appearance/size/visibility
|
|
@@ -1460,7 +1486,7 @@ namespace gea::embedded::ui
|
|
|
1460
1486
|
continue;
|
|
1461
1487
|
if (n->render.dirty)
|
|
1462
1488
|
continue;
|
|
1463
|
-
if (panNodeIsHorizontallyScrollSafe(*n))
|
|
1489
|
+
if (panNodeIsHorizontallyScrollSafe(*n, vx, vw))
|
|
1464
1490
|
continue;
|
|
1465
1491
|
const DirtyRegions::Rect b = transformedBoundsRect(*n, false, i);
|
|
1466
1492
|
if (b.x0 > b.x1 || b.y0 > b.y1)
|
|
@@ -1808,6 +1834,16 @@ namespace gea::embedded::ui
|
|
|
1808
1834
|
auto &state = treeState();
|
|
1809
1835
|
if (root < 0 || root >= state.nodeCount)
|
|
1810
1836
|
return;
|
|
1837
|
+
const bool viewportChanged = gLayoutViewportRoot != root ||
|
|
1838
|
+
gLayoutViewportWidth != width || gLayoutViewportHeight != height;
|
|
1839
|
+
if (viewportChanged) {
|
|
1840
|
+
state.displayListDirty = true;
|
|
1841
|
+
state.displayListRebuildStructural = true;
|
|
1842
|
+
state.nodes[root].render.dirty = true;
|
|
1843
|
+
state.nodes[root].render.layout_dirty = true;
|
|
1844
|
+
}
|
|
1845
|
+
state.mountedWidth = width;
|
|
1846
|
+
state.mountedHeight = height;
|
|
1811
1847
|
// Bump before the scroll-only fast path returns: a scroll-only refresh still
|
|
1812
1848
|
// moves content, so native renderers must re-sync.
|
|
1813
1849
|
state.refreshSerial++;
|
|
@@ -1815,7 +1851,21 @@ namespace gea::embedded::ui
|
|
|
1815
1851
|
perf.treeRefreshCalls++;
|
|
1816
1852
|
DisplayList::instance().clearRetainedBackgroundRecolors();
|
|
1817
1853
|
|
|
1818
|
-
|
|
1854
|
+
const bool textClipDependencies = DisplayList::instance().hasTextClippedBackgrounds();
|
|
1855
|
+
if (textClipDependencies) {
|
|
1856
|
+
bool changed = state.displayListDirty;
|
|
1857
|
+
for (int i = 0; !changed && i < state.nodeCount; ++i)
|
|
1858
|
+
changed = state.nodes[i].render.dirty || state.nodes[i].render.layout_dirty || state.nodes[i].render.transform_dirty;
|
|
1859
|
+
if (changed) {
|
|
1860
|
+
// Background ink depends on descendants, including those whose own
|
|
1861
|
+
// foreground is transparent. Rebuild and repaint these dependencies
|
|
1862
|
+
// together before considering retained translation/recolor shortcuts.
|
|
1863
|
+
state.displayListDirty = true;
|
|
1864
|
+
state.displayListRebuildStructural = true;
|
|
1865
|
+
state.nodes[root].render.dirty = true;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
if (!textClipDependencies && state.pendingScrollIntoViewNode < 0 && RootScrollOnlyRefresh::refresh(root, width, height))
|
|
1819
1869
|
return;
|
|
1820
1870
|
|
|
1821
1871
|
// This frame is NOT a pure scroll, so the software scroll register's
|
|
@@ -1899,7 +1949,7 @@ namespace gea::embedded::ui
|
|
|
1899
1949
|
}
|
|
1900
1950
|
if (anyLayoutDirty)
|
|
1901
1951
|
{
|
|
1902
|
-
if (state.pendingScrollIntoViewNode < 0)
|
|
1952
|
+
if (!viewportChanged && state.pendingScrollIntoViewNode < 0)
|
|
1903
1953
|
{
|
|
1904
1954
|
int scope = scopedRelayoutRoot(state, root);
|
|
1905
1955
|
if (scope >= 0)
|
package/ui/tree_state.h
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include <cstddef>
|
|
11
11
|
#include <cstdint>
|
|
12
12
|
#include <string>
|
|
13
|
+
#include <memory>
|
|
13
14
|
#include <vector>
|
|
14
15
|
|
|
15
16
|
namespace gea::embedded::ui {
|
|
@@ -73,6 +74,35 @@ struct NodeStyleOverrideStore {
|
|
|
73
74
|
const NodeStyleOverride &at(std::size_t index) const;
|
|
74
75
|
};
|
|
75
76
|
|
|
77
|
+
// CSS ::first-line painting is uncommon and line fragments are useful only
|
|
78
|
+
// for nodes inside a block with a first-line background. Keep this metadata in
|
|
79
|
+
// the node's rare allocation instead of charging every Node for it.
|
|
80
|
+
struct FirstLineBackground {
|
|
81
|
+
style_color_t color = 0;
|
|
82
|
+
std::uint8_t alpha = 0;
|
|
83
|
+
bool hasColor = false;
|
|
84
|
+
std::int16_t lineY = 0;
|
|
85
|
+
std::int16_t lineHeight = 0;
|
|
86
|
+
std::int16_t lineContextNode = -1;
|
|
87
|
+
bool lineValid = false;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
struct FirstLineFragment {
|
|
91
|
+
std::int16_t x = 0;
|
|
92
|
+
std::int16_t y = 0;
|
|
93
|
+
std::int16_t width = 0;
|
|
94
|
+
std::int16_t height = 0;
|
|
95
|
+
std::int16_t contextNode = -1;
|
|
96
|
+
bool valid = false;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
struct InlineStaticPosition {
|
|
100
|
+
std::int16_t x = 0;
|
|
101
|
+
std::int16_t y = 0;
|
|
102
|
+
bool continuationLine = false;
|
|
103
|
+
bool valid = false;
|
|
104
|
+
};
|
|
105
|
+
|
|
76
106
|
struct NodeCustomProperty {
|
|
77
107
|
CssAtomId nameId = kInvalidCssAtom;
|
|
78
108
|
std::string value;
|
|
@@ -126,22 +156,42 @@ struct VirtualListNodeState {
|
|
|
126
156
|
// properties, and virtual-list windowing state. Stored in a shared pool and
|
|
127
157
|
// referenced by a single int16 handle on the node (Node::rare_data) instead of
|
|
128
158
|
// inlining a fixed slot on every node, so a plain styled node allocates nothing.
|
|
159
|
+
struct GridTrackLayout {
|
|
160
|
+
std::vector<int> columnStart, columnEnd, rowStart, rowEnd;
|
|
161
|
+
int columnOrigin = 0, rowOrigin = 0;
|
|
162
|
+
};
|
|
163
|
+
|
|
129
164
|
struct NodeRareData {
|
|
130
165
|
NodeAttributeStore attributes;
|
|
131
166
|
NodeEventListeners listeners;
|
|
132
167
|
NodeCustomPropertyStore customProperties;
|
|
168
|
+
// Authored inline values survive rebuilding the computed custom-property map.
|
|
169
|
+
NodeCustomPropertyStore inlineCustomProperties;
|
|
133
170
|
NodeStyleOverrideStore defaultStyles;
|
|
134
171
|
NodeStyleOverrideStore inlineStyles;
|
|
172
|
+
CssAtomId inlineGridTemplates[2] = {kInvalidCssAtom, kInvalidCssAtom};
|
|
173
|
+
uint8_t inlineGridShorthandMask = 0;
|
|
174
|
+
std::unique_ptr<GridTrackLayout> gridLayout;
|
|
135
175
|
VirtualListNodeState virtualList;
|
|
176
|
+
FirstLineBackground firstLineBackground;
|
|
177
|
+
FirstLineFragment firstLineFragment;
|
|
178
|
+
InlineStaticPosition inlineStaticPosition;
|
|
136
179
|
|
|
137
180
|
void clear()
|
|
138
181
|
{
|
|
139
182
|
attributes.clear();
|
|
140
183
|
listeners.clear();
|
|
141
184
|
customProperties.clear();
|
|
185
|
+
inlineCustomProperties.clear();
|
|
142
186
|
defaultStyles.clear();
|
|
143
187
|
inlineStyles.clear();
|
|
188
|
+
inlineGridTemplates[0] = inlineGridTemplates[1] = kInvalidCssAtom;
|
|
189
|
+
inlineGridShorthandMask = 0;
|
|
190
|
+
gridLayout.reset();
|
|
144
191
|
virtualList = VirtualListNodeState{};
|
|
192
|
+
firstLineBackground = FirstLineBackground{};
|
|
193
|
+
firstLineFragment = FirstLineFragment{};
|
|
194
|
+
inlineStaticPosition = InlineStaticPosition{};
|
|
145
195
|
}
|
|
146
196
|
};
|
|
147
197
|
|
|
@@ -162,6 +212,9 @@ struct TreeState {
|
|
|
162
212
|
int mountedRoot = -1;
|
|
163
213
|
int mountedWidth = 0;
|
|
164
214
|
int mountedHeight = 0;
|
|
215
|
+
// Conservative fast-out for fixed-descendant clip/scroll checks. Set on
|
|
216
|
+
// first use and retained until tree state is reset.
|
|
217
|
+
bool fixedPositionUsed = false;
|
|
165
218
|
int lastFrameMs = 0;
|
|
166
219
|
// Monotonic counter bumped on every mount()/refresh() — i.e. whenever the
|
|
167
220
|
// reactive tree is (re)built. Lets native renderers (macOS) skip an entire
|
|
@@ -226,6 +279,7 @@ struct TreeState {
|
|
|
226
279
|
// consulted by InputRenderer::record on the pixel target. The macOS
|
|
227
280
|
// renderer ignores these (NSResponder owns its own caret).
|
|
228
281
|
int activeInputId = -1;
|
|
282
|
+
int hoveredNodeId = -1;
|
|
229
283
|
int caretLastFlipMs = 0;
|
|
230
284
|
bool caretVisible = true;
|
|
231
285
|
};
|