@geastack/engine 0.1.5 → 0.1.7

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.
Files changed (45) hide show
  1. package/README.md +70 -0
  2. package/canvas.cpp +86 -30
  3. package/css/animation.h +64 -0
  4. package/css/declarative.h +6 -0
  5. package/css/engine.h +25 -1
  6. package/image_store.cpp +136 -33
  7. package/package.json +2 -2
  8. package/ui/CSS_FEATURES.md +261 -0
  9. package/ui/absolute_leaf_refresh.cpp +42 -39
  10. package/ui/core.cpp +32 -1
  11. package/ui/css_atom.cpp +6 -0
  12. package/ui/css_atom.h +2 -0
  13. package/ui/css_features.h +282 -0
  14. package/ui/display_invalidation.cpp +29 -0
  15. package/ui/flex_balance.h +73 -0
  16. package/ui/image_node.cpp +33 -28
  17. package/ui/input.cpp +88 -38
  18. package/ui/input_render.cpp +17 -13
  19. package/ui/internal.h +51 -5
  20. package/ui/layout.cpp +2601 -441
  21. package/ui/layout_snapshot.cpp +49 -6
  22. package/ui/node_features.h +18 -0
  23. package/ui/node_lifecycle.cpp +204 -71
  24. package/ui/node_lifecycle.h +1 -0
  25. package/ui/node_model.h +930 -70
  26. package/ui/node_text.h +82 -0
  27. package/ui/render.cpp +793 -352
  28. package/ui/renderer_features.h +19 -0
  29. package/ui/root_scroll_refresh.cpp +46 -24
  30. package/ui/style.cpp +4155 -1073
  31. package/ui/style.h +143 -6
  32. package/ui/style_values.h +16 -0
  33. package/ui/text.cpp +401 -106
  34. package/ui/tree_events.cpp +138 -95
  35. package/ui/tree_events.h +28 -19
  36. package/ui/tree_inspection.h +15 -0
  37. package/ui/tree_internal.h +19 -0
  38. package/ui/tree_nodes.cpp +38 -4
  39. package/ui/tree_render.cpp +119 -40
  40. package/ui/tree_scroll_mirror.cpp +26 -0
  41. package/ui/tree_state.cpp +261 -114
  42. package/ui/tree_state.h +121 -16
  43. package/ui/tree_style.cpp +609 -82
  44. package/ui/view.cpp +720 -299
  45. package/ui/virtual_keyboard.cpp +10 -3
package/ui/tree_nodes.cpp CHANGED
@@ -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
+ #if GEA_CSS_RARE_STYLE
107
108
  releaseRareStyle(state.nodes[id].style.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;
@@ -134,8 +136,8 @@ bool localAbsoluteLeafTreeMutation(const TreeState &state, int child)
134
136
  if (node.first_child >= 0) return false;
135
137
  if (node.type == NodeType::Text || node.type == NodeType::Canvas || node.type == NodeType::VirtualList) return false;
136
138
  if (!isViewLikeNodeType(node.type) && node.type != NodeType::Image) return false;
137
- if (rstyle(node.style).filter_blur_radius > 0 || node.style.mask_right_fade_width > 0) return false;
138
- if (rstyle(node.style).box_shadow_alpha > 0) return false;
139
+ if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0 || node.style.mask_right_fade_width > 0) return false;
140
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0) > 0) return false;
139
141
  return true;
140
142
  }
141
143
 
@@ -176,6 +178,7 @@ void Tree::clear()
176
178
  // switch and bounded at kMaxNodes (~512).
177
179
  for (int i = 0; i < kMaxNodes; i++) state.nodes[i] = Node{};
178
180
  state.nodeCount = 0;
181
+ state.fixedPositionUsed = false;
179
182
  state.mountedRoot = -1;
180
183
  state.mountedWidth = 0;
181
184
  state.mountedHeight = 0;
@@ -183,9 +186,11 @@ void Tree::clear()
183
186
  std::memset(state.nodeCommandDirty, 0, sizeof(state.nodeCommandDirty));
184
187
  std::memset(state.nodeCommandDirtyBoundsValid, 0, sizeof(state.nodeCommandDirtyBoundsValid));
185
188
  std::memset(state.nodeCommandDirtyCanOverpaint, 0, sizeof(state.nodeCommandDirtyCanOverpaint));
189
+ #if GEA_CSS_SCROLLING
186
190
  std::memset(state.scrollDirtyNodes, 0, sizeof(state.scrollDirtyNodes));
187
191
  state.scrollDirtyAny = false;
188
192
  state.pendingScrollIntoViewNode = -1;
193
+ #endif
189
194
  // Drop display-list commands and growable render scratch from the previous app.
190
195
  // Per-frame DisplayList::clear() keeps capacity for reuse; app/tree reset is the
191
196
  // point where a large app should stop poisoning a smaller app's memory shape.
@@ -242,15 +247,19 @@ int Tree::cloneNode(int sourceId, bool deep)
242
247
  clone.style = source.style;
243
248
  // clone.style copied source's rare_style HANDLE (shared pool entry). Give the
244
249
  // clone its own entry with the same contents, so mutating one never aliases.
