@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/view.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "internal.h"
3
3
  #include "state_init.h"
4
+ #include "renderer_features.h"
4
5
  #include "style_values.h"
5
6
  #include "tree_state.h"
6
7
  #include <pixel.h>
@@ -60,11 +61,11 @@ uint8_t combineAlpha(uint8_t parentAlpha, uint8_t localAlpha)
60
61
 
61
62
  bool borderIsSameOpaqueSolidBackground(const Node &node, uint8_t parentAlpha)
62
63
  {
63
- return !hasBorderRelief(node.style) && node.style.has_bg &&
64
- StyleValues::backgroundClip(node.style, rstyle(node.style).bg_image_layer_count - 1) == 0 &&
65
- !styleHasBackgroundImage(node.style) &&
66
- node.style.bg_color == borderPaintColor(node.style, 0) &&
67
- combineAlpha(parentAlpha, node.style.bg_alpha) == combineAlpha(parentAlpha, borderPaintAlpha(node.style, 0));
64
+ return !hasBorderRelief(node.computedStyle()) && node.computedStyle().has_bg &&
65
+ StyleValues::backgroundClip(node.computedStyle(), rstyle(node.computedStyle()).bg_image_layer_count - 1) == 0 &&
66
+ !styleHasBackgroundImage(node.computedStyle()) &&
67
+ node.computedStyle().bg_color == borderPaintColor(node.computedStyle(), 0) &&
68
+ combineAlpha(parentAlpha, node.computedStyle().bg_alpha) == combineAlpha(parentAlpha, borderPaintAlpha(node.computedStyle(), 0));
68
69
  }
69
70
 
70
71
  void appendAlphaCommand(uint8_t alpha, int bx, int by, int bw, int bh)
@@ -129,7 +130,7 @@ int clampPermille(int value)
129
130
 
130
131
  int gradientToStop(const Node &node)
131
132
  {
132
- const int toStop = rstyle(node.style).bg_gradient_to_stop > 0 ? rstyle(node.style).bg_gradient_to_stop : 1000;
133
+ const int toStop = rstyle(node.computedStyle()).bg_gradient_to_stop > 0 ? rstyle(node.computedStyle()).bg_gradient_to_stop : 1000;
133
134
  return std::max(1, toStop);
134
135
  }
135
136
 
@@ -146,24 +147,24 @@ uint16_t gradientColorAt(const Node &node, int permille)
146
147
  {
147
148
  permille = clampPermille(permille);
148
149
  const int toStop = gradientToStop(node);
149
- if (rstyle(node.style).bg_gradient_has_mid && rstyle(node.style).bg_gradient_mid_stop > 0 && rstyle(node.style).bg_gradient_mid_stop < toStop) {
150
- const int stop = rstyle(node.style).bg_gradient_mid_stop;
150
+ if (rstyle(node.computedStyle()).bg_gradient_has_mid && rstyle(node.computedStyle()).bg_gradient_mid_stop > 0 && rstyle(node.computedStyle()).bg_gradient_mid_stop < toStop) {
151
+ const int stop = rstyle(node.computedStyle()).bg_gradient_mid_stop;
151
152
  if (permille <= stop)
152
- return interpolatePremultipliedColor(rstyle(node.style).bg_gradient_from_color,
153
- rstyle(node.style).bg_gradient_from_alpha,
154
- rstyle(node.style).bg_gradient_mid_color,
155
- rstyle(node.style).bg_gradient_mid_alpha,
153
+ return interpolatePremultipliedColor(rstyle(node.computedStyle()).bg_gradient_from_color,
154
+ rstyle(node.computedStyle()).bg_gradient_from_alpha,
155
+ rstyle(node.computedStyle()).bg_gradient_mid_color,
156
+ rstyle(node.computedStyle()).bg_gradient_mid_alpha,
156
157
  stopRangePermille(permille, 0, stop));
157
- return interpolatePremultipliedColor(rstyle(node.style).bg_gradient_mid_color,
158
- rstyle(node.style).bg_gradient_mid_alpha,
159
- rstyle(node.style).bg_gradient_to_color,
160
- rstyle(node.style).bg_gradient_to_alpha,
158
+ return interpolatePremultipliedColor(rstyle(node.computedStyle()).bg_gradient_mid_color,
159
+ rstyle(node.computedStyle()).bg_gradient_mid_alpha,
160
+ rstyle(node.computedStyle()).bg_gradient_to_color,
161
+ rstyle(node.computedStyle()).bg_gradient_to_alpha,
161
162
  stopRangePermille(permille, stop, toStop));
162
163
  }
163
- return interpolatePremultipliedColor(rstyle(node.style).bg_gradient_from_color,
164
- rstyle(node.style).bg_gradient_from_alpha,
165
- rstyle(node.style).bg_gradient_to_color,
166
- rstyle(node.style).bg_gradient_to_alpha,
164
+ return interpolatePremultipliedColor(rstyle(node.computedStyle()).bg_gradient_from_color,
165
+ rstyle(node.computedStyle()).bg_gradient_from_alpha,
166
+ rstyle(node.computedStyle()).bg_gradient_to_color,
167
+ rstyle(node.computedStyle()).bg_gradient_to_alpha,
167
168
  stopRangePermille(permille, 0, toStop));
168
169
  }
169
170
 
@@ -171,17 +172,17 @@ uint8_t gradientAlphaAt(const Node &node, int permille)
171
172
  {
172
173
  permille = clampPermille(permille);
173
174
  const int toStop = gradientToStop(node);
174
- if (rstyle(node.style).bg_gradient_has_mid && rstyle(node.style).bg_gradient_mid_stop > 0 && rstyle(node.style).bg_gradient_mid_stop < toStop) {
175
- const int stop = rstyle(node.style).bg_gradient_mid_stop;
175
+ if (rstyle(node.computedStyle()).bg_gradient_has_mid && rstyle(node.computedStyle()).bg_gradient_mid_stop > 0 && rstyle(node.computedStyle()).bg_gradient_mid_stop < toStop) {
176
+ const int stop = rstyle(node.computedStyle()).bg_gradient_mid_stop;
176
177
  if (permille <= stop)
177
- return interpolateAlpha(rstyle(node.style).bg_gradient_from_alpha,
178
- rstyle(node.style).bg_gradient_mid_alpha,
178
+ return interpolateAlpha(rstyle(node.computedStyle()).bg_gradient_from_alpha,
179
+ rstyle(node.computedStyle()).bg_gradient_mid_alpha,
179
180
  stopRangePermille(permille, 0, stop));
180
- return interpolateAlpha(rstyle(node.style).bg_gradient_mid_alpha,
181
- rstyle(node.style).bg_gradient_to_alpha,
181
+ return interpolateAlpha(rstyle(node.computedStyle()).bg_gradient_mid_alpha,
182
+ rstyle(node.computedStyle()).bg_gradient_to_alpha,
182
183
  stopRangePermille(permille, stop, toStop));
183
184
  }
184
- return interpolateAlpha(rstyle(node.style).bg_gradient_from_alpha, rstyle(node.style).bg_gradient_to_alpha, stopRangePermille(permille, 0, toStop));
185
+ return interpolateAlpha(rstyle(node.computedStyle()).bg_gradient_from_alpha, rstyle(node.computedStyle()).bg_gradient_to_alpha, stopRangePermille(permille, 0, toStop));
185
186
  }
186
187
 
187
188
  void appendFillRectWithAlpha(int x, int y, int w, int h, uint16_t color, uint8_t alpha, uint8_t parentAlpha, int bx, int by, int bw, int bh)
@@ -299,10 +300,10 @@ DisplayCommand *appendLinearGradientRectRaw(const Node &node, int x, int y, int
299
300
  cmd->gradient.y = y;
300
301
  cmd->gradient.w = w;
301
302
  cmd->gradient.h = h;
302
- cmd->gradient.tl = node.style.border_radius[0];
303
- cmd->gradient.tr = node.style.border_radius[1];
304
- cmd->gradient.br = node.style.border_radius[2];
305
- cmd->gradient.bl = node.style.border_radius[3];
303
+ cmd->gradient.tl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)];
304
+ cmd->gradient.tr = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)];
305
+ cmd->gradient.br = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)];
306
+ cmd->gradient.bl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)];
306
307
  cmd->gradient.fromColor = fromColor;
307
308
  cmd->gradient.midColor = midColor;
308
309
  cmd->gradient.toColor = toColor;
@@ -323,16 +324,16 @@ DisplayCommand *appendLinearGradientRectRaw(const Node &node, int x, int y, int
323
324
  y,
324
325
  w,
325
326
  h,
326
- rstyle(node.style).bg_gradient_from_color,
327
- rstyle(node.style).bg_gradient_mid_color,
328
- rstyle(node.style).bg_gradient_to_color,
329
- rstyle(node.style).bg_gradient_mid_stop,
330
- rstyle(node.style).bg_gradient_to_stop,
331
- rstyle(node.style).bg_gradient_angle,
332
- rstyle(node.style).bg_gradient_from_alpha,
333
- rstyle(node.style).bg_gradient_mid_alpha,
334
- rstyle(node.style).bg_gradient_to_alpha,
335
- rstyle(node.style).bg_gradient_has_mid);
327
+ rstyle(node.computedStyle()).bg_gradient_from_color,
328
+ rstyle(node.computedStyle()).bg_gradient_mid_color,
329
+ rstyle(node.computedStyle()).bg_gradient_to_color,
330
+ rstyle(node.computedStyle()).bg_gradient_mid_stop,
331
+ rstyle(node.computedStyle()).bg_gradient_to_stop,
332
+ rstyle(node.computedStyle()).bg_gradient_angle,
333
+ rstyle(node.computedStyle()).bg_gradient_from_alpha,
334
+ rstyle(node.computedStyle()).bg_gradient_mid_alpha,
335
+ rstyle(node.computedStyle()).bg_gradient_to_alpha,
336
+ rstyle(node.computedStyle()).bg_gradient_has_mid);
336
337
  }
337
338
 
338
339
  DisplayCommand *appendRadialGradientRectRaw(const Node &node, int x, int y, int w, int h)
