@geastack/engine 0.1.5 → 0.1.6

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/tree_style.cpp CHANGED
@@ -30,6 +30,19 @@ bool nodeParticipatesInMountedTree(const TreeState &state, int node)
30
30
  bool isTransformProperty(Property prop)
31
31
  {
32
32
  switch (prop) {
33
+ case Property::RotateAngle:
34
+ case Property::RotateAxisX:
35
+ case Property::RotateAxisY:
36
+ case Property::RotateAxisZ:
37
+ case Property::ScaleX:
38
+ case Property::ScaleY:
39
+ case Property::ScaleZ:
40
+ case Property::TransformTranslateOuterAxes:
41
+ case Property::TranslateX:
42
+ case Property::TranslateY:
43
+ case Property::TranslateZ:
44
+ case Property::TranslateXPercent:
45
+ case Property::TranslateYPercent:
33
46
  case Property::TransformRotate:
34
47
  case Property::TransformRotateX:
35
48
  case Property::TransformRotateY:
@@ -40,6 +53,7 @@ bool isTransformProperty(Property prop)
40
53
  case Property::TransformTranslateYPercent:
41
54
  case Property::TransformScaleX:
42
55
  case Property::TransformScaleY:
56
+ case Property::TransformScaleZ:
43
57
  case Property::TransformOriginX:
44
58
  case Property::TransformOriginY:
45
59
  case Property::Perspective:
@@ -54,12 +68,49 @@ bool isTransformProperty(Property prop)
54
68
  bool isLayoutProperty(Property prop)
55
69
  {
56
70
  switch (prop) {
71
+ case Property::FlexLineCount:
72
+ case Property::AspectRatio:
73
+ case Property::TranslatePresent:
74
+ case Property::TransformPresent:
75
+ case Property::RotatePresent:
76
+ case Property::ScalePresent:
77
+ case Property::FilterPresent:
57
78
  case Property::Display:
58
79
  case Property::FlexDirection:
80
+ case Property::BoxSizing:
81
+ case Property::Float:
82
+ case Property::MarginTrim:
83
+ case Property::Clear:
84
+ case Property::WritingMode:
85
+ case Property::Direction:
86
+ case Property::RowGap:
87
+ case Property::ColumnGap:
88
+ case Property::RowGapPercent:
89
+ case Property::ColumnGapPercent:
90
+ case Property::MarginTopAuto:
91
+ case Property::MarginRightAuto:
92
+ case Property::MarginBottomAuto:
93
+ case Property::MarginLeftAuto:
94
+ case Property::MarginTopExpression:
95
+ case Property::MarginRightExpression:
96
+ case Property::MarginBottomExpression:
97
+ case Property::MarginLeftExpression:
98
+ case Property::PaddingTopExpression:
99
+ case Property::PaddingRightExpression:
100
+ case Property::PaddingBottomExpression:
101
+ case Property::PaddingLeftExpression:
102
+ case Property::WidthExpression:
103
+ case Property::HeightExpression:
104
+ case Property::Order:
59
105
  case Property::FlexWrap:
60
106
  case Property::JustifyContent:
61
107
  case Property::AlignItems:
62
108
  case Property::JustifyItems:
109
+ case Property::JustifySelf:
110
+ case Property::GridRowStart:
111
+ case Property::GridColumnStart:
112
+ case Property::GridRowEnd:
113
+ case Property::GridColumnEnd:
63
114
  case Property::AlignContent:
64
115
  case Property::AlignSelf:
65
116
  case Property::Gap:
@@ -74,6 +125,12 @@ bool isLayoutProperty(Property prop)
74
125
  case Property::Flex:
75
126
  case Property::FlexShrink:
76
127
  case Property::FlexBasis:
128
+ case Property::FlexBasisExpression:
129
+ case Property::BorderWidth:
130
+ case Property::BorderTopWidth:
131
+ case Property::BorderRightWidth:
132
+ case Property::BorderBottomWidth:
133
+ case Property::BorderLeftWidth:
77
134
  case Property::PaddingTop:
78
135
  case Property::PaddingRight:
79
136
  case Property::PaddingBottom:
@@ -98,6 +155,9 @@ bool isLayoutProperty(Property prop)
98
155
  case Property::FontSize:
99
156
  case Property::FontWeight:
100
157
  case Property::LineHeight:
158
+ case Property::LineHeightExpression:
159
+ case Property::LineHeightMultiplier:
160
+ case Property::Visibility:
101
161
  case Property::WhiteSpace:
102
162
  case Property::TextOverflow:
103
163
  case Property::ImageId:
@@ -159,7 +219,51 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
159
219
  #else
160
220
  if (recordInline)
161
221
  #endif
162
- ensureRareData(node).inlineStyles.set(prop, value);
222
+ {
223
+ auto &overrides = ensureRareData(node).inlineStyles;
224
+ // Width/height and their percentage/expression companions are one
225
+ // authored declaration. Replaying a stale companion would override a
226
+ // later numeric value (or an intrinsic sizing keyword).
227
+ if (prop == Property::Height || prop == Property::HeightPercent || prop == Property::HeightExpression) {
228
+ for (Property companion : {Property::Height, Property::HeightPercent, Property::HeightExpression})
229
+ if (companion != prop) overrides.remove(companion);
230
+ }
231
+ if (prop == Property::Width || prop == Property::WidthPercent || prop == Property::WidthExpression) {
232
+ for (Property companion : {Property::Width, Property::WidthPercent, Property::WidthExpression})
233
+ if (companion != prop) overrides.remove(companion);
234
+ }
235
+ if (prop == Property::LineHeight || prop == Property::LineHeightExpression || prop == Property::LineHeightMultiplier)
236
+ for (Property companion : {Property::LineHeight, Property::LineHeightExpression, Property::LineHeightMultiplier})
237
+ if (companion != prop) overrides.remove(companion);
238
+ if (prop == Property::FlexBasis || prop == Property::FlexBasisExpression)
239
+ overrides.remove(prop == Property::FlexBasis ? Property::FlexBasisExpression : Property::FlexBasis);
240
+ if (prop >= Property::MarginTop && prop <= Property::MarginLeft)
241
+ overrides.remove(static_cast<Property>(static_cast<int>(Property::MarginTopExpression) + static_cast<int>(prop) - static_cast<int>(Property::MarginTop)));
242
+ if (prop >= Property::PaddingTop && prop <= Property::PaddingLeft)
243
+ overrides.remove(static_cast<Property>(static_cast<int>(Property::PaddingTopExpression) + static_cast<int>(prop) - static_cast<int>(Property::PaddingTop)));
244
+ if (prop == Property::BorderWidth)
245
+ for (Property side : {Property::BorderTopWidth, Property::BorderRightWidth, Property::BorderBottomWidth, Property::BorderLeftWidth}) overrides.remove(side);
246
+ if (prop == Property::BorderRelief)
247
+ for (int side = 0; side < 4; ++side) overrides.remove(static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side));
248
+
249
+ // Literal/currentColor companions form one authored color. A common
250
+ // border-color resets all side colors; later side writes retain their order.
251
+ if (prop == Property::BorderColor || prop == Property::BorderColorCurrent) {
252
+ for (Property color : {Property::BorderColor, Property::BorderColorCurrent,
253
+ Property::BorderTopColor, Property::BorderRightColor, Property::BorderBottomColor, Property::BorderLeftColor,
254
+ Property::BorderTopColorCurrent, Property::BorderRightColorCurrent, Property::BorderBottomColorCurrent, Property::BorderLeftColorCurrent, Property::BorderAlpha, Property::BorderTopAlpha, Property::BorderRightAlpha, Property::BorderBottomAlpha, Property::BorderLeftAlpha})
255
+ overrides.remove(color);
256
+ } else {
257
+ const Property colors[] = {Property::BorderTopColor, Property::BorderRightColor, Property::BorderBottomColor, Property::BorderLeftColor};
258
+ for (int side = 0; side < 4; ++side) {
259
+ const Property current = static_cast<Property>(static_cast<int>(Property::BorderTopColorCurrent) + side);
260
+ if (prop == colors[side] || prop == current) { overrides.remove(colors[side]); overrides.remove(current); overrides.remove(static_cast<Property>(static_cast<int>(Property::BorderTopAlpha) + side)); break; }
261
+ }
262
+ }
263
+ if (prop == Property::BackgroundColor) { overrides.remove(Property::BackgroundColor); overrides.remove(Property::BackgroundAlpha); }
264
+ if (prop == Property::Color) { overrides.remove(Property::Color); overrides.remove(Property::ColorAlpha); }
265
+ overrides.set(prop, value);
266
+ }
163
267
  Node *n = &state.nodes[node];
164
268
  int changed = 0;
165
269
  int prevOpacity = -1;
@@ -195,14 +299,54 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
195
299
  changed = 1;
196
300
  }
197
301
  break;
302
+ case Property::BoxSizing: if (n->style.box_sizing != value) { n->style.box_sizing = value; changed = 1; } break;
303
+ case Property::Float: if (n->style.float_side != value) { n->style.float_side = value; changed = 1; } break;
304
+ case Property::AspectRatio: if (rstyle(n->style).aspect_ratio != value) { rstyleMut(n->style).aspect_ratio = value; changed = 1; } break;
305
+ case Property::Containment: if (rstyle(n->style).containment != value) { rstyleMut(n->style).containment = value; changed = 1; } break;
306
+ case Property::FlexLineCount: if (rstyle(n->style).flex_line_count != value) { rstyleMut(n->style).flex_line_count = value; changed = 1; } break;
307
+ case Property::MarginTrim: if (rstyle(n->style).margin_trim != value) { rstyleMut(n->style).margin_trim = value; changed = 1; } break;
308
+ case Property::Clear: if (n->style.clear_side != value) { n->style.clear_side = value; changed = 1; } break;
309
+ case Property::Direction: if (n->style.direction != value) { n->style.direction = value; changed = 1; } break;
310
+ case Property::WritingMode: if (n->style.writing_mode != value) { n->style.writing_mode = value; changed = 1; } break;
311
+ case Property::RowGap: if (n->style.row_gap != value) { n->style.row_gap = value; changed = 1; } break;
312
+ case Property::ColumnGap: if (n->style.column_gap != value) { n->style.column_gap = value; changed = 1; } break;
313
+ case Property::RowGapPercent: if (n->style.row_gap_percent != value) { n->style.row_gap_percent = value; changed = 1; } break;
314
+ case Property::ColumnGapPercent: if (n->style.column_gap_percent != value) { n->style.column_gap_percent = value; changed = 1; } break;
315
+ case Property::MarginTopAuto: { const auto mask = (n->style.margin_auto & ~1) | (value ? 1 : 0); if (mask != n->style.margin_auto) { n->style.margin_auto = mask; changed = 1; } break; }
316
+ case Property::MarginRightAuto: { const auto mask = (n->style.margin_auto & ~2) | (value ? 2 : 0); if (mask != n->style.margin_auto) { n->style.margin_auto = mask; changed = 1; } break; }
317
+ case Property::MarginBottomAuto: { const auto mask = (n->style.margin_auto & ~4) | (value ? 4 : 0); if (mask != n->style.margin_auto) { n->style.margin_auto = mask; changed = 1; } break; }
318
+ case Property::MarginLeftAuto: { const auto mask = (n->style.margin_auto & ~8) | (value ? 8 : 0); if (mask != n->style.margin_auto) { n->style.margin_auto = mask; changed = 1; } break; }
319
+ case Property::MarginTopExpression: if (rstyle(n->style).margin_expression[0] != value) { rstyleMut(n->style).margin_expression[0] = value; changed = 1; } break;
320
+ case Property::MarginRightExpression: if (rstyle(n->style).margin_expression[1] != value) { rstyleMut(n->style).margin_expression[1] = value; changed = 1; } break;
321
+ case Property::MarginBottomExpression: if (rstyle(n->style).margin_expression[2] != value) { rstyleMut(n->style).margin_expression[2] = value; changed = 1; } break;
322
+ case Property::MarginLeftExpression: if (rstyle(n->style).margin_expression[3] != value) { rstyleMut(n->style).margin_expression[3] = value; changed = 1; } break;
323
+ case Property::PaddingTopExpression: if (rstyle(n->style).padding_expression[0] != value) { rstyleMut(n->style).padding_expression[0] = value; changed = 1; } break;
324
+ case Property::PaddingRightExpression: if (rstyle(n->style).padding_expression[1] != value) { rstyleMut(n->style).padding_expression[1] = value; changed = 1; } break;
325
+ case Property::PaddingBottomExpression: if (rstyle(n->style).padding_expression[2] != value) { rstyleMut(n->style).padding_expression[2] = value; changed = 1; } break;
326
+ case Property::PaddingLeftExpression: if (rstyle(n->style).padding_expression[3] != value) { rstyleMut(n->style).padding_expression[3] = value; changed = 1; } break;
327
+ case Property::WidthExpression: if (n->style.width_expression != value) { n->style.width_expression = value; n->style.width = n->style.width_percent = kUnset; changed = 1; } break;
328
+ case Property::HeightExpression: if (n->style.height_expression != value) { n->style.height_expression = value; n->style.height = n->style.height_percent = kUnset; changed = 1; } break;
329
+ case Property::Order: if (n->style.order != value) { n->style.order = value; changed = 1; } break;
198
330
  case Property::FlexWrap: if (n->style.flex_wrap != value) { n->style.flex_wrap = value; changed = 1; } break;
199
331
  case Property::JustifyContent: if (n->style.justify_content != value) { n->style.justify_content = value; changed = 1; } break;
200
332
  case Property::AlignItems: if (n->style.align_items != value) { n->style.align_items = value; changed = 1; } break;
201
333
  case Property::JustifyItems: if (n->style.justify_items != value) { n->style.justify_items = value; changed = 1; } break;
202
334
  case Property::AlignContent: if (n->style.align_content != value) { n->style.align_content = value; changed = 1; } break;
203
335
  case Property::AlignSelf: if (n->style.align_self != value) { n->style.align_self = value; changed = 1; } break;
204
- case Property::Gap: if (n->style.gap != value) { n->style.gap = value; changed = 1; } break;
336
+ case Property::JustifySelf: if (rstyle(n->style).justify_self != value) { rstyleMut(n->style).justify_self = value; changed = 1; } break;
337
+ case Property::GridRowStart: if (rstyle(n->style).grid_line[0] != value) { rstyleMut(n->style).grid_line[0] = value; changed = 1; } break;
338
+ case Property::GridColumnStart: if (rstyle(n->style).grid_line[1] != value) { rstyleMut(n->style).grid_line[1] = value; changed = 1; } break;
339
+ case Property::GridRowEnd: if (rstyle(n->style).grid_line[2] != value) { rstyleMut(n->style).grid_line[2] = value; changed = 1; } break;
340
+ case Property::GridColumnEnd: if (rstyle(n->style).grid_line[3] != value) { rstyleMut(n->style).grid_line[3] = value; changed = 1; } break;
341
+ case Property::Gap:
342
+ if (n->style.gap != value || n->style.row_gap != kUnset || n->style.column_gap != kUnset || n->style.row_gap_percent != kUnset || n->style.column_gap_percent != kUnset) {
343
+ n->style.gap = value;
344
+ n->style.row_gap = n->style.column_gap = n->style.row_gap_percent = n->style.column_gap_percent = kUnset;
345
+ changed = 1;
346
+ }
347
+ break;
205
348
  case Property::Width:
349
+ if (n->style.width_expression >= 0) { n->style.width_expression = -1; changed = 1; }
206
350
  if (n->style.width != value || n->style.width_percent != kUnset) {
207
351
  n->style.width = value;
208
352
  n->style.width_percent = kUnset;
@@ -210,6 +354,7 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
210
354
  }
211
355
  break;
212
356
  case Property::Height:
357
+ if (n->style.height_expression != -1) { n->style.height_expression = -1; changed = 1; }
213
358
  if (n->style.height != value || n->style.height_percent != kUnset) {
214
359
  n->style.height = value;
215
360
  n->style.height_percent = kUnset;
@@ -217,6 +362,7 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
217
362
  }
218
363
  break;
219
364
  case Property::WidthPercent:
365
+ if (n->style.width_expression >= 0) { n->style.width_expression = -1; changed = 1; }
220
366
  if (n->style.width_percent != value || n->style.width != kUnset) {
221
367
  n->style.width_percent = value;
222
368
  n->style.width = kUnset;
@@ -224,6 +370,7 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
224
370
  }
225
371
  break;
226
372
  case Property::HeightPercent:
373
+ if (n->style.height_expression != -1) { n->style.height_expression = -1; changed = 1; }
227
374
  if (n->style.height_percent != value || n->style.height != kUnset) {
228
375
  n->style.height_percent = value;
229
376
  n->style.height = kUnset;
@@ -236,16 +383,22 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
236
383
  case Property::MaxHeight: if (n->style.max_height != value) { n->style.max_height = value; changed = 1; } break;
237
384
  case Property::Flex: if (n->style.flex != value) { n->style.flex = value; changed = 1; } break;
238
385
  case Property::FlexShrink: if (n->style.flex_shrink != value) { n->style.flex_shrink = value; changed = 1; } break;
239
- case Property::FlexBasis: if (n->style.flex_basis != value) { n->style.flex_basis = value; changed = 1; } break;
240
- case Property::PaddingTop: if (n->style.padding[0] != value) { n->style.padding[0] = value; changed = 1; } break;
241
- case Property::PaddingRight: if (n->style.padding[1] != value) { n->style.padding[1] = value; changed = 1; } break;
242
- case Property::PaddingBottom: if (n->style.padding[2] != value) { n->style.padding[2] = value; changed = 1; } break;
243
- case Property::PaddingLeft: if (n->style.padding[3] != value) { n->style.padding[3] = value; changed = 1; } break;
244
- case Property::MarginTop: if (n->style.margin[0] != value) { n->style.margin[0] = value; changed = 1; } break;
245
- case Property::MarginRight: if (n->style.margin[1] != value) { n->style.margin[1] = value; changed = 1; } break;
246
- case Property::MarginBottom: if (n->style.margin[2] != value) { n->style.margin[2] = value; changed = 1; } break;
247
- case Property::MarginLeft: if (n->style.margin[3] != value) { n->style.margin[3] = value; changed = 1; } break;
248
- case Property::Position: if (n->style.position != value) { n->style.position = value; changed = 1; } break;
386
+ case Property::FlexBasis:
387
+ if (rstyle(n->style).flex_basis_expression >= 0) { rstyleMut(n->style).flex_basis_expression = -1; changed = 1; }
388
+ if (n->style.flex_basis != value) { n->style.flex_basis = value; changed = 1; } break;
389
+ case Property::FlexBasisExpression:
390
+ if (rstyle(n->style).flex_basis_expression != value || n->style.flex_basis != kUnset) {
391
+ rstyleMut(n->style).flex_basis_expression = value; n->style.flex_basis = kUnset; changed = 1;
392
+ } break;
393
+ case Property::PaddingTop: if (rstyle(n->style).padding_expression[0] >= 0) { rstyleMut(n->style).padding_expression[0] = -1; changed = 1; } if (n->style.padding[0] != value) { n->style.padding[0] = value; changed = 1; } break;
394
+ case Property::PaddingRight: if (rstyle(n->style).padding_expression[1] >= 0) { rstyleMut(n->style).padding_expression[1] = -1; changed = 1; } if (n->style.padding[1] != value) { n->style.padding[1] = value; changed = 1; } break;
395
+ case Property::PaddingBottom: if (rstyle(n->style).padding_expression[2] >= 0) { rstyleMut(n->style).padding_expression[2] = -1; changed = 1; } if (n->style.padding[2] != value) { n->style.padding[2] = value; changed = 1; } break;
396
+ case Property::PaddingLeft: if (rstyle(n->style).padding_expression[3] >= 0) { rstyleMut(n->style).padding_expression[3] = -1; changed = 1; } if (n->style.padding[3] != value) { n->style.padding[3] = value; changed = 1; } break;
397
+ case Property::MarginTop: if (rstyle(n->style).margin_expression[0] >= 0) { rstyleMut(n->style).margin_expression[0] = -1; changed = 1; } if (n->style.margin[0] != value || (n->style.margin_auto & 1)) { n->style.margin[0] = value; n->style.margin_auto &= ~1; changed = 1; } break;
398
+ case Property::MarginRight: if (rstyle(n->style).margin_expression[1] >= 0) { rstyleMut(n->style).margin_expression[1] = -1; changed = 1; } if (n->style.margin[1] != value || (n->style.margin_auto & 2)) { n->style.margin[1] = value; n->style.margin_auto &= ~2; changed = 1; } break;
399
+ case Property::MarginBottom: if (rstyle(n->style).margin_expression[2] >= 0) { rstyleMut(n->style).margin_expression[2] = -1; changed = 1; } if (n->style.margin[2] != value || (n->style.margin_auto & 4)) { n->style.margin[2] = value; n->style.margin_auto &= ~4; changed = 1; } break;
400
+ case Property::MarginLeft: if (rstyle(n->style).margin_expression[3] >= 0) { rstyleMut(n->style).margin_expression[3] = -1; changed = 1; } if (n->style.margin[3] != value || (n->style.margin_auto & 8)) { n->style.margin[3] = value; n->style.margin_auto &= ~8; changed = 1; } break;
401
+ case Property::Position: if (value == kPositionFixed) state.fixedPositionUsed = true; if (n->style.position != value) { n->style.position = value; changed = 1; } break;
249
402
  case Property::Top:
250
403
  if (n->style.pos_offsets[0] != value || n->style.pos_offset_percent[0] != kUnset) {
251
404
  n->style.pos_offsets[0] = value;
@@ -302,18 +455,35 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
302
455
  changed = 1;
303
456
  }
304
457
  break;
305
- case Property::ZIndex: if (n->style.z_index != value) { n->style.z_index = value; changed = 1; } break;
458
+ case Property::ZIndex: {
459
+ const bool automatic = value == kZIndexAuto;
460
+ const int level = automatic ? 0 : std::clamp(value, -32768, 32767);
461
+ if (n->style.z_index != level || n->style.z_index_auto != automatic) {
462
+ n->style.z_index = level; n->style.z_index_auto = automatic; changed = 1;
463
+ }
464
+ break;
465
+ }
306
466
  case Property::BackgroundColor: {
307
467
  style_color_t next = StyleValues::pixelFromStyleValue(value);
308
468
  if (n->style.bg_color != next) { n->style.bg_color = next; changed = 1; }
309
469
  if (n->style.bg_alpha != 255) { n->style.bg_alpha = 255; changed = 1; }
310
- if (n->style.bg_fill != 0) { n->style.bg_fill = 0; changed = 1; }
311
- if (rstyle(n->style).bg_gradient_has_mid != 0) { rstyleMut(n->style).bg_gradient_has_mid = 0; changed = 1; }
312
- if (rstyle(n->style).bg_overlay_gradient != 0) { rstyleMut(n->style).bg_overlay_gradient = 0; changed = 1; }
313
- if (rstyle(n->style).bg_radial_gradient != 0) { rstyleMut(n->style).bg_radial_gradient = 0; changed = 1; }
314
- if (rstyle(n->style).bg_grid_axes != 0) { rstyleMut(n->style).bg_grid_axes = 0; changed = 1; }
315
470
  break;
316
471
  }
472
+ case Property::BackgroundAlpha: {
473
+ const uint8_t alpha = static_cast<uint8_t>(std::clamp(value, 0, 255));
474
+ if (n->style.bg_alpha != alpha) { n->style.bg_alpha = alpha; changed = 1; }
475
+ break;
476
+ }
477
+ case Property::BackgroundClip: if (rstyle(n->style).bg_clip != value) { rstyleMut(n->style).bg_clip = value; changed = 1; } break;
478
+ case Property::BackgroundSizeList: if (rstyle(n->style).bg_size_list != value) { rstyleMut(n->style).bg_size_list = value; changed = 1; } break;
479
+ case Property::BackgroundPositionList: if (rstyle(n->style).bg_position_list != value) { rstyleMut(n->style).bg_position_list = value; changed = 1; } break;
480
+ case Property::BackgroundRepeatList: if (rstyle(n->style).bg_repeat_list != value) { rstyleMut(n->style).bg_repeat_list = value; changed = 1; } break;
481
+ case Property::BackgroundAttachmentList: if (rstyle(n->style).bg_attachment_list != value) { rstyleMut(n->style).bg_attachment_list = value; changed = 1; } break;
482
+ case Property::BackgroundOriginList: if (rstyle(n->style).bg_origin_list != value) { rstyleMut(n->style).bg_origin_list = value; changed = 1; } break;
483
+
484
+ case Property::BackgroundImage:
485
+ changed = StyleValues::applyBackgroundImage(n->style, value, node);
486
+ break;
317
487
  case Property::HasBackground: if (n->style.has_bg != value) { n->style.has_bg = value; changed = 1; } break;
318
488
  case Property::ActiveBackgroundColor: {
319
489
  style_color_t next = StyleValues::pixelFromStyleValue(value);
@@ -341,36 +511,81 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
341
511
  changed = 1;
342
512
  }
343
513
  break;
344
- case Property::BorderWidth: if (n->style.border_width != value) { n->style.border_width = value; changed = 1; } break;
514
+ case Property::ColorAlpha: {
515
+ const uint8_t alpha = static_cast<uint8_t>(std::clamp(value, 0, 255));
516
+ if (n->style.text_alpha != alpha) { n->style.text_alpha = alpha; changed = 1; }
517
+ break;
518
+ }
519
+ case Property::BorderAlpha: {
520
+ const uint8_t alpha = static_cast<uint8_t>(std::clamp(value, 0, 255));
521
+ if (n->style.border_alpha != alpha) { n->style.border_alpha = alpha; changed = 1; }
522
+ break;
523
+ }
524
+ case Property::BorderTopAlpha:
525
+ case Property::BorderRightAlpha:
526
+ case Property::BorderBottomAlpha:
527
+ case Property::BorderLeftAlpha:
528
+ {
529
+ const int side = static_cast<int>(prop) - static_cast<int>(Property::BorderTopAlpha);
530
+ const uint8_t alpha = static_cast<uint8_t>(std::clamp(value, 0, 255));
531
+ if (rstyle(n->style).border_side_alpha[side] != alpha) { rstyleMut(n->style).border_side_alpha[side] = alpha; changed = 1; }
532
+ break;
533
+ }
534
+ case Property::BorderColorCurrent: changed |= setBorderColorBinding(n->style, -1, value != 0); break;
535
+ case Property::BorderTopColorCurrent:
536
+ case Property::BorderRightColorCurrent:
537
+ case Property::BorderBottomColorCurrent:
538
+ case Property::BorderLeftColorCurrent:
539
+ changed |= setBorderColorBinding(n->style, static_cast<int>(prop) - static_cast<int>(Property::BorderTopColorCurrent), value != 0);
540
+ break;
541
+ case Property::BorderWidth: changed |= setComputedBorderWidth(n->style, -1, value, n->parent >= 0 ? &state.nodes[n->parent].style : nullptr); break;
345
542
  case Property::BorderColor: {
543
+ changed |= setBorderColorBinding(n->style, -1, false);
346
544
  style_color_t next = StyleValues::pixelFromStyleValue(value);
347
545
  if (n->style.border_color != next) { n->style.border_color = next; changed = 1; }
348
546
  if (n->style.border_alpha != 255) { n->style.border_alpha = 255; changed = 1; }
349
547
  break;
350
548
  }
351
- case Property::BorderTopWidth: if (rstyle(n->style).border_side_width[0] != value) { rstyleMut(n->style).border_side_width[0] = value; changed = 1; } break;
352
- case Property::BorderRightWidth: if (rstyle(n->style).border_side_width[1] != value) { rstyleMut(n->style).border_side_width[1] = value; changed = 1; } break;
353
- case Property::BorderBottomWidth: if (rstyle(n->style).border_side_width[2] != value) { rstyleMut(n->style).border_side_width[2] = value; changed = 1; } break;
354
- case Property::BorderLeftWidth: if (rstyle(n->style).border_side_width[3] != value) { rstyleMut(n->style).border_side_width[3] = value; changed = 1; } break;
549
+ case Property::BorderTopWidth: changed |= setComputedBorderWidth(n->style, 0, value, n->parent >= 0 ? &state.nodes[n->parent].style : nullptr); break;
550
+ case Property::BorderRelief:
551
+ case Property::BorderTopRelief:
552
+ case Property::BorderRightRelief:
553
+ case Property::BorderBottomRelief:
554
+ case Property::BorderLeftRelief:
555
+ for (int side = 0; side < 4; ++side) {
556
+ if (prop != Property::BorderRelief && side != static_cast<int>(prop) - static_cast<int>(Property::BorderTopRelief)) continue;
557
+ if (rstyle(n->style).border_relief[side] != value) {
558
+ rstyleMut(n->style).border_relief[side] = static_cast<uint8_t>(value);
559
+ changed = 1;
560
+ }
561
+ }
562
+ break;
563
+ case Property::BorderRightWidth: changed |= setComputedBorderWidth(n->style, 1, value, n->parent >= 0 ? &state.nodes[n->parent].style : nullptr); break;
564
+ case Property::BorderBottomWidth: changed |= setComputedBorderWidth(n->style, 2, value, n->parent >= 0 ? &state.nodes[n->parent].style : nullptr); break;
565
+ case Property::BorderLeftWidth: changed |= setComputedBorderWidth(n->style, 3, value, n->parent >= 0 ? &state.nodes[n->parent].style : nullptr); break;
355
566
  case Property::BorderTopColor: {
567
+ changed |= setBorderColorBinding(n->style, 0, false);
356
568
  style_color_t next = StyleValues::pixelFromStyleValue(value);
357
569
  if (rstyle(n->style).border_side_color[0] != next) { rstyleMut(n->style).border_side_color[0] = next; changed = 1; }
358
570
  if (rstyle(n->style).border_side_alpha[0] != 255) { rstyleMut(n->style).border_side_alpha[0] = 255; changed = 1; }
359
571
  break;
360
572
  }
361
573
  case Property::BorderRightColor: {
574
+ changed |= setBorderColorBinding(n->style, 1, false);
362
575
  style_color_t next = StyleValues::pixelFromStyleValue(value);
363
576
  if (rstyle(n->style).border_side_color[1] != next) { rstyleMut(n->style).border_side_color[1] = next; changed = 1; }
364
577
  if (rstyle(n->style).border_side_alpha[1] != 255) { rstyleMut(n->style).border_side_alpha[1] = 255; changed = 1; }
365
578
  break;
366
579
  }
367
580
  case Property::BorderBottomColor: {
581
+ changed |= setBorderColorBinding(n->style, 2, false);
368
582
  style_color_t next = StyleValues::pixelFromStyleValue(value);
369
583
  if (rstyle(n->style).border_side_color[2] != next) { rstyleMut(n->style).border_side_color[2] = next; changed = 1; }
370
584
  if (rstyle(n->style).border_side_alpha[2] != 255) { rstyleMut(n->style).border_side_alpha[2] = 255; changed = 1; }
371
585
  break;
372
586
  }
373
587
  case Property::BorderLeftColor: {
588
+ changed |= setBorderColorBinding(n->style, 3, false);
374
589
  style_color_t next = StyleValues::pixelFromStyleValue(value);
375
590
  if (rstyle(n->style).border_side_color[3] != next) { rstyleMut(n->style).border_side_color[3] = next; changed = 1; }
376
591
  if (rstyle(n->style).border_side_alpha[3] != 255) { rstyleMut(n->style).border_side_alpha[3] = 255; changed = 1; }
@@ -435,12 +650,31 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
435
650
  case Property::FontId: if (n->style.font_id != value) { n->style.font_id = value; changed = 1; } break;
436
651
  case Property::FontSize: if (n->style.font_size != value) { n->style.font_size = value; changed = 1; } break;
437
652
  case Property::FontWeight: if (n->style.font_weight != value) { n->style.font_weight = value; changed = 1; } break;
438
- case Property::LineHeight: if (n->style.line_height != value) { n->style.line_height = value; changed = 1; } break;
653
+ case Property::LineHeight:
654
+ if (n->style.line_height_multiplier >= 0) { n->style.line_height_multiplier = -1; changed = 1; }
655
+ if (rstyle(n->style).line_height_expression >= 0) { rstyleMut(n->style).line_height_expression = -1; changed = 1; }
656
+ if (n->style.line_height != value) { n->style.line_height = value; changed = 1; } break;
657
+ case Property::LineHeightExpression: {
658
+ if (n->style.line_height_multiplier >= 0) { n->style.line_height_multiplier = -1; changed = 1; }
659
+ const int height = resolveLineHeightExpression(node, value);
660
+ if (rstyle(n->style).line_height_expression != value || n->style.line_height != height) {
661
+ rstyleMut(n->style).line_height_expression = value; n->style.line_height = height; changed = 1;
662
+ } break;
663
+ }
664
+ case Property::LineHeightMultiplier: {
665
+ const int height = resolveLineHeightMultiplier(node, value);
666
+ if (rstyle(n->style).line_height_expression >= 0) { rstyleMut(n->style).line_height_expression = -1; changed = 1; }
667
+ if (n->style.line_height_multiplier != value || n->style.line_height != height) {
668
+ n->style.line_height_multiplier = value; n->style.line_height = height; changed = 1;
669
+ } break;
670
+ }
439
671
  case Property::TextAlign: if (n->style.text_align != value) { n->style.text_align = value; changed = 1; } break;
440
672
  case Property::TextDecoration: if (n->style.text_decoration != value) { n->style.text_decoration = value; changed = 1; } break;
441
673
  case Property::TextTransform: if (n->style.text_transform != value) { n->style.text_transform = value; changed = 1; } break;
442
674
  case Property::WhiteSpace: if (n->style.white_space != static_cast<int8_t>(value)) { n->style.white_space = static_cast<int8_t>(value); changed = 1; } break;
443
675
  case Property::TextOverflow: if (n->style.text_overflow != static_cast<int8_t>(value)) { n->style.text_overflow = static_cast<int8_t>(value); changed = 1; } break;
676
+ case Property::TransformStyle: if (rstyle(n->style).transform_preserve_3d != (value != 0)) { rstyleMut(n->style).transform_preserve_3d = value != 0; changed = 1; } break;
677
+ case Property::Visibility: if (n->style.visibility != static_cast<int8_t>(value)) { n->style.visibility = static_cast<int8_t>(value); changed = 1; } break;
444
678
  case Property::Backface: if (n->style.backface_hidden != static_cast<int8_t>(value)) { n->style.backface_hidden = static_cast<int8_t>(value); changed = 1; } break;
445
679
  case Property::PointerEvents: if (n->style.pointer_events != static_cast<int8_t>(value)) { n->style.pointer_events = static_cast<int8_t>(value); changed = 1; } break;
446
680
  case Property::Overflow: {
@@ -483,6 +717,24 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
483
717
  }
484
718
  case Property::ImageId: if (n->image_id != value) { n->image_id = value; changed = 1; } break;
485
719
  case Property::ImageFit: if (n->style.image_fit != value) { n->style.image_fit = value; changed = 1; } break;
720
+ case Property::TransformTranslateOuterAxes: if (rstyle(n->style).transform_translate_outer_axes != value) { rstyleMut(n->style).transform_translate_outer_axes = value; changed = 1; } break;
721
+ case Property::RotateAngle: if (rstyle(n->style).rotate_angle != value) { rstyleMut(n->style).rotate_angle = value; changed = 1; } break;
722
+ case Property::RotateAxisX: if (rstyle(n->style).rotate_axis_x != value) { rstyleMut(n->style).rotate_axis_x = value; changed = 1; } break;
723
+ case Property::RotateAxisY: if (rstyle(n->style).rotate_axis_y != value) { rstyleMut(n->style).rotate_axis_y = value; changed = 1; } break;
724
+ case Property::RotateAxisZ: if (rstyle(n->style).rotate_axis_z != value) { rstyleMut(n->style).rotate_axis_z = value; changed = 1; } break;
725
+ case Property::ScaleX: if (rstyle(n->style).scale_x != value) { rstyleMut(n->style).scale_x = value; changed = 1; } break;
726
+ case Property::ScaleY: if (rstyle(n->style).scale_y != value) { rstyleMut(n->style).scale_y = value; changed = 1; } break;
727
+ case Property::ScaleZ: if (rstyle(n->style).scale_z != value) { rstyleMut(n->style).scale_z = value; changed = 1; } break;
728
+ case Property::TranslatePresent: if (rstyle(n->style).translate_present != (value != 0)) { rstyleMut(n->style).translate_present = value != 0; changed = 1; } break;
729
+ case Property::TranslateX: if (rstyle(n->style).translate_x != value) { rstyleMut(n->style).translate_x = value; changed = 1; } break;
730
+ case Property::TranslateY: if (rstyle(n->style).translate_y != value) { rstyleMut(n->style).translate_y = value; changed = 1; } break;
731
+ case Property::TranslateZ: if (rstyle(n->style).translate_z != value) { rstyleMut(n->style).translate_z = value; changed = 1; } break;
732
+ case Property::TranslateXPercent: if (rstyle(n->style).translate_x_percent != value) { rstyleMut(n->style).translate_x_percent = value; changed = 1; } break;
733
+ case Property::TranslateYPercent: if (rstyle(n->style).translate_y_percent != value) { rstyleMut(n->style).translate_y_percent = value; changed = 1; } break;
734
+ case Property::TransformPresent: if (rstyle(n->style).transform_present != (value != 0)) { rstyleMut(n->style).transform_present = value != 0; changed = 1; } break;
735
+ case Property::RotatePresent: if (rstyle(n->style).rotate_present != (value != 0)) { rstyleMut(n->style).rotate_present = value != 0; changed = 1; } break;
736
+ case Property::ScalePresent: if (rstyle(n->style).scale_present != (value != 0)) { rstyleMut(n->style).scale_present = value != 0; changed = 1; } break;
737
+ case Property::FilterPresent: if (rstyle(n->style).filter_present != (value != 0)) { rstyleMut(n->style).filter_present = value != 0; changed = 1; } break;
486
738
  case Property::TransformRotate:
487
739
  if (rstyle(n->style).transform_rotate != value) {
488
740
  rstyleMut(n->style).transform_rotate = value;
@@ -498,6 +750,7 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
498
750
  case Property::TransformTranslateYPercent: if (rstyle(n->style).transform_translate_y_percent != value) { rstyleMut(n->style).transform_translate_y_percent = value; changed = 1; } break;
499
751
  case Property::TransformScaleX: if (rstyle(n->style).transform_scale_x != value) { rstyleMut(n->style).transform_scale_x = value; changed = 1; } break;
500
752
  case Property::TransformScaleY: if (rstyle(n->style).transform_scale_y != value) { rstyleMut(n->style).transform_scale_y = value; changed = 1; } break;
753
+ case Property::TransformScaleZ: if (rstyle(n->style).transform_scale_z != value) { rstyleMut(n->style).transform_scale_z = value; changed = 1; } break;
501
754
  case Property::TransformOriginX: if (rstyle(n->style).transform_origin_x != value) { rstyleMut(n->style).transform_origin_x = value; changed = 1; } break;
502
755
  case Property::TransformOriginY: if (rstyle(n->style).transform_origin_y != value) { rstyleMut(n->style).transform_origin_y = value; changed = 1; } break;
503
756
  case Property::Perspective: if (rstyle(n->style).perspective != value) { rstyleMut(n->style).perspective = value; changed = 1; } break;
@@ -532,7 +785,7 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
532
785
  return;
533
786
  }
534
787
  perf.treeSetStyleChanged++;
535
- if (isLayoutProperty(prop))
788
+ if (isLayoutProperty(prop) || (isTransformProperty(prop) && state.fixedPositionUsed))
536
789
  perf.treeSetStyleLayoutChanged++;
537
790
  if (isTransformProperty(prop))
538
791
  perf.treeSetStyleTransformChanged++;
@@ -540,6 +793,12 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
540
793
  perf.treeSetStylePaintChanged++;
541
794
  if (state.styleInvalidationSuppressionDepth > 0) return;
542
795
  if (!nodeParticipatesInMountedTree(state, node)) return;
796
+ if (prop == Property::Visibility || prop == Property::Backface || prop == Property::TransformStyle)
797
+ tree.markDisplayListDirty();
798
+ const int documentRoot = state.mountedRoot;
799
+ if (documentRoot >= 0 && documentRoot < state.nodeCount && isDocumentCanvasRoot(state.nodes[documentRoot]) &&
800
+ (node == documentRoot || (n->parent == documentRoot && std::string_view(tagFromId(n->tag_id)) == "body")))
801
+ tree.markDisplayListDirty();
543
802
  // An ImageId (src) swap on an element with a FIXED CSS display box (explicit
544
803
  // width+height — e.g. a forecast row's 24x20 icon re-pointed at a different icon
545
804
  // every data refresh) is PAINT-ONLY: the layout box is the styled box regardless
@@ -584,8 +843,9 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
584
843
  n->render.dirty = 1;
585
844
  // Paint-only properties (background, colors, shadows, ...) repaint in
586
845
  // place: geometry is untouched, so they don't demand a relayout pass.
587
- // Layout and transform properties keep the conservative marking.
588
- if (isLayoutProperty(prop) || isTransformProperty(prop))
846
+ // Keep geometry dirt separate from transform dirt: coalescing both must
847
+ // not let a retained transform update suppress the required relayout.
848
+ if (isLayoutProperty(prop) || (isTransformProperty(prop) && state.fixedPositionUsed))
589
849
  n->render.layout_dirty = 1;
590
850
  n->render.non_scroll_dirty = 1;
591
851
  if (isTransformProperty(prop)) {