250
+ #if GEA_CSS_RARE_STYLE
245
251
  clone.style.rare_style = -1;
246
252
  if (source.style.rare_style >= 0) rstyleMut(clone.style) = rstyle(source.style);
253
+ #endif
247
254
  clone.text = source.text;
255
+ #if GEA_UI_IMAGE_NODES
248
256
  clone.image_id = source.image_id;
257
+ #endif
249
258
  clone.tag_id = source.tag_id; // interned tag id — just copy the handle
250
259
  // Copy attributes + custom properties (DOM cloneNode semantics) but NOT
251
260
  // listeners or virtual-list state. All live in the rare-data block; allocate
252
- // one for the clone only if the source has any. (rareDataFor returns a deque
253
- // element whose address is stable across the ensureRareData growth below, so
261
+ // one for the clone only if the source has any. (rareDataFor returns an owned
262
+ // record whose address is stable across the ensureRareData growth below, so
254
263
  // srcRd stays valid.)
255
264
  if (const NodeRareData *srcRd = rareDataFor(sourceId)) {
256
265
  NodeRareData &cloneRd = ensureRareData(id);
@@ -258,6 +267,12 @@ int Tree::cloneNode(int sourceId, bool deep)
258
267
  cloneRd.customProperties = srcRd->customProperties;
259
268
  cloneRd.defaultStyles = srcRd->defaultStyles;
260
269
  cloneRd.inlineStyles = srcRd->inlineStyles;
270
+ cloneRd.inlineCustomProperties = srcRd->inlineCustomProperties;
271
+ #if GEA_CSS_GRID
272
+ cloneRd.inlineGridTemplates[0] = srcRd->inlineGridTemplates[0];
273
+ cloneRd.inlineGridTemplates[1] = srcRd->inlineGridTemplates[1];
274
+ cloneRd.inlineGridShorthandMask = srcRd->inlineGridShorthandMask;
275
+ #endif
261
276
  }
262
277
  state.classLists[id] = state.classLists[sourceId];
263
278
  // Listeners deliberately NOT copied (DOM cloneNode semantics) — compiled
@@ -461,7 +476,9 @@ void Tree::markCanvasDirty(int id)
461
476
  if (surface && surface->displayBacked()) return;
462
477
  state.nodes[id].render.dirty = 1;
463
478
  state.nodes[id].render.layout_dirty = 1;
479
+ #if GEA_CSS_SCROLLING
464
480
  state.nodes[id].render.non_scroll_dirty = 1;
481
+ #endif
465
482
  // Content-only repaint: the canvas's BlitImage command is unchanged frame
466
483
  // to frame (same surface pointer, same rect) — only the pixels it points
467
484
  // at were redrawn. The in-place refresh path re-records and emits a flush
@@ -508,7 +525,9 @@ void Tree::setParent(int child, int parent)
508
525
  if (!localMutation) {
509
526
  old_parent->render.dirty = 1;
510
527
  old_parent->render.layout_dirty = 1;
528
+ #if GEA_CSS_SCROLLING
511
529
  old_parent->render.non_scroll_dirty = 1;
530
+ #endif
512
531
  }
513
532
  }
514
533
  if (c->prev_sibling >= 0) state.nodes[c->prev_sibling].next_sibling = c->next_sibling;
@@ -525,11 +544,15 @@ void Tree::setParent(int child, int parent)
525
544
  if (!localMutation) {
526
545
  state.nodes[parent].render.dirty = 1;
527
546
  state.nodes[parent].render.layout_dirty = 1;
547
+ #if GEA_CSS_SCROLLING
528
548
  state.nodes[parent].render.non_scroll_dirty = 1;
549
+ #endif
529
550
  }
530
551
  c->render.dirty = 1;
531
552
  c->render.layout_dirty = 1;
553
+ #if GEA_CSS_SCROLLING
532
554
  c->render.non_scroll_dirty = 1;
555
+ #endif
533
556
  if (localMutation)
534
557
  markDisplayListContentDirty();
535
558
  else
@@ -561,7 +584,9 @@ void Tree::insertBefore(int child, int parent, int reference)
561
584
  if (!localMutation) {
562
585
  old_parent->render.dirty = 1;
563
586
  old_parent->render.layout_dirty = 1;
587
+ #if GEA_CSS_SCROLLING
564
588
  old_parent->render.non_scroll_dirty = 1;
589
+ #endif
565
590
  }
566
591
  }
567
592
  if (c->prev_sibling >= 0) state.nodes[c->prev_sibling].next_sibling = c->next_sibling;
@@ -580,11 +605,15 @@ void Tree::insertBefore(int child, int parent, int reference)
580
605
  if (!localMutation) {
581
606
  state.nodes[parent].render.dirty = 1;
582
607
  state.nodes[parent].render.layout_dirty = 1;
608
+ #if GEA_CSS_SCROLLING
583
609
  state.nodes[parent].render.non_scroll_dirty = 1;
610
+ #endif
584
611
  }
585
612
  c->render.dirty = 1;
586
613
  c->render.layout_dirty = 1;
614
+ #if GEA_CSS_SCROLLING
587
615
  c->render.non_scroll_dirty = 1;
