@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/style.cpp CHANGED
@@ -99,7 +99,9 @@ char g_recprofLast[420];
99
99
  // those keep their existing computed style (identical to a full recompute). A
100
100
  // GEA_INCREMENTAL_VERIFY build additionally runs the full recompute afterwards and
101
101
  // asserts every node's style matches, proving equivalence on-device.
102
+ #if GEA_CSS_CUSTOM_PROPERTIES
102
103
  std::vector<CssAtomId> g_nodeRefOverflow;
104
+ #endif
103
105
 
104
106
  struct CssAtomSmallList {
105
107
  static constexpr std::uint8_t kInlineCount = 16;
@@ -157,6 +159,7 @@ struct CssAtomSmallList {
157
159
  }
158
160
  };
159
161
 
162
+ #if GEA_CSS_CUSTOM_PROPERTIES
160
163
  struct NodeCustomPropRefs {
161
164
  static constexpr std::uint8_t kInlineCount = 4;
162
165
  static constexpr std::uint16_t kNoOverflow = 0xFFFFu;
@@ -301,37 +304,44 @@ struct CustomPropertyLookupCache {
301
304
  };
302
305
 
303
306
  CustomPropertyLookupCache g_customPropertyLookupCache;
307
+ #elif !GEA_EMBEDDED_SHARED_STYLES
308
+ bool g_nodeStyleTracked[kMaxNodes]{};
309
+ #endif
304
310
 
305
311
  void clearDynamicLengthExpressionResolutionCache();
306
312
 
307
313
  inline void clearCustomPropertyLookupCache()
308
314
  {
315
+ #if GEA_CSS_CUSTOM_PROPERTIES
309
316
  g_customPropertyLookupCache.clear();
317
+ #endif
310
318
  clearDynamicLengthExpressionResolutionCache();
311
319
  }
312
320
 
313
321
  struct DenseNodeMark {
322
+ // A mark stores batch identity, not a node index. Byte epochs retain direct
323
+ // loads and halve both dense arrays; clear all marks before epoch reuse.
314
324
  #if GEA_EMBEDDED_UI_STATE_DYNAMIC_INIT
315
- std::uint16_t marks[kMaxNodes];
316
- std::uint16_t serial;
325
+ std::uint8_t marks[kMaxNodes];
326
+ std::uint8_t serial;
317
327
 
318
328
  // Runtime initialization keeps the nonzero serial out of .data (see
319
329
  // state_init.h); noinline stops the compiler folding it back in.
320
330
  __attribute__((noinline)) DenseNodeMark()
321
331
  {
322
- for (std::uint16_t &mark : marks) mark = 0;
332
+ for (std::uint8_t &mark : marks) mark = 0;
323
333
  serial = 1;
324
334
  }
325
335
  #else
326
- std::uint16_t marks[kMaxNodes]{};
327
- std::uint16_t serial = 1;
336
+ std::uint8_t marks[kMaxNodes]{};
337
+ std::uint8_t serial = 1;
328
338
  #endif
329
339
 
330
340
  void clear()
331
341
  {
332
342
  ++serial;
333
343
  if (serial == 0) {
334
- for (std::uint16_t &mark : marks) mark = 0;
344
+ for (std::uint8_t &mark : marks) mark = 0;
335
345
  serial = 1;
336
346
  }
337
347
  }
@@ -362,8 +372,12 @@ std::unordered_set<int> g_incrRecomputedNodes; // nodes the incremental pass ac
362
372
 
363
373
  inline void recordCustomPropRef(CssAtomId name)
364
374
  {
375
+ #if GEA_CSS_CUSTOM_PROPERTIES
365
376
  if (g_recordingNode < 0 || g_recordingNode >= kMaxNodes || name == kInvalidCssAtom) return;
366
377
  g_nodeRefs[g_recordingNode].insert(name);
378
+ #else
379
+ (void)name;
380
+ #endif
367
381
  }
368
382
 
369
383
  bool nodeParticipatesInMountedTree(const TreeState &state, int node)
@@ -412,12 +426,14 @@ bool styleEqualExceptTextPaint(const ComputedStyle &a, const ComputedStyle &b)
412
426
  a.gap != b.gap ||
413
427
  ar.grid_column_count != br.grid_column_count ||
414
428
  ar.grid_row_count != br.grid_row_count) return false;
429
+ #if GEA_CSS_GRID
415
430
  for (int i = 0; i < kMaxGridTracks; ++i) {
416
431
  if (ar.grid_column_type[i] != br.grid_column_type[i] ||
417
432
  ar.grid_row_type[i] != br.grid_row_type[i] ||
418
433
  ar.grid_column_value[i] != br.grid_column_value[i] ||
419
434
  ar.grid_row_value[i] != br.grid_row_value[i]) return false;
420
435
  }
436
+ #endif
421
437
  if (a.width != b.width ||
422
438
  a.height != b.height ||
423
439
  a.width_expression != b.width_expression ||
@@ -434,20 +450,45 @@ bool styleEqualExceptTextPaint(const ComputedStyle &a, const ComputedStyle &b)
434
450
  ar.flex_basis_expression != br.flex_basis_expression ||
435
451
  ar.line_height_expression != br.line_height_expression ||
436
452
  a.line_height_multiplier != b.line_height_multiplier) return false;
453
+ if (GEA_CSS_POSITION_PX_0(a) != GEA_CSS_POSITION_PX_0(b) ||
454
+ GEA_CSS_POSITION_PX_1(a) != GEA_CSS_POSITION_PX_1(b) ||
455
+ GEA_CSS_POSITION_PX_2(a) != GEA_CSS_POSITION_PX_2(b) ||
456
+ GEA_CSS_POSITION_PX_3(a) != GEA_CSS_POSITION_PX_3(b) ||
457
+ GEA_CSS_POSITION_PERCENT_0(a) != GEA_CSS_POSITION_PERCENT_0(b) ||
458
+ GEA_CSS_POSITION_PERCENT_1(a) != GEA_CSS_POSITION_PERCENT_1(b) ||
459
+ GEA_CSS_POSITION_PERCENT_2(a) != GEA_CSS_POSITION_PERCENT_2(b) ||
460
+ GEA_CSS_POSITION_PERCENT_3(a) != GEA_CSS_POSITION_PERCENT_3(b)) return false;
437
461
  for (int i = 0; i < 4; ++i) {
438
- if (a.padding[i] != b.padding[i] ||
462
+ if (
463
+ #if GEA_CSS_PADDING
464
+ a.padding[i] != b.padding[i] ||
465
+ #endif
466
+ #if GEA_CSS_MARGINS
439
467
  a.margin[i] != b.margin[i] ||
468
+ #endif
469
+ #if GEA_CSS_BOX_EXPRESSIONS
440
470
  ar.margin_expression[i] != br.margin_expression[i] ||
471
+ #endif
472
+ #if GEA_CSS_BOX_EXPRESSIONS
441
473
  ar.padding_expression[i] != br.padding_expression[i] ||
442
- a.pos_offsets[i] != b.pos_offsets[i] ||
443
- a.pos_offset_percent[i] != b.pos_offset_percent[i] ||
474
+ #endif
475
+ #if GEA_CSS_SIDE_BORDERS
444
476
  ar.border_side_width[i] != br.border_side_width[i] ||
477
+ #endif
478
+ #if GEA_CSS_BORDER_RELIEF
445
479
  ar.border_relief[i] != br.border_relief[i] ||
446
- ar.border_color_flags != br.border_color_flags ||
480
+ #endif
481
+ a.border_color_flags != b.border_color_flags ||
482
+ #if GEA_CSS_SIDE_BORDERS
447
483
  ar.border_side_color[i] != br.border_side_color[i] ||
484
+ #endif
485
+ #if GEA_CSS_SIDE_BORDERS
448
486
  ar.border_side_alpha[i] != br.border_side_alpha[i] ||
449
- a.border_radius[i] != b.border_radius[i] ||
450
- a.border_radius_percent[i] != b.border_radius_percent[i]) return false;
487
+ #endif
488
+ #if GEA_CSS_PERCENT_RADIUS
489
+ a.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != b.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] ||
490
+ #endif
491
+ a.border_radius[GEA_CSS_RADIUS_INDEX(i)] != b.border_radius[GEA_CSS_RADIUS_INDEX(i)]) return false;
451
492
  }
