@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/layout.cpp
CHANGED
|
@@ -375,7 +375,7 @@ bool flexRowDirection(const ComputedStyle &style);
|
|
|
375
375
|
double preferredRatio(const Node &node)
|
|
376
376
|
{
|
|
377
377
|
float ratio = 0;
|
|
378
|
-
const int bits = rstyle(node.style).aspect_ratio;
|
|
378
|
+
const int bits = (GEA_CSS_ASPECT_RATIO ? rstyle(node.style).aspect_ratio : 0);
|
|
379
379
|
std::memcpy(&ratio, &bits, sizeof(ratio));
|
|
380
380
|
if (!std::isfinite(ratio)) return 0;
|
|
381
381
|
if (ratio < 0 && node.type == NodeType::Image && node.image_id >= 0) return 0;
|
|
@@ -543,7 +543,7 @@ public:
|
|
|
543
543
|
const int child = children_[i];
|
|
544
544
|
int childAvailWidth = isRow_ ? mainAvail_ : padWidth_;
|
|
545
545
|
int childAvailHeight = isRow_ ? padHeight_ : mainAvail_;
|
|
546
|
-
const int count = rstyle(node_.style).flex_line_count;
|
|
546
|
+
const int count = (GEA_CSS_FLEX_LINE_COUNT ? rstyle(node_.style).flex_line_count : 1);
|
|
547
547
|
const Node &item = Tree::instance().nodes()[child];
|
|
548
548
|
if (node_.style.display == kDisplayFlex && node_.style.flex_wrap && count > 1) {
|
|
549
549
|
// The specified count limits available cross space even for normal
|
|
@@ -661,6 +661,7 @@ public:
|
|
|
661
661
|
Node *nodes = Tree::instance().nodes();
|
|
662
662
|
const int parentId = static_cast<int>(&node_ - nodes);
|
|
663
663
|
int firstLineStyleOwner = -1;
|
|
664
|
+
#if GEA_CSS_FIRST_LINE
|
|
664
665
|
for (int ancestor = parentId; ancestor >= 0; ancestor = nodes[ancestor].parent) {
|
|
665
666
|
const NodeRareData *rare = rareDataFor(ancestor);
|
|
666
667
|
if (rare && rare->firstLineBackground.hasColor) {
|
|
@@ -689,7 +690,9 @@ public:
|
|
|
689
690
|
if (!firstInFlow) break;
|
|
690
691
|
}
|
|
691
692
|
}
|
|
693
|
+
#endif
|
|
692
694
|
const bool captureFirstLine = firstLineStyleOwner >= 0;
|
|
695
|
+
#if GEA_CSS_FIRST_LINE
|
|
693
696
|
// Runs that leave this formatting context must not keep an old fragment
|
|
694
697
|
// rectangle. A nested inline flow may write its own first-line fragment
|
|
695
698
|
// later in the same layout pass.
|
|
@@ -699,6 +702,7 @@ public:
|
|
|
699
702
|
const int run = transparentInlineRun(nodes[child]);
|
|
700
703
|
if (run >= 0) if (NodeRareData *rare = rareDataFor(run)) rare->firstLineFragment.valid = false;
|
|
701
704
|
}
|
|
705
|
+
#endif
|
|
702
706
|
std::vector<std::pair<int, int>> staticBoundaries;
|
|
703
707
|
int flowIndex = 0;
|
|
704
708
|
for (int child = node_.first_child; child >= 0; child = nodes[child].next_sibling) {
|
|
@@ -911,6 +915,7 @@ public:
|
|
|
911
915
|
|
|
912
916
|
placeLineItems(nodes, i, j, contentLeft, contentW, lineTop, lineCross, baseline, penStart,
|
|
913
917
|
!lineIsContinuation);
|
|
918
|
+
#if GEA_CSS_FIRST_LINE
|
|
914
919
|
if (i == 0 && captureFirstLine) {
|
|
915
920
|
int firstFormattedLineHeight = actualLineCross;
|
|
916
921
|
if (!firstLineCandidates.empty()) firstFormattedLineHeight = 0;
|
|
@@ -950,6 +955,7 @@ public:
|
|
|
950
955
|
fragment.valid = fragment.width > 0 && fragment.height > 0;
|
|
951
956
|
}
|
|
952
957
|
}
|
|
958
|
+
#endif
|
|
953
959
|
|
|
954
960
|
if (baseline + lineDescent > flowBottom) flowBottom = baseline + lineDescent;
|
|
955
961
|
if (lineTop + lineCross > flowBottom) flowBottom = lineTop + lineCross;
|
|
@@ -1073,7 +1079,7 @@ public:
|
|
|
1073
1079
|
if (hasExplicitWidth(wrapper) || hasExplicitHeight(wrapper)) return -1;
|
|
1074
1080
|
if (wrapper.style.min_width > 0 || wrapper.style.min_height > 0) return -1;
|
|
1075
1081
|
if (wrapper.style.max_width != kUnset || wrapper.style.max_height != kUnset) return -1;
|
|
1076
|
-
if (wrapper.style
|
|
1082
|
+
if (overflowX(wrapper.style) || overflowY(wrapper.style)) return -1;
|
|
1077
1083
|
if (wrapper.style.align_self >= 0 || wrapper.style.flex > 0 ||
|
|
1078
1084
|
hasFlexBasis(wrapper))
|
|
1079
1085
|
return -1;
|
|
@@ -1300,9 +1306,14 @@ public:
|
|
|
1300
1306
|
|
|
1301
1307
|
int crossAlignmentOffset(int index, int count, int free) const
|
|
1302
1308
|
{
|
|
1309
|
+
#if GEA_CSS_FLEX_WRAP
|
|
1310
|
+
const bool wrapReversed = (node_.style.flex_wrap & 3) == 2;
|
|
1311
|
+
#else
|
|
1312
|
+
constexpr bool wrapReversed = false;
|
|
1313
|
+
#endif
|
|
1303
1314
|
// A wrapping container is multi-line even when only one line is occupied.
|
|
1304
1315
|
// Distributed alignments fall back to start/center for overflowing lines.
|
|
1305
|
-
switch (usedAlignment(node_.style.align_content, free,
|
|
1316
|
+
switch (usedAlignment(node_.style.align_content, free, wrapReversed)) {
|
|
1306
1317
|
case 1: return free / 2;
|
|
1307
1318
|
case 2: return free;
|
|
1308
1319
|
case 3:
|
|
@@ -1363,7 +1374,7 @@ private:
|
|
|
1363
1374
|
sizes.push_back(size);
|
|
1364
1375
|
}
|
|
1365
1376
|
const int available = std::min(total, flexWrapLimit());
|
|
1366
|
-
balancedEnds = balancedFlexLineEnds(sizes, available, mainGap_, rstyle(node_.style).flex_line_count);
|
|
1377
|
+
balancedEnds = balancedFlexLineEnds(sizes, available, mainGap_, (GEA_CSS_FLEX_LINE_COUNT ? rstyle(node_.style).flex_line_count : 1));
|
|
1367
1378
|
}
|
|
1368
1379
|
int lineCount = 0, start = 0, written = 0, main = 0, cross = 0, strut = 0;
|
|
1369
1380
|
auto finish = [&] {
|
|
@@ -1410,7 +1421,7 @@ private:
|
|
|
1410
1421
|
// An unconstrained automatic block main size is content-based; the
|
|
1411
1422
|
// viewport height must not manufacture additional columns.
|
|
1412
1423
|
const int available = std::min(total, flexWrapLimit());
|
|
1413
|
-
const auto ends = balancedFlexLineEnds(sizes, available, mainGap_, rstyle(node_.style).flex_line_count);
|
|
1424
|
+
const auto ends = balancedFlexLineEnds(sizes, available, mainGap_, (GEA_CSS_FLEX_LINE_COUNT ? rstyle(node_.style).flex_line_count : 1));
|
|
1414
1425
|
int start = 0, count = 0;
|
|
1415
1426
|
for (const int end : ends) {
|
|
1416
1427
|
int main = 0, cross = 0;
|
|
@@ -1678,13 +1689,18 @@ private:
|
|
|
1678
1689
|
|
|
1679
1690
|
void positionLineChildren(const FlexLine &line, Node *nodes, int mainOffset, int crossOffset, int autoSpace = 0, int autoCount = 0, int distributedFree = 0)
|
|
1680
1691
|
{
|
|
1692
|
+
#if GEA_CSS_FLEX_WRAP
|
|
1693
|
+
const bool wrapReversed = (node_.style.flex_wrap & 3) == 2;
|
|
1694
|
+
#else
|
|
1695
|
+
constexpr bool wrapReversed = false;
|
|
1696
|
+
#endif
|
|
1681
1697
|
const bool flex = node_.style.display == kDisplayFlex;
|
|
1682
1698
|
const bool logicalRow = flexRowDirection(node_.style);
|
|
1683
1699
|
const int mode = writingMode(node_);
|
|
1684
1700
|
const bool blockReversed = mode == 2 || mode == 3;
|
|
1685
1701
|
const bool inlineReversed = rightToLeft(node_) != (mode == 4);
|
|
1686
1702
|
const bool reverseMain = flex && ((node_.style.flex_direction_explicit && node_.style.flex_direction >= 2) != (logicalRow ? inlineReversed : blockReversed));
|
|
1687
|
-
const bool reverseCross = flex && ((
|
|
1703
|
+
const bool reverseCross = flex && ((wrapReversed) != (logicalRow ? blockReversed : inlineReversed));
|
|
1688
1704
|
const int mainBefore = isRow_ ? (reverseMain ? 1 : 3) : (reverseMain ? 2 : 0);
|
|
1689
1705
|
const int mainAfter = (mainBefore + 2) % 4;
|
|
1690
1706
|
const int crossBefore = isRow_ ? (reverseCross ? 2 : 0) : (reverseCross ? 1 : 3);
|
|
@@ -1776,12 +1792,17 @@ private:
|
|
|
1776
1792
|
|
|
1777
1793
|
void positionCrossAxisChild(int child, Node &childNode, int lineCrossSize, int crossMarginBefore, int crossMarginAfter, int crossTotal, int *crossPosition, int lineMaxBaseline, int lineLastBaseline)
|
|
1778
1794
|
{
|
|
1795
|
+
#if GEA_CSS_FLEX_WRAP
|
|
1796
|
+
const bool wrapReversed = (node_.style.flex_wrap & 3) == 2;
|
|
1797
|
+
#else
|
|
1798
|
+
constexpr bool wrapReversed = false;
|
|
1799
|
+
#endif
|
|
1779
1800
|
const int alignment = crossAlignFor(childNode);
|
|
1780
1801
|
int align = physicalSelfAlignment(node_, childNode, alignment, lineCrossSize - crossTotal, !isRow_);
|
|
1781
1802
|
if (align >= 0) {
|
|
1782
|
-
const bool reversed = gridAxisReversed(node_, !isRow_) != (
|
|
1803
|
+
const bool reversed = gridAxisReversed(node_, !isRow_) != (wrapReversed);
|
|
1783
1804
|
if (reversed) align = align == 2 ? 6 : 2;
|
|
1784
|
-
} else align = usedAlignment(alignment, lineCrossSize - crossTotal,
|
|
1805
|
+
} else align = usedAlignment(alignment, lineCrossSize - crossTotal, wrapReversed);
|
|
1785
1806
|
switch (align) {
|
|
1786
1807
|
case 0:
|
|
1787
1808
|
if (isRow_) {
|
|
@@ -1949,7 +1970,9 @@ public:
|
|
|
1949
1970
|
void run()
|
|
1950
1971
|
{
|
|
1951
1972
|
invalidateInlineChildMetadata();
|
|
1973
|
+
#if GEA_CSS_FIRST_LINE
|
|
1952
1974
|
if (NodeRareData *rare = rareDataFor(id_)) rare->firstLineBackground.lineValid = false;
|
|
1975
|
+
#endif
|
|
1953
1976
|
if (isDisplayNone(node_.style)) return;
|
|
1954
1977
|
prepareOwnSize();
|
|
1955
1978
|
|
|
@@ -2041,7 +2064,9 @@ public:
|
|
|
2041
2064
|
{
|
|
2042
2065
|
if (node_.type == NodeType::Text || node_.type == NodeType::Image) return;
|
|
2043
2066
|
invalidateInlineChildMetadata();
|
|
2067
|
+
#if GEA_CSS_FIRST_LINE
|
|
2044
2068
|
if (NodeRareData *rare = rareDataFor(id_)) rare->firstLineBackground.lineValid = false;
|
|
2069
|
+
#endif
|
|
2045
2070
|
|
|
2046
2071
|
const int padWidth = paddedWidth();
|
|
2047
2072
|
const int padHeight = paddedHeight();
|
|
@@ -2109,7 +2134,9 @@ private:
|
|
|
2109
2134
|
NodeRareData *rare = rareDataFor(child);
|
|
2110
2135
|
if (!rare) continue;
|
|
2111
2136
|
rare->inlineStaticPosition.valid = false;
|
|
2137
|
+
#if GEA_CSS_FIRST_LINE
|
|
2112
2138
|
rare->firstLineFragment.valid = false;
|
|
2139
|
+
#endif
|
|
2113
2140
|
}
|
|
2114
2141
|
}
|
|
2115
2142
|
|
|
@@ -2126,7 +2153,9 @@ private:
|
|
|
2126
2153
|
if (splitInlineWrapper(nodes_, c)) {
|
|
2127
2154
|
splitInlineChildren_ = true;
|
|
2128
2155
|
child.layout.x = child.layout.y = child.layout.width = child.layout.height = 0;
|
|
2156
|
+
#if GEA_CSS_SCROLLING
|
|
2129
2157
|
child.layout.scroll_content_width = child.layout.scroll_content_height = 0;
|
|
2158
|
+
#endif
|
|
2130
2159
|
child.layout.memo_pass = child.layout.memo2_pass = 0;
|
|
2131
2160
|
self(self, c);
|
|
2132
2161
|
} else if (count < capacity) children[count++] = c;
|
|
@@ -2180,6 +2209,9 @@ private:
|
|
|
2180
2209
|
{
|
|
2181
2210
|
if (node_.style.display != kDisplayBlock || hasExplicitHeight(node_) || !establishesBlockContext(node_)) return;
|
|
2182
2211
|
int bottom = node_.layout.height - boxInset(node_.style, 2);
|
|
2212
|
+
// With floats absent, no descendant can extend this bound. Keep the
|
|
2213
|
+
// final height clamp without walking the same subtree at every ancestor.
|
|
2214
|
+
#if GEA_CSS_FLOATS
|
|
2183
2215
|
// CSS 2.2 10.6.7 includes floats through ordinary wrappers, but never
|
|
2184
2216
|
// crosses another formatting context. Child layout is still relative;
|
|
2185
2217
|
// offsets below the first level have already been applied by its parent.
|
|
@@ -2190,14 +2222,15 @@ private:
|
|
|
2190
2222
|
int top = y + child.layout.y;
|
|
2191
2223
|
if (parent != id_ && child.style.position == 2) {
|
|
2192
2224
|
LayoutNodePass owner(engine_, parent, 0, 0);
|
|
2193
|
-
if (hasPositionOffset(child
|
|
2194
|
-
else if (hasPositionOffset(child
|
|
2225
|
+
if (hasPositionOffset<0>(child)) top -= owner.resolvedRelativePositionOffset<0>(child);
|
|
2226
|
+
else if (hasPositionOffset<2>(child)) top += owner.resolvedRelativePositionOffset<2>(child);
|
|
2195
2227
|
}
|
|
2196
2228
|
if (child.style.float_side) bottom = std::max(bottom, top + child.layout.height + child.style.margin[2]);
|
|
2197
2229
|
else if (!establishesBlockContext(child)) self(self, id, top);
|
|
2198
2230
|
}
|
|
2199
2231
|
};
|
|
2200
2232
|
visit(visit, id_, 0);
|
|
2233
|
+
#endif
|
|
2201
2234
|
node_.layout.height = clampBorderSize(engine_, node_, bottom + boxInset(node_.style, 2), false);
|
|
2202
2235
|
}
|
|
2203
2236
|
|
|
@@ -2267,7 +2300,7 @@ private:
|
|
|
2267
2300
|
bool trimmedBlockEdge(int owner, int id, bool bottom) const
|
|
2268
2301
|
{
|
|
2269
2302
|
const Node &container = nodes_[owner];
|
|
2270
|
-
const int trim = rstyle(container.style).margin_trim;
|
|
2303
|
+
const int trim = (GEA_CSS_MARGIN_TRIM ? rstyle(container.style).margin_trim : 0);
|
|
2271
2304
|
if (!(trim & 3) || container.style.display != kDisplayBlock || container.style.flex_direction_explicit || !blockBox(nodes_[id])) return false;
|
|
2272
2305
|
for (bool end : {false, true}) {
|
|
2273
2306
|
if (!(trim & (end ? 2 : 1)) || (end != bottom && !collapsesThrough(id))) continue;
|
|
@@ -2403,6 +2436,7 @@ private:
|
|
|
2403
2436
|
bool layoutFloatChildren(int *children, int count, int contentWidth, int contentHeight, bool autosize)
|
|
2404
2437
|
{
|
|
2405
2438
|
if (node_.style.display != kDisplayBlock) return false;
|
|
2439
|
+
#if GEA_CSS_FLOATS
|
|
2406
2440
|
auto containsFloat = [&](auto &&self, int parent) -> bool {
|
|
2407
2441
|
for (int c = nodes_[parent].first_child; c >= 0; c = nodes_[c].next_sibling) {
|
|
2408
2442
|
const Node &child = nodes_[c];
|
|
@@ -2411,12 +2445,17 @@ private:
|
|
|
2411
2445
|
}
|
|
2412
2446
|
return false;
|
|
2413
2447
|
};
|
|
2448
|
+
#endif
|
|
2414
2449
|
bool blocks = false, inlines = false;
|
|
2415
2450
|
for (int i = 0; i < count; ++i) {
|
|
2416
2451
|
if (blockBox(nodes_[children[i]])) blocks = true;
|
|
2417
2452
|
else if (!nodes_[children[i]].style.float_side) inlines = true;
|
|
2418
2453
|
}
|
|
2419
|
-
if (!splitInlineChildren_ && !(blocks && inlines)
|
|
2454
|
+
if (!splitInlineChildren_ && !(blocks && inlines)
|
|
2455
|
+
#if GEA_CSS_FLOATS
|
|
2456
|
+
&& !containsFloat(containsFloat, id_)
|
|
2457
|
+
#endif
|
|
2458
|
+
) return false;
|
|
2420
2459
|
FloatContext context;
|
|
2421
2460
|
const bool measureWidth = autosize && !hasExplicitWidth(node_) &&
|
|
2422
2461
|
(node_.parent >= 0 || node_.style.float_side || intrinsicWidthConstraint(node_)) &&
|
|
@@ -2459,8 +2498,10 @@ private:
|
|
|
2459
2498
|
line.measureChildren();
|
|
2460
2499
|
return line.layoutInlineFlow(false, true);
|
|
2461
2500
|
};
|
|
2501
|
+
#if GEA_CSS_FIRST_LINE
|
|
2462
2502
|
NodeRareData *ownerRare = rareDataFor(id_);
|
|
2463
2503
|
const bool ownerLineWasValid = ownerRare && ownerRare->firstLineBackground.lineValid;
|
|
2504
|
+
#endif
|
|
2464
2505
|
auto extent = layoutRun(contentWidth);
|
|
2465
2506
|
// If even the first unbreakable unit cannot fit beside a float,
|
|
2466
2507
|
// move this line down to the next float boundary and retry.
|
|
@@ -2490,6 +2531,7 @@ private:
|
|
|
2490
2531
|
flowY = nextBottom;
|
|
2491
2532
|
}
|
|
2492
2533
|
if (right - left != contentWidth) extent = layoutRun(std::max(0, right - left));
|
|
2534
|
+
#if GEA_CSS_FIRST_LINE
|
|
2493
2535
|
if (!ownerLineWasValid && ownerRare && ownerRare->firstLineBackground.lineValid)
|
|
2494
2536
|
ownerRare->firstLineBackground.lineY = clampInt16(ownerRare->firstLineBackground.lineY + flowY);
|
|
2495
2537
|
for (int j = i; j < end; ++j) {
|
|
@@ -2506,6 +2548,7 @@ private:
|
|
|
2506
2548
|
}
|
|
2507
2549
|
}
|
|
2508
2550
|
}
|
|
2551
|
+
#endif
|
|
2509
2552
|
for (int j = i; j < end; ++j) {
|
|
2510
2553
|
nodes_[children[j]].layout.x += left;
|
|
2511
2554
|
nodes_[children[j]].layout.y += flowY;
|
|
@@ -2813,6 +2856,7 @@ private:
|
|
|
2813
2856
|
|
|
2814
2857
|
void layoutGridChildren(int *children, int childCount, int padWidth, int padHeight, bool allowAutosizeParent)
|
|
2815
2858
|
{
|
|
2859
|
+
#if GEA_CSS_GRID
|
|
2816
2860
|
if (!childCount && !rstyle(node_.style).grid_column_count && !rstyle(node_.style).grid_row_count) {
|
|
2817
2861
|
if (auto *rare = rareDataFor(id_)) rare->gridLayout.reset();
|
|
2818
2862
|
if (allowAutosizeParent) autosizeEmptyNode();
|
|
@@ -3007,7 +3051,7 @@ private:
|
|
|
3007
3051
|
gridPhysicalRange(node_, true, columnX[p.column.start], tracks.columnEnd[p.column.end - 1], vertical ? cellY : cellX, vertical ? cellHeight : cellWidth);
|
|
3008
3052
|
gridPhysicalRange(node_, false, rowY[p.row.start], tracks.rowEnd[p.row.end - 1], vertical ? cellX : cellY, vertical ? cellWidth : cellHeight);
|
|
3009
3053
|
engine_.layoutNode(child, cellWidth, cellHeight);
|
|
3010
|
-
const int inlineAlign = rstyle(childNode.style).justify_self >= 0 ? rstyle(childNode.style).justify_self : node_.style.justify_items;
|
|
3054
|
+
const int inlineAlign = (GEA_CSS_JUSTIFY_SELF ? rstyle(childNode.style).justify_self : -1) >= 0 ? (GEA_CSS_JUSTIFY_SELF ? rstyle(childNode.style).justify_self : -1) : node_.style.justify_items;
|
|
3011
3055
|
const int blockAlign = childNode.style.align_self >= 0 ? childNode.style.align_self : node_.style.align_items;
|
|
3012
3056
|
const int alignX = vertical ? blockAlign : inlineAlign;
|
|
3013
3057
|
const int alignY = vertical ? inlineAlign : blockAlign;
|
|
@@ -3034,7 +3078,14 @@ private:
|
|
|
3034
3078
|
childNode.layout.x = x;
|
|
3035
3079
|
childNode.layout.y = y;
|
|
3036
3080
|
}
|
|
3037
|
-
|
|
3081
|
+
#else
|
|
3082
|
+
(void)children;
|
|
3083
|
+
(void)childCount;
|
|
3084
|
+
(void)padWidth;
|
|
3085
|
+
(void)padHeight;
|
|
3086
|
+
(void)allowAutosizeParent;
|
|
3087
|
+
#endif
|
|
3088
|
+
}
|
|
3038
3089
|
|
|
3039
3090
|
void prepareOwnSize()
|
|
3040
3091
|
{
|
|
@@ -3079,6 +3130,7 @@ private:
|
|
|
3079
3130
|
if (!hasExplicitHeight(node_)) node_.layout.height = boxInset(node_.style, 0) + boxInset(node_.style, 2);
|
|
3080
3131
|
node_.layout.width = clampLayoutSize(node_, node_.layout.width, true);
|
|
3081
3132
|
node_.layout.height = clampLayoutSize(node_, node_.layout.height, false);
|
|
3133
|
+
#if GEA_CSS_SCROLLING
|
|
3082
3134
|
// A <virtual-list>'s scroll geometry is owned by
|
|
3083
3135
|
// applyVirtualListContentHeight() (invoked right after this in the
|
|
3084
3136
|
// empty-node branch). Its recycled slot pool is entirely
|
|
@@ -3092,10 +3144,12 @@ private:
|
|
|
3092
3144
|
node_.layout.scroll_x = 0;
|
|
3093
3145
|
node_.layout.scroll_y = 0;
|
|
3094
3146
|
}
|
|
3147
|
+
#endif
|
|
3095
3148
|
}
|
|
3096
3149
|
|
|
3097
3150
|
void updateScrollContentSize()
|
|
3098
3151
|
{
|
|
3152
|
+
#if GEA_CSS_SCROLLING
|
|
3099
3153
|
// A <virtual-list>'s scroll geometry is owned by
|
|
3100
3154
|
// applyVirtualListContentHeight() (scroll_content_height = itemCount *
|
|
3101
3155
|
// rowHeight). Its real children are the recycled, position:absolute slot
|
|
@@ -3138,7 +3192,10 @@ private:
|
|
|
3138
3192
|
if (node_.layout.scroll_y < 0) node_.layout.scroll_y = 0;
|
|
3139
3193
|
if (node_.layout.scroll_y > maxScroll) node_.layout.scroll_y = maxScroll;
|
|
3140
3194
|
}
|
|
3141
|
-
|
|
3195
|
+
#else
|
|
3196
|
+
|
|
3197
|
+
#endif
|
|
3198
|
+
}
|
|
3142
3199
|
|
|
3143
3200
|
// A <virtual-list> only materializes a small pool of real child slot nodes
|
|
3144
3201
|
// but scrolls over a virtual content height of itemCount * rowHeight. The
|
|
@@ -3146,6 +3203,7 @@ private:
|
|
|
3146
3203
|
// controls it purely through the template's stylesheet.
|
|
3147
3204
|
void applyVirtualListContentHeight()
|
|
3148
3205
|
{
|
|
3206
|
+
#if GEA_CSS_SCROLLING
|
|
3149
3207
|
if (node_.type != NodeType::VirtualList) return;
|
|
3150
3208
|
int rowHeight = 0;
|
|
3151
3209
|
for (int child = node_.first_child; child >= 0; child = nodes_[child].next_sibling) {
|
|
@@ -3162,7 +3220,10 @@ private:
|
|
|
3162
3220
|
if (maxScroll < 0) maxScroll = 0;
|
|
3163
3221
|
if (node_.layout.scroll_y < 0) node_.layout.scroll_y = 0;
|
|
3164
3222
|
if (node_.layout.scroll_y > maxScroll) node_.layout.scroll_y = maxScroll;
|
|
3165
|
-
|
|
3223
|
+
#else
|
|
3224
|
+
|
|
3225
|
+
#endif
|
|
3226
|
+
}
|
|
3166
3227
|
|
|
3167
3228
|
void captureBlockStaticPositions()
|
|
3168
3229
|
{
|
|
@@ -3218,9 +3279,9 @@ private:
|
|
|
3218
3279
|
{
|
|
3219
3280
|
bool resized = false;
|
|
3220
3281
|
if (!hasExplicitWidth(childNode) && !isIntrinsicSizeExpression(childNode.style.width_expression) &&
|
|
3221
|
-
hasPositionOffset(childNode
|
|
3222
|
-
hasPositionOffset(childNode
|
|
3223
|
-
int width = childAvailWidth - resolvedPositionOffsetWithBasis(childNode,
|
|
3282
|
+
hasPositionOffset<3>(childNode) &&
|
|
3283
|
+
hasPositionOffset<1>(childNode)) {
|
|
3284
|
+
int width = childAvailWidth - resolvedPositionOffsetWithBasis<3>(childNode, childAvailWidth) - resolvedPositionOffsetWithBasis<1>(childNode, childAvailWidth) -
|
|
3224
3285
|
childNode.style.margin[1] - childNode.style.margin[3];
|
|
3225
3286
|
if (width < 0) width = 0;
|
|
3226
3287
|
width = clampLayoutSize(childNode, width, true);
|
|
@@ -3231,9 +3292,9 @@ private:
|
|
|
3231
3292
|
}
|
|
3232
3293
|
|
|
3233
3294
|
if (!hasExplicitHeight(childNode) && !isIntrinsicSizeExpression(childNode.style.height_expression) &&
|
|
3234
|
-
hasPositionOffset(childNode
|
|
3235
|
-
hasPositionOffset(childNode
|
|
3236
|
-
int height = childAvailHeight - resolvedPositionOffsetWithBasis(childNode,
|
|
3295
|
+
hasPositionOffset<0>(childNode) &&
|
|
3296
|
+
hasPositionOffset<2>(childNode)) {
|
|
3297
|
+
int height = childAvailHeight - resolvedPositionOffsetWithBasis<0>(childNode, childAvailHeight) - resolvedPositionOffsetWithBasis<2>(childNode, childAvailHeight) -
|
|
3237
3298
|
childNode.style.margin[0] - childNode.style.margin[2];
|
|
3238
3299
|
if (height < 0) height = 0;
|
|
3239
3300
|
height = clampLayoutSize(childNode, height, false);
|
|
@@ -3250,11 +3311,11 @@ private:
|
|
|
3250
3311
|
{
|
|
3251
3312
|
int x, y, width, height;
|
|
3252
3313
|
LayoutEngine::absoluteContainingArea(node_, childNode, x, y, width, height);
|
|
3253
|
-
if (hasPositionOffset(childNode
|
|
3254
|
-
else if (hasPositionOffset(childNode
|
|
3314
|
+
if (hasPositionOffset<3>(childNode)) childNode.layout.x = x + resolvedPositionOffsetWithBasis<3>(childNode, width) + childNode.style.margin[3];
|
|
3315
|
+
else if (hasPositionOffset<1>(childNode)) childNode.layout.x = x + width - childNode.layout.width - resolvedPositionOffsetWithBasis<1>(childNode, width) - childNode.style.margin[1];
|
|
3255
3316
|
else childNode.layout.x = alignedAbsoluteChildPosition(childNode, true);
|
|
3256
|
-
if (hasPositionOffset(childNode
|
|
3257
|
-
else if (hasPositionOffset(childNode
|
|
3317
|
+
if (hasPositionOffset<0>(childNode)) childNode.layout.y = y + resolvedPositionOffsetWithBasis<0>(childNode, height) + childNode.style.margin[0];
|
|
3318
|
+
else if (hasPositionOffset<2>(childNode)) childNode.layout.y = y + height - childNode.layout.height - resolvedPositionOffsetWithBasis<2>(childNode, height) - childNode.style.margin[2];
|
|
3258
3319
|
else childNode.layout.y = alignedAbsoluteChildPosition(childNode, false);
|
|
3259
3320
|
}
|
|
3260
3321
|
|
|
@@ -3270,42 +3331,46 @@ private:
|
|
|
3270
3331
|
Node &childNode = nodes_[child];
|
|
3271
3332
|
if (splitInlineChildren_ && splitInlineWrapper(nodes_, child)) self(self, child);
|
|
3272
3333
|
if (childNode.style.position != 2) continue;
|
|
3273
|
-
if (hasPositionOffset(childNode
|
|
3274
|
-
childNode.layout.y += resolvedRelativePositionOffset(childNode
|
|
3275
|
-
else if (hasPositionOffset(childNode
|
|
3276
|
-
childNode.layout.y -= resolvedRelativePositionOffset(childNode
|
|
3277
|
-
if (hasPositionOffset(childNode
|
|
3278
|
-
childNode.layout.x += resolvedRelativePositionOffset(childNode
|
|
3279
|
-
else if (hasPositionOffset(childNode
|
|
3280
|
-
childNode.layout.x -= resolvedRelativePositionOffset(childNode
|
|
3334
|
+
if (hasPositionOffset<0>(childNode))
|
|
3335
|
+
childNode.layout.y += resolvedRelativePositionOffset<0>(childNode);
|
|
3336
|
+
else if (hasPositionOffset<2>(childNode))
|
|
3337
|
+
childNode.layout.y -= resolvedRelativePositionOffset<2>(childNode);
|
|
3338
|
+
if (hasPositionOffset<3>(childNode))
|
|
3339
|
+
childNode.layout.x += resolvedRelativePositionOffset<3>(childNode);
|
|
3340
|
+
else if (hasPositionOffset<1>(childNode))
|
|
3341
|
+
childNode.layout.x -= resolvedRelativePositionOffset<1>(childNode);
|
|
3281
3342
|
}
|
|
3282
3343
|
};
|
|
3283
3344
|
apply(apply, id_);
|
|
3284
3345
|
}
|
|
3285
3346
|
|
|
3286
|
-
|
|
3347
|
+
template <int side>
|
|
3348
|
+
bool hasPositionOffset(const Node &node) const
|
|
3287
3349
|
{
|
|
3288
|
-
return node.style
|
|
3350
|
+
return GEA_CSS_POSITION_PX(node.style, side) != kUnset || GEA_CSS_POSITION_PERCENT(node.style, side) != kUnset;
|
|
3289
3351
|
}
|
|
3290
3352
|
|
|
3291
|
-
|
|
3353
|
+
template <int side>
|
|
3354
|
+
int resolvedPositionOffset(const Node &node) const
|
|
3292
3355
|
{
|
|
3293
|
-
return resolvedPositionOffsetWithBasis(node,
|
|
3356
|
+
return resolvedPositionOffsetWithBasis<side>(node, (side == 0 || side == 2) ? node_.layout.height : node_.layout.width);
|
|
3294
3357
|
}
|
|
3295
3358
|
|
|
3296
|
-
|
|
3359
|
+
template <int side>
|
|
3360
|
+
int resolvedRelativePositionOffset(const Node &node) const
|
|
3297
3361
|
{
|
|
3298
3362
|
int basis = (side == 0 || side == 2) ? node_.layout.height : node_.layout.width;
|
|
3299
3363
|
if (isDisplayGrid(node_.style)) {
|
|
3300
3364
|
basis = (side == 0 || side == 2) ? node.layout.height : node.layout.width;
|
|
3301
3365
|
}
|
|
3302
|
-
return resolvedPositionOffsetWithBasis(node,
|
|
3366
|
+
return resolvedPositionOffsetWithBasis<side>(node, basis);
|
|
3303
3367
|
}
|
|
3304
3368
|
|
|
3305
|
-
|
|
3369
|
+
template <int side>
|
|
3370
|
+
int resolvedPositionOffsetWithBasis(const Node &node, int percentBasis) const
|
|
3306
3371
|
{
|
|
3307
|
-
int offset = node.style
|
|
3308
|
-
const int percent = node.style
|
|
3372
|
+
int offset = GEA_CSS_POSITION_PX(node.style, side) != kUnset ? GEA_CSS_POSITION_PX(node.style, side) : 0;
|
|
3373
|
+
const int percent = GEA_CSS_POSITION_PERCENT(node.style, side);
|
|
3309
3374
|
if (percent != kUnset) {
|
|
3310
3375
|
const int numerator = percentBasis * percent;
|
|
3311
3376
|
offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
|
|
@@ -3349,15 +3414,17 @@ int containingBlockForAbsoluteNode(int node, int root, Node *nodes)
|
|
|
3349
3414
|
return root;
|
|
3350
3415
|
}
|
|
3351
3416
|
|
|
3352
|
-
|
|
3417
|
+
template <int side>
|
|
3418
|
+
bool hasPositionOffsetValue(const Node &node)
|
|
3353
3419
|
{
|
|
3354
|
-
return node.style
|
|
3420
|
+
return GEA_CSS_POSITION_PX(node.style, side) != kUnset || GEA_CSS_POSITION_PERCENT(node.style, side) != kUnset;
|
|
3355
3421
|
}
|
|
3356
3422
|
|
|
3357
|
-
|
|
3423
|
+
template <int side>
|
|
3424
|
+
int resolvedPositionOffsetForBasis(const Node &node, int percentBasis)
|
|
3358
3425
|
{
|
|
3359
|
-
int offset = node.style
|
|
3360
|
-
const int percent = node.style
|
|
3426
|
+
int offset = GEA_CSS_POSITION_PX(node.style, side) != kUnset ? GEA_CSS_POSITION_PX(node.style, side) : 0;
|
|
3427
|
+
const int percent = GEA_CSS_POSITION_PERCENT(node.style, side);
|
|
3361
3428
|
if (percent != kUnset) {
|
|
3362
3429
|
const int numerator = percentBasis * percent;
|
|
3363
3430
|
offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
|
|
@@ -3385,11 +3452,11 @@ void stretchAbsoluteNodeToContainingBlock(int node, int containingWidth, int con
|
|
|
3385
3452
|
Node &absolute = nodes[node];
|
|
3386
3453
|
bool resized = false;
|
|
3387
3454
|
if (!hasExplicitWidth(absolute) && !isIntrinsicSizeExpression(absolute.style.width_expression) &&
|
|
3388
|
-
hasPositionOffsetValue(absolute
|
|
3389
|
-
hasPositionOffsetValue(absolute
|
|
3455
|
+
hasPositionOffsetValue<3>(absolute) &&
|
|
3456
|
+
hasPositionOffsetValue<1>(absolute)) {
|
|
3390
3457
|
int width = containingWidth -
|
|
3391
|
-
resolvedPositionOffsetForBasis(absolute,
|
|
3392
|
-
resolvedPositionOffsetForBasis(absolute,
|
|
3458
|
+
resolvedPositionOffsetForBasis<3>(absolute, containingWidth) -
|
|
3459
|
+
resolvedPositionOffsetForBasis<1>(absolute, containingWidth) -
|
|
3393
3460
|
absolute.style.margin[1] - absolute.style.margin[3];
|
|
3394
3461
|
if (width < 0) width = 0;
|
|
3395
3462
|
width = clampLayoutSize(absolute, width, true);
|
|
@@ -3400,11 +3467,11 @@ void stretchAbsoluteNodeToContainingBlock(int node, int containingWidth, int con
|
|
|
3400
3467
|
}
|
|
3401
3468
|
|
|
3402
3469
|
if (!hasExplicitHeight(absolute) && !isIntrinsicSizeExpression(absolute.style.height_expression) &&
|
|
3403
|
-
hasPositionOffsetValue(absolute
|
|
3404
|
-
hasPositionOffsetValue(absolute
|
|
3470
|
+
hasPositionOffsetValue<0>(absolute) &&
|
|
3471
|
+
hasPositionOffsetValue<2>(absolute)) {
|
|
3405
3472
|
int height = containingHeight -
|
|
3406
|
-
resolvedPositionOffsetForBasis(absolute,
|
|
3407
|
-
resolvedPositionOffsetForBasis(absolute,
|
|
3473
|
+
resolvedPositionOffsetForBasis<0>(absolute, containingHeight) -
|
|
3474
|
+
resolvedPositionOffsetForBasis<2>(absolute, containingHeight) -
|
|
3408
3475
|
absolute.style.margin[0] - absolute.style.margin[2];
|
|
3409
3476
|
if (height < 0) height = 0;
|
|
3410
3477
|
height = clampLayoutSize(absolute, height, false);
|
|
@@ -3421,7 +3488,7 @@ void layoutAbsoluteNode(int node, int containing, int areaX, int areaWidth, int
|
|
|
3421
3488
|
{
|
|
3422
3489
|
Node &absolute = nodes[node];
|
|
3423
3490
|
auto &engine = LayoutEngine::instance();
|
|
3424
|
-
const bool left = hasPositionOffsetValue(absolute
|
|
3491
|
+
const bool left = hasPositionOffsetValue<3>(absolute), right = hasPositionOffsetValue<1>(absolute);
|
|
3425
3492
|
if (absolute.type != NodeType::View || writingMode(absolute) != 0 ||
|
|
3426
3493
|
hasExplicitWidth(absolute) || isIntrinsicSizeExpression(absolute.style.width_expression) ||
|
|
3427
3494
|
(left && right) || (preferredRatio(absolute) > 0 && hasExplicitHeight(absolute))) {
|
|
@@ -3437,10 +3504,12 @@ void layoutAbsoluteNode(int node, int containing, int areaX, int areaWidth, int
|
|
|
3437
3504
|
scope.constraint = 2;
|
|
3438
3505
|
engine.layoutNode(node, 32767, areaHeight, true);
|
|
3439
3506
|
const int maximum = std::max(minimum, absolute.layout.width - boxInsets(absolute.style, true));
|
|
3507
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
3440
3508
|
resolveLayoutBoxLengths(node, areaWidth);
|
|
3509
|
+
#endif
|
|
3441
3510
|
int available = areaWidth - absolute.style.margin[3] - absolute.style.margin[1];
|
|
3442
3511
|
if (left || right) {
|
|
3443
|
-
available -=
|
|
3512
|
+
available -= (left ? resolvedPositionOffsetForBasis<3>(absolute, areaWidth) : resolvedPositionOffsetForBasis<1>(absolute, areaWidth));
|
|
3444
3513
|
} else {
|
|
3445
3514
|
int parentX = 0, parentY = 0;
|
|
3446
3515
|
offsetFromAncestorToNode(containing, absolute.parent, nodes, &parentX, &parentY);
|
|
@@ -3472,10 +3541,10 @@ void positionAbsoluteNodeInContainingBlock(int node, int containing, Node *nodes
|
|
|
3472
3541
|
staticX += nodes[id].layout.x; staticY += nodes[id].layout.y;
|
|
3473
3542
|
if (LayoutEngine::isViewportFixed(nodes[id])) break;
|
|
3474
3543
|
}
|
|
3475
|
-
absolute.layout.x = hasPositionOffsetValue(absolute
|
|
3476
|
-
: hasPositionOffsetValue(absolute
|
|
3477
|
-
absolute.layout.y = hasPositionOffsetValue(absolute
|
|
3478
|
-
: hasPositionOffsetValue(absolute
|
|
3544
|
+
absolute.layout.x = hasPositionOffsetValue<3>(absolute) ? resolvedPositionOffsetForBasis<3>(absolute, width) + absolute.style.margin[3]
|
|
3545
|
+
: hasPositionOffsetValue<1>(absolute) ? width - absolute.layout.width - resolvedPositionOffsetForBasis<1>(absolute, width) - absolute.style.margin[1] : staticX;
|
|
3546
|
+
absolute.layout.y = hasPositionOffsetValue<0>(absolute) ? resolvedPositionOffsetForBasis<0>(absolute, height) + absolute.style.margin[0]
|
|
3547
|
+
: hasPositionOffsetValue<2>(absolute) ? height - absolute.layout.height - resolvedPositionOffsetForBasis<2>(absolute, height) - absolute.style.margin[2] : staticY;
|
|
3479
3548
|
return;
|
|
3480
3549
|
}
|
|
3481
3550
|
|
|
@@ -3491,24 +3560,24 @@ void positionAbsoluteNodeInContainingBlock(int node, int containing, Node *nodes
|
|
|
3491
3560
|
stretchAbsoluteNodeToContainingBlock(node, areaWidth, areaHeight, nodes);
|
|
3492
3561
|
int parentOffsetX = 0, parentOffsetY = 0;
|
|
3493
3562
|
offsetFromAncestorToNode(containing, parent, nodes, &parentOffsetX, &parentOffsetY);
|
|
3494
|
-
if (!hasPositionOffsetValue(absolute
|
|
3563
|
+
if (!hasPositionOffsetValue<3>(absolute) && !hasPositionOffsetValue<1>(absolute))
|
|
3495
3564
|
absolute.layout.x = LayoutEngine::alignedAbsoluteOffset(nodes[parent], absolute, true, &containingNode, areaX - parentOffsetX, areaWidth);
|
|
3496
|
-
if (!hasPositionOffsetValue(absolute
|
|
3565
|
+
if (!hasPositionOffsetValue<0>(absolute) && !hasPositionOffsetValue<2>(absolute))
|
|
3497
3566
|
absolute.layout.y = LayoutEngine::alignedAbsoluteOffset(nodes[parent], absolute, false, &containingNode, areaY - parentOffsetY, areaHeight);
|
|
3498
3567
|
|
|
3499
3568
|
int containingX = absolute.layout.x + parentOffsetX;
|
|
3500
|
-
if (hasPositionOffsetValue(absolute
|
|
3501
|
-
containingX = areaX + resolvedPositionOffsetForBasis(absolute,
|
|
3502
|
-
else if (hasPositionOffsetValue(absolute
|
|
3569
|
+
if (hasPositionOffsetValue<3>(absolute))
|
|
3570
|
+
containingX = areaX + resolvedPositionOffsetForBasis<3>(absolute, areaWidth) + absolute.style.margin[3];
|
|
3571
|
+
else if (hasPositionOffsetValue<1>(absolute))
|
|
3503
3572
|
containingX = areaX + areaWidth - absolute.layout.width -
|
|
3504
|
-
resolvedPositionOffsetForBasis(absolute,
|
|
3573
|
+
resolvedPositionOffsetForBasis<1>(absolute, areaWidth) - absolute.style.margin[1];
|
|
3505
3574
|
|
|
3506
3575
|
int containingY = absolute.layout.y + parentOffsetY;
|
|
3507
|
-
if (hasPositionOffsetValue(absolute
|
|
3508
|
-
containingY = areaY + resolvedPositionOffsetForBasis(absolute,
|
|
3509
|
-
else if (hasPositionOffsetValue(absolute
|
|
3576
|
+
if (hasPositionOffsetValue<0>(absolute))
|
|
3577
|
+
containingY = areaY + resolvedPositionOffsetForBasis<0>(absolute, areaHeight) + absolute.style.margin[0];
|
|
3578
|
+
else if (hasPositionOffsetValue<2>(absolute))
|
|
3510
3579
|
containingY = areaY + areaHeight - absolute.layout.height -
|
|
3511
|
-
resolvedPositionOffsetForBasis(absolute,
|
|
3580
|
+
resolvedPositionOffsetForBasis<2>(absolute, areaHeight) - absolute.style.margin[2];
|
|
3512
3581
|
|
|
3513
3582
|
absolute.layout.x = containingX - parentOffsetX;
|
|
3514
3583
|
absolute.layout.y = containingY - parentOffsetY;
|
|
@@ -3584,6 +3653,7 @@ void LayoutEngine::absoluteContainingArea(const Node &parent, const Node &child,
|
|
|
3584
3653
|
|
|
3585
3654
|
bool LayoutEngine::absoluteGridArea(const Node &parent, const Node &child, int &x, int &y, int &width, int &height)
|
|
3586
3655
|
{
|
|
3656
|
+
#if GEA_CSS_GRID
|
|
3587
3657
|
if (!isDisplayGrid(parent.style)) return false;
|
|
3588
3658
|
if (child.style.position == kPositionFixed) {
|
|
3589
3659
|
if (fixedContainingBlock(child) != &parent - Tree::instance().nodes()) return false;
|
|
@@ -3624,6 +3694,15 @@ bool LayoutEngine::absoluteGridArea(const Node &parent, const Node &child, int &
|
|
|
3624
3694
|
gridPhysicalRange(parent, columns, start, std::max(start, end), horizontal ? x : y, horizontal ? width : height);
|
|
3625
3695
|
}
|
|
3626
3696
|
return true;
|
|
3697
|
+
#else
|
|
3698
|
+
(void)parent;
|
|
3699
|
+
(void)child;
|
|
3700
|
+
(void)x;
|
|
3701
|
+
(void)y;
|
|
3702
|
+
(void)width;
|
|
3703
|
+
(void)height;
|
|
3704
|
+
return false;
|
|
3705
|
+
#endif
|
|
3627
3706
|
}
|
|
3628
3707
|
|
|
3629
3708
|
int LayoutEngine::alignedAbsoluteOffset(const Node &parent, const Node &childNode, bool horizontal,
|
|
@@ -3670,7 +3749,7 @@ int LayoutEngine::alignedAbsoluteOffset(const Node &parent, const Node &childNod
|
|
|
3670
3749
|
const bool grid = isDisplayGrid(parent.style), flex = parent.style.display == kDisplayFlex;
|
|
3671
3750
|
const bool row = flex ? flexRowDirection(parent.style) != (writingMode(parent) != 0) : usesRowLayout(parent.style);
|
|
3672
3751
|
const int crossAlign = childNode.style.align_self >= 0 ? childNode.style.align_self : parent.style.align_items;
|
|
3673
|
-
const int inlineAlign = rstyle(childNode.style).justify_self >= 0 ? rstyle(childNode.style).justify_self : parent.style.justify_items;
|
|
3752
|
+
const int inlineAlign = (GEA_CSS_JUSTIFY_SELF ? rstyle(childNode.style).justify_self : -1) >= 0 ? (GEA_CSS_JUSTIFY_SELF ? rstyle(childNode.style).justify_self : -1) : parent.style.justify_items;
|
|
3674
3753
|
int align = grid
|
|
3675
3754
|
? (horizontal == (writingMode(parent) == 0) ? inlineAlign : crossAlign)
|
|
3676
3755
|
: (horizontal ? (row ? parent.style.justify_content : crossAlign)
|
|
@@ -3833,7 +3912,15 @@ std::uint32_t gLayoutPassSerial = 1;
|
|
|
3833
3912
|
|
|
3834
3913
|
void LayoutEngine::beginLayoutPass()
|
|
3835
3914
|
{
|
|
3836
|
-
if (++gLayoutPassSerial ==
|
|
3915
|
+
if (++gLayoutPassSerial == 0x10000u) {
|
|
3916
|
+
// Stored tags are 16-bit. Invalidate before reusing a serial so a node
|
|
3917
|
+
// untouched for a full cycle cannot appear freshly laid out. Keep the
|
|
3918
|
+
// arithmetic counter 32-bit; normal memo field reads remain direct.
|
|
3919
|
+
auto &tree = Tree::instance();
|
|
3920
|
+
for (int id = 0; id < tree.nodeCount(); ++id)
|
|
3921
|
+
tree.nodes()[id].layout.memo_pass = tree.nodes()[id].layout.memo2_pass = 0;
|
|
3922
|
+
gLayoutPassSerial = 1;
|
|
3923
|
+
}
|
|
3837
3924
|
}
|
|
3838
3925
|
|
|
3839
3926
|
void LayoutEngine::layoutNode(int id, int avail_w, int avail_h, bool intrinsicBoxEdges)
|
|
@@ -3879,8 +3966,10 @@ void LayoutEngine::layoutNode(int id, int avail_w, int avail_h, bool intrinsicBo
|
|
|
3879
3966
|
}
|
|
3880
3967
|
const int minimum = keyword == kSizeMaxContent ? 0 : measure(1);
|
|
3881
3968
|
const int maximum = keyword == kSizeMinContent ? minimum : std::max(minimum, measure(2));
|
|
3969
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
3882
3970
|
const int inlineBasis = node.parent >= 0 && writingMode(Tree::instance().nodes()[node.parent]) != 0 ? avail_h : avail_w;
|
|
3883
3971
|
resolveLayoutBoxLengths(id, intrinsicBoxEdges ? 0 : inlineBasis);
|
|
3972
|
+
#endif
|
|
3884
3973
|
const int edges = boxInsets(node.style, horizontal);
|
|
3885
3974
|
const int stretch = std::max(0, (horizontal ? avail_w : avail_h) -
|
|
3886
3975
|
node.style.margin[horizontal ? 1 : 0] - node.style.margin[horizontal ? 3 : 2] - edges);
|
|
@@ -3891,10 +3980,12 @@ void LayoutEngine::layoutNode(int id, int avail_w, int avail_h, bool intrinsicBo
|
|
|
3891
3980
|
}
|
|
3892
3981
|
if (node.type == NodeType::Text && intrinsicWidthConstraint(node) == 1)
|
|
3893
3982
|
avail_w = std::max(avail_w, TextRenderer::minContentWidth(node) + boxInsets(node.style, true));
|
|
3983
|
+
#if GEA_CSS_BOX_EXPRESSIONS
|
|
3894
3984
|
const int inlineBasis = node.parent >= 0 && writingMode(Tree::instance().nodes()[node.parent]) != 0 ? avail_h : avail_w;
|
|
3895
3985
|
if (resolveLayoutBoxLengths(id, intrinsicBoxEdges ? 0 : inlineBasis)) {
|
|
3896
3986
|
node.layout.memo_pass = node.layout.memo2_pass = 0;
|
|
3897
3987
|
}
|
|
3988
|
+
#endif
|
|
3898
3989
|
const bool memoizable = !gIntrinsicSizeScope && !gFlexBasisScope && avail_w >= INT16_MIN && avail_w <= INT16_MAX &&
|
|
3899
3990
|
avail_h >= INT16_MIN && avail_h <= INT16_MAX;
|
|
3900
3991
|
if (memoizable) {
|
|
@@ -3909,13 +4000,11 @@ void LayoutEngine::layoutNode(int id, int avail_w, int avail_h, bool intrinsicBo
|
|
|
3909
4000
|
if (node.layout.memo2_pass == gLayoutPassSerial &&
|
|
3910
4001
|
node.layout.memo2_avail_w == avail_w &&
|
|
3911
4002
|
node.layout.memo2_avail_h == avail_h &&
|
|
3912
|
-
node.layout.
|
|
3913
|
-
node.layout.
|
|
4003
|
+
node.layout.memo_result_w == node.layout.width &&
|
|
4004
|
+
node.layout.memo_result_h == node.layout.height) {
|
|
3914
4005
|
// Promote the hit to the MRU slot.
|
|
3915
4006
|
std::swap(node.layout.memo_avail_w, node.layout.memo2_avail_w);
|
|
3916
4007
|
std::swap(node.layout.memo_avail_h, node.layout.memo2_avail_h);
|
|
3917
|
-
std::swap(node.layout.memo_result_w, node.layout.memo2_result_w);
|
|
3918
|
-
std::swap(node.layout.memo_result_h, node.layout.memo2_result_h);
|
|
3919
4008
|
std::swap(node.layout.memo_pass, node.layout.memo2_pass);
|
|
3920
4009
|
refreshPerfStatsMutable().treeLayoutMemoHits++;
|
|
3921
4010
|
return;
|
|
@@ -3937,9 +4026,8 @@ void LayoutEngine::layoutNode(int id, int avail_w, int avail_h, bool intrinsicBo
|
|
|
3937
4026
|
}
|
|
3938
4027
|
node.layout.memo2_avail_w = node.layout.memo_avail_w;
|
|
3939
4028
|
node.layout.memo2_avail_h = node.layout.memo_avail_h;
|
|
3940
|
-
node.layout.
|
|
3941
|
-
|
|
3942
|
-
node.layout.memo2_pass = node.layout.memo_pass;
|
|
4029
|
+
node.layout.memo2_pass = node.layout.memo_result_w == node.layout.width &&
|
|
4030
|
+
node.layout.memo_result_h == node.layout.height ? node.layout.memo_pass : 0;
|
|
3943
4031
|
if (memoizable) {
|
|
3944
4032
|
node.layout.memo_avail_w = static_cast<std::int16_t>(avail_w);
|
|
3945
4033
|
node.layout.memo_avail_h = static_cast<std::int16_t>(avail_h);
|
|
@@ -4019,7 +4107,7 @@ bool LayoutEngine::layoutNodeScoped(int scope, int treeRoot)
|
|
|
4019
4107
|
if (a.parent >= 0 && a.parent < nodeCount) {
|
|
4020
4108
|
const Node &parent = nodes[a.parent];
|
|
4021
4109
|
if (isDisplayGrid(parent.style)) {
|
|
4022
|
-
const int inlineAlign = rstyle(a.style).justify_self >= 0 ? rstyle(a.style).justify_self : parent.style.justify_items;
|
|
4110
|
+
const int inlineAlign = (GEA_CSS_JUSTIFY_SELF ? rstyle(a.style).justify_self : -1) >= 0 ? (GEA_CSS_JUSTIFY_SELF ? rstyle(a.style).justify_self : -1) : parent.style.justify_items;
|
|
4023
4111
|
const int blockAlign = a.style.align_self >= 0 ? a.style.align_self : parent.style.align_items;
|
|
4024
4112
|
const int alignX = writingMode(parent) == 0 ? inlineAlign : blockAlign;
|
|
4025
4113
|
const int alignY = writingMode(parent) == 0 ? blockAlign : inlineAlign;
|