616
+ #endif
588
617
  if (localMutation)
589
618
  markDisplayListContentDirty();
590
619
  else
@@ -596,6 +625,7 @@ void Tree::removeNode(int id)
596
625
  {
597
626
  auto &state = treeState();
598
627
  if (id < 0 || id >= state.nodeCount || !state.nodeActive[id]) return;
628
+ if (containsNode(id, state.hoveredNodeId)) pointerHover(-1, -1);
599
629
  while (state.nodes[id].first_child >= 0) {
600
630
  removeNode(state.nodes[id].first_child);
601
631
  if (id >= state.nodeCount || !state.nodeActive[id]) return;
@@ -604,12 +634,16 @@ void Tree::removeNode(int id)
604
634
  markDisplayListDirty();
605
635
  n->render.dirty = 1;
606
636
  n->render.layout_dirty = 1;
637
+ #if GEA_CSS_SCROLLING
607
638
  n->render.non_scroll_dirty = 1;
639
+ #endif
608
640
  if (n->parent >= 0) {
609
641
  Node *p = &state.nodes[n->parent];
610
642
  p->render.dirty = 1;
611
643
  p->render.layout_dirty = 1;
644
+ #if GEA_CSS_SCROLLING
612
645
  p->render.non_scroll_dirty = 1;
646
+ #endif
613
647
  if (p->first_child == id) p->first_child = n->next_sibling;
614
648
  if (p->last_child == id) p->last_child = n->prev_sibling;
615
649
  }
@@ -135,6 +135,7 @@ namespace gea::embedded::ui
135
135
  }
136
136
  #endif
137
137
 
138
+ #if GEA_CSS_SCROLLING
138
139
  struct PreservedScrollOffset
139
140
  {
140
141
  int32_t x = 0;
@@ -213,6 +214,8 @@ namespace gea::embedded::ui
213
214
  }
214
215
  }
215
216
 
217
+ #endif
218
+
216
219
  int dirtyRectArea(const DirtyRegions::Rect &r)
217
220
  {
218
221
  if (r.x0 > r.x1 || r.y0 > r.y1)
@@ -244,10 +247,12 @@ namespace gea::embedded::ui
244
247
  {
245
248
  for (int i = 0; i < 4; ++i)
246
249
  {
247
- if (style.border_radius[i] > 0)
250
+ if (style.border_radius[GEA_CSS_RADIUS_INDEX(i)] > 0)
248
251
  return true;
249
- if (style.border_radius_percent[i] != kUnset && style.border_radius_percent[i] > 0)
252
+ #if GEA_CSS_PERCENT_RADIUS
253
+ if (style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != kUnset && style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] > 0)
250
254
  return true;
255
+ #endif
251
256
  }
252
257
  return false;
253
258
  }
@@ -256,11 +261,11 @@ namespace gea::embedded::ui
256
261
  {
257
262
  if (hasAnyBorder(node.style))
258
263
  return true;
259
- if (rstyle(node.style).filter_blur_radius > 0 || node.render.previous_filter_blur_radius > 0)
264
+ if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0 || node.render.previous_filter_blur_radius > 0)
260
265
  return true;
261
266
  if (node.style.mask_right_fade_width > 0)
262
267
  return true;
263
- if (rstyle(node.style).box_shadow_alpha > 0)
268
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0) > 0)
264
269
  return true;
265
270
  return node.style.has_bg && (styleHasRoundedRasterEdge(node.style) || node.style.bg_alpha < 255);
266
271
  }
@@ -408,37 +413,44 @@ namespace gea::embedded::ui
408
413
  bool hasTransformState(const Node &node)
409
414
  {
410
415
  const RareStyle &rs = rstyle(node.style); // one pool lookup, not 11
411
- return rs.transform_rotate != 0 ||
416
+ return hasIndividualLinearTransform(rs) || hadIndividualLinearTransform(node.render) ||
417
+ rs.transform_rotate != 0 ||
412
418
  node.render.previous_transform_rotate != 0 ||
413
419
  rs.transform_rotate_x != 0 ||
414
420
  node.render.previous_transform_rotate_x != 0 ||
415
421
  rs.transform_rotate_y != 0 ||
416
422
  node.render.previous_transform_rotate_y != 0 ||
417
- rs.transform_translate_x != 0 ||
423
+ composedTranslateX(rs) != 0 ||
418
424
  node.render.previous_transform_translate_x != 0 ||
419
- rs.transform_translate_y != 0 ||
425
+ composedTranslateY(rs) != 0 ||
420
426
  node.render.previous_transform_translate_y != 0 ||
421
- rs.transform_translate_z != 0 ||
427
+ composedTranslateZ(rs) != 0 ||
422
428
  node.render.previous_transform_translate_z != 0 ||
423
- rs.transform_translate_x_percent != 0 ||
429
+ composedTranslateXPercent(rs) != 0 ||
424
430
  node.render.previous_transform_translate_x_percent != 0 ||
425
- rs.transform_translate_y_percent != 0 ||
431
+ composedTranslateYPercent(rs) != 0 ||
426
432
  node.render.previous_transform_translate_y_percent != 0 ||
427
433
  rs.transform_scale_x != 1000 ||
428
434
  node.render.previous_transform_scale_x != 1000 ||
429
435
  rs.transform_scale_y != 1000 ||
436
+ rs.transform_scale_z != 1000 ||
430
437
  node.render.previous_transform_scale_y != 1000 ||
438
+ node.render.previous_transform_scale_z != 1000 ||
431
439
  rs.perspective > 0 ||
432
440
  node.render.previous_perspective > 0;
433
441
  }
