@geastack/engine 0.1.33 → 0.1.34

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.
@@ -69,6 +69,7 @@ public:
69
69
  bool hasAttribute(int node, const char *name) const;
70
70
  void setTagName(int node, const char *tagName);
71
71
  const char *tagName(int node) const;
72
+ int generatedPseudoChild(int node, bool before) const;
72
73
  void setClassName(int node, const char *className);
73
74
  void setClassName(int node, const std::string &className);
74
75
  bool addClass(int node, const std::string &token);
@@ -114,11 +115,13 @@ public:
114
115
 
115
116
  void mount(int root, int width, int height);
116
117
  void refresh(int root, int width, int height);
118
+ void paintCapture(int root, bool transparent);
117
119
  // Native targets (macOS) that bypass the display-list pipeline and drive
118
120
  // platform widgets directly need just the flex-layout pass without any
119
121
  // rendering / dirty-region / present side effects. computeLayout is that
120
122
  // pass in isolation; other targets keep calling refresh() unchanged.
121
123
  void computeLayout(int root, int width, int height);
124
+ void flushLayoutFor(int node);
122
125
  void frame(int timestampMs);
123
126
  void clear();
124
127
 
package/ui/tree_nodes.cpp CHANGED
@@ -322,6 +322,9 @@ int Tree::cloneNode(int sourceId, bool deep)
322
322
  // srcRd stays valid.)
323
323
  if (const NodeRareData *srcRd = rareDataFor(sourceId)) {
324
324
  NodeRareData &cloneRd = ensureRareData(id);
325
+ cloneRd.hasExplicitNamespace = srcRd->hasExplicitNamespace;
326
+ cloneRd.namespaceUri = srcRd->namespaceUri;
327
+ cloneRd.namespacePrefix = srcRd->namespacePrefix;
325
328
  cloneRd.attributes = srcRd->attributes;
326
329
  cloneRd.customProperties = srcRd->customProperties;
327
330
  cloneRd.defaultStyles = srcRd->defaultStyles;
@@ -1942,6 +1942,30 @@ namespace gea::embedded::ui
1942
1942
  LayoutSnapshot::capture();
1943
1943
  }
1944
1944
 
1945
+ void Tree::paintCapture(int root, bool transparent)
1946
+ {
1947
+ using gea::platform::display::Display;
1948
+ using gea::framework::graphics::pixel::nativeColor;
1949
+ using gea::framework::graphics::pixel::preserveCaptureAlpha;
1950
+
1951
+ struct RestoreCaptureAlpha {
1952
+ bool previous = preserveCaptureAlpha;
1953
+ ~RestoreCaptureAlpha() { preserveCaptureAlpha = previous; }
1954
+ } restoreAlpha;
1955
+ preserveCaptureAlpha = transparent;
1956
+
1957
+ auto &list = DisplayList::instance();
1958
+ Display::resetClip();
1959
+ Display::setAlpha(255);
1960
+ Display::canvas()->clear(transparent ? 0 : nativeColor(255, 255, 255));
1961
+
1962
+ list.clear();
1963
+ list.recordNode(root, 255, false, !transparent);
1964
+ list.weldTransformedFaces();
1965
+ list.replay();
1966
+ markDisplayListDirty();
1967
+ }
1968
+
1945
1969
  void Tree::computeLayout(int root, int width, int height)
1946
1970
  {
1947
1971
  auto &state = treeState();
@@ -2000,6 +2024,23 @@ namespace gea::embedded::ui
2000
2024
  state.refreshSerial = 1;
2001
2025
  }
2002
2026
 
2027
+ void Tree::flushLayoutFor(int node)
2028
+ {
2029
+ auto &state = treeState();
2030
+ bool belongsToViewport = false;
2031
+ int remaining = state.nodeCount;
2032
+ for (int ancestor = node; ancestor >= 0 && ancestor < state.nodeCount && remaining-- > 0;
2033
+ ancestor = state.nodes[ancestor].parent) {
2034
+ if (ancestor == gLayoutViewportRoot) belongsToViewport = true;
2035
+ if (ancestor != state.mountedRoot) continue;
2036
+ if (belongsToViewport && gLayoutViewportRoot != state.mountedRoot)
2037
+ computeLayout(gLayoutViewportRoot, gLayoutViewportWidth, gLayoutViewportHeight);
2038
+ else
2039
+ computeLayout(state.mountedRoot, state.mountedWidth, state.mountedHeight);
2040
+ return;
2041
+ }
2042
+ }
2043
+
2003
2044
  namespace
