@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/tree_nodes.cpp
CHANGED
|
@@ -17,16 +17,16 @@ namespace {
|
|
|
17
17
|
|
|
18
18
|
bool nodeCanDrawWithoutCanvas(const Node &node)
|
|
19
19
|
{
|
|
20
|
-
if (node.
|
|
20
|
+
if (node.computedStyle().display == 1) return false;
|
|
21
21
|
if (node.type == NodeType::Canvas) return false;
|
|
22
22
|
// A <camera> leaf paints itself from the platform preview buffer (or a
|
|
23
23
|
// native overlay), never via the box renderer — treat it like a canvas.
|
|
24
24
|
if (node.type == NodeType::Camera) return false;
|
|
25
|
-
if (node.
|
|
25
|
+
if (node.computedStyle().has_bg || hasAnyBorder(node.computedStyle())) return true;
|
|
26
26
|
if (node.type == NodeType::Text && !node.text.empty()) return true;
|
|
27
27
|
if (node.type == NodeType::Image && node.image_id >= 0) return true;
|
|
28
28
|
if (node.type == NodeType::VirtualList) return true;
|
|
29
|
-
if (isViewLikeNodeType(node.type) && node.
|
|
29
|
+
if (isViewLikeNodeType(node.type) && node.computedStyle().overflow == 2) return true;
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -85,7 +85,7 @@ bool canUseDisplayFramebuffer(TreeState &state, int id, int width, int height)
|
|
|
85
85
|
int visibleCanvasCount = 0;
|
|
86
86
|
for (int i = 0; i < state.nodeCount; i++) {
|
|
87
87
|
Node &node = state.nodes[i];
|
|
88
|
-
if (node.
|
|
88
|
+
if (node.computedStyle().display == 1) continue;
|
|
89
89
|
if (node.type == NodeType::Canvas) visibleCanvasCount++;
|
|
90
90
|
if (i != id && nodeCanDrawWithoutCanvas(node)) return failWhy(5, i);
|
|
91
91
|
}
|
|
@@ -104,7 +104,9 @@ void resetNodeSlot(TreeState &state, int id)
|
|
|
104
104
|
// gap before the next record reads freed memory.
|
|
105
105
|
if (!state.nodes[id].text.empty()) DisplayList::instance().scrubNodeText(state.nodes[id].text.c_str());
|
|
106
106
|
releaseRareData(id); // frees the rare-data block: attributes, listeners, custom props, virtual-list
|
|
107
|
-
|
|
107
|
+
#if GEA_CSS_RARE_STYLE
|
|
108
|
+
releaseRareStyle(state.nodes[id].mutableStyle().rare_style); // frees the cold-style block
|
|
109
|
+
#endif
|
|
108
110
|
state.classLists[id].clear();
|
|
109
111
|
state.canvases.remove(id);
|
|
110
112
|
state.nodeCommandDirty[id] = 0;
|
|
@@ -114,7 +116,8 @@ void resetNodeSlot(TreeState &state, int id)
|
|
|
114
116
|
state.nodeInBackdrop[id] = 0;
|
|
115
117
|
state.nodeActive[id] = 0;
|
|
116
118
|
NodeLifecycle::init(&state.nodes[id], NodeType::View);
|
|
117
|
-
|
|
119
|
+
LayoutEngine::instance().resetNodeLayoutState(id);
|
|
120
|
+
state.nodes[id].mutableStyle().display = kDisplayNone;
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
void trimInactiveTail(TreeState &state)
|
|
@@ -128,14 +131,14 @@ bool localAbsoluteLeafTreeMutation(const TreeState &state, int child)
|
|
|
128
131
|
{
|
|
129
132
|
if (child < 0 || child >= state.nodeCount) return false;
|
|
130
133
|
const Node &node = state.nodes[child];
|
|
131
|
-
if (node.
|
|
132
|
-
if (node.
|
|
133
|
-
if (node.
|
|
134
|
+
if (node.computedStyle().display == kDisplayNone) return false;
|
|
135
|
+
if (node.computedStyle().position != 1) return false;
|
|
136
|
+
if (node.computedStyle().width == kUnset || node.computedStyle().height == kUnset) return false;
|
|
134
137
|
if (node.first_child >= 0) return false;
|
|
135
138
|
if (node.type == NodeType::Text || node.type == NodeType::Canvas || node.type == NodeType::VirtualList) return false;
|
|
136
139
|
if (!isViewLikeNodeType(node.type) && node.type != NodeType::Image) return false;
|
|
137
|
-
if (rstyle(node.
|
|
138
|
-
if (rstyle(node.
|
|
140
|
+
if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0 || node.computedStyle().mask_right_fade_width > 0) return false;
|
|
141
|
+
if ((GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0) > 0) return false;
|
|
139
142
|
return true;
|
|
140
143
|
}
|
|
141
144
|
|
|
@@ -143,6 +146,8 @@ bool localAbsoluteLeafTreeMutation(const TreeState &state, int child)
|
|
|
143
146
|
|
|
144
147
|
void Tree::clear()
|
|
145
148
|
{
|
|
149
|
+
LayoutEngine::instance().endLayoutPass();
|
|
150
|
+
LayoutEngine::instance().releasePersistentLayoutStorage();
|
|
146
151
|
auto &state = treeState();
|
|
147
152
|
state.refreshSerial++;
|
|
148
153
|
if (state.refreshSerial == 0) state.refreshSerial = 1;
|
|
@@ -184,9 +189,11 @@ void Tree::clear()
|
|
|
184
189
|
std::memset(state.nodeCommandDirty, 0, sizeof(state.nodeCommandDirty));
|
|
185
190
|
std::memset(state.nodeCommandDirtyBoundsValid, 0, sizeof(state.nodeCommandDirtyBoundsValid));
|
|
186
191
|
std::memset(state.nodeCommandDirtyCanOverpaint, 0, sizeof(state.nodeCommandDirtyCanOverpaint));
|
|
192
|
+
#if GEA_CSS_SCROLLING
|
|
187
193
|
std::memset(state.scrollDirtyNodes, 0, sizeof(state.scrollDirtyNodes));
|
|
188
194
|
state.scrollDirtyAny = false;
|
|
189
195
|
state.pendingScrollIntoViewNode = -1;
|
|
196
|
+
#endif
|
|
190
197
|
// Drop display-list commands and growable render scratch from the previous app.
|
|
191
198
|
// Per-frame DisplayList::clear() keeps capacity for reuse; app/tree reset is the
|
|
192
199
|
// point where a large app should stop poisoning a smaller app's memory shape.
|
|
@@ -225,6 +232,7 @@ int Tree::createNode(NodeType type)
|
|
|
225
232
|
state.nodeActive[id] = 1;
|
|
226
233
|
releaseRareData(id); // free any block from a prior occupant before reinit
|
|
227
234
|
NodeLifecycle::init(&state.nodes[id], type);
|
|
235
|
+
LayoutEngine::instance().resetNodeLayoutState(id);
|
|
228
236
|
state.classLists[id].clear();
|
|
229
237
|
if (type == NodeType::VirtualList) VirtualListRenderer::init(id);
|
|
230
238
|
return id;
|
|
@@ -240,18 +248,22 @@ int Tree::cloneNode(int sourceId, bool deep)
|
|
|
240
248
|
// is safe; an ACTIVE source slot can never be the one createNode reused.
|
|
241
249
|
const Node &source = state.nodes[sourceId];
|
|
242
250
|
Node &clone = state.nodes[id];
|
|
243
|
-
clone.
|
|
244
|
-
// clone.
|
|
251
|
+
clone.mutableStyle() = source.computedStyle();
|
|
252
|
+
// clone.computedStyle() copied source's rare_style HANDLE (shared pool entry). Give the
|
|
245
253
|
// clone its own entry with the same contents, so mutating one never aliases.
|
|
246
|
-
|
|
247
|
-
|
|
254
|
+
#if GEA_CSS_RARE_STYLE
|
|
255
|
+
clone.mutableStyle().rare_style = -1;
|
|
256
|
+
if (source.computedStyle().rare_style >= 0) rstyleMut(clone.mutableStyle()) = rstyle(source.computedStyle());
|
|
257
|
+
#endif
|
|
248
258
|
clone.text = source.text;
|
|
259
|
+
#if GEA_UI_IMAGE_NODES
|
|
249
260
|
clone.image_id = source.image_id;
|
|
261
|
+
#endif
|
|
250
262
|
clone.tag_id = source.tag_id; // interned tag id — just copy the handle
|
|
251
263
|
// Copy attributes + custom properties (DOM cloneNode semantics) but NOT
|
|
252
264
|
// listeners or virtual-list state. All live in the rare-data block; allocate
|
|
253
|
-
// one for the clone only if the source has any. (rareDataFor returns
|
|
254
|
-
//
|
|
265
|
+
// one for the clone only if the source has any. (rareDataFor returns an owned
|
|
266
|
+
// record whose address is stable across the ensureRareData growth below, so
|
|
255
267
|
// srcRd stays valid.)
|
|
256
268
|
if (const NodeRareData *srcRd = rareDataFor(sourceId)) {
|
|
257
269
|
NodeRareData &cloneRd = ensureRareData(id);
|
|
@@ -260,9 +272,11 @@ int Tree::cloneNode(int sourceId, bool deep)
|
|
|
260
272
|
cloneRd.defaultStyles = srcRd->defaultStyles;
|
|
261
273
|
cloneRd.inlineStyles = srcRd->inlineStyles;
|
|
262
274
|
cloneRd.inlineCustomProperties = srcRd->inlineCustomProperties;
|
|
275
|
+
#if GEA_CSS_GRID
|
|
263
276
|
cloneRd.inlineGridTemplates[0] = srcRd->inlineGridTemplates[0];
|
|
264
277
|
cloneRd.inlineGridTemplates[1] = srcRd->inlineGridTemplates[1];
|
|
265
278
|
cloneRd.inlineGridShorthandMask = srcRd->inlineGridShorthandMask;
|
|
279
|
+
#endif
|
|
266
280
|
}
|
|
267
281
|
state.classLists[id] = state.classLists[sourceId];
|
|
268
282
|
// Listeners deliberately NOT copied (DOM cloneNode semantics) — compiled
|
|
@@ -304,7 +318,7 @@ int Tree::createCamera() { return createNode(NodeType::Camera); }
|
|
|
304
318
|
int Tree::createAudio()
|
|
305
319
|
{
|
|
306
320
|
const int id = createNode(NodeType::Audio);
|
|
307
|
-
if (id >= 0) treeState().nodes[id].
|
|
321
|
+
if (id >= 0) treeState().nodes[id].mutableStyle().display = kDisplayNone;
|
|
308
322
|
return id;
|
|
309
323
|
}
|
|
310
324
|
int Tree::createVirtualList() { return createNode(NodeType::VirtualList); }
|
|
@@ -466,7 +480,9 @@ void Tree::markCanvasDirty(int id)
|
|
|
466
480
|
if (surface && surface->displayBacked()) return;
|
|
467
481
|
state.nodes[id].render.dirty = 1;
|
|
468
482
|
state.nodes[id].render.layout_dirty = 1;
|
|
483
|
+
#if GEA_CSS_SCROLLING
|
|
469
484
|
state.nodes[id].render.non_scroll_dirty = 1;
|
|
485
|
+
#endif
|
|
470
486
|
// Content-only repaint: the canvas's BlitImage command is unchanged frame
|
|
471
487
|
// to frame (same surface pointer, same rect) — only the pixels it points
|
|
472
488
|
// at were redrawn. The in-place refresh path re-records and emits a flush
|
|
@@ -513,7 +529,9 @@ void Tree::setParent(int child, int parent)
|
|
|
513
529
|
if (!localMutation) {
|
|
514
530
|
old_parent->render.dirty = 1;
|
|
515
531
|
old_parent->render.layout_dirty = 1;
|
|
532
|
+
#if GEA_CSS_SCROLLING
|
|
516
533
|
old_parent->render.non_scroll_dirty = 1;
|
|
534
|
+
#endif
|
|
517
535
|
}
|
|
518
536
|
}
|
|
519
537
|
if (c->prev_sibling >= 0) state.nodes[c->prev_sibling].next_sibling = c->next_sibling;
|
|
@@ -530,11 +548,15 @@ void Tree::setParent(int child, int parent)
|
|
|
530
548
|
if (!localMutation) {
|
|
531
549
|
state.nodes[parent].render.dirty = 1;
|
|
532
550
|
state.nodes[parent].render.layout_dirty = 1;
|
|
551
|
+
#if GEA_CSS_SCROLLING
|
|
533
552
|
state.nodes[parent].render.non_scroll_dirty = 1;
|
|
553
|
+
#endif
|
|
534
554
|
}
|
|
535
555
|
c->render.dirty = 1;
|
|
536
556
|
c->render.layout_dirty = 1;
|
|
557
|
+
#if GEA_CSS_SCROLLING
|
|
537
558
|
c->render.non_scroll_dirty = 1;
|
|
559
|
+
#endif
|
|
538
560
|
if (localMutation)
|
|
539
561
|
markDisplayListContentDirty();
|
|
540
562
|
else
|
|
@@ -566,7 +588,9 @@ void Tree::insertBefore(int child, int parent, int reference)
|
|
|
566
588
|
if (!localMutation) {
|
|
567
589
|
old_parent->render.dirty = 1;
|
|
568
590
|
old_parent->render.layout_dirty = 1;
|
|
591
|
+
#if GEA_CSS_SCROLLING
|
|
569
592
|
old_parent->render.non_scroll_dirty = 1;
|
|
593
|
+
#endif
|
|
570
594
|
}
|
|
571
595
|
}
|
|
572
596
|
if (c->prev_sibling >= 0) state.nodes[c->prev_sibling].next_sibling = c->next_sibling;
|
|
@@ -585,11 +609,15 @@ void Tree::insertBefore(int child, int parent, int reference)
|
|
|
585
609
|
if (!localMutation) {
|
|
586
610
|
state.nodes[parent].render.dirty = 1;
|
|
587
611
|
state.nodes[parent].render.layout_dirty = 1;
|
|
612
|
+
#if GEA_CSS_SCROLLING
|
|
588
613
|
state.nodes[parent].render.non_scroll_dirty = 1;
|
|
614
|
+
#endif
|
|
589
615
|
}
|
|
590
616
|
c->render.dirty = 1;
|
|
591
617
|
c->render.layout_dirty = 1;
|
|
618
|
+
#if GEA_CSS_SCROLLING
|
|
592
619
|
c->render.non_scroll_dirty = 1;
|
|
620
|
+
#endif
|
|
593
621
|
if (localMutation)
|
|
594
622
|
markDisplayListContentDirty();
|
|
595
623
|
else
|
|
@@ -610,18 +638,22 @@ void Tree::removeNode(int id)
|
|
|
610
638
|
markDisplayListDirty();
|
|
611
639
|
n->render.dirty = 1;
|
|
612
640
|
n->render.layout_dirty = 1;
|
|
641
|
+
#if GEA_CSS_SCROLLING
|
|
613
642
|
n->render.non_scroll_dirty = 1;
|
|
643
|
+
#endif
|
|
614
644
|
if (n->parent >= 0) {
|
|
615
645
|
Node *p = &state.nodes[n->parent];
|
|
616
646
|
p->render.dirty = 1;
|
|
617
647
|
p->render.layout_dirty = 1;
|
|
648
|
+
#if GEA_CSS_SCROLLING
|
|
618
649
|
p->render.non_scroll_dirty = 1;
|
|
650
|
+
#endif
|
|
619
651
|
if (p->first_child == id) p->first_child = n->next_sibling;
|
|
620
652
|
if (p->last_child == id) p->last_child = n->prev_sibling;
|
|
621
653
|
}
|
|
622
654
|
if (n->prev_sibling >= 0) state.nodes[n->prev_sibling].next_sibling = n->next_sibling;
|
|
623
655
|
if (n->next_sibling >= 0) state.nodes[n->next_sibling].prev_sibling = n->prev_sibling;
|
|
624
|
-
n->
|
|
656
|
+
n->mutableStyle().display = 1;
|
|
625
657
|
n->parent = -1;
|
|
626
658
|
n->first_child = -1;
|
|
627
659
|
n->last_child = -1;
|