434
442
 
435
443
  bool hasThreeDimensionalTransformState(const Node &node)
436
444
  {
437
- return rstyle(node.style).transform_rotate_x != 0 ||
445
+ const auto &r = rstyle(node.style);
446
+ return ((r.rotate_angle % 3600) && (r.rotate_axis_x || r.rotate_axis_y)) ||
447
+ ((node.render.previous_rotate_angle % 3600) && (node.render.previous_rotate_axis_x || node.render.previous_rotate_axis_y)) ||
448
+ r.scale_z != 1000 || node.render.previous_scale_z != 1000 ||
449
+ rstyle(node.style).transform_rotate_x != 0 ||
438
450
  node.render.previous_transform_rotate_x != 0 ||
439
451
  rstyle(node.style).transform_rotate_y != 0 ||
440
452
  node.render.previous_transform_rotate_y != 0 ||
441
- rstyle(node.style).transform_translate_z != 0 ||
453
+ composedTranslateZ(rstyle(node.style)) != 0 ||
442
454
  node.render.previous_transform_translate_z != 0 ||
443
455
  rstyle(node.style).perspective > 0 ||
444
456
  node.render.previous_perspective > 0;
@@ -503,15 +515,17 @@ namespace gea::embedded::ui
503
515
  double ry[4]{};
504
516
  for (int i = 0; i < 4; ++i)
505
517
  {
506
- if (node.style.border_radius_percent[i] != kUnset)
518
+ #if GEA_CSS_PERCENT_RADIUS
519
+ if (node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != kUnset)
507
520
  {
508
- const double p = static_cast<double>(node.style.border_radius_percent[i]) / 1000.0;
521
+ const double p = static_cast<double>(node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)]) / 1000.0;
509
522
  rx[i] = std::max(0.0, width * p);
510
523
  ry[i] = std::max(0.0, height * p);
511
524
  }
512
525
  else
526
+ #endif
513
527
  {
514
- const double r = static_cast<double>(std::max(0, static_cast<int>(node.style.border_radius[i])));
528
+ const double r = static_cast<double>(std::max(0, static_cast<int>(node.style.border_radius[GEA_CSS_RADIUS_INDEX(i)])));
515
529
  rx[i] = r;
516
530
  ry[i] = r;
517
531
  }
@@ -639,7 +653,7 @@ namespace gea::embedded::ui
639
653
  return true;
640
654
  if (node.style.has_bg || hasAnyBorder(node.style))
641
655
  return true;
642
- if (rstyle(node.style).box_shadow_alpha > 0 || rstyle(node.style).filter_blur_radius > 0)
656
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0) > 0 || (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0)
643
657
  return true;
644
658
  if (node.style.mask_right_fade_width > 0)
645
659
  return true;
@@ -898,7 +912,7 @@ namespace gea::embedded::ui
898
912
 
899
913
  int filterBlurRadiusForNode(const Node &node, bool usePrevious)