@@ -348,19 +349,19 @@ DisplayCommand *appendRadialGradientRectRaw(const Node &node, int x, int y, int
348
349
  cmd->radialGradient.y = y;
349
350
  cmd->radialGradient.w = w;
350
351
  cmd->radialGradient.h = h;
351
- cmd->radialGradient.tl = node.style.border_radius[0];
352
- cmd->radialGradient.tr = node.style.border_radius[1];
353
- cmd->radialGradient.br = node.style.border_radius[2];
354
- cmd->radialGradient.bl = node.style.border_radius[3];
355
- cmd->radialGradient.cxPermille = rstyle(node.style).bg_radial_gradient_cx;
356
- cmd->radialGradient.cyPermille = rstyle(node.style).bg_radial_gradient_cy;
357
- cmd->radialGradient.rxPermille = rstyle(node.style).bg_radial_gradient_rx;
358
- cmd->radialGradient.ryPermille = rstyle(node.style).bg_radial_gradient_ry;
359
- cmd->radialGradient.fromColor = rstyle(node.style).bg_radial_gradient_from_color;
360
- cmd->radialGradient.toColor = rstyle(node.style).bg_radial_gradient_to_color;
361
- cmd->radialGradient.stopPermille = rstyle(node.style).bg_radial_gradient_stop;
362
- cmd->radialGradient.fromAlpha = rstyle(node.style).bg_radial_gradient_from_alpha;
363
- cmd->radialGradient.toAlpha = rstyle(node.style).bg_radial_gradient_to_alpha;
352
+ cmd->radialGradient.tl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)];
353
+ cmd->radialGradient.tr = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)];
354
+ cmd->radialGradient.br = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)];
355
+ cmd->radialGradient.bl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)];
356
+ cmd->radialGradient.cxPermille = rstyle(node.computedStyle()).bg_radial_gradient_cx;
357
+ cmd->radialGradient.cyPermille = rstyle(node.computedStyle()).bg_radial_gradient_cy;
358
+ cmd->radialGradient.rxPermille = rstyle(node.computedStyle()).bg_radial_gradient_rx;
359
+ cmd->radialGradient.ryPermille = rstyle(node.computedStyle()).bg_radial_gradient_ry;
360
+ cmd->radialGradient.fromColor = rstyle(node.computedStyle()).bg_radial_gradient_from_color;
361
+ cmd->radialGradient.toColor = rstyle(node.computedStyle()).bg_radial_gradient_to_color;
362
+ cmd->radialGradient.stopPermille = rstyle(node.computedStyle()).bg_radial_gradient_stop;
363
+ cmd->radialGradient.fromAlpha = rstyle(node.computedStyle()).bg_radial_gradient_from_alpha;
364
+ cmd->radialGradient.toAlpha = rstyle(node.computedStyle()).bg_radial_gradient_to_alpha;
364
365
  return cmd;
365
366
  }
366
367
 
@@ -426,31 +427,31 @@ void appendStrokeSegmentBandRaw(float x0, float y0, float x1, float y1, float wi
426
427
 
427
428
  bool gradientAlphaNearlyConstant(const Node &node)
428
429
  {
429
- uint8_t minAlpha = std::min(rstyle(node.style).bg_gradient_from_alpha, rstyle(node.style).bg_gradient_to_alpha);
430
- uint8_t maxAlpha = std::max(rstyle(node.style).bg_gradient_from_alpha, rstyle(node.style).bg_gradient_to_alpha);
431
- if (rstyle(node.style).bg_gradient_has_mid) {
432
- minAlpha = std::min(minAlpha, rstyle(node.style).bg_gradient_mid_alpha);
433
- maxAlpha = std::max(maxAlpha, rstyle(node.style).bg_gradient_mid_alpha);
430
+ uint8_t minAlpha = std::min(rstyle(node.computedStyle()).bg_gradient_from_alpha, rstyle(node.computedStyle()).bg_gradient_to_alpha);
431
+ uint8_t maxAlpha = std::max(rstyle(node.computedStyle()).bg_gradient_from_alpha, rstyle(node.computedStyle()).bg_gradient_to_alpha);
432
+ if (rstyle(node.computedStyle()).bg_gradient_has_mid) {
433
+ minAlpha = std::min(minAlpha, rstyle(node.computedStyle()).bg_gradient_mid_alpha);
434
+ maxAlpha = std::max(maxAlpha, rstyle(node.computedStyle()).bg_gradient_mid_alpha);
434
435
  }
435
436
  return maxAlpha - minAlpha <= 8;
436
437
  }
437
438
 
438
439
  bool hasAnyRadius(const Node &node)
439
440
  {
440
- return node.style.border_radius[0] || node.style.border_radius[1] ||
441
- node.style.border_radius[2] || node.style.border_radius[3] ||
442
- node.style.border_radius_percent[0] != kUnset ||
443
- node.style.border_radius_percent[1] != kUnset ||
444
- node.style.border_radius_percent[2] != kUnset ||
445
- node.style.border_radius_percent[3] != kUnset;
441
+ return node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)] || node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)] ||
442
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)] || node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)] ||
443
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] != kUnset ||
444
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] != kUnset ||
445
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] != kUnset ||
446
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] != kUnset;
446
447
  }
447
448
 
448
449
  bool hasAnyPercentRadius(const Node &node)
449
450
  {
450
- return node.style.border_radius_percent[0] != kUnset ||
451
- node.style.border_radius_percent[1] != kUnset ||
452
- node.style.border_radius_percent[2] != kUnset ||
453
- node.style.border_radius_percent[3] != kUnset;
451
+ return node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] != kUnset ||
452
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] != kUnset ||
453
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] != kUnset ||
454
+ node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] != kUnset;
454
455
  }
455
456
 
456
457
  int integerSqrt(int n)
@@ -474,10 +475,10 @@ int normalizedRadius(int radius, int maxRadius)
474
475
  void roundedNodeRowSpan(const Node &node, int y, int *x0, int *x1)
475
476
  {
476
477
  const int maxRadius = std::min(node.layout.width / 2, node.layout.height / 2);
477
- const int tl = normalizedRadius(node.style.border_radius[0], maxRadius);
478
- const int tr = normalizedRadius(node.style.border_radius[1], maxRadius);
479
- const int br = normalizedRadius(node.style.border_radius[2], maxRadius);
480
- const int bl = normalizedRadius(node.style.border_radius[3], maxRadius);
478
+ const int tl = normalizedRadius(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)], maxRadius);
479
+ const int tr = normalizedRadius(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)], maxRadius);
480
+ const int br = normalizedRadius(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)], maxRadius);
481
+ const int bl = normalizedRadius(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)], maxRadius);
481
482
  if ((tl | tr | br | bl) == 0) return;
482
483
 
483
484
  const int left = node.layout.x;
@@ -519,10 +520,10 @@ bool isFullyRoundedShape(const Node &node)
519
520
  const int halfMin = std::min(node.layout.width, node.layout.height) / 2;
520
521
  if (halfMin <= 0) return false;
521
522
  const int minRadius = std::max(1, halfMin - 1);
522
- return node.style.border_radius[0] >= minRadius &&
523
- node.style.border_radius[1] >= minRadius &&
524
- node.style.border_radius[2] >= minRadius &&
525
- node.style.border_radius[3] >= minRadius;
523
+ return node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)] >= minRadius &&
524
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)] >= minRadius &&
525
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)] >= minRadius &&
526
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)] >= minRadius;
526
527
  }
527
528
 
528
529
  void resolvedBorderRadii8(const Node &node, int16_t rx8[4], int16_t ry8[4])
@@ -532,12 +533,15 @@ void resolvedBorderRadii8(const Node &node, int16_t rx8[4], int16_t ry8[4])
532
533
  double rx[4]{};
533
534
  double ry[4]{};
534
535
  for (int i = 0; i < 4; i++) {
535
- if (node.style.border_radius_percent[i] != kUnset) {
536
- const double p = static_cast<double>(node.style.border_radius_percent[i]) / 1000.0;
536
+ #if GEA_CSS_PERCENT_RADIUS
537
+ if (node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != kUnset) {
538
+ const double p = static_cast<double>(node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(i)]) / 1000.0;
537
539
  rx[i] = std::max(0.0, width * p);
538
540
  ry[i] = std::max(0.0, height * p);
539
- } else {
540
- const double r = static_cast<double>(std::max(0, static_cast<int>(node.style.border_radius[i])));
541
+ } else
542
+ #endif
543
+ {
544
+ const double r = static_cast<double>(std::max(0, static_cast<int>(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(i)])));
541
545
  rx[i] = r;
542
546
  ry[i] = r;
543
547
  }
@@ -574,15 +578,15 @@ bool resolvedCircularBorderRadii(const Node &node, int radii[4])
574
578
 
575
579
  void appendFillRoundedRectWithAlpha(const Node &node, uint8_t parentAlpha, const int *resolvedRadii = nullptr)
576
580
  {
577
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.style.bg_alpha);
581
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.computedStyle().bg_alpha);
578
582
  if (effectiveAlpha != parentAlpha)
579
583
  appendAlphaCommand(effectiveAlpha, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
580
584
  DisplayCommand *cmd = DisplayList::instance().append();
581
585
  if (cmd) {
582
- const int tl = resolvedRadii ? resolvedRadii[0] : node.style.border_radius[0];
583
- const int tr = resolvedRadii ? resolvedRadii[1] : node.style.border_radius[1];
584
- const int br = resolvedRadii ? resolvedRadii[2] : node.style.border_radius[2];
585
- const int bl = resolvedRadii ? resolvedRadii[3] : node.style.border_radius[3];
586
+ const int tl = resolvedRadii ? resolvedRadii[0] : node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)];
587
+ const int tr = resolvedRadii ? resolvedRadii[1] : node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)];
588
+ const int br = resolvedRadii ? resolvedRadii[2] : node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)];
589
+ const int bl = resolvedRadii ? resolvedRadii[3] : node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)];
586
590
  cmd->type = DisplayCommandType::FillRoundedRect;
587
591
  cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
588
592
  cmd->fillRoundedRect.x = node.layout.x; cmd->fillRoundedRect.y = node.layout.y;
@@ -591,7 +595,7 @@ void appendFillRoundedRectWithAlpha(const Node &node, uint8_t parentAlpha, const
591
595
  cmd->fillRoundedRect.tr = tr;
592
596
  cmd->fillRoundedRect.br = br;
593
597
  cmd->fillRoundedRect.bl = bl;
594
- cmd->fillRoundedRect.color = node.style.bg_color;
598
+ cmd->fillRoundedRect.color = node.computedStyle().bg_color;
595
599
  }