2004
2045
  {
2005
2046
  // Scoped-relayout root for the current dirty set: the lowest ancestor
package/ui/tree_state.h CHANGED
@@ -208,6 +208,9 @@ struct GridTrackLayout {
208
208
  struct ChildNodeListIdentity;
209
209
 
210
210
  struct NodeRareData {
211
+ CssAtomId namespaceUri = kInvalidCssAtom;
212
+ CssAtomId namespacePrefix = kInvalidCssAtom;
213
+ bool hasExplicitNamespace = false;
211
214
  std::shared_ptr<const ChildNodeListIdentity> childNodeListIdentity;
212
215
  // Reuse the listener record's tail padding for inline-position metadata.
213
216
  // Both members remain ordinary embedded fields with fixed-offset access.
@@ -248,6 +251,9 @@ struct NodeRareData {
248
251
 
249
252
  void clear()
250
253
  {
254
+ namespaceUri = kInvalidCssAtom;
255
+ namespacePrefix = kInvalidCssAtom;
256
+ hasExplicitNamespace = false;
251
257
  childNodeListIdentity.reset();
252
258
  attributes.clear();
253
259
  listeners.clear();
package/ui/view.cpp CHANGED
@@ -1,5 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "internal.h"
3
+ #include "node.h"
3
4
  #include "state_init.h"
4
5
  #include "renderer_features.h"
5
6
  #include "style_values.h"
@@ -1321,6 +1322,12 @@ public:
1321
1322
  return pr;
1322
1323
  }
1323
1324
  static void GEA_VIEW_HOT_SRAM_SECTION("project_point") projectPoint(const ChainProjector &pr, float x, float y, float z, int16_t *outX, int16_t *outY)
1325
+ {
1326
+ const auto p = projectPoint(pr, x, y, z);
1327
+ *outX = static_cast<int16_t>(std::lroundf(p.x));
1328
+ *outY = static_cast<int16_t>(std::lroundf(p.y));
1329
+ }
1330
+ static Point3 projectPoint(const ChainProjector &pr, float x, float y, float z)
1324
1331
  {
1325
1332
  Point3 p{x, y, z};
1326
1333
  if (pr.depth >= 0) {
@@ -1331,8 +1338,7 @@ public:
1331
1338
  applyNodeTransform(state.nodes[id], false, p);
1332
1339
  }
1333
1340
  applyPerspective(pr.perspectiveNode, false, p);
1334
- *outX = static_cast<int16_t>(std::lroundf(p.x));
1335
- *outY = static_cast<int16_t>(std::lroundf(p.y));
1341
+ return p;
1336
1342
  }
1337
1343
 
1338
1344
  static int GEA_VIEW_HOT_SRAM_SECTION("average_depth_compute") averageDepthCompute(const Node &node, bool usePrevious)
@@ -2380,6 +2386,34 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_rect_corners") ViewRen
2380
2386
  ViewGeometry::transformRectCorners(node, usePrevious, x, y, w, h, xs, ys, xs8, ys8);
2381
2387
  }
2382
2388
 
2389
+ gea::host::DOMRect NodeHandle::getBoundingClientRect() const
2390
+ {
2391
+ if (!isConnected()) return gea::host::DOMRect::create();
2392
+ auto &tree = Tree::instance();
2393
+ tree.flushLayoutFor(id());
2394
+ if (!valid()) return gea::host::DOMRect::create();
2395
+
2396
+ int remaining = tree.nodeCount();
2397
+ for (int ancestor = id(); ancestor >= 0 && ancestor < tree.nodeCount() && remaining-- > 0;
2398
+ ancestor = tree.node(ancestor).parent) {
2399
+ if (tree.node(ancestor).computedStyle().display == kDisplayNone)
2400
+ return gea::host::DOMRect::create();
2401
+ }
2402
+ const auto &node = tree.node(id());
2403
+ const auto &box = node.layout;
2404
+ if (!ViewGeometry::hasTransformChain(node, false))
2405
+ return gea::host::DOMRect::create(box.x, box.y, box.width, box.height);
2406
+
2407
+ const auto projector = ViewGeometry::prepareProjector(node);
2408
+ const auto topLeft = ViewGeometry::projectPoint(projector, box.x, box.y, 0);
2409
+ const auto topRight = ViewGeometry::projectPoint(projector, box.x + box.width, box.y, 0);
2410
+ const auto bottomLeft = ViewGeometry::projectPoint(projector, box.x, box.y + box.height, 0);
2411
+ const auto bottomRight = ViewGeometry::projectPoint(projector, box.x + box.width, box.y + box.height, 0);
2412
+ const auto [left, right] = std::minmax({topLeft.x, topRight.x, bottomLeft.x, bottomRight.x});
2413
+ const auto [top, bottom] = std::minmax({topLeft.y, topRight.y, bottomLeft.y, bottomRight.y});
2414
+ return gea::host::DOMRect::create(left, top, right - left, bottom - top);
2415
+ }
2416
+
2383
2417
  int GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_depth") ViewRenderer::transformedDepth(const Node &node, bool usePrevious)
2384
2418
  {
2385
2419
  return ViewGeometry::averageDepth(node, usePrevious);