900
914
  {
901
- return usePrevious ? node.render.previous_filter_blur_radius : rstyle(node.style).filter_blur_radius;
915
+ return usePrevious ? node.render.previous_filter_blur_radius : (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
902
916
  }
903
917
 
904
918
  DirtyRegions::Rect filterBlurBoundsRect(const Node &node, bool usePrevious, int origin)
@@ -1158,16 +1172,17 @@ namespace gea::embedded::ui
1158
1172
 
1159
1173
  bool panNodeHasTransform(const Node &n)
1160
1174
  {
1161
- return rstyle(n.style).transform_rotate != 0 || n.render.previous_transform_rotate != 0 ||
1175
+ return hasIndividualLinearTransform(rstyle(n.style)) || hadIndividualLinearTransform(n.render) ||
1176
+ rstyle(n.style).transform_rotate != 0 || n.render.previous_transform_rotate != 0 ||
1162
1177
  rstyle(n.style).transform_rotate_x != 0 || n.render.previous_transform_rotate_x != 0 ||
1163
1178
  rstyle(n.style).transform_rotate_y != 0 || n.render.previous_transform_rotate_y != 0 ||
1164
- rstyle(n.style).transform_translate_x != 0 || n.render.previous_transform_translate_x != 0 ||
1165
- rstyle(n.style).transform_translate_y != 0 || n.render.previous_transform_translate_y != 0 ||
1166
- rstyle(n.style).transform_translate_z != 0 || n.render.previous_transform_translate_z != 0 ||
1167
- rstyle(n.style).transform_translate_x_percent != 0 || n.render.previous_transform_translate_x_percent != 0 ||
1168
- rstyle(n.style).transform_translate_y_percent != 0 || n.render.previous_transform_translate_y_percent != 0 ||
1179
+ composedTranslateX(rstyle(n.style)) != 0 || n.render.previous_transform_translate_x != 0 ||
1180
+ composedTranslateY(rstyle(n.style)) != 0 || n.render.previous_transform_translate_y != 0 ||
1181
+ composedTranslateZ(rstyle(n.style)) != 0 || n.render.previous_transform_translate_z != 0 ||
1182
+ composedTranslateXPercent(rstyle(n.style)) != 0 || n.render.previous_transform_translate_x_percent != 0 ||
1183
+ composedTranslateYPercent(rstyle(n.style)) != 0 || n.render.previous_transform_translate_y_percent != 0 ||
1169
1184
  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 ||
1185
+ 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
1186
  rstyle(n.style).perspective > 0 || n.render.previous_perspective > 0;
1172
1187
  }
1173
1188
 
@@ -1187,7 +1202,7 @@ namespace gea::embedded::ui
1187
1202
  // that paints nothing or a single solid background color, with no gradient/grid,
1188
1203
  // border, radius, shadow, blur, mask, or partial opacity. Images/text/canvas and
1189
1204
  // anything non-uniform return false → they get repainted after the shift.
1190
- bool panNodeIsHorizontallyScrollSafe(const Node &n)
1205
+ bool panNodeIsHorizontallyScrollSafe(const Node &n, int viewportX, int viewportWidth)
1191
1206
  {
1192
1207
  if (n.type != NodeType::View)
1193
1208
  return false;
@@ -1197,22 +1212,35 @@ namespace gea::embedded::ui
1197
1212
  return false;
1198
1213
  for (int r = 0; r < 4; r++)
1199
1214
  {
1200
- if (n.style.border_radius[r] != 0)
1215
+ if (n.style.border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0)
1201
1216
  return false;
1202
- if (n.style.border_radius_percent[r] != kUnset && n.style.border_radius_percent[r] != 0)
1217
+ #if GEA_CSS_PERCENT_RADIUS
1218
+ if (n.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset && n.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != 0)
1203
1219
  return false;
1220
+ #endif
1204
1221
  }
1205
- if (rstyle(n.style).filter_blur_radius > 0)
1222
+ if ((GEA_CSS_FILTERS ? rstyle(n.style).filter_blur_radius : 0) > 0)
1206
1223
  return false;
1207
1224
  if (n.style.mask_right_fade_width > 0)
1208
1225
  return false;
1209
- if (rstyle(n.style).box_shadow_alpha > 0 &&
1210
- (rstyle(n.style).box_shadow_offset_x != 0 || rstyle(n.style).box_shadow_offset_y != 0 ||
1211
- rstyle(n.style).box_shadow_blur_radius != 0 || rstyle(n.style).box_shadow_spread != 0))
1226
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_alpha : 0) > 0 &&
1227
+ ((GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_offset_x : 0) != 0 || (GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_offset_y : 0) != 0 ||
1228
+ (GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_blur_radius : 0) != 0 || (GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_spread : 0) != 0))
1212
1229
  return false;
1213
1230
  if (n.style.has_bg)
1214
1231
  {
1215
- if (n.style.bg_fill == 1)
1232
+ // A narrow solid rectangle still has horizontal edges: scrolling
1233
+ // it creates a ghost just like scrolling text or a rounded control.
1234
+ if (n.style.bg_alpha != 255 || panNodeHasTransform(n) ||
1235
+ n.layout.x > viewportX || n.layout.x + n.layout.width < viewportX + viewportWidth)
1236
+ return false;
1237
+ for (int parent = n.parent; parent >= 0; parent = treeState().nodes[parent].parent) {
1238
+ const Node &clip = treeState().nodes[parent];
1239
+ if (panNodeHasTransform(clip) || (clip.style.overflow &&
1240
+ (clip.layout.x > viewportX || clip.layout.x + clip.layout.width < viewportX + viewportWidth)))
1241
+ return false;
1242
+ }
1243
+ if (styleHasBackgroundImage(n.style))
1216
1244
  return false; // gradient fill (linear/radial/overlay)
1217
1245
  if (rstyle(n.style).bg_grid_axes != 0)
1218
1246
  return false; // grid overlay
@@ -1259,7 +1287,7 @@ namespace gea::embedded::ui
1259
1287
  resetPanCoverage();
1260
1288
  return false;
1261
1289
  }
