@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/ui/text.cpp CHANGED
@@ -51,30 +51,30 @@ struct ScopedRefreshStat
51
51
 
52
52
  bool hasTransformState(const Node &node)
53
53
  {
54
- return hasIndividualLinearTransform(rstyle(node.style)) || hadIndividualLinearTransform(node.render) ||
55
- rstyle(node.style).transform_rotate != 0 ||
54
+ return hasIndividualLinearTransform(rstyle(node.computedStyle())) || hadIndividualLinearTransform(node.render) ||
55
+ rstyle(node.computedStyle()).transform_rotate != 0 ||
56
56
  node.render.previous_transform_rotate != 0 ||
57
- rstyle(node.style).transform_rotate_x != 0 ||
57
+ rstyle(node.computedStyle()).transform_rotate_x != 0 ||
58
58
  node.render.previous_transform_rotate_x != 0 ||
59
- rstyle(node.style).transform_rotate_y != 0 ||
59
+ rstyle(node.computedStyle()).transform_rotate_y != 0 ||
60
60
  node.render.previous_transform_rotate_y != 0 ||
61
- composedTranslateX(rstyle(node.style)) != 0 ||
61
+ composedTranslateX(rstyle(node.computedStyle())) != 0 ||
62
62
  node.render.previous_transform_translate_x != 0 ||
63
- composedTranslateY(rstyle(node.style)) != 0 ||
63
+ composedTranslateY(rstyle(node.computedStyle())) != 0 ||
64
64
  node.render.previous_transform_translate_y != 0 ||
65
- composedTranslateZ(rstyle(node.style)) != 0 ||
65
+ composedTranslateZ(rstyle(node.computedStyle())) != 0 ||
66
66
  node.render.previous_transform_translate_z != 0 ||
67
- composedTranslateXPercent(rstyle(node.style)) != 0 ||
67
+ composedTranslateXPercent(rstyle(node.computedStyle())) != 0 ||
68
68
  node.render.previous_transform_translate_x_percent != 0 ||
69
- composedTranslateYPercent(rstyle(node.style)) != 0 ||
69
+ composedTranslateYPercent(rstyle(node.computedStyle())) != 0 ||
70
70
  node.render.previous_transform_translate_y_percent != 0 ||
71
- rstyle(node.style).transform_scale_x != 1000 ||
71
+ rstyle(node.computedStyle()).transform_scale_x != 1000 ||
72
72
  node.render.previous_transform_scale_x != 1000 ||
73
- rstyle(node.style).transform_scale_y != 1000 ||
74
- rstyle(node.style).transform_scale_z != 1000 ||
73
+ rstyle(node.computedStyle()).transform_scale_y != 1000 ||
74
+ rstyle(node.computedStyle()).transform_scale_z != 1000 ||
75
75
  node.render.previous_transform_scale_y != 1000 ||
76
76
  node.render.previous_transform_scale_z != 1000 ||
77
- rstyle(node.style).perspective > 0 ||
77
+ rstyle(node.computedStyle()).perspective > 0 ||
78
78
  node.render.previous_perspective > 0;
79
79
  }
80
80
 
