@geastack/engine 0.1.6 → 0.1.7
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/README.md +70 -0
- package/canvas.cpp +52 -30
- package/css/declarative.h +6 -0
- package/css/engine.h +19 -0
- package/image_store.cpp +136 -33
- package/package.json +2 -2
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +15 -13
- package/ui/core.cpp +23 -0
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +282 -0
- package/ui/image_node.cpp +9 -8
- package/ui/input.cpp +22 -2
- package/ui/input_render.cpp +4 -0
- package/ui/layout.cpp +171 -83
- package/ui/layout_snapshot.cpp +28 -1
- package/ui/node_features.h +18 -0
- package/ui/node_lifecycle.cpp +192 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +631 -71
- package/ui/node_text.h +82 -0
- package/ui/render.cpp +155 -87
- package/ui/renderer_features.h +19 -0
- package/ui/root_scroll_refresh.cpp +31 -14
- package/ui/style.cpp +991 -228
- package/ui/text.cpp +24 -4
- package/ui/tree_events.cpp +135 -95
- package/ui/tree_events.h +28 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +32 -4
- package/ui/tree_render.cpp +48 -19
- package/ui/tree_scroll_mirror.cpp +26 -0
- package/ui/tree_state.cpp +261 -114
- package/ui/tree_state.h +69 -18
- package/ui/tree_style.cpp +339 -72
- package/ui/view.cpp +122 -62
- package/ui/virtual_keyboard.cpp +10 -3
package/ui/style.cpp
CHANGED
|
@@ -412,12 +412,14 @@ bool styleEqualExceptTextPaint(const ComputedStyle &a, const ComputedStyle &b)
|
|
|
412
412
|
a.gap != b.gap ||
|
|
413
413
|
ar.grid_column_count != br.grid_column_count ||
|
|
414
414
|
ar.grid_row_count != br.grid_row_count) return false;
|
|
415
|
+
#if GEA_CSS_GRID
|
|
415
416
|
for (int i = 0; i < kMaxGridTracks; ++i) {
|
|
416
417
|
if (ar.grid_column_type[i] != br.grid_column_type[i] ||
|
|
417
418
|
ar.grid_row_type[i] != br.grid_row_type[i] ||
|
|
418
419
|
ar.grid_column_value[i] != br.grid_column_value[i] ||
|
|
419
420
|
ar.grid_row_value[i] != br.grid_row_value[i]) return false;
|
|
420
421
|
}
|
|
422
|
+
#endif
|
|
421
423
|
if (a.width != b.width ||
|
|
422
424
|
a.height != b.height ||
|
|
423
425
|
a.width_expression != b.width_expression ||
|
|
@@ -434,20 +436,40 @@ bool styleEqualExceptTextPaint(const ComputedStyle &a, const ComputedStyle &b)
|
|
|
434
436
|
ar.flex_basis_expression != br.flex_basis_expression ||
|
|
435
437
|
ar.line_height_expression != br.line_height_expression ||
|
|
436
438
|
a.line_height_multiplier != b.line_height_multiplier) return false;
|
|
439
|
+
if (GEA_CSS_POSITION_PX_0(a) != GEA_CSS_POSITION_PX_0(b) ||
|
|
440
|
+
GEA_CSS_POSITION_PX_1(a) != GEA_CSS_POSITION_PX_1(b) ||
|
|
441
|
+
GEA_CSS_POSITION_PX_2(a) != GEA_CSS_POSITION_PX_2(b) ||
|
|
442
|
+
GEA_CSS_POSITION_PX_3(a) != GEA_CSS_POSITION_PX_3(b) ||
|
|
443
|
+
GEA_CSS_POSITION_PERCENT_0(a) != GEA_CSS_POSITION_PERCENT_0(b) ||
|
|
444
|
+
GEA_CSS_POSITION_PERCENT_1(a) != GEA_CSS_POSITION_PERCENT_1(b) ||
|
|
445
|
+
GEA_CSS_POSITION_PERCENT_2(a) != GEA_CSS_POSITION_PERCENT_2(b) ||
|
|
446
|
+
GEA_CSS_POSITION_PERCENT_3(a) != GEA_CSS_POSITION_PERCENT_3(b)) return false;
|
|
437
447
|
for (int i = 0; i < 4; ++i) {
|
|
438
448
|
if (a.padding[i] != b.padding[i] ||
|
|
439
449
|
a.margin[i] != b.margin[i] ||
|
|
450
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
440
451
|
ar.margin_expression[i] != br.margin_expression[i] ||
|
|
452
|
+
#endif
|
|
453
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
441
454
|
ar.padding_expression[i] != br.padding_expression[i] ||
|
|
442
|
-
|
|
443
|
-
|
|
455
|
+
#endif
|
|
456
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
444
457
|
ar.border_side_width[i] != br.border_side_width[i] ||
|
|
458
|
+
#endif
|
|
459
|
+
#if GEA_CSS_BORDER_RELIEF
|
|
445
460
|
ar.border_relief[i] != br.border_relief[i] ||
|
|
446
|
-
|
|
461
|
+
#endif
|
|
462
|
+
a.border_color_flags != b.border_color_flags ||
|
|
463
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
447
464
|
ar.border_side_color[i] != br.border_side_color[i] ||
|
|
465
|
+
#endif
|
|
466
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
448
467
|
ar.border_side_alpha[i] != br.border_side_alpha[i] ||
|
|
449
|
-
|
|
450
|
-
|
|
468
|
+
#endif
|
|
469
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
470
|
+
a.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != b.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] ||
|
|
471
|
+
#endif
|
|
472
|
+
a.border_radius[GEA_CSS_RADIUS_INDEX(i)] != b.border_radius[GEA_CSS_RADIUS_INDEX(i)]) return false;
|
|
451
473
|
}
|
|
452
474
|
if (a.position != b.position ||
|
|
453
475
|
a.z_index != b.z_index ||
|
|
@@ -610,12 +632,14 @@ bool styleEqualExceptLocalDisplayCommands(const ComputedStyle &a, const Computed
|
|
|
610
632
|
a.gap != b.gap ||
|
|
611
633
|
ar.grid_column_count != br.grid_column_count ||
|
|
612
634
|
ar.grid_row_count != br.grid_row_count) return false;
|
|
635
|
+
#if GEA_CSS_GRID
|
|
613
636
|
for (int i = 0; i < kMaxGridTracks; ++i) {
|
|
614
637
|
if (ar.grid_column_type[i] != br.grid_column_type[i] ||
|
|
615
638
|
ar.grid_row_type[i] != br.grid_row_type[i] ||
|
|
616
639
|
ar.grid_column_value[i] != br.grid_column_value[i] ||
|
|
617
640
|
ar.grid_row_value[i] != br.grid_row_value[i]) return false;
|
|
618
641
|
}
|
|
642
|
+
#endif
|
|
619
643
|
if (a.width != b.width ||
|
|
620
644
|
a.height != b.height ||
|
|
621
645
|
a.width_expression != b.width_expression ||
|
|
@@ -632,14 +656,25 @@ bool styleEqualExceptLocalDisplayCommands(const ComputedStyle &a, const Computed
|
|
|
632
656
|
ar.flex_basis_expression != br.flex_basis_expression ||
|
|
633
657
|
ar.line_height_expression != br.line_height_expression ||
|
|
634
658
|
a.line_height_multiplier != b.line_height_multiplier) return false;
|
|
659
|
+
if (GEA_CSS_POSITION_PX_0(a) != GEA_CSS_POSITION_PX_0(b) ||
|
|
660
|
+
GEA_CSS_POSITION_PX_1(a) != GEA_CSS_POSITION_PX_1(b) ||
|
|
661
|
+
GEA_CSS_POSITION_PX_2(a) != GEA_CSS_POSITION_PX_2(b) ||
|
|
662
|
+
GEA_CSS_POSITION_PX_3(a) != GEA_CSS_POSITION_PX_3(b) ||
|
|
663
|
+
GEA_CSS_POSITION_PERCENT_0(a) != GEA_CSS_POSITION_PERCENT_0(b) ||
|
|
664
|
+
GEA_CSS_POSITION_PERCENT_1(a) != GEA_CSS_POSITION_PERCENT_1(b) ||
|
|
665
|
+
GEA_CSS_POSITION_PERCENT_2(a) != GEA_CSS_POSITION_PERCENT_2(b) ||
|
|
666
|
+
GEA_CSS_POSITION_PERCENT_3(a) != GEA_CSS_POSITION_PERCENT_3(b)) return false;
|
|
635
667
|
for (int i = 0; i < 4; ++i) {
|
|
636
668
|
if (boxInset(a, i) != boxInset(b, i) ||
|
|
637
669
|
a.padding[i] != b.padding[i] ||
|
|
638
670
|
a.margin[i] != b.margin[i] ||
|
|
671
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
639
672
|
ar.margin_expression[i] != br.margin_expression[i] ||
|
|
673
|
+
#endif
|
|
674
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
640
675
|
ar.padding_expression[i] != br.padding_expression[i] ||
|
|
641
|
-
|
|
642
|
-
|
|
676
|
+
#endif
|
|
677
|
+
false) return false;
|
|
643
678
|
}
|
|
644
679
|
if (a.position != b.position ||
|
|
645
680
|
a.z_index != b.z_index ||
|
|
@@ -708,10 +743,16 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
|
|
|
708
743
|
Node &target = state.nodes[node];
|
|
709
744
|
if (beforeImageId == target.image_id && styleExactlyEqual(beforeStyle, target.style) && !firstLineChanged) return;
|
|
710
745
|
if (!nodeParticipatesInMountedTree(state, node)) return;
|
|
746
|
+
const bool hadRecolor = target.render.bg_recolor_pending;
|
|
747
|
+
const bool canRecolor = !target.render.dirty || hadRecolor;
|
|
748
|
+
target.render.text_partial_dirty = 0;
|
|
749
|
+
target.render.bg_recolor_pending = 0;
|
|
711
750
|
if (firstLineChanged) {
|
|
712
751
|
target.render.dirty = 1;
|
|
713
752
|
target.render.layout_dirty = 1;
|
|
753
|
+
#if GEA_CSS_SCROLLING
|
|
714
754
|
target.render.non_scroll_dirty = 1;
|
|
755
|
+
#endif
|
|
715
756
|
Tree::instance().markNodeDisplayCommandsDirty(node);
|
|
716
757
|
// First-line backgrounds are recorded with descendant text fragments.
|
|
717
758
|
// Rebuilding only the owner's box would retain their old fill commands.
|
|
@@ -719,7 +760,9 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
|
|
|
719
760
|
for (int child = state.nodes[parent].first_child; child >= 0; child = state.nodes[child].next_sibling) {
|
|
720
761
|
if (state.nodes[child].type == NodeType::Text) {
|
|
721
762
|
state.nodes[child].render.dirty = 1;
|
|
763
|
+
#if GEA_CSS_SCROLLING
|
|
722
764
|
state.nodes[child].render.non_scroll_dirty = 1;
|
|
765
|
+
#endif
|
|
723
766
|
Tree::instance().markNodeDisplayCommandsDirty(child);
|
|
724
767
|
}
|
|
725
768
|
self(self, child);
|
|
@@ -734,7 +777,9 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
|
|
|
734
777
|
if (beforeImageId == target.image_id && styleEqualExceptTextPaint(beforeStyle, target.style)) {
|
|
735
778
|
if (target.type == NodeType::Text || borderUsesCurrentColor(target.style) || borderUsesCurrentColor(beforeStyle)) {
|
|
736
779
|
target.render.dirty = 1; // paint-only: text color; geometry untouched
|
|
780
|
+
#if GEA_CSS_SCROLLING
|
|
737
781
|
target.render.non_scroll_dirty = 1;
|
|
782
|
+
#endif
|
|
738
783
|
Tree::instance().markNodeDisplayCommandsDirty(node);
|
|
739
784
|
}
|
|
740
785
|
return;
|
|
@@ -748,20 +793,23 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
|
|
|
748
793
|
// is still the original (A) from the last render — so almost nothing matches and
|
|
749
794
|
// the background only partially recolors, leaving a patchwork that never
|
|
750
795
|
// converges. Capture `from` only on the first change since the last render (when
|
|
751
|
-
// the framebuffer still matches the current style), and
|
|
752
|
-
if (!
|
|
796
|
+
// the framebuffer still matches the current style), and read the destination from the current style.
|
|
797
|
+
if (canRecolor && !firstLineChanged) {
|
|
798
|
+
if (!hadRecolor) target.render.bg_recolor_from = beforeStyle.bg_color;
|
|
753
799
|
target.render.bg_recolor_pending = 1;
|
|
754
|
-
target.render.bg_recolor_from = beforeStyle.bg_color;
|
|
755
800
|
}
|
|
756
|
-
target.render.bg_recolor_to = target.style.bg_color;
|
|
757
801
|
target.render.dirty = 1; // paint-only: background recolor; geometry untouched
|
|
802
|
+
#if GEA_CSS_SCROLLING
|
|
758
803
|
target.render.non_scroll_dirty = 1;
|
|
804
|
+
#endif
|
|
759
805
|
Tree::instance().markNodeDisplayCommandsDirty(node);
|
|
760
806
|
return;
|
|
761
807
|
}
|
|
762
808
|
|
|
763
809
|
target.render.dirty = 1;
|
|
810
|
+
#if GEA_CSS_SCROLLING
|
|
764
811
|
target.render.non_scroll_dirty = 1;
|
|
812
|
+
#endif
|
|
765
813
|
if (preserves3D(beforeStyle) != preserves3D(target.style))
|
|
766
814
|
Tree::instance().markDisplayListDirty();
|
|
767
815
|
if (beforeImageId == target.image_id && styleEqualExceptLocalDisplayCommands(beforeStyle, target.style)) {
|
|
@@ -798,10 +846,15 @@ void markClassRecomputeStyleDiff(int node, const ComputedStyle &beforeStyle, int
|
|
|
798
846
|
beforeRare.perspective != targetRare.perspective ||
|
|
799
847
|
beforeRare.perspective_origin_x != targetRare.perspective_origin_x ||
|
|
800
848
|
beforeRare.perspective_origin_y != targetRare.perspective_origin_y) {
|
|
849
|
+
#if GEA_CSS_TRANSFORMS
|
|
801
850
|
target.render.transform_dirty = 1;
|
|
851
|
+
#endif
|
|
802
852
|
if (state.fixedPositionUsed) target.render.layout_dirty = 1;
|
|
853
|
+
|
|
854
|
+
#if GEA_CSS_TRANSFORMS
|
|
803
855
|
state.transformScanSerial = ~0ull;
|
|
804
856
|
state.transformScanValid = false; // a transform was added/changed → drop durable no-transform cache
|
|
857
|
+
#endif
|
|
805
858
|
}
|
|
806
859
|
Tree::instance().markNodeDisplayCommandsDirty(node);
|
|
807
860
|
// Flattened backface visibility changes the whole descendant paint group.
|
|
@@ -1306,8 +1359,8 @@ struct ResolvedCssLength {
|
|
|
1306
1359
|
};
|
|
1307
1360
|
|
|
1308
1361
|
struct CachedCssColor {
|
|
1309
|
-
|
|
1310
|
-
|
|
1362
|
+
NodeCustomProperty::ColorValue styleColor = 0;
|
|
1363
|
+
NodeCustomProperty::ColorValue nativeColor = 0;
|
|
1311
1364
|
std::uint8_t alpha = 255;
|
|
1312
1365
|
bool valid = false;
|
|
1313
1366
|
};
|
|
@@ -1342,7 +1395,9 @@ struct CssCompiledValue {
|
|
|
1342
1395
|
std::uint16_t flags = 0;
|
|
1343
1396
|
std::uint8_t aux = 0;
|
|
1344
1397
|
CssLengthSpec lengths[4];
|
|
1345
|
-
|
|
1398
|
+
// Four direct-property pairs are the largest scalar payload. Transform
|
|
1399
|
+
// rotation and scale occupy slots 0..5; translations use lengths[].
|
|
1400
|
+
std::int32_t values[8]{};
|
|
1346
1401
|
};
|
|
1347
1402
|
|
|
1348
1403
|
CssLengthSpec cssLengthSpecForStatic(StaticStyleLengthSpec spec);
|
|
@@ -1421,7 +1476,9 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &value
|
|
|
1421
1476
|
int containmentValue(const std::string &value);
|
|
1422
1477
|
|
|
1423
1478
|
std::uint16_t compileCustomPropertyValue(const CssText &value);
|
|
1479
|
+
#if GEA_CSS_ANIMATIONS
|
|
1424
1480
|
std::uint16_t compileCssAnimationSpec(const CssText &value);
|
|
1481
|
+
#endif
|
|
1425
1482
|
std::uint16_t compileSelectorPlan(const CssText &selector);
|
|
1426
1483
|
std::uint16_t compileMediaConditionPlan(const CssText &condition);
|
|
1427
1484
|
void clearCompiledCssBackgrounds();
|
|
@@ -1430,13 +1487,13 @@ void clearCompiledCssLengthExpressions();
|
|
|
1430
1487
|
void clearStaticLengthExpressionResolutionCache();
|
|
1431
1488
|
|
|
1432
1489
|
struct CssRule {
|
|
1433
|
-
enum class SelectorType {
|
|
1490
|
+
enum class SelectorType : std::uint8_t {
|
|
1434
1491
|
Class,
|
|
1435
1492
|
Element,
|
|
1436
1493
|
Selector
|
|
1437
1494
|
};
|
|
1438
1495
|
|
|
1439
|
-
enum class PseudoElement {
|
|
1496
|
+
enum class PseudoElement : std::uint8_t {
|
|
1440
1497
|
None,
|
|
1441
1498
|
Before,
|
|
1442
1499
|
After,
|
|
@@ -1449,7 +1506,9 @@ struct CssRule {
|
|
|
1449
1506
|
CssRuleProperty propertyKind;
|
|
1450
1507
|
CssDeclarationId declaration;
|
|
1451
1508
|
std::uint16_t compiledValue;
|
|
1509
|
+
#if GEA_CSS_ANIMATIONS
|
|
1452
1510
|
std::uint16_t compiledAnimationSpec;
|
|
1511
|
+
#endif
|
|
1453
1512
|
CssAtomId selectorAtom;
|
|
1454
1513
|
CssAtomId propertyAtom;
|
|
1455
1514
|
int16_t selectorTagId;
|
|
@@ -1462,8 +1521,8 @@ struct CssRule {
|
|
|
1462
1521
|
};
|
|
1463
1522
|
|
|
1464
1523
|
struct CssKeyframeRule {
|
|
1465
|
-
CssAtomId nameAtom;
|
|
1466
1524
|
int offsetPermille;
|
|
1525
|
+
CssAtomId nameAtom;
|
|
1467
1526
|
CssRuleProperty propertyKind;
|
|
1468
1527
|
CssDeclarationId declaration;
|
|
1469
1528
|
std::uint16_t compiledValue;
|
|
@@ -1535,7 +1594,9 @@ void recomputeDescendantClassStyles(int node);
|
|
|
1535
1594
|
void recomputeSubtreeClassStyles(int node);
|
|
1536
1595
|
void setStyleValue(NodeHandle node, Property property, int value, StyleApplicationSource source);
|
|
1537
1596
|
struct ActiveRulePlan;
|
|
1597
|
+
#if GEA_CSS_ANIMATIONS
|
|
1538
1598
|
void primeCssAnimationsForNode(int node, const ActiveRulePlan *activePlan = nullptr);
|
|
1599
|
+
#endif
|
|
1539
1600
|
int parseOriginPart(const std::string &part, int fallback);
|
|
1540
1601
|
|
|
1541
1602
|
// File-scope lazy pointer rather than a function-local static: the static-local
|
|
@@ -1646,7 +1707,9 @@ struct KeyframeRuleIndex {
|
|
|
1646
1707
|
DenseRuleBuckets byName;
|
|
1647
1708
|
};
|
|
1648
1709
|
|
|
1710
|
+
#if GEA_CSS_ANIMATIONS
|
|
1649
1711
|
KeyframeRuleIndex g_keyframeRuleIndex;
|
|
1712
|
+
#endif
|
|
1650
1713
|
|
|
1651
1714
|
struct DenseIdSet {
|
|
1652
1715
|
std::vector<std::uint8_t> bits;
|
|
@@ -1681,15 +1744,20 @@ struct DenseIdSet {
|
|
|
1681
1744
|
|
|
1682
1745
|
void invalidateKeyframeRuleIndex()
|
|
1683
1746
|
{
|
|
1747
|
+
#if GEA_CSS_ANIMATIONS
|
|
1684
1748
|
g_keyframeRuleIndex.valid = false;
|
|
1749
|
+
#endif
|
|
1685
1750
|
}
|
|
1686
1751
|
|
|
1687
1752
|
void clearKeyframeRuleIndex()
|
|
1688
1753
|
{
|
|
1754
|
+
#if GEA_CSS_ANIMATIONS
|
|
1689
1755
|
g_keyframeRuleIndex.byName.clear();
|
|
1690
1756
|
g_keyframeRuleIndex.valid = false;
|
|
1757
|
+
#endif
|
|
1691
1758
|
}
|
|
1692
1759
|
|
|
1760
|
+
#if GEA_CSS_ANIMATIONS
|
|
1693
1761
|
void rebuildKeyframeRuleIndexIfNeeded()
|
|
1694
1762
|
{
|
|
1695
1763
|
if (g_keyframeRuleIndex.valid) return;
|
|
@@ -1710,6 +1778,8 @@ DenseRuleBucketSpan keyframeRuleIndicesForName(CssAtomId name)
|
|
|
1710
1778
|
return g_keyframeRuleIndex.byName.get(name);
|
|
1711
1779
|
}
|
|
1712
1780
|
|
|
1781
|
+
#endif
|
|
1782
|
+
|
|
1713
1783
|
std::vector<CssCompiledValue> &compiledCssValues()
|
|
1714
1784
|
{
|
|
1715
1785
|
static std::vector<CssCompiledValue> list;
|
|
@@ -1764,12 +1834,12 @@ std::uint16_t storeDirectPropertyGroupCompiledValue(std::initializer_list<Static
|
|
|
1764
1834
|
int count = 0;
|
|
1765
1835
|
for (const StaticStylePropertyValue &entry : properties) {
|
|
1766
1836
|
if (count >= 4) break;
|
|
1767
|
-
compiled.values[
|
|
1768
|
-
compiled.values[
|
|
1837
|
+
compiled.values[count * 2] = static_cast<int>(entry.property);
|
|
1838
|
+
compiled.values[1 + count * 2] = entry.value;
|
|
1769
1839
|
count++;
|
|
1770
1840
|
}
|
|
1771
1841
|
if (count == 0) return kNoCompiledCssValue;
|
|
1772
|
-
compiled.
|
|
1842
|
+
compiled.aux = static_cast<std::uint8_t>(count);
|
|
1773
1843
|
list.push_back(compiled);
|
|
1774
1844
|
return static_cast<std::uint16_t>(list.size() - 1);
|
|
1775
1845
|
}
|
|
@@ -2393,13 +2463,17 @@ CssRule makeCssRule(CssRule::SelectorType selectorType,
|
|
|
2393
2463
|
const std::uint16_t compiledValue = declaration == CssDeclarationId::Custom
|
|
2394
2464
|
? compileCustomPropertyValue(value)
|
|
2395
2465
|
: compileCssValue(declaration, value);
|
|
2466
|
+
#if GEA_CSS_ANIMATIONS
|
|
2396
2467
|
const std::uint16_t compiledAnimationSpec = declaration == CssDeclarationId::Animation
|
|
2397
2468
|
? compileCssAnimationSpec(value)
|
|
2398
2469
|
: kNoCompiledCssAnimationSpec;
|
|
2470
|
+
#endif
|
|
2399
2471
|
const std::uint16_t mediaPlan = compileMediaConditionPlan(media);
|
|
2400
2472
|
const bool keepValueText =
|
|
2401
2473
|
declaration == CssDeclarationId::Custom ||
|
|
2474
|
+
#if GEA_CSS_ANIMATIONS
|
|
2402
2475
|
(declaration == CssDeclarationId::Animation && compiledAnimationSpec == kNoCompiledCssAnimationSpec) ||
|
|
2476
|
+
#endif
|
|
2403
2477
|
(declaration != CssDeclarationId::Animation &&
|
|
2404
2478
|
!compiledCssValueCanSkipRuleText(compiledValue));
|
|
2405
2479
|
const bool keepPropertyText =
|
|
@@ -2416,7 +2490,9 @@ CssRule makeCssRule(CssRule::SelectorType selectorType,
|
|
|
2416
2490
|
? storeCssRuleText(std::move(media))
|
|
2417
2491
|
: kNoCssRuleText;
|
|
2418
2492
|
CssRule rule{selectorType, pseudoElement, rulePropertyKind(declaration), declaration, compiledValue,
|
|
2493
|
+
#if GEA_CSS_ANIMATIONS
|
|
2419
2494
|
compiledAnimationSpec,
|
|
2495
|
+
#endif
|
|
2420
2496
|
selectorAtom, propertyAtom, selectorTagId, selectorPlan, mediaPlan,
|
|
2421
2497
|
propertyText, valueText, mediaText};
|
|
2422
2498
|
return rule;
|
|
@@ -2627,9 +2703,9 @@ std::uint16_t storeStaticTransformCompiledValue(std::uint16_t flags,
|
|
|
2627
2703
|
compiled.lengths[0] = cssLengthSpecForStatic(translateX);
|
|
2628
2704
|
compiled.lengths[1] = cssLengthSpecForStatic(translateY);
|
|
2629
2705
|
compiled.lengths[2] = cssLengthSpecForStatic(translateZ);
|
|
2630
|
-
compiled.values[
|
|
2631
|
-
compiled.values[
|
|
2632
|
-
compiled.values[
|
|
2706
|
+
compiled.values[3] = scaleX;
|
|
2707
|
+
compiled.values[4] = scaleY;
|
|
2708
|
+
compiled.values[5] = scaleZ;
|
|
2633
2709
|
list.push_back(compiled);
|
|
2634
2710
|
return static_cast<std::uint16_t>(list.size() - 1);
|
|
2635
2711
|
}
|
|
@@ -2754,7 +2830,9 @@ CssRule makeStaticCompiledCssRule(StaticStyleSelectorKind selectorKind,
|
|
|
2754
2830
|
propertyKind,
|
|
2755
2831
|
declaration,
|
|
2756
2832
|
compiledValue,
|
|
2833
|
+
#if GEA_CSS_ANIMATIONS
|
|
2757
2834
|
kNoCompiledCssAnimationSpec,
|
|
2835
|
+
#endif
|
|
2758
2836
|
selectorAtom,
|
|
2759
2837
|
kInvalidCssAtom,
|
|
2760
2838
|
selectorTagId,
|
|
@@ -3156,7 +3234,7 @@ CssKeyframeRule makeCssKeyframeRule(CssText name, int offsetPermille, CssText pr
|
|
|
3156
3234
|
const std::uint16_t valueText = compiledCssValueCanSkipKeyframeText(compiledValue)
|
|
3157
3235
|
? kNoCssRuleText
|
|
3158
3236
|
: storeCssRuleText(std::move(value));
|
|
3159
|
-
CssKeyframeRule rule{
|
|
3237
|
+
CssKeyframeRule rule{offsetPermille, nameAtom, rulePropertyKind(declaration),
|
|
3160
3238
|
declaration, compiledValue, valueText};
|
|
3161
3239
|
return rule;
|
|
3162
3240
|
}
|
|
@@ -3167,8 +3245,8 @@ CssKeyframeRule makeStaticCompiledKeyframeRule(const char *name,
|
|
|
3167
3245
|
CssDeclarationId declaration,
|
|
3168
3246
|
std::uint16_t compiledValue)
|
|
3169
3247
|
{
|
|
3170
|
-
return CssKeyframeRule{
|
|
3171
|
-
|
|
3248
|
+
return CssKeyframeRule{offsetPermille,
|
|
3249
|
+
internCssAtom(name ? name : ""),
|
|
3172
3250
|
propertyKind,
|
|
3173
3251
|
declaration,
|
|
3174
3252
|
compiledValue,
|
|
@@ -3264,8 +3342,8 @@ CssKeyframeRule makeStaticTransformKeyframeRule(const char *name,
|
|
|
3264
3342
|
int scaleY,
|
|
3265
3343
|
int scaleZ)
|
|
3266
3344
|
{
|
|
3267
|
-
return CssKeyframeRule{
|
|
3268
|
-
|
|
3345
|
+
return CssKeyframeRule{offsetPermille,
|
|
3346
|
+
internCssAtom(name ? name : ""),
|
|
3269
3347
|
rulePropertyKind(CssDeclarationId::Transform),
|
|
3270
3348
|
CssDeclarationId::Transform,
|
|
3271
3349
|
storeStaticTransformCompiledValue(flags,
|
|
@@ -3444,7 +3522,7 @@ const NodeCustomProperty *lookupCustomPropertyEntry(int nodeId, CssAtomId name)
|
|
|
3444
3522
|
|
|
3445
3523
|
const std::string *lookupCustomProperty(int nodeId, CssAtomId name)
|
|
3446
3524
|
{
|
|
3447
|
-
if (const NodeCustomProperty *entry = lookupCustomPropertyEntry(nodeId, name)) return
|
|
3525
|
+
if (const NodeCustomProperty *entry = lookupCustomPropertyEntry(nodeId, name)) return entry->value.get();
|
|
3448
3526
|
return nullptr;
|
|
3449
3527
|
}
|
|
3450
3528
|
|
|
@@ -4147,10 +4225,12 @@ void setCustomPropertyValue(NodeCustomPropertyStore &store, CssAtomId name, cons
|
|
|
4147
4225
|
color.alpha);
|
|
4148
4226
|
return;
|
|
4149
4227
|
}
|
|
4228
|
+
#if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
4150
4229
|
if (const CssLengthSpec *length = cachedCompiledCssLengthSpec(value)) {
|
|
4151
4230
|
store.setLength(name, value, length->value, static_cast<std::uint8_t>(length->unit));
|
|
4152
4231
|
return;
|
|
4153
4232
|
}
|
|
4233
|
+
#endif
|
|
4154
4234
|
store.set(name, value);
|
|
4155
4235
|
}
|
|
4156
4236
|
|
|
@@ -4174,6 +4254,7 @@ void setCustomPropertyRuleValue(NodeCustomPropertyStore &store,
|
|
|
4174
4254
|
static_cast<std::uint8_t>(compiled.values[2]));
|
|
4175
4255
|
return;
|
|
4176
4256
|
}
|
|
4257
|
+
#if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
4177
4258
|
if (compiled.kind == CssCompiledKind::Length) {
|
|
4178
4259
|
CssLengthSpec storedLength;
|
|
4179
4260
|
if (tryPreResolveStaticCustomLengthSpec(compiled.lengths[0], nodeId, storedLength)) {
|
|
@@ -4189,6 +4270,7 @@ void setCustomPropertyRuleValue(NodeCustomPropertyStore &store,
|
|
|
4189
4270
|
static_cast<std::uint8_t>(compiled.lengths[0].unit));
|
|
4190
4271
|
return;
|
|
4191
4272
|
}
|
|
4273
|
+
#endif
|
|
4192
4274
|
}
|
|
4193
4275
|
}
|
|
4194
4276
|
setCustomPropertyValue(store, name, value);
|
|
@@ -5539,7 +5621,7 @@ bool lengthDependsOnInput(const CssLengthSpec &length, int nodeId, CssLengthUnit
|
|
|
5539
5621
|
if (entry->hasLength()) {
|
|
5540
5622
|
spec.value = entry->lengthValue;
|
|
5541
5623
|
spec.unit = static_cast<CssLengthUnit>(entry->lengthUnit);
|
|
5542
|
-
} else if (!parseCompiledLengthSpec(entry->value, spec)) return false;
|
|
5624
|
+
} else if (!parseCompiledLengthSpec(*entry->value, spec)) return false;
|
|
5543
5625
|
return lengthDependsOnInput(spec, nodeId, input, depth + 1);
|
|
5544
5626
|
}
|
|
5545
5627
|
return expression.hasFallback && lengthDependsOnInput(expression.a, nodeId, input, depth + 1);
|
|
@@ -5658,7 +5740,7 @@ ResolvedCssLength resolveCompiledLengthExpressionForNode(const CssLengthExpressi
|
|
|
5658
5740
|
spec.unit = static_cast<CssLengthUnit>(entry->lengthUnit);
|
|
5659
5741
|
return resolveCompiledLengthForNodeDetailed(spec, nodeId, axis, depth + 1);
|
|
5660
5742
|
}
|
|
5661
|
-
return resolveCustomPropertyLengthForNode(entry->value, nodeId, axis, depth + 1);
|
|
5743
|
+
return resolveCustomPropertyLengthForNode(*entry->value, nodeId, axis, depth + 1);
|
|
5662
5744
|
}
|
|
5663
5745
|
if (expression.hasFallback)
|
|
5664
5746
|
return resolveCompiledLengthForNodeDetailed(expression.a, nodeId, axis, depth + 1);
|
|
@@ -6802,6 +6884,7 @@ bool compileKeywordValue(CssDeclarationId declaration, const std::string &value,
|
|
|
6802
6884
|
case CssDeclarationId::AlignContent:
|
|
6803
6885
|
compiled.values[0] = flexAlignValue(value);
|
|
6804
6886
|
return compiled.values[0] >= 0;
|
|
6887
|
+
#if GEA_CSS_GRID
|
|
6805
6888
|
case CssDeclarationId::GridRowStart:
|
|
6806
6889
|
case CssDeclarationId::GridColumnStart:
|
|
6807
6890
|
case CssDeclarationId::GridRowEnd:
|
|
@@ -6812,6 +6895,7 @@ bool compileKeywordValue(CssDeclarationId declaration, const std::string &value,
|
|
|
6812
6895
|
compiled.values[0] = line;
|
|
6813
6896
|
return true;
|
|
6814
6897
|
}
|
|
6898
|
+
#endif
|
|
6815
6899
|
case CssDeclarationId::JustifySelf:
|
|
6816
6900
|
compiled.values[0] = justifySelfValue(value);
|
|
6817
6901
|
return compiled.values[0] >= -1;
|
|
@@ -6836,12 +6920,14 @@ bool compileKeywordValue(CssDeclarationId declaration, const std::string &value,
|
|
|
6836
6920
|
case CssDeclarationId::TextOverflow:
|
|
6837
6921
|
compiled.values[0] = textOverflowValue(value);
|
|
6838
6922
|
return true;
|
|
6923
|
+
#if GEA_CSS_TRANSFORMS
|
|
6839
6924
|
case CssDeclarationId::TransformStyle: {
|
|
6840
6925
|
const auto lower = toLowerAscii(trimCssValue(value));
|
|
6841
6926
|
if (lower != "flat" && lower != "preserve-3d") return false;
|
|
6842
6927
|
compiled.values[0] = lower == "preserve-3d";
|
|
6843
6928
|
return true;
|
|
6844
6929
|
}
|
|
6930
|
+
#endif
|
|
6845
6931
|
case CssDeclarationId::Visibility:
|
|
6846
6932
|
compiled.values[0] = visibilityValue(value);
|
|
6847
6933
|
return compiled.values[0] >= 0;
|
|
@@ -6876,7 +6962,7 @@ bool compileTransformLength(const std::string &value, CssLengthSpec &out)
|
|
|
6876
6962
|
bool compileTransformValue(const std::string &value, CssCompiledValue &compiled)
|
|
6877
6963
|
{
|
|
6878
6964
|
TransformRotationProduct rotations;
|
|
6879
|
-
compiled.values[
|
|
6965
|
+
compiled.values[3] = compiled.values[4] = compiled.values[5] = 1000;
|
|
6880
6966
|
std::size_t i = 0;
|
|
6881
6967
|
bool sawTransform = false;
|
|
6882
6968
|
while (i < value.size()) {
|
|
@@ -6937,26 +7023,26 @@ bool compileTransformValue(const std::string &value, CssCompiledValue &compiled)
|
|
|
6937
7023
|
if (hasDynamicCssValue(arg)) return false;
|
|
6938
7024
|
const int sx = parseScalePermille(args.empty() ? arg : args[0]);
|
|
6939
7025
|
const int sy = parseScalePermille(args.size() > 1 ? args[1] : (args.empty() ? arg : args[0]));
|
|
6940
|
-
compiled.values[
|
|
6941
|
-
compiled.values[
|
|
7026
|
+
compiled.values[3] = multiplyScalePermille(compiled.values[3], sx);
|
|
7027
|
+
compiled.values[4] = multiplyScalePermille(compiled.values[4], sy);
|
|
6942
7028
|
compiled.flags |= (1u << 8) | (1u << 9);
|
|
6943
7029
|
} else if (name == "scale3d") {
|
|
6944
7030
|
if (hasDynamicCssValue(arg) || args.size() != 3) return false;
|
|
6945
|
-
compiled.values[
|
|
6946
|
-
compiled.values[
|
|
6947
|
-
compiled.values[
|
|
7031
|
+
compiled.values[3] = multiplyScalePermille(compiled.values[3], parseScalePermille(args[0]));
|
|
7032
|
+
compiled.values[4] = multiplyScalePermille(compiled.values[4], parseScalePermille(args[1]));
|
|
7033
|
+
compiled.values[5] = multiplyScalePermille(compiled.values[5], parseScalePermille(args[2]));
|
|
6948
7034
|
compiled.flags |= (1u << 8) | (1u << 9) | (1u << 13);
|
|
6949
7035
|
} else if (name == "scalex") {
|
|
6950
7036
|
if (hasDynamicCssValue(arg)) return false;
|
|
6951
|
-
compiled.values[
|
|
7037
|
+
compiled.values[3] = multiplyScalePermille(compiled.values[3], parseScalePermille(arg));
|
|
6952
7038
|
compiled.flags |= 1u << 8;
|
|
6953
7039
|
} else if (name == "scaley") {
|
|
6954
7040
|
if (hasDynamicCssValue(arg)) return false;
|
|
6955
|
-
compiled.values[
|
|
7041
|
+
compiled.values[4] = multiplyScalePermille(compiled.values[4], parseScalePermille(arg));
|
|
6956
7042
|
compiled.flags |= 1u << 9;
|
|
6957
7043
|
} else if (name == "scalez") {
|
|
6958
7044
|
if (hasDynamicCssValue(arg)) return false;
|
|
6959
|
-
compiled.values[
|
|
7045
|
+
compiled.values[5] = multiplyScalePermille(compiled.values[5], parseScalePermille(arg));
|
|
6960
7046
|
compiled.flags |= 1u << 13;
|
|
6961
7047
|
} else {
|
|
6962
7048
|
return false;
|
|
@@ -7098,9 +7184,9 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
|
|
|
7098
7184
|
int align, justify;
|
|
7099
7185
|
if (!parseAlignmentShorthand(declaration, value, align, justify)) return kNoCompiledCssValue;
|
|
7100
7186
|
compiled.kind = CssCompiledKind::DirectPropertyGroup;
|
|
7101
|
-
compiled.
|
|
7102
|
-
compiled.values[
|
|
7103
|
-
compiled.values[
|
|
7187
|
+
compiled.aux = 2;
|
|
7188
|
+
compiled.values[0] = static_cast<int>(alignProperty); compiled.values[1] = align;
|
|
7189
|
+
compiled.values[2] = static_cast<int>(justifyProperty); compiled.values[3] = justify;
|
|
7104
7190
|
return storeCompiledCssValue(compiled);
|
|
7105
7191
|
}
|
|
7106
7192
|
|
|
@@ -7286,7 +7372,12 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
|
|
|
7286
7372
|
case CssDeclarationId::BorderBottomWidth:
|
|
7287
7373
|
case CssDeclarationId::BorderLeftWidth:
|
|
7288
7374
|
case CssDeclarationId::FontSize:
|
|
7375
|
+
#if GEA_CSS_TRANSFORMS
|
|
7289
7376
|
case CssDeclarationId::Perspective:
|
|
7377
|
+
#endif
|
|
7378
|
+
// All preceding length declarations share this body. Only Perspective
|
|
7379
|
+
// itself is conditional; otherwise font-size/padding/min-size fall
|
|
7380
|
+
// through into the unrelated LineHeight compiler when transforms are off.
|
|
7290
7381
|
if (isBorderWidthDeclaration(declaration) && isNegativeLengthLiteral(value)) return kNoCompiledCssValue;
|
|
7291
7382
|
if (!compiledCssValueFeatureEnabled(kCssCompiledFeatureLength)) return kNoCompiledCssValue;
|
|
7292
7383
|
if (!parseCompiledLengthSpec(value, compiled.lengths[0])) return kNoCompiledCssValue;
|
|
@@ -7298,6 +7389,7 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
|
|
|
7298
7389
|
if (!compileLineHeightValue(value, compiled)) return kNoCompiledCssValue;
|
|
7299
7390
|
compiled.kind = CssCompiledKind::LineHeight;
|
|
7300
7391
|
return storeCompiledCssValue(compiled);
|
|
7392
|
+
#if GEA_CSS_TRANSFORMS
|
|
7301
7393
|
case CssDeclarationId::TransformOrigin:
|
|
7302
7394
|
case CssDeclarationId::PerspectiveOrigin: {
|
|
7303
7395
|
if (hasVar) return kNoCompiledCssValue;
|
|
@@ -7331,18 +7423,19 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
|
|
|
7331
7423
|
std::string function;
|
|
7332
7424
|
if (!individualTranslateFunction(value, function)) return kNoCompiledCssValue;
|
|
7333
7425
|
compiled.kind = CssCompiledKind::Transform;
|
|
7334
|
-
compiled.values[
|
|
7426
|
+
compiled.values[3] = compiled.values[4] = 1000;
|
|
7335
7427
|
if (function != "none" && !compileTransformValue(function, compiled)) return kNoCompiledCssValue;
|
|
7336
7428
|
return storeCompiledCssValue(compiled);
|
|
7337
7429
|
}
|
|
7338
7430
|
case CssDeclarationId::Transform: {
|
|
7339
7431
|
if (!compiledCssValueFeatureEnabled(kCssCompiledFeatureTransform)) return kNoCompiledCssValue;
|
|
7340
7432
|
compiled.kind = CssCompiledKind::Transform;
|
|
7341
|
-
compiled.values[
|
|
7342
|
-
compiled.values[
|
|
7433
|
+
compiled.values[3] = 1000;
|
|
7434
|
+
compiled.values[4] = 1000;
|
|
7343
7435
|
if (!compileTransformValue(value, compiled)) return kNoCompiledCssValue;
|
|
7344
7436
|
return storeCompiledCssValue(compiled);
|
|
7345
7437
|
}
|
|
7438
|
+
#endif
|
|
7346
7439
|
case CssDeclarationId::Filter:
|
|
7347
7440
|
if (hasVar && toLowerAscii(value).find("blur(") == std::string::npos) return kNoCompiledCssValue;
|
|
7348
7441
|
if (!compiledCssValueFeatureEnabled(kCssCompiledFeatureEffects)) return kNoCompiledCssValue;
|
|
@@ -7360,6 +7453,7 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
|
|
|
7360
7453
|
if (!compileBoxShadowValue(value, compiled)) return kNoCompiledCssValue;
|
|
7361
7454
|
compiled.kind = CssCompiledKind::BoxShadow;
|
|
7362
7455
|
return storeCompiledCssValue(compiled);
|
|
7456
|
+
#if GEA_CSS_GRID
|
|
7363
7457
|
case CssDeclarationId::GridTemplateColumns:
|
|
7364
7458
|
case CssDeclarationId::GridTemplateRows:
|
|
7365
7459
|
if (hasVar) return kNoCompiledCssValue;
|
|
@@ -7367,6 +7461,7 @@ std::uint16_t compileCssValue(CssDeclarationId declaration, const CssText &rawVa
|
|
|
7367
7461
|
if (!compileGridTemplateValue(value, compiled)) return kNoCompiledCssValue;
|
|
7368
7462
|
compiled.kind = CssCompiledKind::GridTemplate;
|
|
7369
7463
|
return storeCompiledCssValue(compiled);
|
|
7464
|
+
#endif
|
|
7370
7465
|
default:
|
|
7371
7466
|
return kNoCompiledCssValue;
|
|
7372
7467
|
}
|
|
@@ -7391,6 +7486,7 @@ void markDisplayListDirtyForStyleApply()
|
|
|
7391
7486
|
|
|
7392
7487
|
void applyCompiledGridTemplateValue(NodeHandle node, const CssCompiledGridTemplate &grid, bool columns)
|
|
7393
7488
|
{
|
|
7489
|
+
#if GEA_CSS_GRID
|
|
7394
7490
|
if (!node) return;
|
|
7395
7491
|
const int nodeId = node.id();
|
|
7396
7492
|
Node &target = treeState().nodes[nodeId];
|
|
@@ -7414,8 +7510,11 @@ void applyCompiledGridTemplateValue(NodeHandle node, const CssCompiledGridTempla
|
|
|
7414
7510
|
count = static_cast<std::int8_t>(trackCount);
|
|
7415
7511
|
target.render.dirty = 1;
|
|
7416
7512
|
target.render.layout_dirty = 1;
|
|
7513
|
+
#if GEA_CSS_SCROLLING
|
|
7417
7514
|
target.render.non_scroll_dirty = 1;
|
|
7515
|
+
#endif
|
|
7418
7516
|
markDisplayListDirtyForStyleApply();
|
|
7517
|
+
#endif
|
|
7419
7518
|
}
|
|
7420
7519
|
|
|
7421
7520
|
int g_resolvedFontNode = -1;
|
|
@@ -7452,60 +7551,124 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7452
7551
|
style.flex_direction_explicit = 1;
|
|
7453
7552
|
style.flex_direction = value;
|
|
7454
7553
|
return true;
|
|
7554
|
+
#if GEA_CSS_FLEX_WRAP
|
|
7455
7555
|
case Property::FlexWrap: style.flex_wrap = value; return true;
|
|
7556
|
+
#endif
|
|
7557
|
+
#if GEA_CSS_FLEX_LINE_COUNT
|
|
7456
7558
|
case Property::FlexLineCount: rstyleMut(style).flex_line_count = value; return true;
|
|
7559
|
+
#endif
|
|
7560
|
+
#if GEA_CSS_BACKGROUND_LAYERS
|
|
7457
7561
|
case Property::BackgroundClip: rstyleMut(style).bg_clip = value; return true;
|
|
7458
7562
|
case Property::BackgroundSizeList: rstyleMut(style).bg_size_list = value; return true;
|
|
7459
7563
|
case Property::BackgroundPositionList: rstyleMut(style).bg_position_list = value; return true;
|
|
7460
7564
|
case Property::BackgroundRepeatList: rstyleMut(style).bg_repeat_list = value; return true;
|
|
7461
7565
|
case Property::BackgroundAttachmentList: rstyleMut(style).bg_attachment_list = value; return true;
|
|
7462
7566
|
case Property::BackgroundOriginList: rstyleMut(style).bg_origin_list = value; return true;
|
|
7567
|
+
#endif
|
|
7463
7568
|
|
|
7569
|
+
#if GEA_CSS_CONTAINMENT
|
|
7464
7570
|
case Property::Containment: rstyleMut(style).containment = value; return true;
|
|
7571
|
+
#endif
|
|
7465
7572
|
case Property::JustifyContent: style.justify_content = value; return true;
|
|
7466
7573
|
case Property::AlignItems: style.align_items = value; return true;
|
|
7574
|
+
#if GEA_CSS_JUSTIFY_ITEMS
|
|
7467
7575
|
case Property::JustifyItems: style.justify_items = value; return true;
|
|
7576
|
+
#endif
|
|
7577
|
+
#if GEA_CSS_ALIGN_CONTENT
|
|
7468
7578
|
case Property::AlignContent: style.align_content = value; return true;
|
|
7579
|
+
#endif
|
|
7580
|
+
#if GEA_CSS_ALIGN_SELF
|
|
7469
7581
|
case Property::AlignSelf: style.align_self = value; return true;
|
|
7582
|
+
#endif
|
|
7583
|
+
#if GEA_CSS_JUSTIFY_SELF
|
|
7470
7584
|
case Property::JustifySelf: rstyleMut(style).justify_self = value; return true;
|
|
7585
|
+
#endif
|
|
7586
|
+
#if GEA_CSS_GRID
|
|
7471
7587
|
case Property::GridRowStart: rstyleMut(style).grid_line[0] = value; return true;
|
|
7472
7588
|
case Property::GridColumnStart: rstyleMut(style).grid_line[1] = value; return true;
|
|
7473
7589
|
case Property::GridRowEnd: rstyleMut(style).grid_line[2] = value; return true;
|
|
7474
7590
|
case Property::GridColumnEnd: rstyleMut(style).grid_line[3] = value; return true;
|
|
7591
|
+
#endif
|
|
7475
7592
|
case Property::BoxSizing: style.box_sizing = value; return true;
|
|
7593
|
+
#if GEA_CSS_FLOATS
|
|
7476
7594
|
case Property::Float: style.float_side = value; return true;
|
|
7595
|
+
#endif
|
|
7596
|
+
#if GEA_CSS_ASPECT_RATIO
|
|
7477
7597
|
case Property::AspectRatio: rstyleMut(style).aspect_ratio = value; return true;
|
|
7598
|
+
#endif
|
|
7599
|
+
#if GEA_CSS_MARGIN_TRIM
|
|
7478
7600
|
case Property::MarginTrim: rstyleMut(style).margin_trim = value; return true;
|
|
7601
|
+
#endif
|
|
7602
|
+
#if GEA_CSS_FLOATS
|
|
7479
7603
|
case Property::Clear: style.clear_side = value; return true;
|
|
7604
|
+
#endif
|
|
7605
|
+
#if GEA_CSS_WRITING_MODE
|
|
7480
7606
|
case Property::WritingMode: style.writing_mode = value; return true;
|
|
7481
7607
|
case Property::Direction: style.direction = value; return true;
|
|
7608
|
+
#endif
|
|
7609
|
+
#if GEA_CSS_AXIS_GAP
|
|
7482
7610
|
case Property::RowGap: style.row_gap = value; return true;
|
|
7611
|
+
#endif
|
|
7612
|
+
#if GEA_CSS_AXIS_GAP
|
|
7483
7613
|
case Property::ColumnGap: style.column_gap = value; return true;
|
|
7614
|
+
#endif
|
|
7615
|
+
#if GEA_CSS_PERCENT_GAP
|
|
7484
7616
|
case Property::RowGapPercent: style.row_gap_percent = value; return true;
|
|
7485
7617
|
case Property::ColumnGapPercent: style.column_gap_percent = value; return true;
|
|
7618
|
+
#endif
|
|
7486
7619
|
case Property::MarginTopAuto: style.margin_auto = (style.margin_auto & ~1) | (value ? 1 : 0); return true;
|
|
7487
7620
|
case Property::MarginRightAuto: style.margin_auto = (style.margin_auto & ~2) | (value ? 2 : 0); return true;
|
|
7488
7621
|
case Property::MarginBottomAuto: style.margin_auto = (style.margin_auto & ~4) | (value ? 4 : 0); return true;
|
|
7489
7622
|
case Property::MarginLeftAuto: style.margin_auto = (style.margin_auto & ~8) | (value ? 8 : 0); return true;
|
|
7623
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7490
7624
|
case Property::MarginTopExpression: rstyleMut(style).margin_expression[0] = value; return true;
|
|
7625
|
+
#endif
|
|
7626
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7491
7627
|
case Property::MarginRightExpression: rstyleMut(style).margin_expression[1] = value; return true;
|
|
7628
|
+
#endif
|
|
7629
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7492
7630
|
case Property::MarginBottomExpression: rstyleMut(style).margin_expression[2] = value; return true;
|
|
7631
|
+
#endif
|
|
7632
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7493
7633
|
case Property::MarginLeftExpression: rstyleMut(style).margin_expression[3] = value; return true;
|
|
7634
|
+
#endif
|
|
7635
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7494
7636
|
case Property::PaddingTopExpression: rstyleMut(style).padding_expression[0] = value; return true;
|
|
7637
|
+
#endif
|
|
7638
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7495
7639
|
case Property::PaddingRightExpression: rstyleMut(style).padding_expression[1] = value; return true;
|
|
7640
|
+
#endif
|
|
7641
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7496
7642
|
case Property::PaddingBottomExpression: rstyleMut(style).padding_expression[2] = value; return true;
|
|
7643
|
+
#endif
|
|
7644
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7497
7645
|
case Property::PaddingLeftExpression: rstyleMut(style).padding_expression[3] = value; return true;
|
|
7646
|
+
#endif
|
|
7498
7647
|
case Property::WidthExpression: style.width_expression = value; style.width = style.width_percent = kUnset; return true;
|
|
7648
|
+
#if GEA_CSS_HEIGHT_EXPRESSIONS
|
|
7499
7649
|
case Property::HeightExpression: style.height_expression = value; style.height = style.height_percent = kUnset; return true;
|
|
7650
|
+
#endif
|
|
7651
|
+
#if GEA_CSS_ORDER
|
|
7500
7652
|
case Property::Order: style.order = value; return true;
|
|
7501
|
-
|
|
7653
|
+
#endif
|
|
7654
|
+
case Property::Gap:
|
|
7655
|
+
style.gap = value;
|
|
7656
|
+
#if GEA_CSS_AXIS_GAP
|
|
7657
|
+
style.row_gap = style.column_gap = kUnset;
|
|
7658
|
+
#endif
|
|
7659
|
+
#if GEA_CSS_PERCENT_GAP
|
|
7660
|
+
style.row_gap_percent = style.column_gap_percent = kUnset;
|
|
7661
|
+
#endif
|
|
7662
|
+
return true;
|
|
7502
7663
|
case Property::Width:
|
|
7503
7664
|
style.width_expression = -1;
|
|
7504
7665
|
style.width = value;
|
|
7505
7666
|
style.width_percent = kUnset;
|
|
7506
7667
|
return true;
|
|
7507
7668
|
case Property::Height:
|
|
7669
|
+
#if GEA_CSS_HEIGHT_EXPRESSIONS
|
|
7508
7670
|
style.height_expression = -1;
|
|
7671
|
+
#endif
|
|
7509
7672
|
style.height = value;
|
|
7510
7673
|
style.height_percent = kUnset;
|
|
7511
7674
|
return true;
|
|
@@ -7515,66 +7678,165 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7515
7678
|
style.width = kUnset;
|
|
7516
7679
|
return true;
|
|
7517
7680
|
case Property::HeightPercent:
|
|
7681
|
+
#if GEA_CSS_HEIGHT_EXPRESSIONS
|
|
7518
7682
|
style.height_expression = -1;
|
|
7683
|
+
#endif
|
|
7519
7684
|
style.height_percent = value;
|
|
7520
7685
|
style.height = kUnset;
|
|
7521
7686
|
return true;
|
|
7687
|
+
#if GEA_CSS_MIN_WIDTH
|
|
7522
7688
|
case Property::MinWidth: style.min_width = value; return true;
|
|
7689
|
+
#endif
|
|
7523
7690
|
case Property::MinHeight: style.min_height = value; return true;
|
|
7524
7691
|
case Property::MaxWidth: style.max_width = value; return true;
|
|
7692
|
+
#if GEA_CSS_MAX_HEIGHT
|
|
7525
7693
|
case Property::MaxHeight: style.max_height = value; return true;
|
|
7694
|
+
#endif
|
|
7526
7695
|
case Property::Flex: style.flex = value; return true;
|
|
7527
7696
|
case Property::FlexShrink: style.flex_shrink = value; return true;
|
|
7528
7697
|
case Property::FlexBasis:
|
|
7698
|
+
#if GEA_CSS_FLEX_BASIS_EXPRESSIONS
|
|
7529
7699
|
if (rstyle(style).flex_basis_expression >= 0) rstyleMut(style).flex_basis_expression = -1;
|
|
7530
|
-
|
|
7700
|
+
#endif
|
|
7701
|
+
#if GEA_CSS_FLEX_BASIS
|
|
7702
|
+
style.flex_basis = value;
|
|
7703
|
+
#endif
|
|
7704
|
+
return true;
|
|
7705
|
+
#if GEA_CSS_FLEX_BASIS_EXPRESSIONS
|
|
7531
7706
|
case Property::FlexBasisExpression:
|
|
7532
|
-
rstyleMut(style).flex_basis_expression = value;
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
case Property::
|
|
7539
|
-
|
|
7540
|
-
|
|
7707
|
+
rstyleMut(style).flex_basis_expression = value;
|
|
7708
|
+
#if GEA_CSS_FLEX_BASIS
|
|
7709
|
+
style.flex_basis = kUnset;
|
|
7710
|
+
#endif
|
|
7711
|
+
return true;
|
|
7712
|
+
#endif
|
|
7713
|
+
case Property::PaddingTop:
|
|
7714
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7715
|
+
if (rstyle(style).padding_expression[0] >= 0) rstyleMut(style).padding_expression[0] = -1;
|
|
7716
|
+
#endif
|
|
7717
|
+
style.padding[0] = value; return true;
|
|
7718
|
+
case Property::PaddingRight:
|
|
7719
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7720
|
+
if (rstyle(style).padding_expression[1] >= 0) rstyleMut(style).padding_expression[1] = -1;
|
|
7721
|
+
#endif
|
|
7722
|
+
style.padding[1] = value; return true;
|
|
7723
|
+
case Property::PaddingBottom:
|
|
7724
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7725
|
+
if (rstyle(style).padding_expression[2] >= 0) rstyleMut(style).padding_expression[2] = -1;
|
|
7726
|
+
#endif
|
|
7727
|
+
style.padding[2] = value; return true;
|
|
7728
|
+
case Property::PaddingLeft:
|
|
7729
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7730
|
+
if (rstyle(style).padding_expression[3] >= 0) rstyleMut(style).padding_expression[3] = -1;
|
|
7731
|
+
#endif
|
|
7732
|
+
style.padding[3] = value; return true;
|
|
7733
|
+
case Property::MarginTop:
|
|
7734
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7735
|
+
if (rstyle(style).margin_expression[0] >= 0) rstyleMut(style).margin_expression[0] = -1;
|
|
7736
|
+
#endif
|
|
7737
|
+
style.margin_auto &= ~1; style.margin[0] = value; return true;
|
|
7738
|
+
case Property::MarginRight:
|
|
7739
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7740
|
+
if (rstyle(style).margin_expression[1] >= 0) rstyleMut(style).margin_expression[1] = -1;
|
|
7741
|
+
#endif
|
|
7742
|
+
style.margin_auto &= ~2; style.margin[1] = value; return true;
|
|
7743
|
+
case Property::MarginBottom:
|
|
7744
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7745
|
+
if (rstyle(style).margin_expression[2] >= 0) rstyleMut(style).margin_expression[2] = -1;
|
|
7746
|
+
#endif
|
|
7747
|
+
style.margin_auto &= ~4; style.margin[2] = value; return true;
|
|
7748
|
+
case Property::MarginLeft:
|
|
7749
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
7750
|
+
if (rstyle(style).margin_expression[3] >= 0) rstyleMut(style).margin_expression[3] = -1;
|
|
7751
|
+
#endif
|
|
7752
|
+
style.margin_auto &= ~8; style.margin[3] = value; return true;
|
|
7541
7753
|
case Property::Position: if (value == kPositionFixed) treeState().fixedPositionUsed = true; style.position = value; return true;
|
|
7542
7754
|
case Property::Top:
|
|
7543
|
-
|
|
7544
|
-
style
|
|
7755
|
+
#if GEA_CSS_POSITION_TOP
|
|
7756
|
+
GEA_CSS_POSITION_PX_0(style) = value;
|
|
7757
|
+
#if GEA_CSS_POSITION_TOP_PERCENT
|
|
7758
|
+
GEA_CSS_POSITION_PERCENT_0(style) = kUnset;
|
|
7759
|
+
#endif
|
|
7545
7760
|
return true;
|
|
7761
|
+
#else
|
|
7762
|
+
return false;
|
|
7763
|
+
#endif
|
|
7546
7764
|
case Property::Right:
|
|
7547
|
-
|
|
7548
|
-
style
|
|
7765
|
+
#if GEA_CSS_POSITION_RIGHT
|
|
7766
|
+
GEA_CSS_POSITION_PX_1(style) = value;
|
|
7767
|
+
#if GEA_CSS_POSITION_RIGHT_PERCENT
|
|
7768
|
+
GEA_CSS_POSITION_PERCENT_1(style) = kUnset;
|
|
7769
|
+
#endif
|
|
7549
7770
|
return true;
|
|
7771
|
+
#else
|
|
7772
|
+
return false;
|
|
7773
|
+
#endif
|
|
7550
7774
|
case Property::Bottom:
|
|
7551
|
-
|
|
7552
|
-
style
|
|
7775
|
+
#if GEA_CSS_POSITION_BOTTOM
|
|
7776
|
+
GEA_CSS_POSITION_PX_2(style) = value;
|
|
7777
|
+
#if GEA_CSS_POSITION_BOTTOM_PERCENT
|
|
7778
|
+
GEA_CSS_POSITION_PERCENT_2(style) = kUnset;
|
|
7779
|
+
#endif
|
|
7553
7780
|
return true;
|
|
7781
|
+
#else
|
|
7782
|
+
return false;
|
|
7783
|
+
#endif
|
|
7554
7784
|
case Property::Left:
|
|
7555
|
-
|
|
7556
|
-
style
|
|
7785
|
+
#if GEA_CSS_POSITION_LEFT
|
|
7786
|
+
GEA_CSS_POSITION_PX_3(style) = value;
|
|
7787
|
+
#if GEA_CSS_POSITION_LEFT_PERCENT
|
|
7788
|
+
GEA_CSS_POSITION_PERCENT_3(style) = kUnset;
|
|
7789
|
+
#endif
|
|
7557
7790
|
return true;
|
|
7791
|
+
#else
|
|
7792
|
+
return false;
|
|
7793
|
+
#endif
|
|
7558
7794
|
case Property::TopPercent:
|
|
7559
|
-
|
|
7560
|
-
style
|
|
7795
|
+
#if GEA_CSS_POSITION_TOP_PERCENT
|
|
7796
|
+
GEA_CSS_POSITION_PERCENT_0(style) = value;
|
|
7797
|
+
#if GEA_CSS_POSITION_TOP
|
|
7798
|
+
GEA_CSS_POSITION_PX_0(style) = kUnset;
|
|
7799
|
+
#endif
|
|
7561
7800
|
return true;
|
|
7801
|
+
#else
|
|
7802
|
+
return false;
|
|
7803
|
+
#endif
|
|
7562
7804
|
case Property::RightPercent:
|
|
7563
|
-
|
|
7564
|
-
style
|
|
7805
|
+
#if GEA_CSS_POSITION_RIGHT_PERCENT
|
|
7806
|
+
GEA_CSS_POSITION_PERCENT_1(style) = value;
|
|
7807
|
+
#if GEA_CSS_POSITION_RIGHT
|
|
7808
|
+
GEA_CSS_POSITION_PX_1(style) = kUnset;
|
|
7809
|
+
#endif
|
|
7565
7810
|
return true;
|
|
7811
|
+
#else
|
|
7812
|
+
return false;
|
|
7813
|
+
#endif
|
|
7566
7814
|
case Property::BottomPercent:
|
|
7567
|
-
|
|
7568
|
-
style
|
|
7815
|
+
#if GEA_CSS_POSITION_BOTTOM_PERCENT
|
|
7816
|
+
GEA_CSS_POSITION_PERCENT_2(style) = value;
|
|
7817
|
+
#if GEA_CSS_POSITION_BOTTOM
|
|
7818
|
+
GEA_CSS_POSITION_PX_2(style) = kUnset;
|
|
7819
|
+
#endif
|
|
7569
7820
|
return true;
|
|
7821
|
+
#else
|
|
7822
|
+
return false;
|
|
7823
|
+
#endif
|
|
7570
7824
|
case Property::LeftPercent:
|
|
7571
|
-
|
|
7572
|
-
style
|
|
7825
|
+
#if GEA_CSS_POSITION_LEFT_PERCENT
|
|
7826
|
+
GEA_CSS_POSITION_PERCENT_3(style) = value;
|
|
7827
|
+
#if GEA_CSS_POSITION_LEFT
|
|
7828
|
+
GEA_CSS_POSITION_PX_3(style) = kUnset;
|
|
7829
|
+
#endif
|
|
7573
7830
|
return true;
|
|
7831
|
+
#else
|
|
7832
|
+
return false;
|
|
7833
|
+
#endif
|
|
7834
|
+
#if GEA_CSS_Z_INDEX
|
|
7574
7835
|
case Property::ZIndex:
|
|
7575
7836
|
style.z_index_auto = value == kZIndexAuto;
|
|
7576
7837
|
style.z_index = style.z_index_auto ? 0 : std::clamp(value, -32768, 32767);
|
|
7577
7838
|
return true;
|
|
7839
|
+
#endif
|
|
7578
7840
|
case Property::BackgroundColor: {
|
|
7579
7841
|
style.bg_color = StyleValues::pixelFromStyleValue(value);
|
|
7580
7842
|
style.bg_alpha = 255;
|
|
@@ -7591,33 +7853,52 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7591
7853
|
case Property::HasActiveBackground: style.has_active_bg = value; return true;
|
|
7592
7854
|
case Property::Color:
|
|
7593
7855
|
style.text_color = StyleValues::pixelFromStyleValue(value);
|
|
7856
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
7594
7857
|
style.text_alpha = 255;
|
|
7858
|
+
#endif
|
|
7595
7859
|
return true;
|
|
7860
|
+
#if GEA_CSS_OPACITY
|
|
7596
7861
|
case Property::Opacity:
|
|
7597
7862
|
style.opacity = static_cast<std::uint8_t>(value < 0 ? 0 : value > 255 ? 255 : value);
|
|
7598
7863
|
return true;
|
|
7599
|
-
|
|
7600
|
-
case Property::
|
|
7864
|
+
#endif
|
|
7865
|
+
case Property::ColorAlpha:
|
|
7866
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
7867
|
+
style.text_alpha = static_cast<std::uint8_t>(std::clamp(value, 0, 255));
|
|
7868
|
+
#endif
|
|
7869
|
+
return true;
|
|
7870
|
+
case Property::BorderAlpha:
|
|
7871
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
7872
|
+
style.border_alpha = static_cast<std::uint8_t>(std::clamp(value, 0, 255));
|
|
7873
|
+
#endif
|
|
7874
|
+
return true;
|
|
7875
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
7601
7876
|
case Property::BorderTopAlpha:
|
|
7602
7877
|
case Property::BorderRightAlpha:
|
|
7603
7878
|
case Property::BorderBottomAlpha:
|
|
7604
7879
|
case Property::BorderLeftAlpha:
|
|
7605
7880
|
rstyleMut(style).border_side_alpha[static_cast<int>(property) - static_cast<int>(Property::BorderTopAlpha)] = static_cast<std::uint8_t>(std::clamp(value, 0, 255));
|
|
7606
7881
|
return true;
|
|
7882
|
+
#endif
|
|
7607
7883
|
case Property::BorderColorCurrent: setBorderColorBinding(style, -1, value != 0); return true;
|
|
7884
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
7608
7885
|
case Property::BorderTopColorCurrent:
|
|
7609
7886
|
case Property::BorderRightColorCurrent:
|
|
7610
7887
|
case Property::BorderBottomColorCurrent:
|
|
7611
7888
|
case Property::BorderLeftColorCurrent:
|
|
7612
7889
|
setBorderColorBinding(style, static_cast<int>(property) - static_cast<int>(Property::BorderTopColorCurrent), value != 0);
|
|
7613
7890
|
return true;
|
|
7891
|
+
#endif
|
|
7614
7892
|
case Property::BorderWidth:
|
|
7615
7893
|
setComputedBorderWidth(style, -1, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
|
|
7616
7894
|
case Property::BorderColor:
|
|
7617
7895
|
setBorderColorBinding(style, -1, false);
|
|
7618
7896
|
style.border_color = StyleValues::pixelFromStyleValue(value);
|
|
7897
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
7619
7898
|
style.border_alpha = 255;
|
|
7899
|
+
#endif
|
|
7620
7900
|
return true;
|
|
7901
|
+
#if GEA_CSS_BORDER_RELIEF
|
|
7621
7902
|
case Property::BorderTopRelief:
|
|
7622
7903
|
case Property::BorderRightRelief:
|
|
7623
7904
|
case Property::BorderBottomRelief:
|
|
@@ -7630,6 +7911,8 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7630
7911
|
if (value == 0 && !hasBorderRelief(style)) return true;
|
|
7631
7912
|
for (int side = 0; side < 4; ++side) rstyleMut(style).border_relief[side] = static_cast<uint8_t>(value);
|
|
7632
7913
|
return true;
|
|
7914
|
+
#endif
|
|
7915
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
7633
7916
|
case Property::BorderTopWidth: setComputedBorderWidth(style, 0, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
|
|
7634
7917
|
case Property::BorderRightWidth: setComputedBorderWidth(style, 1, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
|
|
7635
7918
|
case Property::BorderBottomWidth: setComputedBorderWidth(style, 2, value, target.parent >= 0 ? &treeState().nodes[target.parent].style : nullptr); return true;
|
|
@@ -7654,62 +7937,92 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7654
7937
|
rstyleMut(style).border_side_color[3] = StyleValues::pixelFromStyleValue(value);
|
|
7655
7938
|
rstyleMut(style).border_side_alpha[3] = 255;
|
|
7656
7939
|
return true;
|
|
7940
|
+
#endif
|
|
7657
7941
|
case Property::BorderRadiusTopLeft:
|
|
7658
|
-
style.border_radius[0] = value;
|
|
7659
|
-
|
|
7942
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(0)] = value;
|
|
7943
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
7944
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] = kUnset;
|
|
7945
|
+
#endif
|
|
7660
7946
|
return true;
|
|
7661
7947
|
case Property::BorderRadiusTopRight:
|
|
7662
|
-
style.border_radius[1] = value;
|
|
7663
|
-
|
|
7948
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(1)] = value;
|
|
7949
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
7950
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] = kUnset;
|
|
7951
|
+
#endif
|
|
7664
7952
|
return true;
|
|
7665
7953
|
case Property::BorderRadiusBottomRight:
|
|
7666
|
-
style.border_radius[2] = value;
|
|
7667
|
-
|
|
7954
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(2)] = value;
|
|
7955
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
7956
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] = kUnset;
|
|
7957
|
+
#endif
|
|
7668
7958
|
return true;
|
|
7669
7959
|
case Property::BorderRadiusBottomLeft:
|
|
7670
|
-
style.border_radius[3] = value;
|
|
7671
|
-
|
|
7960
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(3)] = value;
|
|
7961
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
7962
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] = kUnset;
|
|
7963
|
+
#endif
|
|
7672
7964
|
return true;
|
|
7965
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
7673
7966
|
case Property::BorderRadiusTopLeftPercent:
|
|
7674
|
-
style.border_radius_percent[0] = value;
|
|
7675
|
-
style.border_radius[0] = 0;
|
|
7967
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] = value;
|
|
7968
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(0)] = 0;
|
|
7676
7969
|
return true;
|
|
7677
7970
|
case Property::BorderRadiusTopRightPercent:
|
|
7678
|
-
style.border_radius_percent[1] = value;
|
|
7679
|
-
style.border_radius[1] = 0;
|
|
7971
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] = value;
|
|
7972
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(1)] = 0;
|
|
7680
7973
|
return true;
|
|
7681
7974
|
case Property::BorderRadiusBottomRightPercent:
|
|
7682
|
-
style.border_radius_percent[2] = value;
|
|
7683
|
-
style.border_radius[2] = 0;
|
|
7975
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] = value;
|
|
7976
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(2)] = 0;
|
|
7684
7977
|
return true;
|
|
7685
7978
|
case Property::BorderRadiusBottomLeftPercent:
|
|
7686
|
-
style.border_radius_percent[3] = value;
|
|
7687
|
-
style.border_radius[3] = 0;
|
|
7979
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] = value;
|
|
7980
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(3)] = 0;
|
|
7688
7981
|
return true;
|
|
7982
|
+
#endif
|
|
7689
7983
|
case Property::FontId: style.font_id = value; return true;
|
|
7690
7984
|
case Property::FontSize: style.font_size = value; return true;
|
|
7691
7985
|
case Property::FontWeight: style.font_weight = value; return true;
|
|
7692
7986
|
case Property::LineHeight:
|
|
7693
7987
|
if (style.line_height_multiplier >= 0) style.line_height_multiplier = -1;
|
|
7988
|
+
#if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
|
|
7694
7989
|
if (rstyle(style).line_height_expression >= 0) rstyleMut(style).line_height_expression = -1;
|
|
7990
|
+
#endif
|
|
7695
7991
|
style.line_height = value; return true;
|
|
7992
|
+
#if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
|
|
7696
7993
|
case Property::LineHeightExpression:
|
|
7697
7994
|
if (style.line_height_multiplier >= 0) style.line_height_multiplier = -1;
|
|
7698
7995
|
rstyleMut(style).line_height_expression = value;
|
|
7699
7996
|
style.line_height = resolveLineHeightExpression(static_cast<int>(&target - treeState().nodes), value); return true;
|
|
7997
|
+
#endif
|
|
7700
7998
|
case Property::LineHeightMultiplier:
|
|
7701
7999
|
style.line_height_multiplier = value;
|
|
8000
|
+
#if GEA_CSS_LINE_HEIGHT_EXPRESSIONS
|
|
7702
8001
|
if (rstyle(style).line_height_expression >= 0) rstyleMut(style).line_height_expression = -1;
|
|
8002
|
+
#endif
|
|
7703
8003
|
style.line_height = resolveLineHeightMultiplier(static_cast<int>(&target - treeState().nodes), value); return true;
|
|
7704
8004
|
case Property::TextAlign: style.text_align = value; return true;
|
|
8005
|
+
#if GEA_CSS_TEXT_DECORATION
|
|
7705
8006
|
case Property::TextDecoration: style.text_decoration = value; return true;
|
|
8007
|
+
#endif
|
|
8008
|
+
#if GEA_CSS_TEXT_TRANSFORM
|
|
7706
8009
|
case Property::TextTransform: style.text_transform = value; return true;
|
|
8010
|
+
#endif
|
|
7707
8011
|
case Property::WhiteSpace: style.white_space = static_cast<std::int8_t>(value); return true;
|
|
7708
8012
|
case Property::TextOverflow: style.text_overflow = static_cast<std::int8_t>(value); return true;
|
|
8013
|
+
#if GEA_CSS_TRANSFORMS
|
|
7709
8014
|
case Property::TransformStyle: rstyleMut(style).transform_preserve_3d = value != 0; return true;
|
|
8015
|
+
#endif
|
|
8016
|
+
#if GEA_CSS_VISIBILITY
|
|
7710
8017
|
case Property::Visibility: style.visibility = static_cast<std::int8_t>(value); return true;
|
|
8018
|
+
#endif
|
|
8019
|
+
#if GEA_CSS_TRANSFORMS
|
|
7711
8020
|
case Property::Backface: style.backface_hidden = static_cast<std::int8_t>(value); return true;
|
|
8021
|
+
#endif
|
|
8022
|
+
#if GEA_CSS_POINTER_EVENTS
|
|
7712
8023
|
case Property::PointerEvents: style.pointer_events = static_cast<std::int8_t>(value); return true;
|
|
8024
|
+
#endif
|
|
8025
|
+
#if GEA_CSS_OVERFLOW_AXES
|
|
7713
8026
|
case Property::Overflow: {
|
|
7714
8027
|
const auto next = static_cast<std::int8_t>(value);
|
|
7715
8028
|
style.overflow = next;
|
|
@@ -7729,11 +8042,24 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7729
8042
|
style.overflow = aggregateOverflow(style.overflow_x, next);
|
|
7730
8043
|
return true;
|
|
7731
8044
|
}
|
|
8045
|
+
#else
|
|
8046
|
+
case Property::Overflow:
|
|
8047
|
+
case Property::OverflowX:
|
|
8048
|
+
case Property::OverflowY:
|
|
8049
|
+
style.overflow = static_cast<std::int8_t>(value); return true;
|
|
8050
|
+
#endif
|
|
8051
|
+
#if GEA_CSS_MASK
|
|
7732
8052
|
case Property::MaskRightFadeWidth:
|
|
7733
8053
|
style.mask_right_fade_width = static_cast<std::int16_t>(value < 0 ? 0 : value > 32767 ? 32767 : value);
|
|
7734
8054
|
return true;
|
|
8055
|
+
#endif
|
|
8056
|
+
#if GEA_UI_IMAGE_NODES
|
|
7735
8057
|
case Property::ImageId: target.image_id = value; return true;
|
|
8058
|
+
#endif
|
|
8059
|
+
#if GEA_CSS_IMAGE_FIT
|
|
7736
8060
|
case Property::ImageFit: style.image_fit = value; return true;
|
|
8061
|
+
#endif
|
|
8062
|
+
#if GEA_CSS_TRANSFORMS
|
|
7737
8063
|
case Property::TransformTranslateOuterAxes: rstyleMut(style).transform_translate_outer_axes = value; return true;
|
|
7738
8064
|
case Property::RotateAngle: rstyleMut(style).rotate_angle = value; return true;
|
|
7739
8065
|
case Property::RotateAxisX: rstyleMut(style).rotate_axis_x = value; return true;
|
|
@@ -7751,7 +8077,11 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7751
8077
|
case Property::TransformPresent: rstyleMut(style).transform_present = value != 0; return true;
|
|
7752
8078
|
case Property::RotatePresent: rstyleMut(style).rotate_present = value != 0; return true;
|
|
7753
8079
|
case Property::ScalePresent: rstyleMut(style).scale_present = value != 0; return true;
|
|
8080
|
+
#endif
|
|
8081
|
+
#if GEA_CSS_FILTERS
|
|
7754
8082
|
case Property::FilterPresent: rstyleMut(style).filter_present = value != 0; return true;
|
|
8083
|
+
#endif
|
|
8084
|
+
#if GEA_CSS_TRANSFORMS
|
|
7755
8085
|
case Property::TransformRotate: rstyleMut(style).transform_rotate = value; return true;
|
|
7756
8086
|
case Property::TransformRotateX: rstyleMut(style).transform_rotate_x = value; return true;
|
|
7757
8087
|
case Property::TransformRotateY: rstyleMut(style).transform_rotate_y = value; return true;
|
|
@@ -7768,20 +8098,37 @@ bool setClassRuleValueFastUnchecked(Node &target, Property property, int value)
|
|
|
7768
8098
|
case Property::Perspective: rstyleMut(style).perspective = value; return true;
|
|
7769
8099
|
case Property::PerspectiveOriginX: rstyleMut(style).perspective_origin_x = value; return true;
|
|
7770
8100
|
case Property::PerspectiveOriginY: rstyleMut(style).perspective_origin_y = value; return true;
|
|
8101
|
+
#endif
|
|
8102
|
+
#if GEA_CSS_FILTERS
|
|
7771
8103
|
case Property::FilterBlur: rstyleMut(style).filter_blur_radius = value; return true;
|
|
8104
|
+
#endif
|
|
8105
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7772
8106
|
case Property::BoxShadowInset:
|
|
7773
8107
|
rstyleMut(style).box_shadow_inset = value != 0 ? 1 : 0;
|
|
7774
8108
|
return true;
|
|
8109
|
+
#endif
|
|
8110
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7775
8111
|
case Property::BoxShadowOffsetX: rstyleMut(style).box_shadow_offset_x = value; return true;
|
|
8112
|
+
#endif
|
|
8113
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7776
8114
|
case Property::BoxShadowOffsetY: rstyleMut(style).box_shadow_offset_y = value; return true;
|
|
8115
|
+
#endif
|
|
8116
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7777
8117
|
case Property::BoxShadowBlur: rstyleMut(style).box_shadow_blur_radius = value; return true;
|
|
8118
|
+
#endif
|
|
8119
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7778
8120
|
case Property::BoxShadowSpread: rstyleMut(style).box_shadow_spread = value; return true;
|
|
8121
|
+
#endif
|
|
8122
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7779
8123
|
case Property::BoxShadowColor:
|
|
7780
8124
|
rstyleMut(style).box_shadow_color = StyleValues::pixelFromStyleValue(value);
|
|
7781
8125
|
return true;
|
|
8126
|
+
#endif
|
|
8127
|
+
#if GEA_CSS_BOX_SHADOW
|
|
7782
8128
|
case Property::BoxShadowAlpha:
|
|
7783
8129
|
rstyleMut(style).box_shadow_alpha = static_cast<std::uint8_t>(value < 0 ? 0 : value > 255 ? 255 : value);
|
|
7784
8130
|
return true;
|
|
8131
|
+
#endif
|
|
7785
8132
|
default:
|
|
7786
8133
|
return false;
|
|
7787
8134
|
}
|
|
@@ -7811,6 +8158,20 @@ void setStyleValue(NodeHandle node, Property property, int value, StyleApplicati
|
|
|
7811
8158
|
}
|
|
7812
8159
|
}
|
|
7813
8160
|
|
|
8161
|
+
void setLengthStyleValue(NodeHandle node, const CssLengthSpec &length, Property property, int value, StyleApplicationSource source)
|
|
8162
|
+
{
|
|
8163
|
+
setStyleValue(node, property, value, source);
|
|
8164
|
+
if (source == StyleApplicationSource::Inline && length.unit == CssLengthUnit::Px && std::isfinite(length.value))
|
|
8165
|
+
ensureRareData(node.id()).inlineStyles.setCssPixels(property, length.value);
|
|
8166
|
+
}
|
|
8167
|
+
|
|
8168
|
+
void setLengthStyleValue(NodeHandle node, const std::string &text, Property property, int value, StyleApplicationSource source)
|
|
8169
|
+
{
|
|
8170
|
+
CssLengthSpec length;
|
|
8171
|
+
if (parseCompiledLengthSpec(text, length)) setLengthStyleValue(node, length, property, value, source);
|
|
8172
|
+
else setStyleValue(node, property, value, source);
|
|
8173
|
+
}
|
|
8174
|
+
|
|
7814
8175
|
void setStyleValueKnownTarget(NodeHandle node,
|
|
7815
8176
|
Node &target,
|
|
7816
8177
|
Property property,
|
|
@@ -7851,7 +8212,7 @@ void setPositionOffsetValue(NodeHandle node,
|
|
|
7851
8212
|
return;
|
|
7852
8213
|
}
|
|
7853
8214
|
}
|
|
7854
|
-
|
|
8215
|
+
setLengthStyleValue(node, value, lengthProperty, parseLengthForNode(value, node.id(), axis), source);
|
|
7855
8216
|
}
|
|
7856
8217
|
|
|
7857
8218
|
int deferredLengthExpression(const CssLengthSpec &length)
|
|
@@ -7881,7 +8242,8 @@ void setFlexBasisValue(NodeHandle node, bool hasBasis, const CssLengthSpec &leng
|
|
|
7881
8242
|
const int expression = deferredLengthExpression(length);
|
|
7882
8243
|
if (expression >= 0) setStyleValue(node, Property::FlexBasisExpression, expression, source);
|
|
7883
8244
|
} else {
|
|
7884
|
-
|
|
8245
|
+
if (hasBasis) setLengthStyleValue(node, length, Property::FlexBasis, resolveCompiledLengthForNode(length, node.id(), LengthAxis::Horizontal), source);
|
|
8246
|
+
else setStyleValue(node, Property::FlexBasis, kUnset, source);
|
|
7885
8247
|
}
|
|
7886
8248
|
}
|
|
7887
8249
|
|
|
@@ -7889,7 +8251,7 @@ void setBoxLengthValue(NodeHandle node, bool padding, int side, const CssLengthS
|
|
|
7889
8251
|
{
|
|
7890
8252
|
const Property pixel = static_cast<Property>(static_cast<int>(padding ? Property::PaddingTop : Property::MarginTop) + side);
|
|
7891
8253
|
const int value = length.unit == CssLengthUnit::Auto ? 0 : resolveCompiledLengthForNode(length, node.id(), LengthAxis::Horizontal);
|
|
7892
|
-
|
|
8254
|
+
setLengthStyleValue(node, length, pixel, padding ? std::max(0, value) : value, source);
|
|
7893
8255
|
if (!padding)
|
|
7894
8256
|
setStyleValue(node, static_cast<Property>(static_cast<int>(Property::MarginTopAuto) + side), length.unit == CssLengthUnit::Auto, source);
|
|
7895
8257
|
// A var() can acquire a percentage or font-relative value later, even
|
|
@@ -7901,6 +8263,22 @@ void setBoxLengthValue(NodeHandle node, bool padding, int side, const CssLengthS
|
|
|
7901
8263
|
expression, source);
|
|
7902
8264
|
}
|
|
7903
8265
|
|
|
8266
|
+
void setGapLengthValues(NodeHandle node, CssDeclarationId declaration, const CssLengthSpec &row, const CssLengthSpec &column, StyleApplicationSource source)
|
|
8267
|
+
{
|
|
8268
|
+
if (declaration == CssDeclarationId::Gap)
|
|
8269
|
+
setLengthStyleValue(node, row, Property::Gap, row.unit == CssLengthUnit::Percent ? 0 : resolveCompiledLengthForNode(row, node.id(), LengthAxis::Vertical), source);
|
|
8270
|
+
for (int axis = 0; axis < 2; ++axis) {
|
|
8271
|
+
if (declaration == CssDeclarationId::RowGap && axis != 0) continue;
|
|
8272
|
+
if (declaration == CssDeclarationId::ColumnGap && axis != 1) continue;
|
|
8273
|
+
const auto &length = axis == 0 ? row : column;
|
|
8274
|
+
const bool percent = length.unit == CssLengthUnit::Percent;
|
|
8275
|
+
setLengthStyleValue(node, length, axis == 0 ? Property::RowGap : Property::ColumnGap,
|
|
8276
|
+
percent ? 0 : resolveCompiledLengthForNode(length, node.id(), axis == 0 ? LengthAxis::Vertical : LengthAxis::Horizontal), source);
|
|
8277
|
+
setStyleValue(node, axis == 0 ? Property::RowGapPercent : Property::ColumnGapPercent,
|
|
8278
|
+
percent ? roundToInt(length.value * 10.0) : kUnset, source);
|
|
8279
|
+
}
|
|
8280
|
+
}
|
|
8281
|
+
|
|
7904
8282
|
void setSizeValue(NodeHandle node,
|
|
7905
8283
|
Property lengthProperty,
|
|
7906
8284
|
Property percentProperty,
|
|
@@ -7940,7 +8318,7 @@ void setSizeValue(NodeHandle node,
|
|
|
7940
8318
|
if (parseSimplePercentPermille(value, percent))
|
|
7941
8319
|
setStyleValue(node, percentProperty, percent, source);
|
|
7942
8320
|
else
|
|
7943
|
-
|
|
8321
|
+
setLengthStyleValue(node, value, lengthProperty, parseLengthForNode(value, node.id(), axis), source);
|
|
7944
8322
|
}
|
|
7945
8323
|
|
|
7946
8324
|
void setAllPadding(NodeHandle node, int value, StyleApplicationSource source)
|
|
@@ -7978,9 +8356,11 @@ void setMarginBox(NodeHandle node, const BoxLengths &box, StyleApplicationSource
|
|
|
7978
8356
|
void setAllBorderRadius(NodeHandle node, int value, StyleApplicationSource source)
|
|
7979
8357
|
{
|
|
7980
8358
|
setStyleValue(node, Property::BorderRadiusTopLeft, value, source);
|
|
8359
|
+
#if GEA_CSS_CORNER_RADIUS
|
|
7981
8360
|
setStyleValue(node, Property::BorderRadiusTopRight, value, source);
|
|
7982
8361
|
setStyleValue(node, Property::BorderRadiusBottomRight, value, source);
|
|
7983
8362
|
setStyleValue(node, Property::BorderRadiusBottomLeft, value, source);
|
|
8363
|
+
#endif
|
|
7984
8364
|
}
|
|
7985
8365
|
|
|
7986
8366
|
Property borderRadiusLengthProperty(int corner)
|
|
@@ -8012,7 +8392,7 @@ void setBorderRadiusCornerValue(NodeHandle node,
|
|
|
8012
8392
|
if (parseSimplePercentPermille(value, percent))
|
|
8013
8393
|
setStyleValue(node, borderRadiusPercentProperty(corner), percent, source);
|
|
8014
8394
|
else
|
|
8015
|
-
|
|
8395
|
+
setLengthStyleValue(node, value, borderRadiusLengthProperty(corner), parseLengthForNode(value, node.id(), LengthAxis::None), source);
|
|
8016
8396
|
}
|
|
8017
8397
|
|
|
8018
8398
|
void applyBorderRadiusValue(NodeHandle node, const std::string &value, StyleApplicationSource source)
|
|
@@ -8022,13 +8402,15 @@ void applyBorderRadiusValue(NodeHandle node, const std::string &value, StyleAppl
|
|
|
8022
8402
|
const auto parts = splitWords(axes.empty() ? value : axes[0]);
|
|
8023
8403
|
if (parts.empty()) return;
|
|
8024
8404
|
const std::string &tl = parts[0];
|
|
8405
|
+
setBorderRadiusCornerValue(node, 0, tl, source);
|
|
8406
|
+
#if GEA_CSS_CORNER_RADIUS
|
|
8025
8407
|
const std::string &tr = parts.size() > 1 ? parts[1] : tl;
|
|
8026
8408
|
const std::string &br = parts.size() > 2 ? parts[2] : tl;
|
|
8027
8409
|
const std::string &bl = parts.size() > 3 ? parts[3] : tr;
|
|
8028
|
-
setBorderRadiusCornerValue(node, 0, tl, source);
|
|
8029
8410
|
setBorderRadiusCornerValue(node, 1, tr, source);
|
|
8030
8411
|
setBorderRadiusCornerValue(node, 2, br, source);
|
|
8031
8412
|
setBorderRadiusCornerValue(node, 3, bl, source);
|
|
8413
|
+
#endif
|
|
8032
8414
|
}
|
|
8033
8415
|
|
|
8034
8416
|
void setIndividualRotation(NodeHandle node, const IndividualRotation &r, bool present, StyleApplicationSource source)
|
|
@@ -8084,6 +8466,7 @@ void setTransformComponents(NodeHandle node, const TransformComponents &t, Style
|
|
|
8084
8466
|
|
|
8085
8467
|
bool applyTransformComponentsFast(NodeHandle node, const TransformComponents &t, StyleApplicationSource source)
|
|
8086
8468
|
{
|
|
8469
|
+
#if GEA_CSS_TRANSFORMS
|
|
8087
8470
|
setStyleValue(node, Property::TransformTranslateOuterAxes, t.translateOuterAxes, source);
|
|
8088
8471
|
setStyleValue(node, Property::TransformPresent, t.hasRotateX || t.hasRotateY || t.hasRotateZ || t.hasTranslateX || t.hasTranslateY || t.hasTranslateZ || t.hasScaleX || t.hasScaleY || t.hasScaleZ, source);
|
|
8089
8472
|
{
|
|
@@ -8135,16 +8518,27 @@ bool applyTransformComponentsFast(NodeHandle node, const TransformComponents &t,
|
|
|
8135
8518
|
if (!nodeParticipatesInMountedTree(state, nodeId)) return true;
|
|
8136
8519
|
target.render.dirty = 1;
|
|
8137
8520
|
if (state.fixedPositionUsed) target.render.layout_dirty = 1;
|
|
8521
|
+
#if GEA_CSS_SCROLLING
|
|
8138
8522
|
target.render.non_scroll_dirty = 1;
|
|
8523
|
+
#endif
|
|
8524
|
+
#if GEA_CSS_TRANSFORMS
|
|
8139
8525
|
target.render.transform_dirty = 1;
|
|
8526
|
+
#endif
|
|
8527
|
+
|
|
8528
|
+
#if GEA_CSS_TRANSFORMS
|
|
8140
8529
|
state.transformScanSerial = ~0ull;
|
|
8141
8530
|
state.transformScanValid = false;
|
|
8531
|
+
#endif
|
|
8142
8532
|
Tree::instance().markNodeDisplayCommandsDirty(nodeId);
|
|
8143
8533
|
return true;
|
|
8534
|
+
#else
|
|
8535
|
+
return false;
|
|
8536
|
+
#endif
|
|
8144
8537
|
}
|
|
8145
8538
|
|
|
8146
8539
|
bool applyTransformSlotsFast(NodeHandle node, const std::int16_t *slots, StyleApplicationSource source)
|
|
8147
8540
|
{
|
|
8541
|
+
#if GEA_CSS_TRANSFORMS
|
|
8148
8542
|
{
|
|
8149
8543
|
static const bool gTraceCube = std::getenv("GEA_DEBUG_CUBE") != nullptr;
|
|
8150
8544
|
if (gTraceCube)
|
|
@@ -8186,12 +8580,22 @@ bool applyTransformSlotsFast(NodeHandle node, const std::int16_t *slots, StyleAp
|
|
|
8186
8580
|
if (!nodeParticipatesInMountedTree(state, nodeId)) return true;
|
|
8187
8581
|
target.render.dirty = 1;
|
|
8188
8582
|
if (state.fixedPositionUsed) target.render.layout_dirty = 1;
|
|
8583
|
+
#if GEA_CSS_SCROLLING
|
|
8189
8584
|
target.render.non_scroll_dirty = 1;
|
|
8585
|
+
#endif
|
|
8586
|
+
#if GEA_CSS_TRANSFORMS
|
|
8190
8587
|
target.render.transform_dirty = 1;
|
|
8588
|
+
#endif
|
|
8589
|
+
|
|
8590
|
+
#if GEA_CSS_TRANSFORMS
|
|
8191
8591
|
state.transformScanSerial = ~0ull;
|
|
8192
8592
|
state.transformScanValid = false;
|
|
8593
|
+
#endif
|
|
8193
8594
|
Tree::instance().markNodeDisplayCommandsDirty(nodeId);
|
|
8194
8595
|
return true;
|
|
8596
|
+
#else
|
|
8597
|
+
return false;
|
|
8598
|
+
#endif
|
|
8195
8599
|
}
|
|
8196
8600
|
|
|
8197
8601
|
Property borderSideWidthProperty(int side);
|
|
@@ -8208,10 +8612,15 @@ bool applyBorderWidthBox(NodeHandle node, const CssCompiledValue &compiled, Styl
|
|
|
8208
8612
|
widths[side] = resolveBorderWidth(compiled.lengths[side], node.id());
|
|
8209
8613
|
if (widths[side] < 0) return true;
|
|
8210
8614
|
}
|
|
8211
|
-
|
|
8615
|
+
bool uniform = widths[0] == widths[1] && widths[0] == widths[2] && widths[0] == widths[3];
|
|
8616
|
+
if (source == StyleApplicationSource::Inline)
|
|
8617
|
+
for (int side = 1; side < 4; ++side)
|
|
8618
|
+
uniform = uniform && compiled.lengths[side].unit == compiled.lengths[0].unit && compiled.lengths[side].value == compiled.lengths[0].value;
|
|
8212
8619
|
setUniformBorderWidth(node, uniform ? widths[0] : 0, source);
|
|
8620
|
+
if (uniform && source == StyleApplicationSource::Inline && compiled.lengths[0].unit == CssLengthUnit::Px)
|
|
8621
|
+
ensureRareData(node.id()).inlineStyles.setCssPixels(Property::BorderWidth, compiled.lengths[0].value);
|
|
8213
8622
|
if (!uniform)
|
|
8214
|
-
for (int side = 0; side < 4; ++side)
|
|
8623
|
+
for (int side = 0; side < 4; ++side) setLengthStyleValue(node, compiled.lengths[side], borderSideWidthProperty(side), widths[side], source);
|
|
8215
8624
|
return true;
|
|
8216
8625
|
}
|
|
8217
8626
|
|
|
@@ -8222,7 +8631,7 @@ void applyBorderShorthand(NodeHandle node, const std::string &value, StyleApplic
|
|
|
8222
8631
|
const auto parts = splitFunctionAwareWords(value);
|
|
8223
8632
|
const int width = resolveBorderWidth(compiled.lengths[0], node.id());
|
|
8224
8633
|
if (width < 0) return;
|
|
8225
|
-
|
|
8634
|
+
setLengthStyleValue(node, compiled.lengths[0], Property::BorderWidth, width, source);
|
|
8226
8635
|
for (int side = 0; side < 4; ++side)
|
|
8227
8636
|
setStyleValue(node, static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side), compiled.values[2], source);
|
|
8228
8637
|
for (const auto &part : parts) {
|
|
@@ -8231,7 +8640,9 @@ void applyBorderShorthand(NodeHandle node, const std::string &value, StyleApplic
|
|
|
8231
8640
|
const ParsedCssColor color = parseCssColor(part);
|
|
8232
8641
|
setStyleValue(node, Property::BorderColor, color.valid ? cssColorStyleValue(color) : parseColorStyleValue(value), source);
|
|
8233
8642
|
if (color.valid) {
|
|
8643
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
8234
8644
|
setStyleValue(node, Property::BorderAlpha, color.a, source);
|
|
8645
|
+
#endif
|
|
8235
8646
|
markNodeDisplayCommandsDirtyForStyleApply(node.id());
|
|
8236
8647
|
}
|
|
8237
8648
|
return;
|
|
@@ -8291,7 +8702,7 @@ void applyBorderSideShorthand(NodeHandle node, int side, const std::string &valu
|
|
|
8291
8702
|
const auto parts = splitFunctionAwareWords(value);
|
|
8292
8703
|
const int width = resolveBorderWidth(compiled.lengths[0], node.id());
|
|
8293
8704
|
if (width < 0) return;
|
|
8294
|
-
|
|
8705
|
+
setLengthStyleValue(node, compiled.lengths[0], borderSideWidthProperty(side), width, source);
|
|
8295
8706
|
setStyleValue(node, static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side), compiled.values[2], source);
|
|
8296
8707
|
for (const auto &part : parts) {
|
|
8297
8708
|
if (part.empty()) continue;
|
|
@@ -8360,8 +8771,10 @@ void applyBackgroundSizeValue(NodeHandle node, const std::string &value)
|
|
|
8360
8771
|
if (parts.empty()) return;
|
|
8361
8772
|
const int stepX = parseLengthForNode(parts[0], node.id(), LengthAxis::Horizontal);
|
|
8362
8773
|
const int stepY = parseLengthForNode(parts.size() > 1 ? parts[1] : parts[0], node.id(), LengthAxis::Vertical);
|
|
8774
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
8363
8775
|
if (stepX > 0) rstyleMut(target.style).bg_grid_step_x = static_cast<uint16_t>(std::min(stepX, 65535));
|
|
8364
8776
|
if (stepY > 0) rstyleMut(target.style).bg_grid_step_y = static_cast<uint16_t>(std::min(stepY, 65535));
|
|
8777
|
+
#endif
|
|
8365
8778
|
markNodeDisplayCommandsDirtyForStyleApply(node.id());
|
|
8366
8779
|
}
|
|
8367
8780
|
|
|
@@ -8370,7 +8783,9 @@ void applyTextColorValue(NodeHandle node, const std::string &value, StyleApplica
|
|
|
8370
8783
|
if (!node) return;
|
|
8371
8784
|
const ParsedCssColor color = parseCssColor(firstColorToken(value));
|
|
8372
8785
|
setStyleValue(node, Property::Color, color.valid ? cssColorStyleValue(color) : parseColorStyleValue(value), source);
|
|
8786
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
8373
8787
|
setStyleValue(node, Property::ColorAlpha, color.valid ? color.a : 255, source);
|
|
8788
|
+
#endif
|
|
8374
8789
|
markNodeDisplayCommandsDirtyForStyleApply(node.id());
|
|
8375
8790
|
}
|
|
8376
8791
|
|
|
@@ -8383,13 +8798,16 @@ void applyBorderColorValue(NodeHandle node, const std::string &value, StyleAppli
|
|
|
8383
8798
|
}
|
|
8384
8799
|
const ParsedCssColor color = parseCssColor(firstColorToken(value));
|
|
8385
8800
|
setStyleValue(node, Property::BorderColor, color.valid ? cssColorStyleValue(color) : parseColorStyleValue(value), source);
|
|
8801
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
8386
8802
|
setStyleValue(node, Property::BorderAlpha, color.valid ? color.a : 255, source);
|
|
8803
|
+
#endif
|
|
8387
8804
|
markNodeDisplayCommandsDirtyForStyleApply(node.id());
|
|
8388
8805
|
}
|
|
8389
8806
|
|
|
8390
8807
|
int16_t *animatedTransformSlot(RareStyle &rs, Property property)
|
|
8391
8808
|
{
|
|
8392
8809
|
switch (property) {
|
|
8810
|
+
#if GEA_CSS_TRANSFORMS
|
|
8393
8811
|
case Property::RotateAngle: return &rs.rotate_angle;
|
|
8394
8812
|
case Property::ScaleX: return &rs.scale_x;
|
|
8395
8813
|
case Property::ScaleY: return &rs.scale_y;
|
|
@@ -8410,6 +8828,7 @@ int16_t *animatedTransformSlot(RareStyle &rs, Property property)
|
|
|
8410
8828
|
case Property::TransformScaleX: return &rs.transform_scale_x;
|
|
8411
8829
|
case Property::TransformScaleY: return &rs.transform_scale_y;
|
|
8412
8830
|
case Property::TransformScaleZ: return &rs.transform_scale_z;
|
|
8831
|
+
#endif
|
|
8413
8832
|
default: return nullptr;
|
|
8414
8833
|
}
|
|
8415
8834
|
}
|
|
@@ -8429,10 +8848,17 @@ bool applyAnimatedTransformStyleValueFast(int nodeId, Property property, int val
|
|
|
8429
8848
|
if (!nodeParticipatesInMountedTree(state, nodeId)) return true;
|
|
8430
8849
|
target.render.dirty = 1;
|
|
8431
8850
|
if (state.fixedPositionUsed) target.render.layout_dirty = 1;
|
|
8851
|
+
#if GEA_CSS_SCROLLING
|
|
8432
8852
|
target.render.non_scroll_dirty = 1;
|
|
8853
|
+
#endif
|
|
8854
|
+
#if GEA_CSS_TRANSFORMS
|
|
8433
8855
|
target.render.transform_dirty = 1;
|
|
8856
|
+
#endif
|
|
8857
|
+
|
|
8858
|
+
#if GEA_CSS_TRANSFORMS
|
|
8434
8859
|
state.transformScanSerial = ~0ull;
|
|
8435
8860
|
state.transformScanValid = false;
|
|
8861
|
+
#endif
|
|
8436
8862
|
Tree::instance().markNodeDisplayCommandsDirty(nodeId);
|
|
8437
8863
|
return true;
|
|
8438
8864
|
}
|
|
@@ -8479,6 +8905,7 @@ int resolveLayoutFlexBasis(int nodeId, int percentageBasis, bool horizontal)
|
|
|
8479
8905
|
|
|
8480
8906
|
bool resolveLayoutBoxLengths(int nodeId, int percentageBasis)
|
|
8481
8907
|
{
|
|
8908
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
8482
8909
|
auto &node = treeState().nodes[nodeId];
|
|
8483
8910
|
#if !GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
8484
8911
|
if (node.style.rare_style < 0) return false;
|
|
@@ -8493,12 +8920,22 @@ bool resolveLayoutBoxLengths(int nodeId, int percentageBasis)
|
|
|
8493
8920
|
if (expression < 0) continue;
|
|
8494
8921
|
const int raw = resolveLayoutSizeExpression(nodeId, expression, true);
|
|
8495
8922
|
const int value = std::max(padding ? 0 : -32768, std::min(32767, raw));
|
|
8496
|
-
|
|
8497
|
-
|
|
8923
|
+
// Padding can have a proven unsigned byte range while margin remains
|
|
8924
|
+
// signed. Keep writes typed; the existing side choice already branches.
|
|
8925
|
+
if (padding) {
|
|
8926
|
+
if (node.style.padding[side] != value) { node.style.padding[side] = value; changed = true; }
|
|
8927
|
+
} else if (node.style.margin[side] != value) {
|
|
8928
|
+
node.style.margin[side] = static_cast<int16_t>(value); changed = true;
|
|
8929
|
+
}
|
|
8498
8930
|
}
|
|
8499
8931
|
}
|
|
8500
8932
|
g_boxPercentageBasis = previous;
|
|
8501
8933
|
return changed;
|
|
8934
|
+
#else
|
|
8935
|
+
(void)nodeId;
|
|
8936
|
+
(void)percentageBasis;
|
|
8937
|
+
return false;
|
|
8938
|
+
#endif
|
|
8502
8939
|
}
|
|
8503
8940
|
|
|
8504
8941
|
|
|
@@ -8563,7 +9000,9 @@ void applyInheritedStyleDefaults(int node)
|
|
|
8563
9000
|
const auto &parentStyle = state.nodes[parent].style;
|
|
8564
9001
|
auto &style = state.nodes[node].style;
|
|
8565
9002
|
style.text_color = parentStyle.text_color;
|
|
9003
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
8566
9004
|
style.text_alpha = parentStyle.text_alpha;
|
|
9005
|
+
#endif
|
|
8567
9006
|
style.font_id = parentStyle.font_id;
|
|
8568
9007
|
style.font_size = parentStyle.font_size;
|
|
8569
9008
|
style.font_weight = parentStyle.font_weight;
|
|
@@ -8571,9 +9010,13 @@ void applyInheritedStyleDefaults(int node)
|
|
|
8571
9010
|
if (parentStyle.line_height_multiplier >= 0)
|
|
8572
9011
|
style.line_height_multiplier = parentStyle.line_height_multiplier;
|
|
8573
9012
|
style.text_align = parentStyle.text_align;
|
|
9013
|
+
#if GEA_CSS_TEXT_TRANSFORM
|
|
8574
9014
|
style.text_transform = parentStyle.text_transform;
|
|
9015
|
+
#endif
|
|
8575
9016
|
style.white_space = parentStyle.white_space;
|
|
9017
|
+
#if GEA_CSS_VISIBILITY
|
|
8576
9018
|
style.visibility = parentStyle.visibility;
|
|
9019
|
+
#endif
|
|
8577
9020
|
}
|
|
8578
9021
|
|
|
8579
9022
|
bool applyNumberDeclarationWithSource(NodeHandle node,
|
|
@@ -8705,6 +9148,7 @@ bool applyNumberDeclarationWithSource(NodeHandle node,
|
|
|
8705
9148
|
setStyleValue(node, Property::LineHeightMultiplier, bits, source);
|
|
8706
9149
|
return true;
|
|
8707
9150
|
}
|
|
9151
|
+
#if GEA_CSS_TRANSFORMS
|
|
8708
9152
|
case CssDeclarationId::Transform:
|
|
8709
9153
|
setStyleValue(node, Property::TransformPresent, 1, source);
|
|
8710
9154
|
setStyleValue(node, Property::TransformRotate, numericRotateTenths(value), source);
|
|
@@ -8718,6 +9162,7 @@ bool applyNumberDeclarationWithSource(NodeHandle node,
|
|
|
8718
9162
|
const int scale[3] = {factor, factor, 1000};
|
|
8719
9163
|
setIndividualScale(node, scale, true, source); return true;
|
|
8720
9164
|
}
|
|
9165
|
+
#endif
|
|
8721
9166
|
default:
|
|
8722
9167
|
return false;
|
|
8723
9168
|
}
|
|
@@ -8757,6 +9202,42 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8757
9202
|
}
|
|
8758
9203
|
|
|
8759
9204
|
switch (declaration) {
|
|
9205
|
+
#if !GEA_CSS_GRID
|
|
9206
|
+
case CssDeclarationId::GridRowStart:
|
|
9207
|
+
case CssDeclarationId::GridColumnStart:
|
|
9208
|
+
case CssDeclarationId::GridRowEnd:
|
|
9209
|
+
case CssDeclarationId::GridColumnEnd:
|
|
9210
|
+
case CssDeclarationId::GridRow:
|
|
9211
|
+
case CssDeclarationId::GridColumn:
|
|
9212
|
+
case CssDeclarationId::GridArea:
|
|
9213
|
+
case CssDeclarationId::Grid:
|
|
9214
|
+
case CssDeclarationId::GridTemplate:
|
|
9215
|
+
case CssDeclarationId::GridTemplateColumns:
|
|
9216
|
+
case CssDeclarationId::GridTemplateRows:
|
|
9217
|
+
return false;
|
|
9218
|
+
#endif
|
|
9219
|
+
#if !GEA_CSS_TRANSFORMS
|
|
9220
|
+
case CssDeclarationId::TransformStyle:
|
|
9221
|
+
case CssDeclarationId::Translate:
|
|
9222
|
+
case CssDeclarationId::Transform:
|
|
9223
|
+
case CssDeclarationId::Rotate:
|
|
9224
|
+
case CssDeclarationId::Scale:
|
|
9225
|
+
case CssDeclarationId::TransformOrigin:
|
|
9226
|
+
case CssDeclarationId::Perspective:
|
|
9227
|
+
case CssDeclarationId::PerspectiveOrigin:
|
|
9228
|
+
return false;
|
|
9229
|
+
#endif
|
|
9230
|
+
#if !GEA_CSS_FLOATS
|
|
9231
|
+
case CssDeclarationId::Float:
|
|
9232
|
+
case CssDeclarationId::Clear:
|
|
9233
|
+
return false;
|
|
9234
|
+
#endif
|
|
9235
|
+
#if !GEA_CSS_WRITING_MODE
|
|
9236
|
+
case CssDeclarationId::Direction:
|
|
9237
|
+
case CssDeclarationId::WritingMode:
|
|
9238
|
+
return false;
|
|
9239
|
+
#endif
|
|
9240
|
+
|
|
8760
9241
|
case CssDeclarationId::BackgroundClip: {
|
|
8761
9242
|
const int parent = Tree::instance().node(nodeId).parent;
|
|
8762
9243
|
const int clip = toLowerAscii(trimCssValue(value)) == "inherit"
|
|
@@ -8768,7 +9249,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8768
9249
|
case CssDeclarationId::Contain: {
|
|
8769
9250
|
const int parent = Tree::instance().node(nodeId).parent;
|
|
8770
9251
|
const int flags = toLowerAscii(trimCssValue(value)) == "inherit"
|
|
8771
|
-
? (parent >= 0 ? rstyle(Tree::instance().node(parent).style).containment : 0)
|
|
9252
|
+
? (parent >= 0 ? (GEA_CSS_CONTAINMENT ? rstyle(Tree::instance().node(parent).style).containment : 0) : 0)
|
|
8772
9253
|
: containmentValue(value);
|
|
8773
9254
|
if (flags >= 0) setStyleValue(node, Property::Containment, flags, source);
|
|
8774
9255
|
return true;
|
|
@@ -8782,7 +9263,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8782
9263
|
}
|
|
8783
9264
|
if (ratio == "inherit") {
|
|
8784
9265
|
const int parent = Tree::instance().node(nodeId).parent;
|
|
8785
|
-
setStyleValue(node, Property::AspectRatio, parent >= 0 ? rstyle(Tree::instance().node(parent).style).aspect_ratio : 0, source);
|
|
9266
|
+
setStyleValue(node, Property::AspectRatio, parent >= 0 ? (GEA_CSS_ASPECT_RATIO ? rstyle(Tree::instance().node(parent).style).aspect_ratio : 0) : 0, source);
|
|
8786
9267
|
return true;
|
|
8787
9268
|
}
|
|
8788
9269
|
const auto words = splitFunctionAwareWords(ratio);
|
|
@@ -8823,25 +9304,30 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8823
9304
|
if (value == "content-box") setStyleValue(node, Property::BoxSizing, 0, source);
|
|
8824
9305
|
if (value == "border-box") setStyleValue(node, Property::BoxSizing, 1, source);
|
|
8825
9306
|
return true;
|
|
9307
|
+
#if GEA_CSS_FLOATS
|
|
8826
9308
|
case CssDeclarationId::Float:
|
|
8827
9309
|
if (value == "none") setStyleValue(node, Property::Float, 0, source);
|
|
8828
9310
|
if (value == "left") setStyleValue(node, Property::Float, 1, source);
|
|
8829
9311
|
if (value == "right") setStyleValue(node, Property::Float, 2, source);
|
|
8830
9312
|
return true;
|
|
9313
|
+
#endif
|
|
8831
9314
|
case CssDeclarationId::MarginTrim: {
|
|
8832
9315
|
const int parent = Tree::instance().node(nodeId).parent;
|
|
8833
9316
|
const int flags = toLowerAscii(trimCssValue(value)) == "inherit"
|
|
8834
|
-
? (parent >= 0 ? rstyle(Tree::instance().node(parent).style).margin_trim : 0)
|
|
9317
|
+
? (parent >= 0 ? (GEA_CSS_MARGIN_TRIM ? rstyle(Tree::instance().node(parent).style).margin_trim : 0) : 0)
|
|
8835
9318
|
: marginTrimValue(value);
|
|
8836
9319
|
if (flags >= 0) setStyleValue(node, Property::MarginTrim, flags, source);
|
|
8837
9320
|
return true;
|
|
8838
9321
|
}
|
|
9322
|
+
#if GEA_CSS_FLOATS
|
|
8839
9323
|
case CssDeclarationId::Clear:
|
|
8840
9324
|
if (value == "none") setStyleValue(node, Property::Clear, 0, source);
|
|
8841
9325
|
if (value == "left") setStyleValue(node, Property::Clear, 1, source);
|
|
8842
9326
|
if (value == "right") setStyleValue(node, Property::Clear, 2, source);
|
|
8843
9327
|
if (value == "both") setStyleValue(node, Property::Clear, 3, source);
|
|
8844
9328
|
return true;
|
|
9329
|
+
#endif
|
|
9330
|
+
#if GEA_CSS_WRITING_MODE
|
|
8845
9331
|
case CssDeclarationId::Direction:
|
|
8846
9332
|
if (value == "ltr" || value == "initial") setStyleValue(node, Property::Direction, 0, source);
|
|
8847
9333
|
if (value == "rtl") setStyleValue(node, Property::Direction, 1, source);
|
|
@@ -8855,6 +9341,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8855
9341
|
if (value == "sideways-lr") setStyleValue(node, Property::WritingMode, 4, source);
|
|
8856
9342
|
if (value == "inherit") setStyleValue(node, Property::WritingMode, -1, source);
|
|
8857
9343
|
return true;
|
|
9344
|
+
#endif
|
|
8858
9345
|
case CssDeclarationId::FlexFlow: {
|
|
8859
9346
|
int direction = 1;
|
|
8860
9347
|
bool hasDirection = false;
|
|
@@ -8886,18 +9373,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8886
9373
|
else if (!parseCompiledLengthSpec(parts[i], specs[i]) || specs[i].value < 0) return true;
|
|
8887
9374
|
}
|
|
8888
9375
|
if (parts.size() == 1) specs[1] = specs[0];
|
|
8889
|
-
|
|
8890
|
-
setStyleValue(node, Property::Gap, specs[0].unit == CssLengthUnit::Percent ? 0 : resolveCompiledLengthForNode(specs[0], nodeId, LengthAxis::Vertical), source);
|
|
8891
|
-
for (int axis = 0; axis < 2; ++axis) {
|
|
8892
|
-
if (declaration == CssDeclarationId::RowGap && axis != 0) continue;
|
|
8893
|
-
if (declaration == CssDeclarationId::ColumnGap && axis != 1) continue;
|
|
8894
|
-
const auto &spec = specs[declaration == CssDeclarationId::Gap ? axis : 0];
|
|
8895
|
-
const bool percent = spec.unit == CssLengthUnit::Percent;
|
|
8896
|
-
setStyleValue(node, axis == 0 ? Property::RowGap : Property::ColumnGap,
|
|
8897
|
-
percent ? 0 : resolveCompiledLengthForNode(spec, nodeId, axis == 0 ? LengthAxis::Vertical : LengthAxis::Horizontal), source);
|
|
8898
|
-
setStyleValue(node, axis == 0 ? Property::RowGapPercent : Property::ColumnGapPercent,
|
|
8899
|
-
percent ? roundToInt(spec.value * 10.0) : kUnset, source);
|
|
8900
|
-
}
|
|
9376
|
+
setGapLengthValues(node, declaration, specs[0], specs[1], source);
|
|
8901
9377
|
return true;
|
|
8902
9378
|
}
|
|
8903
9379
|
case CssDeclarationId::Order: {
|
|
@@ -8922,7 +9398,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8922
9398
|
if (value == "initial" || value == "unset") setStyleValue(node, Property::FlexLineCount, 1, source);
|
|
8923
9399
|
else if (value == "inherit") {
|
|
8924
9400
|
const int parent = Tree::instance().node(nodeId).parent;
|
|
8925
|
-
setStyleValue(node, Property::FlexLineCount, parent >= 0 ? rstyle(Tree::instance().node(parent).style).flex_line_count : 1, source);
|
|
9401
|
+
setStyleValue(node, Property::FlexLineCount, parent >= 0 ? (GEA_CSS_FLEX_LINE_COUNT ? rstyle(Tree::instance().node(parent).style).flex_line_count : 1) : 1, source);
|
|
8926
9402
|
} else if (parseOrder(value, count) && count >= 1) setStyleValue(node, Property::FlexLineCount, count, source);
|
|
8927
9403
|
return true;
|
|
8928
9404
|
}
|
|
@@ -8963,13 +9439,14 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
8963
9439
|
} else {
|
|
8964
9440
|
const auto &inherited = Tree::instance().node(parent).style;
|
|
8965
9441
|
align = declaration == CssDeclarationId::PlaceItems ? inherited.align_items : declaration == CssDeclarationId::PlaceContent ? inherited.align_content : inherited.align_self;
|
|
8966
|
-
justify = declaration == CssDeclarationId::PlaceItems ? inherited.justify_items : declaration == CssDeclarationId::PlaceContent ? inherited.justify_content : rstyle(inherited).justify_self;
|
|
9442
|
+
justify = declaration == CssDeclarationId::PlaceItems ? inherited.justify_items : declaration == CssDeclarationId::PlaceContent ? inherited.justify_content : (GEA_CSS_JUSTIFY_SELF ? rstyle(inherited).justify_self : -1);
|
|
8967
9443
|
}
|
|
8968
9444
|
} else if (!parseAlignmentShorthand(declaration, value, align, justify)) return true;
|
|
8969
9445
|
setStyleValue(node, alignProperty, align, source);
|
|
8970
9446
|
setStyleValue(node, justifyProperty, justify, source);
|
|
8971
9447
|
return true;
|
|
8972
9448
|
}
|
|
9449
|
+
#if GEA_CSS_GRID
|
|
8973
9450
|
case CssDeclarationId::GridRowStart:
|
|
8974
9451
|
case CssDeclarationId::GridColumnStart:
|
|
8975
9452
|
case CssDeclarationId::GridRowEnd:
|
|
@@ -9010,6 +9487,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9010
9487
|
case CssDeclarationId::GridTemplateRows:
|
|
9011
9488
|
applyGridTemplateValue(node, value, false);
|
|
9012
9489
|
return true;
|
|
9490
|
+
#endif
|
|
9013
9491
|
case CssDeclarationId::Ignored:
|
|
9014
9492
|
case CssDeclarationId::Content:
|
|
9015
9493
|
case CssDeclarationId::Animation:
|
|
@@ -9021,16 +9499,16 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9021
9499
|
setSizeValue(node, Property::Height, Property::HeightPercent, value, LengthAxis::Vertical, source);
|
|
9022
9500
|
return true;
|
|
9023
9501
|
case CssDeclarationId::MinWidth:
|
|
9024
|
-
|
|
9502
|
+
setLengthStyleValue(node, value, Property::MinWidth, parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
|
|
9025
9503
|
return true;
|
|
9026
9504
|
case CssDeclarationId::MinHeight:
|
|
9027
|
-
|
|
9505
|
+
setLengthStyleValue(node, value, Property::MinHeight, parseLengthForNode(value, nodeId, LengthAxis::Vertical), source);
|
|
9028
9506
|
return true;
|
|
9029
9507
|
case CssDeclarationId::MaxWidth:
|
|
9030
|
-
|
|
9508
|
+
setLengthStyleValue(node, value, Property::MaxWidth, value == "none" ? kUnset : parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
|
|
9031
9509
|
return true;
|
|
9032
9510
|
case CssDeclarationId::MaxHeight:
|
|
9033
|
-
|
|
9511
|
+
setLengthStyleValue(node, value, Property::MaxHeight, value == "none" ? kUnset : parseLengthForNode(value, nodeId, LengthAxis::Vertical), source);
|
|
9034
9512
|
return true;
|
|
9035
9513
|
case CssDeclarationId::Flex: {
|
|
9036
9514
|
CssCompiledValue compiled;
|
|
@@ -9164,16 +9642,16 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9164
9642
|
applyBorderSideShorthand(node, 3, value, source);
|
|
9165
9643
|
return true;
|
|
9166
9644
|
case CssDeclarationId::BorderTopWidth:
|
|
9167
|
-
if (const int width = parseBorderWidth(value, nodeId); width >= 0)
|
|
9645
|
+
if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderTopWidth, width, source);
|
|
9168
9646
|
return true;
|
|
9169
9647
|
case CssDeclarationId::BorderRightWidth:
|
|
9170
|
-
if (const int width = parseBorderWidth(value, nodeId); width >= 0)
|
|
9648
|
+
if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderRightWidth, width, source);
|
|
9171
9649
|
return true;
|
|
9172
9650
|
case CssDeclarationId::BorderBottomWidth:
|
|
9173
|
-
if (const int width = parseBorderWidth(value, nodeId); width >= 0)
|
|
9651
|
+
if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderBottomWidth, width, source);
|
|
9174
9652
|
return true;
|
|
9175
9653
|
case CssDeclarationId::BorderLeftWidth:
|
|
9176
|
-
if (const int width = parseBorderWidth(value, nodeId); width >= 0)
|
|
9654
|
+
if (const int width = parseBorderWidth(value, nodeId); width >= 0) setLengthStyleValue(node, value, Property::BorderLeftWidth, width, source);
|
|
9177
9655
|
return true;
|
|
9178
9656
|
case CssDeclarationId::BorderTopColor:
|
|
9179
9657
|
applyBorderSideColorValue(node, 0, value, source);
|
|
@@ -9211,12 +9689,12 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9211
9689
|
if (!parseFontShorthand(value, font)) return true;
|
|
9212
9690
|
setStyleValue(node, Property::FontWeight, font.weight, source);
|
|
9213
9691
|
setStyleValue(node, Property::FontId, fontFamilyValue(font.family), source);
|
|
9214
|
-
|
|
9692
|
+
setLengthStyleValue(node, font.size, Property::FontSize, fontSizeValue(font.size, nodeId), source);
|
|
9215
9693
|
setAuthoredLineHeightValue(node, font.lineHeight, source);
|
|
9216
9694
|
return true;
|
|
9217
9695
|
}
|
|
9218
9696
|
case CssDeclarationId::FontSize:
|
|
9219
|
-
|
|
9697
|
+
setLengthStyleValue(node, value, Property::FontSize, fontSizeValue(value, nodeId), source);
|
|
9220
9698
|
return true;
|
|
9221
9699
|
case CssDeclarationId::FontWeight:
|
|
9222
9700
|
setStyleValue(node, Property::FontWeight, fontWeightValue(value), source);
|
|
@@ -9239,12 +9717,14 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9239
9717
|
case CssDeclarationId::TextOverflow:
|
|
9240
9718
|
setStyleValue(node, Property::TextOverflow, textOverflowValue(value), source);
|
|
9241
9719
|
return true;
|
|
9720
|
+
#if GEA_CSS_TRANSFORMS
|
|
9242
9721
|
case CssDeclarationId::TransformStyle: {
|
|
9243
9722
|
const auto lower = toLowerAscii(trimCssValue(value));
|
|
9244
9723
|
if (lower == "flat" || lower == "preserve-3d" || lower == "initial" || lower == "unset")
|
|
9245
9724
|
setStyleValue(node, Property::TransformStyle, lower == "preserve-3d", source);
|
|
9246
9725
|
return true;
|
|
9247
9726
|
}
|
|
9727
|
+
#endif
|
|
9248
9728
|
case CssDeclarationId::Visibility: {
|
|
9249
9729
|
const int visibility = visibilityValue(value);
|
|
9250
9730
|
if (visibility >= 0) setStyleValue(node, Property::Visibility, visibility, source);
|
|
@@ -9275,6 +9755,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9275
9755
|
case CssDeclarationId::MaskImage:
|
|
9276
9756
|
setStyleValue(node, Property::MaskRightFadeWidth, parseRightFadeMaskWidth(value, nodeId), source);
|
|
9277
9757
|
return true;
|
|
9758
|
+
#if GEA_CSS_TRANSFORMS
|
|
9278
9759
|
case CssDeclarationId::Translate: {
|
|
9279
9760
|
std::string function;
|
|
9280
9761
|
if (individualTranslateFunction(value, function)) setIndividualTranslation(node, parseTransformComponents(function, nodeId), source);
|
|
@@ -9295,6 +9776,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9295
9776
|
setIndividualScale(node, scale, toLowerAscii(trimCssValue(value)) != "none", source);
|
|
9296
9777
|
return true;
|
|
9297
9778
|
}
|
|
9779
|
+
#endif
|
|
9298
9780
|
case CssDeclarationId::Filter:
|
|
9299
9781
|
setStyleValue(node, Property::FilterPresent, toLowerAscii(value).find("blur(") != std::string::npos, source);
|
|
9300
9782
|
setStyleValue(node, Property::FilterBlur, parseFilterBlurRadius(value, nodeId), source);
|
|
@@ -9302,6 +9784,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9302
9784
|
case CssDeclarationId::BoxShadow:
|
|
9303
9785
|
applyBoxShadowValue(node, value, source);
|
|
9304
9786
|
return true;
|
|
9787
|
+
#if GEA_CSS_TRANSFORMS
|
|
9305
9788
|
case CssDeclarationId::TransformOrigin: {
|
|
9306
9789
|
const auto parts = splitWords(value);
|
|
9307
9790
|
setStyleValue(node, Property::TransformOriginX, parseOriginPart(parts.empty() ? "" : parts[0], 500), source);
|
|
@@ -9309,7 +9792,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9309
9792
|
return true;
|
|
9310
9793
|
}
|
|
9311
9794
|
case CssDeclarationId::Perspective:
|
|
9312
|
-
|
|
9795
|
+
setLengthStyleValue(node, value, Property::Perspective, parseLengthForNode(value, nodeId, LengthAxis::Horizontal), source);
|
|
9313
9796
|
return true;
|
|
9314
9797
|
case CssDeclarationId::PerspectiveOrigin: {
|
|
9315
9798
|
const auto parts = splitWords(value);
|
|
@@ -9317,6 +9800,7 @@ bool applyKnownResolvedPropertyWithSource(NodeHandle node, CssDeclarationId decl
|
|
|
9317
9800
|
setStyleValue(node, Property::PerspectiveOriginY, parseOriginPart(parts.size() < 2 ? "" : parts[1], 500), source);
|
|
9318
9801
|
return true;
|
|
9319
9802
|
}
|
|
9803
|
+
#endif
|
|
9320
9804
|
case CssDeclarationId::Unknown:
|
|
9321
9805
|
case CssDeclarationId::Custom:
|
|
9322
9806
|
return false;
|
|
@@ -9369,7 +9853,7 @@ void setCompiledSizeValue(NodeHandle node,
|
|
|
9369
9853
|
if (resolved.isPercent)
|
|
9370
9854
|
setStyleValue(node, percentProperty, roundToInt(resolved.value), source);
|
|
9371
9855
|
else
|
|
9372
|
-
|
|
9856
|
+
setLengthStyleValue(node, length, lengthProperty, roundToInt(resolved.value), source);
|
|
9373
9857
|
}
|
|
9374
9858
|
|
|
9375
9859
|
void setCompiledPositionOffsetValue(NodeHandle node,
|
|
@@ -9383,7 +9867,7 @@ void setCompiledPositionOffsetValue(NodeHandle node,
|
|
|
9383
9867
|
if (resolved.isPercent)
|
|
9384
9868
|
setStyleValue(node, percentProperty, roundToInt(resolved.value), source);
|
|
9385
9869
|
else
|
|
9386
|
-
|
|
9870
|
+
setLengthStyleValue(node, length, lengthProperty, roundToInt(resolved.value), source);
|
|
9387
9871
|
}
|
|
9388
9872
|
|
|
9389
9873
|
void setCompiledBorderRadiusCornerValue(NodeHandle node,
|
|
@@ -9395,7 +9879,7 @@ void setCompiledBorderRadiusCornerValue(NodeHandle node,
|
|
|
9395
9879
|
if (resolved.isPercent)
|
|
9396
9880
|
setStyleValue(node, borderRadiusPercentProperty(corner), roundToInt(resolved.value), source);
|
|
9397
9881
|
else
|
|
9398
|
-
|
|
9882
|
+
setLengthStyleValue(node, length, borderRadiusLengthProperty(corner), roundToInt(resolved.value), source);
|
|
9399
9883
|
}
|
|
9400
9884
|
|
|
9401
9885
|
void resolveCompiledTranslate(const CssLengthSpec &length,
|
|
@@ -9421,9 +9905,9 @@ TransformComponents transformFromCompiled(const CssCompiledValue &compiled, int
|
|
|
9421
9905
|
t.rotateX = compiled.values[0];
|
|
9422
9906
|
t.rotateY = compiled.values[1];
|
|
9423
9907
|
t.rotateZ = compiled.values[2];
|
|
9424
|
-
t.scaleX = compiled.values[
|
|
9425
|
-
t.scaleY = compiled.values[
|
|
9426
|
-
t.scaleZ = compiled.values[
|
|
9908
|
+
t.scaleX = compiled.values[3];
|
|
9909
|
+
t.scaleY = compiled.values[4];
|
|
9910
|
+
t.scaleZ = compiled.values[5];
|
|
9427
9911
|
t.hasRotateX = (compiled.flags & (1u << 0)) != 0;
|
|
9428
9912
|
t.hasRotateY = (compiled.flags & (1u << 1)) != 0;
|
|
9429
9913
|
t.hasRotateZ = (compiled.flags & (1u << 2)) != 0;
|
|
@@ -9459,7 +9943,9 @@ bool applyCompiledColorValue(NodeHandle node,
|
|
|
9459
9943
|
target.style.text_alpha == static_cast<std::uint8_t>(alpha))
|
|
9460
9944
|
return true;
|
|
9461
9945
|
setStyleValueKnownTarget(node, target, Property::Color, styleColor, source);
|
|
9946
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
9462
9947
|
setStyleValueKnownTarget(node, target, Property::ColorAlpha, alpha, source);
|
|
9948
|
+
#endif
|
|
9463
9949
|
markNodeDisplayCommandsDirtyForStyleApply(nodeId);
|
|
9464
9950
|
return true;
|
|
9465
9951
|
case CssDeclarationId::ActiveBackgroundColor:
|
|
@@ -9480,11 +9966,13 @@ bool applyCompiledColorValue(NodeHandle node,
|
|
|
9480
9966
|
markNodeDisplayCommandsDirtyForStyleApply(nodeId);
|
|
9481
9967
|
return true;
|
|
9482
9968
|
case CssDeclarationId::BorderColor:
|
|
9483
|
-
if (source == StyleApplicationSource::ClassRule &&
|
|
9969
|
+
if (source == StyleApplicationSource::ClassRule && target.style.border_color_flags == 16u && target.style.border_color == static_cast<style_color_t>(nativeColor) &&
|
|
9484
9970
|
target.style.border_alpha == static_cast<std::uint8_t>(alpha))
|
|
9485
9971
|
return true;
|
|
9486
9972
|
setStyleValueKnownTarget(node, target, Property::BorderColor, styleColor, source);
|
|
9973
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
9487
9974
|
setStyleValue(node, Property::BorderAlpha, alpha, source);
|
|
9975
|
+
#endif
|
|
9488
9976
|
markNodeDisplayCommandsDirtyForStyleApply(nodeId);
|
|
9489
9977
|
return true;
|
|
9490
9978
|
case CssDeclarationId::BorderTopColor:
|
|
@@ -9495,7 +9983,7 @@ bool applyCompiledColorValue(NodeHandle node,
|
|
|
9495
9983
|
declaration == CssDeclarationId::BorderRightColor ? 1 :
|
|
9496
9984
|
declaration == CssDeclarationId::BorderBottomColor ? 2 : 3;
|
|
9497
9985
|
const RareStyle ¤t = rstyle(target.style);
|
|
9498
|
-
if (source == StyleApplicationSource::ClassRule && (
|
|
9986
|
+
if (source == StyleApplicationSource::ClassRule && (target.style.border_color_flags & (1u << side)) && !borderColorIsCurrent(target.style, side) && current.border_side_color[side] == static_cast<style_color_t>(nativeColor) &&
|
|
9499
9987
|
current.border_side_alpha[side] == static_cast<std::uint8_t>(alpha))
|
|
9500
9988
|
return true;
|
|
9501
9989
|
setStyleValueKnownTarget(node, target, borderSideColorProperty(side), styleColor, source);
|
|
@@ -9535,7 +10023,7 @@ bool resolveCompiledColorRef(int nodeId,
|
|
|
9535
10023
|
out.alpha = entry->colorAlpha;
|
|
9536
10024
|
return true;
|
|
9537
10025
|
}
|
|
9538
|
-
const CachedCssColor color = cachedCssColorForValue(entry->value);
|
|
10026
|
+
const CachedCssColor color = cachedCssColorForValue(*entry->value);
|
|
9539
10027
|
if (!color.valid) return false;
|
|
9540
10028
|
out.styleColor = color.styleColor;
|
|
9541
10029
|
out.nativeColor = static_cast<style_color_t>(color.nativeColor);
|
|
@@ -9624,6 +10112,7 @@ bool resolveCompiledRadialGradientColors(const CssCompiledRadialGradient &input,
|
|
|
9624
10112
|
|
|
9625
10113
|
void applyCompiledLinearGradient(RareStyle &rs, const CssCompiledLinearGradient &gradient)
|
|
9626
10114
|
{
|
|
10115
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9627
10116
|
rs.bg_gradient_from_color = gradient.fromNativeColor;
|
|
9628
10117
|
rs.bg_gradient_mid_color = gradient.midNativeColor;
|
|
9629
10118
|
rs.bg_gradient_to_color = gradient.toNativeColor;
|
|
@@ -9634,10 +10123,12 @@ void applyCompiledLinearGradient(RareStyle &rs, const CssCompiledLinearGradient
|
|
|
9634
10123
|
rs.bg_gradient_to_stop = gradient.toStopPermille;
|
|
9635
10124
|
rs.bg_gradient_has_mid = gradient.hasMid;
|
|
9636
10125
|
rs.bg_gradient_angle = gradient.angleTenths;
|
|
10126
|
+
#endif
|
|
9637
10127
|
}
|
|
9638
10128
|
|
|
9639
10129
|
void applyCompiledOverlayGradient(RareStyle &rs, const CssCompiledLinearGradient &gradient)
|
|
9640
10130
|
{
|
|
10131
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9641
10132
|
rs.bg_overlay_gradient = 1;
|
|
9642
10133
|
rs.bg_overlay_gradient_from_color = gradient.fromNativeColor;
|
|
9643
10134
|
rs.bg_overlay_gradient_mid_color = gradient.midNativeColor;
|
|
@@ -9649,10 +10140,12 @@ void applyCompiledOverlayGradient(RareStyle &rs, const CssCompiledLinearGradient
|
|
|
9649
10140
|
rs.bg_overlay_gradient_to_stop = gradient.toStopPermille;
|
|
9650
10141
|
rs.bg_overlay_gradient_has_mid = gradient.hasMid;
|
|
9651
10142
|
rs.bg_overlay_gradient_angle = gradient.angleTenths;
|
|
10143
|
+
#endif
|
|
9652
10144
|
}
|
|
9653
10145
|
|
|
9654
10146
|
void applyCompiledRadialGradient(RareStyle &rs, const CssCompiledRadialGradient &gradient)
|
|
9655
10147
|
{
|
|
10148
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9656
10149
|
rs.bg_radial_gradient = 1;
|
|
9657
10150
|
rs.bg_radial_gradient_from_color = gradient.fromNativeColor;
|
|
9658
10151
|
rs.bg_radial_gradient_to_color = gradient.toNativeColor;
|
|
@@ -9663,6 +10156,7 @@ void applyCompiledRadialGradient(RareStyle &rs, const CssCompiledRadialGradient
|
|
|
9663
10156
|
rs.bg_radial_gradient_cy = gradient.cyPermille;
|
|
9664
10157
|
rs.bg_radial_gradient_rx = gradient.rxPermille;
|
|
9665
10158
|
rs.bg_radial_gradient_ry = gradient.ryPermille;
|
|
10159
|
+
#endif
|
|
9666
10160
|
}
|
|
9667
10161
|
|
|
9668
10162
|
bool compiledLinearGradientMatches(const RareStyle &rs, const CssCompiledLinearGradient &gradient)
|
|
@@ -9763,11 +10257,18 @@ bool applyBackgroundImageToStyle(ComputedStyle &style, int handle, int nodeId)
|
|
|
9763
10257
|
(!axes || (current.bg_grid_color == background->gridColor && current.bg_grid_alpha == background->gridAlpha &&
|
|
9764
10258
|
current.bg_grid_line_x == lineX && current.bg_grid_line_y == lineY))) return false;
|
|
9765
10259
|
RareStyle &rs = rstyleMut(style);
|
|
10260
|
+
#if GEA_CSS_BACKGROUND_LAYERS
|
|
9766
10261
|
rs.bg_image_layer_count = background ? background->layerCount : 1;
|
|
10262
|
+
#endif
|
|
10263
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9767
10264
|
rs.bg_gradient_layer = background ? background->gradientLayer : 0;
|
|
9768
10265
|
rs.bg_overlay_gradient_layer = background ? background->overlayLayer : 0;
|
|
9769
10266
|
rs.bg_radial_gradient_layer = background ? background->radialLayer : 0;
|
|
10267
|
+
#endif
|
|
10268
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
9770
10269
|
style.bg_fill = background && background->hasGradient ? 1 : 0;
|
|
10270
|
+
#endif
|
|
10271
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9771
10272
|
rs.bg_gradient_has_mid = 0;
|
|
9772
10273
|
rs.bg_overlay_gradient = 0;
|
|
9773
10274
|
rs.bg_radial_gradient = 0;
|
|
@@ -9775,16 +10276,19 @@ bool applyBackgroundImageToStyle(ComputedStyle &style, int handle, int nodeId)
|
|
|
9775
10276
|
rs.bg_grid_color = 0;
|
|
9776
10277
|
rs.bg_grid_alpha = 255;
|
|
9777
10278
|
rs.bg_grid_line_x = rs.bg_grid_line_y = 0;
|
|
10279
|
+
#endif
|
|
9778
10280
|
if (background) {
|
|
9779
10281
|
if (background->hasGradient) applyCompiledLinearGradient(rs, gradient);
|
|
9780
10282
|
if (background->hasOverlayGradient) applyCompiledOverlayGradient(rs, overlay);
|
|
9781
10283
|
if (background->hasRadialGradient) applyCompiledRadialGradient(rs, radial);
|
|
10284
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9782
10285
|
rs.bg_grid_axes = background->gridAxes;
|
|
9783
10286
|
rs.bg_grid_color = background->gridColor;
|
|
9784
10287
|
rs.bg_grid_alpha = background->gridAlpha;
|
|
9785
10288
|
rs.bg_grid_axes = axes;
|
|
9786
10289
|
rs.bg_grid_line_x = lineX;
|
|
9787
10290
|
rs.bg_grid_line_y = lineY;
|
|
10291
|
+
#endif
|
|
9788
10292
|
}
|
|
9789
10293
|
return true;
|
|
9790
10294
|
}
|
|
@@ -9855,35 +10359,37 @@ bool applyRuntimeLengthValue(NodeHandle node,
|
|
|
9855
10359
|
}
|
|
9856
10360
|
switch (declaration) {
|
|
9857
10361
|
case CssDeclarationId::Gap:
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
9862
|
-
|
|
9863
|
-
|
|
9864
|
-
case CssDeclarationId::
|
|
9865
|
-
case CssDeclarationId::
|
|
9866
|
-
case CssDeclarationId::
|
|
9867
|
-
case CssDeclarationId::
|
|
9868
|
-
case CssDeclarationId::
|
|
9869
|
-
case CssDeclarationId::
|
|
9870
|
-
case CssDeclarationId::
|
|
9871
|
-
case CssDeclarationId::
|
|
9872
|
-
case CssDeclarationId::
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
case CssDeclarationId::BorderTopWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0)
|
|
9878
|
-
case CssDeclarationId::BorderRightWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0)
|
|
9879
|
-
case CssDeclarationId::BorderBottomWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0)
|
|
9880
|
-
case CssDeclarationId::BorderLeftWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0)
|
|
10362
|
+
setGapLengthValues(node, declaration, length, length, source);
|
|
10363
|
+
return true;
|
|
10364
|
+
case CssDeclarationId::MinWidth: setLengthStyleValue(node, length, Property::MinWidth, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10365
|
+
case CssDeclarationId::MinHeight: setLengthStyleValue(node, length, Property::MinHeight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
|
|
10366
|
+
case CssDeclarationId::MaxWidth: setLengthStyleValue(node, length, Property::MaxWidth, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10367
|
+
case CssDeclarationId::MaxHeight: setLengthStyleValue(node, length, Property::MaxHeight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
|
|
10368
|
+
case CssDeclarationId::PaddingTop: setLengthStyleValue(node, length, Property::PaddingTop, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
|
|
10369
|
+
case CssDeclarationId::PaddingRight: setLengthStyleValue(node, length, Property::PaddingRight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10370
|
+
case CssDeclarationId::PaddingBottom: setLengthStyleValue(node, length, Property::PaddingBottom, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
|
|
10371
|
+
case CssDeclarationId::PaddingLeft: setLengthStyleValue(node, length, Property::PaddingLeft, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10372
|
+
case CssDeclarationId::MarginTop: setLengthStyleValue(node, length, Property::MarginTop, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
|
|
10373
|
+
case CssDeclarationId::MarginRight: setLengthStyleValue(node, length, Property::MarginRight, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10374
|
+
case CssDeclarationId::MarginBottom: setLengthStyleValue(node, length, Property::MarginBottom, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Vertical), source); return true;
|
|
10375
|
+
case CssDeclarationId::MarginLeft: setLengthStyleValue(node, length, Property::MarginLeft, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10376
|
+
case CssDeclarationId::BorderWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) {
|
|
10377
|
+
setUniformBorderWidth(node, width, source);
|
|
10378
|
+
if (source == StyleApplicationSource::Inline && length.unit == CssLengthUnit::Px)
|
|
10379
|
+
ensureRareData(node.id()).inlineStyles.setCssPixels(Property::BorderWidth, length.value);
|
|
10380
|
+
} return true;
|
|
10381
|
+
case CssDeclarationId::BorderTopWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderTopWidth, width, source); return true;
|
|
10382
|
+
case CssDeclarationId::BorderRightWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderRightWidth, width, source); return true;
|
|
10383
|
+
case CssDeclarationId::BorderBottomWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderBottomWidth, width, source); return true;
|
|
10384
|
+
case CssDeclarationId::BorderLeftWidth: if (const int width = resolveBorderWidth(length, nodeId); width >= 0) setLengthStyleValue(node, length, Property::BorderLeftWidth, width, source); return true;
|
|
9881
10385
|
case CssDeclarationId::FontSize:
|
|
9882
|
-
|
|
10386
|
+
setLengthStyleValue(node, length, Property::FontSize, resolveFontSizeLength(length, nodeId), source);
|
|
9883
10387
|
return true;
|
|
9884
|
-
|
|
10388
|
+
#if GEA_CSS_TRANSFORMS
|
|
10389
|
+
case CssDeclarationId::Perspective: setLengthStyleValue(node, length, Property::Perspective, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal), source); return true;
|
|
10390
|
+
#endif
|
|
9885
10391
|
case CssDeclarationId::MaskImage:
|
|
9886
|
-
|
|
10392
|
+
setLengthStyleValue(node, length,
|
|
9887
10393
|
Property::MaskRightFadeWidth,
|
|
9888
10394
|
std::max(0, resolveCompiledLengthForNode(length, nodeId, LengthAxis::Horizontal)),
|
|
9889
10395
|
source);
|
|
@@ -9991,8 +10497,10 @@ bool applyRuntimeBackgroundSizeValue(NodeHandle node,
|
|
|
9991
10497
|
const int stepX = resolveCompiledLengthForNode(stepXLength, nodeId, LengthAxis::Horizontal);
|
|
9992
10498
|
const int stepY = resolveCompiledLengthForNode(stepYLength, nodeId, LengthAxis::Vertical);
|
|
9993
10499
|
RareStyle &rs = rstyleMut(target.style);
|
|
10500
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
9994
10501
|
if (stepX > 0) rs.bg_grid_step_x = static_cast<std::uint16_t>(std::min(stepX, 65535));
|
|
9995
10502
|
if (stepY > 0) rs.bg_grid_step_y = static_cast<std::uint16_t>(std::min(stepY, 65535));
|
|
10503
|
+
#endif
|
|
9996
10504
|
markNodeDisplayCommandsDirtyForStyleApply(nodeId);
|
|
9997
10505
|
return true;
|
|
9998
10506
|
}
|
|
@@ -10018,11 +10526,15 @@ bool applyRuntimeBorderShorthandValue(NodeHandle node,
|
|
|
10018
10526
|
const int snappedWidth = resolveBorderWidth(width, nodeId);
|
|
10019
10527
|
if (snappedWidth < 0) return true;
|
|
10020
10528
|
setUniformBorderWidth(node, snappedWidth, source);
|
|
10529
|
+
if (source == StyleApplicationSource::Inline && width.unit == CssLengthUnit::Px)
|
|
10530
|
+
ensureRareData(node.id()).inlineStyles.setCssPixels(Property::BorderWidth, width.value);
|
|
10021
10531
|
for (int side = 0; side < 4; ++side)
|
|
10022
10532
|
setStyleValue(node, static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side), relief, source);
|
|
10023
10533
|
if (alpha >= 0) {
|
|
10024
10534
|
setStyleValue(node, Property::BorderColor, color, source);
|
|
10535
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
10025
10536
|
setStyleValue(node, Property::BorderAlpha, alpha, source);
|
|
10537
|
+
#endif
|
|
10026
10538
|
markNodeDisplayCommandsDirtyForStyleApply(nodeId);
|
|
10027
10539
|
} else setStyleValue(node, Property::BorderColorCurrent, 1, source);
|
|
10028
10540
|
return true;
|
|
@@ -10085,7 +10597,7 @@ bool applyCompiledBorderRadiusValue(NodeHandle node, const CssCompiledValue &com
|
|
|
10085
10597
|
{
|
|
10086
10598
|
if (!node || compiled.kind != CssCompiledKind::BorderRadius) return false;
|
|
10087
10599
|
if (compiled.declaration == CssDeclarationId::BorderRadius) {
|
|
10088
|
-
for (int corner = 0; corner <
|
|
10600
|
+
for (int corner = 0; corner < GEA_CSS_RADIUS_COUNT; ++corner)
|
|
10089
10601
|
setCompiledBorderRadiusCornerValue(node, corner, compiled.lengths[corner], source);
|
|
10090
10602
|
return true;
|
|
10091
10603
|
}
|
|
@@ -10215,6 +10727,9 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10215
10727
|
if (!node) return true;
|
|
10216
10728
|
const int nodeId = node.id();
|
|
10217
10729
|
switch (compiled.kind) {
|
|
10730
|
+
#if !GEA_CSS_GRID
|
|
10731
|
+
case CssCompiledKind::GridTemplate: return false;
|
|
10732
|
+
#endif
|
|
10218
10733
|
case CssCompiledKind::Noop:
|
|
10219
10734
|
return true;
|
|
10220
10735
|
case CssCompiledKind::DirectProperty: {
|
|
@@ -10224,13 +10739,13 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10224
10739
|
return true;
|
|
10225
10740
|
}
|
|
10226
10741
|
case CssCompiledKind::DirectPropertyGroup: {
|
|
10227
|
-
int count = compiled.
|
|
10742
|
+
int count = compiled.aux;
|
|
10228
10743
|
if (count < 0) count = 0;
|
|
10229
10744
|
if (count > 4) count = 4;
|
|
10230
10745
|
for (int i = 0; i < count; ++i) {
|
|
10231
|
-
const int propertyIndex = compiled.values[
|
|
10746
|
+
const int propertyIndex = compiled.values[i * 2];
|
|
10232
10747
|
if (propertyIndex < 0 || propertyIndex >= static_cast<int>(Property::Count)) return false;
|
|
10233
|
-
setStyleValue(node, static_cast<Property>(propertyIndex), compiled.values[
|
|
10748
|
+
setStyleValue(node, static_cast<Property>(propertyIndex), compiled.values[1 + i * 2], source);
|
|
10234
10749
|
}
|
|
10235
10750
|
return true;
|
|
10236
10751
|
}
|
|
@@ -10245,10 +10760,12 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10245
10760
|
case CssDeclarationId::JustifyItems: setStyleValue(node, Property::JustifyItems, compiled.values[0], source); return true;
|
|
10246
10761
|
case CssDeclarationId::AlignContent: setStyleValue(node, Property::AlignContent, compiled.values[0], source); return true;
|
|
10247
10762
|
case CssDeclarationId::JustifySelf: setStyleValue(node, Property::JustifySelf, compiled.values[0], source); return true;
|
|
10763
|
+
#if GEA_CSS_GRID
|
|
10248
10764
|
case CssDeclarationId::GridRowStart: setStyleValue(node, Property::GridRowStart, compiled.values[0], source); return true;
|
|
10249
10765
|
case CssDeclarationId::GridColumnStart: setStyleValue(node, Property::GridColumnStart, compiled.values[0], source); return true;
|
|
10250
10766
|
case CssDeclarationId::GridRowEnd: setStyleValue(node, Property::GridRowEnd, compiled.values[0], source); return true;
|
|
10251
10767
|
case CssDeclarationId::GridColumnEnd: setStyleValue(node, Property::GridColumnEnd, compiled.values[0], source); return true;
|
|
10768
|
+
#endif
|
|
10252
10769
|
case CssDeclarationId::AlignSelf: setStyleValue(node, Property::AlignSelf, compiled.values[0], source); return true;
|
|
10253
10770
|
case CssDeclarationId::Position: setStyleValue(node, Property::Position, compiled.values[0], source); return true;
|
|
10254
10771
|
case CssDeclarationId::TextAlign: setStyleValue(node, Property::TextAlign, compiled.values[0], source); return true;
|
|
@@ -10256,7 +10773,9 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10256
10773
|
case CssDeclarationId::TextTransform: setStyleValue(node, Property::TextTransform, compiled.values[0], source); return true;
|
|
10257
10774
|
case CssDeclarationId::WhiteSpace: setStyleValue(node, Property::WhiteSpace, compiled.values[0], source); return true;
|
|
10258
10775
|
case CssDeclarationId::TextOverflow: setStyleValue(node, Property::TextOverflow, compiled.values[0], source); return true;
|
|
10776
|
+
#if GEA_CSS_TRANSFORMS
|
|
10259
10777
|
case CssDeclarationId::TransformStyle: setStyleValue(node, Property::TransformStyle, compiled.values[0], source); return true;
|
|
10778
|
+
#endif
|
|
10260
10779
|
case CssDeclarationId::Visibility: setStyleValue(node, Property::Visibility, compiled.values[0], source); return true;
|
|
10261
10780
|
case CssDeclarationId::BackfaceVisibility: setStyleValue(node, Property::Backface, compiled.values[0], source); return true;
|
|
10262
10781
|
case CssDeclarationId::PointerEvents: setStyleValue(node, Property::PointerEvents, compiled.values[0], source); return true;
|
|
@@ -10317,7 +10836,7 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10317
10836
|
color.alpha = entry->colorAlpha;
|
|
10318
10837
|
color.valid = true;
|
|
10319
10838
|
} else {
|
|
10320
|
-
color = cachedCssColorForValue(entry->value);
|
|
10839
|
+
color = cachedCssColorForValue(*entry->value);
|
|
10321
10840
|
}
|
|
10322
10841
|
if (color.valid)
|
|
10323
10842
|
return applyCompiledColorValue(node,
|
|
@@ -10379,6 +10898,7 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10379
10898
|
return applyCompiledFilterBlurValue(node, compiled, source);
|
|
10380
10899
|
case CssCompiledKind::BoxShadow:
|
|
10381
10900
|
return applyCompiledBoxShadowValue(node, compiled, source);
|
|
10901
|
+
#if GEA_CSS_GRID
|
|
10382
10902
|
case CssCompiledKind::GridTemplate: {
|
|
10383
10903
|
const CssCompiledGridTemplate *grid =
|
|
10384
10904
|
compiledCssGridTemplateForHandle(static_cast<std::uint16_t>(compiled.values[0]));
|
|
@@ -10393,6 +10913,7 @@ bool applyCompiledCssValueWithSource(NodeHandle node, const CssCompiledValue &co
|
|
|
10393
10913
|
}
|
|
10394
10914
|
return false;
|
|
10395
10915
|
}
|
|
10916
|
+
#endif
|
|
10396
10917
|
case CssCompiledKind::LineHeight:
|
|
10397
10918
|
return applyCompiledLineHeightValue(node, compiled, source);
|
|
10398
10919
|
case CssCompiledKind::None:
|
|
@@ -10477,6 +10998,7 @@ void applyPropertyWithSource(NodeHandle node,
|
|
|
10477
10998
|
if (!node) return;
|
|
10478
10999
|
const int nodeId = node.id();
|
|
10479
11000
|
if (declaration == CssDeclarationId::Unknown) return;
|
|
11001
|
+
#if GEA_CSS_GRID
|
|
10480
11002
|
if (source == StyleApplicationSource::Inline &&
|
|
10481
11003
|
(declaration == CssDeclarationId::GridTemplateColumns || declaration == CssDeclarationId::GridTemplateRows ||
|
|
10482
11004
|
declaration == CssDeclarationId::Grid || declaration == CssDeclarationId::GridTemplate)) {
|
|
@@ -10491,6 +11013,7 @@ void applyPropertyWithSource(NodeHandle node,
|
|
|
10491
11013
|
if (mask & (1 << axis)) rare.inlineGridTemplates[axis] = internCssAtom(rawValue);
|
|
10492
11014
|
rare.inlineGridShorthandMask = (rare.inlineGridShorthandMask & ~mask) | (shorthand ? mask : 0);
|
|
10493
11015
|
}
|
|
11016
|
+
#endif
|
|
10494
11017
|
if (declaration == CssDeclarationId::FlexBasis && rawValue.find("var(") != std::string::npos) {
|
|
10495
11018
|
if (const CssLengthSpec *length = cachedCompiledCssLengthSpec(rawValue)) {
|
|
10496
11019
|
setFlexBasisValue(node, true, *length, source);
|
|
@@ -10514,6 +11037,22 @@ void applyPropertyWithSource(NodeHandle node,
|
|
|
10514
11037
|
const int64_t _vt = recNow();
|
|
10515
11038
|
#endif
|
|
10516
11039
|
const bool directValue = rawValue.find("var(") == std::string::npos && isTrimmedCssValue(rawValue);
|
|
11040
|
+
// A whole-value var() compiles like the same declaration in a rule, so it
|
|
11041
|
+
// reads a static custom color's native value; that entry has no text to
|
|
11042
|
+
// substitute. Anything the compiled form cannot apply falls back below.
|
|
11043
|
+
if (!directValue && isTrimmedCssValue(rawValue) && rawValue.rfind("var(", 0) == 0 && rawValue.back() == ')' &&
|
|
11044
|
+
(declaration == CssDeclarationId::Color || declaration == CssDeclarationId::BackgroundColor ||
|
|
11045
|
+
declaration == CssDeclarationId::Background || declaration == CssDeclarationId::ActiveBackgroundColor ||
|
|
11046
|
+
declaration == CssDeclarationId::BorderColor || declaration == CssDeclarationId::BorderTopColor ||
|
|
11047
|
+
declaration == CssDeclarationId::BorderRightColor || declaration == CssDeclarationId::BorderBottomColor ||
|
|
11048
|
+
declaration == CssDeclarationId::BorderLeftColor)) {
|
|
11049
|
+
CssCompiledValue colorVar;
|
|
11050
|
+
colorVar.declaration = declaration;
|
|
11051
|
+
if (compileColorVarValue(rawValue, colorVar)) {
|
|
11052
|
+
colorVar.kind = CssCompiledKind::ColorVar;
|
|
11053
|
+
if (applyCompiledCssValueWithSource(node, colorVar, source)) return;
|
|
11054
|
+
}
|
|
11055
|
+
}
|
|
10517
11056
|
const CssCompiledValue *compiledValue = directValue
|
|
10518
11057
|
? inlineCompiledStyleValueFor(declaration, rawValue)
|
|
10519
11058
|
: nullptr;
|
|
@@ -10525,7 +11064,7 @@ void applyPropertyWithSource(NodeHandle node,
|
|
|
10525
11064
|
const int64_t _bt = recNow();
|
|
10526
11065
|
struct BodyTimer { int64_t s; ~BodyTimer() { g_profBodyUs += recNow() - s; } } _bodyTimer{_bt};
|
|
10527
11066
|
#endif
|
|
10528
|
-
if (compiledValue && applyCompiledCssValueWithSource(node, *compiledValue, source)) return;
|
|
11067
|
+
if (directValue && compiledValue && applyCompiledCssValueWithSource(node, *compiledValue, source)) return;
|
|
10529
11068
|
const std::string &value = directValue ? rawValue : resolvedValue;
|
|
10530
11069
|
(void)applyKnownResolvedPropertyWithSource(node, declaration, value, source);
|
|
10531
11070
|
}
|
|
@@ -10623,6 +11162,7 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
|
|
|
10623
11162
|
return true;
|
|
10624
11163
|
}
|
|
10625
11164
|
const int id = node.id();
|
|
11165
|
+
#if GEA_CSS_GRID
|
|
10626
11166
|
if (property == "grid" || property == "grid-template") {
|
|
10627
11167
|
NodeRareData *rare = rareDataFor(id);
|
|
10628
11168
|
if (!rare || (rare->inlineGridTemplates[0] == kInvalidCssAtom && rare->inlineGridTemplates[1] == kInvalidCssAtom)) return false;
|
|
@@ -10631,6 +11171,8 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
|
|
|
10631
11171
|
recomputeSubtreeClassStyles(id);
|
|
10632
11172
|
return true;
|
|
10633
11173
|
}
|
|
11174
|
+
#endif
|
|
11175
|
+
#if GEA_CSS_GRID
|
|
10634
11176
|
if (property == "grid-template-columns" || property == "grid-template-rows") {
|
|
10635
11177
|
NodeRareData *rare = rareDataFor(id);
|
|
10636
11178
|
const int axis = property == "grid-template-rows" ? 1 : 0;
|
|
@@ -10640,6 +11182,7 @@ bool removeInlineStyleProperty(NodeHandle node, const std::string &property)
|
|
|
10640
11182
|
recomputeSubtreeClassStyles(id);
|
|
10641
11183
|
return true;
|
|
10642
11184
|
}
|
|
11185
|
+
#endif
|
|
10643
11186
|
if (property == "font") return removeInlineStyleProperties(id, {Property::FontId, Property::FontSize, Property::FontWeight, Property::LineHeight, Property::LineHeightExpression, Property::LineHeightMultiplier});
|
|
10644
11187
|
if (property == "display") return removeInlineStyleProperties(id, {Property::Display});
|
|
10645
11188
|
if (property == "contain") return removeInlineStyleProperties(id, {Property::Containment});
|
|
@@ -10822,6 +11365,7 @@ void replayInlineStyles(int node)
|
|
|
10822
11365
|
const NodeStyleOverride &entry = rd->inlineStyles.at(i);
|
|
10823
11366
|
Tree::instance().setStyleFromClass(node, entry.property, entry.value);
|
|
10824
11367
|
}
|
|
11368
|
+
#if GEA_CSS_GRID
|
|
10825
11369
|
if (const NodeRareData *rd = rareDataFor(node)) {
|
|
10826
11370
|
// Copy the atoms before replay: resolving authored values can touch
|
|
10827
11371
|
// pooled style storage. Resolve variables and font-relative tracks anew.
|
|
@@ -10839,6 +11383,7 @@ void replayInlineStyles(int node)
|
|
|
10839
11383
|
value, StyleApplicationSource::ClassRule);
|
|
10840
11384
|
}
|
|
10841
11385
|
}
|
|
11386
|
+
#endif
|
|
10842
11387
|
}
|
|
10843
11388
|
|
|
10844
11389
|
void applyDefaultStyleOverrides(int node)
|
|
@@ -10852,6 +11397,7 @@ void applyDefaultStyleOverrides(int node)
|
|
|
10852
11397
|
}
|
|
10853
11398
|
}
|
|
10854
11399
|
|
|
11400
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
10855
11401
|
int16_t g_pseudoBeforeTagId = -1;
|
|
10856
11402
|
int16_t g_pseudoAfterTagId = -1;
|
|
10857
11403
|
|
|
@@ -10878,6 +11424,10 @@ bool isGeneratedPseudoNode(const Node &node)
|
|
|
10878
11424
|
return tag == pseudoBeforeTagId() || tag == pseudoAfterTagId();
|
|
10879
11425
|
}
|
|
10880
11426
|
|
|
11427
|
+
#else
|
|
11428
|
+
constexpr bool isGeneratedPseudoNode(const Node &) { return false; }
|
|
11429
|
+
#endif
|
|
11430
|
+
|
|
10881
11431
|
std::string normalizeSelectorText(const std::string &selector)
|
|
10882
11432
|
{
|
|
10883
11433
|
std::string out = trimCssValue(selector);
|
|
@@ -11001,7 +11551,7 @@ bool equalsLiteral(const char *text, std::size_t length, const char *literal)
|
|
|
11001
11551
|
struct ParsedSimpleSelector {
|
|
11002
11552
|
int16_t tagId = -1;
|
|
11003
11553
|
CssAtomId idAtom = kInvalidCssAtom;
|
|
11004
|
-
SmallSelectorList<CssAtomId, 4> classIds;
|
|
11554
|
+
[[no_unique_address]] SmallSelectorList<CssAtomId, 4> classIds;
|
|
11005
11555
|
bool hasTag = false;
|
|
11006
11556
|
bool wantsRoot = false;
|
|
11007
11557
|
bool wantsFirstChild = false;
|
|
@@ -11070,20 +11620,22 @@ ParsedSimpleSelector parseSimpleSelector(const char *rawSimple, std::size_t rawL
|
|
|
11070
11620
|
}
|
|
11071
11621
|
|
|
11072
11622
|
struct SelectorPart {
|
|
11073
|
-
ParsedSimpleSelector simple;
|
|
11623
|
+
[[no_unique_address]] ParsedSimpleSelector simple;
|
|
11074
11624
|
bool directParent = false;
|
|
11075
11625
|
};
|
|
11076
11626
|
|
|
11077
11627
|
struct SelectorPlan {
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
SmallSelectorList<
|
|
11628
|
+
// The lists have nontrivial ownership and trailing padding. Let adjacent
|
|
11629
|
+
// scalar fields occupy that padding without changing any access path.
|
|
11630
|
+
[[no_unique_address]] SmallSelectorList<SelectorPart, 4> parts;
|
|
11631
|
+
bool rightmostRoot = false;
|
|
11632
|
+
bool valid = true;
|
|
11633
|
+
[[no_unique_address]] SmallSelectorList<CssAtomId, 4> ancestorClasses;
|
|
11081
11634
|
CssAtomId rightmostId = kInvalidCssAtom;
|
|
11635
|
+
[[no_unique_address]] SmallSelectorList<int16_t, 4> ancestorTags;
|
|
11082
11636
|
CssAtomId rightmostClass = kInvalidCssAtom;
|
|
11083
11637
|
int16_t rightmostTag = -1;
|
|
11084
11638
|
int specificity = 0;
|
|
11085
|
-
bool rightmostRoot = false;
|
|
11086
|
-
bool valid = true;
|
|
11087
11639
|
};
|
|
11088
11640
|
|
|
11089
11641
|
template <typename T>
|
|
@@ -11828,6 +12380,7 @@ bool ruleMediaMatchesUncached(const CssRule &rule)
|
|
|
11828
12380
|
return mediaConditionMatches(cssRuleTextForHandle(rule.mediaText));
|
|
11829
12381
|
}
|
|
11830
12382
|
|
|
12383
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
11831
12384
|
int findPseudoChild(int parent, CssRule::PseudoElement pseudo)
|
|
11832
12385
|
{
|
|
11833
12386
|
const int16_t tag = pseudoTagId(pseudo);
|
|
@@ -11874,6 +12427,8 @@ int ensurePseudoChild(int parent, CssRule::PseudoElement pseudo)
|
|
|
11874
12427
|
return child;
|
|
11875
12428
|
}
|
|
11876
12429
|
|
|
12430
|
+
#endif
|
|
12431
|
+
|
|
11877
12432
|
static constexpr std::size_t kRuleCandidateCacheClassCapacity = 6;
|
|
11878
12433
|
|
|
11879
12434
|
struct RuleCandidateSignature {
|
|
@@ -12059,7 +12614,9 @@ struct RuleIndex {
|
|
|
12059
12614
|
DenseRuleBuckets selByTag;
|
|
12060
12615
|
std::vector<int> selRoot;
|
|
12061
12616
|
std::vector<int> selAlways;
|
|
12617
|
+
#if GEA_CSS_ANIMATIONS
|
|
12062
12618
|
std::vector<int> animationRules; // rules with property == "animation" (any selector type)
|
|
12619
|
+
#endif
|
|
12063
12620
|
RuleCandidateCacheStore candidateCache;
|
|
12064
12621
|
// Classes/tags that appear in a NON-rightmost simple selector of any complex rule
|
|
12065
12622
|
// (i.e. as an ancestor matcher, like `.theme-night` in `.theme-night .icon`).
|
|
@@ -12151,7 +12708,9 @@ void rebuildRuleIndexIfNeeded()
|
|
|
12151
12708
|
g_ruleIndex.selByTag.clear();
|
|
12152
12709
|
g_ruleIndex.selRoot.clear();
|
|
12153
12710
|
g_ruleIndex.selAlways.clear();
|
|
12711
|
+
#if GEA_CSS_ANIMATIONS
|
|
12154
12712
|
g_ruleIndex.animationRules.clear();
|
|
12713
|
+
#endif
|
|
12155
12714
|
g_ruleIndex.candidateCache.clear();
|
|
12156
12715
|
ruleCandidateCacheLastHit() = static_cast<std::size_t>(-1);
|
|
12157
12716
|
clearActiveRulePlanCache();
|
|
@@ -12223,7 +12782,9 @@ void rebuildRuleIndexIfNeeded()
|
|
|
12223
12782
|
list[i].pseudoElement == CssRule::PseudoElement::After ||
|
|
12224
12783
|
list[i].pseudoElement == CssRule::PseudoElement::FirstLine)
|
|
12225
12784
|
g_ruleIndex.hasPseudoElementRules = true;
|
|
12785
|
+
#if GEA_CSS_ANIMATIONS
|
|
12226
12786
|
if (list[i].propertyKind == CssRuleProperty::Animation) g_ruleIndex.animationRules.push_back(i);
|
|
12787
|
+
#endif
|
|
12227
12788
|
}
|
|
12228
12789
|
g_ruleIndex.byClass.finalize();
|
|
12229
12790
|
g_ruleIndex.byTag.finalize();
|
|
@@ -12291,13 +12852,19 @@ CssAtomId nodeIdAttributeAtom(int node)
|
|
|
12291
12852
|
enum ActiveRuleBucket : std::uint8_t {
|
|
12292
12853
|
kActiveMainCustom,
|
|
12293
12854
|
kActiveMainRule,
|
|
12855
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
12294
12856
|
kActiveBeforeCustom,
|
|
12295
12857
|
kActiveBeforeRule,
|
|
12296
12858
|
kActiveAfterCustom,
|
|
12297
12859
|
kActiveAfterRule,
|
|
12860
|
+
#endif
|
|
12861
|
+
#if GEA_CSS_FIRST_LINE
|
|
12298
12862
|
kActiveFirstLineCustom,
|
|
12299
12863
|
kActiveFirstLineRule,
|
|
12864
|
+
#endif
|
|
12865
|
+
#if GEA_CSS_ANIMATIONS
|
|
12300
12866
|
kActiveAnimation,
|
|
12867
|
+
#endif
|
|
12301
12868
|
kActiveRuleBucketCount
|
|
12302
12869
|
};
|
|
12303
12870
|
|
|
@@ -12439,7 +13006,11 @@ struct CachedStyleApplyOp {
|
|
|
12439
13006
|
std::uint8_t borderRelief = 0;
|
|
12440
13007
|
std::uint8_t properties[kCachedStyleApplyOpPropertyCapacity]{};
|
|
12441
13008
|
std::int32_t values[kCachedStyleApplyOpPropertyCapacity]{};
|
|
13009
|
+
#if GEA_CSS_TRANSFORMS
|
|
12442
13010
|
std::int16_t transform[kCachedTransformValueCount]{};
|
|
13011
|
+
#else
|
|
13012
|
+
static constexpr std::int16_t transform[kCachedTransformValueCount]{};
|
|
13013
|
+
#endif
|
|
12443
13014
|
};
|
|
12444
13015
|
|
|
12445
13016
|
class CachedStyleApplyOpStore {
|
|
@@ -12823,7 +13394,9 @@ bool addCachedLengthDeclaration(CachedStyleApplyOp &op, CssDeclarationId declara
|
|
|
12823
13394
|
case CssDeclarationId::BorderBottomWidth: return addCachedStyleApplyProperty(op, Property::BorderBottomWidth, value);
|
|
12824
13395
|
case CssDeclarationId::BorderLeftWidth: return addCachedStyleApplyProperty(op, Property::BorderLeftWidth, value);
|
|
12825
13396
|
case CssDeclarationId::FontSize: return addCachedStyleApplyProperty(op, Property::FontSize, value);
|
|
13397
|
+
#if GEA_CSS_TRANSFORMS
|
|
12826
13398
|
case CssDeclarationId::Perspective: return addCachedStyleApplyProperty(op, Property::Perspective, value);
|
|
13399
|
+
#endif
|
|
12827
13400
|
case CssDeclarationId::MaskImage:
|
|
12828
13401
|
return addCachedStyleApplyProperty(op, Property::MaskRightFadeWidth, std::max(0, value));
|
|
12829
13402
|
default:
|
|
@@ -12884,7 +13457,7 @@ bool addCachedBorderRadiusDeclaration(CachedStyleApplyOp &op,
|
|
|
12884
13457
|
const CssCompiledValue &compiled)
|
|
12885
13458
|
{
|
|
12886
13459
|
if (declaration == CssDeclarationId::BorderRadius) {
|
|
12887
|
-
for (int corner = 0; corner <
|
|
13460
|
+
for (int corner = 0; corner < GEA_CSS_RADIUS_COUNT; ++corner)
|
|
12888
13461
|
if (!addCachedBorderRadiusCorner(op, corner, compiled.lengths[corner])) return false;
|
|
12889
13462
|
return true;
|
|
12890
13463
|
}
|
|
@@ -12946,10 +13519,12 @@ bool addCachedKeywordDeclaration(CachedStyleApplyOp &op, CssDeclarationId declar
|
|
|
12946
13519
|
case CssDeclarationId::JustifyItems: return addCachedStyleApplyProperty(op, Property::JustifyItems, value);
|
|
12947
13520
|
case CssDeclarationId::AlignContent: return addCachedStyleApplyProperty(op, Property::AlignContent, value);
|
|
12948
13521
|
case CssDeclarationId::JustifySelf: return addCachedStyleApplyProperty(op, Property::JustifySelf, value);
|
|
13522
|
+
#if GEA_CSS_GRID
|
|
12949
13523
|
case CssDeclarationId::GridRowStart: return addCachedStyleApplyProperty(op, Property::GridRowStart, value);
|
|
12950
13524
|
case CssDeclarationId::GridColumnStart: return addCachedStyleApplyProperty(op, Property::GridColumnStart, value);
|
|
12951
13525
|
case CssDeclarationId::GridRowEnd: return addCachedStyleApplyProperty(op, Property::GridRowEnd, value);
|
|
12952
13526
|
case CssDeclarationId::GridColumnEnd: return addCachedStyleApplyProperty(op, Property::GridColumnEnd, value);
|
|
13527
|
+
#endif
|
|
12953
13528
|
case CssDeclarationId::AlignSelf: return addCachedStyleApplyProperty(op, Property::AlignSelf, value);
|
|
12954
13529
|
case CssDeclarationId::Position: return addCachedStyleApplyProperty(op, Property::Position, value);
|
|
12955
13530
|
case CssDeclarationId::TextAlign: return addCachedStyleApplyProperty(op, Property::TextAlign, value);
|
|
@@ -12957,7 +13532,9 @@ bool addCachedKeywordDeclaration(CachedStyleApplyOp &op, CssDeclarationId declar
|
|
|
12957
13532
|
case CssDeclarationId::TextTransform: return addCachedStyleApplyProperty(op, Property::TextTransform, value);
|
|
12958
13533
|
case CssDeclarationId::WhiteSpace: return addCachedStyleApplyProperty(op, Property::WhiteSpace, value);
|
|
12959
13534
|
case CssDeclarationId::TextOverflow: return addCachedStyleApplyProperty(op, Property::TextOverflow, value);
|
|
13535
|
+
#if GEA_CSS_TRANSFORMS
|
|
12960
13536
|
case CssDeclarationId::TransformStyle: return addCachedStyleApplyProperty(op, Property::TransformStyle, value);
|
|
13537
|
+
#endif
|
|
12961
13538
|
case CssDeclarationId::Visibility: return addCachedStyleApplyProperty(op, Property::Visibility, value);
|
|
12962
13539
|
case CssDeclarationId::BackfaceVisibility: return addCachedStyleApplyProperty(op, Property::Backface, value);
|
|
12963
13540
|
case CssDeclarationId::PointerEvents: return addCachedStyleApplyProperty(op, Property::PointerEvents, value);
|
|
@@ -12988,14 +13565,15 @@ bool cachedTransformTranslateValue(const CssLengthSpec &length,
|
|
|
12988
13565
|
|
|
12989
13566
|
bool buildCachedTransformApplyOp(const CssCompiledValue &compiled, CachedStyleApplyOp &op)
|
|
12990
13567
|
{
|
|
13568
|
+
#if GEA_CSS_TRANSFORMS
|
|
12991
13569
|
if (compiled.kind != CssCompiledKind::Transform) return false;
|
|
12992
13570
|
TransformComponents transform;
|
|
12993
13571
|
transform.rotateX = compiled.values[0];
|
|
12994
13572
|
transform.rotateY = compiled.values[1];
|
|
12995
13573
|
transform.rotateZ = compiled.values[2];
|
|
12996
|
-
transform.scaleX = compiled.values[
|
|
12997
|
-
transform.scaleY = compiled.values[
|
|
12998
|
-
transform.scaleZ = compiled.values[
|
|
13574
|
+
transform.scaleX = compiled.values[3];
|
|
13575
|
+
transform.scaleY = compiled.values[4];
|
|
13576
|
+
transform.scaleZ = compiled.values[5];
|
|
12999
13577
|
if ((compiled.flags & (1u << 3)) != 0 &&
|
|
13000
13578
|
!cachedTransformTranslateValue(compiled.lengths[0], true, transform.translateX, transform.translateXPercent))
|
|
13001
13579
|
return false;
|
|
@@ -13023,6 +13601,9 @@ bool buildCachedTransformApplyOp(const CssCompiledValue &compiled, CachedStyleAp
|
|
|
13023
13601
|
op.transform[9] = cachedInt16Value(transform.scaleY);
|
|
13024
13602
|
op.transform[10] = cachedInt16Value(transform.scaleZ);
|
|
13025
13603
|
return true;
|
|
13604
|
+
#else
|
|
13605
|
+
(void)compiled; (void)op; return false;
|
|
13606
|
+
#endif
|
|
13026
13607
|
}
|
|
13027
13608
|
|
|
13028
13609
|
bool buildCachedCompiledTransformApplyOp(const CssCompiledValue &compiled, CachedStyleApplyOp &op)
|
|
@@ -13191,14 +13772,14 @@ bool buildCachedStyleApplyOp(const CssCompiledValue *compiled, CachedStyleApplyO
|
|
|
13191
13772
|
return addCachedStyleApplyProperty(op, static_cast<Property>(propertyIndex), compiled->values[1]);
|
|
13192
13773
|
}
|
|
13193
13774
|
case CssCompiledKind::DirectPropertyGroup: {
|
|
13194
|
-
int count = compiled->
|
|
13775
|
+
int count = compiled->aux;
|
|
13195
13776
|
if (count < 0 || count > static_cast<int>(kCachedStyleApplyOpPropertyCapacity)) return false;
|
|
13196
13777
|
for (int i = 0; i < count; ++i) {
|
|
13197
|
-
const int propertyIndex = compiled->values[
|
|
13778
|
+
const int propertyIndex = compiled->values[i * 2];
|
|
13198
13779
|
if (propertyIndex < 0 || propertyIndex >= static_cast<int>(Property::Count)) return false;
|
|
13199
13780
|
if (!addCachedStyleApplyProperty(op,
|
|
13200
13781
|
static_cast<Property>(propertyIndex),
|
|
13201
|
-
compiled->values[
|
|
13782
|
+
compiled->values[1 + i * 2])) return false;
|
|
13202
13783
|
}
|
|
13203
13784
|
return op.propertyCount != 0;
|
|
13204
13785
|
}
|
|
@@ -13271,8 +13852,10 @@ bool buildCachedStyleApplyOp(const CssCompiledValue *compiled, CachedStyleApplyO
|
|
|
13271
13852
|
case CssCompiledKind::BackgroundSize:
|
|
13272
13853
|
if (buildCachedBackgroundSizeApplyOp(*compiled, op)) return true;
|
|
13273
13854
|
return buildRuntimeBackgroundSizeApplyOp(*compiled, op);
|
|
13855
|
+
#if GEA_CSS_GRID
|
|
13274
13856
|
case CssCompiledKind::GridTemplate:
|
|
13275
13857
|
return buildCachedGridTemplateApplyOp(*compiled, op);
|
|
13858
|
+
#endif
|
|
13276
13859
|
case CssCompiledKind::LineHeight:
|
|
13277
13860
|
if (compiled->aux == 0 && addCachedStyleApplyProperty(op, Property::LineHeight, 0)) return true;
|
|
13278
13861
|
op = CachedStyleApplyOp{};
|
|
@@ -13375,8 +13958,10 @@ bool cachedStyleApplyOpsEqual(const CachedStyleApplyOp &a, const CachedStyleAppl
|
|
|
13375
13958
|
return true;
|
|
13376
13959
|
if (a.kind == CachedStyleApplyOpKind::Transform) {
|
|
13377
13960
|
if (a.values[0] != b.values[0] || a.values[1] != b.values[1]) return false;
|
|
13961
|
+
#if GEA_CSS_TRANSFORMS
|
|
13378
13962
|
for (std::uint8_t i = 0; i < kCachedTransformValueCount; ++i)
|
|
13379
13963
|
if (a.transform[i] != b.transform[i]) return false;
|
|
13964
|
+
#endif
|
|
13380
13965
|
return true;
|
|
13381
13966
|
}
|
|
13382
13967
|
if (a.kind == CachedStyleApplyOpKind::CompiledTransform)
|
|
@@ -13630,9 +14215,11 @@ void addPropertyWrite(PropertyWriteMask &mask, Property property)
|
|
|
13630
14215
|
if (property == borderSideColorProperty(side) || property == current) { mask.add(current); mask.add(borderSideColorProperty(side)); mask.add(static_cast<Property>(static_cast<int>(Property::BorderTopAlpha) + side)); return; }
|
|
13631
14216
|
}
|
|
13632
14217
|
switch (property) {
|
|
14218
|
+
#if GEA_CSS_BORDER_RELIEF
|
|
13633
14219
|
case Property::BorderRelief:
|
|
13634
14220
|
for (int side = 0; side < 4; ++side) mask.add(static_cast<Property>(static_cast<int>(Property::BorderTopRelief) + side));
|
|
13635
14221
|
return;
|
|
14222
|
+
#endif
|
|
13636
14223
|
case Property::BorderWidth:
|
|
13637
14224
|
mask.add(property);
|
|
13638
14225
|
for (int side = 0; side < 4; ++side) mask.add(borderSideWidthProperty(side));
|
|
@@ -13810,6 +14397,9 @@ bool addColorDeclarationWrites(CssDeclarationId declaration, PropertyWriteMask &
|
|
|
13810
14397
|
bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask &mask)
|
|
13811
14398
|
{
|
|
13812
14399
|
switch (compiled.kind) {
|
|
14400
|
+
#if !GEA_CSS_GRID
|
|
14401
|
+
case CssCompiledKind::GridTemplate: return false;
|
|
14402
|
+
#endif
|
|
13813
14403
|
case CssCompiledKind::Noop:
|
|
13814
14404
|
return true;
|
|
13815
14405
|
case CssCompiledKind::DirectProperty: {
|
|
@@ -13819,11 +14409,11 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
13819
14409
|
return true;
|
|
13820
14410
|
}
|
|
13821
14411
|
case CssCompiledKind::DirectPropertyGroup: {
|
|
13822
|
-
int count = compiled.
|
|
14412
|
+
int count = compiled.aux;
|
|
13823
14413
|
if (count < 0) count = 0;
|
|
13824
14414
|
if (count > 4) count = 4;
|
|
13825
14415
|
for (int i = 0; i < count; ++i) {
|
|
13826
|
-
const int propertyIndex = compiled.values[
|
|
14416
|
+
const int propertyIndex = compiled.values[i * 2];
|
|
13827
14417
|
if (propertyIndex < 0 || propertyIndex >= static_cast<int>(Property::Count)) return false;
|
|
13828
14418
|
addPropertyWrite(mask, static_cast<Property>(propertyIndex));
|
|
13829
14419
|
}
|
|
@@ -13840,10 +14430,12 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
13840
14430
|
case CssDeclarationId::JustifyItems: addPropertyWrite(mask, Property::JustifyItems); return true;
|
|
13841
14431
|
case CssDeclarationId::AlignContent: addPropertyWrite(mask, Property::AlignContent); return true;
|
|
13842
14432
|
case CssDeclarationId::JustifySelf: addPropertyWrite(mask, Property::JustifySelf); return true;
|
|
14433
|
+
#if GEA_CSS_GRID
|
|
13843
14434
|
case CssDeclarationId::GridRowStart: addPropertyWrite(mask, Property::GridRowStart); return true;
|
|
13844
14435
|
case CssDeclarationId::GridColumnStart: addPropertyWrite(mask, Property::GridColumnStart); return true;
|
|
13845
14436
|
case CssDeclarationId::GridRowEnd: addPropertyWrite(mask, Property::GridRowEnd); return true;
|
|
13846
14437
|
case CssDeclarationId::GridColumnEnd: addPropertyWrite(mask, Property::GridColumnEnd); return true;
|
|
14438
|
+
#endif
|
|
13847
14439
|
case CssDeclarationId::AlignSelf: addPropertyWrite(mask, Property::AlignSelf); return true;
|
|
13848
14440
|
case CssDeclarationId::Position: addPropertyWrite(mask, Property::Position); return true;
|
|
13849
14441
|
case CssDeclarationId::TextAlign: addPropertyWrite(mask, Property::TextAlign); return true;
|
|
@@ -13851,7 +14443,9 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
13851
14443
|
case CssDeclarationId::TextTransform: addPropertyWrite(mask, Property::TextTransform); return true;
|
|
13852
14444
|
case CssDeclarationId::WhiteSpace: addPropertyWrite(mask, Property::WhiteSpace); return true;
|
|
13853
14445
|
case CssDeclarationId::TextOverflow: addPropertyWrite(mask, Property::TextOverflow); return true;
|
|
14446
|
+
#if GEA_CSS_TRANSFORMS
|
|
13854
14447
|
case CssDeclarationId::TransformStyle: addPropertyWrite(mask, Property::TransformStyle); return true;
|
|
14448
|
+
#endif
|
|
13855
14449
|
case CssDeclarationId::Visibility: addPropertyWrite(mask, Property::Visibility); return true;
|
|
13856
14450
|
case CssDeclarationId::BackfaceVisibility: addPropertyWrite(mask, Property::Backface); return true;
|
|
13857
14451
|
case CssDeclarationId::PointerEvents: addPropertyWrite(mask, Property::PointerEvents); return true;
|
|
@@ -13915,7 +14509,9 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
13915
14509
|
case CssDeclarationId::BorderBottomWidth: addPropertyWrite(mask, Property::BorderBottomWidth); return true;
|
|
13916
14510
|
case CssDeclarationId::BorderLeftWidth: addPropertyWrite(mask, Property::BorderLeftWidth); return true;
|
|
13917
14511
|
case CssDeclarationId::FontSize: addPropertyWrite(mask, Property::FontSize); return true;
|
|
14512
|
+
#if GEA_CSS_TRANSFORMS
|
|
13918
14513
|
case CssDeclarationId::Perspective: addPropertyWrite(mask, Property::Perspective); return true;
|
|
14514
|
+
#endif
|
|
13919
14515
|
case CssDeclarationId::MaskImage: addPropertyWrite(mask, Property::MaskRightFadeWidth); return true;
|
|
13920
14516
|
default: return false;
|
|
13921
14517
|
}
|
|
@@ -14025,7 +14621,7 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
14025
14621
|
}
|
|
14026
14622
|
case CssCompiledKind::BorderRadius:
|
|
14027
14623
|
if (compiled.declaration == CssDeclarationId::BorderRadius) {
|
|
14028
|
-
for (int corner = 0; corner <
|
|
14624
|
+
for (int corner = 0; corner < GEA_CSS_RADIUS_COUNT; ++corner)
|
|
14029
14625
|
addPropertyWrite(mask, borderRadiusLengthProperty(corner));
|
|
14030
14626
|
return true;
|
|
14031
14627
|
}
|
|
@@ -14053,6 +14649,7 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
14053
14649
|
case CssCompiledKind::BoxShadow:
|
|
14054
14650
|
addBoxShadowPropertyWrites(mask);
|
|
14055
14651
|
return true;
|
|
14652
|
+
#if GEA_CSS_GRID
|
|
14056
14653
|
case CssCompiledKind::GridTemplate:
|
|
14057
14654
|
if (compiled.declaration == CssDeclarationId::GridTemplateColumns) {
|
|
14058
14655
|
mask.addIndex(kVirtualGridTemplateColumnsWrite);
|
|
@@ -14063,6 +14660,7 @@ bool addCompiledValueWrites(const CssCompiledValue &compiled, PropertyWriteMask
|
|
|
14063
14660
|
return true;
|
|
14064
14661
|
}
|
|
14065
14662
|
return false;
|
|
14663
|
+
#endif
|
|
14066
14664
|
case CssCompiledKind::LineHeight:
|
|
14067
14665
|
addPropertyWrite(mask, Property::LineHeight);
|
|
14068
14666
|
return true;
|
|
@@ -14115,9 +14713,13 @@ void collapseShadowedActiveRuleBucket(ActiveRulePlan::Bucket &bucket)
|
|
|
14115
14713
|
void collapseShadowedActiveRules(ActiveRulePlan &plan)
|
|
14116
14714
|
{
|
|
14117
14715
|
collapseShadowedActiveRuleBucket(plan.buckets[kActiveMainRule]);
|
|
14716
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
14118
14717
|
collapseShadowedActiveRuleBucket(plan.buckets[kActiveBeforeRule]);
|
|
14119
14718
|
collapseShadowedActiveRuleBucket(plan.buckets[kActiveAfterRule]);
|
|
14719
|
+
#endif
|
|
14720
|
+
#if GEA_CSS_FIRST_LINE
|
|
14120
14721
|
collapseShadowedActiveRuleBucket(plan.buckets[kActiveFirstLineRule]);
|
|
14722
|
+
#endif
|
|
14121
14723
|
}
|
|
14122
14724
|
|
|
14123
14725
|
int activeRuleBucketFor(const CssRule &rule)
|
|
@@ -14128,11 +14730,23 @@ int activeRuleBucketFor(const CssRule &rule)
|
|
|
14128
14730
|
case CssRule::PseudoElement::None:
|
|
14129
14731
|
return custom ? kActiveMainCustom : kActiveMainRule;
|
|
14130
14732
|
case CssRule::PseudoElement::Before:
|
|
14733
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
14131
14734
|
return custom ? kActiveBeforeCustom : kActiveBeforeRule;
|
|
14735
|
+
#else
|
|
14736
|
+
return -1;
|
|
14737
|
+
#endif
|
|
14132
14738
|
case CssRule::PseudoElement::After:
|
|
14739
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
14133
14740
|
return custom ? kActiveAfterCustom : kActiveAfterRule;
|
|
14741
|
+
#else
|
|
14742
|
+
return -1;
|
|
14743
|
+
#endif
|
|
14134
14744
|
case CssRule::PseudoElement::FirstLine:
|
|
14745
|
+
#if GEA_CSS_FIRST_LINE
|
|
14135
14746
|
return custom ? kActiveFirstLineCustom : kActiveFirstLineRule;
|
|
14747
|
+
#else
|
|
14748
|
+
return -1;
|
|
14749
|
+
#endif
|
|
14136
14750
|
case CssRule::PseudoElement::Unsupported:
|
|
14137
14751
|
return -1;
|
|
14138
14752
|
}
|
|
@@ -14287,9 +14901,11 @@ void addCachedActiveCandidateRule(ActiveRulePlan &plan,
|
|
|
14287
14901
|
}
|
|
14288
14902
|
const int bucket = activeRuleBucketFor(rule);
|
|
14289
14903
|
if (bucket >= 0) plan.push(bucket, ruleIndex);
|
|
14904
|
+
#if GEA_CSS_ANIMATIONS
|
|
14290
14905
|
if (rule.propertyKind == CssRuleProperty::Animation &&
|
|
14291
14906
|
rule.pseudoElement == CssRule::PseudoElement::None)
|
|
14292
14907
|
plan.push(kActiveAnimation, ruleIndex);
|
|
14908
|
+
#endif
|
|
14293
14909
|
}
|
|
14294
14910
|
|
|
14295
14911
|
void addActiveCandidateRule(ActiveRulePlan &plan,
|
|
@@ -14312,9 +14928,11 @@ void addActiveCandidateRule(ActiveRulePlan &plan,
|
|
|
14312
14928
|
if (rule.selectorType == CssRule::SelectorType::Selector && !selectorMatchesNode(rule, selectorNode)) return;
|
|
14313
14929
|
const int bucket = activeRuleBucketFor(rule);
|
|
14314
14930
|
if (bucket >= 0) plan.push(bucket, ruleIndex);
|
|
14931
|
+
#if GEA_CSS_ANIMATIONS
|
|
14315
14932
|
if (rule.propertyKind == CssRuleProperty::Animation &&
|
|
14316
14933
|
rule.pseudoElement == CssRule::PseudoElement::None)
|
|
14317
14934
|
plan.push(kActiveAnimation, ruleIndex);
|
|
14935
|
+
#endif
|
|
14318
14936
|
}
|
|
14319
14937
|
|
|
14320
14938
|
void addActiveCandidateRuleBucket(ActiveRulePlan &plan,
|
|
@@ -14467,8 +15085,10 @@ bool applyCachedStyleApplyOpWithSource(NodeHandle node,
|
|
|
14467
15085
|
Node &target = state.nodes[nodeId];
|
|
14468
15086
|
if (rstyle(target.style).bg_grid_axes == 0) return true;
|
|
14469
15087
|
RareStyle &rs = rstyleMut(target.style);
|
|
15088
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
14470
15089
|
if (op.values[0] > 0) rs.bg_grid_step_x = static_cast<std::uint16_t>(op.values[0]);
|
|
14471
15090
|
if (op.values[1] > 0) rs.bg_grid_step_y = static_cast<std::uint16_t>(op.values[1]);
|
|
15091
|
+
#endif
|
|
14472
15092
|
markNodeDisplayCommandsDirtyForStyleApply(nodeId);
|
|
14473
15093
|
return true;
|
|
14474
15094
|
}
|
|
@@ -14705,6 +15325,7 @@ void applyActiveRuleSpansToNode(int node, const ActiveRulePlan &plan, int custom
|
|
|
14705
15325
|
|
|
14706
15326
|
void applyFirstLineBackground(int node, const ActiveRulePlan &plan)
|
|
14707
15327
|
{
|
|
15328
|
+
#if GEA_CSS_FIRST_LINE
|
|
14708
15329
|
NodeRareData *rare = rareDataFor(node);
|
|
14709
15330
|
const FirstLineBackground previous = rare ? rare->firstLineBackground : FirstLineBackground{};
|
|
14710
15331
|
if (rare) rare->firstLineBackground = FirstLineBackground{};
|
|
@@ -14736,7 +15357,7 @@ void applyFirstLineBackground(int node, const ActiveRulePlan &plan)
|
|
|
14736
15357
|
color.alpha = entry->colorAlpha;
|
|
14737
15358
|
color.valid = true;
|
|
14738
15359
|
} else {
|
|
14739
|
-
color = cachedCssColorForValue(entry->value);
|
|
15360
|
+
color = cachedCssColorForValue(*entry->value);
|
|
14740
15361
|
}
|
|
14741
15362
|
if (color.valid) {
|
|
14742
15363
|
rare->firstLineBackground.color = color.nativeColor;
|
|
@@ -14776,17 +15397,15 @@ void applyFirstLineBackground(int node, const ActiveRulePlan &plan)
|
|
|
14776
15397
|
rare->firstLineBackground.lineContextNode = previous.lineContextNode;
|
|
14777
15398
|
rare->firstLineBackground.lineValid = previous.lineValid;
|
|
14778
15399
|
}
|
|
15400
|
+
#else
|
|
15401
|
+
(void)node;
|
|
15402
|
+
(void)plan;
|
|
15403
|
+
#endif
|
|
14779
15404
|
}
|
|
14780
15405
|
|
|
14781
|
-
|
|
15406
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
15407
|
+
void syncPseudoElementsForNode(int node, const ActiveRulePlan &plan)
|
|
14782
15408
|
{
|
|
14783
|
-
ActiveRulePlan ownedPlan;
|
|
14784
|
-
const ActiveRulePlan *plan = existingPlan;
|
|
14785
|
-
if (!plan) {
|
|
14786
|
-
buildActiveRulePlanForNode(node, ownedPlan);
|
|
14787
|
-
plan = &ownedPlan;
|
|
14788
|
-
}
|
|
14789
|
-
|
|
14790
15409
|
const struct {
|
|
14791
15410
|
CssRule::PseudoElement pseudo;
|
|
14792
15411
|
int customBucket;
|
|
@@ -14796,7 +15415,7 @@ void syncPseudoElementsForNode(int node, const ActiveRulePlan *existingPlan = nu
|
|
|
14796
15415
|
{CssRule::PseudoElement::After, kActiveAfterCustom, kActiveAfterRule},
|
|
14797
15416
|
};
|
|
14798
15417
|
for (const auto &entry : pseudoBuckets) {
|
|
14799
|
-
const bool hasMatchingRule = plan
|
|
15418
|
+
const bool hasMatchingRule = plan.has(entry.customBucket) || plan.has(entry.ruleBucket);
|
|
14800
15419
|
if (!hasMatchingRule) {
|
|
14801
15420
|
const int stalePseudoNode = findPseudoChild(node, entry.pseudo);
|
|
14802
15421
|
if (stalePseudoNode >= 0) Tree::instance().removeNode(stalePseudoNode);
|
|
@@ -14812,19 +15431,23 @@ void syncPseudoElementsForNode(int node, const ActiveRulePlan *existingPlan = nu
|
|
|
14812
15431
|
releaseRareStyle(staleRareStyle);
|
|
14813
15432
|
applyInheritedStyleDefaults(pseudoNode);
|
|
14814
15433
|
applyDefaultStyleOverrides(pseudoNode);
|
|
14815
|
-
applyActiveRuleSpansToNode(pseudoNode,
|
|
15434
|
+
applyActiveRuleSpansToNode(pseudoNode, plan, entry.customBucket, entry.ruleBucket);
|
|
14816
15435
|
replayInlineStyles(pseudoNode);
|
|
14817
15436
|
}
|
|
14818
15437
|
}
|
|
14819
15438
|
|
|
15439
|
+
#endif
|
|
15440
|
+
|
|
14820
15441
|
void recomputeNodeClassStyles(int node)
|
|
14821
15442
|
{
|
|
14822
15443
|
auto &state = treeState();
|
|
14823
15444
|
if (node < 0 || node >= state.nodeCount) return;
|
|
14824
15445
|
|
|
14825
15446
|
const ComputedStyle beforeStyle = state.nodes[node].style;
|
|
15447
|
+
#if GEA_CSS_FIRST_LINE
|
|
14826
15448
|
const FirstLineBackground beforeFirstLine = rareDataFor(node)
|
|
14827
15449
|
? rareDataFor(node)->firstLineBackground : FirstLineBackground{};
|
|
15450
|
+
#endif
|
|
14828
15451
|
int16_t staleRareStyle = beforeStyle.rare_style;
|
|
14829
15452
|
const int beforeImageId = state.nodes[node].image_id;
|
|
14830
15453
|
state.styleInvalidationSuppressionDepth++;
|
|
@@ -14859,25 +15482,35 @@ void recomputeNodeClassStyles(int node)
|
|
|
14859
15482
|
_t = recNow();
|
|
14860
15483
|
#endif
|
|
14861
15484
|
replayInlineStyles(node);
|
|
15485
|
+
#if GEA_CSS_FIRST_LINE
|
|
14862
15486
|
applyFirstLineBackground(node, activePlan);
|
|
14863
15487
|
const FirstLineBackground afterFirstLine = rareDataFor(node)
|
|
14864
15488
|
? rareDataFor(node)->firstLineBackground : FirstLineBackground{};
|
|
14865
15489
|
const bool firstLineChanged = beforeFirstLine.hasColor != afterFirstLine.hasColor ||
|
|
14866
15490
|
beforeFirstLine.color != afterFirstLine.color ||
|
|
14867
15491
|
beforeFirstLine.alpha != afterFirstLine.alpha;
|
|
15492
|
+
#else
|
|
15493
|
+
constexpr bool firstLineChanged = false;
|
|
15494
|
+
#endif
|
|
14868
15495
|
// Inline overrides store expression handles, not a newly evaluated pixel
|
|
14869
15496
|
// value. Seed used edges before diffing so custom/font changes schedule
|
|
14870
15497
|
// layout even when the expression handle itself is unchanged.
|
|
15498
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
14871
15499
|
resolveLayoutBoxLengths(node, percentBasisForNode(node, LengthAxis::Horizontal));
|
|
15500
|
+
#endif
|
|
15501
|
+
#if GEA_CSS_ANIMATIONS
|
|
14872
15502
|
primeCssAnimationsForNode(node, &activePlan);
|
|
15503
|
+
#endif
|
|
14873
15504
|
// A runtime `src` attribute's image id is NOT class-derived, so the reset
|
|
14874
15505
|
// above must not lose it: restore it unless a class rule supplied its own
|
|
14875
15506
|
// image. (Re-resolving from the attribute instead would re-read and
|
|
14876
15507
|
// re-decode the file — e.g. a full-page EPUB cover from the SD card — on
|
|
14877
15508
|
// every recompute of the node or any ancestor.)
|
|
15509
|
+
#if GEA_UI_IMAGE_NODES
|
|
14878
15510
|
if (state.nodes[node].type == NodeType::Image && state.nodes[node].image_id < 0 &&
|
|
14879
15511
|
beforeImageId >= 0 && Tree::instance().hasAttribute(node, "src"))
|
|
14880
15512
|
state.nodes[node].image_id = beforeImageId;
|
|
15513
|
+
#endif
|
|
14881
15514
|
state.styleInvalidationSuppressionDepth--;
|
|
14882
15515
|
markClassRecomputeStyleDiff(node, beforeStyle, beforeImageId, firstLineChanged);
|
|
14883
15516
|
if (staleRareStyle >= 0 && state.nodes[node].style.rare_style != staleRareStyle)
|
|
@@ -14886,9 +15519,11 @@ void recomputeNodeClassStyles(int node)
|
|
|
14886
15519
|
g_profMiscUs += recNow() - _t;
|
|
14887
15520
|
_t = recNow();
|
|
14888
15521
|
#endif
|
|
15522
|
+
#if GEA_CSS_PSEUDO_ELEMENTS
|
|
14889
15523
|
if (!isGeneratedPseudoNode(state.nodes[node]) &&
|
|
14890
15524
|
(g_ruleIndex.hasPseudoElementRules || nodeHasGeneratedPseudoChild(node)))
|
|
14891
|
-
syncPseudoElementsForNode(node,
|
|
15525
|
+
syncPseudoElementsForNode(node, activePlan);
|
|
15526
|
+
#endif
|
|
14892
15527
|
#if GEA_RECPROF
|
|
14893
15528
|
g_profPseudoUs += recNow() - _t;
|
|
14894
15529
|
#endif
|
|
@@ -14940,27 +15575,62 @@ void recomputeDescendantClassStyles(int node)
|
|
|
14940
15575
|
// applyInheritedStyleDefaults) or via explicit border-width inheritance.
|
|
14941
15576
|
struct ParentStyleSnapshot {
|
|
14942
15577
|
style_color_t text_color;
|
|
15578
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
14943
15579
|
std::uint8_t text_alpha;
|
|
15580
|
+
#else
|
|
15581
|
+
static constexpr std::uint8_t text_alpha = 255;
|
|
15582
|
+
#endif
|
|
14944
15583
|
std::int16_t font_id;
|
|
14945
|
-
|
|
15584
|
+
decltype(ComputedStyle::font_size) font_size;
|
|
14946
15585
|
std::int16_t font_weight;
|
|
14947
|
-
|
|
15586
|
+
decltype(ComputedStyle::line_height) line_height;
|
|
14948
15587
|
std::int32_t line_height_multiplier;
|
|
14949
15588
|
std::uint8_t text_align;
|
|
15589
|
+
#if GEA_CSS_TEXT_TRANSFORM
|
|
14950
15590
|
std::uint8_t text_transform;
|
|
15591
|
+
#else
|
|
15592
|
+
static constexpr std::uint8_t text_transform = 0;
|
|
15593
|
+
#endif
|
|
14951
15594
|
std::uint8_t white_space;
|
|
15595
|
+
#if GEA_CSS_VISIBILITY
|
|
14952
15596
|
std::uint8_t visibility;
|
|
15597
|
+
#else
|
|
15598
|
+
static constexpr std::uint8_t visibility = 0;
|
|
15599
|
+
#endif
|
|
15600
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
14953
15601
|
std::array<int, 4> border_widths;
|
|
15602
|
+
#else
|
|
15603
|
+
std::array<decltype(ComputedStyle::border_width), 1> border_widths;
|
|
15604
|
+
#endif
|
|
14954
15605
|
};
|
|
14955
15606
|
|
|
14956
15607
|
ParentStyleSnapshot snapshotParentStyle(const ComputedStyle &s)
|
|
14957
15608
|
{
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
15609
|
+
ParentStyleSnapshot out;
|
|
15610
|
+
out.text_color = s.text_color;
|
|
15611
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
15612
|
+
out.text_alpha = s.text_alpha;
|
|
15613
|
+
#endif
|
|
15614
|
+
out.font_id = s.font_id;
|
|
15615
|
+
out.font_size = s.font_size;
|
|
15616
|
+
out.font_weight = s.font_weight;
|
|
15617
|
+
out.line_height = s.line_height;
|
|
15618
|
+
out.line_height_multiplier = s.line_height_multiplier;
|
|
15619
|
+
out.text_align = s.text_align;
|
|
15620
|
+
#if GEA_CSS_TEXT_TRANSFORM
|
|
15621
|
+
out.text_transform = s.text_transform;
|
|
15622
|
+
#endif
|
|
15623
|
+
out.white_space = s.white_space;
|
|
15624
|
+
#if GEA_CSS_VISIBILITY
|
|
15625
|
+
out.visibility = s.visibility;
|
|
15626
|
+
#endif
|
|
15627
|
+
#if GEA_CSS_SIDE_BORDERS
|
|
15628
|
+
out.border_widths = {computedBorderWidth(s, 0), computedBorderWidth(s, 1),
|
|
15629
|
+
computedBorderWidth(s, 2), computedBorderWidth(s, 3)};
|
|
15630
|
+
#else
|
|
15631
|
+
out.border_widths = {s.border_width};
|
|
15632
|
+
#endif
|
|
15633
|
+
return out;
|
|
14964
15634
|
}
|
|
14965
15635
|
|
|
14966
15636
|
bool parentStylesDiffer(const ParentStyleSnapshot &a, const ParentStyleSnapshot &b)
|
|
@@ -14997,7 +15667,10 @@ bool classChangeAffectsDescendants(int node)
|
|
|
14997
15667
|
}
|
|
14998
15668
|
|
|
14999
15669
|
struct NodeClassSnapshot {
|
|
15000
|
-
|
|
15670
|
+
// Use the existing whole-source class bound. Unproven/native builds keep
|
|
15671
|
+
// the historical eight-token scratch; overflow still works in every build.
|
|
15672
|
+
static constexpr std::size_t kInlineCount =
|
|
15673
|
+
GEA_UI_CLASS_INLINE_TOKENS < 4 ? GEA_UI_CLASS_INLINE_TOKENS : 8;
|
|
15001
15674
|
|
|
15002
15675
|
CssAtomId inlineTokens[kInlineCount]{};
|
|
15003
15676
|
CssAtomId *spillTokens = nullptr;
|
|
@@ -15046,11 +15719,15 @@ bool classTokensTouchAncestorSelectors(const NodeClassSnapshot &oldTokens, const
|
|
|
15046
15719
|
struct CustomPropertyFingerprint {
|
|
15047
15720
|
CssAtomId nameId = kInvalidCssAtom;
|
|
15048
15721
|
CssAtomId valueAtom = kInvalidCssAtom;
|
|
15049
|
-
|
|
15050
|
-
|
|
15722
|
+
NodeCustomProperty::ColorValue colorStyle = 0;
|
|
15723
|
+
NodeCustomProperty::ColorValue colorNative = 0;
|
|
15724
|
+
#if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
15051
15725
|
float lengthValue = 0.0f;
|
|
15726
|
+
#endif
|
|
15052
15727
|
std::uint8_t colorAlpha = 255;
|
|
15728
|
+
#if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
15053
15729
|
std::uint8_t lengthUnit = 0;
|
|
15730
|
+
#endif
|
|
15054
15731
|
std::uint8_t flags = 0;
|
|
15055
15732
|
bool valueEmpty = true;
|
|
15056
15733
|
bool exact = true;
|
|
@@ -15060,13 +15737,15 @@ CustomPropertyFingerprint customPropertyFingerprint(const NodeCustomProperty &pr
|
|
|
15060
15737
|
{
|
|
15061
15738
|
CustomPropertyFingerprint out;
|
|
15062
15739
|
out.nameId = property.nameId;
|
|
15063
|
-
out.valueEmpty = property.value
|
|
15740
|
+
out.valueEmpty = property.value->empty();
|
|
15064
15741
|
out.valueAtom = property.valueAtom;
|
|
15065
15742
|
out.colorStyle = property.colorStyle;
|
|
15066
15743
|
out.colorNative = property.colorNative;
|
|
15744
|
+
#if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
15067
15745
|
out.lengthValue = property.lengthValue;
|
|
15068
|
-
out.colorAlpha = property.colorAlpha;
|
|
15069
15746
|
out.lengthUnit = property.lengthUnit;
|
|
15747
|
+
#endif
|
|
15748
|
+
out.colorAlpha = property.colorAlpha;
|
|
15070
15749
|
out.flags = property.flags;
|
|
15071
15750
|
out.exact = out.valueEmpty || out.valueAtom != kInvalidCssAtom;
|
|
15072
15751
|
return out;
|
|
@@ -15082,14 +15761,16 @@ bool customPropertyFingerprintEqualsValue(const CustomPropertyFingerprint &befor
|
|
|
15082
15761
|
before.colorNative != after.colorNative ||
|
|
15083
15762
|
before.colorAlpha != after.colorAlpha))
|
|
15084
15763
|
return false;
|
|
15764
|
+
#if GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
15085
15765
|
if ((before.flags & 2u) != 0 &&
|
|
15086
15766
|
(before.lengthUnit != after.lengthUnit ||
|
|
15087
15767
|
std::fabs(static_cast<double>(before.lengthValue) -
|
|
15088
15768
|
static_cast<double>(after.lengthValue)) >= 0.0001))
|
|
15089
15769
|
return false;
|
|
15770
|
+
#endif
|
|
15090
15771
|
if (!before.exact) return false; // conservative: recompute descendants rather than risk a stale var().
|
|
15091
|
-
if (before.valueEmpty) return after.value
|
|
15092
|
-
if (after.value
|
|
15772
|
+
if (before.valueEmpty) return after.value->empty();
|
|
15773
|
+
if (after.value->empty()) return false;
|
|
15093
15774
|
return after.valueAtom == before.valueAtom && after.valueAtom != kInvalidCssAtom;
|
|
15094
15775
|
}
|
|
15095
15776
|
|
|
@@ -15320,6 +16001,7 @@ void noteKeyframeRuleRegistrationChanged()
|
|
|
15320
16001
|
invalidateKeyframeRuleIndex();
|
|
15321
16002
|
}
|
|
15322
16003
|
|
|
16004
|
+
#if GEA_CSS_ANIMATIONS
|
|
15323
16005
|
std::vector<std::string> splitCssTokens(const std::string &value)
|
|
15324
16006
|
{
|
|
15325
16007
|
std::vector<std::string> out;
|
|
@@ -15625,6 +16307,7 @@ CssAnimationSpec animationSpecForNodeFromActivePlan(const ActiveRulePlan &plan)
|
|
|
15625
16307
|
double currentStyleValue(const Node &node, Property property)
|
|
15626
16308
|
{
|
|
15627
16309
|
switch (property) {
|
|
16310
|
+
#if GEA_CSS_TRANSFORMS
|
|
15628
16311
|
case Property::TransformRotate: return static_cast<double>(rstyle(node.style).transform_rotate) / 10.0;
|
|
15629
16312
|
case Property::TransformRotateX: return static_cast<double>(rstyle(node.style).transform_rotate_x) / 10.0;
|
|
15630
16313
|
case Property::TransformRotateY: return static_cast<double>(rstyle(node.style).transform_rotate_y) / 10.0;
|
|
@@ -15652,7 +16335,8 @@ double currentStyleValue(const Node &node, Property property)
|
|
|
15652
16335
|
case Property::TransformScaleX: return rstyle(node.style).transform_scale_x;
|
|
15653
16336
|
case Property::TransformScaleY: return rstyle(node.style).transform_scale_y;
|
|
15654
16337
|
case Property::TransformScaleZ: return rstyle(node.style).transform_scale_z;
|
|
15655
|
-
|
|
16338
|
+
#endif
|
|
16339
|
+
case Property::FilterBlur: return (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
|
|
15656
16340
|
case Property::Opacity: return node.style.opacity;
|
|
15657
16341
|
case Property::Width: return node.style.width;
|
|
15658
16342
|
case Property::Height: return node.style.height;
|
|
@@ -15660,14 +16344,14 @@ double currentStyleValue(const Node &node, Property property)
|
|
|
15660
16344
|
case Property::HeightPercent: return node.style.height_percent == kUnset ? 0 : node.style.height_percent;
|
|
15661
16345
|
case Property::LineHeight: return node.style.line_height;
|
|
15662
16346
|
case Property::FontWeight: return node.style.font_weight;
|
|
15663
|
-
case Property::Top: return node.style
|
|
15664
|
-
case Property::Right: return node.style
|
|
15665
|
-
case Property::Bottom: return node.style
|
|
15666
|
-
case Property::Left: return node.style
|
|
15667
|
-
case Property::TopPercent: return node.style
|
|
15668
|
-
case Property::RightPercent: return node.style
|
|
15669
|
-
case Property::BottomPercent: return node.style
|
|
15670
|
-
case Property::LeftPercent: return node.style
|
|
16347
|
+
case Property::Top: return GEA_CSS_POSITION_PX_0(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PX_0(node.style);
|
|
16348
|
+
case Property::Right: return GEA_CSS_POSITION_PX_1(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PX_1(node.style);
|
|
16349
|
+
case Property::Bottom: return GEA_CSS_POSITION_PX_2(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PX_2(node.style);
|
|
16350
|
+
case Property::Left: return GEA_CSS_POSITION_PX_3(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PX_3(node.style);
|
|
16351
|
+
case Property::TopPercent: return GEA_CSS_POSITION_PERCENT_0(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_0(node.style);
|
|
16352
|
+
case Property::RightPercent: return GEA_CSS_POSITION_PERCENT_1(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_1(node.style);
|
|
16353
|
+
case Property::BottomPercent: return GEA_CSS_POSITION_PERCENT_2(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_2(node.style);
|
|
16354
|
+
case Property::LeftPercent: return GEA_CSS_POSITION_PERCENT_3(node.style) == kUnset ? 0 : GEA_CSS_POSITION_PERCENT_3(node.style);
|
|
15671
16355
|
case Property::BackgroundColor: return node.style.bg_color;
|
|
15672
16356
|
case Property::Color: return node.style.text_color;
|
|
15673
16357
|
default: return 0;
|
|
@@ -15804,6 +16488,7 @@ bool addCompiledPropertyKeyframe(CssAnimationTrackList &tracks, int nodeId, int
|
|
|
15804
16488
|
case CssCompiledKind::DirectProperty: {
|
|
15805
16489
|
const Property property = static_cast<Property>(compiled.values[0]);
|
|
15806
16490
|
switch (property) {
|
|
16491
|
+
#if GEA_CSS_TRANSFORMS
|
|
15807
16492
|
case Property::RotateAngle:
|
|
15808
16493
|
addTrackKeyframe(tracks, property, offset, compiled.values[1] / 10.0); return true;
|
|
15809
16494
|
case Property::RotatePresent:
|
|
@@ -15814,6 +16499,7 @@ bool addCompiledPropertyKeyframe(CssAnimationTrackList &tracks, int nodeId, int
|
|
|
15814
16499
|
case Property::ScaleX:
|
|
15815
16500
|
case Property::ScaleY:
|
|
15816
16501
|
case Property::ScaleZ:
|
|
16502
|
+
#endif
|
|
15817
16503
|
case Property::Opacity:
|
|
15818
16504
|
case Property::Width:
|
|
15819
16505
|
case Property::Height:
|
|
@@ -16131,6 +16817,8 @@ void startAnimationForNode(int nodeId, const CssAnimationSpec &spec, std::uint32
|
|
|
16131
16817
|
}
|
|
16132
16818
|
}
|
|
16133
16819
|
|
|
16820
|
+
#endif
|
|
16821
|
+
|
|
16134
16822
|
} // namespace
|
|
16135
16823
|
|
|
16136
16824
|
bool StyleValues::hasTextBackgroundClip(const ComputedStyle &style)
|
|
@@ -16175,7 +16863,7 @@ BackgroundPlacement StyleValues::backgroundPlacement(const ComputedStyle &style,
|
|
|
16175
16863
|
}
|
|
16176
16864
|
if (out.origin != 0) {
|
|
16177
16865
|
int inset[4];
|
|
16178
|
-
for (int i = 0; i < 4; ++i) inset[i] =
|
|
16866
|
+
for (int i = 0; i < 4; ++i) inset[i] = computedBorderWidth(node.style, i) +
|
|
16179
16867
|
(out.origin == 2 ? std::max<int>(0, node.style.padding[i]) : 0);
|
|
16180
16868
|
x += inset[3]; y += inset[0]; width -= inset[1]+inset[3]; height -= inset[0]+inset[2];
|
|
16181
16869
|
}
|
|
@@ -16377,22 +17065,30 @@ void Style::cssScale(double value) const
|
|
|
16377
17065
|
void StyleSheet::clear()
|
|
16378
17066
|
{
|
|
16379
17067
|
rules().clear();
|
|
17068
|
+
#if GEA_CSS_ANIMATIONS
|
|
16380
17069
|
keyframeRules().clear();
|
|
17070
|
+
#endif
|
|
16381
17071
|
g_ruleRegistrationBatchDepth = 0;
|
|
16382
17072
|
g_ruleRegistrationRulesChanged = false;
|
|
16383
17073
|
g_ruleRegistrationKeyframesChanged = false;
|
|
17074
|
+
#if GEA_CSS_ANIMATIONS
|
|
16384
17075
|
clearKeyframeRuleIndex();
|
|
17076
|
+
#endif
|
|
16385
17077
|
clearCssRuleTexts();
|
|
16386
17078
|
compiledCssValues().clear();
|
|
16387
17079
|
clearInlineCompiledStyleCache();
|
|
17080
|
+
#if GEA_CSS_ANIMATIONS
|
|
16388
17081
|
compiledCssAnimationSpecs().clear();
|
|
17082
|
+
#endif
|
|
16389
17083
|
clearCompiledCssBackgrounds();
|
|
16390
17084
|
clearCompiledCssGridTemplates();
|
|
16391
17085
|
clearCompiledCssLengthExpressions();
|
|
16392
17086
|
clearCompiledCssLengthCache();
|
|
16393
17087
|
clearCompiledCssColorCache();
|
|
16394
17088
|
clearMediaConditionPlans();
|
|
17089
|
+
#if GEA_CSS_ANIMATIONS
|
|
16395
17090
|
gea::css::AnimationEngine::instance().clear();
|
|
17091
|
+
#endif
|
|
16396
17092
|
invalidateRuleIndex();
|
|
16397
17093
|
clearSelectorPartsCache();
|
|
16398
17094
|
g_nodeRefOverflow.clear();
|
|
@@ -16855,6 +17551,7 @@ void StyleSheet::registerStaticAnimationRule(StaticStyleSelectorKind selectorKin
|
|
|
16855
17551
|
StaticStyleAnimationEasing easing,
|
|
16856
17552
|
const char *media)
|
|
16857
17553
|
{
|
|
17554
|
+
#if GEA_CSS_ANIMATIONS
|
|
16858
17555
|
rules().push_back(makeStaticAnimationCssRule(selectorKind,
|
|
16859
17556
|
selector,
|
|
16860
17557
|
name,
|
|
@@ -16866,6 +17563,7 @@ void StyleSheet::registerStaticAnimationRule(StaticStyleSelectorKind selectorKin
|
|
|
16866
17563
|
easing,
|
|
16867
17564
|
media));
|
|
16868
17565
|
noteStyleRuleRegistrationChanged();
|
|
17566
|
+
#endif
|
|
16869
17567
|
}
|
|
16870
17568
|
|
|
16871
17569
|
void StyleSheet::registerStaticCustomLengthRule(StaticStyleSelectorKind selectorKind,
|
|
@@ -16963,7 +17661,27 @@ void StyleSheet::setClassName(NodeHandle node, const std::string &className) con
|
|
|
16963
17661
|
|
|
16964
17662
|
bool StyleSheet::applyPixelLengthProperty(NodeHandle node, StyleDeclaration declaration, double value) const
|
|
16965
17663
|
{
|
|
16966
|
-
|
|
17664
|
+
if (!node || !std::isfinite(value)) return false;
|
|
17665
|
+
// A compiled `${value}px` has the same unit as a parsed CSS length. In
|
|
17666
|
+
// particular, use the size/position rules that clear competing percentage
|
|
17667
|
+
// values and preserve length expressions; a raw numeric setter cannot do that.
|
|
17668
|
+
const CssLengthSpec length{static_cast<float>(value), CssLengthUnit::Px};
|
|
17669
|
+
if (applyRuntimeSizeValue(node, declaration, length, StyleApplicationSource::Inline) ||
|
|
17670
|
+
applyRuntimePositionOffsetValue(node, declaration, length, StyleApplicationSource::Inline) ||
|
|
17671
|
+
applyRuntimeLengthValue(node, declaration, length, StyleApplicationSource::Inline)) return true;
|
|
17672
|
+
if (declaration == CssDeclarationId::Padding || declaration == CssDeclarationId::Margin) {
|
|
17673
|
+
for (int side = 0; side < 4; ++side) setBoxLengthValue(node, declaration == CssDeclarationId::Padding, side, length, StyleApplicationSource::Inline);
|
|
17674
|
+
return true;
|
|
17675
|
+
}
|
|
17676
|
+
if (declaration == CssDeclarationId::BorderRadius) {
|
|
17677
|
+
for (int corner = 0; corner < 4; ++corner) setCompiledBorderRadiusCornerValue(node, corner, length, StyleApplicationSource::Inline);
|
|
17678
|
+
return true;
|
|
17679
|
+
}
|
|
17680
|
+
if (declaration >= CssDeclarationId::BorderTopLeftRadius && declaration <= CssDeclarationId::BorderBottomLeftRadius) {
|
|
17681
|
+
setCompiledBorderRadiusCornerValue(node, static_cast<int>(declaration) - static_cast<int>(CssDeclarationId::BorderTopLeftRadius), length, StyleApplicationSource::Inline);
|
|
17682
|
+
return true;
|
|
17683
|
+
}
|
|
17684
|
+
return false;
|
|
16967
17685
|
}
|
|
16968
17686
|
|
|
16969
17687
|
bool StyleSheet::applyNumberProperty(NodeHandle node, const char *property, double value) const
|
|
@@ -17013,6 +17731,7 @@ void StyleSheet::recomputeSubtree(int nodeId) const
|
|
|
17013
17731
|
|
|
17014
17732
|
void StyleSheet::startCssAnimations(std::uint32_t nowMs) const
|
|
17015
17733
|
{
|
|
17734
|
+
#if GEA_CSS_ANIMATIONS
|
|
17016
17735
|
rebuildRuleIndexIfNeeded();
|
|
17017
17736
|
if (g_ruleIndex.animationRules.empty()) return;
|
|
17018
17737
|
auto &state = treeState();
|
|
@@ -17021,6 +17740,9 @@ void StyleSheet::startCssAnimations(std::uint32_t nowMs) const
|
|
|
17021
17740
|
const CssAnimationSpec spec = animationSpecForNode(node);
|
|
17022
17741
|
startAnimationForNode(node, spec, nowMs);
|
|
17023
17742
|
}
|
|
17743
|
+
#else
|
|
17744
|
+
(void)nowMs;
|
|
17745
|
+
#endif
|
|
17024
17746
|
}
|
|
17025
17747
|
|
|
17026
17748
|
void Tree::setClassName(int node, const std::string &className)
|
|
@@ -17080,7 +17802,7 @@ const char *tagFromId(int16_t id)
|
|
|
17080
17802
|
// When GEA_EMBEDDED_RARE_STYLE_INLINE is enabled, the rare fields are embedded in
|
|
17081
17803
|
// ComputedStyle, so these become trivial (rstyleMut returns the embedded struct;
|
|
17082
17804
|
// release/reset are no-ops) and the pool + free list are compiled out.
|
|
17083
|
-
#if !GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
17805
|
+
#if GEA_CSS_RARE_STYLE && !GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
17084
17806
|
namespace {
|
|
17085
17807
|
std::vector<int16_t> &rareStyleFreeList()
|
|
17086
17808
|
{
|
|
@@ -17092,11 +17814,14 @@ std::vector<int16_t> &rareStyleFreeList()
|
|
|
17092
17814
|
|
|
17093
17815
|
RareStyle &rstyleMut(ComputedStyle &style)
|
|
17094
17816
|
{
|
|
17817
|
+
#if GEA_CSS_RARE_STYLE
|
|
17095
17818
|
// rstyleMut is also used by native setup/tests that write transform fields
|
|
17096
17819
|
// directly, bypassing Tree::setStyle's transform-cache invalidation.
|
|
17820
|
+
#if GEA_CSS_TRANSFORMS
|
|
17097
17821
|
auto &state = treeState();
|
|
17098
17822
|
state.transformScanSerial = ~0ull;
|
|
17099
17823
|
state.transformScanValid = false;
|
|
17824
|
+
#endif
|
|
17100
17825
|
#if GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
17101
17826
|
return style.rare;
|
|
17102
17827
|
#else
|
|
@@ -17114,10 +17839,16 @@ RareStyle &rstyleMut(ComputedStyle &style)
|
|
|
17114
17839
|
style.rare_style = handle;
|
|
17115
17840
|
return pool[static_cast<std::size_t>(handle)];
|
|
17116
17841
|
#endif
|
|
17842
|
+
#else
|
|
17843
|
+
(void)style;
|
|
17844
|
+
static RareStyle empty;
|
|
17845
|
+
return empty;
|
|
17846
|
+
#endif
|
|
17117
17847
|
}
|
|
17118
17848
|
|
|
17119
17849
|
void releaseRareStyle(int16_t &handle)
|
|
17120
17850
|
{
|
|
17851
|
+
#if GEA_CSS_RARE_STYLE
|
|
17121
17852
|
#if GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
17122
17853
|
(void)handle; // embedded rare is freed with the node; nothing to release
|
|
17123
17854
|
#else
|
|
@@ -17126,15 +17857,22 @@ void releaseRareStyle(int16_t &handle)
|
|
|
17126
17857
|
rareStyleFreeList().push_back(handle);
|
|
17127
17858
|
handle = -1;
|
|
17128
17859
|
#endif
|
|
17860
|
+
#else
|
|
17861
|
+
(void)handle;
|
|
17862
|
+
#endif
|
|
17129
17863
|
}
|
|
17130
17864
|
|
|
17131
17865
|
void resetRareStylePool()
|
|
17132
17866
|
{
|
|
17867
|
+
#if GEA_CSS_RARE_STYLE
|
|
17133
17868
|
#if GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
17134
17869
|
// rare fields are embedded per-node; there is no shared pool to reset.
|
|
17135
17870
|
#else
|
|
17136
17871
|
rareStylePool().clear();
|
|
17137
17872
|
rareStyleFreeList().clear();
|
|
17873
|
+
#endif
|
|
17874
|
+
#else
|
|
17875
|
+
|
|
17138
17876
|
#endif
|
|
17139
17877
|
}
|
|
17140
17878
|
|
|
@@ -17238,12 +17976,36 @@ std::string Tree::className(int node) const
|
|
|
17238
17976
|
return state.classLists[node].value();
|
|
17239
17977
|
}
|
|
17240
17978
|
|
|
17979
|
+
void rescaleInlineCssPixels()
|
|
17980
|
+
{
|
|
17981
|
+
auto &state = treeState();
|
|
17982
|
+
for (int node = 0; node < state.nodeCount; ++node) {
|
|
17983
|
+
auto *rare = rareDataFor(node);
|
|
17984
|
+
if (!rare) continue;
|
|
17985
|
+
auto &values = rare->inlineStyles;
|
|
17986
|
+
for (std::size_t i = 0; i < values.size(); ++i) {
|
|
17987
|
+
const Property property = values.at(i).property;
|
|
17988
|
+
float pixels;
|
|
17989
|
+
if (!values.getCssPixels(property, pixels)) continue;
|
|
17990
|
+
const CssLengthSpec length{pixels, CssLengthUnit::Px};
|
|
17991
|
+
const bool border = property == Property::BorderWidth || property == Property::BorderTopWidth ||
|
|
17992
|
+
property == Property::BorderRightWidth || property == Property::BorderBottomWidth || property == Property::BorderLeftWidth;
|
|
17993
|
+
int resolved = border ? resolveBorderWidth(length, node) : property == Property::FontSize
|
|
17994
|
+
? resolveFontSizeLength(length, node) : resolveCompiledLengthForNode(length, node, LengthAxis::None);
|
|
17995
|
+
if (property >= Property::PaddingTop && property <= Property::PaddingLeft) resolved = std::max(0, resolved);
|
|
17996
|
+
values.set(property, resolved);
|
|
17997
|
+
values.setCssPixels(property, pixels);
|
|
17998
|
+
}
|
|
17999
|
+
}
|
|
18000
|
+
}
|
|
18001
|
+
|
|
17241
18002
|
void setViewportMetrics(int width, int height, double devicePixelRatio)
|
|
17242
18003
|
{
|
|
17243
18004
|
g_viewport_width = width;
|
|
17244
18005
|
g_viewport_height = height;
|
|
17245
18006
|
g_device_pixel_ratio = sanitizedDevicePixelRatio(devicePixelRatio);
|
|
17246
18007
|
clearStaticLengthExpressionResolutionCache();
|
|
18008
|
+
rescaleInlineCssPixels();
|
|
17247
18009
|
invalidateRuleIndex();
|
|
17248
18010
|
recomputeAllClassStyles();
|
|
17249
18011
|
}
|
|
@@ -17259,6 +18021,7 @@ void setDevicePixelRatio(double devicePixelRatio)
|
|
|
17259
18021
|
if (sanitized == g_device_pixel_ratio) return;
|
|
17260
18022
|
g_device_pixel_ratio = sanitized;
|
|
17261
18023
|
clearStaticLengthExpressionResolutionCache();
|
|
18024
|
+
rescaleInlineCssPixels();
|
|
17262
18025
|
invalidateRuleIndex();
|
|
17263
18026
|
recomputeAllClassStyles();
|
|
17264
18027
|
}
|