596
600
  if (effectiveAlpha != parentAlpha)
597
601
  appendAlphaCommand(parentAlpha, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
@@ -675,7 +679,7 @@ void appendFillCircleWithAlpha(int cx, int cy, int r, gea::framework::graphics::
675
679
 
676
680
  void appendStrokeWithAlpha(const Node &node, uint8_t parentAlpha)
677
681
  {
678
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, borderPaintAlpha(node.style, 0));
682
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, borderPaintAlpha(node.computedStyle(), 0));
679
683
  if (effectiveAlpha != parentAlpha)
680
684
  appendAlphaCommand(effectiveAlpha, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
681
685
 
@@ -684,30 +688,30 @@ void appendStrokeWithAlpha(const Node &node, uint8_t parentAlpha)
684
688
  // Canvas::strokeRect is deliberately the fast one-pixel primitive. Route
685
689
  // wider square CSS borders through the width-aware rounded-rect rasterizer
686
690
  // with zero radii instead of silently collapsing border-width to 1px.
687
- if (hasAnyRadius(node) || node.style.border_width > 1) {
691
+ if (hasAnyRadius(node) || node.computedStyle().border_width > 1) {
688
692
  cmd->type = DisplayCommandType::StrokeRoundedRect;
689
693
  cmd->strokeRoundedRect = {};
690
694
  cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
691
695
  cmd->strokeRoundedRect.x = node.layout.x; cmd->strokeRoundedRect.y = node.layout.y;
692
696
  cmd->strokeRoundedRect.w = node.layout.width; cmd->strokeRoundedRect.h = node.layout.height;
693
- cmd->strokeRoundedRect.tl = node.style.border_radius[0];
694
- cmd->strokeRoundedRect.tr = node.style.border_radius[1];
695
- cmd->strokeRoundedRect.br = node.style.border_radius[2];
696
- cmd->strokeRoundedRect.bl = node.style.border_radius[3];
697
- cmd->strokeRoundedRect.lineWidth = node.style.border_width;
697
+ cmd->strokeRoundedRect.tl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)];
698
+ cmd->strokeRoundedRect.tr = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)];
699
+ cmd->strokeRoundedRect.br = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)];
700
+ cmd->strokeRoundedRect.bl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)];
701
+ cmd->strokeRoundedRect.lineWidth = node.computedStyle().border_width;
698
702
  resolvedBorderRadii8(node, cmd->strokeRoundedRect.rx8, cmd->strokeRoundedRect.ry8);
699
703
  cmd->strokeRoundedRect.cssRadii = hasAnyPercentRadius(node);
700
704
  for (int i = 0; i < 4; ++i)
701
705
  if (cmd->strokeRoundedRect.rx8[i] > std::min(node.layout.width, node.layout.height) * 4 ||
702
706
  cmd->strokeRoundedRect.ry8[i] > std::min(node.layout.width, node.layout.height) * 4)
703
707
  cmd->strokeRoundedRect.cssRadii = 1;
704
- cmd->strokeRoundedRect.color = borderPaintColor(node.style, 0);
708
+ cmd->strokeRoundedRect.color = borderPaintColor(node.computedStyle(), 0);
705
709
  } else {
706
710
  cmd->type = DisplayCommandType::StrokeRect;
707
711
  cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
708
712
  cmd->stroke.x = node.layout.x; cmd->stroke.y = node.layout.y;
709
713
  cmd->stroke.w = node.layout.width; cmd->stroke.h = node.layout.height;
710
- cmd->stroke.color = borderPaintColor(node.style, 0);
714
+ cmd->stroke.color = borderPaintColor(node.computedStyle(), 0);
711
715
  }
712
716
  }
713
717
 
@@ -752,7 +756,7 @@ public:
752
756
  // wrappers and text nodes.
753
757
  static bool hasTransformableBox(const Node &node)