452
493
  if (a.position != b.position ||
453
494
  a.z_index != b.z_index ||
@@ -610,12 +651,14 @@ bool styleEqualExceptLocalDisplayCommands(const ComputedStyle &a, const Computed
610
651
  a.gap != b.gap ||
611
652
  ar.grid_column_count != br.grid_column_count ||
612
653
  ar.grid_row_count != br.grid_row_count) return false;
654
+ #if GEA_CSS_GRID
613
655
  for (int i = 0; i < kMaxGridTracks; ++i) {
614
656
  if (ar.grid_column_type[i] != br.grid_column_type[i] ||
615
657
  ar.grid_row_type[i] != br.grid_row_type[i] ||
616
658
  ar.grid_column_value[i] != br.grid_column_value[i] ||
617
659
  ar.grid_row_value[i] != br.grid_row_value[i]) return false;
618
660
  }
661
+ #endif
619
662
  if (a.width != b.width ||
620
663
  a.height != b.height ||
621
664
  a.width_expression != b.width_expression ||
@@ -632,14 +675,29 @@ bool styleEqualExceptLocalDisplayCommands(const ComputedStyle &a, const Computed
632
675
  ar.flex_basis_expression != br.flex_basis_expression ||
633
676
  ar.line_height_expression != br.line_height_expression ||
634
677
  a.line_height_multiplier != b.line_height_multiplier) return false;
678
+ if (GEA_CSS_POSITION_PX_0(a) != GEA_CSS_POSITION_PX_0(b) ||
679
+ GEA_CSS_POSITION_PX_1(a) != GEA_CSS_POSITION_PX_1(b) ||
680
+ GEA_CSS_POSITION_PX_2(a) != GEA_CSS_POSITION_PX_2(b) ||
681
+ GEA_CSS_POSITION_PX_3(a) != GEA_CSS_POSITION_PX_3(b) ||
682
+ GEA_CSS_POSITION_PERCENT_0(a) != GEA_CSS_POSITION_PERCENT_0(b) ||
683
+ GEA_CSS_POSITION_PERCENT_1(a) != GEA_CSS_POSITION_PERCENT_1(b) ||
684
+ GEA_CSS_POSITION_PERCENT_2(a) != GEA_CSS_POSITION_PERCENT_2(b) ||
685
+ GEA_CSS_POSITION_PERCENT_3(a) != GEA_CSS_POSITION_PERCENT_3(b)) return false;
635
686
  for (int i = 0; i < 4; ++i) {
636
687
  if (boxInset(a, i) != boxInset(b, i) ||
688
+ #if GEA_CSS_PADDING
637
689
  a.padding[i] != b.padding[i] ||
690
+ #endif
691
+ #if GEA_CSS_MARGINS
638
692
  a.margin[i] != b.margin[i] ||
693
+ #endif
694
+ #if GEA_CSS_BOX_EXPRESSIONS
639
695
  ar.margin_expression[i] != br.margin_expression[i] ||
696
+ #endif
697
+ #if GEA_CSS_BOX_EXPRESSIONS
640
698
  ar.padding_expression[i] != br.padding_expression[i] ||
641
- a.pos_offsets[i] != b.pos_offsets[i] ||
642
- a.pos_offset_percent[i] != b.pos_offset_percent[i]) return false;
699
+ #endif
700
+ false) return false;
643
701
  }
644
702
  if (a.position != b.position ||
645
703
  a.z_index != b.z_index ||
@@ -706,12 +764,18 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
706
764
  auto &state = treeState();
707
765
  if (node < 0 || node >= state.nodeCount) return;
708
766
  Node &target = state.nodes[node];
709
- if (beforeImageId == target.image_id && styleExactlyEqual(beforeStyle, target.style) && !firstLineChanged) return;
767
+ if (beforeImageId == target.image_id && styleExactlyEqual(beforeStyle, target.computedStyle()) && !firstLineChanged) return;
710
768
  if (!nodeParticipatesInMountedTree(state, node)) return;
769
+ const bool hadRecolor = target.render.bg_recolor_pending;
770
+ const bool canRecolor = !target.render.dirty || hadRecolor;
771
+ target.render.text_partial_dirty = 0;
772
+ target.render.bg_recolor_pending = 0;
711
773
  if (firstLineChanged) {
712
774
  target.render.dirty = 1;
713
775
  target.render.layout_dirty = 1;
776
+ #if GEA_CSS_SCROLLING
714
777
  target.render.non_scroll_dirty = 1;
778
+ #endif
715
779
  Tree::instance().markNodeDisplayCommandsDirty(node);
716
780
  // First-line backgrounds are recorded with descendant text fragments.
717
781
  // Rebuilding only the owner's box would retain their old fill commands.
@@ -719,7 +783,9 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
719
783
  for (int child = state.nodes[parent].first_child; child >= 0; child = state.nodes[child].next_sibling) {
720
784
  if (state.nodes[child].type == NodeType::Text) {
721
785
  state.nodes[child].render.dirty = 1;
786
+ #if GEA_CSS_SCROLLING
722
787
  state.nodes[child].render.non_scroll_dirty = 1;
788
+ #endif
723
789
  Tree::instance().markNodeDisplayCommandsDirty(child);
724
790
  }
725
791
  self(self, child);
@@ -727,20 +793,22 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
727
793
  };
728
794
  invalidateText(invalidateText, node);
729
795
  }
730
- if (beforeImageId == target.image_id && styleExactlyEqual(beforeStyle, target.style) && firstLineChanged) {
796
+ if (beforeImageId == target.image_id && styleExactlyEqual(beforeStyle, target.computedStyle()) && firstLineChanged) {
731
797
  return;
732
798
  }
733
799
 
734
- if (beforeImageId == target.image_id && styleEqualExceptTextPaint(beforeStyle, target.style)) {
735
- if (target.type == NodeType::Text || borderUsesCurrentColor(target.style) || borderUsesCurrentColor(beforeStyle)) {
800
+ if (beforeImageId == target.image_id && styleEqualExceptTextPaint(beforeStyle, target.computedStyle())) {
801
+ if (target.type == NodeType::Text || borderUsesCurrentColor(target.computedStyle()) || borderUsesCurrentColor(beforeStyle)) {
736
802
  target.render.dirty = 1; // paint-only: text color; geometry untouched
803
+ #if GEA_CSS_SCROLLING
737
804
  target.render.non_scroll_dirty = 1;
805
+ #endif
738
806
  Tree::instance().markNodeDisplayCommandsDirty(node);
739
807
  }
740
808
  return;
741
809
  }
742
810
 
743
- if (beforeImageId == target.image_id && styleEqualExceptPlainBackgroundColor(beforeStyle, target.style)) {
811
+ if (beforeImageId == target.image_id && styleEqualExceptPlainBackgroundColor(beforeStyle, target.computedStyle())) {
744
812
  // Preserve `bg_recolor_from` across coalesced changes. The in-place recolor
745
813
  // rewrites framebuffer pixels equal to `from`. If several background-color
746
814
  // changes land between renders (e.g. fast rotary spins A->B->C), overwriting
@@ -748,27 +816,30 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
748
816
  // is still the original (A) from the last render — so almost nothing matches and
749
817
  // the background only partially recolors, leaving a patchwork that never
750
818
  // converges. Capture `from` only on the first change since the last render (when
751
- // the framebuffer still matches the current style), and just advance `to`.
752
- if (!target.render.bg_recolor_pending) {
819
+ // the framebuffer still matches the current style), and read the destination from the current style.
820
+ if (canRecolor && !firstLineChanged) {
821
+ if (!hadRecolor) target.render.bg_recolor_from = beforeStyle.bg_color;
753
822
  target.render.bg_recolor_pending = 1;
754
- target.render.bg_recolor_from = beforeStyle.bg_color;
755
823
  }
756
- target.render.bg_recolor_to = target.style.bg_color;
757
824
  target.render.dirty = 1; // paint-only: background recolor; geometry untouched
825
+ #if GEA_CSS_SCROLLING
758
826
  target.render.non_scroll_dirty = 1;
827
+ #endif
759
828
  Tree::instance().markNodeDisplayCommandsDirty(node);
760
829
  return;
761
830
  }
762
831
 
763
832
  target.render.dirty = 1;
833
+ #if GEA_CSS_SCROLLING
764
834
  target.render.non_scroll_dirty = 1;
765
- if (preserves3D(beforeStyle) != preserves3D(target.style))
835
+ #endif
836
+ if (preserves3D(beforeStyle) != preserves3D(target.computedStyle()))
766
837
  Tree::instance().markDisplayListDirty();
767
- if (beforeImageId == target.image_id && styleEqualExceptLocalDisplayCommands(beforeStyle, target.style)) {
838
+ if (beforeImageId == target.image_id && styleEqualExceptLocalDisplayCommands(beforeStyle, target.computedStyle())) {
768
839
  // Local display-command diff: geometry equal by the predicate's
769
840
  // construction (transforms ride transform_dirty), so no layout pass.
770
841
  const RareStyle &beforeRare = rstyle(beforeStyle);
771
- const RareStyle &targetRare = rstyle(target.style);
842
+ const RareStyle &targetRare = rstyle(target.computedStyle());
772
843
  if (beforeRare.transform_rotate != targetRare.transform_rotate ||
773
844
  beforeRare.transform_translate_outer_axes != targetRare.transform_translate_outer_axes ||
774
845
  beforeRare.rotate_angle != targetRare.rotate_angle ||
@@ -798,15 +869,20 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
798
869
  beforeRare.perspective != targetRare.perspective ||
799
870
  beforeRare.perspective_origin_x != targetRare.perspective_origin_x ||
800
871
  beforeRare.perspective_origin_y != targetRare.perspective_origin_y) {
872
+ #if GEA_CSS_TRANSFORMS
801
873
  target.render.transform_dirty = 1;
874
+ #endif
802
875
  if (state.fixedPositionUsed) target.render.layout_dirty = 1;
876
+
877
+ #if GEA_CSS_TRANSFORMS
803
878
  state.transformScanSerial = ~0ull;
804
879
  state.transformScanValid = false; // a transform was added/changed → drop durable no-transform cache
880
+ #endif
805
881
  }
806
882
  Tree::instance().markNodeDisplayCommandsDirty(node);
807
883
  // Flattened backface visibility changes the whole descendant paint group.
808
- if (beforeStyle.backface_hidden != target.style.backface_hidden ||
809
- rstyle(beforeStyle).transform_preserve_3d != rstyle(target.style).transform_preserve_3d)
884
+ if (beforeStyle.backface_hidden != target.computedStyle().backface_hidden ||
885
+ rstyle(beforeStyle).transform_preserve_3d != rstyle(target.computedStyle()).transform_preserve_3d)
810
886
  Tree::instance().markDisplayListDirty();
811
887
  return;
812
888
  }
@@ -1015,6 +1091,11 @@ using CssDeclarationId = StyleDeclaration;
1015
1091
  CssDeclarationId classifyDeclaration(const char *property)
1016
1092
  {
1017
1093
  if (!property || !*property) return CssDeclarationId::Unknown;
1094
+ // Position updates are frequent; resolve them before the long declaration list.
1095
+ if (std::strcmp(property, "top") == 0) return CssDeclarationId::Top;
1096
+ if (std::strcmp(property, "left") == 0) return CssDeclarationId::Left;
1097
+ if (std::strcmp(property, "right") == 0) return CssDeclarationId::Right;
1098
+ if (std::strcmp(property, "bottom") == 0) return CssDeclarationId::Bottom;
1018
1099
  if (property[0] == '-' && property[1] == '-') return CssDeclarationId::Custom;
1019
1100
  if (std::strcmp(property, "color-scheme") == 0 ||
1020
1101
  std::strcmp(property, "isolation") == 0 ||
@@ -1078,10 +1159,6 @@ CssDeclarationId classifyDeclaration(const char *property)
1078
1159
  if (std::strcmp(property, "margin-left") == 0) return CssDeclarationId::MarginLeft;
1079
1160
  if (std::strcmp(property, "position") == 0) return CssDeclarationId::Position;
1080
1161
  if (std::strcmp(property, "inset") == 0) return CssDeclarationId::Inset;
1081
- if (std::strcmp(property, "top") == 0) return CssDeclarationId::Top;
1082
- if (std::strcmp(property, "right") == 0) return CssDeclarationId::Right;
1083
- if (std::strcmp(property, "bottom") == 0) return CssDeclarationId::Bottom;
1084
- if (std::strcmp(property, "left") == 0) return CssDeclarationId::Left;
1085
1162
  if (std::strcmp(property, "box-sizing") == 0) return CssDeclarationId::BoxSizing;
1086
1163
  if (std::strcmp(property, "float") == 0) return CssDeclarationId::Float;
1087
1164
  if (std::strcmp(property, "aspect-ratio") == 0) return CssDeclarationId::AspectRatio;
@@ -1306,8 +1383,8 @@ struct ResolvedCssLength {
1306
1383
  };
1307
1384
 
1308
1385
  struct CachedCssColor {
1309
- std::int32_t styleColor = 0;
1310
- std::int32_t nativeColor = 0;
1386
+ NodeCustomProperty::ColorValue styleColor = 0;
1387
+ NodeCustomProperty::ColorValue nativeColor = 0;
1311
1388
  std::uint8_t alpha = 255;
1312
1389
  bool valid = false;
1313
1390
  };
@@ -1342,7 +1419,9 @@ struct CssCompiledValue {
1342
1419
  std::uint16_t flags = 0;
1343
1420
  std::uint8_t aux = 0;
1344
1421
  CssLengthSpec lengths[4];
1345
- std::int32_t values[11]{};
1422
+ // Four direct-property pairs are the largest scalar payload. Transform
1423
+ // rotation and scale occupy slots 0..5; translations use lengths[].
1424
+ std::int32_t values[8]{};
1346
1425
  };
1347
1426
 
1348
1427
  CssLengthSpec cssLengthSpecForStatic(StaticStyleLengthSpec spec);
@@ -1421,7 +1500,9 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &value
1421
1500
  int containmentValue(const std::string &value);
1422
1501
 
1423
1502
  std::uint16_t compileCustomPropertyValue(const CssText &value);
1503
+ #if GEA_CSS_ANIMATIONS
1424
1504
  std::uint16_t compileCssAnimationSpec(const CssText &value);
1505
+ #endif
1425
1506
  std::uint16_t compileSelectorPlan(const CssText &selector);
1426
1507
  std::uint16_t compileMediaConditionPlan(const CssText &condition);
1427
1508
  void clearCompiledCssBackgrounds();
@@ -1430,13 +1511,13 @@ void clearCompiledCssLengthExpressions();
1430
1511
  void clearStaticLengthExpressionResolutionCache();
1431
1512
 
1432
1513
  struct CssRule {
1433
- enum class SelectorType {
1514
+ enum class SelectorType : std::uint8_t {
1434
1515
  Class,
1435
1516
  Element,
1436
1517
  Selector
1437
1518
  };
1438
1519
 
1439
- enum class PseudoElement {
1520
+ enum class PseudoElement : std::uint8_t {
1440
1521
  None,
1441
1522
  Before,
1442
1523
  After,
@@ -1449,7 +1530,9 @@ struct CssRule {
1449
1530
  CssRuleProperty propertyKind;
1450
1531
  CssDeclarationId declaration;
1451
1532
  std::uint16_t compiledValue;
1533
+ #if GEA_CSS_ANIMATIONS
1452
1534
  std::uint16_t compiledAnimationSpec;
1535
+ #endif
1453
1536
  CssAtomId selectorAtom;
1454
1537
  CssAtomId propertyAtom;
1455
1538
  int16_t selectorTagId;
@@ -1462,8 +1545,8 @@ struct CssRule {
1462
1545
  };
1463
1546
 
1464
1547
  struct CssKeyframeRule {
1465
- CssAtomId nameAtom;
1466
1548
  int offsetPermille;
1549
+ CssAtomId nameAtom;
1467
1550
  CssRuleProperty propertyKind;
1468
1551
  CssDeclarationId declaration;
1469
1552
  std::uint16_t compiledValue;
@@ -1535,7 +1618,9 @@ void recomputeDescendantClassStyles(int node);
1535
1618
  void recomputeSubtreeClassStyles(int node);
1536
1619
  void setStyleValue(NodeHandle node, Property property, int value, StyleApplicationSource source);
1537
1620
  struct ActiveRulePlan;
1621
+ #if GEA_CSS_ANIMATIONS
1538
1622
  void primeCssAnimationsForNode(int node, const ActiveRulePlan *activePlan = nullptr);
1623
+ #endif
1539
1624
  int parseOriginPart(const std::string &part, int fallback);
1540
1625
 
1541
1626
  // File-scope lazy pointer rather than a function-local static: the static-local
@@ -1646,7 +1731,9 @@ struct KeyframeRuleIndex {
1646
1731
  DenseRuleBuckets byName;
1647
1732
  };
1648
1733
 
1734
+ #if GEA_CSS_ANIMATIONS
1649
1735
  KeyframeRuleIndex g_keyframeRuleIndex;
1736
+ #endif
1650
1737
 
1651
1738
  struct DenseIdSet {
1652
1739
  std::vector<std::uint8_t> bits;
@@ -1681,15 +1768,20 @@ struct DenseIdSet {
1681
1768
 
1682
1769
  void invalidateKeyframeRuleIndex()
1683
1770
  {
1771
+ #if GEA_CSS_ANIMATIONS
1684
1772
  g_keyframeRuleIndex.valid = false;
1773
+ #endif
1685
1774
  }
1686
1775
 
1687
1776
  void clearKeyframeRuleIndex()
1688
1777
  {
1778
+ #if GEA_CSS_ANIMATIONS
1689
1779
  g_keyframeRuleIndex.byName.clear();
1690
1780
  g_keyframeRuleIndex.valid = false;
1781
+ #endif
1691
1782
  }
1692
1783
 
1784
+ #if GEA_CSS_ANIMATIONS
1693
1785
  void rebuildKeyframeRuleIndexIfNeeded()
1694
1786
  {
1695
1787
  if (g_keyframeRuleIndex.valid) return;
@@ -1710,6 +1802,8 @@ DenseRuleBucketSpan keyframeRuleIndicesForName(CssAtomId name)
1710
1802
  return g_keyframeRuleIndex.byName.get(name);
1711
1803
  }
1712
1804
 
1805
+ #endif
1806
+
1713
1807
  std::vector<CssCompiledValue> &compiledCssValues()
1714
1808
  {
1715
1809
  static std::vector<CssCompiledValue> list;
@@ -1764,12 +1858,12 @@ std::uint16_t storeDirectPropertyGroupCompiledValue(std::initializer_list<Static
1764
1858
  int count = 0;
1765
1859
  for (const StaticStylePropertyValue &entry : properties) {
1766
1860
  if (count >= 4) break;
1767
- compiled.values[1 + count * 2] = static_cast<int>(entry.property);
1768
- compiled.values[2 + count * 2] = entry.value;
1861
+ compiled.values[count * 2] = static_cast<int>(entry.property);
1862
+ compiled.values[1 + count * 2] = entry.value;
1769
1863
  count++;
1770
1864
  }
1771
1865
  if (count == 0) return kNoCompiledCssValue;
1772
- compiled.values[0] = count;
1866
+ compiled.aux = static_cast<std::uint8_t>(count);
1773
1867
  list.push_back(compiled);
1774
1868
  return static_cast<std::uint16_t>(list.size() - 1);
1775
1869
  }
@@ -2203,19 +2297,21 @@ std::vector<CssLengthExpression> &compiledCssLengthExpressions()
2203
2297
  }
2204
2298
 
2205
2299
  struct StaticLengthExpressionResolution {
2206
- ResolvedCssLength value;
2300
+ // Reuse ResolvedCssLength's two tail-padding bytes for cache bookkeeping.
2301
+ // All members remain direct loads; the cached value keeps its full precision.
2302
+ [[no_unique_address]] ResolvedCssLength value;
2207
2303
  std::uint8_t status = 0; // 0 unknown, 1 dynamic, 2 cacheable
2208
2304
  std::uint8_t valid = 0;
2209
2305
  };
2210
2306
 
2211
2307
  struct DynamicLengthExpressionResolution {
2212
2308
  #if GEA_EMBEDDED_UI_STATE_DYNAMIC_INIT
2213
- ResolvedCssLength value;
2309
+ [[no_unique_address]] ResolvedCssLength value;
2310
+ std::uint8_t axis;
2311
+ std::uint8_t valid;
2214
2312
  std::uint16_t handle;
2215
2313
  std::int16_t nodeId;
2216
2314
  int basis;
2217
- std::uint8_t axis;
2218
- std::uint8_t valid;
2219
2315
 
2220
2316
  // Runtime initialization keeps the nonzero sentinels out of .data (see
2221
2317
  // state_init.h); noinline stops the compiler folding them back in.
@@ -2229,12 +2325,12 @@ struct DynamicLengthExpressionResolution {
2229
2325
  valid = 0;
2230
2326
  }
2231
2327
  #else
2232
- ResolvedCssLength value;
2328
+ [[no_unique_address]] ResolvedCssLength value;
2329
+ std::uint8_t axis = 0;
2330
+ std::uint8_t valid = 0;
2233
2331
  std::uint16_t handle = kNoCompiledCssLengthExpression;
2234
2332
  std::int16_t nodeId = -1;
2235
2333
  int basis = 0;
2236
- std::uint8_t axis = 0;
2237
- std::uint8_t valid = 0;
2238
2334
  #endif
2239
2335
  };
2240
2336
 
@@ -2393,13 +2489,17 @@ CssRule makeCssRule(CssRule::SelectorType selectorType,
2393
2489
  const std::uint16_t compiledValue = declaration == CssDeclarationId::Custom
2394
2490
  ? compileCustomPropertyValue(value)
2395
2491
  : compileCssValue(declaration, value);
2492
+ #if GEA_CSS_ANIMATIONS
2396
2493
  const std::uint16_t compiledAnimationSpec = declaration == CssDeclarationId::Animation
2397
2494
  ? compileCssAnimationSpec(value)
2398
2495
  : kNoCompiledCssAnimationSpec;
2496
+ #endif
2399
2497
  const std::uint16_t mediaPlan = compileMediaConditionPlan(media);
2400
2498
  const bool keepValueText =
2401
2499
  declaration == CssDeclarationId::Custom ||
2500
+ #if GEA_CSS_ANIMATIONS
2402
2501
  (declaration == CssDeclarationId::Animation && compiledAnimationSpec == kNoCompiledCssAnimationSpec) ||
2502
+ #endif
2403
2503
  (declaration != CssDeclarationId::Animation &&
2404
2504
  !compiledCssValueCanSkipRuleText(compiledValue));
2405
2505
  const bool keepPropertyText =
@@ -2416,7 +2516,9 @@ CssRule makeCssRule(CssRule::SelectorType selectorType,
2416
2516
  ? storeCssRuleText(std::move(media))
2417
2517
  : kNoCssRuleText;
2418
2518
  CssRule rule{selectorType, pseudoElement, rulePropertyKind(declaration), declaration, compiledValue,
2519
+ #if GEA_CSS_ANIMATIONS
2419
2520
  compiledAnimationSpec,
2521
+ #endif
2420
2522
  selectorAtom, propertyAtom, selectorTagId, selectorPlan, mediaPlan,
2421
2523
  propertyText, valueText, mediaText};
2422
2524
  return rule;
@@ -2627,9 +2729,9 @@ std::uint16_t storeStaticTransformCompiledValue(std::uint16_t flags,
2627
2729
  compiled.lengths[0] = cssLengthSpecForStatic(translateX);
2628
2730
  compiled.lengths[1] = cssLengthSpecForStatic(translateY);
2629
2731
  compiled.lengths[2] = cssLengthSpecForStatic(translateZ);
2630
- compiled.values[8] = scaleX;
2631
- compiled.values[9] = scaleY;
2632
- compiled.values[10] = scaleZ;
2732
+ compiled.values[3] = scaleX;
2733
+ compiled.values[4] = scaleY;
2734
+ compiled.values[5] = scaleZ;
2633
2735
  list.push_back(compiled);
2634
2736
  return static_cast<std::uint16_t>(list.size() - 1);
2635
2737
  }
@@ -2754,7 +2856,9 @@ CssRule makeStaticCompiledCssRule(StaticStyleSelectorKind selectorKind,
2754
2856
  propertyKind,
2755
2857
  declaration,
2756
2858
  compiledValue,
2859
+ #if GEA_CSS_ANIMATIONS
2757
2860
  kNoCompiledCssAnimationSpec,
2861
+ #endif
2758
2862
  selectorAtom,
2759
2863
  kInvalidCssAtom,
2760
2864
  selectorTagId,
@@ -3156,7 +3260,7 @@ CssKeyframeRule makeCssKeyframeRule(CssText name, int offsetPermille, CssText pr
3156
3260
  const std::uint16_t valueText = compiledCssValueCanSkipKeyframeText(compiledValue)
3157
3261
  ? kNoCssRuleText
3158
3262
  : storeCssRuleText(std::move(value));
3159
- CssKeyframeRule rule{nameAtom, offsetPermille, rulePropertyKind(declaration),
3263
+ CssKeyframeRule rule{offsetPermille, nameAtom, rulePropertyKind(declaration),
3160
3264
  declaration, compiledValue, valueText};
3161
3265
  return rule;
3162
3266
  }
@@ -3167,8 +3271,8 @@ CssKeyframeRule makeStaticCompiledKeyframeRule(const char *name,
3167
3271
  CssDeclarationId declaration,
3168
3272
  std::uint16_t compiledValue)
3169
3273
  {
3170
- return CssKeyframeRule{internCssAtom(name ? name : ""),
3171
- offsetPermille,
3274
+ return CssKeyframeRule{offsetPermille,
3275
+ internCssAtom(name ? name : ""),
3172
3276
  propertyKind,
3173
3277
  declaration,
3174
3278
  compiledValue,
@@ -3264,8 +3368,8 @@ CssKeyframeRule makeStaticTransformKeyframeRule(const char *name,
3264
3368
  int scaleY,
3265
3369
  int scaleZ)
3266
3370
  {
3267
- return CssKeyframeRule{internCssAtom(name ? name : ""),
3268
- offsetPermille,
3371
+ return CssKeyframeRule{offsetPermille,
3372
+ internCssAtom(name ? name : ""),
3269
3373
  rulePropertyKind(CssDeclarationId::Transform),
3270
3374
  CssDeclarationId::Transform,
3271
3375
  storeStaticTransformCompiledValue(flags,
@@ -3406,6 +3510,7 @@ std::vector<std::string> splitTopLevel(const std::string &value, char delimiter)
3406
3510
 
3407
3511
  const NodeCustomProperty *lookupCustomPropertyEntry(int nodeId, CssAtomId name)
3408
3512
  {
3513
+ #if GEA_CSS_CUSTOM_PROPERTIES
3409
3514
  // Record the dependency against the node currently being recomputed (not nodeId:
3410
3515
  // pseudo-element resolution looks up from the pseudo node but the dependency
3411
3516
  // belongs to its owner, which is g_recordingNode). Record on every lookup, hit or
@@ -3439,12 +3544,15 @@ const NodeCustomProperty *lookupCustomPropertyEntry(int nodeId, CssAtomId name)
3439
3544
  }
3440
3545
  }
3441
3546
  storeVisited(nullptr);
3547
+ #else
3548
+ (void)nodeId; (void)name;
3549
+ #endif
3442
3550
  return nullptr;
3443
3551
  }
3444
3552
 
3445
3553
  const std::string *lookupCustomProperty(int nodeId, CssAtomId name)
3446
3554
  {
3447
- if (const NodeCustomProperty *entry = lookupCustomPropertyEntry(nodeId, name)) return &entry->value;
3555
+ if (const NodeCustomProperty *entry = lookupCustomPropertyEntry(nodeId, name)) return entry->value.get();
3448
3556
  return nullptr;
3449
3557
  }
3450
3558
 
@@ -3505,17 +3613,17 @@ int percentBasisForNode(int nodeId, LengthAxis axis)
3505
3613
  int parent = nodeId >= 0 && nodeId < state.nodeCount ? state.nodes[nodeId].parent : -1;
3506
3614
  if (parent >= 0 && parent < state.nodeCount) {
3507
3615
  const auto &p = state.nodes[parent];
3508
- const int padding = boxInsets(p.style, axis != LengthAxis::Vertical);
3616
+ const int padding = boxInsets(p.computedStyle(), axis != LengthAxis::Vertical);
3509
3617
  auto contentBasis = [padding](int value) {
3510
3618
  value -= padding;
3511
3619
  return value < 0 ? 0 : value;
3512
3620
  };
3513
3621
  if (axis == LengthAxis::Vertical) {
3514
3622
  if (p.layout.height > 0) return contentBasis(p.layout.height);
3515
- if (p.style.height != kUnset) return p.style.box_sizing == 0 ? p.style.height : contentBasis(p.style.height);
3623
+ if (p.computedStyle().height != kUnset) return p.computedStyle().box_sizing == 0 ? p.computedStyle().height : contentBasis(p.computedStyle().height);
3516
3624
  } else {
3517
3625
  if (p.layout.width > 0) return contentBasis(p.layout.width);
3518
- if (p.style.width != kUnset) return p.style.box_sizing == 0 ? p.style.width : contentBasis(p.style.width);
3626
+ if (p.computedStyle().width != kUnset) return p.computedStyle().box_sizing == 0 ? p.computedStyle().width : contentBasis(p.computedStyle().width);
3519
3627
  }
3520
3628
  }
3521
3629
  return axis == LengthAxis::Vertical ? g_viewport_height : g_viewport_width;
@@ -3562,7 +3670,7 @@ int lineHeightForLength(int nodeId, bool rootRelative)
3562
3670
  if (basis >= 0 && basis < state.nodeCount &&
3563
3671
  (basis == g_fontSizeBasisNode || basis == g_lineHeightBasisNode)) basis = state.nodes[basis].parent;
3564
3672
  if (basis >= 0 && basis < state.nodeCount) {
3565
- const auto &style = state.nodes[basis].style;
3673
+ const auto &style = state.nodes[basis].computedStyle();
3566
3674
  if (style.line_height > 0) return style.line_height;
3567
3675
  return TextRenderer::measureHeight(" ", style.font_id, currentFontSizeForNode(basis));
3568
3676
  }
@@ -3574,7 +3682,7 @@ int zeroAdvanceForNode(int nodeId)
3574
3682
  {
3575
3683
  const auto &state = treeState();
3576
3684
  nodeId = fontMetricBasisNode(nodeId);
3577
- const int fontId = nodeId >= 0 && nodeId < state.nodeCount ? state.nodes[nodeId].style.font_id : -1;
3685
+ const int fontId = nodeId >= 0 && nodeId < state.nodeCount ? state.nodes[nodeId].computedStyle().font_id : -1;
3578
3686
  return TextRenderer::measureWidth("0", fontId, currentFontSizeForNode(nodeId));
3579
3687
  }
3580
3688
 
@@ -3783,8 +3891,8 @@ int parseLength(const std::string &value)
3783
3891
  int currentFontSizeForNode(int nodeId)
3784
3892
  {
3785
3893
  auto &state = treeState();
3786
- if (nodeId >= 0 && nodeId < state.nodeCount && state.nodes[nodeId].style.font_size > 0)
3787
- return state.nodes[nodeId].style.font_size;
3894
+ if (nodeId >= 0 && nodeId < state.nodeCount && state.nodes[nodeId].computedStyle().font_size > 0)
3895
+ return state.nodes[nodeId].computedStyle().font_size;
3788
3896
  return cssPixelLength(16.0);
3789
3897
  }
3790
3898
 
@@ -4096,7 +4204,7 @@ ParsedCssColor parseCssColor(const std::string &value)
4096
4204
  // RAW (pre-panel-swap) native style-value for colours applied via setStyleValue()
4097
4205
  // -> Tree::setStyle() -> StyleValues::pixelFromStyleValue(), which applies the
4098
4206
  // panel byte-swap once on 16-bit boards (must be raw here or colours double-swap,
4099
- // e.g. cream text rendered periwinkle). Colours written straight into node.style
4207
+ // e.g. cream text rendered periwinkle). Colours written straight into node.computedStyle()
4100
4208
  // (gradient stops, grid lines) bypass that swap and use cssColorNative() instead.
4101
4209
  // On full-colour boards there is no panel concept, so both are identical RGBA8888.
4102
4210
  gea::framework::graphics::pixel::native_t cssColorStyleValue(const ParsedCssColor &color)
@@ -4147,10 +4255,12 @@ void setCustomPropertyValue(NodeCustomPropertyStore &store, CssAtomId name, cons
4147
4255
  color.alpha);
4148
4256
  return;
4149
4257
  }
4258
+ #if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
4150
4259
  if (const CssLengthSpec *length = cachedCompiledCssLengthSpec(value)) {
4151
4260
  store.setLength(name, value, length->value, static_cast<std::uint8_t>(length->unit));
4152
4261
  return;
4153
4262
  }
4263
+ #endif
4154
4264
  store.set(name, value);
4155
4265
  }
4156
4266
 
@@ -4174,6 +4284,7 @@ void setCustomPropertyRuleValue(NodeCustomPropertyStore &store,
4174
4284
  static_cast<std::uint8_t>(compiled.values[2]));
4175
4285
  return;
4176
4286
  }
4287
+ #if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
4177
4288
  if (compiled.kind == CssCompiledKind::Length) {
4178
4289
  CssLengthSpec storedLength;
4179
4290
  if (tryPreResolveStaticCustomLengthSpec(compiled.lengths[0], nodeId, storedLength)) {
@@ -4189,6 +4300,7 @@ void setCustomPropertyRuleValue(NodeCustomPropertyStore &store,
4189
4300
  static_cast<std::uint8_t>(compiled.lengths[0].unit));
4190
4301
  return;
4191
4302
  }
4303
+ #endif
4192
4304
  }
4193
4305
  }
4194
4306
  setCustomPropertyValue(store, name, value);
@@ -5539,7 +5651,7 @@ bool lengthDependsOnInput(const CssLengthSpec &length, int nodeId, CssLengthUnit
5539
5651
  if (entry->hasLength()) {
5540
5652
  spec.value = entry->lengthValue;
5541
5653
  spec.unit = static_cast<CssLengthUnit>(entry->lengthUnit);
5542
- } else if (!parseCompiledLengthSpec(entry->value, spec)) return false;
5654
+ } else if (!parseCompiledLengthSpec(*entry->value, spec)) return false;
5543
5655
  return lengthDependsOnInput(spec, nodeId, input, depth + 1);
5544
5656
  }
5545
5657
  return expression.hasFallback && lengthDependsOnInput(expression.a, nodeId, input, depth + 1);
@@ -5658,7 +5770,7 @@ ResolvedCssLength resolveCompiledLengthExpressionForNode(const CssLengthExpressi
5658
5770
  spec.unit = static_cast<CssLengthUnit>(entry->lengthUnit);
5659
5771
  return resolveCompiledLengthForNodeDetailed(spec, nodeId, axis, depth + 1);
5660
5772
  }
5661
- return resolveCustomPropertyLengthForNode(entry->value, nodeId, axis, depth + 1);
5773
+ return resolveCustomPropertyLengthForNode(*entry->value, nodeId, axis, depth + 1);
5662
5774
  }
5663
5775
  if (expression.hasFallback)
5664
5776
  return resolveCompiledLengthForNodeDetailed(expression.a, nodeId, axis, depth + 1);
@@ -6802,6 +6914,7 @@ bool compileKeywordValue(CssDeclarationId declaration, const std::string &value,
6802
6914
  case CssDeclarationId::AlignContent:
6803
6915
  compiled.values[0] = flexAlignValue(value);
6804
6916
  return compiled.values[0] >= 0;
6917
+ #if GEA_CSS_GRID
6805
6918
  case CssDeclarationId::GridRowStart:
6806
6919
  case CssDeclarationId::GridColumnStart:
6807
6920
  case CssDeclarationId::GridRowEnd:
@@ -6812,6 +6925,7 @@ bool compileKeywordValue(CssDeclarationId declaration, const std::string &value,
6812
6925
  compiled.values[0] = line;
6813
6926
  return true;
6814
6927
  }
6928
+ #endif
6815
6929
  case CssDeclarationId::JustifySelf:
6816
6930
  compiled.values[0] = justifySelfValue(value);
6817
6931
  return compiled.values[0] >= -1;
@@ -6836,12 +6950,14 @@ bool compileKeywordValue(CssDeclarationId declaration, const std::string &value,
6836
6950
  case CssDeclarationId::TextOverflow:
6837
6951
  compiled.values[0] = textOverflowValue(value);
6838
6952
  return true;
6953
+ #if GEA_CSS_TRANSFORMS
6839
6954
  case CssDeclarationId::TransformStyle: {
6840
6955
  const auto lower = toLowerAscii(trimCssValue(value));
6841
6956
  if (lower != "flat" && lower != "preserve-3d") return false;
6842
6957
  compiled.values[0] = lower == "preserve-3d";
6843
6958
  return true;
6844
6959
  }
6960
+ #endif
6845
6961
  case CssDeclarationId::Visibility:
6846
6962
  compiled.values[0] = visibilityValue(value);
6847
6963
  return compiled.values[0] >= 0;
@@ -6876,7 +6992,7 @@ bool compileTransformLength(const std::string &value, CssLengthSpec &out)
6876
6992
  bool compileTransformValue(const std::string &value, CssCompiledValue &compiled)
6877
6993
  {
6878
6994
  TransformRotationProduct rotations;
6879
- compiled.values[8] = compiled.values[9] = compiled.values[10] = 1000;
6995
+ compiled.values[3] = compiled.values[4] = compiled.values[5] = 1000;
6880
6996
  std::size_t i = 0;
6881
6997
  bool sawTransform = false;
6882
6998
  while (i < value.size()) {
@@ -6937,26 +7053,26 @@ bool compileTransformValue(const std::string &value, CssCompiledValue &compiled)
6937
7053
  if (hasDynamicCssValue(arg)) return false;
6938
7054
  const int sx = parseScalePermille(args.empty() ? arg : args[0]);
6939
7055
  const int sy = parseScalePermille(args.size() > 1 ? args[1] : (args.empty() ? arg : args[0]));
6940
- compiled.values[8] = multiplyScalePermille(compiled.values[8], sx);
6941
- compiled.values[9] = multiplyScalePermille(compiled.values[9], sy);
7056
+ compiled.values[3] = multiplyScalePermille(compiled.values[3], sx);
7057
+ compiled.values[4] = multiplyScalePermille(compiled.values[4], sy);
6942
7058
  compiled.flags |= (1u << 8) | (1u << 9);
6943
7059
  } else if (name == "scale3d") {
6944
7060
  if (hasDynamicCssValue(arg) || args.size() != 3) return false;
6945
- compiled.values[8] = multiplyScalePermille(compiled.values[8], parseScalePermille(args[0]));
6946
- compiled.values[9] = multiplyScalePermille(compiled.values[9], parseScalePermille(args[1]));
6947
- compiled.values[10] = multiplyScalePermille(compiled.values[10], parseScalePermille(args[2]));
7061
+ compiled.values[3] = multiplyScalePermille(compiled.values[3], parseScalePermille(args[0]));
7062
+ compiled.values[4] = multiplyScalePermille(compiled.values[4], parseScalePermille(args[1]));
7063
+ compiled.values[5] = multiplyScalePermille(compiled.values[5], parseScalePermille(args[2]));
6948
7064
  compiled.flags |= (1u << 8) | (1u << 9) | (1u << 13);
6949
7065
  } else if (name == "scalex") {
6950
7066
  if (hasDynamicCssValue(arg)) return false;
6951
- compiled.values[8] = multiplyScalePermille(compiled.values[8], parseScalePermille(arg));
7067
+ compiled.values[3] = multiplyScalePermille(compiled.values[3], parseScalePermille(arg));
6952
7068
  compiled.flags |= 1u << 8;
6953
7069
  } else if (name == "scaley") {
6954
7070
  if (hasDynamicCssValue(arg)) return false;
6955
- compiled.values[9] = multiplyScalePermille(compiled.values[9], parseScalePermille(arg));
7071
+ compiled.values[4] = multiplyScalePermille(compiled.values[4], parseScalePermille(arg));
6956
7072
  compiled.flags |= 1u << 9;
6957
7073
  } else if (name == "scalez") {
6958
7074
  if (hasDynamicCssValue(arg)) return false;
6959
- compiled.values[10] = multiplyScalePermille(compiled.values[10], parseScalePermille(arg));
7075
+ compiled.values[5] = multiplyScalePermille(compiled.values[5], parseScalePermille(arg));
6960
7076
  compiled.flags |= 1u << 13;
6961
7077
  } else {
6962
7078
  return false;
@@ -7098,9 +7214,9 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
7098
7214
  int align, justify;
7099
7215
  if (!parseAlignmentShorthand(declaration, value, align, justify)) return kNoCompiledCssValue;
7100
7216
  compiled.kind = CssCompiledKind::DirectPropertyGroup;
7101
- compiled.values[0] = 2;
7102
- compiled.values[1] = static_cast<int>(alignProperty); compiled.values[2] = align;
7103
- compiled.values[3] = static_cast<int>(justifyProperty); compiled.values[4] = justify;
7217
+ compiled.aux = 2;
7218
+ compiled.values[0] = static_cast<int>(alignProperty); compiled.values[1] = align;
7219
+ compiled.values[2] = static_cast<int>(justifyProperty); compiled.values[3] = justify;
7104
7220
  return storeCompiledCssValue(compiled);
7105
7221
  }
7106
7222
 
@@ -7286,7 +7402,12 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
7286
7402
  case CssDeclarationId::BorderBottomWidth:
7287
7403
  case CssDeclarationId::BorderLeftWidth:
7288
7404
  case CssDeclarationId::FontSize:
7405
+ #if GEA_CSS_TRANSFORMS
7289
7406
  case CssDeclarationId::Perspective:
7407
+ #endif
7408
+ // All preceding length declarations share this body. Only Perspective
7409
+ // itself is conditional; otherwise font-size/padding/min-size fall
7410
+ // through into the unrelated LineHeight compiler when transforms are off.
7290
7411
  if (isBorderWidthDeclaration(declaration) && isNegativeLengthLiteral(value)) return kNoCompiledCssValue;
7291
7412
  if (!compiledCssValueFeatureEnabled(kCssCompiledFeatureLength)) return kNoCompiledCssValue;
7292
7413
  if (!parseCompiledLengthSpec(value, compiled.lengths[0])) return kNoCompiledCssValue;
@@ -7298,6 +7419,7 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
7298
7419
  if (!compileLineHeightValue(value, compiled)) return kNoCompiledCssValue;
7299
7420
  compiled.kind = CssCompiledKind::LineHeight;
7300
7421
  return storeCompiledCssValue(compiled);
7422
+ #if GEA_CSS_TRANSFORMS
7301
7423
  case CssDeclarationId::TransformOrigin:
7302
7424
  case CssDeclarationId::PerspectiveOrigin: {
7303
7425
  if (hasVar) return kNoCompiledCssValue;
@@ -7331,18 +7453,19 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
7331
7453
  std::string function;
7332
7454
  if (!individualTranslateFunction(value, function)) return kNoCompiledCssValue;
7333
7455
  compiled.kind = CssCompiledKind::Transform;
7334
- compiled.values[8] = compiled.values[9] = 1000;
7456
+ compiled.values[3] = compiled.values[4] = 1000;
7335
7457
  if (function != "none" && !compileTransformValue(function, compiled)) return kNoCompiledCssValue;
7336
7458
  return storeCompiledCssValue(compiled);
7337
7459
  }
7338
7460
  case CssDeclarationId::Transform: {
7339
7461
  if (!compiledCssValueFeatureEnabled(kCssCompiledFeatureTransform)) return kNoCompiledCssValue;
7340
7462
  compiled.kind = CssCompiledKind::Transform;
7341
- compiled.values[8] = 1000;
7342
- compiled.values[9] = 1000;
7463
+ compiled.values[3] = 1000;
7464
+ compiled.values[4] = 1000;
7343
7465
  if (!compileTransformValue(value, compiled)) return kNoCompiledCssValue;
7344
7466
  return storeCompiledCssValue(compiled);
7345
7467
  }
7468
+ #endif
7346
7469
  case CssDeclarationId::Filter:
7347
7470
  if (hasVar && toLowerAscii(value).find("blur(") == std::string::npos) return kNoCompiledCssValue;
7348
7471
  if (!compiledCssValueFeatureEnabled(kCssCompiledFeatureEffects)) return kNoCompiledCssValue;
@@ -7360,6 +7483,7 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
7360
7483
  if (!compileBoxShadowValue(value, compiled)) return kNoCompiledCssValue;
7361
7484
  compiled.kind = CssCompiledKind::BoxShadow;
7362
7485
  return storeCompiledCssValue(compiled);
7486
+ #if GEA_CSS_GRID
7363
7487
  case CssDeclarationId::GridTemplateColumns:
7364
7488
  case CssDeclarationId::GridTemplateRows:
7365
7489
  if (hasVar) return kNoCompiledCssValue;
@@ -7367,6 +7491,7 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
7367
7491
  if (!compileGridTemplateValue(value, compiled)) return kNoCompiledCssValue;
7368
7492
  compiled.kind = CssCompiledKind::GridTemplate;
7369
7493
  return storeCompiledCssValue(compiled);
7494
+ #endif
7370
7495
  default:
7371
7496
  return kNoCompiledCssValue;
7372
7497
  }
@@ -7391,11 +7516,12 @@ void markDisplayListDirtyForStyleApply()
7391
7516
 
7392
7517
  void applyCompiledGridTemplateValue(NodeHandle node, const CssCompiledGridTemplate &grid, bool columns)
7393
7518
  {
7519
+ #if GEA_CSS_GRID
7394
7520
  if (!node) return;
7395
7521
  const int nodeId = node.id();
7396
7522
  Node &target = treeState().nodes[nodeId];
7397
7523
  const LengthAxis axis = columns ? LengthAxis::Horizontal : LengthAxis::Vertical;
7398
- RareStyle &rs = rstyleMut(target.style);
7524
+ RareStyle &rs = rstyleMut(target.mutableStyle());
7399
7525
  int8_t *types = columns ? rs.grid_column_type : rs.grid_row_type;
7400
7526
  int16_t *values = columns ? rs.grid_column_value : rs.grid_row_value;
7401
7527
  int8_t &count = columns ? rs.grid_column_count : rs.grid_row_count;
@@ -7414,8 +7540,11 @@ void applyCompiledGridTemplateValue(NodeHandle node, const CssCompiledGridTempla
7414
7540
  count = static_cast<std::int8_t>(trackCount);
7415
7541
  target.render.dirty = 1;
7416
7542
  target.render.layout_dirty = 1;
7543
+ #if GEA_CSS_SCROLLING
7417
7544
  target.render.non_scroll_dirty = 1;
7545
+ #endif
7418
7546
  markDisplayListDirtyForStyleApply();
7547
+ #endif
7419
7548
  }
7420
7549
 
7421
7550
  int g_resolvedFontNode = -1;
@@ -7442,139 +7571,374 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7442
7571
  &target == &treeState().nodes[g_resolvedFontNode]) return true;
7443
7572
  if (g_resolvedLineHeightNode >= 0 && isLineHeightProperty(property) &&
7444
7573
  &target == &treeState().nodes[g_resolvedLineHeightNode]) return true;
7445
- ComputedStyle &style = target.style;
7574
+ ComputedStyle &style = target.mutableStyle();
7446
7575
  switch (property) {
7447
7576
  case Property::Display:
7577
+ #if GEA_CSS_DISPLAY_EXPLICIT
7448
7578
  style.display_explicit = 1;
7579
+ #endif
7449
7580
  style.display = value;
7450
7581
  return true;
7582
+ #if GEA_CSS_FLEX_DIRECTION
7451
7583
  case Property::FlexDirection:
7452
7584
  style.flex_direction_explicit = 1;
7453
7585
  style.flex_direction = value;
7454
7586
  return true;
7587
+ #endif
7588
+ #if GEA_CSS_FLEX_WRAP
7455
7589
  case Property::FlexWrap: style.flex_wrap = value; return true;
7590
+ #endif
7591
+ #if GEA_CSS_FLEX_LINE_COUNT
7456
7592
  case Property::FlexLineCount: rstyleMut(style).flex_line_count = value; return true;
7593
+ #endif
7594
+ #if GEA_CSS_BACKGROUND_LAYERS
7457
7595
  case Property::BackgroundClip: rstyleMut(style).bg_clip = value; return true;
7458
7596
  case Property::BackgroundSizeList: rstyleMut(style).bg_size_list = value; return true;
7459
7597
  case Property::BackgroundPositionList: rstyleMut(style).bg_position_list = value; return true;
7460
7598
  case Property::BackgroundRepeatList: rstyleMut(style).bg_repeat_list = value; return true;
7461
7599
  case Property::BackgroundAttachmentList: rstyleMut(style).bg_attachment_list = value; return true;
7462
7600
  case Property::BackgroundOriginList: rstyleMut(style).bg_origin_list = value; return true;
7601
+ #endif
7463
7602
 
7603
+ #if GEA_CSS_CONTAINMENT
7464
7604
  case Property::Containment: rstyleMut(style).containment = value; return true;
7605
+ #endif
7606
+ #if GEA_CSS_JUSTIFY_CONTENT
7465
7607
  case Property::JustifyContent: style.justify_content = value; return true;
7608
+ #endif
7609
+ #if GEA_CSS_ALIGN_ITEMS
7466
7610
  case Property::AlignItems: style.align_items = value; return true;
7611
+ #endif
7612
+ #if GEA_CSS_JUSTIFY_ITEMS
7467
7613
  case Property::JustifyItems: style.justify_items = value; return true;
7614
+ #endif
7615
+ #if GEA_CSS_ALIGN_CONTENT
7468
7616
  case Property::AlignContent: style.align_content = value; return true;
7617
+ #endif
7618
+ #if GEA_CSS_ALIGN_SELF
7469
7619
  case Property::AlignSelf: style.align_self = value; return true;
7620
+ #endif
7621
+ #if GEA_CSS_JUSTIFY_SELF
7470
7622
  case Property::JustifySelf: rstyleMut(style).justify_self = value; return true;
7623
+ #endif
7624
+ #if GEA_CSS_GRID
7471
7625
  case Property::GridRowStart: rstyleMut(style).grid_line[0] = value; return true;
7472
7626
  case Property::GridColumnStart: rstyleMut(style).grid_line[1] = value; return true;
7473
7627
  case Property::GridRowEnd: rstyleMut(style).grid_line[2] = value; return true;
7474
7628
  case Property::GridColumnEnd: rstyleMut(style).grid_line[3] = value; return true;
7629
+ #endif
7630
+ #if GEA_CSS_BOX_SIZING
7475
7631
  case Property::BoxSizing: style.box_sizing = value; return true;
7632
+ #endif
7633
+ #if GEA_CSS_FLOATS
7476
7634
  case Property::Float: style.float_side = value; return true;
7635
+ #endif
7636
+ #if GEA_CSS_ASPECT_RATIO
7477
7637
  case Property::AspectRatio: rstyleMut(style).aspect_ratio = value; return true;
7638
+ #endif
7639
+ #if GEA_CSS_MARGIN_TRIM
7478
7640
  case Property::MarginTrim: rstyleMut(style).margin_trim = value; return true;
7641
+ #endif
7642
+ #if GEA_CSS_FLOATS
7479
7643
  case Property::Clear: style.clear_side = value; return true;
7644
+ #endif
7645
+ #if GEA_CSS_WRITING_MODE
7480
7646
  case Property::WritingMode: style.writing_mode = value; return true;
7481
7647
  case Property::Direction: style.direction = value; return true;
7648
+ #endif
7649
+ #if GEA_CSS_AXIS_GAP
7482
7650
  case Property::RowGap: style.row_gap = value; return true;
7651
+ #endif
7652
+ #if GEA_CSS_AXIS_GAP
7483
7653
  case Property::ColumnGap: style.column_gap = value; return true;
7654
+ #endif
7655
+ #if GEA_CSS_PERCENT_GAP
7484
7656
  case Property::RowGapPercent: style.row_gap_percent = value; return true;
7485
7657
  case Property::ColumnGapPercent: style.column_gap_percent = value; return true;
7658
+ #endif
7659
+ #if GEA_CSS_MARGIN_AUTO
7486
7660
  case Property::MarginTopAuto: style.margin_auto = (style.margin_auto & ~1) | (value ? 1 : 0); return true;
7661
+ #endif
7662
+ #if GEA_CSS_MARGIN_AUTO
7487
7663
  case Property::MarginRightAuto: style.margin_auto = (style.margin_auto & ~2) | (value ? 2 : 0); return true;
7664
+ #endif
7665
+ #if GEA_CSS_MARGIN_AUTO
7488
7666
  case Property::MarginBottomAuto: style.margin_auto = (style.margin_auto & ~4) | (value ? 4 : 0); return true;
7667
+ #endif
7668
+ #if GEA_CSS_MARGIN_AUTO
7489
7669
  case Property::MarginLeftAuto: style.margin_auto = (style.margin_auto & ~8) | (value ? 8 : 0); return true;
7670
+ #endif
7671
+ #if GEA_CSS_BOX_EXPRESSIONS
7490
7672
  case Property::MarginTopExpression: rstyleMut(style).margin_expression[0] = value; return true;
7673
+ #endif
7674
+ #if GEA_CSS_BOX_EXPRESSIONS
7491
7675
  case Property::MarginRightExpression: rstyleMut(style).margin_expression[1] = value; return true;
7676
+ #endif
7677
+ #if GEA_CSS_BOX_EXPRESSIONS
7492
7678
  case Property::MarginBottomExpression: rstyleMut(style).margin_expression[2] = value; return true;
7679
+ #endif
7680
+ #if GEA_CSS_BOX_EXPRESSIONS
7493
7681
  case Property::MarginLeftExpression: rstyleMut(style).margin_expression[3] = value; return true;
7682
+ #endif
7683
+ #if GEA_CSS_BOX_EXPRESSIONS
7494
7684
  case Property::PaddingTopExpression: rstyleMut(style).padding_expression[0] = value; return true;
7685
+ #endif
7686
+ #if GEA_CSS_BOX_EXPRESSIONS
7495
7687
  case Property::PaddingRightExpression: rstyleMut(style).padding_expression[1] = value; return true;
7688
+ #endif
7689
+ #if GEA_CSS_BOX_EXPRESSIONS
7496
7690
  case Property::PaddingBottomExpression: rstyleMut(style).padding_expression[2] = value; return true;
7691
+ #endif
7692
+ #if GEA_CSS_BOX_EXPRESSIONS
7497
7693
  case Property::PaddingLeftExpression: rstyleMut(style).padding_expression[3] = value; return true;
7498
- case Property::WidthExpression: style.width_expression = value; style.width = style.width_percent = kUnset; return true;
7499
- case Property::HeightExpression: style.height_expression = value; style.height = style.height_percent = kUnset; return true;
7694
+ #endif
7695
+ #if GEA_CSS_WIDTH_EXPRESSIONS
7696
+ case Property::WidthExpression:
7697
+ style.width_expression = value;
7698
+ style.width = kUnset;
7699
+ #if GEA_CSS_WIDTH_PERCENT
7700
+ style.width_percent = kUnset;
7701
+ #endif
7702
+ return true;
7703
+ #endif
7704
+ #if GEA_CSS_HEIGHT_EXPRESSIONS
7705
+ case Property::HeightExpression:
7706
+ style.height_expression = value;
7707
+ style.height = kUnset;
7708
+ #if GEA_CSS_HEIGHT_PERCENT
7709
+ style.height_percent = kUnset;
7710
+ #endif
7711
+ return true;
7712
+ #endif
7713
+ #if GEA_CSS_ORDER
7500
7714
  case Property::Order: style.order = value; return true;
7501
- case Property::Gap: style.gap = value; style.row_gap = style.column_gap = style.row_gap_percent = style.column_gap_percent = kUnset; return true;
7715
+ #endif
7716
+ #if GEA_CSS_GAP
7717
+ case Property::Gap:
7718
+ style.gap = value;
7719
+ #if GEA_CSS_AXIS_GAP
7720
+ style.row_gap = style.column_gap = kUnset;
7721
+ #endif
7722
+ #if GEA_CSS_PERCENT_GAP
7723
+ style.row_gap_percent = style.column_gap_percent = kUnset;
7724
+ #endif
7725
+ return true;
7726
+ #endif
7502
7727
  case Property::Width:
7728
+ #if GEA_CSS_WIDTH_EXPRESSIONS
7503
7729
  style.width_expression = -1;
7730
+ #endif
7504
7731
  style.width = value;
7732
+ #if GEA_CSS_WIDTH_PERCENT
7505
7733
  style.width_percent = kUnset;
7734
+ #endif
7506
7735
  return true;
7507
7736
  case Property::Height:
7737
+ #if GEA_CSS_HEIGHT_EXPRESSIONS
7508
7738
  style.height_expression = -1;
7739
+ #endif
7509
7740
  style.height = value;
7741
+ #if GEA_CSS_HEIGHT_PERCENT
7510
7742
  style.height_percent = kUnset;
7743
+ #endif
7511
7744
  return true;
7512
7745
  case Property::WidthPercent:
7746
+ #if GEA_CSS_WIDTH_EXPRESSIONS
7513
7747
  style.width_expression = -1;
7748
+ #endif
7749
+ #if GEA_CSS_WIDTH_PERCENT
7514
7750
  style.width_percent = value;
7751
+ #endif
7515
7752
  style.width = kUnset;
7516
7753
  return true;
7517
7754
  case Property::HeightPercent:
7755
+ #if GEA_CSS_HEIGHT_EXPRESSIONS
7518
7756
  style.height_expression = -1;
7757
+ #endif
7758
+ #if GEA_CSS_HEIGHT_PERCENT
7519
7759
  style.height_percent = value;
7760
+ #endif
7520
7761
  style.height = kUnset;
7521
7762
  return true;
7763
+ #if GEA_CSS_MIN_WIDTH
7522
7764
  case Property::MinWidth: style.min_width = value; return true;
7765
+ #endif
7766
+ #if GEA_CSS_MIN_HEIGHT
7523
7767
  case Property::MinHeight: style.min_height = value; return true;
7768
+ #endif
7769
+ #if GEA_CSS_MAX_WIDTH
7524
7770
  case Property::MaxWidth: style.max_width = value; return true;
7771
+ #endif
7772
+ #if GEA_CSS_MAX_HEIGHT
7525
7773
  case Property::MaxHeight: style.max_height = value; return true;
7774
+ #endif
7775
+ #if GEA_CSS_FLEX_FACTORS
7526
7776
  case Property::Flex: style.flex = value; return true;
7527
7777
  case Property::FlexShrink: style.flex_shrink = value; return true;
7778
+ #endif
7528
7779
  case Property::FlexBasis:
7780
+ #if GEA_CSS_FLEX_BASIS_EXPRESSIONS
7529
7781
  if (rstyle(style).flex_basis_expression >= 0) rstyleMut(style).flex_basis_expression = -1;
7530
- style.flex_basis = value; return true;
7782
+ #endif
7783
+ #if GEA_CSS_FLEX_BASIS
7784
+ style.flex_basis = value;
7785
+ #endif
7786
+ return true;
7787
+ #if GEA_CSS_FLEX_BASIS_EXPRESSIONS
7531
7788
  case Property::FlexBasisExpression:
7532
- rstyleMut(style).flex_basis_expression = value; style.flex_basis = kUnset; return true;
7533
- case Property::PaddingTop: if (rstyle(style).padding_expression[0] >= 0) rstyleMut(style).padding_expression[0] = -1; style.padding[0] = value; return true;
7534
- case Property::PaddingRight: if (rstyle(style).padding_expression[1] >= 0) rstyleMut(style).padding_expression[1] = -1; style.padding[1] = value; return true;
7535
- case Property::PaddingBottom: if (rstyle(style).padding_expression[2] >= 0) rstyleMut(style).padding_expression[2] = -1; style.padding[2] = value; return true;
7536
- case Property::PaddingLeft: if (rstyle(style).padding_expression[3] >= 0) rstyleMut(style).padding_expression[3] = -1; style.padding[3] = value; return true;
7537
- case Property::MarginTop: if (rstyle(style).margin_expression[0] >= 0) rstyleMut(style).margin_expression[0] = -1; style.margin_auto &= ~1; style.margin[0] = value; return true;
7538
- case Property::MarginRight: if (rstyle(style).margin_expression[1] >= 0) rstyleMut(style).margin_expression[1] = -1; style.margin_auto &= ~2; style.margin[1] = value; return true;
7539
- case Property::MarginBottom: if (rstyle(style).margin_expression[2] >= 0) rstyleMut(style).margin_expression[2] = -1; style.margin_auto &= ~4; style.margin[2] = value; return true;
7540
- case Property::MarginLeft: if (rstyle(style).margin_expression[3] >= 0) rstyleMut(style).margin_expression[3] = -1; style.margin_auto &= ~8; style.margin[3] = value; return true;
7789
+ rstyleMut(style).flex_basis_expression = value;
7790
+ #if GEA_CSS_FLEX_BASIS
7791
+ style.flex_basis = kUnset;
7792
+ #endif
7793
+ return true;
7794
+ #endif
7795
+ #if GEA_CSS_PADDING
7796
+ case Property::PaddingTop:
7797
+ #if GEA_CSS_BOX_EXPRESSIONS
7798
+ if (rstyle(style).padding_expression[0] >= 0) rstyleMut(style).padding_expression[0] = -1;
7799
+ #endif
7800
+ style.padding[0] = value; return true;
7801
+ case Property::PaddingRight:
7802
+ #if GEA_CSS_BOX_EXPRESSIONS
7803
+ if (rstyle(style).padding_expression[1] >= 0) rstyleMut(style).padding_expression[1] = -1;
7804
+ #endif
7805
+ style.padding[1] = value; return true;
7806
+ case Property::PaddingBottom:
7807
+ #if GEA_CSS_BOX_EXPRESSIONS
7808
+ if (rstyle(style).padding_expression[2] >= 0) rstyleMut(style).padding_expression[2] = -1;
7809
+ #endif
7810
+ style.padding[2] = value; return true;
7811
+ case Property::PaddingLeft:
7812
+ #if GEA_CSS_BOX_EXPRESSIONS
7813
+ if (rstyle(style).padding_expression[3] >= 0) rstyleMut(style).padding_expression[3] = -1;
7814
+ #endif
7815
+ style.padding[3] = value; return true;
7816
+ #endif
7817
+ #if GEA_CSS_MARGINS
7818
+ case Property::MarginTop:
7819
+ #if GEA_CSS_BOX_EXPRESSIONS
7820
+ if (rstyle(style).margin_expression[0] >= 0) rstyleMut(style).margin_expression[0] = -1;
7821
+ #endif
7822
+
7823
+ #if GEA_CSS_MARGIN_AUTO
7824
+ style.margin_auto &= ~1;
7825
+ #endif
7826
+ style.margin[0] = value; return true;
7827
+ case Property::MarginRight:
7828
+ #if GEA_CSS_BOX_EXPRESSIONS
7829
+ if (rstyle(style).margin_expression[1] >= 0) rstyleMut(style).margin_expression[1] = -1;
7830
+ #endif
7831
+
7832
+ #if GEA_CSS_MARGIN_AUTO
7833
+ style.margin_auto &= ~2;
7834
+ #endif
7835
+ style.margin[1] = value; return true;
7836
+ case Property::MarginBottom:
7837
+ #if GEA_CSS_BOX_EXPRESSIONS
7838
+ if (rstyle(style).margin_expression[2] >= 0) rstyleMut(style).margin_expression[2] = -1;
7839
+ #endif
7840
+
7841
+ #if GEA_CSS_MARGIN_AUTO
7842
+ style.margin_auto &= ~4;
7843
+ #endif
7844
+ style.margin[2] = value; return true;
7845
+ case Property::MarginLeft:
7846
+ #if GEA_CSS_BOX_EXPRESSIONS
7847
+ if (rstyle(style).margin_expression[3] >= 0) rstyleMut(style).margin_expression[3] = -1;
7848
+ #endif
7849
+
7850
+ #if GEA_CSS_MARGIN_AUTO
7851
+ style.margin_auto &= ~8;
7852
+ #endif
7853
+ style.margin[3] = value; return true;
7854
+ #endif
7541
7855
  case Property::Position: if (value == kPositionFixed) treeState().fixedPositionUsed = true; style.position = value; return true;
7542
7856
  case Property::Top:
7543
- style.pos_offsets[0] = value;
7544
- style.pos_offset_percent[0] = kUnset;
7857
+ #if GEA_CSS_POSITION_TOP
7858
+ GEA_CSS_POSITION_PX_0(style) = value;
7859
+ #if GEA_CSS_POSITION_TOP_PERCENT
7860
+ GEA_CSS_POSITION_PERCENT_0(style) = kUnset;
7861
+ #endif
7545
7862
  return true;
7863
+ #else
7864
+ return false;
7865
+ #endif
7546
7866
  case Property::Right:
7547
- style.pos_offsets[1] = value;
7548
- style.pos_offset_percent[1] = kUnset;
7867
+ #if GEA_CSS_POSITION_RIGHT
7868
+ GEA_CSS_POSITION_PX_1(style) = value;
7869
+ #if GEA_CSS_POSITION_RIGHT_PERCENT
7870
+ GEA_CSS_POSITION_PERCENT_1(style) = kUnset;
7871
+ #endif
7549
7872
  return true;
7873
+ #else
7874
+ return false;
7875
+ #endif
7550
7876
  case Property::Bottom:
7551
- style.pos_offsets[2] = value;
7552
- style.pos_offset_percent[2] = kUnset;
7877
+ #if GEA_CSS_POSITION_BOTTOM
7878
+ GEA_CSS_POSITION_PX_2(style) = value;
7879
+ #if GEA_CSS_POSITION_BOTTOM_PERCENT
7880
+ GEA_CSS_POSITION_PERCENT_2(style) = kUnset;
7881
+ #endif
7553
7882
  return true;
7883
+ #else
7884
+ return false;
7885
+ #endif
7554
7886
  case Property::Left:
7555
- style.pos_offsets[3] = value;
7556
- style.pos_offset_percent[3] = kUnset;
7887
+ #if GEA_CSS_POSITION_LEFT
7888
+ GEA_CSS_POSITION_PX_3(style) = value;
7889
+ #if GEA_CSS_POSITION_LEFT_PERCENT
7890
+ GEA_CSS_POSITION_PERCENT_3(style) = kUnset;
7891
+ #endif
7557
7892
  return true;
7893
+ #else
7894
+ return false;
7895
+ #endif
7558
7896
  case Property::TopPercent:
7559
- style.pos_offset_percent[0] = value;
7560
- style.pos_offsets[0] = kUnset;
7897
+ #if GEA_CSS_POSITION_TOP_PERCENT
7898
+ GEA_CSS_POSITION_PERCENT_0(style) = value;
7899
+ #if GEA_CSS_POSITION_TOP
7900
+ GEA_CSS_POSITION_PX_0(style) = kUnset;
7901
+ #endif
7561
7902
  return true;
7903
+ #else
7904
+ return false;
7905
+ #endif
7562
7906
  case Property::RightPercent:
7563
- style.pos_offset_percent[1] = value;
7564
- style.pos_offsets[1] = kUnset;
7907
+ #if GEA_CSS_POSITION_RIGHT_PERCENT
7908
+ GEA_CSS_POSITION_PERCENT_1(style) = value;
7909
+ #if GEA_CSS_POSITION_RIGHT
7910
+ GEA_CSS_POSITION_PX_1(style) = kUnset;
7911
+ #endif
7565
7912
  return true;
7913
+ #else
7914
+ return false;
7915
+ #endif
7566
7916
  case Property::BottomPercent:
7567
- style.pos_offset_percent[2] = value;
7568
- style.pos_offsets[2] = kUnset;
7917
+ #if GEA_CSS_POSITION_BOTTOM_PERCENT
7918
+ GEA_CSS_POSITION_PERCENT_2(style) = value;
7919
+ #if GEA_CSS_POSITION_BOTTOM
7920
+ GEA_CSS_POSITION_PX_2(style) = kUnset;
7921
+ #endif
7569
7922
  return true;
7923
+ #else
7924
+ return false;
7925
+ #endif
7570
7926
  case Property::LeftPercent:
7571
- style.pos_offset_percent[3] = value;
7572
- style.pos_offsets[3] = kUnset;
7927
+ #if GEA_CSS_POSITION_LEFT_PERCENT
7928
+ GEA_CSS_POSITION_PERCENT_3(style) = value;
7929
+ #if GEA_CSS_POSITION_LEFT
7930
+ GEA_CSS_POSITION_PX_3(style) = kUnset;
7931
+ #endif
7573
7932
  return true;
7933
+ #else
7934
+ return false;
7935
+ #endif
7936
+ #if GEA_CSS_Z_INDEX
7574
7937
  case Property::ZIndex:
7575
7938
  style.z_index_auto = value == kZIndexAuto;
7576
7939
  style.z_index = style.z_index_auto ? 0 : std::clamp(value, -32768, 32767);
7577
7940
  return true;
7941
+ #endif
7578
7942
  case Property::BackgroundColor: {
7579
7943
  style.bg_color = StyleValues::pixelFromStyleValue(value);
7580
7944
  style.bg_alpha = 255;
@@ -7585,39 +7949,64 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7585
7949
  StyleValues::applyBackgroundImage(style, value, static_cast<int>(&target - treeState().nodes));
7586
7950
  return true;
7587
7951
  case Property::HasBackground: style.has_bg = value; return true;
7952
+ #if GEA_CSS_ACTIVE_BACKGROUND
7588
7953
  case Property::ActiveBackgroundColor:
7589
7954
  style.active_bg_color = StyleValues::pixelFromStyleValue(value);
7590
7955
  return true;
7956
+ #endif
7957
+ #if GEA_CSS_ACTIVE_BACKGROUND
7591
7958
  case Property::HasActiveBackground: style.has_active_bg = value; return true;
7959
+ #endif
7592
7960
  case Property::Color:
7593
7961
  style.text_color = StyleValues::pixelFromStyleValue(value);
7962
+ #if GEA_CSS_TEXT_ALPHA
7594
7963
  style.text_alpha = 255;
7964
+ #endif
7595
7965
  return true;
7966
+ #if GEA_CSS_OPACITY
7596
7967
  case Property::Opacity:
7597
7968
  style.opacity = static_cast<std::uint8_t>(value < 0 ? 0 : value > 255 ? 255 : value);
7598
7969
  return true;
7599
- case Property::ColorAlpha: style.text_alpha = static_cast<std::uint8_t>(std::clamp(value, 0, 255)); return true;
7600
- case Property::BorderAlpha: style.border_alpha = static_cast<std::uint8_t>(std::clamp(value, 0, 255)); return true;
7970
+ #endif
7971
+ case Property::ColorAlpha:
7972
+ #if GEA_CSS_TEXT_ALPHA
7973
+ style.text_alpha = static_cast<std::uint8_t>(std::clamp(value, 0, 255));
7974
+ #endif
7975
+ return true;
7976
+ case Property::BorderAlpha:
7977
+ #if GEA_CSS_BORDER_ALPHA
7978
+ style.border_alpha = static_cast<std::uint8_t>(std::clamp(value, 0, 255));
7979
+ #endif
7980
+ return true;
7981
+ #if GEA_CSS_SIDE_BORDERS
7601
7982
  case Property::BorderTopAlpha:
7602
7983
  case Property::BorderRightAlpha:
7603
7984
  case Property::BorderBottomAlpha:
7604
7985
  case Property::BorderLeftAlpha:
7605
7986
  rstyleMut(style).border_side_alpha[static_cast<int>(property) - static_cast<int>(Property::BorderTopAlpha)] = static_cast<std::uint8_t>(std::clamp(value, 0, 255));
7606
7987
  return true;
7988
+ #endif
7607
7989
  case Property::BorderColorCurrent: setBorderColorBinding(style, -1, value != 0); return true;
7990
+ #if GEA_CSS_SIDE_BORDERS
7608
7991
  case Property::BorderTopColorCurrent:
7609
7992
  case Property::BorderRightColorCurrent:
7610
7993
  case Property::BorderBottomColorCurrent:
7611
7994
  case Property::BorderLeftColorCurrent:
7612
7995
  setBorderColorBinding(style, static_cast<int>(property) - static_cast<int>(Property::BorderTopColorCurrent), value != 0);
7613
7996
  return true;
7997
+ #endif
7614
7998
  case Property::BorderWidth:
7615
- setComputedBorderWidth(style, -1, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
7999
+ setComputedBorderWidth(style, -1, value, target.parent >= 0 ? &treeState().nodes[target.parent].computedStyle() : nullptr); return true;
8000
+ #if GEA_CSS_BORDER_COLORS
7616
8001
  case Property::BorderColor:
7617
8002
  setBorderColorBinding(style, -1, false);
7618
8003
  style.border_color = StyleValues::pixelFromStyleValue(value);
8004
+ #if GEA_CSS_BORDER_ALPHA
7619
8005
  style.border_alpha = 255;
8006
+ #endif
7620
8007
  return true;
8008
+ #endif
8009
+ #if GEA_CSS_BORDER_RELIEF
7621
8010
  case Property::BorderTopRelief:
7622
8011
  case Property::BorderRightRelief:
7623
8012
  case Property::BorderBottomRelief:
@@ -7630,10 +8019,12 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7630
8019
  if (value == 0 && !hasBorderRelief(style)) return true;
7631
8020
  for (int side = 0; side < 4; ++side) rstyleMut(style).border_relief[side] = static_cast<uint8_t>(value);
7632
8021
  return true;
7633
- case Property::BorderTopWidth: setComputedBorderWidth(style, 0, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
7634
- case Property::BorderRightWidth: setComputedBorderWidth(style, 1, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
7635
- case Property::BorderBottomWidth: setComputedBorderWidth(style, 2, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
7636
- case Property::BorderLeftWidth: setComputedBorderWidth(style, 3, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
8022
+ #endif
8023
+ #if GEA_CSS_SIDE_BORDERS
8024
+ case Property::BorderTopWidth: setComputedBorderWidth(style, 0, value, target.parent >= 0 ? &treeState().nodes[target.parent].computedStyle() : nullptr); return true;
8025
+ case Property::BorderRightWidth: setComputedBorderWidth(style, 1, value, target.parent >= 0 ? &treeState().nodes[target.parent].computedStyle() : nullptr); return true;
8026
+ case Property::BorderBottomWidth: setComputedBorderWidth(style, 2, value, target.parent >= 0 ? &treeState().nodes[target.parent].computedStyle() : nullptr); return true;
8027
+ case Property::BorderLeftWidth: setComputedBorderWidth(style, 3, value, target.parent >= 0 ? &treeState().nodes[target.parent].computedStyle() : nullptr); return true;
7637
8028
  case Property::BorderTopColor:
7638
8029
  setBorderColorBinding(style, 0, false);
7639
8030
  rstyleMut(style).border_side_color[0] = StyleValues::pixelFromStyleValue(value);
@@ -7654,62 +8045,108 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7654
8045
  rstyleMut(style).border_side_color[3] = StyleValues::pixelFromStyleValue(value);
7655
8046
  rstyleMut(style).border_side_alpha[3] = 255;
7656
8047
  return true;
8048
+ #endif
7657
8049
  case Property::BorderRadiusTopLeft:
7658
- style.border_radius[0] = value;
7659
- style.border_radius_percent[0] = kUnset;
8050
+ style.border_radius[GEA_CSS_RADIUS_INDEX(0)] = value;
8051
+ #if GEA_CSS_PERCENT_RADIUS
8052
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] = kUnset;
8053
+ #endif
7660
8054
  return true;
7661
8055
  case Property::BorderRadiusTopRight:
7662
- style.border_radius[1] = value;
7663
- style.border_radius_percent[1] = kUnset;
8056
+ style.border_radius[GEA_CSS_RADIUS_INDEX(1)] = value;
8057
+ #if GEA_CSS_PERCENT_RADIUS
8058
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] = kUnset;
8059
+ #endif
7664
8060
  return true;
7665
8061
  case Property::BorderRadiusBottomRight:
7666
- style.border_radius[2] = value;
7667
- style.border_radius_percent[2] = kUnset;
8062
+ style.border_radius[GEA_CSS_RADIUS_INDEX(2)] = value;
8063
+ #if GEA_CSS_PERCENT_RADIUS
8064
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] = kUnset;
8065
+ #endif
7668
8066
  return true;
7669
8067
  case Property::BorderRadiusBottomLeft:
7670
- style.border_radius[3] = value;
7671
- style.border_radius_percent[3] = kUnset;
8068
+ style.border_radius[GEA_CSS_RADIUS_INDEX(3)] = value;
8069
+ #if GEA_CSS_PERCENT_RADIUS
8070
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] = kUnset;
8071
+ #endif
7672
8072
  return true;
8073
+ #if GEA_CSS_PERCENT_RADIUS
7673
8074
  case Property::BorderRadiusTopLeftPercent:
7674
- style.border_radius_percent[0] = value;
7675
- style.border_radius[0] = 0;
8075
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] = value;
8076
+ style.border_radius[GEA_CSS_RADIUS_INDEX(0)] = 0;
7676
8077
  return true;
7677
8078
  case Property::BorderRadiusTopRightPercent:
7678
- style.border_radius_percent[1] = value;
7679
- style.border_radius[1] = 0;
8079
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] = value;
8080
+ style.border_radius[GEA_CSS_RADIUS_INDEX(1)] = 0;
7680
8081
  return true;
7681
8082
  case Property::BorderRadiusBottomRightPercent:
7682
- style.border_radius_percent[2] = value;
7683
- style.border_radius[2] = 0;
8083
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] = value;
8084
+ style.border_radius[GEA_CSS_RADIUS_INDEX(2)] = 0;
7684
8085
  return true;
7685
8086
  case Property::BorderRadiusBottomLeftPercent:
7686
- style.border_radius_percent[3] = value;
7687
- style.border_radius[3] = 0;
8087
+ style.border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] = value;
8088
+ style.border_radius[GEA_CSS_RADIUS_INDEX(3)] = 0;
7688
8089
  return true;
8090
+ #endif
7689
8091
  case Property::FontId: style.font_id = value; return true;
7690
8092
  case Property::FontSize: style.font_size = value; return true;
8093
+ #if GEA_CSS_FONT_WEIGHT
7691
8094
  case Property::FontWeight: style.font_weight = value; return true;
8095
+ #endif
8096
+ #if GEA_CSS_LINE_HEIGHT
7692
8097
  case Property::LineHeight:
8098
+ #if GEA_CSS_LINE_HEIGHT_MULTIPLIER
7693
8099
  if (style.line_height_multiplier >= 0) style.line_height_multiplier = -1;
8100
+ #endif
8101
+ #if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
7694
8102
  if (rstyle(style).line_height_expression >= 0) rstyleMut(style).line_height_expression = -1;
8103
+ #endif
7695
8104
  style.line_height = value; return true;
8105
+ #if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
7696
8106
  case Property::LineHeightExpression:
8107
+ #if GEA_CSS_LINE_HEIGHT_MULTIPLIER
7697
8108
  if (style.line_height_multiplier >= 0) style.line_height_multiplier = -1;
8109
+ #endif
7698
8110
  rstyleMut(style).line_height_expression = value;
7699
8111
  style.line_height = resolveLineHeightExpression(static_cast<int>(&target - treeState().nodes), value); return true;
8112
+ #endif
8113
+ #if GEA_CSS_LINE_HEIGHT_MULTIPLIER
7700
8114
  case Property::LineHeightMultiplier:
7701
8115
  style.line_height_multiplier = value;
8116
+ #if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
7702
8117
  if (rstyle(style).line_height_expression >= 0) rstyleMut(style).line_height_expression = -1;
8118
+ #endif
7703
8119
  style.line_height = resolveLineHeightMultiplier(static_cast<int>(&target - treeState().nodes), value); return true;
8120
+ #endif
8121
+ #endif
8122
+ #if GEA_CSS_TEXT_ALIGN
7704
8123
  case Property::TextAlign: style.text_align = value; return true;
8124
+ #endif
8125
+ #if GEA_CSS_TEXT_DECORATION
7705
8126
  case Property::TextDecoration: style.text_decoration = value; return true;
8127
+ #endif
8128
+ #if GEA_CSS_TEXT_TRANSFORM
7706
8129
  case Property::TextTransform: style.text_transform = value; return true;
8130
+ #endif
8131
+ #if GEA_CSS_WHITE_SPACE
7707
8132
  case Property::WhiteSpace: style.white_space = static_cast<std::int8_t>(value); return true;
8133
+ #endif
8134
+ #if GEA_CSS_TEXT_OVERFLOW
7708
8135
  case Property::TextOverflow: style.text_overflow = static_cast<std::int8_t>(value); return true;
8136
+ #endif
8137
+ #if GEA_CSS_TRANSFORMS
7709
8138
  case Property::TransformStyle: rstyleMut(style).transform_preserve_3d = value != 0; return true;
8139
+ #endif
8140
+ #if GEA_CSS_VISIBILITY
7710
8141
  case Property::Visibility: style.visibility = static_cast<std::int8_t>(value); return true;
8142
+ #endif
8143
+ #if GEA_CSS_TRANSFORMS
7711
8144
  case Property::Backface: style.backface_hidden = static_cast<std::int8_t>(value); return true;
8145
+ #endif
8146
+ #if GEA_CSS_POINTER_EVENTS
7712
8147
  case Property::PointerEvents: style.pointer_events = static_cast<std::int8_t>(value); return true;
8148
+ #endif
8149
+ #if GEA_CSS_OVERFLOW_AXES
7713
8150
  case Property::Overflow: {
7714
8151
  const auto next = static_cast<std::int8_t>(value);
7715
8152
  style.overflow = next;
@@ -7729,11 +8166,24 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7729
8166
  style.overflow = aggregateOverflow(style.overflow_x, next);
7730
8167
  return true;
7731
8168
  }
8169
+ #else
8170
+ case Property::Overflow:
8171
+ case Property::OverflowX:
8172
+ case Property::OverflowY:
8173
+ style.overflow = static_cast<std::int8_t>(value); return true;
8174
+ #endif
8175
+ #if GEA_CSS_MASK
7732
8176
  case Property::MaskRightFadeWidth:
7733
8177
  style.mask_right_fade_width = static_cast<std::int16_t>(value < 0 ? 0 : value > 32767 ? 32767 : value);
7734
8178
  return true;
8179
+ #endif
8180
+ #if GEA_UI_IMAGE_NODES
7735
8181
  case Property::ImageId: target.image_id = value; return true;
8182
+ #endif
8183
+ #if GEA_CSS_IMAGE_FIT
7736
8184
  case Property::ImageFit: style.image_fit = value; return true;
8185
+ #endif
8186
+ #if GEA_CSS_TRANSFORMS
7737
8187
  case Property::TransformTranslateOuterAxes: rstyleMut(style).transform_translate_outer_axes = value; return true;
7738
8188
  case Property::RotateAngle: rstyleMut(style).rotate_angle = value; return true;
7739
8189
  case Property::RotateAxisX: rstyleMut(style).rotate_axis_x = value; return true;
@@ -7751,7 +8201,11 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7751
8201
  case Property::TransformPresent: rstyleMut(style).transform_present = value != 0; return true;
7752
8202
  case Property::RotatePresent: rstyleMut(style).rotate_present = value != 0; return true;
7753
8203
  case Property::ScalePresent: rstyleMut(style).scale_present = value != 0; return true;
8204
+ #endif
8205
+ #if GEA_CSS_FILTERS
7754
8206
  case Property::FilterPresent: rstyleMut(style).filter_present = value != 0; return true;
8207
+ #endif
8208
+ #if GEA_CSS_TRANSFORMS
7755
8209
  case Property::TransformRotate: rstyleMut(style).transform_rotate = value; return true;
7756
8210
  case Property::TransformRotateX: rstyleMut(style).transform_rotate_x = value; return true;
7757
8211
  case Property::TransformRotateY: rstyleMut(style).transform_rotate_y = value; return true;
@@ -7768,20 +8222,37 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
7768
8222
  case Property::Perspective: rstyleMut(style).perspective = value; return true;
7769
8223
  case Property::PerspectiveOriginX: rstyleMut(style).perspective_origin_x = value; return true;
7770
8224
  case Property::PerspectiveOriginY: rstyleMut(style).perspective_origin_y = value; return true;
8225
+ #endif
8226
+ #if GEA_CSS_FILTERS
7771
8227
  case Property::FilterBlur: rstyleMut(style).filter_blur_radius = value; return true;
8228
+ #endif
8229
+ #if GEA_CSS_BOX_SHADOW
7772
8230
  case Property::BoxShadowInset:
7773
8231
  rstyleMut(style).box_shadow_inset = value != 0 ? 1 : 0;
7774
8232
  return true;
8233
+ #endif
8234
+ #if GEA_CSS_BOX_SHADOW
7775
8235
  case Property::BoxShadowOffsetX: rstyleMut(style).box_shadow_offset_x = value; return true;
8236
+ #endif
8237
+ #if GEA_CSS_BOX_SHADOW
7776
8238
  case Property::BoxShadowOffsetY: rstyleMut(style).box_shadow_offset_y = value; return true;
8239
+ #endif
8240
+ #if GEA_CSS_BOX_SHADOW
7777
8241
  case Property::BoxShadowBlur: rstyleMut(style).box_shadow_blur_radius = value; return true;
8242
+ #endif
8243
+ #if GEA_CSS_BOX_SHADOW
7778
8244
  case Property::BoxShadowSpread: rstyleMut(style).box_shadow_spread = value; return true;
8245
+ #endif
8246
+ #if GEA_CSS_BOX_SHADOW
7779
8247
  case Property::BoxShadowColor:
7780
8248
  rstyleMut(style).box_shadow_color = StyleValues::pixelFromStyleValue(value);
7781
8249
  return true;
8250
+ #endif
8251
+ #if GEA_CSS_BOX_SHADOW
7782
8252
  case Property::BoxShadowAlpha:
7783
8253
  rstyleMut(style).box_shadow_alpha = static_cast<std::uint8_t>(value < 0 ? 0 : value > 255 ? 255 : value);
7784
8254
  return true;
8255
+ #endif
7785
8256
  default:
7786
8257
  return false;
7787
8258
  }
@@ -7811,6 +8282,20 @@ void setStyleValue(NodeHandle node, Property property, int value, StyleApplicati
7811
8282
  }
7812
8283
  }
7813
8284
 
8285
+ void setLengthStyleValue(NodeHandle node, const CssLengthSpec &length, Property property, int value, StyleApplicationSource source)
8286
+ {
8287
+ setStyleValue(node, property, value, source);
8288
+ if (source == StyleApplicationSource::Inline && length.unit == CssLengthUnit::Px && std::isfinite(length.value))
8289
+ ensureRareData(node.id()).inlineStyles.setCssPixels(property, length.value);
8290
+ }
8291
+
8292
+ void setLengthStyleValue(NodeHandle node, const std::string &text, Property property, int value, StyleApplicationSource source)
8293
+ {
8294
+ CssLengthSpec length;
8295
+ if (parseCompiledLengthSpec(text, length)) setLengthStyleValue(node, length, property, value, source);
8296
+ else setStyleValue(node, property, value, source);
8297
+ }
8298
+
7814
8299
  void setStyleValueKnownTarget(NodeHandle node,
7815
8300
  Node &target,
7816
8301
  Property property,
@@ -7851,7 +8336,7 @@ void setPositionOffsetValue(NodeHandle node,
7851
8336
  return;
7852
8337
  }
7853
8338
  }
7854
- setStyleValue(node, lengthProperty, parseLengthForNode(value, node.id(), axis), source);
8339
+ setLengthStyleValue(node, value, lengthProperty, parseLengthForNode(value, node.id(), axis), source);
7855
8340
  }
7856
8341
 
7857
8342
  int deferredLengthExpression(const CssLengthSpec &length)
@@ -7881,7 +8366,8 @@ void setFlexBasisValue(NodeHandle node, bool hasBasis, const CssLengthSpec &leng
7881
8366
  const int expression = deferredLengthExpression(length);
7882
8367
  if (expression >= 0) setStyleValue(node, Property::FlexBasisExpression, expression, source);
7883
8368
  } else {
7884
- setStyleValue(node, Property::FlexBasis, hasBasis ? resolveCompiledLengthForNode(length, node.id(), LengthAxis::Horizontal) : kUnset, source);
8369
+ if (hasBasis) setLengthStyleValue(node, length, Property::FlexBasis, resolveCompiledLengthForNode(length, node.id(), LengthAxis::Horizontal), source);
8370
+ else setStyleValue(node, Property::FlexBasis, kUnset, source);
7885
8371
  }
7886
8372
  }
7887
8373
 
@@ -7889,7 +8375,7 @@ void setBoxLengthValue(NodeHandle node, bool padding, int side, const CssLengthS
7889
8375
  {
7890
8376
  const Property pixel = static_cast<Property>(static_cast<int>(padding ? Property::PaddingTop : Property::MarginTop) + side);
7891
8377
  const int value = length.unit == CssLengthUnit::Auto ? 0 : resolveCompiledLengthForNode(length, node.id(), LengthAxis::Horizontal);
7892
- setStyleValue(node, pixel, padding ? std::max(0, value) : value, source);
8378
+ setLengthStyleValue(node, length, pixel, padding ? std::max(0, value) : value, source);
7893
8379
  if (!padding)
7894
8380
  setStyleValue(node, static_cast<Property>(static_cast<int>(Property::MarginTopAuto) + side), length.unit == CssLengthUnit::Auto, source);
7895
8381
  // A var() can acquire a percentage or font-relative value later, even
@@ -7901,6 +8387,22 @@ void setBoxLengthValue(NodeHandle node, bool padding, int side, const CssLengthS
7901
8387
  expression, source);
7902
8388
  }
7903
8389
 
8390
+ void setGapLengthValues(NodeHandle node, CssDeclarationId declaration, const CssLengthSpec &row, const CssLengthSpec &column, StyleApplicationSource source)
8391
+ {
8392
+ if (declaration == CssDeclarationId::Gap)
8393
+ setLengthStyleValue(node, row, Property::Gap, row.unit == CssLengthUnit::Percent ? 0 : resolveCompiledLengthForNode(row, node.id(), LengthAxis::Vertical), source);
8394
+ for (int axis = 0; axis < 2; ++axis) {
8395
+ if (declaration == CssDeclarationId::RowGap && axis != 0) continue;
8396
+ if (declaration == CssDeclarationId::ColumnGap && axis != 1) continue;
8397
+ const auto &length = axis == 0 ? row : column;
8398
+ const bool percent = length.unit == CssLengthUnit::Percent;
8399
+ setLengthStyleValue(node, length, axis == 0 ? Property::RowGap : Property::ColumnGap,
8400
+ percent ? 0 : resolveCompiledLengthForNode(length, node.id(), axis == 0 ? LengthAxis::Vertical : LengthAxis::Horizontal), source);
8401
+ setStyleValue(node, axis == 0 ? Property::RowGapPercent : Property::ColumnGapPercent,
8402
+ percent ? roundToInt(length.value * 10.0) : kUnset, source);
8403
+ }
8404
+ }
8405
+
7904
8406
  void setSizeValue(NodeHandle node,
7905
8407
  Property lengthProperty,
7906
8408
  Property percentProperty,
@@ -7940,7 +8442,7 @@ void setSizeValue(NodeHandle node,
7940
8442
  if (parseSimplePercentPermille(value, percent))
7941
8443
  setStyleValue(node, percentProperty, percent, source);
7942
8444
  else
7943
- setStyleValue(node, lengthProperty, parseLengthForNode(value, node.id(), axis), source);
8445
+ setLengthStyleValue(node, value, lengthProperty, parseLengthForNode(value, node.id(), axis), source);
7944
8446
  }
7945
8447
 
7946
8448
  void setAllPadding(NodeHandle node, int value, StyleApplicationSource source)
@@ -7978,9 +8480,11 @@ void setMarginBox(NodeHandle node, const BoxLengths &box, StyleApplicationSource
7978
8480
  void setAllBorderRadius(NodeHandle node, int value, StyleApplicationSource source)
7979
8481
  {
7980
8482
  setStyleValue(node, Property::BorderRadiusTopLeft, value, source);
8483
+ #if GEA_CSS_CORNER_RADIUS
7981
8484
  setStyleValue(node, Property::BorderRadiusTopRight, value, source);
7982
8485
  setStyleValue(node, Property::BorderRadiusBottomRight, value, source);
7983
8486
  setStyleValue(node, Property::BorderRadiusBottomLeft, value, source);
8487
+ #endif
7984
8488
  }
7985
8489
 
7986
8490
  Property borderRadiusLengthProperty(int corner)
@@ -8012,7 +8516,7 @@ void setBorderRadiusCornerValue(NodeHandle node,
8012
8516
  if (parseSimplePercentPermille(value, percent))
8013
8517
  setStyleValue(node, borderRadiusPercentProperty(corner), percent, source);
8014
8518
  else
8015
- setStyleValue(node, borderRadiusLengthProperty(corner), parseLengthForNode(value, node.id(), LengthAxis::None), source);
8519
+ setLengthStyleValue(node, value, borderRadiusLengthProperty(corner), parseLengthForNode(value, node.id(), LengthAxis::None), source);
8016
8520
  }
8017
8521
 
8018
8522
  void applyBorderRadiusValue(NodeHandle node, const std::string &value, StyleApplicationSource source)
@@ -8022,13 +8526,15 @@ void applyBorderRadiusValue(NodeHandle node, const std::string &value, StyleAppl
8022
8526
  const auto parts = splitWords(axes.empty() ? value : axes[0]);
8023
8527
  if (parts.empty()) return;
8024
8528
  const std::string &tl = parts[0];
8529
+ setBorderRadiusCornerValue(node, 0, tl, source);
8530
+ #if GEA_CSS_CORNER_RADIUS
8025
8531
  const std::string &tr = parts.size() > 1 ? parts[1] : tl;
8026
8532
  const std::string &br = parts.size() > 2 ? parts[2] : tl;
8027
8533
  const std::string &bl = parts.size() > 3 ? parts[3] : tr;
8028
- setBorderRadiusCornerValue(node, 0, tl, source);
8029
8534
  setBorderRadiusCornerValue(node, 1, tr, source);
8030
8535
  setBorderRadiusCornerValue(node, 2, br, source);
8031
8536
  setBorderRadiusCornerValue(node, 3, bl, source);
8537
+ #endif
8032
8538
  }
8033
8539
 
8034
8540
  void setIndividualRotation(NodeHandle node, const IndividualRotation &r, bool present, StyleApplicationSource source)
@@ -8084,6 +8590,7 @@ void setTransformComponents(NodeHandle node, const TransformComponents &t, Style
8084
8590
 
8085
8591
  bool applyTransformComponentsFast(NodeHandle node, const TransformComponents &t, StyleApplicationSource source)
8086
8592
  {
8593
+ #if GEA_CSS_TRANSFORMS
8087
8594
  setStyleValue(node, Property::TransformTranslateOuterAxes, t.translateOuterAxes, source);
8088
8595
  setStyleValue(node, Property::TransformPresent, t.hasRotateX || t.hasRotateY || t.hasRotateZ || t.hasTranslateX || t.hasTranslateY || t.hasTranslateZ || t.hasScaleX || t.hasScaleY || t.hasScaleZ, source);
8089
8596
  {
@@ -8099,7 +8606,7 @@ bool applyTransformComponentsFast(NodeHandle node, const TransformComponents &t,
8099
8606
  const int nodeId = node.id();
8100
8607
  if (nodeId < 0 || nodeId >= state.nodeCount) return true;
8101
8608
  Node &target = state.nodes[nodeId];
8102
- const RareStyle &current = rstyle(target.style);
8609
+ const RareStyle &current = rstyle(target.computedStyle());
8103
8610
  if (current.transform_rotate_x == static_cast<int16_t>(t.rotateX) &&
8104
8611
  current.transform_rotate_y == static_cast<int16_t>(t.rotateY) &&
8105
8612
  current.transform_rotate == static_cast<int16_t>(t.rotateZ) &&
@@ -8112,7 +8619,7 @@ bool applyTransformComponentsFast(NodeHandle node, const TransformComponents &t,
8112
8619
  current.transform_scale_y == static_cast<int16_t>(t.scaleY) &&
8113
8620
  current.transform_scale_z == static_cast<int16_t>(t.scaleZ))
8114
8621
  return true;
8115
- RareStyle &rs = rstyleMut(target.style);
8622
+ RareStyle &rs = rstyleMut(target.mutableStyle());
8116
8623
  rs.transform_rotate_x = static_cast<int16_t>(t.rotateX);
8117
8624
  rs.transform_rotate_y = static_cast<int16_t>(t.rotateY);
8118
8625
  rs.transform_rotate = static_cast<int16_t>(t.rotateZ);
@@ -8135,16 +8642,27 @@ bool applyTransformComponentsFast(NodeHandle node, const TransformComponents &t,
8135
8642
  if (!nodeParticipatesInMountedTree(state, nodeId)) return true;
8136
8643
  target.render.dirty = 1;
8137
8644
  if (state.fixedPositionUsed) target.render.layout_dirty = 1;
8645
+ #if GEA_CSS_SCROLLING
8138
8646
  target.render.non_scroll_dirty = 1;
8647
+ #endif
8648
+ #if GEA_CSS_TRANSFORMS
8139
8649
  target.render.transform_dirty = 1;
8650
+ #endif
8651
+
8652
+ #if GEA_CSS_TRANSFORMS
8140
8653
  state.transformScanSerial = ~0ull;
8141
8654
  state.transformScanValid = false;
8655
+ #endif
8142
8656
  Tree::instance().markNodeDisplayCommandsDirty(nodeId);
8143
8657
  return true;
8658
+ #else
8659
+ return false;
8660
+ #endif
8144
8661
  }
8145
8662
 
8146
8663
  bool applyTransformSlotsFast(NodeHandle node, const std::int16_t *slots, StyleApplicationSource source)
8147
8664
  {
8665
+ #if GEA_CSS_TRANSFORMS
8148
8666
  {
8149
8667
  static const bool gTraceCube = std::getenv("GEA_DEBUG_CUBE") != nullptr;
8150
8668
  if (gTraceCube)
@@ -8157,7 +8675,7 @@ bool applyTransformSlotsFast(NodeHandle node, const std::int16_t *slots, StyleAp
8157
8675
  const int nodeId = node.id();
8158
8676
  if (nodeId < 0 || nodeId >= state.nodeCount) return true;
8159
8677
  Node &target = state.nodes[nodeId];
8160
- const RareStyle &current = rstyle(target.style);
8678
+ const RareStyle &current = rstyle(target.computedStyle());
8161
8679
  if (current.transform_rotate_x == slots[0] &&
8162
8680
  current.transform_rotate_y == slots[1] &&
8163
8681
  current.transform_rotate == slots[2] &&
@@ -8170,7 +8688,7 @@ bool applyTransformSlotsFast(NodeHandle node, const std::int16_t *slots, StyleAp
8170
8688
  current.transform_scale_y == slots[9] &&
8171
8689
  current.transform_scale_z == slots[10])
8172
8690
  return true;
8173
- RareStyle &rs = rstyleMut(target.style);
8691
+ RareStyle &rs = rstyleMut(target.mutableStyle());
8174
8692
  rs.transform_rotate_x = slots[0];
8175
8693
  rs.transform_rotate_y = slots[1];
8176
8694
  rs.transform_rotate = slots[2];
@@ -8186,12 +8704,22 @@ bool applyTransformSlotsFast(NodeHandle node, const std::int16_t *slots, StyleAp
8186
8704
  if (!nodeParticipatesInMountedTree(state, nodeId)) return true;
8187
8705
  target.render.dirty = 1;
8188
8706
  if (state.fixedPositionUsed) target.render.layout_dirty = 1;
8707
+ #if GEA_CSS_SCROLLING
8189
8708
  target.render.non_scroll_dirty = 1;
8709
+ #endif
8710
+ #if GEA_CSS_TRANSFORMS
8190
8711
  target.render.transform_dirty = 1;
8712
+ #endif
8713
+
8714
+ #if GEA_CSS_TRANSFORMS
8191
8715
  state.transformScanSerial = ~0ull;
8192
8716
  state.transformScanValid = false;
8717
+ #endif
8193
8718
  Tree::instance().markNodeDisplayCommandsDirty(nodeId);
8194
8719
  return true;
8720
+ #else
8721
+ return false;
8722
+ #endif
8195
8723
  }
8196
8724
 
8197
8725
  Property borderSideWidthProperty(int side);
@@ -8208,10 +8736,15 @@ bool applyBorderWidthBox(NodeHandle node, const CssCompiledValue &compiled, Styl
8208
8736
  widths[side] = resolveBorderWidth(compiled.lengths[side], node.id());
8209
8737
  if (widths[side] < 0) return true;
8210
8738
  }
8211
- const bool uniform = widths[0] == widths[1] && widths[0] == widths[2] && widths[0] == widths[3];
8739
+ bool uniform = widths[0] == widths[1] && widths[0] == widths[2] && widths[0] == widths[3];
8740
+ if (source == StyleApplicationSource::Inline)
8741
+ for (int side = 1; side < 4; ++side)
8742
+ uniform = uniform && compiled.lengths[side].unit == compiled.lengths[0].unit && compiled.lengths[side].value == compiled.lengths[0].value;
8212
8743
  setUniformBorderWidth(node, uniform ? widths[0] : 0, source);
8744
+ if (uniform && source == StyleApplicationSource::Inline && compiled.lengths[0].unit == CssLengthUnit::Px)
8745
+ ensureRareData(node.id()).inlineStyles.setCssPixels(Property::BorderWidth, compiled.lengths[0].value);
8213
8746
  if (!uniform)
8214
- for (int side = 0; side < 4; ++side) setStyleValue(node, borderSideWidthProperty(side), widths[side], source);
8747
+ for (int side = 0; side < 4; ++side) setLengthStyleValue(node, compiled.lengths[side], borderSideWidthProperty(side), widths[side], source);
8215
8748
  return true;
8216
8749
  }
8217
8750
 
@@ -8222,7 +8755,7 @@ void applyBorderShorthand(NodeHandle node, const std::string &value, StyleApplic
8222
8755
  const auto parts = splitFunctionAwareWords(value);
8223
8756
  const int width = resolveBorderWidth(compiled.lengths[0], node.id());
8224
8757
  if (width < 0) return;
8225
- setUniformBorderWidth(node, width, source);
8758
+ setLengthStyleValue(node, compiled.lengths[0], Property::BorderWidth, width, source);
8226
8759
  for (int side = 0; side < 4; ++side)
8227
8760
  setStyleValue(node, static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side), compiled.values[2], source);
8228
8761
  for (const auto &part : parts) {
@@ -8231,7 +8764,9 @@ void applyBorderShorthand(NodeHandle node, const std::string &value, StyleApplic
8231
8764
  const ParsedCssColor color = parseCssColor(part);
8232
8765
  setStyleValue(node, Property::BorderColor, color.valid ? cssColorStyleValue(color) : parseColorStyleValue(value), source);
8233
8766
  if (color.valid) {
8767
+ #if GEA_CSS_BORDER_ALPHA
8234
8768
  setStyleValue(node, Property::BorderAlpha, color.a, source);
8769
+ #endif
8235
8770
  markNodeDisplayCommandsDirtyForStyleApply(node.id());
8236
8771
  }
8237
8772
  return;
@@ -8291,7 +8826,7 @@ void applyBorderSideShorthand(NodeHandle node, int side, const std::string &valu
8291
8826
  const auto parts = splitFunctionAwareWords(value);
8292
8827
  const int width = resolveBorderWidth(compiled.lengths[0], node.id());
8293
8828
  if (width < 0) return;
8294
- setStyleValue(node, borderSideWidthProperty(side), width, source);
8829
+ setLengthStyleValue(node, compiled.lengths[0], borderSideWidthProperty(side), width, source);
8295
8830
  setStyleValue(node, static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side), compiled.values[2], source);
8296
8831
  for (const auto &part : parts) {
8297
8832
  if (part.empty()) continue;
@@ -8353,15 +8888,17 @@ void applyBackgroundSizeValue(NodeHandle node, const std::string &value)
8353
8888
  {
8354
8889
  if (!node) return;
8355
8890
  Node &target = treeState().nodes[node.id()];
8356
- if (rstyle(target.style).bg_grid_axes == 0) return;
8891
+ if (rstyle(target.computedStyle()).bg_grid_axes == 0) return;
8357
8892
  const auto layers = splitTopLevel(value, ',');
8358
8893
  if (layers.empty()) return;
8359
8894
  const auto parts = splitWords(layers[0]);
8360
8895
  if (parts.empty()) return;
8361
8896
  const int stepX = parseLengthForNode(parts[0], node.id(), LengthAxis::Horizontal);
8362
8897
  const int stepY = parseLengthForNode(parts.size() > 1 ? parts[1] : parts[0], node.id(), LengthAxis::Vertical);
8363
- if (stepX > 0) rstyleMut(target.style).bg_grid_step_x = static_cast<uint16_t>(std::min(stepX, 65535));
8364
- if (stepY > 0) rstyleMut(target.style).bg_grid_step_y = static_cast<uint16_t>(std::min(stepY, 65535));
8898
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
8899
+ if (stepX > 0) rstyleMut(target.mutableStyle()).bg_grid_step_x = static_cast<uint16_t>(std::min(stepX, 65535));
8900
+ if (stepY > 0) rstyleMut(target.mutableStyle()).bg_grid_step_y = static_cast<uint16_t>(std::min(stepY, 65535));
8901
+ #endif
8365
8902
  markNodeDisplayCommandsDirtyForStyleApply(node.id());
8366
8903
  }
8367
8904
 
@@ -8370,7 +8907,9 @@ void applyTextColorValue(NodeHandle node, const std::string &value, StyleApplica
8370
8907
  if (!node) return;
8371
8908
  const ParsedCssColor color = parseCssColor(firstColorToken(value));
8372
8909
  setStyleValue(node, Property::Color, color.valid ? cssColorStyleValue(color) : parseColorStyleValue(value), source);
8910
+ #if GEA_CSS_TEXT_ALPHA
8373
8911
  setStyleValue(node, Property::ColorAlpha, color.valid ? color.a : 255, source);
8912
+ #endif
8374
8913
  markNodeDisplayCommandsDirtyForStyleApply(node.id());
8375
8914
  }
8376
8915
 
@@ -8383,13 +8922,16 @@ void applyBorderColorValue(NodeHandle node, const std::string &value, StyleAppli
8383
8922
  }
8384
8923
  const ParsedCssColor color = parseCssColor(firstColorToken(value));
8385
8924
  setStyleValue(node, Property::BorderColor, color.valid ? cssColorStyleValue(color) : parseColorStyleValue(value), source);
8925
+ #if GEA_CSS_BORDER_ALPHA
8386
8926
  setStyleValue(node, Property::BorderAlpha, color.valid ? color.a : 255, source);
8927
+ #endif
8387
8928
  markNodeDisplayCommandsDirtyForStyleApply(node.id());
8388
8929
  }
8389
8930
 
8390
8931
  int16_t *animatedTransformSlot(RareStyle &rs, Property property)
8391
8932
  {
8392
8933
  switch (property) {
8934
+ #if GEA_CSS_TRANSFORMS
8393
8935
  case Property::RotateAngle: return &rs.rotate_angle;
8394
8936
  case Property::ScaleX: return &rs.scale_x;
8395
8937
  case Property::ScaleY: return &rs.scale_y;
@@ -8410,6 +8952,7 @@ int16_t *animatedTransformSlot(RareStyle &rs, Property property)
8410
8952
  case Property::TransformScaleX: return &rs.transform_scale_x;
8411
8953
  case Property::TransformScaleY: return &rs.transform_scale_y;
8412
8954
  case Property::TransformScaleZ: return &rs.transform_scale_z;
8955
+ #endif
8413
8956
  default: return nullptr;
8414
8957
  }
8415
8958
  }
@@ -8419,7 +8962,7 @@ bool applyAnimatedTransformStyleValueFast(int nodeId, Property property, int val
8419
8962
  auto &state = treeState();
8420
8963
  if (nodeId < 0 || nodeId >= state.nodeCount) return true;
8421
8964
  Node &target = state.nodes[nodeId];
8422
- RareStyle &rs = rstyleMut(target.style);
8965
+ RareStyle &rs = rstyleMut(target.mutableStyle());
8423
8966
  int16_t *slot = animatedTransformSlot(rs, property);
8424
8967
  if (!slot) return false;
8425
8968
  const int16_t next = static_cast<int16_t>(value);
@@ -8429,16 +8972,35 @@ bool applyAnimatedTransformStyleValueFast(int nodeId, Property property, int val
8429
8972
  if (!nodeParticipatesInMountedTree(state, nodeId)) return true;
8430
8973
  target.render.dirty = 1;
8431
8974
  if (state.fixedPositionUsed) target.render.layout_dirty = 1;
8975
+ #if GEA_CSS_SCROLLING
8432
8976
  target.render.non_scroll_dirty = 1;
8977
+ #endif
8978
+ #if GEA_CSS_TRANSFORMS
8433
8979
  target.render.transform_dirty = 1;
8980
+ #endif
8981
+
8982
+ #if GEA_CSS_TRANSFORMS
8434
8983
  state.transformScanSerial = ~0ull;
8435
8984
  state.transformScanValid = false;
8985
+ #endif
8436
8986
  Tree::instance().markNodeDisplayCommandsDirty(nodeId);
8437
8987
  return true;
8438
8988
  }
8439
8989
 
8440
8990
  } // namespace
8441
8991
 
8992
+ StorageUsage styleDependencyStorageUsage()
8993
+ {
8994
+ StorageUsage usage;
8995
+ #if GEA_CSS_CUSTOM_PROPERTIES
8996
+ usage.staticBytes = sizeof(g_nodeRefs) + sizeof(g_nodeRefOverflow) + sizeof(g_recordingNode) + sizeof(g_customPropertyLookupCache);
8997
+ usage.addVector(g_nodeRefOverflow);
8998
+ #elif !GEA_EMBEDDED_SHARED_STYLES
8999
+ usage.staticBytes = sizeof(g_nodeStyleTracked);
9000
+ #endif
9001
+ return usage;
9002
+ }
9003
+
8442
9004
  bool layoutSizeExpressionUsesPercentage(int nodeId, int expression)
8443
9005
  {
8444
9006
  return expression >= 0 && lengthDependsOnInput(
@@ -8466,7 +9028,7 @@ int resolveLineHeightExpression(int nodeId, int expression)
8466
9028
 
8467
9029
  int resolveLayoutFlexBasis(int nodeId, int percentageBasis, bool horizontal)
8468
9030
  {
8469
- const auto &style = treeState().nodes[nodeId].style;
9031
+ const auto &style = treeState().nodes[nodeId].computedStyle();
8470
9032
  const int expression = rstyle(style).flex_basis_expression;
8471
9033
  if (expression < 0) return style.flex_basis;
8472
9034
  if (percentageBasis < 0 && layoutSizeExpressionUsesPercentage(nodeId, expression)) return kUnset;
@@ -8479,11 +9041,12 @@ int resolveLayoutFlexBasis(int nodeId, int percentageBasis, bool horizontal)
8479
9041
 
8480
9042
  bool resolveLayoutBoxLengths(int nodeId, int percentageBasis)
8481
9043
  {
9044
+ #if GEA_CSS_BOX_EXPRESSIONS
8482
9045
  auto &node = treeState().nodes[nodeId];
8483
9046
  #if !GEA_EMBEDDED_RARE_STYLE_INLINE
8484
- if (node.style.rare_style < 0) return false;
9047
+ if (node.computedStyle().rare_style < 0) return false;
8485
9048
  #endif
8486
- const RareStyle &rare = rstyle(node.style);
9049
+ const RareStyle &rare = rstyle(node.computedStyle());
8487
9050
  const int previous = g_boxPercentageBasis;
8488
9051
  g_boxPercentageBasis = std::max(0, percentageBasis);
8489
9052
  bool changed = false;
@@ -8493,12 +9056,26 @@ bool resolveLayoutBoxLengths(int nodeId, int percentageBasis)
8493
9056
  if (expression < 0) continue;
8494
9057
  const int raw = resolveLayoutSizeExpression(nodeId, expression, true);
8495
9058
  const int value = std::max(padding ? 0 : -32768, std::min(32767, raw));
8496
- auto &target = padding ? node.style.padding[side] : node.style.margin[side];
8497
- if (target != value) { target = static_cast<int16_t>(value); changed = true; }
9059
+ // Padding can have a proven unsigned byte range while margin remains
9060
+ // signed. Keep writes typed; the existing side choice already branches.
9061
+ if (padding) {
9062
+ #if GEA_CSS_PADDING
9063
+ if (node.computedStyle().padding[side] != value) { node.mutableStyle().padding[side] = value; changed = true; }
9064
+ #endif
9065
+ } else {
9066
+ #if GEA_CSS_MARGINS
9067
+ if (node.computedStyle().margin[side] != value) { node.mutableStyle().margin[side] = static_cast<int16_t>(value); changed = true; }
9068
+ #endif
9069
+ }
8498
9070
  }
8499
9071
  }
8500
9072
  g_boxPercentageBasis = previous;
8501
9073
  return changed;
9074
+ #else
9075
+ (void)nodeId;
9076
+ (void)percentageBasis;
9077
+ return false;
9078
+ #endif
8502
9079
  }
8503
9080
 
8504
9081
 
@@ -8560,20 +9137,36 @@ void applyInheritedStyleDefaults(int node)
8560
9137
  const int parent = state.nodes[node].parent;
8561
9138
  if (parent < 0 || parent >= state.nodeCount) return;
8562
9139
 
8563
- const auto &parentStyle = state.nodes[parent].style;
8564
- auto &style = state.nodes[node].style;
9140
+ const auto &parentStyle = state.nodes[parent].computedStyle();
9141
+ auto &style = state.nodes[node].mutableStyle();
8565
9142
  style.text_color = parentStyle.text_color;
9143
+ #if GEA_CSS_TEXT_ALPHA
8566
9144
  style.text_alpha = parentStyle.text_alpha;
9145
+ #endif
8567
9146
  style.font_id = parentStyle.font_id;
8568
9147
  style.font_size = parentStyle.font_size;
9148
+ #if GEA_CSS_FONT_WEIGHT
8569
9149
  style.font_weight = parentStyle.font_weight;
9150
+ #endif
9151
+ #if GEA_CSS_LINE_HEIGHT
8570
9152
  style.line_height = parentStyle.line_height;
9153
+ #endif
9154
+ #if GEA_CSS_LINE_HEIGHT_MULTIPLIER
8571
9155
  if (parentStyle.line_height_multiplier >= 0)
8572
9156
  style.line_height_multiplier = parentStyle.line_height_multiplier;
9157
+ #endif
9158
+ #if GEA_CSS_TEXT_ALIGN
8573
9159
  style.text_align = parentStyle.text_align;
9160
+ #endif
9161
+ #if GEA_CSS_TEXT_TRANSFORM
8574
9162
  style.text_transform = parentStyle.text_transform;
9163
+ #endif
9164
+ #if GEA_CSS_WHITE_SPACE
8575
9165
  style.white_space = parentStyle.white_space;
9166
+ #endif
9167
+ #if GEA_CSS_VISIBILITY
8576
9168
  style.visibility = parentStyle.visibility;
9169
+ #endif
8577
9170
  }
8578
9171
 
8579
9172
  bool applyNumberDeclarationWithSource(NodeHandle node,
@@ -8705,6 +9298,7 @@ bool applyNumberDeclarationWithSource(NodeHandle node,
8705
9298
  setStyleValue(node, Property::LineHeightMultiplier, bits, source);
8706
9299
  return true;
8707
9300
  }
9301
+ #if GEA_CSS_TRANSFORMS
8708
9302
  case CssDeclarationId::Transform:
8709
9303
  setStyleValue(node, Property::TransformPresent, 1, source);
8710
9304
  setStyleValue(node, Property::TransformRotate, numericRotateTenths(value), source);
@@ -8718,6 +9312,7 @@ bool applyNumberDeclarationWithSource(NodeHandle node,
8718
9312
  const int scale[3] = {factor, factor, 1000};
8719
9313
  setIndividualScale(node, scale, true, source); return true;
8720
9314
  }
9315
+ #endif
8721
9316
  default:
8722
9317
  return false;
8723
9318
  }
@@ -8745,7 +9340,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8745
9340
  if (placement != Property::Count) {
8746
9341
  const int parent = Tree::instance().node(nodeId).parent;
8747
9342
  const int handle = toLowerAscii(trimCssValue(value)) == "inherit"
8748
- ? (parent >= 0 ? backgroundPlacementHandle(Tree::instance().node(parent).style, placement) : -1)
9343
+ ? (parent >= 0 ? backgroundPlacementHandle(Tree::instance().node(parent).computedStyle(), placement) : -1)
8749
9344
  : compileBackgroundPlacement(declaration, value);
8750
9345
  if (handle >= -1) setStyleValue(node, placement, handle, source);
8751
9346
  return true;
@@ -8757,10 +9352,46 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8757
9352
  }
8758
9353
 
8759
9354
  switch (declaration) {
9355
+ #if !GEA_CSS_GRID
9356
+ case CssDeclarationId::GridRowStart:
9357
+ case CssDeclarationId::GridColumnStart:
9358
+ case CssDeclarationId::GridRowEnd:
9359
+ case CssDeclarationId::GridColumnEnd:
9360
+ case CssDeclarationId::GridRow:
9361
+ case CssDeclarationId::GridColumn:
9362
+ case CssDeclarationId::GridArea:
9363
+ case CssDeclarationId::Grid:
9364
+ case CssDeclarationId::GridTemplate:
9365
+ case CssDeclarationId::GridTemplateColumns:
9366
+ case CssDeclarationId::GridTemplateRows:
9367
+ return false;
9368
+ #endif
9369
+ #if !GEA_CSS_TRANSFORMS
9370
+ case CssDeclarationId::TransformStyle:
9371
+ case CssDeclarationId::Translate:
9372
+ case CssDeclarationId::Transform:
9373
+ case CssDeclarationId::Rotate:
9374
+ case CssDeclarationId::Scale:
9375
+ case CssDeclarationId::TransformOrigin:
9376
+ case CssDeclarationId::Perspective:
9377
+ case CssDeclarationId::PerspectiveOrigin:
9378
+ return false;
9379
+ #endif
9380
+ #if !GEA_CSS_FLOATS
9381
+ case CssDeclarationId::Float:
9382
+ case CssDeclarationId::Clear:
9383
+ return false;
9384
+ #endif
9385
+ #if !GEA_CSS_WRITING_MODE
9386
+ case CssDeclarationId::Direction:
9387
+ case CssDeclarationId::WritingMode:
9388
+ return false;
9389
+ #endif
9390
+
8760
9391
  case CssDeclarationId::BackgroundClip: {
8761
9392
  const int parent = Tree::instance().node(nodeId).parent;
8762
9393
  const int clip = toLowerAscii(trimCssValue(value)) == "inherit"
8763
- ? (parent >= 0 ? rstyle(Tree::instance().node(parent).style).bg_clip : 0)
9394
+ ? (parent >= 0 ? rstyle(Tree::instance().node(parent).computedStyle()).bg_clip : 0)
8764
9395
  : compileBackgroundClip(value);
8765
9396
  if (clip >= 0) setStyleValue(node, Property::BackgroundClip, clip, source);
8766
9397
  return true;
@@ -8768,7 +9399,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8768
9399
  case CssDeclarationId::Contain: {
8769
9400
  const int parent = Tree::instance().node(nodeId).parent;
8770
9401
  const int flags = toLowerAscii(trimCssValue(value)) == "inherit"
8771
- ? (parent >= 0 ? rstyle(Tree::instance().node(parent).style).containment : 0)
9402
+ ? (parent >= 0 ? (GEA_CSS_CONTAINMENT ? rstyle(Tree::instance().node(parent).computedStyle()).containment : 0) : 0)
8772
9403
  : containmentValue(value);
8773
9404
  if (flags >= 0) setStyleValue(node, Property::Containment, flags, source);
8774
9405
  return true;
@@ -8782,7 +9413,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8782
9413
  }
8783
9414
  if (ratio == "inherit") {
8784
9415
  const int parent = Tree::instance().node(nodeId).parent;
8785
- setStyleValue(node, Property::AspectRatio, parent >= 0 ? rstyle(Tree::instance().node(parent).style).aspect_ratio : 0, source);
9416
+ setStyleValue(node, Property::AspectRatio, parent >= 0 ? (GEA_CSS_ASPECT_RATIO ? rstyle(Tree::instance().node(parent).computedStyle()).aspect_ratio : 0) : 0, source);
8786
9417
  return true;
8787
9418
  }
8788
9419
  const auto words = splitFunctionAwareWords(ratio);
@@ -8823,25 +9454,30 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8823
9454
  if (value == "content-box") setStyleValue(node, Property::BoxSizing, 0, source);
8824
9455
  if (value == "border-box") setStyleValue(node, Property::BoxSizing, 1, source);
8825
9456
  return true;
9457
+ #if GEA_CSS_FLOATS
8826
9458
  case CssDeclarationId::Float:
8827
9459
  if (value == "none") setStyleValue(node, Property::Float, 0, source);
8828
9460
  if (value == "left") setStyleValue(node, Property::Float, 1, source);
8829
9461
  if (value == "right") setStyleValue(node, Property::Float, 2, source);
8830
9462
  return true;
9463
+ #endif
8831
9464
  case CssDeclarationId::MarginTrim: {
8832
9465
  const int parent = Tree::instance().node(nodeId).parent;
8833
9466
  const int flags = toLowerAscii(trimCssValue(value)) == "inherit"
8834
- ? (parent >= 0 ? rstyle(Tree::instance().node(parent).style).margin_trim : 0)
9467
+ ? (parent >= 0 ? (GEA_CSS_MARGIN_TRIM ? rstyle(Tree::instance().node(parent).computedStyle()).margin_trim : 0) : 0)
8835
9468
  : marginTrimValue(value);
8836
9469
  if (flags >= 0) setStyleValue(node, Property::MarginTrim, flags, source);
8837
9470
  return true;
8838
9471
  }
9472
+ #if GEA_CSS_FLOATS
8839
9473
  case CssDeclarationId::Clear:
8840
9474
  if (value == "none") setStyleValue(node, Property::Clear, 0, source);
8841
9475
  if (value == "left") setStyleValue(node, Property::Clear, 1, source);
8842
9476
  if (value == "right") setStyleValue(node, Property::Clear, 2, source);
8843
9477
  if (value == "both") setStyleValue(node, Property::Clear, 3, source);
8844
9478
  return true;
9479
+ #endif
9480
+ #if GEA_CSS_WRITING_MODE
8845
9481
  case CssDeclarationId::Direction:
8846
9482
  if (value == "ltr" || value == "initial") setStyleValue(node, Property::Direction, 0, source);
8847
9483
  if (value == "rtl") setStyleValue(node, Property::Direction, 1, source);
@@ -8855,6 +9491,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8855
9491
  if (value == "sideways-lr") setStyleValue(node, Property::WritingMode, 4, source);
8856
9492
  if (value == "inherit") setStyleValue(node, Property::WritingMode, -1, source);
8857
9493
  return true;
9494
+ #endif
8858
9495
  case CssDeclarationId::FlexFlow: {
8859
9496
  int direction = 1;
8860
9497
  bool hasDirection = false;
@@ -8886,18 +9523,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8886
9523
  else if (!parseCompiledLengthSpec(parts[i], specs[i]) || specs[i].value < 0) return true;
8887
9524
  }
8888
9525
  if (parts.size() == 1) specs[1] = specs[0];
8889
- if (declaration == CssDeclarationId::Gap)
8890
- setStyleValue(node, Property::Gap, specs[0].unit == CssLengthUnit::Percent ? 0 : resolveCompiledLengthForNode(specs[0], nodeId, LengthAxis::Vertical), source);
8891
- for (int axis = 0; axis < 2; ++axis) {
8892
- if (declaration == CssDeclarationId::RowGap && axis != 0) continue;
8893
- if (declaration == CssDeclarationId::ColumnGap && axis != 1) continue;
8894
- const auto &spec = specs[declaration == CssDeclarationId::Gap ? axis : 0];
8895
- const bool percent = spec.unit == CssLengthUnit::Percent;
8896
- setStyleValue(node, axis == 0 ? Property::RowGap : Property::ColumnGap,
8897
- percent ? 0 : resolveCompiledLengthForNode(spec, nodeId, axis == 0 ? LengthAxis::Vertical : LengthAxis::Horizontal), source);
8898
- setStyleValue(node, axis == 0 ? Property::RowGapPercent : Property::ColumnGapPercent,
8899
- percent ? roundToInt(spec.value * 10.0) : kUnset, source);
8900
- }
9526
+ setGapLengthValues(node, declaration, specs[0], specs[1], source);
8901
9527
  return true;
8902
9528
  }
8903
9529
  case CssDeclarationId::Order: {
@@ -8914,7 +9540,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8914
9540
  case CssDeclarationId::FlexWrap:
8915
9541
  if (value == "inherit") {
8916
9542
  const int parent = Tree::instance().node(nodeId).parent;
8917
- setStyleValue(node, Property::FlexWrap, parent >= 0 ? Tree::instance().node(parent).style.flex_wrap : 0, source);
9543
+ setStyleValue(node, Property::FlexWrap, parent >= 0 ? Tree::instance().node(parent).computedStyle().flex_wrap : 0, source);
8918
9544
  } else if (flexWrapValue(value) >= 0) setStyleValue(node, Property::FlexWrap, flexWrapValue(value), source);
8919
9545
  return true;
8920
9546
  case CssDeclarationId::FlexLineCount: {
@@ -8922,7 +9548,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8922
9548
  if (value == "initial" || value == "unset") setStyleValue(node, Property::FlexLineCount, 1, source);
8923
9549
  else if (value == "inherit") {
8924
9550
  const int parent = Tree::instance().node(nodeId).parent;
8925
- setStyleValue(node, Property::FlexLineCount, parent >= 0 ? rstyle(Tree::instance().node(parent).style).flex_line_count : 1, source);
9551
+ setStyleValue(node, Property::FlexLineCount, parent >= 0 ? (GEA_CSS_FLEX_LINE_COUNT ? rstyle(Tree::instance().node(parent).computedStyle()).flex_line_count : 1) : 1, source);
8926
9552
  } else if (parseOrder(value, count) && count >= 1) setStyleValue(node, Property::FlexLineCount, count, source);
8927
9553
  return true;
8928
9554
  }
@@ -8961,15 +9587,16 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
8961
9587
  if (parent < 0) {
8962
9588
  align = justify = declaration == CssDeclarationId::PlaceSelf ? -1 : 0;
8963
9589
  } else {
8964
- const auto &inherited = Tree::instance().node(parent).style;
9590
+ const auto &inherited = Tree::instance().node(parent).computedStyle();
8965
9591
  align = declaration == CssDeclarationId::PlaceItems ? inherited.align_items : declaration == CssDeclarationId::PlaceContent ? inherited.align_content : inherited.align_self;
8966
- justify = declaration == CssDeclarationId::PlaceItems ? inherited.justify_items : declaration == CssDeclarationId::PlaceContent ? inherited.justify_content : rstyle(inherited).justify_self;
9592
+ justify = declaration == CssDeclarationId::PlaceItems ? inherited.justify_items : declaration == CssDeclarationId::PlaceContent ? inherited.justify_content : (GEA_CSS_JUSTIFY_SELF ? rstyle(inherited).justify_self : -1);
8967
9593
  }
8968
9594
  } else if (!parseAlignmentShorthand(declaration, value, align, justify)) return true;
8969
9595
  setStyleValue(node, alignProperty, align, source);
8970
9596
  setStyleValue(node, justifyProperty, justify, source);
8971
9597
  return true;
8972
9598
  }
9599
+ #if GEA_CSS_GRID
8973
9600
  case CssDeclarationId::GridRowStart:
8974
9601
  case CssDeclarationId::GridColumnStart:
8975
9602
  case CssDeclarationId::GridRowEnd:
@@ -9010,6 +9637,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9010
9637
  case CssDeclarationId::GridTemplateRows:
9011
9638
  applyGridTemplateValue(node, value, false);
9012
9639
  return true;
9640
+ #endif
9013
9641
  case CssDeclarationId::Ignored:
9014
9642
  case CssDeclarationId::Content:
9015
9643
  case CssDeclarationId::Animation:
@@ -9021,16 +9649,16 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9021
9649
  setSizeValue(node, Property::Height, Property::HeightPercent, value, LengthAxis::Vertical, source);
9022
9650
  return true;
9023
9651
  case CssDeclarationId::MinWidth:
9024
- setStyleValue(node, Property::MinWidth, parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
9652
+ setLengthStyleValue(node, value, Property::MinWidth, parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
9025
9653
  return true;
9026
9654
  case CssDeclarationId::MinHeight:
9027
- setStyleValue(node, Property::MinHeight, parseLengthForNode(value, nodeId, LengthAxis::Vertical), source);
9655
+ setLengthStyleValue(node, value, Property::MinHeight, parseLengthForNode(value, nodeId, LengthAxis::Vertical), source);
9028
9656
  return true;
9029
9657
  case CssDeclarationId::MaxWidth:
9030
- setStyleValue(node, Property::MaxWidth, value == "none" ? kUnset : parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
9658
+ setLengthStyleValue(node, value, Property::MaxWidth, value == "none" ? kUnset : parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
9031
9659
  return true;
9032
9660
  case CssDeclarationId::MaxHeight:
9033
- setStyleValue(node, Property::MaxHeight, value == "none" ? kUnset : parseLengthForNode(value, nodeId, LengthAxis::Vertical), source);
9661
+ setLengthStyleValue(node, value, Property::MaxHeight, value == "none" ? kUnset : parseLengthForNode(value, nodeId, LengthAxis::Vertical), source);
9034
9662
  return true;
9035
9663
  case CssDeclarationId::Flex: {
9036
9664
  CssCompiledValue compiled;
@@ -9164,16 +9792,16 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9164
9792
  applyBorderSideShorthand(node, 3, value, source);
9165
9793
  return true;
9166
9794
  case CssDeclarationId::BorderTopWidth:
9167
- if (const int width = parseBorderWidth(value, nodeId); width >= 0) setStyleValue(node, Property::BorderTopWidth, width, source);
9795
+ if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderTopWidth, width, source);
9168
9796
  return true;
9169
9797
  case CssDeclarationId::BorderRightWidth:
9170
- if (const int width = parseBorderWidth(value, nodeId); width >= 0) setStyleValue(node, Property::BorderRightWidth, width, source);
9798
+ if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderRightWidth, width, source);
9171
9799
  return true;
9172
9800
  case CssDeclarationId::BorderBottomWidth:
9173
- if (const int width = parseBorderWidth(value, nodeId); width >= 0) setStyleValue(node, Property::BorderBottomWidth, width, source);
9801
+ if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderBottomWidth, width, source);
9174
9802
  return true;
9175
9803
  case CssDeclarationId::BorderLeftWidth:
9176
- if (const int width = parseBorderWidth(value, nodeId); width >= 0) setStyleValue(node, Property::BorderLeftWidth, width, source);
9804
+ if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderLeftWidth, width, source);
9177
9805
  return true;
9178
9806
  case CssDeclarationId::BorderTopColor:
9179
9807
  applyBorderSideColorValue(node, 0, value, source);
@@ -9211,12 +9839,12 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9211
9839
  if (!parseFontShorthand(value, font)) return true;
9212
9840
  setStyleValue(node, Property::FontWeight, font.weight, source);
9213
9841
  setStyleValue(node, Property::FontId, fontFamilyValue(font.family), source);
9214
- setStyleValue(node, Property::FontSize, fontSizeValue(font.size, nodeId), source);
9842
+ setLengthStyleValue(node, font.size, Property::FontSize, fontSizeValue(font.size, nodeId), source);
9215
9843
  setAuthoredLineHeightValue(node, font.lineHeight, source);
9216
9844
  return true;
9217
9845
  }
9218
9846
  case CssDeclarationId::FontSize:
9219
- setStyleValue(node, Property::FontSize, fontSizeValue(value, nodeId), source);
9847
+ setLengthStyleValue(node, value, Property::FontSize, fontSizeValue(value, nodeId), source);
9220
9848
  return true;
9221
9849
  case CssDeclarationId::FontWeight:
9222
9850
  setStyleValue(node, Property::FontWeight, fontWeightValue(value), source);
@@ -9239,12 +9867,14 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9239
9867
  case CssDeclarationId::TextOverflow:
9240
9868
  setStyleValue(node, Property::TextOverflow, textOverflowValue(value), source);
9241
9869
  return true;
9870
+ #if GEA_CSS_TRANSFORMS
9242
9871
  case CssDeclarationId::TransformStyle: {
9243
9872
  const auto lower = toLowerAscii(trimCssValue(value));
9244
9873
  if (lower == "flat" || lower == "preserve-3d" || lower == "initial" || lower == "unset")
9245
9874
  setStyleValue(node, Property::TransformStyle, lower == "preserve-3d", source);
9246
9875
  return true;
9247
9876
  }
9877
+ #endif
9248
9878
  case CssDeclarationId::Visibility: {
9249
9879
  const int visibility = visibilityValue(value);
9250
9880
  if (visibility >= 0) setStyleValue(node, Property::Visibility, visibility, source);
@@ -9275,6 +9905,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9275
9905
  case CssDeclarationId::MaskImage:
9276
9906
  setStyleValue(node, Property::MaskRightFadeWidth, parseRightFadeMaskWidth(value, nodeId), source);
9277
9907
  return true;
9908
+ #if GEA_CSS_TRANSFORMS
9278
9909
  case CssDeclarationId::Translate: {
9279
9910
  std::string function;
9280
9911
  if (individualTranslateFunction(value, function)) setIndividualTranslation(node, parseTransformComponents(function, nodeId), source);
@@ -9295,6 +9926,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9295
9926
  setIndividualScale(node, scale, toLowerAscii(trimCssValue(value)) != "none", source);
9296
9927
  return true;
9297
9928
  }
9929
+ #endif
9298
9930
  case CssDeclarationId::Filter:
9299
9931
  setStyleValue(node, Property::FilterPresent, toLowerAscii(value).find("blur(") != std::string::npos, source);
9300
9932
  setStyleValue(node, Property::FilterBlur, parseFilterBlurRadius(value, nodeId), source);
@@ -9302,6 +9934,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9302
9934
  case CssDeclarationId::BoxShadow:
9303
9935
  applyBoxShadowValue(node, value, source);
9304
9936
  return true;
9937
+ #if GEA_CSS_TRANSFORMS
9305
9938
  case CssDeclarationId::TransformOrigin: {
9306
9939
  const auto parts = splitWords(value);
9307
9940
  setStyleValue(node, Property::TransformOriginX, parseOriginPart(parts.empty() ? "" : parts[0], 500), source);
@@ -9309,7 +9942,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9309
9942
  return true;
9310
9943
  }
9311
9944
  case CssDeclarationId::Perspective:
9312
- setStyleValue(node, Property::Perspective, parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
9945
+ setLengthStyleValue(node, value, Property::Perspective, parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
9313
9946
  return true;
9314
9947
  case CssDeclarationId::PerspectiveOrigin: {
9315
9948
  const auto parts = splitWords(value);
@@ -9317,6 +9950,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
9317
9950
  setStyleValue(node, Property::PerspectiveOriginY, parseOriginPart(parts.size() < 2 ? "" : parts[1], 500), source);
9318
9951
  return true;
9319
9952
  }
9953
+ #endif
9320
9954
  case CssDeclarationId::Unknown:
9321
9955
  case CssDeclarationId::Custom:
9322
9956
  return false;
@@ -9369,7 +10003,7 @@ void setCompiledSizeValue(NodeHandle node,
9369
10003
  if (resolved.isPercent)
9370
10004
  setStyleValue(node, percentProperty, roundToInt(resolved.value), source);
9371
10005
  else
9372
- setStyleValue(node, lengthProperty, roundToInt(resolved.value), source);
10006
+ setLengthStyleValue(node, length, lengthProperty, roundToInt(resolved.value), source);
9373
10007
  }
9374
10008
 
9375
10009
  void setCompiledPositionOffsetValue(NodeHandle node,
@@ -9383,7 +10017,7 @@ void setCompiledPositionOffsetValue(NodeHandle node,
9383
10017
  if (resolved.isPercent)
9384
10018
  setStyleValue(node, percentProperty, roundToInt(resolved.value), source);
9385
10019
  else
9386
- setStyleValue(node, lengthProperty, roundToInt(resolved.value), source);
10020
+ setLengthStyleValue(node, length, lengthProperty, roundToInt(resolved.value), source);
9387
10021
  }
9388
10022
 
9389
10023
  void setCompiledBorderRadiusCornerValue(NodeHandle node,
@@ -9395,7 +10029,7 @@ void setCompiledBorderRadiusCornerValue(NodeHandle node,
9395
10029
  if (resolved.isPercent)
9396
10030
  setStyleValue(node, borderRadiusPercentProperty(corner), roundToInt(resolved.value), source);
9397
10031
  else
9398
- setStyleValue(node, borderRadiusLengthProperty(corner), roundToInt(resolved.value), source);
10032
+ setLengthStyleValue(node, length, borderRadiusLengthProperty(corner), roundToInt(resolved.value), source);
9399
10033
  }
9400
10034
 
9401
10035
  void resolveCompiledTranslate(const CssLengthSpec &length,
@@ -9421,9 +10055,9 @@ TransformComponents transformFromCompiled(const CssCompiledValue &compiled, int
9421
10055
  t.rotateX = compiled.values[0];
9422
10056
  t.rotateY = compiled.values[1];
9423
10057
  t.rotateZ = compiled.values[2];
9424
- t.scaleX = compiled.values[8];
9425
- t.scaleY = compiled.values[9];
9426
- t.scaleZ = compiled.values[10];
10058
+ t.scaleX = compiled.values[3];
10059
+ t.scaleY = compiled.values[4];
10060
+ t.scaleZ = compiled.values[5];
9427
10061
  t.hasRotateX = (compiled.flags & (1u << 0)) != 0;
9428
10062
  t.hasRotateY = (compiled.flags & (1u << 1)) != 0;
9429
10063
  t.hasRotateZ = (compiled.flags & (1u << 2)) != 0;
@@ -9455,11 +10089,13 @@ bool applyCompiledColorValue(NodeHandle node,
9455
10089
  Node &target = treeState().nodes[nodeId];
9456
10090
  switch (declaration) {
9457
10091
  case CssDeclarationId::Color:
9458
- if (source == StyleApplicationSource::ClassRule && target.style.text_color == static_cast<style_color_t>(nativeColor) &&
9459
- target.style.text_alpha == static_cast<std::uint8_t>(alpha))
10092
+ if (source == StyleApplicationSource::ClassRule && target.computedStyle().text_color == static_cast<style_color_t>(nativeColor) &&
10093
+ target.computedStyle().text_alpha == static_cast<std::uint8_t>(alpha))
9460
10094
  return true;
9461
10095
  setStyleValueKnownTarget(node, target, Property::Color, styleColor, source);
10096
+ #if GEA_CSS_TEXT_ALPHA
9462
10097
  setStyleValueKnownTarget(node, target, Property::ColorAlpha, alpha, source);
10098
+ #endif
9463
10099
  markNodeDisplayCommandsDirtyForStyleApply(nodeId);
9464
10100
  return true;
9465
10101
  case CssDeclarationId::ActiveBackgroundColor:
@@ -9480,11 +10116,13 @@ bool applyCompiledColorValue(NodeHandle node,
9480
10116
  markNodeDisplayCommandsDirtyForStyleApply(nodeId);
9481
10117
  return true;
9482
10118
  case CssDeclarationId::BorderColor:
9483
- if (source == StyleApplicationSource::ClassRule && rstyle(target.style).border_color_flags == 16u && target.style.border_color == static_cast<style_color_t>(nativeColor) &&
9484
- target.style.border_alpha == static_cast<std::uint8_t>(alpha))
10119
+ if (source == StyleApplicationSource::ClassRule && target.computedStyle().border_color_flags == 16u && target.computedStyle().border_color == static_cast<style_color_t>(nativeColor) &&
10120
+ target.computedStyle().border_alpha == static_cast<std::uint8_t>(alpha))
9485
10121
  return true;
9486
10122
  setStyleValueKnownTarget(node, target, Property::BorderColor, styleColor, source);
10123
+ #if GEA_CSS_BORDER_ALPHA
9487
10124
  setStyleValue(node, Property::BorderAlpha, alpha, source);
10125
+ #endif
9488
10126
  markNodeDisplayCommandsDirtyForStyleApply(nodeId);
9489
10127
  return true;
9490
10128
  case CssDeclarationId::BorderTopColor:
@@ -9494,8 +10132,8 @@ bool applyCompiledColorValue(NodeHandle node,
9494
10132
  const int side = declaration == CssDeclarationId::BorderTopColor ? 0 :
9495
10133
  declaration == CssDeclarationId::BorderRightColor ? 1 :
9496
10134
  declaration == CssDeclarationId::BorderBottomColor ? 2 : 3;
9497
- const RareStyle &current = rstyle(target.style);
9498
- if (source == StyleApplicationSource::ClassRule && (current.border_color_flags & (1u << side)) && !borderColorIsCurrent(target.style, side) && current.border_side_color[side] == static_cast<style_color_t>(nativeColor) &&
10135
+ const RareStyle &current = rstyle(target.computedStyle());
10136
+ if (source == StyleApplicationSource::ClassRule && (target.computedStyle().border_color_flags & (1u << side)) && !borderColorIsCurrent(target.computedStyle(), side) && current.border_side_color[side] == static_cast<style_color_t>(nativeColor) &&
9499
10137
  current.border_side_alpha[side] == static_cast<std::uint8_t>(alpha))
9500
10138
  return true;
9501
10139
  setStyleValueKnownTarget(node, target, borderSideColorProperty(side), styleColor, source);
@@ -9535,7 +10173,7 @@ bool resolveCompiledColorRef(int nodeId,
9535
10173
  out.alpha = entry->colorAlpha;
9536
10174
  return true;
9537
10175
  }
9538
- const CachedCssColor color = cachedCssColorForValue(entry->value);
10176
+ const CachedCssColor color = cachedCssColorForValue(*entry->value);
9539
10177
  if (!color.valid) return false;
9540
10178
  out.styleColor = color.styleColor;
9541
10179
  out.nativeColor = static_cast<style_color_t>(color.nativeColor);
@@ -9624,6 +10262,7 @@ bool resolveCompiledRadialGradientColors(const CssCompiledRadialGradient &input,
9624
10262
 
9625
10263
  void applyCompiledLinearGradient(RareStyle &rs, const CssCompiledLinearGradient &gradient)
9626
10264
  {
10265
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9627
10266
  rs.bg_gradient_from_color = gradient.fromNativeColor;
9628
10267
  rs.bg_gradient_mid_color = gradient.midNativeColor;
9629
10268
  rs.bg_gradient_to_color = gradient.toNativeColor;
@@ -9634,10 +10273,12 @@ void applyCompiledLinearGradient(RareStyle &rs, const CssCompiledLinearGradient
9634
10273
  rs.bg_gradient_to_stop = gradient.toStopPermille;
9635
10274
  rs.bg_gradient_has_mid = gradient.hasMid;
9636
10275
  rs.bg_gradient_angle = gradient.angleTenths;
10276
+ #endif
9637
10277
  }
9638
10278
 
9639
10279
  void applyCompiledOverlayGradient(RareStyle &rs, const CssCompiledLinearGradient &gradient)
9640
10280
  {
10281
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9641
10282
  rs.bg_overlay_gradient = 1;
9642
10283
  rs.bg_overlay_gradient_from_color = gradient.fromNativeColor;
9643
10284
  rs.bg_overlay_gradient_mid_color = gradient.midNativeColor;
@@ -9649,10 +10290,12 @@ void applyCompiledOverlayGradient(RareStyle &rs, const CssCompiledLinearGradient
9649
10290
  rs.bg_overlay_gradient_to_stop = gradient.toStopPermille;
9650
10291
  rs.bg_overlay_gradient_has_mid = gradient.hasMid;
9651
10292
  rs.bg_overlay_gradient_angle = gradient.angleTenths;
10293
+ #endif
9652
10294
  }
9653
10295
 
9654
10296
  void applyCompiledRadialGradient(RareStyle &rs, const CssCompiledRadialGradient &gradient)
9655
10297
  {
10298
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9656
10299
  rs.bg_radial_gradient = 1;
9657
10300
  rs.bg_radial_gradient_from_color = gradient.fromNativeColor;
9658
10301
  rs.bg_radial_gradient_to_color = gradient.toNativeColor;
@@ -9663,6 +10306,7 @@ void applyCompiledRadialGradient(RareStyle &rs, const CssCompiledRadialGradient
9663
10306
  rs.bg_radial_gradient_cy = gradient.cyPermille;
9664
10307
  rs.bg_radial_gradient_rx = gradient.rxPermille;
9665
10308
  rs.bg_radial_gradient_ry = gradient.ryPermille;
10309
+ #endif
9666
10310
  }
9667
10311
 
9668
10312
  bool compiledLinearGradientMatches(const RareStyle &rs, const CssCompiledLinearGradient &gradient)
@@ -9763,11 +10407,18 @@ bool applyBackgroundImageToStyle(ComputedStyle &style, int handle, int nodeId)
9763
10407
  (!axes || (current.bg_grid_color == background->gridColor && current.bg_grid_alpha == background->gridAlpha &&
9764
10408
  current.bg_grid_line_x == lineX && current.bg_grid_line_y == lineY))) return false;
9765
10409
  RareStyle &rs = rstyleMut(style);
10410
+ #if GEA_CSS_BACKGROUND_LAYERS
9766
10411
  rs.bg_image_layer_count = background ? background->layerCount : 1;
10412
+ #endif
10413
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9767
10414
  rs.bg_gradient_layer = background ? background->gradientLayer : 0;
9768
10415
  rs.bg_overlay_gradient_layer = background ? background->overlayLayer : 0;
9769
10416
  rs.bg_radial_gradient_layer = background ? background->radialLayer : 0;
10417
+ #endif
10418
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
9770
10419
  style.bg_fill = background && background->hasGradient ? 1 : 0;
10420
+ #endif
10421
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9771
10422
  rs.bg_gradient_has_mid = 0;
9772
10423
  rs.bg_overlay_gradient = 0;
9773
10424
  rs.bg_radial_gradient = 0;
@@ -9775,16 +10426,19 @@ bool applyBackgroundImageToStyle(ComputedStyle &style, int handle, int nodeId)
9775
10426
  rs.bg_grid_color = 0;
9776
10427
  rs.bg_grid_alpha = 255;
9777
10428
  rs.bg_grid_line_x = rs.bg_grid_line_y = 0;
10429
+ #endif
9778
10430
  if (background) {
9779
10431
  if (background->hasGradient) applyCompiledLinearGradient(rs, gradient);
9780
10432
  if (background->hasOverlayGradient) applyCompiledOverlayGradient(rs, overlay);
9781
10433
  if (background->hasRadialGradient) applyCompiledRadialGradient(rs, radial);
10434
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9782
10435
  rs.bg_grid_axes = background->gridAxes;
9783
10436
  rs.bg_grid_color = background->gridColor;
9784
10437
  rs.bg_grid_alpha = background->gridAlpha;
9785
10438
  rs.bg_grid_axes = axes;
9786
10439
  rs.bg_grid_line_x = lineX;
9787
10440
  rs.bg_grid_line_y = lineY;
10441
+ #endif
9788
10442
  }
9789
10443
  return true;
9790
10444
  }
@@ -9855,35 +10509,37 @@ bool applyRuntimeLengthValue(NodeHandle node,
9855
10509
  }
9856
10510
  switch (declaration) {
9857
10511
  case CssDeclarationId::Gap:
9858
- setStyleValue(node, Property::Gap, length.unit == CssLengthUnit::Percent ? 0 : resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source);
9859
- if (length.unit == CssLengthUnit::Percent) {
9860
- setStyleValue(node, Property::RowGapPercent, roundToInt(length.value * 10.0), source);
9861
- setStyleValue(node, Property::ColumnGapPercent, roundToInt(length.value * 10.0), source);
9862
- }
9863
- return true;
9864
- case CssDeclarationId::MinWidth: setStyleValue(node, Property::MinWidth, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
9865
- case CssDeclarationId::MinHeight: setStyleValue(node, Property::MinHeight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
9866
- case CssDeclarationId::MaxWidth: setStyleValue(node, Property::MaxWidth, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
9867
- case CssDeclarationId::MaxHeight: setStyleValue(node, Property::MaxHeight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
9868
- case CssDeclarationId::PaddingTop: setStyleValue(node, Property::PaddingTop, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
9869
- case CssDeclarationId::PaddingRight: setStyleValue(node, Property::PaddingRight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
9870
- case CssDeclarationId::PaddingBottom: setStyleValue(node, Property::PaddingBottom, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
9871
- case CssDeclarationId::PaddingLeft: setStyleValue(node, Property::PaddingLeft, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
9872
- case CssDeclarationId::MarginTop: setStyleValue(node, Property::MarginTop, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
9873
- case CssDeclarationId::MarginRight: setStyleValue(node, Property::MarginRight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
9874
- case CssDeclarationId::MarginBottom: setStyleValue(node, Property::MarginBottom, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
9875
- case CssDeclarationId::MarginLeft: setStyleValue(node, Property::MarginLeft, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
9876
- case CssDeclarationId::BorderWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setUniformBorderWidth(node, width, source); return true;
9877
- case CssDeclarationId::BorderTopWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setStyleValue(node, Property::BorderTopWidth, width, source); return true;
9878
- case CssDeclarationId::BorderRightWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setStyleValue(node, Property::BorderRightWidth, width, source); return true;
9879
- case CssDeclarationId::BorderBottomWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setStyleValue(node, Property::BorderBottomWidth, width, source); return true;
9880
- case CssDeclarationId::BorderLeftWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setStyleValue(node, Property::BorderLeftWidth, width, source); return true;
10512
+ setGapLengthValues(node, declaration, length, length, source);
10513
+ return true;
10514
+ case CssDeclarationId::MinWidth: setLengthStyleValue(node, length, Property::MinWidth, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10515
+ case CssDeclarationId::MinHeight: setLengthStyleValue(node, length, Property::MinHeight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
10516
+ case CssDeclarationId::MaxWidth: setLengthStyleValue(node, length, Property::MaxWidth, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10517
+ case CssDeclarationId::MaxHeight: setLengthStyleValue(node, length, Property::MaxHeight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
10518
+ case CssDeclarationId::PaddingTop: setLengthStyleValue(node, length, Property::PaddingTop, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
10519
+ case CssDeclarationId::PaddingRight: setLengthStyleValue(node, length, Property::PaddingRight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10520
+ case CssDeclarationId::PaddingBottom: setLengthStyleValue(node, length, Property::PaddingBottom, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
10521
+ case CssDeclarationId::PaddingLeft: setLengthStyleValue(node, length, Property::PaddingLeft, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10522
+ case CssDeclarationId::MarginTop: setLengthStyleValue(node, length, Property::MarginTop, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
10523
+ case CssDeclarationId::MarginRight: setLengthStyleValue(node, length, Property::MarginRight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10524
+ case CssDeclarationId::MarginBottom: setLengthStyleValue(node, length, Property::MarginBottom, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
10525
+ case CssDeclarationId::MarginLeft: setLengthStyleValue(node, length, Property::MarginLeft, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10526
+ case CssDeclarationId::BorderWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) {
10527
+ setUniformBorderWidth(node, width, source);
10528
+ if (source == StyleApplicationSource::Inline && length.unit == CssLengthUnit::Px)
10529
+ ensureRareData(node.id()).inlineStyles.setCssPixels(Property::BorderWidth, length.value);
10530
+ } return true;
10531
+ case CssDeclarationId::BorderTopWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderTopWidth, width, source); return true;
10532
+ case CssDeclarationId::BorderRightWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderRightWidth, width, source); return true;
10533
+ case CssDeclarationId::BorderBottomWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderBottomWidth, width, source); return true;
10534
+ case CssDeclarationId::BorderLeftWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderLeftWidth, width, source); return true;
9881
10535
  case CssDeclarationId::FontSize:
9882
- setStyleValue(node, Property::FontSize, resolveFontSizeLength(length, nodeId), source);
10536
+ setLengthStyleValue(node, length, Property::FontSize, resolveFontSizeLength(length, nodeId), source);
9883
10537
  return true;
9884
- case CssDeclarationId::Perspective: setStyleValue(node, Property::Perspective, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10538
+ #if GEA_CSS_TRANSFORMS
10539
+ case CssDeclarationId::Perspective: setLengthStyleValue(node, length, Property::Perspective, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
10540
+ #endif
9885
10541
  case CssDeclarationId::MaskImage:
9886
- setStyleValue(node,
10542
+ setLengthStyleValue(node, length,
9887
10543
  Property::MaskRightFadeWidth,
9888
10544
  std::max(0, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal)),
9889
10545
  source);
@@ -9987,12 +10643,14 @@ bool applyRuntimeBackgroundSizeValue(NodeHandle node,
9987
10643
  auto &state = treeState();
9988
10644
  if (nodeId < 0 || nodeId >= state.nodeCount) return true;
9989
10645
  Node &target = state.nodes[nodeId];
9990
- if (rstyle(target.style).bg_grid_axes == 0) return true;
10646
+ if (rstyle(target.computedStyle()).bg_grid_axes == 0) return true;
9991
10647
  const int stepX = resolveCompiledLengthForNode(stepXLength, nodeId, LengthAxis::Horizontal);
9992
10648
  const int stepY = resolveCompiledLengthForNode(stepYLength, nodeId, LengthAxis::Vertical);
9993
- RareStyle &rs = rstyleMut(target.style);
10649
+ RareStyle &rs = rstyleMut(target.mutableStyle());
10650
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
9994
10651
  if (stepX > 0) rs.bg_grid_step_x = static_cast<std::uint16_t>(std::min(stepX, 65535));
9995
10652
  if (stepY > 0) rs.bg_grid_step_y = static_cast<std::uint16_t>(std::min(stepY, 65535));
10653
+ #endif
9996
10654
  markNodeDisplayCommandsDirtyForStyleApply(nodeId);
9997
10655
  return true;
9998
10656
  }
@@ -10018,11 +10676,15 @@ bool applyRuntimeBorderShorthandValue(NodeHandle node,
10018
10676
  const int snappedWidth = resolveBorderWidth(width, nodeId);
10019
10677
  if (snappedWidth < 0) return true;
10020
10678
  setUniformBorderWidth(node, snappedWidth, source);
10679
+ if (source == StyleApplicationSource::Inline && width.unit == CssLengthUnit::Px)
10680
+ ensureRareData(node.id()).inlineStyles.setCssPixels(Property::BorderWidth, width.value);
10021
10681
  for (int side = 0; side < 4; ++side)
10022
10682
  setStyleValue(node, static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side), relief, source);
10023
10683
  if (alpha >= 0) {
10024
10684
  setStyleValue(node, Property::BorderColor, color, source);
10685
+ #if GEA_CSS_BORDER_ALPHA
10025
10686
  setStyleValue(node, Property::BorderAlpha, alpha, source);
10687
+ #endif
10026
10688
  markNodeDisplayCommandsDirtyForStyleApply(nodeId);
10027
10689
  } else setStyleValue(node, Property::BorderColorCurrent, 1, source);
10028
10690
  return true;
@@ -10085,7 +10747,7 @@ bool applyCompiledBorderRadiusValue(NodeHandle node, const CssCompiledValue &com
10085
10747
  {
10086
10748
  if (!node || compiled.kind != CssCompiledKind::BorderRadius) return false;
10087
10749
  if (compiled.declaration == CssDeclarationId::BorderRadius) {
10088
- for (int corner = 0; corner < 4; ++corner)
10750
+ for (int corner = 0; corner < GEA_CSS_RADIUS_COUNT; ++corner)
10089
10751
  setCompiledBorderRadiusCornerValue(node, corner, compiled.lengths[corner], source);
10090
10752
  return true;
10091
10753
  }
@@ -10215,6 +10877,9 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10215
10877
  if (!node) return true;
10216
10878
  const int nodeId = node.id();
10217
10879
  switch (compiled.kind) {
10880
+ #if !GEA_CSS_GRID
10881
+ case CssCompiledKind::GridTemplate: return false;
10882
+ #endif
10218
10883
  case CssCompiledKind::Noop:
10219
10884
  return true;
10220
10885
  case CssCompiledKind::DirectProperty: {
@@ -10224,13 +10889,13 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10224
10889
  return true;
10225
10890
  }
10226
10891
  case CssCompiledKind::DirectPropertyGroup: {
10227
- int count = compiled.values[0];
10892
+ int count = compiled.aux;
10228
10893
  if (count < 0) count = 0;
10229
10894
  if (count > 4) count = 4;
10230
10895
  for (int i = 0; i < count; ++i) {
10231
- const int propertyIndex = compiled.values[1 + i * 2];
10896
+ const int propertyIndex = compiled.values[i * 2];
10232
10897
  if (propertyIndex < 0 || propertyIndex >= static_cast<int>(Property::Count)) return false;
10233
- setStyleValue(node, static_cast<Property>(propertyIndex), compiled.values[2 + i * 2], source);
10898
+ setStyleValue(node, static_cast<Property>(propertyIndex), compiled.values[1 + i * 2], source);
10234
10899
  }
10235
10900
  return true;
10236
10901
  }
@@ -10245,10 +10910,12 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10245
10910
  case CssDeclarationId::JustifyItems: setStyleValue(node, Property::JustifyItems, compiled.values[0], source); return true;
10246
10911
  case CssDeclarationId::AlignContent: setStyleValue(node, Property::AlignContent, compiled.values[0], source); return true;
10247
10912
  case CssDeclarationId::JustifySelf: setStyleValue(node, Property::JustifySelf, compiled.values[0], source); return true;
10913
+ #if GEA_CSS_GRID
10248
10914
  case CssDeclarationId::GridRowStart: setStyleValue(node, Property::GridRowStart, compiled.values[0], source); return true;
10249
10915
  case CssDeclarationId::GridColumnStart: setStyleValue(node, Property::GridColumnStart, compiled.values[0], source); return true;
10250
10916
  case CssDeclarationId::GridRowEnd: setStyleValue(node, Property::GridRowEnd, compiled.values[0], source); return true;
10251
10917
  case CssDeclarationId::GridColumnEnd: setStyleValue(node, Property::GridColumnEnd, compiled.values[0], source); return true;
10918
+ #endif
10252
10919
  case CssDeclarationId::AlignSelf: setStyleValue(node, Property::AlignSelf, compiled.values[0], source); return true;
10253
10920
  case CssDeclarationId::Position: setStyleValue(node, Property::Position, compiled.values[0], source); return true;
10254
10921
  case CssDeclarationId::TextAlign: setStyleValue(node, Property::TextAlign, compiled.values[0], source); return true;
@@ -10256,7 +10923,9 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10256
10923
  case CssDeclarationId::TextTransform: setStyleValue(node, Property::TextTransform, compiled.values[0], source); return true;
10257
10924
  case CssDeclarationId::WhiteSpace: setStyleValue(node, Property::WhiteSpace, compiled.values[0], source); return true;
10258
10925
  case CssDeclarationId::TextOverflow: setStyleValue(node, Property::TextOverflow, compiled.values[0], source); return true;
10926
+ #if GEA_CSS_TRANSFORMS
10259
10927
  case CssDeclarationId::TransformStyle: setStyleValue(node, Property::TransformStyle, compiled.values[0], source); return true;
10928
+ #endif
10260
10929
  case CssDeclarationId::Visibility: setStyleValue(node, Property::Visibility, compiled.values[0], source); return true;
10261
10930
  case CssDeclarationId::BackfaceVisibility: setStyleValue(node, Property::Backface, compiled.values[0], source); return true;
10262
10931
  case CssDeclarationId::PointerEvents: setStyleValue(node, Property::PointerEvents, compiled.values[0], source); return true;
@@ -10317,7 +10986,7 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10317
10986
  color.alpha = entry->colorAlpha;
10318
10987
  color.valid = true;
10319
10988
  } else {
10320
- color = cachedCssColorForValue(entry->value);
10989
+ color = cachedCssColorForValue(*entry->value);
10321
10990
  }
10322
10991
  if (color.valid)
10323
10992
  return applyCompiledColorValue(node,
@@ -10379,6 +11048,7 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10379
11048
  return applyCompiledFilterBlurValue(node, compiled, source);
10380
11049
  case CssCompiledKind::BoxShadow:
10381
11050
  return applyCompiledBoxShadowValue(node, compiled, source);
11051
+ #if GEA_CSS_GRID
10382
11052
  case CssCompiledKind::GridTemplate: {
10383
11053
  const CssCompiledGridTemplate *grid =
10384
11054
  compiledCssGridTemplateForHandle(static_cast<std::uint16_t>(compiled.values[0]));
@@ -10393,6 +11063,7 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
10393
11063
  }
10394
11064
  return false;
10395
11065
  }
11066
+ #endif
10396
11067
  case CssCompiledKind::LineHeight:
10397
11068
  return applyCompiledLineHeightValue(node, compiled, source);
10398
11069
  case CssCompiledKind::None:
@@ -10469,6 +11140,37 @@ const CssCompiledValue *inlineCompiledStyleValueFor(CssDeclarationId declaration
10469
11140
  #endif
10470
11141
  }
10471
11142
 
11143
+ // Unitless integers use rawNumber, exactly as parseLengthForNode does.
11144
+ // Units, fractions, expressions and values outside this exact range retain
11145
+ // the general parser (including px device-pixel-ratio conversion).
11146
+ bool applyIntegerPosition(NodeHandle node, CssDeclarationId declaration,
11147
+ const std::string &text, StyleApplicationSource source)
11148
+ {
11149
+ Property property;
11150
+ switch (declaration) {
11151
+ case CssDeclarationId::Top: property = Property::Top; break;
11152
+ case CssDeclarationId::Right: property = Property::Right; break;
11153
+ case CssDeclarationId::Bottom: property = Property::Bottom; break;
11154
+ case CssDeclarationId::Left: property = Property::Left; break;
11155
+ default: return false;
11156
+ }
11157
+ if (text.empty()) return false;
11158
+ std::size_t index = (text[0] == '-' || text[0] == '+') ? 1 : 0;
11159
+ if (index == text.size()) return false;
11160
+ int value = 0;
11161
+ for (; index < text.size(); ++index) {
11162
+ const unsigned digit = static_cast<unsigned char>(text[index]) - '0';
11163
+ if (digit > 9) return false;
11164
+ value = value * 10 + static_cast<int>(digit);
11165
+ if (value > 32767) return false;
11166
+ }
11167
+ #if GEA_EMBEDDED_UI_REFRESH_PERF
11168
+ refreshPerfStatsMutable().treeIntegerPositionFastCalls++;
11169
+ #endif
11170
+ setStyleValue(node, property, rawNumber(text[0] == '-' ? -value : value), source);
11171
+ return true;
11172
+ }
11173
+
10472
11174
  void applyPropertyWithSource(NodeHandle node,
10473
11175
  CssDeclarationId declaration,
10474
11176
  const std::string &rawValue,
@@ -10477,6 +11179,8 @@ void applyPropertyWithSource(NodeHandle node,
10477
11179
  if (!node) return;
10478
11180
  const int nodeId = node.id();
10479
11181
  if (declaration == CssDeclarationId::Unknown) return;
11182
+ if (applyIntegerPosition(node, declaration, rawValue, source)) return;
11183
+ #if GEA_CSS_GRID
10480
11184
  if (source == StyleApplicationSource::Inline &&
10481
11185
  (declaration == CssDeclarationId::GridTemplateColumns || declaration == CssDeclarationId::GridTemplateRows ||
10482
11186
  declaration == CssDeclarationId::Grid || declaration == CssDeclarationId::GridTemplate)) {
@@ -10491,6 +11195,7 @@ void applyPropertyWithSource(NodeHandle node,
10491
11195
  if (mask & (1 << axis)) rare.inlineGridTemplates[axis] = internCssAtom(rawValue);
10492
11196
  rare.inlineGridShorthandMask = (rare.inlineGridShorthandMask & ~mask) | (shorthand ? mask : 0);
10493
11197
  }
11198
+ #endif
10494
11199
  if (declaration == CssDeclarationId::FlexBasis && rawValue.find("var(") != std::string::npos) {
10495
11200
  if (const CssLengthSpec *length = cachedCompiledCssLengthSpec(rawValue)) {
10496
11201
  setFlexBasisValue(node, true, *length, source);
@@ -10514,6 +11219,22 @@ void applyPropertyWithSource(NodeHandle node,
10514
11219
  const int64_t _vt = recNow();
10515
11220
  #endif
10516
11221
  const bool directValue = rawValue.find("var(") == std::string::npos && isTrimmedCssValue(rawValue);
11222
+ // A whole-value var() compiles like the same declaration in a rule, so it
11223
+ // reads a static custom color's native value; that entry has no text to
11224
+ // substitute. Anything the compiled form cannot apply falls back below.
11225
+ if (!directValue && isTrimmedCssValue(rawValue) && rawValue.rfind("var(", 0) == 0 && rawValue.back() == ')' &&
11226
+ (declaration == CssDeclarationId::Color || declaration == CssDeclarationId::BackgroundColor ||
11227
+ declaration == CssDeclarationId::Background || declaration == CssDeclarationId::ActiveBackgroundColor ||
11228
+ declaration == CssDeclarationId::BorderColor || declaration == CssDeclarationId::BorderTopColor ||
11229
+ declaration == CssDeclarationId::BorderRightColor || declaration == CssDeclarationId::BorderBottomColor ||
11230
+ declaration == CssDeclarationId::BorderLeftColor)) {
11231
+ CssCompiledValue colorVar;
11232
+ colorVar.declaration = declaration;
11233
+ if (compileColorVarValue(rawValue, colorVar)) {
11234
+ colorVar.kind = CssCompiledKind::ColorVar;
11235
+ if (applyCompiledCssValueWithSource(node, colorVar, source)) return;
11236
+ }
11237
+ }
10517
11238
  const CssCompiledValue *compiledValue = directValue
10518
11239
  ? inlineCompiledStyleValueFor(declaration, rawValue)
10519
11240
  : nullptr;
@@ -10525,7 +11246,7 @@ void applyPropertyWithSource(NodeHandle node,
10525
11246
  const int64_t _bt = recNow();
10526
11247
  struct BodyTimer { int64_t s; ~BodyTimer() { g_profBodyUs += recNow() - s; } } _bodyTimer{_bt};
10527
11248
  #endif
10528
- if (compiledValue && applyCompiledCssValueWithSource(node, *compiledValue, source)) return;
11249
+ if (directValue && compiledValue && applyCompiledCssValueWithSource(node, *compiledValue, source)) return;
10529
11250
  const std::string &value = directValue ? rawValue : resolvedValue;
10530
11251
  (void)applyKnownResolvedPropertyWithSource(node, declaration, value, source);
10531
11252
  }
@@ -10612,6 +11333,7 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
10612
11333
  {
10613
11334
  if (!node) return false;
10614
11335
  if (property.rfind("--", 0) == 0) {
11336
+ #if GEA_CSS_CUSTOM_PROPERTIES
10615
11337
  NodeRareData *rare = rareDataFor(node.id());
10616
11338
  if (!rare) return false;
10617
11339
  auto &values = rare->inlineCustomProperties.values;
@@ -10621,8 +11343,12 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
10621
11343
  values.erase(end, values.end());
10622
11344
  recomputeSubtreeClassStyles(node.id());
10623
11345
  return true;
11346
+ #else
11347
+ return false;
11348
+ #endif
10624
11349
  }
10625
11350
  const int id = node.id();
11351
+ #if GEA_CSS_GRID
10626
11352
  if (property == "grid" || property == "grid-template") {
10627
11353
  NodeRareData *rare = rareDataFor(id);
10628
11354
  if (!rare || (rare->inlineGridTemplates[0] == kInvalidCssAtom && rare->inlineGridTemplates[1] == kInvalidCssAtom)) return false;
@@ -10631,6 +11357,8 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
10631
11357
  recomputeSubtreeClassStyles(id);
10632
11358
  return true;
10633
11359
  }
11360
+ #endif
11361
+ #if GEA_CSS_GRID
10634
11362
  if (property == "grid-template-columns" || property == "grid-template-rows") {
10635
11363
  NodeRareData *rare = rareDataFor(id);
10636
11364
  const int axis = property == "grid-template-rows" ? 1 : 0;
@@ -10640,6 +11368,7 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
10640
11368
  recomputeSubtreeClassStyles(id);
10641
11369
  return true;
10642
11370
  }
11371
+ #endif
10643
11372
  if (property == "font") return removeInlineStyleProperties(id, {Property::FontId, Property::FontSize, Property::FontWeight, Property::LineHeight, Property::LineHeightExpression, Property::LineHeightMultiplier});
10644
11373
  if (property == "display") return removeInlineStyleProperties(id, {Property::Display});
10645
11374
  if (property == "contain") return removeInlineStyleProperties(id, {Property::Containment});
@@ -10822,6 +11551,7 @@ void replayInlineStyles(int node)
10822
11551
  const NodeStyleOverride &entry = rd->inlineStyles.at(i);
10823
11552
  Tree::instance().setStyleFromClass(node, entry.property, entry.value);
10824
11553
  }
11554
+ #if GEA_CSS_GRID
10825
11555
  if (const NodeRareData *rd = rareDataFor(node)) {
10826
11556
  // Copy the atoms before replay: resolving authored values can touch
10827
11557
  // pooled style storage. Resolve variables and font-relative tracks anew.
@@ -10839,6 +11569,7 @@ void replayInlineStyles(int node)
10839
11569
  value, StyleApplicationSource::ClassRule);
10840
11570
  }
10841
11571
  }
11572
+ #endif
10842
11573
  }
10843
11574
 
10844
11575
  void applyDefaultStyleOverrides(int node)
@@ -10852,6 +11583,7 @@ void applyDefaultStyleOverrides(int node)
10852
11583
  }
10853
11584
  }
10854
11585
 
11586
+ #if GEA_CSS_PSEUDO_ELEMENTS
10855
11587
  int16_t g_pseudoBeforeTagId = -1;
10856
11588
  int16_t g_pseudoAfterTagId = -1;
10857
11589
 
@@ -10878,6 +11610,10 @@ bool isGeneratedPseudoNode(const Node &node)
10878
11610
  return tag == pseudoBeforeTagId() || tag == pseudoAfterTagId();
10879
11611
  }
10880
11612
 
11613
+ #else
11614
+ constexpr bool isGeneratedPseudoNode(const Node &) { return false; }
11615
+ #endif
11616
+
10881
11617
  std::string normalizeSelectorText(const std::string &selector)
10882
11618
  {
10883
11619
  std::string out = trimCssValue(selector);
@@ -11001,7 +11737,7 @@ bool equalsLiteral(const char *text, std::size_t length, const char *literal)
11001
11737
  struct ParsedSimpleSelector {
11002
11738
  int16_t tagId = -1;
11003
11739
  CssAtomId idAtom = kInvalidCssAtom;
11004
- SmallSelectorList<CssAtomId, 4> classIds;
11740
+ [[no_unique_address]] SmallSelectorList<CssAtomId, 4> classIds;
11005
11741
  bool hasTag = false;
11006
11742
  bool wantsRoot = false;
11007
11743
  bool wantsFirstChild = false;
@@ -11070,20 +11806,22 @@ ParsedSimpleSelector parseSimpleSelector(const char *rawSimple, std::size_t rawL
11070
11806
  }
11071
11807
 
11072
11808
  struct SelectorPart {
11073
- ParsedSimpleSelector simple;
11809
+ [[no_unique_address]] ParsedSimpleSelector simple;
11074
11810
  bool directParent = false;
11075
11811
  };
11076
11812
 
11077
11813
  struct SelectorPlan {
11078
- SmallSelectorList<SelectorPart, 4> parts;
11079
- SmallSelectorList<CssAtomId, 4> ancestorClasses;
11080
- SmallSelectorList<int16_t, 4> ancestorTags;
11814
+ // The lists have nontrivial ownership and trailing padding. Let adjacent
11815
+ // scalar fields occupy that padding without changing any access path.
11816
+ [[no_unique_address]] SmallSelectorList<SelectorPart, 4> parts;
11817
+ bool rightmostRoot = false;
11818
+ bool valid = true;
11819
+ [[no_unique_address]] SmallSelectorList<CssAtomId, 4> ancestorClasses;
11081
11820
  CssAtomId rightmostId = kInvalidCssAtom;
11821
+ [[no_unique_address]] SmallSelectorList<int16_t, 4> ancestorTags;
11082
11822
  CssAtomId rightmostClass = kInvalidCssAtom;
11083
11823
  int16_t rightmostTag = -1;
11084
11824
  int specificity = 0;
11085
- bool rightmostRoot = false;
11086
- bool valid = true;
11087
11825
  };
11088
11826
 
11089
11827
  template <typename T>
@@ -11828,6 +12566,7 @@ bool ruleMediaMatchesUncached(const CssRule &rule)
11828
12566
  return mediaConditionMatches(cssRuleTextForHandle(rule.mediaText));
11829
12567
  }
11830
12568
 
12569
+ #if GEA_CSS_PSEUDO_ELEMENTS
11831
12570
  int findPseudoChild(int parent, CssRule::PseudoElement pseudo)
11832
12571
  {
11833
12572
  const int16_t tag = pseudoTagId(pseudo);
@@ -11874,7 +12613,12 @@ int ensurePseudoChild(int parent, CssRule::PseudoElement pseudo)
11874
12613
  return child;
11875
12614
  }
11876
12615
 
11877
- static constexpr std::size_t kRuleCandidateCacheClassCapacity = 6;
12616
+ #endif
12617
+
12618
+ // The class-list proof also bounds cache keys. Unknown/overflow-capable apps
12619
+ // retain the six-token fast key and the existing uncached fallback beyond it.
12620
+ static constexpr std::size_t kRuleCandidateCacheClassCapacity =
12621
+ GEA_UI_CLASS_OVERFLOW ? 6 : std::min<std::size_t>(6, GEA_UI_CLASS_INLINE_TOKENS);
11878
12622
 
11879
12623
  struct RuleCandidateSignature {
11880
12624
  CssAtomId classes[kRuleCandidateCacheClassCapacity]{};
@@ -12059,7 +12803,9 @@ struct RuleIndex {
12059
12803
  DenseRuleBuckets selByTag;
12060
12804
  std::vector<int> selRoot;
12061
12805
  std::vector<int> selAlways;
12806
+ #if GEA_CSS_ANIMATIONS
12062
12807
  std::vector<int> animationRules; // rules with property == "animation" (any selector type)
12808
+ #endif
12063
12809
  RuleCandidateCacheStore candidateCache;
12064
12810
  // Classes/tags that appear in a NON-rightmost simple selector of any complex rule
12065
12811
  // (i.e. as an ancestor matcher, like `.theme-night` in `.theme-night .icon`).
@@ -12151,7 +12897,9 @@ void rebuildRuleIndexIfNeeded()
12151
12897
  g_ruleIndex.selByTag.clear();
12152
12898
  g_ruleIndex.selRoot.clear();
12153
12899
  g_ruleIndex.selAlways.clear();
12900
+ #if GEA_CSS_ANIMATIONS
12154
12901
  g_ruleIndex.animationRules.clear();
12902
+ #endif
12155
12903
  g_ruleIndex.candidateCache.clear();
12156
12904
  ruleCandidateCacheLastHit() = static_cast<std::size_t>(-1);
12157
12905
  clearActiveRulePlanCache();
@@ -12223,7 +12971,9 @@ void rebuildRuleIndexIfNeeded()
12223
12971
  list[i].pseudoElement == CssRule::PseudoElement::After ||
12224
12972
  list[i].pseudoElement == CssRule::PseudoElement::FirstLine)
12225
12973
  g_ruleIndex.hasPseudoElementRules = true;
12974
+ #if GEA_CSS_ANIMATIONS
12226
12975
  if (list[i].propertyKind == CssRuleProperty::Animation) g_ruleIndex.animationRules.push_back(i);
12976
+ #endif
12227
12977
  }
12228
12978
  g_ruleIndex.byClass.finalize();
12229
12979
  g_ruleIndex.byTag.finalize();
@@ -12289,18 +13039,45 @@ CssAtomId nodeIdAttributeAtom(int node)
12289
13039
  }
12290
13040
 
12291
13041
  enum ActiveRuleBucket : std::uint8_t {
13042
+ #if GEA_CSS_CUSTOM_PROPERTIES
12292
13043
  kActiveMainCustom,
13044
+ #endif
12293
13045
  kActiveMainRule,
13046
+ #if GEA_CSS_PSEUDO_ELEMENTS
13047
+ #if GEA_CSS_CUSTOM_PROPERTIES
12294
13048
  kActiveBeforeCustom,
13049
+ #endif
12295
13050
  kActiveBeforeRule,
13051
+ #if GEA_CSS_CUSTOM_PROPERTIES
12296
13052
  kActiveAfterCustom,
13053
+ #endif
12297
13054
  kActiveAfterRule,
13055
+ #endif
13056
+ #if GEA_CSS_FIRST_LINE
13057
+ #if GEA_CSS_CUSTOM_PROPERTIES
12298
13058
  kActiveFirstLineCustom,
13059
+ #endif
12299
13060
  kActiveFirstLineRule,
13061
+ #endif
13062
+ #if GEA_CSS_ANIMATIONS
12300
13063
  kActiveAnimation,
13064
+ #endif
12301
13065
  kActiveRuleBucketCount
12302
13066
  };
12303
13067
 
13068
+ #if !GEA_CSS_CUSTOM_PROPERTIES
13069
+ // Bucket readers already treat negative IDs as empty. Keep that contract
13070
+ // without reserving a bucket, count or offset for an absent CSS feature.
13071
+ static constexpr int kActiveMainCustom = -1;
13072
+ #if GEA_CSS_PSEUDO_ELEMENTS
13073
+ static constexpr int kActiveBeforeCustom = -1;
13074
+ static constexpr int kActiveAfterCustom = -1;
13075
+ #endif
13076
+ #if GEA_CSS_FIRST_LINE
13077
+ static constexpr int kActiveFirstLineCustom = -1;
13078
+ #endif
13079
+ #endif
13080
+
12304
13081
  struct ActiveRulePlanCacheEntry;
12305
13082
 
12306
13083
  struct ActiveRulePlan {
@@ -12439,7 +13216,11 @@ struct CachedStyleApplyOp {
12439
13216
  std::uint8_t borderRelief = 0;
12440
13217
  std::uint8_t properties[kCachedStyleApplyOpPropertyCapacity]{};
12441
13218
  std::int32_t values[kCachedStyleApplyOpPropertyCapacity]{};
13219
+ #if GEA_CSS_TRANSFORMS
12442
13220
  std::int16_t transform[kCachedTransformValueCount]{};
13221
+ #else
13222
+ static constexpr std::int16_t transform[kCachedTransformValueCount]{};
13223
+ #endif
12443
13224
  };
12444
13225
 
12445
13226
  class CachedStyleApplyOpStore {
@@ -12823,7 +13604,9 @@ bool addCachedLengthDeclaration(CachedStyleApplyOp &op, CssDeclarationId declara
12823
13604
  case CssDeclarationId::BorderBottomWidth: return addCachedStyleApplyProperty(op, Property::BorderBottomWidth, value);
12824
13605
  case CssDeclarationId::BorderLeftWidth: return addCachedStyleApplyProperty(op, Property::BorderLeftWidth, value);
12825
13606
  case CssDeclarationId::FontSize: return addCachedStyleApplyProperty(op, Property::FontSize, value);
13607
+ #if GEA_CSS_TRANSFORMS
12826
13608
  case CssDeclarationId::Perspective: return addCachedStyleApplyProperty(op, Property::Perspective, value);
13609
+ #endif
12827
13610
  case CssDeclarationId::MaskImage:
12828
13611
  return addCachedStyleApplyProperty(op, Property::MaskRightFadeWidth, std::max(0, value));
12829
13612
  default:
@@ -12884,7 +13667,7 @@ bool addCachedBorderRadiusDeclaration(CachedStyleApplyOp &op,
12884
13667
  const CssCompiledValue &compiled)
12885
13668
  {
12886
13669
  if (declaration == CssDeclarationId::BorderRadius) {
12887
- for (int corner = 0; corner < 4; ++corner)
13670
+ for (int corner = 0; corner < GEA_CSS_RADIUS_COUNT; ++corner)
12888
13671
  if (!addCachedBorderRadiusCorner(op, corner, compiled.lengths[corner])) return false;
12889
13672
  return true;
12890
13673
  }
@@ -12946,10 +13729,12 @@ bool addCachedKeywordDeclaration(CachedStyleApplyOp &op, CssDeclarationId declar
12946
13729
  case CssDeclarationId::JustifyItems: return addCachedStyleApplyProperty(op, Property::JustifyItems, value);
12947
13730
  case CssDeclarationId::AlignContent: return addCachedStyleApplyProperty(op, Property::AlignContent, value);
12948
13731
  case CssDeclarationId::JustifySelf: return addCachedStyleApplyProperty(op, Property::JustifySelf, value);
13732
+ #if GEA_CSS_GRID
12949
13733
  case CssDeclarationId::GridRowStart: return addCachedStyleApplyProperty(op, Property::GridRowStart, value);
12950
13734
  case CssDeclarationId::GridColumnStart: return addCachedStyleApplyProperty(op, Property::GridColumnStart, value);
12951
13735
  case CssDeclarationId::GridRowEnd: return addCachedStyleApplyProperty(op, Property::GridRowEnd, value);
12952
13736
  case CssDeclarationId::GridColumnEnd: return addCachedStyleApplyProperty(op, Property::GridColumnEnd, value);
13737
+ #endif
12953
13738
  case CssDeclarationId::AlignSelf: return addCachedStyleApplyProperty(op, Property::AlignSelf, value);
12954
13739
  case CssDeclarationId::Position: return addCachedStyleApplyProperty(op, Property::Position, value);
12955
13740
  case CssDeclarationId::TextAlign: return addCachedStyleApplyProperty(op, Property::TextAlign, value);
@@ -12957,7 +13742,9 @@ bool addCachedKeywordDeclaration(CachedStyleApplyOp &op, CssDeclarationId declar
12957
13742
  case CssDeclarationId::TextTransform: return addCachedStyleApplyProperty(op, Property::TextTransform, value);
12958
13743
  case CssDeclarationId::WhiteSpace: return addCachedStyleApplyProperty(op, Property::WhiteSpace, value);
12959
13744
  case CssDeclarationId::TextOverflow: return addCachedStyleApplyProperty(op, Property::TextOverflow, value);
13745
+ #if GEA_CSS_TRANSFORMS
12960
13746
  case CssDeclarationId::TransformStyle: return addCachedStyleApplyProperty(op, Property::TransformStyle, value);
13747
+ #endif
12961
13748
  case CssDeclarationId::Visibility: return addCachedStyleApplyProperty(op, Property::Visibility, value);
12962
13749
  case CssDeclarationId::BackfaceVisibility: return addCachedStyleApplyProperty(op, Property::Backface, value);
12963
13750
  case CssDeclarationId::PointerEvents: return addCachedStyleApplyProperty(op, Property::PointerEvents, value);
@@ -12988,14 +13775,15 @@ bool cachedTransformTranslateValue(const CssLengthSpec &length,
12988
13775
 
12989
13776
  bool buildCachedTransformApplyOp(const CssCompiledValue &compiled, CachedStyleApplyOp &op)
12990
13777
  {
13778
+ #if GEA_CSS_TRANSFORMS
12991
13779
  if (compiled.kind != CssCompiledKind::Transform) return false;
12992
13780
  TransformComponents transform;
12993
13781
  transform.rotateX = compiled.values[0];
12994
13782
  transform.rotateY = compiled.values[1];
12995
13783
  transform.rotateZ = compiled.values[2];
12996
- transform.scaleX = compiled.values[8];
12997
- transform.scaleY = compiled.values[9];
12998
- transform.scaleZ = compiled.values[10];
13784
+ transform.scaleX = compiled.values[3];
13785
+ transform.scaleY = compiled.values[4];
13786
+ transform.scaleZ = compiled.values[5];
12999
13787
  if ((compiled.flags & (1u << 3)) != 0 &&
13000
13788
  !cachedTransformTranslateValue(compiled.lengths[0], true, transform.translateX, transform.translateXPercent))
13001
13789
  return false;
@@ -13023,6 +13811,9 @@ bool buildCachedTransformApplyOp(const CssCompiledValue &compiled, CachedStyleAp
13023
13811
  op.transform[9] = cachedInt16Value(transform.scaleY);
13024
13812
  op.transform[10] = cachedInt16Value(transform.scaleZ);
13025
13813
  return true;
13814
+ #else
13815
+ (void)compiled; (void)op; return false;
13816
+ #endif
13026
13817
  }
13027
13818
 
13028
13819
  bool buildCachedCompiledTransformApplyOp(const CssCompiledValue &compiled, CachedStyleApplyOp &op)
@@ -13191,14 +13982,14 @@ bool buildCachedStyleApplyOp(const CssCompiledValue *compiled, CachedStyleApplyO
13191
13982
  return addCachedStyleApplyProperty(op, static_cast<Property>(propertyIndex), compiled->values[1]);
13192
13983
  }
13193
13984
  case CssCompiledKind::DirectPropertyGroup: {
13194
- int count = compiled->values[0];
13985
+ int count = compiled->aux;
13195
13986
  if (count < 0 || count > static_cast<int>(kCachedStyleApplyOpPropertyCapacity)) return false;
13196
13987
  for (int i = 0; i < count; ++i) {
13197
- const int propertyIndex = compiled->values[1 + i * 2];
13988
+ const int propertyIndex = compiled->values[i * 2];
13198
13989
  if (propertyIndex < 0 || propertyIndex >= static_cast<int>(Property::Count)) return false;
13199
13990
  if (!addCachedStyleApplyProperty(op,
13200
13991
  static_cast<Property>(propertyIndex),
13201
- compiled->values[2 + i * 2])) return false;
13992
+ compiled->values[1 + i * 2])) return false;
13202
13993
  }
13203
13994
  return op.propertyCount != 0;
13204
13995
  }
@@ -13271,8 +14062,10 @@ bool buildCachedStyleApplyOp(const CssCompiledValue *compiled, CachedStyleApplyO
13271
14062
  case CssCompiledKind::BackgroundSize:
13272
14063
  if (buildCachedBackgroundSizeApplyOp(*compiled, op)) return true;
13273
14064
  return buildRuntimeBackgroundSizeApplyOp(*compiled, op);
14065
+ #if GEA_CSS_GRID
13274
14066
  case CssCompiledKind::GridTemplate:
13275
14067
  return buildCachedGridTemplateApplyOp(*compiled, op);
14068
+ #endif
13276
14069
  case CssCompiledKind::LineHeight:
13277
14070
  if (compiled->aux == 0 && addCachedStyleApplyProperty(op, Property::LineHeight, 0)) return true;
13278
14071
  op = CachedStyleApplyOp{};
@@ -13375,8 +14168,10 @@ bool cachedStyleApplyOpsEqual(const CachedStyleApplyOp &a, const CachedStyleAppl
13375
14168
  return true;
13376
14169
  if (a.kind == CachedStyleApplyOpKind::Transform) {
13377
14170
  if (a.values[0] != b.values[0] || a.values[1] != b.values[1]) return false;
14171
+ #if GEA_CSS_TRANSFORMS
13378
14172
  for (std::uint8_t i = 0; i < kCachedTransformValueCount; ++i)
13379
14173
  if (a.transform[i] != b.transform[i]) return false;
14174
+ #endif
13380
14175
  return true;
13381
14176
  }
13382
14177
  if (a.kind == CachedStyleApplyOpKind::CompiledTransform)
@@ -13630,9 +14425,11 @@ void addPropertyWrite(PropertyWriteMask &mask, Property property)
13630
14425
  if (property == borderSideColorProperty(side) || property == current) { mask.add(current); mask.add(borderSideColorProperty(side)); mask.add(static_cast<Property>(static_cast<int>(Property::BorderTopAlpha) + side)); return; }
13631
14426
  }
13632
14427
  switch (property) {
14428
+ #if GEA_CSS_BORDER_RELIEF
13633
14429
  case Property::BorderRelief:
13634
14430
  for (int side = 0; side < 4; ++side) mask.add(static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side));
13635
14431
  return;
14432
+ #endif
13636
14433
  case Property::BorderWidth:
13637
14434
  mask.add(property);
13638
14435
  for (int side = 0; side < 4; ++side) mask.add(borderSideWidthProperty(side));
@@ -13810,6 +14607,9 @@ bool addColorDeclarationWrites(CssDeclarationId declaration, PropertyWriteMask &
13810
14607
  bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask &mask)
13811
14608
  {
13812
14609
  switch (compiled.kind) {
14610
+ #if !GEA_CSS_GRID
14611
+ case CssCompiledKind::GridTemplate: return false;
14612
+ #endif
13813
14613
  case CssCompiledKind::Noop:
13814
14614
  return true;
13815
14615
  case CssCompiledKind::DirectProperty: {
@@ -13819,11 +14619,11 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
13819
14619
  return true;
13820
14620
  }
13821
14621
  case CssCompiledKind::DirectPropertyGroup: {
13822
- int count = compiled.values[0];
14622
+ int count = compiled.aux;
13823
14623
  if (count < 0) count = 0;
13824
14624
  if (count > 4) count = 4;
13825
14625
  for (int i = 0; i < count; ++i) {
13826
- const int propertyIndex = compiled.values[1 + i * 2];
14626
+ const int propertyIndex = compiled.values[i * 2];
13827
14627
  if (propertyIndex < 0 || propertyIndex >= static_cast<int>(Property::Count)) return false;
13828
14628
  addPropertyWrite(mask, static_cast<Property>(propertyIndex));
13829
14629
  }
@@ -13840,10 +14640,12 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
13840
14640
  case CssDeclarationId::JustifyItems: addPropertyWrite(mask, Property::JustifyItems); return true;
13841
14641
  case CssDeclarationId::AlignContent: addPropertyWrite(mask, Property::AlignContent); return true;
13842
14642
  case CssDeclarationId::JustifySelf: addPropertyWrite(mask, Property::JustifySelf); return true;
14643
+ #if GEA_CSS_GRID
13843
14644
  case CssDeclarationId::GridRowStart: addPropertyWrite(mask, Property::GridRowStart); return true;
13844
14645
  case CssDeclarationId::GridColumnStart: addPropertyWrite(mask, Property::GridColumnStart); return true;
13845
14646
  case CssDeclarationId::GridRowEnd: addPropertyWrite(mask, Property::GridRowEnd); return true;
13846
14647
  case CssDeclarationId::GridColumnEnd: addPropertyWrite(mask, Property::GridColumnEnd); return true;
14648
+ #endif
13847
14649
  case CssDeclarationId::AlignSelf: addPropertyWrite(mask, Property::AlignSelf); return true;
13848
14650
  case CssDeclarationId::Position: addPropertyWrite(mask, Property::Position); return true;
13849
14651
  case CssDeclarationId::TextAlign: addPropertyWrite(mask, Property::TextAlign); return true;
@@ -13851,7 +14653,9 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
13851
14653
  case CssDeclarationId::TextTransform: addPropertyWrite(mask, Property::TextTransform); return true;
13852
14654
  case CssDeclarationId::WhiteSpace: addPropertyWrite(mask, Property::WhiteSpace); return true;
13853
14655
  case CssDeclarationId::TextOverflow: addPropertyWrite(mask, Property::TextOverflow); return true;
14656
+ #if GEA_CSS_TRANSFORMS
13854
14657
  case CssDeclarationId::TransformStyle: addPropertyWrite(mask, Property::TransformStyle); return true;
14658
+ #endif
13855
14659
  case CssDeclarationId::Visibility: addPropertyWrite(mask, Property::Visibility); return true;
13856
14660
  case CssDeclarationId::BackfaceVisibility: addPropertyWrite(mask, Property::Backface); return true;
13857
14661
  case CssDeclarationId::PointerEvents: addPropertyWrite(mask, Property::PointerEvents); return true;
@@ -13915,7 +14719,9 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
13915
14719
  case CssDeclarationId::BorderBottomWidth: addPropertyWrite(mask, Property::BorderBottomWidth); return true;
13916
14720
  case CssDeclarationId::BorderLeftWidth: addPropertyWrite(mask, Property::BorderLeftWidth); return true;
13917
14721
  case CssDeclarationId::FontSize: addPropertyWrite(mask, Property::FontSize); return true;
14722
+ #if GEA_CSS_TRANSFORMS
13918
14723
  case CssDeclarationId::Perspective: addPropertyWrite(mask, Property::Perspective); return true;
14724
+ #endif
13919
14725
  case CssDeclarationId::MaskImage: addPropertyWrite(mask, Property::MaskRightFadeWidth); return true;
13920
14726
  default: return false;
13921
14727
  }
@@ -14025,7 +14831,7 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
14025
14831
  }
14026
14832
  case CssCompiledKind::BorderRadius:
14027
14833
  if (compiled.declaration == CssDeclarationId::BorderRadius) {
14028
- for (int corner = 0; corner < 4; ++corner)
14834
+ for (int corner = 0; corner < GEA_CSS_RADIUS_COUNT; ++corner)
14029
14835
  addPropertyWrite(mask, borderRadiusLengthProperty(corner));
14030
14836
  return true;
14031
14837
  }
@@ -14053,6 +14859,7 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
14053
14859
  case CssCompiledKind::BoxShadow:
14054
14860
  addBoxShadowPropertyWrites(mask);
14055
14861
  return true;
14862
+ #if GEA_CSS_GRID
14056
14863
  case CssCompiledKind::GridTemplate:
14057
14864
  if (compiled.declaration == CssDeclarationId::GridTemplateColumns) {
14058
14865
  mask.addIndex(kVirtualGridTemplateColumnsWrite);
@@ -14063,6 +14870,7 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
14063
14870
  return true;
14064
14871
  }
14065
14872
  return false;
14873
+ #endif
14066
14874
  case CssCompiledKind::LineHeight:
14067
14875
  addPropertyWrite(mask, Property::LineHeight);
14068
14876
  return true;
@@ -14115,9 +14923,13 @@ void collapseShadowedActiveRuleBucket(ActiveRulePlan::Bucket &bucket)
14115
14923
  void collapseShadowedActiveRules(ActiveRulePlan &plan)
14116
14924
  {
14117
14925
  collapseShadowedActiveRuleBucket(plan.buckets[kActiveMainRule]);
14926
+ #if GEA_CSS_PSEUDO_ELEMENTS
14118
14927
  collapseShadowedActiveRuleBucket(plan.buckets[kActiveBeforeRule]);
14119
14928
  collapseShadowedActiveRuleBucket(plan.buckets[kActiveAfterRule]);
14929
+ #endif
14930
+ #if GEA_CSS_FIRST_LINE
14120
14931
  collapseShadowedActiveRuleBucket(plan.buckets[kActiveFirstLineRule]);
14932
+ #endif
14121
14933
  }
14122
14934
 
14123
14935
  int activeRuleBucketFor(const CssRule &rule)
@@ -14128,11 +14940,23 @@ int activeRuleBucketFor(const CssRule &rule)
14128
14940
  case CssRule::PseudoElement::None:
14129
14941
  return custom ? kActiveMainCustom : kActiveMainRule;
14130
14942
  case CssRule::PseudoElement::Before:
14943
+ #if GEA_CSS_PSEUDO_ELEMENTS
14131
14944
  return custom ? kActiveBeforeCustom : kActiveBeforeRule;
14945
+ #else
14946
+ return -1;
14947
+ #endif
14132
14948
  case CssRule::PseudoElement::After:
14949
+ #if GEA_CSS_PSEUDO_ELEMENTS
14133
14950
  return custom ? kActiveAfterCustom : kActiveAfterRule;
14951
+ #else
14952
+ return -1;
14953
+ #endif
14134
14954
  case CssRule::PseudoElement::FirstLine:
14955
+ #if GEA_CSS_FIRST_LINE
14135
14956
  return custom ? kActiveFirstLineCustom : kActiveFirstLineRule;
14957
+ #else
14958
+ return -1;
14959
+ #endif
14136
14960
  case CssRule::PseudoElement::Unsupported:
14137
14961
  return -1;
14138
14962
  }
@@ -14287,9 +15111,11 @@ void addCachedActiveCandidateRule(ActiveRulePlan &plan,
14287
15111
  }
14288
15112
  const int bucket = activeRuleBucketFor(rule);
14289
15113
  if (bucket >= 0) plan.push(bucket, ruleIndex);
15114
+ #if GEA_CSS_ANIMATIONS
14290
15115
  if (rule.propertyKind == CssRuleProperty::Animation &&
14291
15116
  rule.pseudoElement == CssRule::PseudoElement::None)
14292
15117
  plan.push(kActiveAnimation, ruleIndex);
15118
+ #endif
14293
15119
  }
14294
15120
 
14295
15121
  void addActiveCandidateRule(ActiveRulePlan &plan,
@@ -14312,9 +15138,11 @@ void addActiveCandidateRule(ActiveRulePlan &plan,
14312
15138
  if (rule.selectorType == CssRule::SelectorType::Selector && !selectorMatchesNode(rule, selectorNode)) return;
14313
15139
  const int bucket = activeRuleBucketFor(rule);
14314
15140
  if (bucket >= 0) plan.push(bucket, ruleIndex);
15141
+ #if GEA_CSS_ANIMATIONS
14315
15142
  if (rule.propertyKind == CssRuleProperty::Animation &&
14316
15143
  rule.pseudoElement == CssRule::PseudoElement::None)
14317
15144
  plan.push(kActiveAnimation, ruleIndex);
15145
+ #endif
14318
15146
  }
14319
15147
 
14320
15148
  void addActiveCandidateRuleBucket(ActiveRulePlan &plan,
@@ -14465,10 +15293,12 @@ bool applyCachedStyleApplyOpWithSource(NodeHandle node,
14465
15293
  auto &state = treeState();
14466
15294
  if (nodeId < 0 || nodeId >= state.nodeCount) return true;
14467
15295
  Node &target = state.nodes[nodeId];
14468
- if (rstyle(target.style).bg_grid_axes == 0) return true;
14469
- RareStyle &rs = rstyleMut(target.style);
15296
+ if (rstyle(target.computedStyle()).bg_grid_axes == 0) return true;
15297
+ RareStyle &rs = rstyleMut(target.mutableStyle());
15298
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
14470
15299
  if (op.values[0] > 0) rs.bg_grid_step_x = static_cast<std::uint16_t>(op.values[0]);
14471
15300
  if (op.values[1] > 0) rs.bg_grid_step_y = static_cast<std::uint16_t>(op.values[1]);
15301
+ #endif
14472
15302
  markNodeDisplayCommandsDirtyForStyleApply(nodeId);
14473
15303
  return true;
14474
15304
  }
@@ -14671,7 +15501,11 @@ void applyActiveRuleSpanToNode(int node, const ActiveRulePlan &plan, int bucketI
14671
15501
 
14672
15502
  void applyActiveRuleSpansToNode(int node, const ActiveRulePlan &plan, int customBucket, int ruleBucket)
14673
15503
  {
15504
+ #if GEA_CSS_CUSTOM_PROPERTIES
14674
15505
  applyActiveRuleSpanToNode(node, plan, customBucket);
15506
+ #else
15507
+ (void)customBucket;
15508
+ #endif
14675
15509
  // Resolve the font cascade before any property consumes its metrics. Keep
14676
15510
  // the winning font fixed while replaying the ordinary cascade so intervening
14677
15511
  // font declarations cannot change the basis of a padding/line-height/length.
@@ -14686,9 +15520,11 @@ void applyActiveRuleSpansToNode(int node, const ActiveRulePlan &plan, int custom
14686
15520
  g_resolvedFontNode = node;
14687
15521
  // Inherited unitless numbers are resolved against this element's final font.
14688
15522
  // Lengths and percentages inherit their already-computed pixel value.
14689
- auto &style = treeState().nodes[node].style;
15523
+ auto &style = treeState().nodes[node].mutableStyle();
15524
+ #if GEA_CSS_LINE_HEIGHT
14690
15525
  if (style.line_height_multiplier >= 0)
14691
15526
  style.line_height = resolveLineHeightMultiplier(node, style.line_height_multiplier);
15527
+ #endif
14692
15528
  // lh consumers need the winning line-height, evaluated using the final font.
14693
15529
  applyActiveRuleSpanToNode(node, plan, ruleBucket, 2);
14694
15530
  if (const NodeRareData *rd = rareDataFor(node))
@@ -14705,6 +15541,7 @@ void applyActiveRuleSpansToNode(int node, const ActiveRulePlan &plan, int custom
14705
15541
 
14706
15542
  void applyFirstLineBackground(int node, const ActiveRulePlan &plan)
14707
15543
  {
15544
+ #if GEA_CSS_FIRST_LINE
14708
15545
  NodeRareData *rare = rareDataFor(node);
14709
15546
  const FirstLineBackground previous = rare ? rare->firstLineBackground : FirstLineBackground{};
14710
15547
  if (rare) rare->firstLineBackground = FirstLineBackground{};
@@ -14736,7 +15573,7 @@ void applyFirstLineBackground(int node, const ActiveRulePlan &plan)
14736
15573
  color.alpha = entry->colorAlpha;
14737
15574
  color.valid = true;
14738
15575
  } else {
14739
- color = cachedCssColorForValue(entry->value);
15576
+ color = cachedCssColorForValue(*entry->value);
14740
15577
  }
14741
15578
  if (color.valid) {
14742
15579
  rare->firstLineBackground.color = color.nativeColor;
@@ -14776,17 +15613,15 @@ void applyFirstLineBackground(int node, const ActiveRulePlan &plan)
14776
15613
  rare->firstLineBackground.lineContextNode = previous.lineContextNode;
14777
15614
  rare->firstLineBackground.lineValid = previous.lineValid;
14778
15615
  }
15616
+ #else
15617
+ (void)node;
15618
+ (void)plan;
15619
+ #endif
14779
15620
  }
14780
15621
 
14781
- void syncPseudoElementsForNode(int node, const ActiveRulePlan *existingPlan = nullptr)
15622
+ #if GEA_CSS_PSEUDO_ELEMENTS
15623
+ void syncPseudoElementsForNode(int node, const ActiveRulePlan &plan)
14782
15624
  {
14783
- ActiveRulePlan ownedPlan;
14784
- const ActiveRulePlan *plan = existingPlan;
14785
- if (!plan) {
14786
- buildActiveRulePlanForNode(node, ownedPlan);
14787
- plan = &ownedPlan;
14788
- }
14789
-
14790
15625
  const struct {
14791
15626
  CssRule::PseudoElement pseudo;
14792
15627
  int customBucket;
@@ -14796,7 +15631,7 @@ void syncPseudoElementsForNode(int node, const ActiveRulePlan *existingPlan = nu
14796
15631
  {CssRule::PseudoElement::After, kActiveAfterCustom, kActiveAfterRule},
14797
15632
  };
14798
15633
  for (const auto &entry : pseudoBuckets) {
14799
- const bool hasMatchingRule = plan->has(entry.customBucket) || plan->has(entry.ruleBucket);
15634
+ const bool hasMatchingRule = plan.has(entry.customBucket) || plan.has(entry.ruleBucket);
14800
15635
  if (!hasMatchingRule) {
14801
15636
  const int stalePseudoNode = findPseudoChild(node, entry.pseudo);
14802
15637
  if (stalePseudoNode >= 0) Tree::instance().removeNode(stalePseudoNode);
@@ -14806,34 +15641,46 @@ void syncPseudoElementsForNode(int node, const ActiveRulePlan *existingPlan = nu
14806
15641
  if (pseudoNode < 0) continue;
14807
15642
  if (NodeRareData *rd = rareDataFor(pseudoNode)) rd->customProperties.clear();
14808
15643
  clearCustomPropertyLookupCache();
14809
- int16_t staleRareStyle = treeState().nodes[pseudoNode].style.rare_style;
15644
+ int16_t staleRareStyle = treeState().nodes[pseudoNode].computedStyle().rare_style;
14810
15645
  Tree::instance().resetStyleForClassRecompute(pseudoNode);
14811
- if (staleRareStyle >= 0 && treeState().nodes[pseudoNode].style.rare_style != staleRareStyle)
15646
+ if (staleRareStyle >= 0 && treeState().nodes[pseudoNode].computedStyle().rare_style != staleRareStyle)
14812
15647
  releaseRareStyle(staleRareStyle);
14813
15648
  applyInheritedStyleDefaults(pseudoNode);
14814
15649
  applyDefaultStyleOverrides(pseudoNode);
14815
- applyActiveRuleSpansToNode(pseudoNode, *plan, entry.customBucket, entry.ruleBucket);
15650
+ applyActiveRuleSpansToNode(pseudoNode, plan, entry.customBucket, entry.ruleBucket);
14816
15651
  replayInlineStyles(pseudoNode);
14817
15652
  }
14818
15653
  }
14819
15654
 
15655
+ #endif
15656
+
14820
15657
  void recomputeNodeClassStyles(int node)
14821
15658
  {
14822
15659
  auto &state = treeState();
14823
15660
  if (node < 0 || node >= state.nodeCount) return;
14824
15661
 
14825
- const ComputedStyle beforeStyle = state.nodes[node].style;
15662
+ const ComputedStyle beforeStyle = state.nodes[node].computedStyle();
15663
+ #if GEA_CSS_FIRST_LINE
14826
15664
  const FirstLineBackground beforeFirstLine = rareDataFor(node)
14827
15665
  ? rareDataFor(node)->firstLineBackground : FirstLineBackground{};
15666
+ #endif
14828
15667
  int16_t staleRareStyle = beforeStyle.rare_style;
14829
15668
  const int beforeImageId = state.nodes[node].image_id;
14830
15669
  state.styleInvalidationSuppressionDepth++;
14831
15670
  // Record this node's custom-property dependencies fresh (lookupCustomProperty
14832
15671
  // appends into g_nodeRefs[g_recordingNode] for every var() resolved here,
14833
15672
  // including the node's pseudo-elements via syncPseudoElementsForNode below).
15673
+ #if GEA_CSS_CUSTOM_PROPERTIES
14834
15674
  const int prevRecordingNode = g_recordingNode;
14835
15675
  g_recordingNode = node;
15676
+ #endif
15677
+ #if GEA_CSS_CUSTOM_PROPERTIES
14836
15678
  if (node >= 0 && node < kMaxNodes) g_nodeRefs[node].clearForRecompute();
15679
+ #elif GEA_EMBEDDED_SHARED_STYLES
15680
+ state.nodes[node].class_style_tracked = true;
15681
+ #else
15682
+ g_nodeStyleTracked[node] = true;
15683
+ #endif
14837
15684
  #if GEA_RECPROF
14838
15685
  g_profNodes++;
14839
15686
  int64_t _t = recNow();
@@ -14859,40 +15706,55 @@ void recomputeNodeClassStyles(int node)
14859
15706
  _t = recNow();
14860
15707
  #endif
14861
15708
  replayInlineStyles(node);
15709
+ #if GEA_CSS_FIRST_LINE
14862
15710
  applyFirstLineBackground(node, activePlan);
14863
15711
  const FirstLineBackground afterFirstLine = rareDataFor(node)
14864
15712
  ? rareDataFor(node)->firstLineBackground : FirstLineBackground{};
14865
15713
  const bool firstLineChanged = beforeFirstLine.hasColor != afterFirstLine.hasColor ||
14866
15714
  beforeFirstLine.color != afterFirstLine.color ||
14867
15715
  beforeFirstLine.alpha != afterFirstLine.alpha;
15716
+ #else
15717
+ constexpr bool firstLineChanged = false;
15718
+ #endif
14868
15719
  // Inline overrides store expression handles, not a newly evaluated pixel
14869
15720
  // value. Seed used edges before diffing so custom/font changes schedule
14870
15721
  // layout even when the expression handle itself is unchanged.
15722
+ #if GEA_CSS_BOX_EXPRESSIONS
14871
15723
  resolveLayoutBoxLengths(node, percentBasisForNode(node, LengthAxis::Horizontal));
15724
+ #endif
15725
+ #if GEA_CSS_ANIMATIONS
14872
15726
  primeCssAnimationsForNode(node, &activePlan);
15727
+ #endif
14873
15728
  // A runtime `src` attribute's image id is NOT class-derived, so the reset
14874
15729
  // above must not lose it: restore it unless a class rule supplied its own
14875
15730
  // image. (Re-resolving from the attribute instead would re-read and
14876
15731
  // re-decode the file — e.g. a full-page EPUB cover from the SD card — on
14877
15732
  // every recompute of the node or any ancestor.)
15733
+ #if GEA_UI_IMAGE_NODES
14878
15734
  if (state.nodes[node].type == NodeType::Image && state.nodes[node].image_id < 0 &&
14879
15735
  beforeImageId >= 0 && Tree::instance().hasAttribute(node, "src"))
14880
15736
  state.nodes[node].image_id = beforeImageId;
15737
+ #endif
14881
15738
  state.styleInvalidationSuppressionDepth--;
14882
15739
  markClassRecomputeStyleDiff(node, beforeStyle, beforeImageId, firstLineChanged);
14883
- if (staleRareStyle >= 0 && state.nodes[node].style.rare_style != staleRareStyle)
15740
+ if (staleRareStyle >= 0 && state.nodes[node].computedStyle().rare_style != staleRareStyle)
14884
15741
  releaseRareStyle(staleRareStyle);
14885
15742
  #if GEA_RECPROF
14886
15743
  g_profMiscUs += recNow() - _t;
14887
15744
  _t = recNow();
14888
15745
  #endif
15746
+ #if GEA_CSS_PSEUDO_ELEMENTS
14889
15747
  if (!isGeneratedPseudoNode(state.nodes[node]) &&
14890
15748
  (g_ruleIndex.hasPseudoElementRules || nodeHasGeneratedPseudoChild(node)))
14891
- syncPseudoElementsForNode(node, &activePlan);
15749
+ syncPseudoElementsForNode(node, activePlan);
15750
+ #endif
14892
15751
  #if GEA_RECPROF
14893
15752
  g_profPseudoUs += recNow() - _t;
14894
15753
  #endif
15754
+ state.nodes[node].internComputedStyle();
15755
+ #if GEA_CSS_CUSTOM_PROPERTIES
14895
15756
  g_recordingNode = prevRecordingNode;
15757
+ #endif
14896
15758
  }
14897
15759
 
14898
15760
  // When set (during the initial app mount), per-op class-style recomputes are
@@ -14940,27 +15802,92 @@ void recomputeDescendantClassStyles(int node)
14940
15802
  // applyInheritedStyleDefaults) or via explicit border-width inheritance.
14941
15803
  struct ParentStyleSnapshot {
14942
15804
  style_color_t text_color;
15805
+ #if GEA_CSS_TEXT_ALPHA
14943
15806
  std::uint8_t text_alpha;
15807
+ #else
15808
+ static constexpr std::uint8_t text_alpha = 255;
15809
+ #endif
14944
15810
  std::int16_t font_id;
14945
- std::int16_t font_size;
15811
+ decltype(ComputedStyle::font_size) font_size;
15812
+ #if GEA_CSS_FONT_WEIGHT
14946
15813
  std::int16_t font_weight;
14947
- std::int16_t line_height;
15814
+ #else
15815
+ static constexpr std::int16_t font_weight = 400;
15816
+ #endif
15817
+ #if GEA_CSS_LINE_HEIGHT
15818
+ decltype(ComputedStyle::line_height) line_height;
15819
+ #else
15820
+ static constexpr std::int16_t line_height = 0;
15821
+ #endif
15822
+ #if GEA_CSS_LINE_HEIGHT_MULTIPLIER
14948
15823
  std::int32_t line_height_multiplier;
15824
+ #else
15825
+ static constexpr std::int32_t line_height_multiplier = -1;
15826
+ #endif
15827
+ #if GEA_CSS_TEXT_ALIGN
14949
15828
  std::uint8_t text_align;
15829
+ #else
15830
+ static constexpr std::uint8_t text_align = 0;
15831
+ #endif
15832
+ #if GEA_CSS_TEXT_TRANSFORM
14950
15833
  std::uint8_t text_transform;
15834
+ #else
15835
+ static constexpr std::uint8_t text_transform = 0;
15836
+ #endif
15837
+ #if GEA_CSS_WHITE_SPACE
14951
15838
  std::uint8_t white_space;
15839
+ #else
15840
+ static constexpr std::uint8_t white_space = 0;
15841
+ #endif
15842
+ #if GEA_CSS_VISIBILITY
14952
15843
  std::uint8_t visibility;
15844
+ #else
15845
+ static constexpr std::uint8_t visibility = 0;
15846
+ #endif
15847
+ #if GEA_CSS_SIDE_BORDERS
14953
15848
  std::array<int, 4> border_widths;
15849
+ #else
15850
+ std::array<std::remove_cv_t<decltype(ComputedStyle::border_width)>, 1> border_widths;
15851
+ #endif
14954
15852
  };
14955
15853
 
14956
15854
  ParentStyleSnapshot snapshotParentStyle(const ComputedStyle &s)
14957
15855
  {
14958
- return ParentStyleSnapshot{s.text_color, s.text_alpha, static_cast<std::int16_t>(s.font_id),
14959
- static_cast<std::int16_t>(s.font_size), static_cast<std::int16_t>(s.font_weight),
14960
- static_cast<std::int16_t>(s.line_height), s.line_height_multiplier,
14961
- static_cast<std::uint8_t>(s.text_align), static_cast<std::uint8_t>(s.text_transform),
14962
- static_cast<std::uint8_t>(s.white_space), static_cast<std::uint8_t>(s.visibility),
14963
- {computedBorderWidth(s, 0), computedBorderWidth(s, 1), computedBorderWidth(s, 2), computedBorderWidth(s, 3)}};
15856
+ ParentStyleSnapshot out;
15857
+ out.text_color = s.text_color;
15858
+ #if GEA_CSS_TEXT_ALPHA
15859
+ out.text_alpha = s.text_alpha;
15860
+ #endif
15861
+ out.font_id = s.font_id;
15862
+ out.font_size = s.font_size;
15863
+ #if GEA_CSS_FONT_WEIGHT
15864
+ out.font_weight = s.font_weight;
15865
+ #endif
15866
+ #if GEA_CSS_LINE_HEIGHT
15867
+ out.line_height = s.line_height;
15868
+ #endif
15869
+ #if GEA_CSS_LINE_HEIGHT_MULTIPLIER
15870
+ out.line_height_multiplier = s.line_height_multiplier;
15871
+ #endif
15872
+ #if GEA_CSS_TEXT_ALIGN
15873
+ out.text_align = s.text_align;
15874
+ #endif
15875
+ #if GEA_CSS_TEXT_TRANSFORM
15876
+ out.text_transform = s.text_transform;
15877
+ #endif
15878
+ #if GEA_CSS_WHITE_SPACE
15879
+ out.white_space = s.white_space;
15880
+ #endif
15881
+ #if GEA_CSS_VISIBILITY
15882
+ out.visibility = s.visibility;
15883
+ #endif
15884
+ #if GEA_CSS_SIDE_BORDERS
15885
+ out.border_widths = {computedBorderWidth(s, 0), computedBorderWidth(s, 1),
15886
+ computedBorderWidth(s, 2), computedBorderWidth(s, 3)};
15887
+ #else
15888
+ out.border_widths = {s.border_width};
15889
+ #endif
15890
+ return out;
14964
15891
  }
14965
15892
 
14966
15893
  bool parentStylesDiffer(const ParentStyleSnapshot &a, const ParentStyleSnapshot &b)
@@ -14997,7 +15924,10 @@ bool classChangeAffectsDescendants(int node)
14997
15924
  }
14998
15925
 
14999
15926
  struct NodeClassSnapshot {
15000
- static constexpr std::size_t kInlineCount = 8;
15927
+ // Use the existing whole-source class bound. Unproven/native builds keep
15928
+ // the historical eight-token scratch; overflow still works in every build.
15929
+ static constexpr std::size_t kInlineCount =
15930
+ GEA_UI_CLASS_INLINE_TOKENS < 4 ? GEA_UI_CLASS_INLINE_TOKENS : 8;
15001
15931
 
15002
15932
  CssAtomId inlineTokens[kInlineCount]{};
15003
15933
  CssAtomId *spillTokens = nullptr;
@@ -15046,11 +15976,15 @@ bool classTokensTouchAncestorSelectors(const NodeClassSnapshot &oldTokens, const
15046
15976
  struct CustomPropertyFingerprint {
15047
15977
  CssAtomId nameId = kInvalidCssAtom;
15048
15978
  CssAtomId valueAtom = kInvalidCssAtom;
15049
- std::int32_t colorStyle = 0;
15050
- std::int32_t colorNative = 0;
15979
+ NodeCustomProperty::ColorValue colorStyle = 0;
15980
+ NodeCustomProperty::ColorValue colorNative = 0;
15981
+ #if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
15051
15982
  float lengthValue = 0.0f;
15983
+ #endif
15052
15984
  std::uint8_t colorAlpha = 255;
15985
+ #if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
15053
15986
  std::uint8_t lengthUnit = 0;
15987
+ #endif
15054
15988
  std::uint8_t flags = 0;
15055
15989
  bool valueEmpty = true;
15056
15990
  bool exact = true;
@@ -15060,13 +15994,15 @@ CustomPropertyFingerprint customPropertyFingerprint(const NodeCustomProperty &pr
15060
15994
  {
15061
15995
  CustomPropertyFingerprint out;
15062
15996
  out.nameId = property.nameId;
15063
- out.valueEmpty = property.value.empty();
15997
+ out.valueEmpty = property.value->empty();
15064
15998
  out.valueAtom = property.valueAtom;
15065
15999
  out.colorStyle = property.colorStyle;
15066
16000
  out.colorNative = property.colorNative;
16001
+ #if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
15067
16002
  out.lengthValue = property.lengthValue;
15068
- out.colorAlpha = property.colorAlpha;
15069
16003
  out.lengthUnit = property.lengthUnit;
16004
+ #endif
16005
+ out.colorAlpha = property.colorAlpha;
15070
16006
  out.flags = property.flags;
15071
16007
  out.exact = out.valueEmpty || out.valueAtom != kInvalidCssAtom;
15072
16008
  return out;
@@ -15082,14 +16018,16 @@ bool customPropertyFingerprintEqualsValue(const CustomPropertyFingerprint &befor
15082
16018
  before.colorNative != after.colorNative ||
15083
16019
  before.colorAlpha != after.colorAlpha))
15084
16020
  return false;
16021
+ #if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
15085
16022
  if ((before.flags & 2u) != 0 &&
15086
16023
  (before.lengthUnit != after.lengthUnit ||
15087
16024
  std::fabs(static_cast<double>(before.lengthValue) -
15088
16025
  static_cast<double>(after.lengthValue)) >= 0.0001))
15089
16026
  return false;
16027
+ #endif
15090
16028
  if (!before.exact) return false; // conservative: recompute descendants rather than risk a stale var().
15091
- if (before.valueEmpty) return after.value.empty();
15092
- if (after.value.empty()) return false;
16029
+ if (before.valueEmpty) return after.value->empty();
16030
+ if (after.value->empty()) return false;
15093
16031
  return after.valueAtom == before.valueAtom && after.valueAtom != kInvalidCssAtom;
15094
16032
  }
15095
16033
 
@@ -15185,9 +16123,18 @@ void recomputeNodeIncremental(int node, const CssAtomSmallList &changedAbove, bo
15185
16123
  if (node < 0 || node >= state.nodeCount) return;
15186
16124
  if (isGeneratedPseudoNode(state.nodes[node])) return;
15187
16125
 
16126
+ #if GEA_CSS_CUSTOM_PROPERTIES
15188
16127
  const NodeCustomPropRefs &refs = g_nodeRefs[node];
15189
16128
  const bool tracked = refs.tracked;
15190
16129
  const bool referencesChanged = refs.touches(changedAbove);
16130
+ #else
16131
+ #if GEA_EMBEDDED_SHARED_STYLES
16132
+ const bool tracked = state.nodes[node].class_style_tracked;
16133
+ #else
16134
+ const bool tracked = g_nodeStyleTracked[node];
16135
+ #endif
16136
+ constexpr bool referencesChanged = false;
16137
+ #endif
15191
16138
  const bool directlyChanged = pending.contains(node);
15192
16139
  // A never-recorded node (e.g. freshly created this batch) must recompute — we
15193
16140
  // have no dependency info to justify skipping it.
@@ -15207,15 +16154,15 @@ void recomputeNodeIncremental(int node, const CssAtomSmallList &changedAbove, bo
15207
16154
  #if GEA_INCREMENTAL_VERIFY
15208
16155
  g_incrRecomputedNodes.insert(node);
15209
16156
  #endif
15210
- const ParentStyleSnapshot before = snapshotParentStyle(state.nodes[node].style);
16157
+ const ParentStyleSnapshot before = snapshotParentStyle(state.nodes[node].computedStyle());
15211
16158
  CustomPropertySnapshot beforeCustom;
15212
16159
  snapshotCustomProperties(rareDataFor(node), beforeCustom);
15213
16160
  recomputeNodeClassStyles(node);
15214
- inheritablesChanged = parentStylesDiffer(before, snapshotParentStyle(state.nodes[node].style));
16161
+ inheritablesChanged = parentStylesDiffer(before, snapshotParentStyle(state.nodes[node].computedStyle()));
15215
16162
  // Reconcile the cascaded custom-property set for descendants: a (re)defined
15216
16163
  // property whose value changed is now changed for them; one whose value is
15217
16164
  // unchanged shadows any same-named change from above; a removed one un-shadows.
15218
- static const std::vector<NodeCustomProperty> kNoCustomProps;
16165
+ static const NodeCustomPropertyStore::Values kNoCustomProps;
15219
16166
  const NodeRareData *rdCustomAfter = rareDataFor(node);
15220
16167
  const auto &afterCustom = rdCustomAfter ? rdCustomAfter->customProperties.values : kNoCustomProps;
15221
16168
  for (const auto &kv : afterCustom) {
@@ -15257,7 +16204,7 @@ void collectSubtreeStyles(int node, std::vector<int> &ids, std::vector<ComputedS
15257
16204
  auto &state = treeState();
15258
16205
  if (node < 0 || node >= state.nodeCount) return;
15259
16206
  ids.push_back(node);
15260
- styles.push_back(state.nodes[node].style);
16207
+ styles.push_back(state.nodes[node].computedStyle());
15261
16208
  imageIds.push_back(state.nodes[node].image_id);
15262
16209
  for (int child = state.nodes[node].first_child; child >= 0; child = state.nodes[child].next_sibling)
15263
16210
  collectSubtreeStyles(child, ids, styles, imageIds);
@@ -15276,9 +16223,17 @@ void syncNodeClassAttribute(int node)
15276
16223
  void recomputeAllClassStyles()
15277
16224
  {
15278
16225
  auto &state = treeState();
16226
+ #if GEA_CSS_CUSTOM_PROPERTIES
15279
16227
  g_nodeRefOverflow.clear();
16228
+ #endif
15280
16229
  clearCustomPropertyLookupCache();
16230
+ #if GEA_CSS_CUSTOM_PROPERTIES
15281
16231
  for (auto &refs : g_nodeRefs) refs.reset();
16232
+ #elif GEA_EMBEDDED_SHARED_STYLES
16233
+ for (auto &node : treeState().nodes) node.class_style_tracked = false;
16234
+ #else
16235
+ std::fill(std::begin(g_nodeStyleTracked), std::end(g_nodeStyleTracked), false);
16236
+ #endif
15282
16237
  for (int i = 0; i < state.nodeCount; i++) {
15283
16238
  if (state.nodes[i].parent < 0) recomputeSubtreeClassStyles(i);
15284
16239
  }
@@ -15320,6 +16275,7 @@ void noteKeyframeRuleRegistrationChanged()
15320
16275
  invalidateKeyframeRuleIndex();
15321
16276
  }
15322
16277
 
16278
+ #if GEA_CSS_ANIMATIONS
15323
16279
  std::vector<std::string> splitCssTokens(const std::string &value)
15324
16280
  {
15325
16281
  std::vector<std::string> out;
@@ -15625,51 +16581,53 @@ CssAnimationSpec animationSpecForNodeFromActivePlan(const ActiveRulePlan &plan)
15625
16581
  double currentStyleValue(const Node &node, Property property)
15626
16582
  {
15627
16583
  switch (property) {
15628
- case Property::TransformRotate: return static_cast<double>(rstyle(node.style).transform_rotate) / 10.0;
15629
- case Property::TransformRotateX: return static_cast<double>(rstyle(node.style).transform_rotate_x) / 10.0;
15630
- case Property::TransformRotateY: return static_cast<double>(rstyle(node.style).transform_rotate_y) / 10.0;
15631
- case Property::TransformTranslateOuterAxes: return rstyle(node.style).transform_translate_outer_axes;
15632
- case Property::RotateAngle: return static_cast<double>(rstyle(node.style).rotate_angle) / 10.0;
15633
- case Property::RotateAxisX: return rstyle(node.style).rotate_axis_x;
15634
- case Property::RotateAxisY: return rstyle(node.style).rotate_axis_y;
15635
- case Property::RotateAxisZ: return rstyle(node.style).rotate_axis_z;
15636
- case Property::ScaleX: return rstyle(node.style).scale_x;
15637
- case Property::ScaleY: return rstyle(node.style).scale_y;
15638
- case Property::ScaleZ: return rstyle(node.style).scale_z;
15639
- case Property::RotatePresent: return rstyle(node.style).rotate_present;
15640
- case Property::ScalePresent: return rstyle(node.style).scale_present;
15641
- case Property::TranslatePresent: return rstyle(node.style).translate_present;
15642
- case Property::TranslateX: return rstyle(node.style).translate_x;
15643
- case Property::TranslateY: return rstyle(node.style).translate_y;
15644
- case Property::TranslateZ: return rstyle(node.style).translate_z;
15645
- case Property::TranslateXPercent: return rstyle(node.style).translate_x_percent;
15646
- case Property::TranslateYPercent: return rstyle(node.style).translate_y_percent;
15647
- case Property::TransformTranslateX: return rstyle(node.style).transform_translate_x;
15648
- case Property::TransformTranslateY: return rstyle(node.style).transform_translate_y;
15649
- case Property::TransformTranslateZ: return rstyle(node.style).transform_translate_z;
15650
- case Property::TransformTranslateXPercent: return rstyle(node.style).transform_translate_x_percent;
15651
- case Property::TransformTranslateYPercent: return rstyle(node.style).transform_translate_y_percent;
15652
- case Property::TransformScaleX: return rstyle(node.style).transform_scale_x;
15653
- case Property::TransformScaleY: return rstyle(node.style).transform_scale_y;
15654
- case Property::TransformScaleZ: return rstyle(node.style).transform_scale_z;
15655
- case Property::FilterBlur: return rstyle(node.style).filter_blur_radius;
15656
- case Property::Opacity: return node.style.opacity;
15657
- case Property::Width: return node.style.width;
15658
- case Property::Height: return node.style.height;
15659
- case Property::WidthPercent: return node.style.width_percent == kUnset ? 0 : node.style.width_percent;
15660
- case Property::HeightPercent: return node.style.height_percent == kUnset ? 0 : node.style.height_percent;
15661
- case Property::LineHeight: return node.style.line_height;
15662
- case Property::FontWeight: return node.style.font_weight;
15663
- case Property::Top: return node.style.pos_offsets[0] == kUnset ? 0 : node.style.pos_offsets[0];
15664
- case Property::Right: return node.style.pos_offsets[1] == kUnset ? 0 : node.style.pos_offsets[1];
15665
- case Property::Bottom: return node.style.pos_offsets[2] == kUnset ? 0 : node.style.pos_offsets[2];
15666
- case Property::Left: return node.style.pos_offsets[3] == kUnset ? 0 : node.style.pos_offsets[3];
15667
- case Property::TopPercent: return node.style.pos_offset_percent[0] == kUnset ? 0 : node.style.pos_offset_percent[0];
15668
- case Property::RightPercent: return node.style.pos_offset_percent[1] == kUnset ? 0 : node.style.pos_offset_percent[1];
15669
- case Property::BottomPercent: return node.style.pos_offset_percent[2] == kUnset ? 0 : node.style.pos_offset_percent[2];
15670
- case Property::LeftPercent: return node.style.pos_offset_percent[3] == kUnset ? 0 : node.style.pos_offset_percent[3];
15671
- case Property::BackgroundColor: return node.style.bg_color;
15672
- case Property::Color: return node.style.text_color;
16584
+ #if GEA_CSS_TRANSFORMS
16585
+ case Property::TransformRotate: return static_cast<double>(rstyle(node.computedStyle()).transform_rotate) / 10.0;
16586
+ case Property::TransformRotateX: return static_cast<double>(rstyle(node.computedStyle()).transform_rotate_x) / 10.0;
16587
+ case Property::TransformRotateY: return static_cast<double>(rstyle(node.computedStyle()).transform_rotate_y) / 10.0;
16588
+ case Property::TransformTranslateOuterAxes: return rstyle(node.computedStyle()).transform_translate_outer_axes;
16589
+ case Property::RotateAngle: return static_cast<double>(rstyle(node.computedStyle()).rotate_angle) / 10.0;
16590
+ case Property::RotateAxisX: return rstyle(node.computedStyle()).rotate_axis_x;
16591
+ case Property::RotateAxisY: return rstyle(node.computedStyle()).rotate_axis_y;
16592
+ case Property::RotateAxisZ: return rstyle(node.computedStyle()).rotate_axis_z;
16593
+ case Property::ScaleX: return rstyle(node.computedStyle()).scale_x;
16594
+ case Property::ScaleY: return rstyle(node.computedStyle()).scale_y;
16595
+ case Property::ScaleZ: return rstyle(node.computedStyle()).scale_z;
16596
+ case Property::RotatePresent: return rstyle(node.computedStyle()).rotate_present;
16597
+ case Property::ScalePresent: return rstyle(node.computedStyle()).scale_present;
16598
+ case Property::TranslatePresent: return rstyle(node.computedStyle()).translate_present;
16599
+ case Property::TranslateX: return rstyle(node.computedStyle()).translate_x;
16600
+ case Property::TranslateY: return rstyle(node.computedStyle()).translate_y;
16601
+ case Property::TranslateZ: return rstyle(node.computedStyle()).translate_z;
16602
+ case Property::TranslateXPercent: return rstyle(node.computedStyle()).translate_x_percent;
16603
+ case Property::TranslateYPercent: return rstyle(node.computedStyle()).translate_y_percent;
16604
+ case Property::TransformTranslateX: return rstyle(node.computedStyle()).transform_translate_x;
16605
+ case Property::TransformTranslateY: return rstyle(node.computedStyle()).transform_translate_y;
16606
+ case Property::TransformTranslateZ: return rstyle(node.computedStyle()).transform_translate_z;
16607
+ case Property::TransformTranslateXPercent: return rstyle(node.computedStyle()).transform_translate_x_percent;
16608
+ case Property::TransformTranslateYPercent: return rstyle(node.computedStyle()).transform_translate_y_percent;
16609
+ case Property::TransformScaleX: return rstyle(node.computedStyle()).transform_scale_x;
16610
+ case Property::TransformScaleY: return rstyle(node.computedStyle()).transform_scale_y;
16611
+ case Property::TransformScaleZ: return rstyle(node.computedStyle()).transform_scale_z;
16612
+ #endif
16613
+ case Property::FilterBlur: return (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0);
16614
+ case Property::Opacity: return node.computedStyle().opacity;
16615
+ case Property::Width: return node.computedStyle().width;
16616
+ case Property::Height: return node.computedStyle().height;
16617
+ case Property::WidthPercent: return node.computedStyle().width_percent == kUnset ? 0 : node.computedStyle().width_percent;
16618
+ case Property::HeightPercent: return node.computedStyle().height_percent == kUnset ? 0 : node.computedStyle().height_percent;
16619
+ case Property::LineHeight: return node.computedStyle().line_height;
16620
+ case Property::FontWeight: return node.computedStyle().font_weight;
16621
+ case Property::Top: return GEA_CSS_POSITION_PX_0(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PX_0(node.computedStyle());
16622
+ case Property::Right: return GEA_CSS_POSITION_PX_1(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PX_1(node.computedStyle());
16623
+ case Property::Bottom: return GEA_CSS_POSITION_PX_2(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PX_2(node.computedStyle());
16624
+ case Property::Left: return GEA_CSS_POSITION_PX_3(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PX_3(node.computedStyle());
16625
+ case Property::TopPercent: return GEA_CSS_POSITION_PERCENT_0(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_0(node.computedStyle());
16626
+ case Property::RightPercent: return GEA_CSS_POSITION_PERCENT_1(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_1(node.computedStyle());
16627
+ case Property::BottomPercent: return GEA_CSS_POSITION_PERCENT_2(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_2(node.computedStyle());
16628
+ case Property::LeftPercent: return GEA_CSS_POSITION_PERCENT_3(node.computedStyle()) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_3(node.computedStyle());
16629
+ case Property::BackgroundColor: return node.computedStyle().bg_color;
16630
+ case Property::Color: return node.computedStyle().text_color;
15673
16631
  default: return 0;
15674
16632
  }
15675
16633
  }
@@ -15804,6 +16762,7 @@ bool addCompiledPropertyKeyframe(CssAnimationTrackList &tracks, int nodeId, int
15804
16762
  case CssCompiledKind::DirectProperty: {
15805
16763
  const Property property = static_cast<Property>(compiled.values[0]);
15806
16764
  switch (property) {
16765
+ #if GEA_CSS_TRANSFORMS
15807
16766
  case Property::RotateAngle:
15808
16767
  addTrackKeyframe(tracks, property, offset, compiled.values[1] / 10.0); return true;
15809
16768
  case Property::RotatePresent:
@@ -15814,6 +16773,7 @@ bool addCompiledPropertyKeyframe(CssAnimationTrackList &tracks, int nodeId, int
15814
16773
  case Property::ScaleX:
15815
16774
  case Property::ScaleY:
15816
16775
  case Property::ScaleZ:
16776
+ #endif
15817
16777
  case Property::Opacity:
15818
16778
  case Property::Width:
15819
16779
  case Property::Height:
@@ -16131,6 +17091,8 @@ void startAnimationForNode(int nodeId, const CssAnimationSpec &spec, std::uint32
16131
17091
  }
16132
17092
  }
16133
17093
 
17094
+ #endif
17095
+
16134
17096
  } // namespace
16135
17097
 
16136
17098
  bool StyleValues::hasTextBackgroundClip(const ComputedStyle &style)
@@ -16175,8 +17137,8 @@ BackgroundPlacement StyleValues::backgroundPlacement(const ComputedStyle &style,
16175
17137
  }
16176
17138
  if (out.origin != 0) {
16177
17139
  int inset[4];
16178
- for (int i = 0; i < 4; ++i) inset[i] = std::max<int>(node.style.border_width, rstyle(node.style).border_side_width[i]) +
16179
- (out.origin == 2 ? std::max<int>(0, node.style.padding[i]) : 0);
17140
+ for (int i = 0; i < 4; ++i) inset[i] = computedBorderWidth(node.computedStyle(), i) +
17141
+ (out.origin == 2 ? std::max<int>(0, node.computedStyle().padding[i]) : 0);
16180
17142
  x += inset[3]; y += inset[0]; width -= inset[1]+inset[3]; height -= inset[0]+inset[2];
16181
17143
  }
16182
17144
  }
@@ -16288,14 +17250,18 @@ void endStyleMountBatch()
16288
17250
  const int id = vIds[i];
16289
17251
  // Field-wise compare (ComputedStyle has padding, so memcmp gives false diffs).
16290
17252
  // styleEqualExceptTextPaint covers every field but text_color, which we add.
16291
- const bool equal = styleEqualExceptTextPaint(vStyles[i], state.nodes[id].style) &&
16292
- vStyles[i].text_color == state.nodes[id].style.text_color &&
17253
+ const bool equal = styleEqualExceptTextPaint(vStyles[i], state.nodes[id].computedStyle()) &&
17254
+ vStyles[i].text_color == state.nodes[id].computedStyle().text_color &&
16293
17255
  vImg[i] == state.nodes[id].image_id;
16294
17256
  if (!equal) {
16295
17257
  mismatches++;
16296
17258
  if (logged < 8) {
16297
17259
  const bool recomputed = g_incrRecomputedNodes.count(id) > 0;
17260
+ #if GEA_CSS_CUSTOM_PROPERTIES
16298
17261
  const std::string refs = (id >= 0 && id < kMaxNodes) ? g_nodeRefs[id].debugString() : std::string();
17262
+ #else
17263
+ const std::string refs;
17264
+ #endif
16299
17265
  GEA_STYLE_LOGW("gea.recincr", " mismatch node=%d tag=%s class=[%s] incrRecomputed=%d refs=[%s]", id,
16300
17266
  tagFromId(state.nodes[id].tag_id), state.classLists[id].value().c_str(), recomputed ? 1 : 0,
16301
17267
  refs.c_str());
@@ -16377,27 +17343,43 @@ void Style::cssScale(double value) const
16377
17343
  void StyleSheet::clear()
16378
17344
  {
16379
17345
  rules().clear();
17346
+ #if GEA_CSS_ANIMATIONS
16380
17347
  keyframeRules().clear();
17348
+ #endif
16381
17349
  g_ruleRegistrationBatchDepth = 0;
16382
17350
  g_ruleRegistrationRulesChanged = false;
16383
17351
  g_ruleRegistrationKeyframesChanged = false;
17352
+ #if GEA_CSS_ANIMATIONS
16384
17353
  clearKeyframeRuleIndex();
17354
+ #endif
16385
17355
  clearCssRuleTexts();
16386
17356
  compiledCssValues().clear();
16387
17357
  clearInlineCompiledStyleCache();
17358
+ #if GEA_CSS_ANIMATIONS
16388
17359
  compiledCssAnimationSpecs().clear();
17360
+ #endif
16389
17361
  clearCompiledCssBackgrounds();
16390
17362
  clearCompiledCssGridTemplates();
16391
17363
  clearCompiledCssLengthExpressions();
16392
17364
  clearCompiledCssLengthCache();
16393
17365
  clearCompiledCssColorCache();
16394
17366
  clearMediaConditionPlans();
17367
+ #if GEA_CSS_ANIMATIONS
16395
17368
  gea::css::AnimationEngine::instance().clear();
17369
+ #endif
16396
17370
  invalidateRuleIndex();
16397
17371
  clearSelectorPartsCache();
17372
+ #if GEA_CSS_CUSTOM_PROPERTIES
16398
17373
  g_nodeRefOverflow.clear();
17374
+ #endif
16399
17375
  clearCustomPropertyLookupCache();
16400
- for (auto &refs : g_nodeRefs) refs.reset(); // stale per-node custom-prop dependencies from the previous app
17376
+ #if GEA_CSS_CUSTOM_PROPERTIES
17377
+ for (auto &refs : g_nodeRefs) refs.reset();
17378
+ #elif GEA_EMBEDDED_SHARED_STYLES
17379
+ for (auto &node : treeState().nodes) node.class_style_tracked = false;
17380
+ #else
17381
+ std::fill(std::begin(g_nodeStyleTracked), std::end(g_nodeStyleTracked), false);
17382
+ #endif
16401
17383
  g_pendingRecomputeMark.clear();
16402
17384
  g_forceFullSubtreeMark.clear();
16403
17385
  recomputeAllClassStyles();
@@ -16855,6 +17837,7 @@ void StyleSheet::registerStaticAnimationRule(StaticStyleSelectorKind selectorKin
16855
17837
  StaticStyleAnimationEasing easing,
16856
17838
  const char *media)
16857
17839
  {
17840
+ #if GEA_CSS_ANIMATIONS
16858
17841
  rules().push_back(makeStaticAnimationCssRule(selectorKind,
16859
17842
  selector,
16860
17843
  name,
@@ -16866,6 +17849,7 @@ void StyleSheet::registerStaticAnimationRule(StaticStyleSelectorKind selectorKin
16866
17849
  easing,
16867
17850
  media));
16868
17851
  noteStyleRuleRegistrationChanged();
17852
+ #endif
16869
17853
  }
16870
17854
 
16871
17855
  void StyleSheet::registerStaticCustomLengthRule(StaticStyleSelectorKind selectorKind,
@@ -16963,7 +17947,27 @@ void StyleSheet::setClassName(NodeHandle node, const std::string &className) con
16963
17947
 
16964
17948
  bool StyleSheet::applyPixelLengthProperty(NodeHandle node, StyleDeclaration declaration, double value) const
16965
17949
  {
16966
- return applyNumberDeclarationWithSource(node, declaration, value * g_device_pixel_ratio, StyleApplicationSource::Inline);
17950
+ if (!node || !std::isfinite(value)) return false;
17951
+ // A compiled `${value}px` has the same unit as a parsed CSS length. In
17952
+ // particular, use the size/position rules that clear competing percentage
17953
+ // values and preserve length expressions; a raw numeric setter cannot do that.
17954
+ const CssLengthSpec length{static_cast<float>(value), CssLengthUnit::Px};
17955
+ if (applyRuntimeSizeValue(node, declaration, length, StyleApplicationSource::Inline) ||
17956
+ applyRuntimePositionOffsetValue(node, declaration, length, StyleApplicationSource::Inline) ||
17957
+ applyRuntimeLengthValue(node, declaration, length, StyleApplicationSource::Inline)) return true;
17958
+ if (declaration == CssDeclarationId::Padding || declaration == CssDeclarationId::Margin) {
17959
+ for (int side = 0; side < 4; ++side) setBoxLengthValue(node, declaration == CssDeclarationId::Padding, side, length, StyleApplicationSource::Inline);
17960
+ return true;
17961
+ }
17962
+ if (declaration == CssDeclarationId::BorderRadius) {
17963
+ for (int corner = 0; corner < 4; ++corner) setCompiledBorderRadiusCornerValue(node, corner, length, StyleApplicationSource::Inline);
17964
+ return true;
17965
+ }
17966
+ if (declaration >= CssDeclarationId::BorderTopLeftRadius && declaration <= CssDeclarationId::BorderBottomLeftRadius) {
17967
+ setCompiledBorderRadiusCornerValue(node, static_cast<int>(declaration) - static_cast<int>(CssDeclarationId::BorderTopLeftRadius), length, StyleApplicationSource::Inline);
17968
+ return true;
17969
+ }
17970
+ return false;
16967
17971
  }
16968
17972
 
16969
17973
  bool StyleSheet::applyNumberProperty(NodeHandle node, const char *property, double value) const
@@ -17013,14 +18017,18 @@ void StyleSheet::recomputeSubtree(int nodeId) const
17013
18017
 
17014
18018
  void StyleSheet::startCssAnimations(std::uint32_t nowMs) const
17015
18019
  {
18020
+ #if GEA_CSS_ANIMATIONS
17016
18021
  rebuildRuleIndexIfNeeded();
17017
18022
  if (g_ruleIndex.animationRules.empty()) return;
17018
18023
  auto &state = treeState();
17019
18024
  for (int node = 0; node < state.nodeCount; ++node) {
17020
- if (isDisplayNone(state.nodes[node].style)) continue;
18025
+ if (isDisplayNone(state.nodes[node].computedStyle())) continue;
17021
18026
  const CssAnimationSpec spec = animationSpecForNode(node);
17022
18027
  startAnimationForNode(node, spec, nowMs);
17023
18028
  }
18029
+ #else
18030
+ (void)nowMs;
18031
+ #endif
17024
18032
  }
17025
18033
 
17026
18034
  void Tree::setClassName(int node, const std::string &className)
@@ -17080,7 +18088,7 @@ const char *tagFromId(int16_t id)
17080
18088
  // When GEA_EMBEDDED_RARE_STYLE_INLINE is enabled, the rare fields are embedded in
17081
18089
  // ComputedStyle, so these become trivial (rstyleMut returns the embedded struct;
17082
18090
  // release/reset are no-ops) and the pool + free list are compiled out.
17083
- #if !GEA_EMBEDDED_RARE_STYLE_INLINE
18091
+ #if GEA_CSS_RARE_STYLE && !GEA_EMBEDDED_RARE_STYLE_INLINE
17084
18092
  namespace {
17085
18093
  std::vector<int16_t> &rareStyleFreeList()
17086
18094
  {
@@ -17092,11 +18100,14 @@ std::vector<int16_t> &rareStyleFreeList()
17092
18100
 
17093
18101
  RareStyle &rstyleMut(ComputedStyle &style)
17094
18102
  {
18103
+ #if GEA_CSS_RARE_STYLE
17095
18104
  // rstyleMut is also used by native setup/tests that write transform fields
17096
18105
  // directly, bypassing Tree::setStyle's transform-cache invalidation.
18106
+ #if GEA_CSS_TRANSFORMS
17097
18107
  auto &state = treeState();
17098
18108
  state.transformScanSerial = ~0ull;
17099
18109
  state.transformScanValid = false;
18110
+ #endif
17100
18111
  #if GEA_EMBEDDED_RARE_STYLE_INLINE
17101
18112
  return style.rare;
17102
18113
  #else
@@ -17114,10 +18125,16 @@ RareStyle &rstyleMut(ComputedStyle &style)
17114
18125
  style.rare_style = handle;
17115
18126
  return pool[static_cast<std::size_t>(handle)];
17116
18127
  #endif
18128
+ #else
18129
+ (void)style;
18130
+ static RareStyle empty;
18131
+ return empty;
18132
+ #endif
17117
18133
  }
17118
18134
 
17119
18135
  void releaseRareStyle(int16_t &handle)
17120
18136
  {
18137
+ #if GEA_CSS_RARE_STYLE
17121
18138
  #if GEA_EMBEDDED_RARE_STYLE_INLINE
17122
18139
  (void)handle; // embedded rare is freed with the node; nothing to release
17123
18140
  #else
@@ -17126,15 +18143,22 @@ void releaseRareStyle(int16_t &handle)
17126
18143
  rareStyleFreeList().push_back(handle);
17127
18144
  handle = -1;
17128
18145
  #endif
18146
+ #else
18147
+ (void)handle;
18148
+ #endif
17129
18149
  }
17130
18150
 
17131
18151
  void resetRareStylePool()
17132
18152
  {
18153
+ #if GEA_CSS_RARE_STYLE
17133
18154
  #if GEA_EMBEDDED_RARE_STYLE_INLINE
17134
18155
  // rare fields are embedded per-node; there is no shared pool to reset.
17135
18156
  #else
17136
18157
  rareStylePool().clear();
17137
18158
  rareStyleFreeList().clear();
18159
+ #endif
18160
+ #else
18161
+
17138
18162
  #endif
17139
18163
  }
17140
18164
 
@@ -17238,12 +18262,36 @@ std::string Tree::className(int node) const
17238
18262
  return state.classLists[node].value();
17239
18263
  }
17240
18264
 
18265
+ void rescaleInlineCssPixels()
18266
+ {
18267
+ auto &state = treeState();
18268
+ for (int node = 0; node < state.nodeCount; ++node) {
18269
+ auto *rare = rareDataFor(node);
18270
+ if (!rare) continue;
18271
+ auto &values = rare->inlineStyles;
18272
+ for (std::size_t i = 0; i < values.size(); ++i) {
18273
+ const Property property = values.at(i).property;
18274
+ float pixels;
18275
+ if (!values.getCssPixels(property, pixels)) continue;
18276
+ const CssLengthSpec length{pixels, CssLengthUnit::Px};
18277
+ const bool border = property == Property::BorderWidth || property == Property::BorderTopWidth ||
18278
+ property == Property::BorderRightWidth || property == Property::BorderBottomWidth || property == Property::BorderLeftWidth;
18279
+ int resolved = border ? resolveBorderWidth(length, node) : property == Property::FontSize
18280
+ ? resolveFontSizeLength(length, node) : resolveCompiledLengthForNode(length, node, LengthAxis::None);
18281
+ if (property >= Property::PaddingTop && property <= Property::PaddingLeft) resolved = std::max(0, resolved);
18282
+ values.set(property, resolved);
18283
+ values.setCssPixels(property, pixels);
18284
+ }
18285
+ }
18286
+ }
18287
+
17241
18288
  void setViewportMetrics(int width, int height, double devicePixelRatio)
17242
18289
  {
17243
18290
  g_viewport_width = width;
17244
18291
  g_viewport_height = height;
17245
18292
  g_device_pixel_ratio = sanitizedDevicePixelRatio(devicePixelRatio);
17246
18293
  clearStaticLengthExpressionResolutionCache();
18294
+ rescaleInlineCssPixels();
17247
18295
  invalidateRuleIndex();
17248
18296
  recomputeAllClassStyles();
17249
18297
  }
@@ -17259,6 +18307,7 @@ void setDevicePixelRatio(double devicePixelRatio)
17259
18307
  if (sanitized == g_device_pixel_ratio) return;
17260
18308
  g_device_pixel_ratio = sanitized;
17261
18309
  clearStaticLengthExpressionResolutionCache();
18310
+ rescaleInlineCssPixels();
17262
18311
  invalidateRuleIndex();
17263
18312
  recomputeAllClassStyles();
17264
18313
  }