1262
- if (gHorizontalPanFastPathDisabled)
1290
+ if (gHorizontalPanFastPathDisabled || LayoutEngine::containsViewportFixed(root))
1263
1291
  {
1264
1292
  resetPanCoverage();
1265
1293
  return false;
@@ -1340,6 +1368,13 @@ namespace gea::embedded::ui
1340
1368
  if (absDx >= vw)
1341
1369
  return false; // teleport — a full repaint is simpler and safer
1342
1370
 
1371
+ // Shifting the viewport is useful for a camera/world that spans it,
1372
+ // not a small floating subtree (drag previews, tooltips). For those,
1373
+ // the shift corrupts every stationary sibling and step 5 repaints
1374
+ // nearly the entire screen instead of just the old/new card bounds.
1375
+ if (W->layout.width < vw || W->layout.height < vh)
1376
+ return false;
1377
+
1343
1378
  // 3. Decide what the memcpy can't reproduce and must be repainted explicitly:
1344
1379
  // every wrapper descendant that did NOT translate uniformly with the camera.
1345
1380
  // A descendant needs repainting when it is dirty (its appearance/size/visibility
@@ -1460,7 +1495,7 @@ namespace gea::embedded::ui
1460
1495
  continue;
1461
1496
  if (n->render.dirty)
1462
1497
  continue;
1463
- if (panNodeIsHorizontallyScrollSafe(*n))
1498
+ if (panNodeIsHorizontallyScrollSafe(*n, vx, vw))
1464
1499
  continue;
1465
1500
  const DirtyRegions::Rect b = transformedBoundsRect(*n, false, i);
1466
1501
  if (b.x0 > b.x1 || b.y0 > b.y1)
@@ -1690,11 +1725,15 @@ namespace gea::embedded::ui
1690
1725
  }
1691
1726
  else
1692
1727
  {
1728
+ #if GEA_CSS_SCROLLING
1693
1729
  PreservedScrollOffset scrollOffsets[kMaxNodes];
1694
1730
  preserveScrollOffsets(scrollOffsets, kMaxNodes);
1731
+ #endif
1695
1732
  LayoutEngine::instance().beginLayoutPass();
1696
1733
  LayoutEngine::instance().layoutNode(root, width, height);
1734
+ #if GEA_CSS_SCROLLING
1697
1735
  restoreScrollOffsetsAfterLayout(scrollOffsets, kMaxNodes);
1736
+ #endif
1698
1737
  applyPendingScrollIntoView();
1699
1738
  LayoutEngine::instance().resolveAbsoluteCoords(root, 0, 0);
1700
1739
  noteLaidOutViewport(root, width, height);
@@ -1808,6 +1847,16 @@ namespace gea::embedded::ui
1808
1847
  auto &state = treeState();
1809
1848
  if (root < 0 || root >= state.nodeCount)
1810
1849
  return;
1850
+ const bool viewportChanged = gLayoutViewportRoot != root ||
1851
+ gLayoutViewportWidth != width || gLayoutViewportHeight != height;
1852
+ if (viewportChanged) {
1853
+ state.displayListDirty = true;
1854
+ state.displayListRebuildStructural = true;
1855
+ state.nodes[root].render.dirty = true;
1856
+ state.nodes[root].render.layout_dirty = true;
1857
+ }
1858
+ state.mountedWidth = width;
1859
+ state.mountedHeight = height;
1811
1860
  // Bump before the scroll-only fast path returns: a scroll-only refresh still
1812
1861
  // moves content, so native renderers must re-sync.
1813
1862
  state.refreshSerial++;
@@ -1815,7 +1864,21 @@ namespace gea::embedded::ui
1815
1864
  perf.treeRefreshCalls++;
1816
1865
  DisplayList::instance().clearRetainedBackgroundRecolors();
1817
1866
 
1818
- if (state.pendingScrollIntoViewNode < 0 && RootScrollOnlyRefresh::refresh(root, width, height))
1867
+ const bool textClipDependencies = DisplayList::instance().hasTextClippedBackgrounds();
1868
+ if (textClipDependencies) {
1869
+ bool changed = state.displayListDirty;
1870
+ for (int i = 0; !changed && i < state.nodeCount; ++i)
1871
+ changed = state.nodes[i].render.dirty || state.nodes[i].render.layout_dirty || state.nodes[i].render.transform_dirty;
1872
+ if (changed) {
1873
+ // Background ink depends on descendants, including those whose own
1874
+ // foreground is transparent. Rebuild and repaint these dependencies
1875
+ // together before considering retained translation/recolor shortcuts.
1876
+ state.displayListDirty = true;
1877
+ state.displayListRebuildStructural = true;
1878
+ state.nodes[root].render.dirty = true;
1879
+ }
1880
+ }
1881
+ if (!textClipDependencies && state.pendingScrollIntoViewNode < 0 && RootScrollOnlyRefresh::refresh(root, width, height))
1819
1882
  return;
1820
1883
 
1821
1884
  // This frame is NOT a pure scroll, so the software scroll register's
@@ -1873,8 +1936,10 @@ namespace gea::embedded::ui
1873
1936
  }
1874
1937
  else
1875
1938
  {
1939
+ #if GEA_CSS_SCROLLING
1876
1940
  PreservedScrollOffset scrollOffsets[kMaxNodes];
1877
1941
  preserveScrollOffsets(scrollOffsets, kMaxNodes);
1942
+ #endif
1878
1943
  // Scoped relayout: when every dirty node sits under a box-stable
1879
1944
  // ancestor (e.g. a city-name text growing inside a fixed-size header),
1880
1945
  // re-lay only that subtree — the memoized available box makes the
@@ -1899,7 +1964,7 @@ namespace gea::embedded::ui
1899
1964
  }
1900
1965
  if (anyLayoutDirty)