754
758
  {
755
- if (node.style.display == kDisplayNone) return false;
759
+ if (node.computedStyle().display == kDisplayNone) return false;
756
760
  if (node.type == NodeType::Text) return false;
757
761
  if (node.type == NodeType::Image) return true;
758
762
  return !LayoutEngine::isCssInlineLevelBox(node);
@@ -760,8 +764,9 @@ public:
760
764
 
761
765
  static bool nodeHasLocalTransform(const Node &node, bool usePrevious)
762
766
  {
767
+ if (!GEA_CSS_TRANSFORMS) return false;
763
768
  if (usePrevious ? !node.render.previous_transformable_box : !hasTransformableBox(node)) return false;
764
- const RareStyle &rs = rstyle(node.style); // one pool lookup, not 10
769
+ const RareStyle &rs = rstyle(node.computedStyle()); // one pool lookup, not 10
765
770
  const int rotate = usePrevious ? node.render.previous_transform_rotate : rs.transform_rotate;
766
771
  const int rotateX = usePrevious ? node.render.previous_transform_rotate_x : rs.transform_rotate_x;
767
772
  const int rotateY = usePrevious ? node.render.previous_transform_rotate_y : rs.transform_rotate_y;
@@ -796,6 +801,7 @@ public:
796
801
  // record path is bypassed at O(1).
797
802
  static bool GEA_VIEW_HOT_SRAM_SECTION("any_transform_present") anyTransformPresent()
798
803
  {
804
+ #if GEA_CSS_TRANSFORMS
799
805
  auto &state = treeState();
800
806
  if (state.transformScanSerial == state.refreshSerial) return state.transformPresent;
801
807
  // Durable no-transform cache: a transform-free tree stays transform-free until a
@@ -809,7 +815,7 @@ public:
809
815
  for (int i = 0; i < state.nodeCount; i++) {
810
816
  const Node &n = state.nodes[i];
811
817
  if (nodeHasLocalTransform(n, false) || nodeHasLocalTransform(n, true) ||
812
- (hasTransformableBox(n) && rstyle(n.style).perspective > 0) ||
818
+ (hasTransformableBox(n) && rstyle(n.computedStyle()).perspective > 0) ||
813
819
  (n.render.previous_transformable_box && n.render.previous_perspective > 0)) {
814
820
  present = true;
815
821
  break;
@@ -819,6 +825,9 @@ public:
819
825
  state.transformScanSerial = state.refreshSerial;
820
826
  state.transformScanValid = true;
821
827
  return present;
828
+ #else
829
+ return false;
830
+ #endif
822
831
  }
823
832
 
824
833
  static bool GEA_VIEW_HOT_SRAM_SECTION("has_transform_chain") hasTransformChain(const Node &node, bool usePrevious)
@@ -828,7 +837,7 @@ public:
828
837
  for (int id = nodeIndex(node); id >= 0 && id < state.nodeCount; id = state.nodes[id].parent) {
829
838
  if (nodeHasLocalTransform(state.nodes[id], usePrevious)) return true;
830
839
  if (usePrevious ? !state.nodes[id].render.previous_transformable_box : !hasTransformableBox(state.nodes[id])) continue;
831
- const int perspective = usePrevious ? state.nodes[id].render.previous_perspective : rstyle(state.nodes[id].style).perspective;
840
+ const int perspective = usePrevious ? state.nodes[id].render.previous_perspective : rstyle(state.nodes[id].computedStyle()).perspective;
832
841
  if (perspective > 0) return true;
833
842
  }
834
843
  return false;
@@ -881,6 +890,7 @@ public:
881
890
  float previousMatrix[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
882
891
  };
883
892
 
893
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS
884
894
  struct AverageDepthCacheEntry {
885
895
  int nodeId = -1;
886
896
  int depth = 0;
@@ -946,6 +956,7 @@ public:
946
956
  for (int i = 0; i < count; i++) entries[i].nodeId = -1;
947
957
  }
948
958
 
959
+ #endif
949
960
  static Point3 applyLinear(const float *m, Point3 p)
950
961
  {
951
962
  return {m[0] * p.x + m[1] * p.y + m[2] * p.z,
@@ -999,7 +1010,7 @@ public:
999
1010
 
1000
1011
  static void fillNodeTransform(NodeTransformCache &e, const Node &node, int id)
1001
1012
  {
1002
- const RareStyle &r = rstyle(node.style);
1013
+ const RareStyle &r = rstyle(node.computedStyle());
1003
1014
  e.x = node.layout.x; e.y = node.layout.y; e.w = node.layout.width; e.h = node.layout.height;
1004
1015
  e.ox = e.x + e.w * r.transform_origin_x * kInv1000f;
1005
1016
  e.oy = e.y + e.h * r.transform_origin_y * kInv1000f;
@@ -1048,6 +1059,7 @@ public:
1048
1059
 
1049
1060
  static NodeTransformCache *cachedNodeTransform(const Node &node)
1050
1061
  {
1062
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS
1051
1063
  static ActiveTransformCache cache;
1052
1064
  const int id = nodeIndex(node);
1053
1065
  if (id < 0) return nullptr;
@@ -1085,6 +1097,10 @@ public:
1085
1097
  if (e.nodeId != -1) return nullptr;
1086
1098
  fillNodeTransform(e, node, id);
1087
1099
  return &e;
1100
+ #else
1101
+ (void)node;
1102
+ return nullptr;
1103
+ #endif
1088
1104
  }
1089
1105
 
1090
1106
  // Current-frame transform coefficients for a node, computed once per refresh
@@ -1099,6 +1115,7 @@ public:
1099
1115
  // is fixed within a refresh, and the serial bumps when the tree re-records (the
1100
1116
  // animating cube each frame). Only the current frame is cached; the colder
1101
1117
  // previous-frame (dirty-bounds) path computes directly.
1118
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS
1102
1119
  static const NodeTransformCache &nodeTransform(const Node &node)
1103
1120
  {
1104
1121
  if (NodeTransformCache *e = cachedNodeTransform(node)) return *e;
@@ -1107,6 +1124,15 @@ public:
1107
1124
  return fallback;
1108
1125
  }
1109
1126
 
1127
+ #else
1128
+ static NodeTransformCache nodeTransform(const Node &node)
1129
+ {
1130
+ NodeTransformCache value;
1131
+ fillNodeTransform(value, node, nodeIndex(node));
1132
+ return value;
1133
+ }
1134
+ #endif
1135
+
1110
1136
  // Pure hardware-FPU application of precomputed transform coefficients to a
1111
1137
  // point — no cache lookup, no divides, no trig. transformRectCorners hoists
1112
1138
  // the per-node cache lookup out of its 4-corner loop and calls this directly.
@@ -1120,6 +1146,7 @@ public:
1120
1146
  // Facing of a plane within its own CSS 3D rendering context.
1121
1147
  static bool backFacing(const Node &node)
1122
1148
  {
1149
+ #if GEA_CSS_TRANSFORMS
1123
1150
  auto &state = treeState();
1124
1151
  Point3 normal{0, 0, 1};
1125
1152
  float offset = 0;
@@ -1139,15 +1166,19 @@ public:
1139
1166
  id = state.nodes[id].parent;
1140
1167
  if (id < 0 || id >= state.nodeCount) break;
1141
1168
  const auto &parent = state.nodes[id];
1142
- const auto &rare = rstyle(parent.style);
1169
+ const auto &rare = rstyle(parent.computedStyle());
1143
1170
  if (hasTransformableBox(parent) && rare.perspective > 0) {
1144
1171
  const float ox = parent.layout.x + parent.layout.width * rare.perspective_origin_x * 0.001f;
1145
1172
  const float oy = parent.layout.y + parent.layout.height * rare.perspective_origin_y * 0.001f;
1146
1173
  normal.z += (offset + normal.x * ox + normal.y * oy) / rare.perspective;
1147
1174
  }
1148
- if (!hasTransformableBox(parent) || !preserves3D(parent.style)) break;
1175
+ if (!hasTransformableBox(parent) || !preserves3D(parent.computedStyle())) break;
1149
1176
  }
1150
1177
  return normal.z < -0.00001f;
1178
+ #else
1179
+ (void)node;
1180
+ return false;
1181
+ #endif
1151
1182
  }
1152
1183
 
1153
1184
  // Previous-frame analogue of applyCachedTransform — pure-FPU application of the
@@ -1222,7 +1253,7 @@ public:
1222
1253
  auto &state = treeState();
1223
1254
  for (int id = nodeIndex(node); id >= 0 && id < state.nodeCount; id = state.nodes[id].parent) {
1224
1255
  if (usePrevious ? !state.nodes[id].render.previous_transformable_box : !hasTransformableBox(state.nodes[id])) continue;
1225
- const int perspective = usePrevious ? state.nodes[id].render.previous_perspective : rstyle(state.nodes[id].style).perspective;
1256
+ const int perspective = usePrevious ? state.nodes[id].render.previous_perspective : rstyle(state.nodes[id].computedStyle()).perspective;
1226
1257
  if (perspective > 0) return id;
1227
1258
  }
1228
1259
  return -1;
@@ -1236,7 +1267,7 @@ public:
1236
1267
  const int y = usePrevious ? node.layout.previous_y : node.layout.y;
1237
1268
  const int w = usePrevious ? node.layout.previous_width : node.layout.width;
1238
1269
  const int h = usePrevious ? node.layout.previous_height : node.layout.height;
1239
- const RareStyle &rs = rstyle(node.style); // one pool lookup, not 3
1270
+ const RareStyle &rs = rstyle(node.computedStyle()); // one pool lookup, not 3
1240
1271
  const int perspective = usePrevious ? node.render.previous_perspective : rs.perspective;
1241
1272
  const int originX = usePrevious ? node.render.previous_perspective_origin_x : rs.perspective_origin_x;
1242
1273
  const int originY = usePrevious ? node.render.previous_perspective_origin_y : rs.perspective_origin_y;
@@ -1396,6 +1427,7 @@ public:
1396
1427
  // path isn't cached (cold, used only for dirty bounds).
1397
1428
  static int GEA_VIEW_HOT_SRAM_SECTION("average_depth") averageDepth(const Node &node, bool usePrevious)
1398
1429
  {
1430
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS
1399
1431
  if (usePrevious) return averageDepthCompute(node, true);
1400
1432
  static ActiveDepthCache cache;
1401
1433
  const int id = nodeIndex(node);
@@ -1414,6 +1446,9 @@ public:
1414
1446
  return d;
1415
1447
  }
1416
1448
  return averageDepthCompute(node, false);
1449
+ #else
1450
+ return averageDepthCompute(node, usePrevious);
1451
+ #endif
1417
1452
  }
1418
1453
 
1419
1454
  // The node's four projected screen-space corners for the current frame, cached
@@ -1422,6 +1457,7 @@ public:
1422
1457
  // collapses those (and the dirty pass's current-frame half) to one projection.
1423
1458
  static void GEA_VIEW_HOT_SRAM_SECTION("transform_corners") transformCorners(const Node &node, bool usePrevious, int16_t *xs, int16_t *ys)
1424
1459
  {
1460
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS
1425
1461
  if (usePrevious) {
1426
1462
  // Cache previous-frame corners per node per refresh, mirroring the current-frame
1427
1463
  // path below. The dirty-bounds collect projects each node's previous corners
@@ -1480,6 +1516,13 @@ public:
1480
1516
  }
1481
1517
  transformRectCorners(node, false, node.layout.x, node.layout.y,
1482
1518
  node.layout.width, node.layout.height, xs, ys);
1519
+ #else
1520
+ transformRectCorners(node, usePrevious,
1521
+ usePrevious ? node.layout.previous_x : node.layout.x,
1522
+ usePrevious ? node.layout.previous_y : node.layout.y,
1523
+ usePrevious ? node.layout.previous_width : node.layout.width,
1524
+ usePrevious ? node.layout.previous_height : node.layout.height, xs, ys);
1525
+ #endif
1483
1526
  }
1484
1527
  };
1485
1528
 
@@ -1490,13 +1533,13 @@ void appendReliefBordersWithAlpha(const Node &node, uint8_t parentAlpha)
1490
1533
  if (w <= 0 || h <= 0) return;
1491
1534
  int widths[4];
1492
1535
  for (int side = 0; side < 4; ++side)
1493
- widths[side] = std::min(computedBorderWidth(node.style, side), side % 2 ? w / 2 : h / 2);
1536
+ widths[side] = std::min(computedBorderWidth(node.computedStyle(), side), side % 2 ? w / 2 : h / 2);
1494
1537
  const bool transformed = ViewGeometry::hasTransformChain(node, false);
1495
1538
  for (int side = 0; side < 4; ++side) {
1496
1539
  if (widths[side] <= 0) continue;
1497
- const int relief = rstyle(node.style).border_relief[side];
1540
+ const int relief = rstyle(node.computedStyle()).border_relief[side];
1498
1541
  const int bands = relief == 1 || relief == 2 ? 2 : 1;
1499
- const auto color = borderPaintColor(node.style, side);
1542
+ const auto color = borderPaintColor(node.computedStyle(), side);
1500
1543
  int r, g, b; pixel::unpackRgb565(color, &r, &g, &b);
1501
1544
  r = pixel::expand5To8(r); g = pixel::expand6To8(g); b = pixel::expand5To8(b);
1502
1545
  // CSS permits UA-defined relief shades. Mixing with white keeps even a
@@ -1523,7 +1566,7 @@ void appendReliefBordersWithAlpha(const Node &node, uint8_t parentAlpha)
1523
1566
  const bool shadedDark = (side == 0 || side == 3) == inset;
1524
1567
  int bx0, by0, bx1, by1; boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
1525
1568
  appendFillQuadWithAlpha(xs, ys, relief == 0 ? color : shadedDark ? dark : light,
1526
- borderPaintAlpha(node.style, side), parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
1569
+ borderPaintAlpha(node.computedStyle(), side), parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
1527
1570
  }
1528
1571
  }
1529
1572
  }
@@ -1534,16 +1577,16 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
1534
1577
  const int y = node.layout.y;
1535
1578
  const int w = node.layout.width;
1536
1579
  const int h = node.layout.height;
1537
- if (hasBorderRelief(node.style)) { appendReliefBordersWithAlpha(node, parentAlpha); return; }
1538
- const bool textClippedTransform = StyleValues::hasTextBackgroundClip(node.style) &&
1580
+ if (hasBorderRelief(node.computedStyle())) { appendReliefBordersWithAlpha(node, parentAlpha); return; }
1581
+ const bool textClippedTransform = StyleValues::hasTextBackgroundClip(node.computedStyle()) &&
1539
1582
  ViewGeometry::hasTransformChain(node, false) && !isFullyRoundedShape(node);
1540
- if (w <= 0 || h <= 0 || (!hasSideBorder(node.style) && !borderColorsDiffer(node.style) && !textClippedTransform)) return;
1583
+ if (w <= 0 || h <= 0 || (!hasSideBorder(node.computedStyle()) && !borderColorsDiffer(node.computedStyle()) && !textClippedTransform)) return;
1541
1584
 
1542
1585
  const bool transformed = ViewGeometry::hasTransformChain(node, false);
1543
1586
  for (int side = 0; side < 4; ++side) {
1544
- const int borderWidth = std::max<int>(node.style.border_width, rstyle(node.style).border_side_width[side]);
1545
- const auto color = borderPaintColor(node.style, side);
1546
- const auto alpha = borderPaintAlpha(node.style, side);
1587
+ const int borderWidth = computedBorderWidth(node.computedStyle(), side);
1588
+ const auto color = borderPaintColor(node.computedStyle(), side);
1589
+ const auto alpha = borderPaintAlpha(node.computedStyle(), side);
1547
1590
  if (borderWidth <= 0) continue;
1548
1591
  int sx = x;
1549
1592
  int sy = y;
@@ -1563,8 +1606,8 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
1563
1606
  // Horizontal edges own the corners. Avoid compositing a translucent
1564
1607
  // asymmetric border twice where two side rectangles would overlap.
1565
1608
  if (side == 1 || side == 3) {
1566
- const int top = std::min<int>(std::max<int>(node.style.border_width, rstyle(node.style).border_side_width[0]), h);
1567
- const int bottom = std::min<int>(std::max<int>(node.style.border_width, rstyle(node.style).border_side_width[2]), h - top);
1609
+ const int top = std::min<int>(computedBorderWidth(node.computedStyle(), 0), h);
1610
+ const int bottom = std::min<int>(computedBorderWidth(node.computedStyle(), 2), h - top);
1568
1611
  sy += top;
1569
1612
  sh -= top + bottom;
1570
1613
  }
@@ -1646,26 +1689,26 @@ void recordLinearGradientBackground(const Node &node, uint8_t parentAlpha)
1646
1689
  g.ly = static_cast<int16_t>(y);
1647
1690
  g.lw = static_cast<int16_t>(w);
1648
1691
  g.lh = static_cast<int16_t>(h);
1649
- g.fromColor = rstyle(node.style).bg_gradient_from_color;
1650
- g.midColor = rstyle(node.style).bg_gradient_mid_color;
1651
- g.toColor = rstyle(node.style).bg_gradient_to_color;
1652
- g.midStop = static_cast<uint16_t>(rstyle(node.style).bg_gradient_mid_stop);
1692
+ g.fromColor = rstyle(node.computedStyle()).bg_gradient_from_color;
1693
+ g.midColor = rstyle(node.computedStyle()).bg_gradient_mid_color;
1694
+ g.toColor = rstyle(node.computedStyle()).bg_gradient_to_color;
1695
+ g.midStop = static_cast<uint16_t>(rstyle(node.computedStyle()).bg_gradient_mid_stop);
1653
1696
  g.toStop = static_cast<uint16_t>(gradientToStop(node));
1654
- g.angle = static_cast<int16_t>(rstyle(node.style).bg_gradient_angle);
1655
- g.fromAlpha = rstyle(node.style).bg_gradient_from_alpha;
1656
- g.midAlpha = rstyle(node.style).bg_gradient_mid_alpha;
1657
- g.toAlpha = rstyle(node.style).bg_gradient_to_alpha;
1658
- g.hasMid = rstyle(node.style).bg_gradient_has_mid ? 1 : 0;
1659
- g.backfaceHidden = node.style.backface_hidden ? 1 : 0;
1697
+ g.angle = static_cast<int16_t>(rstyle(node.computedStyle()).bg_gradient_angle);
1698
+ g.fromAlpha = rstyle(node.computedStyle()).bg_gradient_from_alpha;
1699
+ g.midAlpha = rstyle(node.computedStyle()).bg_gradient_mid_alpha;
1700
+ g.toAlpha = rstyle(node.computedStyle()).bg_gradient_to_alpha;
1701
+ g.hasMid = rstyle(node.computedStyle()).bg_gradient_has_mid ? 1 : 0;
1702
+ g.backfaceHidden = node.computedStyle().backface_hidden ? 1 : 0;
1660
1703
  // Transformed rectangular borders ride this command as an edge frame (the
1661
1704
  // span rasterizer paints the first/last edgeWidth px of every span, tracing
1662
1705
  // the quad outline). Emitting projected stroke quads instead would disarm
1663
1706
  // the transform-reproject fast path every frame.
1664
- if (!StyleValues::hasTextBackgroundClip(node.style) && node.style.border_width > 0 && !hasBorderRelief(node.style) && !hasSideBorder(node.style) && !borderColorsDiffer(node.style) && borderPaintAlpha(node.style, 0) > 0 &&
1707
+ if (!StyleValues::hasTextBackgroundClip(node.computedStyle()) && node.computedStyle().border_width > 0 && !hasBorderRelief(node.computedStyle()) && !hasSideBorder(node.computedStyle()) && !borderColorsDiffer(node.computedStyle()) && borderPaintAlpha(node.computedStyle(), 0) > 0 &&
1665
1708
  !isFullyRoundedShape(node)) {
1666
- g.edgeColor = borderPaintColor(node.style, 0);
1667
- g.edgeAlpha = borderPaintAlpha(node.style, 0);
1668
- const int ew = node.style.border_width < 1 ? 1 : node.style.border_width;
1709
+ g.edgeColor = borderPaintColor(node.computedStyle(), 0);
1710
+ g.edgeAlpha = borderPaintAlpha(node.computedStyle(), 0);
1711
+ const int ew = node.computedStyle().border_width < 1 ? 1 : node.computedStyle().border_width;
1669
1712
  g.edgeWidth = static_cast<uint8_t>(ew > 8 ? 8 : ew);
1670
1713
  } else {
1671
1714
  g.edgeColor = 0;
@@ -1676,7 +1719,7 @@ void recordLinearGradientBackground(const Node &node, uint8_t parentAlpha)
1676
1719
 
1677
1720
  void recordRadialGradientBackground(const Node &node)
1678
1721
  {
1679
- if (!rstyle(node.style).bg_radial_gradient) return;
1722
+ if (!rstyle(node.computedStyle()).bg_radial_gradient) return;
1680
1723
  const int x = node.layout.x;
1681
1724
  const int y = node.layout.y;
1682
1725
  const int w = node.layout.width;
@@ -1688,7 +1731,7 @@ void recordRadialGradientBackground(const Node &node)
1688
1731
 
1689
1732
  void recordOverlayLinearGradientBackground(const Node &node)
1690
1733
  {
1691
- if (!rstyle(node.style).bg_overlay_gradient) return;
1734
+ if (!rstyle(node.computedStyle()).bg_overlay_gradient) return;
1692
1735
  const int x = node.layout.x;
1693
1736
  const int y = node.layout.y;
1694
1737
  const int w = node.layout.width;
@@ -1700,44 +1743,44 @@ void recordOverlayLinearGradientBackground(const Node &node)
1700
1743
  y,
1701
1744
  w,
1702
1745
  h,
1703
- rstyle(node.style).bg_overlay_gradient_from_color,
1704
- rstyle(node.style).bg_overlay_gradient_mid_color,
1705
- rstyle(node.style).bg_overlay_gradient_to_color,
1706
- rstyle(node.style).bg_overlay_gradient_mid_stop,
1707
- rstyle(node.style).bg_overlay_gradient_to_stop,
1708
- rstyle(node.style).bg_overlay_gradient_angle,
1709
- rstyle(node.style).bg_overlay_gradient_from_alpha,
1710
- rstyle(node.style).bg_overlay_gradient_mid_alpha,
1711
- rstyle(node.style).bg_overlay_gradient_to_alpha,
1712
- rstyle(node.style).bg_overlay_gradient_has_mid);
1746
+ rstyle(node.computedStyle()).bg_overlay_gradient_from_color,
1747
+ rstyle(node.computedStyle()).bg_overlay_gradient_mid_color,
1748
+ rstyle(node.computedStyle()).bg_overlay_gradient_to_color,
1749
+ rstyle(node.computedStyle()).bg_overlay_gradient_mid_stop,
1750
+ rstyle(node.computedStyle()).bg_overlay_gradient_to_stop,
1751
+ rstyle(node.computedStyle()).bg_overlay_gradient_angle,
1752
+ rstyle(node.computedStyle()).bg_overlay_gradient_from_alpha,
1753
+ rstyle(node.computedStyle()).bg_overlay_gradient_mid_alpha,
1754
+ rstyle(node.computedStyle()).bg_overlay_gradient_to_alpha,
1755
+ rstyle(node.computedStyle()).bg_overlay_gradient_has_mid);
1713
1756
  }
1714
1757
 
1715
1758
  // Background positioning and painting areas are distinct. In particular, the
1716
1759
  // document canvas paints beyond the root box without stretching its images.
1717
1760
  bool recordPlacedBackgrounds(const Node &geometry, const Node &source, bool canvas)
1718
1761
  {
1719
- const auto &r = rstyle(source.style);
1762
+ const auto &r = rstyle(source.computedStyle());
1720
1763
  if (!canvas && r.bg_size_list < 0 && r.bg_position_list < 0 && r.bg_repeat_list < 0 &&
1721
1764
  r.bg_attachment_list < 0 && r.bg_origin_list < 0) return false;
1722
1765
  if (ViewGeometry::hasTransformChain(geometry, false)) return false;
1723
1766
  const int nodeId = ViewGeometry::nodeIndex(geometry);
1724
1767
  for (int layer = r.bg_image_layer_count-1; layer >= 0; --layer) {
1725
- const bool linear = source.style.bg_fill == 1 && layer == r.bg_gradient_layer;
1768
+ const bool linear = source.computedStyle().bg_fill == 1 && layer == r.bg_gradient_layer;
1726
1769
  const bool overlay = r.bg_overlay_gradient && layer == r.bg_overlay_gradient_layer;
1727
1770
  const bool radial = r.bg_radial_gradient && layer == r.bg_radial_gradient_layer;
1728
1771
  if (!linear && !overlay && !radial) continue;
1729
- const auto p = StyleValues::backgroundPlacement(source.style, nodeId, layer,
1772
+ const auto p = StyleValues::backgroundPlacement(source.computedStyle(), nodeId, layer,
1730
1773
  geometry.layout.x, geometry.layout.y, geometry.layout.width, geometry.layout.height);
1731
1774
  if (p.width <= 0 || p.height <= 0) continue;
1732
1775
  int x = canvas ? 0 : geometry.layout.x, y = canvas ? 0 : geometry.layout.y;
1733
1776
  int w = canvas ? treeState().mountedWidth : geometry.layout.width;
1734
1777
  int h = canvas ? treeState().mountedHeight : geometry.layout.height;
1735
- const int clip = canvas ? 0 : StyleValues::backgroundClip(source.style, layer);
1778
+ const int clip = canvas ? 0 : StyleValues::backgroundClip(source.computedStyle(), layer);
1736
1779
  TextBackgroundClipScope textClip(source, clip);
1737
1780
  if (clip == 1 || clip == 2) {
1738
1781
  int inset[4];
1739
- for (int i = 0; i < 4; ++i) inset[i] = std::max<int>(geometry.style.border_width, rstyle(geometry.style).border_side_width[i]) +
1740
- (clip == 2 ? std::max<int>(0, geometry.style.padding[i]) : 0);
1782
+ for (int i = 0; i < 4; ++i) inset[i] = computedBorderWidth(geometry.computedStyle(), i) +
1783
+ (clip == 2 ? std::max<int>(0, geometry.computedStyle().padding[i]) : 0);
1741
1784
  x += inset[3]; y += inset[0]; w -= inset[1]+inset[3]; h -= inset[0]+inset[2];
1742
1785
  }
1743
1786
  if (w <= 0 || h <= 0) continue;
@@ -1793,7 +1836,7 @@ void recordTransformedEllipseFill(const Node &node, uint8_t parentAlpha)
1793
1836
 
1794
1837
  int bx0, by0, bx1, by1;
1795
1838
  ViewRenderer::transformedBounds(node, false, &bx0, &by0, &bx1, &by1);
1796
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.style.bg_alpha);
1839
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.computedStyle().bg_alpha);
1797
1840
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
1798
1841
 
1799
1842
  const double cx = static_cast<double>(x) + static_cast<double>(w) * 0.5;
@@ -1819,7 +1862,7 @@ void recordTransformedEllipseFill(const Node &node, uint8_t parentAlpha)
1819
1862
  ViewGeometry::transformRectCorners(node, false, sx, sy, sw, sh, xs, ys);
1820
1863
  int qx0, qy0, qx1, qy1;
1821
1864
  boundsFromCorners(xs, ys, &qx0, &qy0, &qx1, &qy1);
1822
- appendFillQuadRaw(xs, ys, node.style.bg_color, qx0, qy0, qx1 - qx0 + 1, qy1 - qy0 + 1,
1865
+ appendFillQuadRaw(xs, ys, node.computedStyle().bg_color, qx0, qy0, qx1 - qx0 + 1, qy1 - qy0 + 1,
1823
1866
  sx, sy, sw, sh, true);
1824
1867
  }
1825
1868
 
@@ -1831,8 +1874,8 @@ void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha, int
1831
1874
  int inset[4]{};
1832
1875
  if (backgroundClip > 0)
1833
1876
  for (int i = 0; i < 4; ++i)
1834
- inset[i] = std::max<int>(node.style.border_width, rstyle(node.style).border_side_width[i]) +
1835
- (backgroundClip == 2 ? std::max<int>(0, node.style.padding[i]) : 0);
1877
+ inset[i] = computedBorderWidth(node.computedStyle(), i) +
1878
+ (backgroundClip == 2 ? std::max<int>(0, node.computedStyle().padding[i]) : 0);
1836
1879
  const int x = node.layout.x + inset[3];
1837
1880
  const int y = node.layout.y + inset[0];
1838
1881
  const int w = node.layout.width - inset[3] - inset[1];
@@ -1843,7 +1886,7 @@ void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha, int
1843
1886
  ViewGeometry::transformRectCorners(node, false, x, y, w, h, xs, ys);
1844
1887
  int bx0, by0, bx1, by1;
1845
1888
  boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
1846
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.style.bg_alpha);
1889
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.computedStyle().bg_alpha);
1847
1890
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
1848
1891
  int16_t rx8[4]{};
1849
1892
  int16_t ry8[4]{};
@@ -1872,8 +1915,8 @@ void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha, int
1872
1915
  r.trRx8 = rx8[1]; r.trRy8 = ry8[1];
1873
1916
  r.brRx8 = rx8[2]; r.brRy8 = ry8[2];
1874
1917
  r.blRx8 = rx8[3]; r.blRy8 = ry8[3];
1875
- r.color = node.style.bg_color;
1876
- r.backfaceHidden = node.style.backface_hidden ? 1 : 0;
1918
+ r.color = node.computedStyle().bg_color;
1919
+ r.backfaceHidden = node.computedStyle().backface_hidden ? 1 : 0;
1877
1920
  }
1878
1921
 
1879
1922
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
@@ -1885,16 +1928,16 @@ void recordTransformedEllipseStroke(const Node &node, uint8_t parentAlpha)
1885
1928
  const int y = node.layout.y;
1886
1929
  const int w = node.layout.width;
1887
1930
  const int h = node.layout.height;
1888
- if (w <= 0 || h <= 0 || node.style.border_width <= 0) return;
1931
+ if (w <= 0 || h <= 0 || node.computedStyle().border_width <= 0) return;
1889
1932
 
1890
1933
  int bx0, by0, bx1, by1;
1891
1934
  ViewRenderer::transformedBounds(node, false, &bx0, &by0, &bx1, &by1);
1892
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, borderPaintAlpha(node.style, 0));
1935
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, borderPaintAlpha(node.computedStyle(), 0));
1893
1936
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
1894
1937
 
1895
1938
  const float cx = static_cast<float>(x) + static_cast<float>(w) * 0.5f;
1896
1939
  const float cy = static_cast<float>(y) + static_cast<float>(h) * 0.5f;
1897
- const float stroke = static_cast<float>(node.style.border_width < 1 ? 1 : node.style.border_width);
1940
+ const float stroke = static_cast<float>(node.computedStyle().border_width < 1 ? 1 : node.computedStyle().border_width);
1898
1941
  const float screenStroke = std::max(1.6f, stroke * 1.2f);
1899
1942
  const float rx = std::max(0.0f, static_cast<float>(w) * 0.5f - stroke * 0.5f);
1900
1943
  const float ry = std::max(0.0f, static_cast<float>(h) * 0.5f - stroke * 0.5f);
@@ -1917,7 +1960,7 @@ void recordTransformedEllipseStroke(const Node &node, uint8_t parentAlpha)
1917
1960
  int16_t px, py;
1918
1961
  ViewGeometry::projectPoint(projector, localX, localY, 0.0f, &px, &py);
1919
1962
  if (i > 0)
1920
- appendStrokeSegmentBandRaw(prevX, prevY, px, py, screenStroke, borderPaintColor(node.style, 0),
1963
+ appendStrokeSegmentBandRaw(prevX, prevY, px, py, screenStroke, borderPaintColor(node.computedStyle(), 0),
1921
1964
  prevLocalX, prevLocalY, localX, localY, true);
1922
1965
  prevX = px;
1923
1966
  prevY = py;
@@ -1944,11 +1987,11 @@ void appendBackgroundGridRectRaw(const Node &node, int x, int y, int w, int h)
1944
1987
  if (xs[2] - xs[3] < 1) xs[2] = xs[3] + 1; // bottom edge width (BR right of BL)
1945
1988
  int bx0, by0, bx1, by1;
1946
1989
  boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
1947
- appendFillQuadRaw(xs, ys, rstyle(node.style).bg_grid_color, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1,
1990
+ appendFillQuadRaw(xs, ys, rstyle(node.computedStyle()).bg_grid_color, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1,
1948
1991
  x, y, w, h, 3);
1949
1992
  } else {
1950
1993
  if (!hasAnyRadius(node)) {
1951
- appendFillRectRaw(x, y, w, h, rstyle(node.style).bg_grid_color, x, y, w, h);
1994
+ appendFillRectRaw(x, y, w, h, rstyle(node.computedStyle()).bg_grid_color, x, y, w, h);
1952
1995
  return;
1953
1996
  }
1954
1997
  int runX0 = 0;
@@ -1957,7 +2000,7 @@ void appendBackgroundGridRectRaw(const Node &node, int x, int y, int w, int h)
1957
2000
  int runH = 0;
1958
2001
  auto flushRun = [&]() {
1959
2002
  if (runH > 0 && runX0 <= runX1)
1960
- appendFillRectRaw(runX0, runY, runX1 - runX0 + 1, runH, rstyle(node.style).bg_grid_color, runX0, runY, runX1 - runX0 + 1, runH);
2003
+ appendFillRectRaw(runX0, runY, runX1 - runX0 + 1, runH, rstyle(node.computedStyle()).bg_grid_color, runX0, runY, runX1 - runX0 + 1, runH);
1961
2004
  runH = 0;
1962
2005
  };
1963
2006
  for (int py = y; py < y + h; ++py) {
@@ -1984,8 +2027,8 @@ void appendBackgroundGridRectRaw(const Node &node, int x, int y, int w, int h)
1984
2027
 
1985
2028
  void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
1986
2029
  {
1987
- if (rstyle(node.style).bg_grid_axes == 0) return;
1988
- const auto placement = StyleValues::backgroundPlacement(node.style, ViewGeometry::nodeIndex(node), 0, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
2030
+ if (rstyle(node.computedStyle()).bg_grid_axes == 0) return;
2031
+ const auto placement = StyleValues::backgroundPlacement(node.computedStyle(), ViewGeometry::nodeIndex(node), 0, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
1989
2032
  const int x0 = node.layout.x;
1990
2033
  const int y0 = node.layout.y;
1991
2034
  const int x1 = node.layout.x + node.layout.width;
@@ -1995,23 +2038,23 @@ void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
1995
2038
  int bx0 = x0, by0 = y0, bx1 = x1 - 1, by1 = y1 - 1;
1996
2039
  if (ViewGeometry::hasTransformChain(node, false))
1997
2040
  ViewRenderer::transformedBounds(node, false, &bx0, &by0, &bx1, &by1);
1998
- const uint8_t effectiveAlpha = combineAlpha(parentAlpha, rstyle(node.style).bg_grid_alpha);
2041
+ const uint8_t effectiveAlpha = combineAlpha(parentAlpha, rstyle(node.computedStyle()).bg_grid_alpha);
1999
2042
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
2000
2043
 
2001
- if ((rstyle(node.style).bg_grid_axes & 1) != 0 && rstyle(node.style).bg_grid_line_x > 0) {
2002
- const int step = rstyle(node.style).bg_size_list >= 0 ? placement.width : rstyle(node.style).bg_grid_step_x > 0 ? rstyle(node.style).bg_grid_step_x : rstyle(node.style).bg_grid_line_x;
2044
+ if ((rstyle(node.computedStyle()).bg_grid_axes & 1) != 0 && rstyle(node.computedStyle()).bg_grid_line_x > 0) {
2045
+ const int step = rstyle(node.computedStyle()).bg_size_list >= 0 ? placement.width : rstyle(node.computedStyle()).bg_grid_step_x > 0 ? rstyle(node.computedStyle()).bg_grid_step_x : rstyle(node.computedStyle()).bg_grid_line_x;
2003
2046
  if (step > 0) {
2004
2047
  for (int x = x0; x < x1; x += step) {
2005
- const int w = std::min<int>(rstyle(node.style).bg_grid_line_x, x1 - x);
2048
+ const int w = std::min<int>(rstyle(node.computedStyle()).bg_grid_line_x, x1 - x);
2006
2049
  appendBackgroundGridRectRaw(node, x, y0, w, y1 - y0);
2007
2050
  }
2008
2051
  }
2009
2052
  }
2010
- if ((rstyle(node.style).bg_grid_axes & 2) != 0 && rstyle(node.style).bg_grid_line_y > 0) {
2011
- const int step = rstyle(node.style).bg_size_list >= 0 ? placement.height : rstyle(node.style).bg_grid_step_y > 0 ? rstyle(node.style).bg_grid_step_y : rstyle(node.style).bg_grid_line_y;
2053
+ if ((rstyle(node.computedStyle()).bg_grid_axes & 2) != 0 && rstyle(node.computedStyle()).bg_grid_line_y > 0) {
2054
+ const int step = rstyle(node.computedStyle()).bg_size_list >= 0 ? placement.height : rstyle(node.computedStyle()).bg_grid_step_y > 0 ? rstyle(node.computedStyle()).bg_grid_step_y : rstyle(node.computedStyle()).bg_grid_line_y;
2012
2055
  if (step > 0) {
2013
2056
  for (int y = y0; y < y1; y += step) {
2014
- const int h = std::min<int>(rstyle(node.style).bg_grid_line_y, y1 - y);
2057
+ const int h = std::min<int>(rstyle(node.computedStyle()).bg_grid_line_y, y1 - y);
2015
2058
  appendBackgroundGridRectRaw(node, x0, y, x1 - x0, h);
2016
2059
  }
2017
2060
  }
@@ -2020,6 +2063,7 @@ void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
2020
2063
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
2021
2064
  }
2022
2065
 
2066
+ #if GEA_CSS_BOX_SHADOW
2023
2067
  uint8_t insetShadowAlphaAt(int depth, int solidDepth, int blurRadius, uint8_t baseAlpha)
2024
2068
  {
2025
2069
  if (baseAlpha == 0) return 0;
@@ -2044,7 +2088,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
2044
2088
  boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
2045
2089
  appendFillQuadWithAlpha(xs,
2046
2090
  ys,
2047
- rstyle(node.style).box_shadow_color,
2091
+ (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_color : 0),
2048
2092
  alpha,
2049
2093
  parentAlpha,
2050
2094
  bx0,
@@ -2059,7 +2103,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
2059
2103
  return;
2060
2104
  }
2061
2105
  if (!hasAnyRadius(node)) {
2062
- appendFillRectWithAlpha(x, y, w, h, rstyle(node.style).box_shadow_color, alpha, parentAlpha, x, y, w, h);
2106
+ appendFillRectWithAlpha(x, y, w, h, (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_color : 0), alpha, parentAlpha, x, y, w, h);
2063
2107
  return;
2064
2108
  }
2065
2109
  int runX0 = 0;
@@ -2072,7 +2116,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
2072
2116
  runY,
2073
2117
  runX1 - runX0 + 1,
2074
2118
  runH,
2075
- rstyle(node.style).box_shadow_color,
2119
+ (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_color : 0),
2076
2120
  alpha,
2077
2121
  parentAlpha,
2078
2122
  runX0,
@@ -2126,7 +2170,7 @@ void constrainShadowRadii(ShadowContour &shape)
2126
2170
  ShadowContour insetShadowClip(const Node &node)
2127
2171
  {
2128
2172
  int border[4];
2129
- for (int i = 0; i < 4; ++i) border[i] = std::max<int>(node.style.border_width, rstyle(node.style).border_side_width[i]);
2173
+ for (int i = 0; i < 4; ++i) border[i] = computedBorderWidth(node.computedStyle(), i);
2130
2174
  ShadowContour shape{float(node.layout.x + border[3]), float(node.layout.y + border[0]),
2131
2175
  float(std::max(0, node.layout.width - border[3] - border[1])),
2132
2176
  float(std::max(0, node.layout.height - border[0] - border[2]))};
@@ -2184,8 +2228,8 @@ bool shadowContourRow(const ShadowContour &shape, int y, int &left, int &right)
2184
2228
  void appendShadowRect(const Node &node, uint8_t parentAlpha, int x, int y, int w, int h)
2185
2229
  {
2186
2230
  if (w <= 0 || h <= 0) return;
2187
- const auto color = rstyle(node.style).box_shadow_color;
2188
- const auto alpha = rstyle(node.style).box_shadow_alpha;
2231
+ const auto color = (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_color : 0);
2232
+ const auto alpha = (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0);
2189
2233
  if (!ViewGeometry::hasTransformChain(node, false)) {
2190
2234
  appendFillRectWithAlpha(x, y, w, h, color, alpha, parentAlpha, x, y, w, h);
2191
2235
  return;
@@ -2206,7 +2250,7 @@ void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowC
2206
2250
  bool circular = true;
2207
2251
  for (int i = 0; i < 4; ++i) circular &= clip.rx[i] == clip.ry[i] && clip.rx[i] == std::floor(clip.rx[i]) && clip.rx[i] <= std::min(clip.w, clip.h) * 0.5f;
2208
2252
  if (ox == 0 && oy == 0 && spread > 0 && hole.w > 0 && hole.h > 0 && circular &&
2209
- combineAlpha(parentAlpha, rstyle(node.style).box_shadow_alpha) == 255 &&
2253
+ combineAlpha(parentAlpha, (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0)) == 255 &&
2210
2254
  !ViewGeometry::hasTransformChain(node, false)) {
2211
2255
  DisplayCommand *cmd = DisplayList::instance().append();
2212
2256
  if (cmd) {
@@ -2221,7 +2265,7 @@ void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowC
2221
2265
  cmd->strokeRoundedRect.br = static_cast<int16_t>(clip.rx[2]);
2222
2266
  cmd->strokeRoundedRect.bl = static_cast<int16_t>(clip.rx[3]);
2223
2267
  cmd->strokeRoundedRect.lineWidth = spread;
2224
- cmd->strokeRoundedRect.color = rstyle(node.style).box_shadow_color;
2268
+ cmd->strokeRoundedRect.color = (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_color : 0);
2225
2269
  }
2226
2270
  return;
2227
2271
  }
@@ -2254,23 +2298,23 @@ void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowC
2254
2298
 
2255
2299
  void recordInsetBoxShadow(const Node &node, uint8_t parentAlpha)
2256
2300
  {
2257
- if (!rstyle(node.style).box_shadow_inset || rstyle(node.style).box_shadow_alpha == 0) return;
2301
+ if (!(GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_inset : 0) || (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0) == 0) return;
2258
2302
  const int x = node.layout.x;
2259
2303
  const int y = node.layout.y;
2260
2304
  const int w = node.layout.width;
2261
2305
  const int h = node.layout.height;
2262
2306
  if (w <= 0 || h <= 0) return;
2263
2307
 
2264
- const int blur = std::max<int>(0, rstyle(node.style).box_shadow_blur_radius);
2308
+ const int blur = std::max<int>(0, (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_blur_radius : 0));
2265
2309
  if (blur == 0) {
2266
- recordSharpInsetShadow(node, parentAlpha, insetShadowClip(node), rstyle(node.style).box_shadow_spread,
2267
- rstyle(node.style).box_shadow_offset_x, rstyle(node.style).box_shadow_offset_y);
2310
+ recordSharpInsetShadow(node, parentAlpha, insetShadowClip(node), (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_spread : 0),
2311
+ (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_offset_x : 0), (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_offset_y : 0));
2268
2312
  return;
2269
2313
  }
2270
- const int spread = std::max<int>(0, rstyle(node.style).box_shadow_spread);
2271
- const int ox = rstyle(node.style).box_shadow_offset_x;
2272
- const int oy = rstyle(node.style).box_shadow_offset_y;
2273
- const uint8_t baseAlpha = rstyle(node.style).box_shadow_alpha;
2314
+ const int spread = std::max<int>(0, (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_spread : 0));
2315
+ const int ox = (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_offset_x : 0);
2316
+ const int oy = (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_offset_y : 0);
2317
+ const uint8_t baseAlpha = (GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0);
2274
2318
 
2275
2319
  const int leftSolid = spread + std::max(0, ox);
2276
2320
  const int rightSolid = spread + std::max(0, -ox);
@@ -2291,6 +2335,8 @@ void recordInsetBoxShadow(const Node &node, uint8_t parentAlpha)
2291
2335
  appendInsetShadowBand(node, parentAlpha, x + w - d - 1, y, 1, h, insetShadowAlphaAt(d, rightSolid, blur, baseAlpha));
2292
2336
  }
2293
2337
 
2338
+ #endif
2339
+
2294
2340
  void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_bounds") ViewRenderer::transformedBounds(const Node &node, bool use_prev, int *x0, int *y0, int *x1, int *y1)
2295
2341
  {
2296
2342
  const Node *n = &node;
@@ -2309,7 +2355,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_bounds") ViewRenderer:
2309
2355
  // exactly the layout box. In a transformed tree we must still walk ancestors:
2310
2356
  // otherwise plain children (for example a face label <span>) ignore their
2311
2357
  // transformed parent plane and paint as axis-aligned overlay text.
2312
- if (!use_prev && n->style.rare_style < 0 && !ViewGeometry::anyTransformPresent()) {
2358
+ if (!use_prev && n->computedStyle().rare_style < 0 && !ViewGeometry::anyTransformPresent()) {
2313
2359
  *x0 = x;
2314
2360
  *y0 = y;
2315
2361
  *x1 = x + w - 1;
@@ -2317,10 +2363,10 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_bounds") ViewRenderer:
2317
2363
  return;
2318
2364
  }
2319
2365
 
2320
- int rotate = use_prev ? n->render.previous_transform_rotate : rstyle(n->style).transform_rotate;
2366
+ int rotate = use_prev ? n->render.previous_transform_rotate : rstyle(n->computedStyle()).transform_rotate;
2321
2367
 
2322
2368
  auto expandForBlur = [&]() {
2323
- const int radius = use_prev ? n->render.previous_filter_blur_radius : rstyle(n->style).filter_blur_radius;
2369
+ const int radius = use_prev ? n->render.previous_filter_blur_radius : (GEA_CSS_FILTERS ? rstyle(n->computedStyle()).filter_blur_radius : 0);
2324
2370
  if (radius <= 0) return;
2325
2371
  const int extentX = std::max(1, radius) * 5;
2326
2372
  const int extentY = std::max(1, radius) * 5;
@@ -2367,8 +2413,8 @@ bool ViewRenderer::backfaceSubtreeHidden(const Node &node)
2367
2413
  const auto &state = treeState();
2368
2414
  for (int id = ViewGeometry::nodeIndex(node); id >= 0 && id < state.nodeCount; id = state.nodes[id].parent) {
2369
2415
  const auto &ancestor = state.nodes[id];
2370
- if (ViewGeometry::hasTransformableBox(ancestor) && ancestor.style.backface_hidden &&
2371
- !preserves3D(ancestor.style) && ViewGeometry::backFacing(ancestor))
2416
+ if (ViewGeometry::hasTransformableBox(ancestor) && ancestor.computedStyle().backface_hidden &&
2417
+ !preserves3D(ancestor.computedStyle()) && ViewGeometry::backFacing(ancestor))
2372
2418
  return true;
2373
2419
  }
2374
2420
  return false;
@@ -2399,7 +2445,7 @@ bool ViewRenderer::recordClipBegin(const Node &node)
2399
2445
  {
2400
2446
  const Node *n = &node;
2401
2447
  if (ViewGeometry::hasTransformChain(*n, false)) return 0;
2402
- if (!isViewLikeNodeType(n->type) || n->style.overflow == 0) return 0;
2448
+ if (!isViewLikeNodeType(n->type) || n->computedStyle().overflow == 0) return 0;
2403
2449
  if (n->first_child < 0) return 0;
2404
2450
 
2405
2451
  int x, y, w, h;
@@ -2418,19 +2464,27 @@ bool ViewRenderer::recordClipBegin(const Node &node)
2418
2464
 
2419
2465
  int ViewRenderer::scrollMaxX(const Node &node)
2420
2466
  {
2467
+ #if GEA_CSS_SCROLLING
2421
2468
  if (node.type == NodeType::VirtualList) return 0;
2422
2469
  int max_x = node.layout.scroll_content_width - node.layout.width;
2423
2470
  return max_x > 0 ? max_x : 0;
2471
+ #else
2472
+ (void)node; return 0;
2473
+ #endif
2424
2474
  }
2425
2475
 
2426
2476
  int ViewRenderer::scrollMaxY(const Node &node)
2427
2477
  {
2478
+ #if GEA_CSS_SCROLLING
2428
2479
  if (node.type == NodeType::VirtualList) {
2429
2480
  const int id = static_cast<int>(&node - Tree::instance().nodes());
2430
2481
  return VirtualListRenderer::scrollMaxY(id);
2431
2482
  }
2432
2483
  int max_y = node.layout.scroll_content_height - node.layout.height;
2433
2484
  return max_y > 0 ? max_y : 0;
2485
+ #else
2486
+ (void)node; return 0;
2487
+ #endif
2434
2488
  }
2435
2489
 
2436
2490
  void ViewRenderer::recordClipEnd(const Node &node)
@@ -2454,10 +2508,10 @@ int ViewRenderer::canvasBackgroundSource()
2454
2508
  const Node &html = state.nodes[root];
2455
2509
  // CSS Backgrounds: a transparent root with no images takes the first
2456
2510
  // direct body's background. Its used background is then transparent.
2457
- if (!rstyle(html.style).containment && (!html.style.has_bg || html.style.bg_alpha == 0) && !styleHasBackgroundImage(html.style)) {
2511
+ if (!(GEA_CSS_CONTAINMENT ? rstyle(html.computedStyle()).containment : 0) && (!html.computedStyle().has_bg || html.computedStyle().bg_alpha == 0) && !styleHasBackgroundImage(html.computedStyle())) {
2458
2512
  for (int child = html.first_child; child >= 0; child = state.nodes[child].next_sibling)
2459
2513
  if (std::string_view(tagFromId(state.nodes[child].tag_id)) == "body")
2460
- return rstyle(state.nodes[child].style).containment ? root : child;
2514
+ return (GEA_CSS_CONTAINMENT ? rstyle(state.nodes[child].computedStyle()).containment : 0) ? root : child;
2461
2515
  }
2462
2516
  return root;
2463
2517
  }
@@ -2473,7 +2527,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
2473
2527
  const bool canvasRoot = isDocumentCanvasRoot(node);
2474
2528
  if (canvasRoot && canvasSource >= 0) {
2475
2529
  const auto &state = treeState();
2476
- const auto &source = state.nodes[canvasSource].style;
2530
+ const auto &source = state.nodes[canvasSource].computedStyle();
2477
2531
  if (source.display != 1 && source.has_bg && source.bg_alpha > 0)
2478
2532
  appendFillRectWithAlpha(0, 0, state.mountedWidth, state.mountedHeight,
2479
2533
  source.bg_color, source.bg_alpha, parentAlpha, 0, 0, state.mountedWidth, state.mountedHeight);
@@ -2488,11 +2542,11 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
2488
2542
  }
2489
2543
  if (w <= 0 || h <= 0) return;
2490
2544
 
2491
- if (n->style.has_bg) {
2545
+ if (n->computedStyle().has_bg) {
2492
2546
  // The color is the bottom layer; image longhands never replace it.
2493
- if (n->style.bg_alpha > 0 && !canvasRoot &&
2547
+ if (n->computedStyle().bg_alpha > 0 && !canvasRoot &&
2494
2548
  (canvasSource < 0 || &treeState().nodes[canvasSource] != n)) {
2495
- const int clip = StyleValues::backgroundClip(n->style, rstyle(n->style).bg_image_layer_count - 1);
2549
+ const int clip = StyleValues::backgroundClip(n->computedStyle(), rstyle(n->computedStyle()).bg_image_layer_count - 1);
2496
2550
  TextBackgroundClipScope textClip(*n, clip);
2497
2551
  if (clip == 1 || clip == 2) {
2498
2552
  recordTransformedRoundedRectFill(*n, parentAlpha, clip);
@@ -2504,7 +2558,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
2504
2558
  recordTransformedRoundedRectFill(*n, parentAlpha);
2505
2559
  } else {
2506
2560
  ViewGeometry::transformCorners(*n, false, xs, ys);
2507
- appendFillQuadWithAlpha(xs, ys, n->style.bg_color, n->style.bg_alpha, parentAlpha,
2561
+ appendFillQuadWithAlpha(xs, ys, n->computedStyle().bg_color, n->computedStyle().bg_alpha, parentAlpha,
2508
2562
  bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1,
2509
2563
  x, y, w, h, true);
2510
2564
  }
@@ -2513,22 +2567,22 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
2513
2567
  if (!appendResolvedCircularRoundedRectWithAlpha(*n, parentAlpha))
2514
2568
  recordTransformedRoundedRectFill(*n, parentAlpha);
2515
2569
  } else {
2516
- appendFillRectWithAlpha(x, y, w, h, n->style.bg_color, n->style.bg_alpha, parentAlpha, x, y, w, h);
2570
+ appendFillRectWithAlpha(x, y, w, h, n->computedStyle().bg_color, n->computedStyle().bg_alpha, parentAlpha, x, y, w, h);
2517
2571
  }
2518
2572
  }
2519
2573
  }
2520
2574
  if (!canvasRoot && (canvasSource < 0 || &treeState().nodes[canvasSource] != n)) {
2521
2575
  if (!recordPlacedBackgrounds(*n, *n, false)) {
2522
- if (n->style.bg_fill == 1) {
2523
- TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->style, rstyle(n->style).bg_gradient_layer));
2576
+ if (n->computedStyle().bg_fill == 1) {
2577
+ TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->computedStyle(), rstyle(n->computedStyle()).bg_gradient_layer));
2524
2578
  recordLinearGradientBackground(*n, parentAlpha);
2525
2579
  }
2526
2580
  {
2527
- TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->style, rstyle(n->style).bg_radial_gradient_layer));
2581
+ TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->computedStyle(), rstyle(n->computedStyle()).bg_radial_gradient_layer));
2528
2582
  recordRadialGradientBackground(*n);
2529
2583
  }
2530
2584
  {
2531
- TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->style, rstyle(n->style).bg_overlay_gradient_layer));
2585
+ TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->computedStyle(), rstyle(n->computedStyle()).bg_overlay_gradient_layer));
2532
2586
  recordOverlayLinearGradientBackground(*n);
2533
2587
  }
2534
2588
  }
@@ -2536,9 +2590,11 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
2536
2590
  }
2537
2591
  }
2538
2592
 
2593
+ #if GEA_CSS_BOX_SHADOW
2539
2594
  recordInsetBoxShadow(*n, parentAlpha);
2595
+ #endif
2540
2596
 
2541
- if (n->style.border_width > 0 && !hasBorderRelief(n->style) && !hasSideBorder(n->style) && !borderColorsDiffer(n->style) && !borderIsSameOpaqueSolidBackground(*n, parentAlpha)) {
2597
+ if (n->computedStyle().border_width > 0 && !hasBorderRelief(n->computedStyle()) && !hasSideBorder(n->computedStyle()) && !borderColorsDiffer(n->computedStyle()) && !borderIsSameOpaqueSolidBackground(*n, parentAlpha)) {
2542
2598
  if (ViewGeometry::hasTransformChain(*n, false)) {
2543
2599
  if (isFullyRoundedShape(*n)) recordTransformedEllipseStroke(*n, parentAlpha);
2544
2600
  } else {
@@ -2550,8 +2606,9 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
2550
2606
 
2551
2607
  void ViewRenderer::recordScrollbar(const Node &node)
2552
2608
  {
2609
+ #if GEA_CSS_SCROLLING
2553
2610
  const Node *n = &node;
2554
- if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->style))) return;
2611
+ if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->computedStyle()))) return;
2555
2612
  if (n->layout.height <= 0 || n->layout.scroll_content_height <= n->layout.height) return;
2556
2613
 
2557
2614
  int track_h = n->layout.height - 12;
@@ -2588,6 +2645,9 @@ void ViewRenderer::recordScrollbar(const Node &node)
2588
2645
  // constant would not fit. 0x8C8E94 is the exact RGB888 expansion of the RGB565
2589
2646
  // 0x8C72 this used to spell, so 16-bit panels emit the identical pixel.
2590
2647
  cmd->fillRoundedRect.color = gea::framework::graphics::pixel::nativeFromRrggbbaa(0x8C8E94FFu);
2648
+ #else
2649
+ (void)node;
2650
+ #endif
2591
2651
  }
2592
2652
 
2593
2653
  } // namespace gea::embedded::ui