@@ -124,7 +124,6 @@ struct LineBreakCacheEntry {
124
124
  int fontId = -2;
125
125
  int fontSize = -1;
126
126
  int lineHeight = 0;
127
- int scaleQ8 = 0; // scale * 256, integer key for bitmap-font variant
128
127
  int lineCount = 0;
129
128
  std::uint16_t renderBytes[kMaxCachedLines];
130
129
  std::uint16_t consumedBytes[kMaxCachedLines];
@@ -215,20 +214,20 @@ bool currentTransformChainIsPureTranslate(const Node &node, float *outX, float *
215
214
  bool anyTranslate = false;
216
215
  for (;;) {
217
216
  const Node &n = id >= 0 ? tree.node(id) : node;
218
- if (hasIndividualLinearTransform(rstyle(n.style)) || (rstyle(n.style).transform_rotate % 3600) != 0 ||
219
- (rstyle(n.style).transform_rotate_x % 3600) != 0 ||
220
- (rstyle(n.style).transform_rotate_y % 3600) != 0 ||
221
- composedTranslateZ(rstyle(n.style)) != 0 ||
222
- rstyle(n.style).transform_scale_x != 1000 ||
223
- rstyle(n.style).transform_scale_y != 1000 ||
224
- rstyle(n.style).transform_scale_z != 1000 ||
225
- rstyle(n.style).perspective > 0)
217
+ if (hasIndividualLinearTransform(rstyle(n.computedStyle())) || (rstyle(n.computedStyle()).transform_rotate % 3600) != 0 ||
218
+ (rstyle(n.computedStyle()).transform_rotate_x % 3600) != 0 ||
219
+ (rstyle(n.computedStyle()).transform_rotate_y % 3600) != 0 ||
220
+ composedTranslateZ(rstyle(n.computedStyle())) != 0 ||
221
+ rstyle(n.computedStyle()).transform_scale_x != 1000 ||
222
+ rstyle(n.computedStyle()).transform_scale_y != 1000 ||
223
+ rstyle(n.computedStyle()).transform_scale_z != 1000 ||
224
+ rstyle(n.computedStyle()).perspective > 0)
226
225
  return false;
227
226
 
228
- const float localDx = static_cast<float>(composedTranslateX(rstyle(n.style))) +
229
- static_cast<float>(n.layout.width) * static_cast<float>(composedTranslateXPercent(rstyle(n.style))) * 0.001f;
230
- const float localDy = static_cast<float>(composedTranslateY(rstyle(n.style))) +
231
- static_cast<float>(n.layout.height) * static_cast<float>(composedTranslateYPercent(rstyle(n.style))) * 0.001f;
227
+ const float localDx = static_cast<float>(composedTranslateX(rstyle(n.computedStyle()))) +
228
+ static_cast<float>(n.layout.width) * static_cast<float>(composedTranslateXPercent(rstyle(n.computedStyle()))) * 0.001f;
229
+ const float localDy = static_cast<float>(composedTranslateY(rstyle(n.computedStyle()))) +
230
+ static_cast<float>(n.layout.height) * static_cast<float>(composedTranslateYPercent(rstyle(n.computedStyle()))) * 0.001f;
232
231
  if (localDx != 0.0f || localDy != 0.0f) {
233
232
  anyTranslate = true;
234
233
  dx += localDx;
@@ -711,10 +710,10 @@ int rasterizedSingleLineInkCenterOffsetY(const char *text,
711
710
 
712
711
  bool recordProjectedRasterText(const Node &node, const char *text, uint8_t /*parentAlpha*/, int tx, int ty, int tw)
713
712
  {
714
- if (node.style.font_id < 0 || std::strchr(text, '\n')) return false;
715
- const int fontSize = node.style.font_size > 0 ? node.style.font_size : kBitmapFontHeight;
713
+ if (node.computedStyle().font_id < 0 || std::strchr(text, '\n')) return false;
714
+ const int fontSize = node.computedStyle().font_size > 0 ? node.computedStyle().font_size : kBitmapFontHeight;
716
715
  gea::framework::graphics::RasterizedFont font =
717
- gea::framework::graphics::FontRegistry::rasterizedFamily(node.style.font_id, fontSize);
716
+ gea::framework::graphics::FontRegistry::rasterizedFamily(node.computedStyle().font_id, fontSize);
718
717
  if (!font.valid()) return false;
719
718
 
720
719
  int lineWidth = 0;
@@ -730,9 +729,9 @@ bool recordProjectedRasterText(const Node &node, const char *text, uint8_t /*par
730
729
  if (lineWidth <= 0) return true;
731
730
 
732
731
  const int fontLineHeight = font.lineHeight();
733
- const int lineAdvance = node.style.line_height > 0 ? node.style.line_height : fontLineHeight;
734
- const int lineBoxOffset = node.style.line_height > 0 ? (lineAdvance - fontLineHeight) / 2 : 0;
735
- const int srcX = tx + alignedOffset(node.style.text_align, tw, lineWidth);
732
+ const int lineAdvance = node.computedStyle().line_height > 0 ? node.computedStyle().line_height : fontLineHeight;
733
+ const int lineBoxOffset = node.computedStyle().line_height > 0 ? (lineAdvance - fontLineHeight) / 2 : 0;
734
+ const int srcX = tx + alignedOffset(node.computedStyle().text_align, tw, lineWidth);
736
735
  const int srcY = ty + lineBoxOffset;
737
736
  const int srcW = lineWidth;
738
737
  const int srcH = fontLineHeight;
@@ -762,15 +761,15 @@ bool recordProjectedRasterText(const Node &node, const char *text, uint8_t /*par
762
761
  cmd->projectedText.y2 = ys[2];
763
762
  cmd->projectedText.x3 = xs[3];
764
763
  cmd->projectedText.y3 = ys[3];
765
- cmd->projectedText.fontId = node.style.font_id;
764
+ cmd->projectedText.fontId = node.computedStyle().font_id;
766
765
  cmd->projectedText.fontSize = fontSize;
767
- cmd->projectedText.color = node.style.text_color;
768
- cmd->projectedText.alpha = node.style.text_alpha;
769
- cmd->projectedText.textTransform = node.style.text_transform;
770
- cmd->projectedText.whiteSpace = node.style.white_space;
766
+ cmd->projectedText.color = node.computedStyle().text_color;
767
+ cmd->projectedText.alpha = node.computedStyle().text_alpha;
768
+ cmd->projectedText.textTransform = node.computedStyle().text_transform;
769
+ cmd->projectedText.whiteSpace = node.computedStyle().white_space;
771
770
  // Flattened ancestor groups are culled by the recorder for every paint type.
772
771
  // This command's flag describes only its own face in a preserve-3d group.
773
- cmd->projectedText.backfaceHidden = node.style.backface_hidden ? 1 : 0;
772
+ cmd->projectedText.backfaceHidden = node.computedStyle().backface_hidden ? 1 : 0;
774
773
  return true;
775
774
  }
776
775
  #endif
@@ -953,14 +952,14 @@ struct GlyphAdvanceSource {
953
952
  GlyphAdvanceSource advanceSourceForNode(const Node &node)
954
953
  {
955
954
  GlyphAdvanceSource src;
956
- const int fontSize = node.style.font_size > 0 ? node.style.font_size : kBitmapFontHeight;
955
+ const int fontSize = node.computedStyle().font_size > 0 ? node.computedStyle().font_size : kBitmapFontHeight;
957
956
  #ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
958
- if (node.style.font_id >= 0) {
959
- src.font = gea::framework::graphics::FontRegistry::rasterizedFamily(node.style.font_id, fontSize);
957
+ if (node.computedStyle().font_id >= 0) {
958
+ src.font = gea::framework::graphics::FontRegistry::rasterizedFamily(node.computedStyle().font_id, fontSize);
960
959
  if (src.font.valid()) {
961
960
  src.rasterized = true;
962
961
  src.valid = true;
963
- src.lineAdvance = node.style.line_height > 0 ? node.style.line_height : src.font.lineHeight();
962
+ src.lineAdvance = node.computedStyle().line_height > 0 ? node.computedStyle().line_height : src.font.lineHeight();
964
963
  return src;
965
964
  }
966
965
  }
@@ -970,7 +969,7 @@ GlyphAdvanceSource advanceSourceForNode(const Node &node)
970
969
  if (src.glyphWidth < 1) src.glyphWidth = 1;
971
970
  int glyphHeight = static_cast<int>(kBitmapFontHeight * scale + 0.5f);
972
971
  if (glyphHeight < 1) glyphHeight = 1;
973
- src.lineAdvance = node.style.line_height > 0 ? node.style.line_height : glyphHeight;
972
+ src.lineAdvance = node.computedStyle().line_height > 0 ? node.computedStyle().line_height : glyphHeight;
974
973
  src.valid = true;
975
974
  return src;
976
975
  }
@@ -994,26 +993,26 @@ TextLayoutMeasure measureTextLayoutForNode(const Node &node, const char *text, i
994
993
  {
995
994
  if (contentWidth < 0) contentWidth = 0;
996
995
  std::string transformed;
997
- const char *measureText = textWithTransform(text, node.style.text_transform, transformed, node.style.white_space);
996
+ const char *measureText = textWithTransform(text, node.computedStyle().text_transform, transformed, node.computedStyle().white_space);
998
997
  // white-space: nowrap lays the run out as a single line — measure against an
999
998
  // unbounded width so the content box sizes to the full text (then max-width /
1000
999
  // the parent box clamps it). Drawing truncates/ellipsizes the overflow.
1001
- const int measureWidth = (node.style.white_space == 1 || node.style.white_space == 2) ? 32767 : contentWidth;
1000
+ const int measureWidth = (node.computedStyle().white_space == 1 || node.computedStyle().white_space == 2) ? 32767 : contentWidth;
1002
1001
  const TextMeasure measured = TextMetrics::measure(measureText,
1003
1002
  measureWidth,
1004
- node.style.font_id,
1005
- node.style.font_size,
1006
- node.style.line_height,
1007
- node.style.font_weight);
1003
+ node.computedStyle().font_id,
1004
+ node.computedStyle().font_size,
1005
+ node.computedStyle().line_height,
1006
+ node.computedStyle().font_weight);
1008
1007
  TextLayoutMeasure out;
1009
- out.width = measured.width + boxInset(node.style, 1) + boxInset(node.style, 3);
1010
- out.height = measured.height + boxInset(node.style, 0) + boxInset(node.style, 2);
1011
- if (node.style.width != kUnset) out.width = contentSizeToBorderSize(node.style, node.style.width, true);
1012
- else if ((node.style.width_percent != kUnset || node.style.width_expression >= 0) && node.layout.width > 0) out.width = node.layout.width;
1013
- if (node.style.height != kUnset) out.height = contentSizeToBorderSize(node.style, node.style.height, false);
1014
- else if ((node.style.height_percent != kUnset || node.style.height_expression >= 0) && node.layout.height > 0) out.height = node.layout.height;
1015
- out.width = clampBorderBoxSize(node.style, out.width, true);
1016
- out.height = clampBorderBoxSize(node.style, out.height, false);
1008
+ out.width = measured.width + boxInset(node.computedStyle(), 1) + boxInset(node.computedStyle(), 3);
1009
+ out.height = measured.height + boxInset(node.computedStyle(), 0) + boxInset(node.computedStyle(), 2);
1010
+ if (node.computedStyle().width != kUnset) out.width = contentSizeToBorderSize(node.computedStyle(), node.computedStyle().width, true);
1011
+ else if ((node.computedStyle().width_percent != kUnset || node.computedStyle().width_expression >= 0) && node.layout.width > 0) out.width = node.layout.width;
1012
+ if (node.computedStyle().height != kUnset) out.height = contentSizeToBorderSize(node.computedStyle(), node.computedStyle().height, false);
1013
+ else if ((node.computedStyle().height_percent != kUnset || node.computedStyle().height_expression >= 0) && node.layout.height > 0) out.height = node.layout.height;
1014
+ out.width = clampBorderBoxSize(node.computedStyle(), out.width, true);
1015
+ out.height = clampBorderBoxSize(node.computedStyle(), out.height, false);
1017
1016
  return out;
1018
1017
  }
1019
1018
 
@@ -1021,13 +1020,13 @@ int measureSingleLineTextWidthForNode(const Node &node, const char *text)
1021
1020
  {
1022
1021
  if (!text || !text[0]) return 0;
1023
1022
  std::string transformed;
1024
- const char *measureText = textWithTransform(text, node.style.text_transform, transformed, node.style.white_space);
1023
+ const char *measureText = textWithTransform(text, node.computedStyle().text_transform, transformed, node.computedStyle().white_space);
1025
1024
  return TextMetrics::measure(measureText,
1026
1025
  32767,
1027
- node.style.font_id,
1028
- node.style.font_size,
1029
- node.style.line_height,
1030
- node.style.font_weight).width;
1026
+ node.computedStyle().font_id,
1027
+ node.computedStyle().font_size,
1028
+ node.computedStyle().line_height,
1029
+ node.computedStyle().font_weight).width;
1031
1030
  }
1032
1031
 
1033
1032
  struct TextCoverageSink {
@@ -1221,7 +1220,6 @@ private:
1221
1220
  entry.fontId = fontId;
1222
1221
  entry.fontSize = fontSize;
1223
1222
  entry.lineHeight = lineAdvance;
1224
- entry.scaleQ8 = 0;
1225
1223
  entry.lineCount = 0;
1226
1224
 
1227
1225
  const char *p = text;
@@ -1515,11 +1513,11 @@ void Tree::setText(int node, const char *text)
1515
1513
  {
1516
1514
  auto &perf = refreshPerfStatsMutable();
1517
1515
  ScopedRefreshStat timer(perf.treeSetTextUs);
1518
- perf.treeSetTextCalls++;
1516
+ GEA_REFRESH_PERF(perf.treeSetTextCalls++);
1519
1517
  if (node < 0 || node >= nodeCount() || !text) return;
1520
1518
  Node &target = this->node(node);
1521
1519
  if (target.text == text) return;
1522
- perf.treeSetTextChanged++;
1520
+ GEA_REFRESH_PERF(perf.treeSetTextChanged++);
1523
1521
  // Hidden subtree: just store the text. A display:none node paints nothing, so
1524
1522
  // dirtying it for a text change would churn layout (its zero-size box defeats
1525
1523
  // the bbox prediction below -> full relayout) and drop the static-backdrop
@@ -1530,14 +1528,14 @@ void Tree::setText(int node, const char *text)
1530
1528
  int guard = 0;
1531
1529
  for (int a = node; a >= 0 && a < nodeCount() && guard <= nodeCount(); a = this->node(a).parent, ++guard)
1532
1530
  {
1533
- if (this->node(a).style.display == 1)
1531
+ if (this->node(a).computedStyle().display == 1)
1534
1532
  {
1535
1533
  // Same realloc-dangle guard as the visible path below: a node hidden
1536
1534
  // NOW may still have retained commands from when it was visible.
1537
1535
  const char *gid_oldBuffer = target.text.c_str();
1538
1536
  target.text.assign(text);
1539
1537
  if (target.text.c_str() != gid_oldBuffer) DisplayList::instance().scrubNodeText(gid_oldBuffer);
1540
- perf.treeSetTextHidden++;
1538
+ GEA_REFRESH_PERF(perf.treeSetTextHidden++);
1541
1539
  return;
1542
1540
  }
1543
1541
  }
@@ -1592,8 +1590,17 @@ void Tree::setText(int node, const char *text)
1592
1590
  // fixed-width label appear equally wide. A shrinking update such as
1593
1591
  // "San Francisco" -> "Lisbon" then dirtied only the new, shorter run (or even a
1594
1592
  // sliver at the box edge), leaving the old trailing glyphs on the physical panel.
1595
- const bool gid_canPartial = gid_singleLine && target.style.white_space == 1 &&
1596
- target.style.text_align == 0 && gid_prefix < gid_newLen;
1593
+ const bool gid_hadPartial = target.render.text_partial_dirty;
1594
+ const int gid_previousX0 = gid_hadPartial ? target.render.text_dirty.x0 : 0;
1595
+ const int gid_previousX1 = gid_hadPartial ? target.render.text_dirty.x1 : 0;
1596
+ const bool gid_canPartial = (!target.render.dirty || gid_hadPartial) &&
1597
+ !target.render.bg_recolor_pending && gid_singleLine && target.computedStyle().white_space == 1 &&
1598
+ target.computedStyle().text_align == 0 && gid_prefix < gid_newLen;
1599
+ // Text and recolor shortcuts share their payload. Other pending paint
1600
+ // changes require a full node repaint, while consecutive text runs union
1601
+ // their extents so none of the earlier changes is forgotten.
1602
+ target.render.bg_recolor_pending = 0;
1603
+ target.render.text_partial_dirty = 0;
1597
1604
  int gid_preW = 0;
1598
1605
  int gid_rightW = 0;
1599
1606
  if (gid_canPartial) {
@@ -1619,7 +1626,9 @@ void Tree::setText(int node, const char *text)
1619
1626
  const bool gid_hadLayoutDirty = target.render.layout_dirty != 0;
1620
1627
  target.render.dirty = 1;
1621
1628
  target.render.layout_dirty = 1;
1629
+ #if GEA_CSS_SCROLLING
1622
1630
  target.render.non_scroll_dirty = 1;
1631
+ #endif
1623
1632
  target.render.text_layout_stable = 0;
1624
1633
  markNodeDisplayCommandsDirty(node);
1625
1634
  // assign() past capacity reallocates and frees the old buffer, leaving any
@@ -1645,12 +1654,12 @@ void Tree::setText(int node, const char *text)
1645
1654
  if (target.layout.width > 0 && target.layout.height > 0 &&
1646
1655
  target.parent >= 0 && target.first_child < 0 &&
1647
1656
  !hasTransformState(target)) {
1648
- const bool absolute = target.style.position == 1;
1649
- const bool fixedWidth = target.style.width != kUnset || target.style.width_percent != kUnset;
1657
+ const bool absolute = target.computedStyle().position == 1;
1658
+ const bool fixedWidth = target.computedStyle().width != kUnset || target.computedStyle().width_percent != kUnset;
1650
1659
  if (absolute || fixedWidth) {
1651
- const int fixedBoxWidth = target.style.width != kUnset ? target.style.width : target.layout.width;
1660
+ const int fixedBoxWidth = target.computedStyle().width != kUnset ? target.computedStyle().width : target.layout.width;
1652
1661
  const int content_w = fixedWidth
1653
- ? fixedBoxWidth - target.style.padding[1] - target.style.padding[3]
1662
+ ? fixedBoxWidth - target.computedStyle().padding[1] - target.computedStyle().padding[3]
1654
1663
  : 0x4000; // 16384 px — well beyond any panel dimension
1655
1664
  const TextLayoutMeasure measured = measureTextLayoutForNode(target, target.text.c_str(), content_w);
1656
1665
  if (absolute) {
@@ -1668,16 +1677,18 @@ void Tree::setText(int node, const char *text)
1668
1677
  // shift the tail), cover both the old and new extents so no stale pixels remain.
1669
1678
  const bool gid_sameHeight = (measured.height == gid_oldH);
1670
1679
  if (gid_sameHeight && gid_canPartial) {
1671
- const int gid_originX = target.layout.x + target.style.padding[3];
1680
+ const int gid_originX = target.layout.x + target.computedStyle().padding[3];
1672
1681
  constexpr int kTextDirtyPadPx = 4; // AA / glyph-overhang guard
1673
- target.render.text_dirty_x0 = static_cast<int16_t>(gid_originX + gid_preW - kTextDirtyPadPx);
1674
- target.render.text_dirty_x1 = static_cast<int16_t>(gid_originX + gid_rightW + kTextDirtyPadPx);
1682
+ const int x0 = gid_originX + gid_preW - kTextDirtyPadPx;
1683
+ const int x1 = gid_originX + gid_rightW + kTextDirtyPadPx;
1684
+ target.render.text_dirty.x0 = static_cast<int16_t>(gid_hadPartial ? std::min(gid_previousX0, x0) : x0);
1685
+ target.render.text_dirty.x1 = static_cast<int16_t>(gid_hadPartial ? std::max(gid_previousX1, x1) : x1);
1675
1686
  target.render.text_partial_dirty = 1;
1676
1687
  }
1677
1688
  }
1678
1689
  }
1679
1690
  if (target.render.text_layout_stable) {
1680
- perf.treeSetTextStable++;
1691
+ GEA_REFRESH_PERF(perf.treeSetTextStable++);
1681
1692
  // The pre-measure confirmed the box is unchanged: geometry can't move,
1682
1693
  // so this is paint-only dirt (unless something else already made the
1683
1694
  // node layout-dirty this frame).
@@ -1696,11 +1707,11 @@ bool TextRenderer::canFragmentInlineRuns(const Node &node)
1696
1707
  if (cached >= 0) return cached != 0;
1697
1708
  int w = 0;
1698
1709
  int h = 0;
1699
- const int fontId = node.style.font_id;
1700
- const int fontSize = node.style.font_size > 0 ? node.style.font_size : kBitmapFontHeight;
1710
+ const int fontId = node.computedStyle().font_id;
1711
+ const int fontSize = node.computedStyle().font_size > 0 ? node.computedStyle().font_size : kBitmapFontHeight;
1701
1712
  const bool hostMeasures =
1702
- gea_host_measure_text_with_style("Mg", 32767, fontId, fontSize, node.style.font_weight, node.style.line_height, &w, &h) ||
1703
- gea_host_measure_text_with_line_height("Mg", 32767, fontId, fontSize, node.style.line_height, &w, &h) ||
1713
+ gea_host_measure_text_with_style("Mg", 32767, fontId, fontSize, node.computedStyle().font_weight, node.computedStyle().line_height, &w, &h) ||
1714
+ gea_host_measure_text_with_line_height("Mg", 32767, fontId, fontSize, node.computedStyle().line_height, &w, &h) ||
1704
1715
  gea_host_measure_text("Mg", 32767, fontId, fontSize, &w, &h);
1705
1716
  cached = hostMeasures ? 0 : 1;
1706
1717
  return cached != 0;
@@ -1708,18 +1719,18 @@ bool TextRenderer::canFragmentInlineRuns(const Node &node)
1708
1719
 
1709
1720
  int TextRenderer::baselineOffset(const Node &node, bool last)
1710
1721
  {
1711
- const int fontSize = node.style.font_size > 0 ? node.style.font_size : 16;
1712
- const auto font = gea::framework::graphics::FontRegistry::rasterizedFamily(node.style.font_id, fontSize);
1713
- if (!font.valid()) return node.layout.height + node.style.margin[2];
1714
- const int lineAdvance = node.style.line_height > 0 ? node.style.line_height : font.lineHeight();
1715
- const int halfLeading = node.style.line_height > 0 ? (lineAdvance - font.lineHeight()) / 2 : 0;
1716
- int offset = boxInset(node.style, 0) + halfLeading + font.ascender();
1722
+ const int fontSize = node.computedStyle().font_size > 0 ? node.computedStyle().font_size : 16;
1723
+ const auto font = gea::framework::graphics::FontRegistry::rasterizedFamily(node.computedStyle().font_id, fontSize);
1724
+ if (!font.valid()) return node.layout.height + node.computedStyle().margin[2];
1725
+ const int lineAdvance = node.computedStyle().line_height > 0 ? node.computedStyle().line_height : font.lineHeight();
1726
+ const int halfLeading = node.computedStyle().line_height > 0 ? (lineAdvance - font.lineHeight()) / 2 : 0;
1727
+ int offset = boxInset(node.computedStyle(), 0) + halfLeading + font.ascender();
1717
1728
  if (last) {
1718
1729
  std::string storage;
1719
- const char *text = prepareText(node.text.c_str(), node.style.text_transform, node.style.white_space, storage);
1720
- const int width = node.style.white_space == 1 || node.style.white_space == 2
1721
- ? 32767 : std::max(1, node.layout.width - boxInsets(node.style, true));
1722
- const auto measured = TextMetrics::measure(text, width, node.style.font_id, fontSize, node.style.line_height, node.style.font_weight);
1730
+ const char *text = prepareText(node.text.c_str(), node.computedStyle().text_transform, node.computedStyle().white_space, storage);
1731
+ const int width = node.computedStyle().white_space == 1 || node.computedStyle().white_space == 2
1732
+ ? 32767 : std::max(1, node.layout.width - boxInsets(node.computedStyle(), true));
1733
+ const auto measured = TextMetrics::measure(text, width, node.computedStyle().font_id, fontSize, node.computedStyle().line_height, node.computedStyle().font_weight);
1723
1734
  offset += std::max(0, measured.height - lineAdvance);
1724
1735
  }
1725
1736
  return offset;
@@ -1732,20 +1743,20 @@ InlineFlowMeasure TextRenderer::measureInlineFlow(const Node &node, int firstAva
1732
1743
  if (!raw || !raw[0]) return out;
1733
1744
  // nowrap is a single line by definition, and an author-sized box wraps within
1734
1745
  // its own width — neither participates in the block's line boxes.
1735
- if (node.style.white_space == 1 || node.style.white_space == 2) return out;
1746
+ if (node.computedStyle().white_space == 1 || node.computedStyle().white_space == 2) return out;
1736
1747
  if (!canFragmentInlineRuns(node)) return out;
1737
1748
 
1738
1749
  const GlyphAdvanceSource advance = advanceSourceForNode(node);
1739
1750
  if (!advance.valid || advance.lineAdvance <= 0) return out;
1740
1751
 
1741
1752
  std::string transformed;
1742
- const char *text = textWithTransform(raw, node.style.text_transform, transformed, node.style.white_space);
1753
+ const char *text = textWithTransform(raw, node.computedStyle().text_transform, transformed, node.computedStyle().white_space);
1743
1754
  if (!text || !text[0]) return out;
1744
1755
 
1745
1756
  if (contentWidth < 1) contentWidth = 1;
1746
1757
  if (firstAvail < 0) firstAvail = 0;
1747
1758
 
1748
- if (atLineStart && (node.style.white_space == 0 || node.style.white_space == 4)) {
1759
+ if (atLineStart && (node.computedStyle().white_space == 0 || node.computedStyle().white_space == 4)) {
1749
1760
  const int lead = leadingCollapsibleBytes(text);
1750
1761
  if (lead > 0) {
1751
1762
  const char *p = text;
@@ -1765,7 +1776,7 @@ InlineFlowMeasure TextRenderer::measureInlineFlow(const Node &node, int firstAva
1765
1776
  const int visible = line.width + (lineIndex == 0 ? out.firstLineIndentAdjust : 0);
1766
1777
  if (lineIndex == 0) {
1767
1778
  out.firstLineWidth = visible;
1768
- if (node.style.white_space == 0 || node.style.white_space == 4) {
1779
+ if (node.computedStyle().white_space == 0 || node.computedStyle().white_space == 4) {
1769
1780
  const char *end = p + line.renderBytes;
1770
1781
  for (const char *glyph = p; glyph < end;) {
1771
1782
  const int cp = nextUtf8Codepoint(glyph);
@@ -1787,11 +1798,11 @@ InlineFlowMeasure TextRenderer::measureInlineFlow(const Node &node, int firstAva
1787
1798
  int TextRenderer::firstUnbreakableWidth(const Node &node)
1788
1799
  {
1789
1800
  std::string storage;
1790
- const char *text = prepareText(node.text.c_str(), node.style.text_transform, node.style.white_space, storage);
1801
+ const char *text = prepareText(node.text.c_str(), node.computedStyle().text_transform, node.computedStyle().white_space, storage);
1791
1802
  if (!text) return 0;
1792
- if (node.style.white_space == 0 || node.style.white_space == 1 || node.style.white_space == 4)
1803
+ if (node.computedStyle().white_space == 0 || node.computedStyle().white_space == 1 || node.computedStyle().white_space == 4)
1793
1804
  text += leadingCollapsibleBytes(text);
1794
- const bool wrapping = node.style.white_space != 1 && node.style.white_space != 2;
1805
+ const bool wrapping = node.computedStyle().white_space != 1 && node.computedStyle().white_space != 2;
1795
1806
  const char *end = text;
1796
1807
  while (*end) {
1797
1808
  const char *start = end;
@@ -1805,8 +1816,8 @@ int TextRenderer::firstUnbreakableWidth(const Node &node)
1805
1816
  int TextRenderer::minContentWidth(const Node &node, int *pendingWord)
1806
1817
  {
1807
1818
  std::string storage;
1808
- const char *text = prepareText(node.text.c_str(), node.style.text_transform, node.style.white_space, storage);
1809
- const bool wrapping = node.style.white_space != 1 && node.style.white_space != 2;
1819
+ const char *text = prepareText(node.text.c_str(), node.computedStyle().text_transform, node.computedStyle().white_space, storage);
1820
+ const bool wrapping = node.computedStyle().white_space != 1 && node.computedStyle().white_space != 2;
1810
1821
  const char *start = text;
1811
1822
  int width = 0, current = pendingWord ? *pendingWord : 0;
1812
1823
  for (const char *p = text;; ++p) {
@@ -1831,10 +1842,10 @@ void TextRenderer::layout(int id, int avail_w)
1831
1842
  {
1832
1843
  Node *n = &Tree::instance().nodes()[id];
1833
1844
 
1834
- int content_w = avail_w - boxInset(n->style, 1) - boxInset(n->style, 3)
1835
- - n->style.margin[1] - n->style.margin[3];
1836
- if (n->style.width != kUnset) content_w = contentSizeToBorderSize(n->style, n->style.width, true) - boxInset(n->style, 1) - boxInset(n->style, 3);
1837
- else if ((n->style.width_percent != kUnset || n->style.width_expression >= 0) && n->layout.width > 0) content_w = n->layout.width - boxInset(n->style, 1) - boxInset(n->style, 3);
1845
+ int content_w = avail_w - boxInset(n->computedStyle(), 1) - boxInset(n->computedStyle(), 3)
1846
+ - n->computedStyle().margin[1] - n->computedStyle().margin[3];
1847
+ if (n->computedStyle().width != kUnset) content_w = contentSizeToBorderSize(n->computedStyle(), n->computedStyle().width, true) - boxInset(n->computedStyle(), 1) - boxInset(n->computedStyle(), 3);
1848
+ else if ((n->computedStyle().width_percent != kUnset || n->computedStyle().width_expression >= 0) && n->layout.width > 0) content_w = n->layout.width - boxInset(n->computedStyle(), 1) - boxInset(n->computedStyle(), 3);
1838
1849
  if (content_w < 0) content_w = 0;
1839
1850
 
1840
1851
  const TextLayoutMeasure measured = measureTextLayoutForNode(*n, n->text.c_str(), content_w);
@@ -1859,9 +1870,9 @@ bool TextRenderer::remeasureContentBox(int id, bool keepBoxWidth)
1859
1870
  // explicit width re-wraps within the fixed box; natural-width text hugs the
1860
1871
  // new content (the 0x4000 bound matches setText's bbox predictor).
1861
1872
  int content_w = 0x4000;
1862
- if (keepBoxWidth) content_w = n.layout.width - boxInsets(n.style, true);
1863
- else if (n.style.width != kUnset) content_w = contentSizeToBorderSize(n.style, n.style.width, true) - boxInset(n.style, 1) - boxInset(n.style, 3);
1864
- else if ((n.style.width_percent != kUnset || n.style.width_expression >= 0) && n.layout.width > 0) content_w = n.layout.width - boxInset(n.style, 1) - boxInset(n.style, 3);
1873
+ if (keepBoxWidth) content_w = n.layout.width - boxInsets(n.computedStyle(), true);
1874
+ else if (n.computedStyle().width != kUnset) content_w = contentSizeToBorderSize(n.computedStyle(), n.computedStyle().width, true) - boxInset(n.computedStyle(), 1) - boxInset(n.computedStyle(), 3);
1875
+ else if ((n.computedStyle().width_percent != kUnset || n.computedStyle().width_expression >= 0) && n.layout.width > 0) content_w = n.layout.width - boxInset(n.computedStyle(), 1) - boxInset(n.computedStyle(), 3);
1865
1876
  if (content_w < 0) content_w = 0;
1866
1877
  const TextLayoutMeasure measured = measureTextLayoutForNode(n, n.text.c_str(), content_w);
1867
1878
  if (keepBoxWidth) {
@@ -1911,6 +1922,7 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
1911
1922
  const Node *n = &node;
1912
1923
  if (n->type != NodeType::Text || n->text.empty()) return;
1913
1924
 
1925
+ #if GEA_CSS_FIRST_LINE
1914
1926
  // A first-line background belongs to the inline fragment, not the block's
1915
1927
  // entire width. Layout records this run's first line box/advance only when an
1916
1928
  // ancestor has a resolved ::first-line background. Emit it before the text
@@ -1981,15 +1993,16 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
1981
1993
  }
1982
1994
 
1983
1995
 
1996
+ #endif
1984
1997
  int x = n->layout.x;
1985
1998
  int y = n->layout.y;
1986
1999
  int w = n->layout.width;
1987
2000
  int h = n->layout.height;
1988
- int tx = x + boxInset(n->style, 3);
1989
- int ty = y + boxInset(n->style, 0);
1990
- int tw = w - boxInset(n->style, 1) - boxInset(n->style, 3);
2001
+ int tx = x + boxInset(n->computedStyle(), 3);
2002
+ int ty = y + boxInset(n->computedStyle(), 0);
2003
+ int tw = w - boxInset(n->computedStyle(), 1) - boxInset(n->computedStyle(), 3);
1991
2004
  if (tw < 0) tw = 0;
1992
- float textScale = n->style.font_size > 0 ? static_cast<float>(n->style.font_size) / kBitmapFontHeight : 1.0f;
2005
+ float textScale = n->computedStyle().font_size > 0 ? static_cast<float>(n->computedStyle().font_size) / kBitmapFontHeight : 1.0f;
1993
2006
 
1994
2007
  int bx = x;
1995
2008
  int by = y;
@@ -1999,7 +2012,7 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
1999
2012
  int drawY = ty;
2000
2013
  int drawW = tw;
2001
2014
  int containerW = tw;
2002
- int commandLineHeight = n->style.line_height;
2015
+ int commandLineHeight = n->computedStyle().line_height;
2003
2016
  int transformedX0 = x;
2004
2017
  int transformedY0 = y;
2005
2018
  int transformedX1 = x + w - 1;
@@ -2026,14 +2039,14 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2026
2039
  }
2027
2040
  }
2028
2041
  std::string transformedText;
2029
- const char *measureText = textWithTransform(n->text.c_str(), n->style.text_transform, transformedText, n->style.white_space);
2042
+ const char *measureText = textWithTransform(n->text.c_str(), n->computedStyle().text_transform, transformedText, n->computedStyle().white_space);
2030
2043
  #ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
2031
2044
  if (transformed && recordProjectedRasterText(*n, measureText, parentAlpha, tx, ty, tw)) return;
2032
2045
  #endif
2033
2046
  if (transformed && transformedX1 >= transformedX0 && transformedY1 >= transformedY0) {
2034
2047
  const int projectedW = transformedX1 - transformedX0 + 1;
2035
2048
  const int projectedH = transformedY1 - transformedY0 + 1;
2036
- const int contentH = h - boxInset(n->style, 0) - boxInset(n->style, 2);
2049
+ const int contentH = h - boxInset(n->computedStyle(), 0) - boxInset(n->computedStyle(), 2);
2037
2050
  const int centerX = transformedX0 + projectedW / 2;
2038
2051
  const int centerY = transformedY0 + projectedH / 2;
2039
2052
  float projectedScaleX = tw > 0 ? static_cast<float>(projectedW) / static_cast<float>(tw) : 1.0f;
@@ -2045,12 +2058,12 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2045
2058
  projectedScale = clampFloat(projectedScale, 0.35f, 1.35f);
2046
2059
  textScale *= projectedScale;
2047
2060
  const int projectedFontSize = static_cast<int>(textScale * kBitmapFontHeight + 0.5f);
2048
- const int projectedLineHeight = n->style.line_height > 0
2049
- ? static_cast<int>(static_cast<float>(n->style.line_height) * projectedScale + 0.5f)
2061
+ const int projectedLineHeight = n->computedStyle().line_height > 0
2062
+ ? static_cast<int>(static_cast<float>(n->computedStyle().line_height) * projectedScale + 0.5f)
2050
2063
  : 0;
2051
2064
  commandLineHeight = projectedLineHeight;
2052
2065
  const TextMeasure projectedMeasure =
2053
- TextMetrics::measure(measureText, 32767, n->style.font_id, projectedFontSize, projectedLineHeight, n->style.font_weight);
2066
+ TextMetrics::measure(measureText, 32767, n->computedStyle().font_id, projectedFontSize, projectedLineHeight, n->computedStyle().font_weight);
2054
2067
  drawW = projectedMeasure.width > 0 ? projectedMeasure.width : projectedW;
2055
2068
  const int drawH = projectedMeasure.height > 0 ? projectedMeasure.height : (contentH > 0 ? contentH : projectedH);
2056
2069
  containerW = drawW;
@@ -2065,7 +2078,7 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2065
2078
  bw = drawX1 - drawX + 1 + pad * 2;
2066
2079
  bh = drawY1 - drawY + 1 + pad * 2;
2067
2080
  #ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
2068
- if (n->style.font_id >= 0) {
2081
+ if (n->computedStyle().font_id >= 0) {
2069
2082
  const int commandFontSize = static_cast<int>(textScale * kBitmapFontHeight + 0.5f);
2070
2083
  int ix0 = 0;
2071
2084
  int iy0 = 0;
@@ -2073,9 +2086,9 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2073
2086
  int iy1 = -1;
2074
2087
  if (rasterizedTextInkBounds(measureText,
2075
2088
  drawW,
2076
- n->style.text_align,
2089
+ n->computedStyle().text_align,
2077
2090
  containerW,
2078
- n->style.font_id,
2091
+ n->computedStyle().font_id,
2079
2092
  commandFontSize,
2080
2093
  commandLineHeight,
2081
2094
  &ix0,
@@ -2092,8 +2105,8 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2092
2105
  #endif
2093
2106
  }
2094
2107
 
2095
- const bool noWrap = n->style.white_space == 1;
2096
- const bool noSoftWrap = noWrap || n->style.white_space == 2;
2108
+ const bool noWrap = n->computedStyle().white_space == 1;
2109
+ const bool noSoftWrap = noWrap || n->computedStyle().white_space == 2;
2097
2110
  // Inline continuation (see LayoutBox::inline_indent): line 0 starts at
2098
2111
  // `drawX + inlineIndent`, every later line at `drawX`. The tight ink/paint
2099
2112
  // bounds below all assume one origin for the whole run, so an indented run
@@ -2109,7 +2122,7 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2109
2122
  if (!transformed && inlineIndent == 0) {
2110
2123
  const int commandFontSize = static_cast<int>(textScale * kBitmapFontHeight + 0.5f);
2111
2124
  const TextMeasure paintMeasure =
2112
- TextMetrics::measure(measureText, noSoftWrap ? 32767 : drawW, n->style.font_id, commandFontSize, commandLineHeight, n->style.font_weight);
2125
+ TextMetrics::measure(measureText, noSoftWrap ? 32767 : drawW, n->computedStyle().font_id, commandFontSize, commandLineHeight, n->computedStyle().font_weight);
2113
2126
  if (paintMeasure.width > 0 && paintMeasure.height > 0) {
2114
2127
  // CSS: a flex container's bare text becomes an anonymous flex item, so
2115
2128
  // align-items centers (or end-aligns) it on the cross axis. This node
@@ -2118,11 +2131,16 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2118
2131
  // had to fake it with line-height. Row-direction flex only (the cross
2119
2132
  // axis is vertical there); a child-bearing flex container aligns its
2120
2133
  // child BOXES through layout as before.
2121
- if (n->style.display == kDisplayFlex && n->first_child < 0 &&
2122
- usesRowLayout(n->style)) {
2123
- const int contentH = h - boxInset(n->style, 0) - boxInset(n->style, 2);
2134
+ if (n->computedStyle().display == kDisplayFlex && n->first_child < 0 &&
2135
+ usesRowLayout(n->computedStyle())) {
2136
+ const int contentH = h - boxInset(n->computedStyle(), 0) - boxInset(n->computedStyle(), 2);
2124
2137
  const int slack = contentH - paintMeasure.height;
2125
- const int alignment = usedAlignment(n->style.align_items, slack, (n->style.flex_wrap & 3) == 2);
2138
+ #if GEA_CSS_FLEX_WRAP
2139
+ const bool reverseCrossAxis = (n->computedStyle().flex_wrap & 3) == 2;
2140
+ #else
2141
+ constexpr bool reverseCrossAxis = false;
2142
+ #endif
2143
+ const int alignment = usedAlignment(n->computedStyle().align_items, slack, reverseCrossAxis);
2126
2144
  if (alignment == 1) drawY += slack / 2;
2127
2145
  else if (alignment == 2) drawY += slack;
2128
2146
  }
@@ -2131,9 +2149,9 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2131
2149
  int paintWidth = paintMeasure.width;
2132
2150
  if (noWrap && paintWidth > drawW) paintWidth = drawW;
2133
2151
  #ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
2134
- if (n->style.font_id >= 0) {
2152
+ if (n->computedStyle().font_id >= 0) {
2135
2153
  gea::framework::graphics::RasterizedFont font =
2136
- gea::framework::graphics::FontRegistry::rasterizedFamily(n->style.font_id, commandFontSize);
2154
+ gea::framework::graphics::FontRegistry::rasterizedFamily(n->computedStyle().font_id, commandFontSize);
2137
2155
  const int lineAdvance = commandLineHeight > 0 ? commandLineHeight : (font.valid() ? font.lineHeight() : 0);
2138
2156
  const bool singleLine = font.valid() &&
2139
2157
  std::strchr(measureText, '\n') == nullptr &&
@@ -2145,30 +2163,30 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2145
2163
  // RenderState::inline_baseline.
2146
2164
  if (singleLine && !n->render.inline_baseline) {
2147
2165
  drawY += rasterizedSingleLineInkCenterOffsetY(measureText,
2148
- n->style.text_align,
2166
+ n->computedStyle().text_align,
2149
2167
  containerW,
2150
- n->style.font_id,
2168
+ n->computedStyle().font_id,
2151
2169
  commandFontSize,
2152
2170
  commandLineHeight);
2153
2171
  }
2154
2172
  }
2155
2173
  #endif
2156
- const int xOffset = alignedOffset(n->style.text_align, containerW, paintWidth);
2174
+ const int xOffset = alignedOffset(n->computedStyle().text_align, containerW, paintWidth);
2157
2175
  int paintX0 = drawX + xOffset;
2158
2176
  int paintY0 = drawY;
2159
2177
  int paintX1 = paintX0 + paintWidth - 1;
2160
2178
  int paintY1 = paintY0 + paintMeasure.height - 1;
2161
2179
  #ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
2162
- if (n->style.font_id >= 0) {
2180
+ if (n->computedStyle().font_id >= 0) {
2163
2181
  int ix0 = 0;
2164
2182
  int iy0 = 0;
2165
2183
  int ix1 = -1;
2166
2184
  int iy1 = -1;
2167
2185
  if (rasterizedTextInkBounds(measureText,
2168
2186
  noSoftWrap ? 32767 : drawW,
2169
- n->style.text_align,
2187
+ n->computedStyle().text_align,
2170
2188
  containerW,
2171
- n->style.font_id,
2189
+ n->computedStyle().font_id,
2172
2190
  commandFontSize,
2173
2191
  commandLineHeight,
2174
2192
  &ix0,
@@ -2197,10 +2215,10 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2197
2215
  }
2198
2216
 
2199
2217
  // TEMPORARY BASELINE INSTRUMENTATION (env-gated) — remove before landing.
2200
- if (std::getenv("GEA_TEXT_BASELINE_DEBUG") && n->style.font_id >= 0) {
2218
+ if (std::getenv("GEA_TEXT_BASELINE_DEBUG") && n->computedStyle().font_id >= 0) {
2201
2219
  const int dbgFontSize = static_cast<int>(textScale * kBitmapFontHeight + 0.5f);
2202
2220
  gea::framework::graphics::RasterizedFont dbgFont =
2203
- gea::framework::graphics::FontRegistry::rasterizedFamily(n->style.font_id, dbgFontSize);
2221
+ gea::framework::graphics::FontRegistry::rasterizedFamily(n->computedStyle().font_id, dbgFontSize);
2204
2222
  const int fontLH = dbgFont.valid() ? dbgFont.lineHeight() : -1;
2205
2223
  const int asc = dbgFont.valid() ? dbgFont.ascender() : -1;
2206
2224
  const int lineAdv = commandLineHeight > 0 ? commandLineHeight : fontLH;
@@ -2208,8 +2226,8 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2208
2226
  int inkOff = 0;
2209
2227
  #ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
2210
2228
  const int genFonts = 1;
2211
- inkOff = rasterizedSingleLineInkCenterOffsetY(measureText, n->style.text_align, containerW,
2212
- n->style.font_id, dbgFontSize, commandLineHeight);
2229
+ inkOff = rasterizedSingleLineInkCenterOffsetY(measureText, n->computedStyle().text_align, containerW,
2230
+ n->computedStyle().font_id, dbgFontSize, commandLineHeight);
2213
2231
  #else
2214
2232
  const int genFonts = 0;
2215
2233
  #endif
@@ -2220,14 +2238,14 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2220
2238
  preview[pi] = '\0';
2221
2239
  std::printf("[baseline] gen=%d '%s' font=%d size=%d asc=%d fontLH=%d cssLH=%d "
2222
2240
  "box=(%d,%d,%dx%d) ty=%d drawY=%d inkOff=%d lineBoxOff=%d baselineY=%d\n",
2223
- genFonts, preview, n->style.font_id, dbgFontSize, asc, fontLH,
2224
- n->style.line_height, n->layout.x, n->layout.y, n->layout.width,
2241
+ genFonts, preview, n->computedStyle().font_id, dbgFontSize, asc, fontLH,
2242
+ n->computedStyle().line_height, n->layout.x, n->layout.y, n->layout.width,
2225
2243
  n->layout.height, ty, drawY, inkOff, lineBoxOff, drawY + lineBoxOff + asc);
2226
2244
  std::fflush(stdout);
2227
2245
  }
2228
2246
 
2229
2247
 
2230
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, n->style.text_alpha);
2248
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, n->computedStyle().text_alpha);
2231
2249
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx, by, bw, bh);
2232
2250
 
2233
2251
  DisplayCommand *cmd = DisplayList::instance().append();
@@ -2240,18 +2258,18 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2240
2258
  cmd->text.text = n->text.c_str();
2241
2259
  cmd->text.x = drawX; cmd->text.y = drawY;
2242
2260
  cmd->text.maxWidth = drawW;
2243
- cmd->text.color = n->style.text_color;
2261
+ cmd->text.color = n->computedStyle().text_color;
2244
2262
  cmd->text.scale = textScale;
2245
- cmd->text.align = n->style.text_align;
2246
- cmd->text.textTransform = n->style.text_transform;
2263
+ cmd->text.align = n->computedStyle().text_align;
2264
+ cmd->text.textTransform = n->computedStyle().text_transform;
2247
2265
  cmd->text.lineHeight = commandLineHeight;
2248
2266
  cmd->text.containerWidth = containerW;
2249
- cmd->text.fontId = n->style.font_id;
2250
- cmd->text.whiteSpace = n->style.white_space;
2251
- cmd->text.textOverflow = n->style.text_overflow;
2267
+ cmd->text.fontId = n->computedStyle().font_id;
2268
+ cmd->text.whiteSpace = n->computedStyle().white_space;
2269
+ cmd->text.textOverflow = n->computedStyle().text_overflow;
2252
2270
  cmd->text.firstLineIndent = static_cast<int16_t>(inlineIndent);
2253
2271
  {
2254
- const int contentH = h - boxInset(n->style, 0) - boxInset(n->style, 2);
2272
+ const int contentH = h - boxInset(n->computedStyle(), 0) - boxInset(n->computedStyle(), 2);
2255
2273
  cmd->text.maxHeight = static_cast<int16_t>(contentH > 0 ? (contentH > 32767 ? 32767 : contentH) : 0);
2256
2274
  }
2257
2275
 
@@ -2261,11 +2279,11 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2261
2279
  // underline sits near the baseline, and thickness scales with the text.
2262
2280
  // The width matches the measured text width so the line doesn't extend
2263
2281
  // past the actual glyphs.
2264
- if (n->style.text_decoration != 0 && !n->text.empty()) {
2265
- const int fontSize = n->style.font_size > 0 ? n->style.font_size : kBitmapFontHeight;
2266
- const int lineWidth = TextMetrics::measure(measureText, tw, n->style.font_id, n->style.font_size, 0, n->style.font_weight).width;
2282
+ if (n->computedStyle().text_decoration != 0 && !n->text.empty()) {
2283
+ const int fontSize = n->computedStyle().font_size > 0 ? n->computedStyle().font_size : kBitmapFontHeight;
2284
+ const int lineWidth = TextMetrics::measure(measureText, tw, n->computedStyle().font_id, n->computedStyle().font_size, 0, n->computedStyle().font_weight).width;
2267
2285
  const int lineHeight = textDecorationThickness(fontSize);
2268
- const int lineY = textDecorationY(ty, fontSize, lineHeight, n->style.text_decoration);
2286
+ const int lineY = textDecorationY(ty, fontSize, lineHeight, n->computedStyle().text_decoration);
2269
2287
  DisplayCommand *deco = DisplayList::instance().append();
2270
2288
  if (deco) {
2271
2289
  deco->type = DisplayCommandType::FillRect;
@@ -2275,7 +2293,7 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
2275
2293
  deco->fill.y = lineY;
2276
2294
  deco->fill.w = lineWidth;
2277
2295
  deco->fill.h = lineHeight;
2278
- deco->fill.color = n->style.text_color;
2296
+ deco->fill.color = n->computedStyle().text_color;
2279
2297
  }
2280
2298
  }
2281
2299