1901
1966
  {
1902
- if (state.pendingScrollIntoViewNode < 0)
1967
+ if (!viewportChanged && state.pendingScrollIntoViewNode < 0)
1903
1968
  {
1904
1969
  int scope = scopedRelayoutRoot(state, root);
1905
1970
  if (scope >= 0)
@@ -1925,7 +1990,9 @@ namespace gea::embedded::ui
1925
1990
  LayoutEngine::instance().beginLayoutPass();
1926
1991
  LayoutEngine::instance().layoutNode(root, width, height);
1927
1992
  }
1993
+ #if GEA_CSS_SCROLLING
1928
1994
  restoreScrollOffsetsAfterLayout(scrollOffsets, kMaxNodes);
1995
+ #endif
1929
1996
  applyPendingScrollIntoView();
1930
1997
  if (!scoped)
1931
1998
  LayoutEngine::instance().resolveAbsoluteCoords(root, 0, 0);
@@ -1968,7 +2035,9 @@ namespace gea::embedded::ui
1968
2035
  }
1969
2036
  n.render.dirty = 1;
1970
2037
  n.render.layout_dirty = 1;
2038
+ #if GEA_CSS_SCROLLING
1971
2039
  n.render.non_scroll_dirty = 1;
2040
+ #endif
1972
2041
  }
1973
2042
  } // anyLayoutDirty
1974
2043
  }
@@ -2354,7 +2423,7 @@ namespace gea::embedded::ui
2354
2423
  py0 = state.nodeCommandDirtyY0[i];
2355
2424
  py1 = state.nodeCommandDirtyY1[i];
2356
2425
  }
2357
- DirtyRegions::Rect partial{n->render.text_dirty_x0, py0, n->render.text_dirty_x1, py1, i};
2426
+ DirtyRegions::Rect partial{n->render.text_dirty.x0, py0, n->render.text_dirty.x1, py1, i};
2358
2427
  partial = expandDirtyRect(partial, GEA_EMBEDDED_TEXT_DIRTY_GUARD_PX);
2359
2428
  partial = dirtyRectWithRasterGuard(*n, partial);
2360
2429
  addDirtyRegion(rects, &rect_count, partial, width, height);
@@ -2369,8 +2438,8 @@ namespace gea::embedded::ui
2369
2438
  n->first_child < 0 &&
2370
2439
  !hasAnyBorder(n->style) &&
2371
2440
  n->style.opacity == 255 &&
2372
- rstyle(n->style).filter_blur_radius <= 0 &&
2373
- rstyle(n->style).box_shadow_blur_radius <= 0 &&
2441
+ (GEA_CSS_FILTERS ? rstyle(n->style).filter_blur_radius : 0) <= 0 &&
2442
+ (GEA_CSS_BOX_SHADOW ? rstyle(n->style).box_shadow_blur_radius : 0) <= 0 &&
2374
2443
  n->layout.x == n->layout.previous_x &&
2375
2444
  n->layout.y == n->layout.previous_y &&
2376
2445
  n->layout.width == n->layout.previous_width &&
@@ -2383,7 +2452,7 @@ namespace gea::embedded::ui
2383
2452
  int recolorY1 = -1;
2384
2453
  if (DisplayList::instance().recolorRetainedSolidBackground(i,
2385
2454
  n->render.bg_recolor_from,
2386
- n->render.bg_recolor_to,
2455
+ n->style.bg_color,
2387
2456
  &recolorX0,
2388
2457
  &recolorY0,
2389
2458
  &recolorX1,
@@ -2433,7 +2502,9 @@ namespace gea::embedded::ui
2433
2502
  perf.treeBgRecolorPixels += recolorPixels;
2434
2503
  n->render.dirty = 0;
2435
2504
  n->render.layout_dirty = 0;
2505
+ #if GEA_CSS_SCROLLING
2436
2506
  n->render.non_scroll_dirty = 0;
2507
+ #endif
2437
2508
  n->render.bg_recolor_pending = 0;
2438
2509
  continue;
2439
2510
  }
@@ -3055,6 +3126,7 @@ namespace gea::embedded::ui
3055
3126
  tickInputCaret(timestamp_ms);
3056
3127
 
3057
3128
  int changed = 0;
3129
+ #if GEA_CSS_BLINK
3058
3130
  for (int i = 0; i < state.nodeCount; i++)
3059
3131
  {
3060
3132
  Node *n = &state.nodes[i];
@@ -3065,7 +3137,9 @@ namespace gea::embedded::ui
3065
3137
  n->style.blink_visible = 1;
3066
3138
  n->render.dirty = 1;
3067
3139
  n->render.layout_dirty = 1;
3140
+ #if GEA_CSS_SCROLLING
3068
3141
  n->render.non_scroll_dirty = 1;
3142
+ #endif
3069
3143
  changed = 1;
3070
3144
  }
3071
3145
  continue;
@@ -3080,10 +3154,13 @@ namespace gea::embedded::ui
3080
3154
  n->style.blink_visible = visible;
3081
3155
  n->render.dirty = 1;
3082
3156
  n->render.layout_dirty = 1;
3157
+ #if GEA_CSS_SCROLLING
3083
3158
  n->render.non_scroll_dirty = 1;
3159
+ #endif
3084
3160
  markDisplayListDirty();
3085
3161
  changed = 1;
3086
3162
  }
3163
+ #endif
3087
3164
 
3088
3165
  // Live <camera> preview: while a camera is streaming, repaint each camera
3089
3166
  // leaf every frame so fresh frames reach the panel — the same idea as the
@@ -3115,7 +3192,9 @@ namespace gea::embedded::ui
3115
3192
  }
3116
3193
  n->render.dirty = 1;
3117
3194
  n->render.layout_dirty = 1;
3195
+ #if GEA_CSS_SCROLLING
3118
3196
  n->render.non_scroll_dirty = 1;
3197
+ #endif
3119
3198
  // Content-only: the camera's blit command is unchanged frame to frame —
3120
3199
  // only the surface pixels it points at are refreshed — so there's no
3121
3200
  // draw-order change. Using the structural markDisplayListDirty() forced a
@@ -14,33 +14,49 @@ Mirror &Mirror::instance()
14
14
 
15
15
  bool Mirror::scrollDirtyAny() const
16
16
  {
17
+ #if GEA_CSS_SCROLLING
17
18
  return treeState().scrollDirtyAny;
19
+ #else
20
+ return false;
21
+ #endif
18
22
  }
19
23
 
20
24
  void Mirror::copyScrollDirty(uint64_t *dst, int word_count) const
21
25
  {
26
+ #if GEA_CSS_SCROLLING
22
27
  if (!dst || word_count <= 0) return;
23
28
  auto &state = treeState();
24
29
  for (int i = 0; i < word_count; i++)
25
30
  dst[i] = i < kScrollDirtyWordCount ? state.scrollDirtyNodes[i] : 0;
31
+ #else
32
+ if (dst && word_count > 0) std::fill_n(dst, word_count, uint64_t{0});
33
+ #endif
26
34
  }
27
35
 
28
36
  void Mirror::clearScrollDirty() const
29
37
  {
38
+ #if GEA_CSS_SCROLLING
30
39
  auto &state = treeState();
31
40
  for (int i = 0; i < kScrollDirtyWordCount; i++)
32
41
  state.scrollDirtyNodes[i] = 0;
33
42
  state.scrollDirtyAny = false;
43
+ #else
44
+
45
+ #endif
34
46
  }
35
47
 
36
48
  bool Mirror::nodeIsScrollable(int node) const
37
49
  {
50
+ #if GEA_CSS_SCROLLING
38
51
  auto &state = treeState();
39
52
  if (node < 0 || node >= state.nodeCount) return false;
40
53
  Node *n = &state.nodes[node];
41
54
  return isViewLikeNodeType(n->type) &&
42
55
  ((n->type != NodeType::VirtualList && scrollsOverflowX(n->style) && ViewRenderer::scrollMaxX(*n) > 0) ||
43
56
  ((n->type == NodeType::VirtualList || scrollsOverflowY(n->style)) && ViewRenderer::scrollMaxY(*n) > 0));
57
+ #else
58
+ (void)node; return false;
59
+ #endif
44
60
  }
45
61
 
46
62
  int Mirror::scrollX(int node) const
@@ -52,6 +68,7 @@ int Mirror::scrollX(int node) const
52
68
 
53
69
  void Mirror::setScrollX(int node, int scroll_x) const
54
70
  {
71
+ #if GEA_CSS_SCROLLING
55
72
  auto &state = treeState();
56
73
  if (node < 0 || node >= state.nodeCount) return;
57
74
  Node *n = &state.nodes[node];
@@ -65,10 +82,15 @@ void Mirror::setScrollX(int node, int scroll_x) const
65
82
  n->layout.scroll_x = scroll_x;
66
83
  n->render.dirty = 1;
67
84
  n->render.layout_dirty = 1;
85
+ #if GEA_CSS_SCROLLING
68
86
  n->render.non_scroll_dirty = 1;
87
+ #endif
69
88
  n->render.scroll_dirty = 1;
70
89
  state.scrollDirtyNodes[node / 64] |= (1ull << (node % 64));
71
90
  state.scrollDirtyAny = true;
91
+ #else
92
+ (void)node; (void)scroll_x;
93
+ #endif
72
94
  }
73
95
 
74
96
  int Mirror::scrollY(int node) const
@@ -80,6 +102,7 @@ int Mirror::scrollY(int node) const
80
102
 
81
103
  void Mirror::setScrollY(int node, int scroll_y) const
82
104
  {
105
+ #if GEA_CSS_SCROLLING
83
106
  auto &state = treeState();
84
107
  if (node < 0 || node >= state.nodeCount) return;
85
108
  Node *n = &state.nodes[node];
@@ -96,6 +119,9 @@ void Mirror::setScrollY(int node, int scroll_y) const
96
119
  n->render.scroll_dirty = 1;
97
120
  state.scrollDirtyNodes[node / 64] |= (1ull << (node % 64));
98
121
  state.scrollDirtyAny = true;
122
+ #else
123
+ (void)node; (void)scroll_y;
124
+ #endif
99
125
  }
100
126
 
101
127
  } // namespace gea::embedded::ui