@geastack/engine 0.1.5 → 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 +86 -30
- package/css/animation.h +64 -0
- package/css/declarative.h +6 -0
- package/css/engine.h +25 -1
- package/image_store.cpp +136 -33
- package/package.json +2 -2
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +42 -39
- package/ui/core.cpp +32 -1
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +282 -0
- package/ui/display_invalidation.cpp +29 -0
- package/ui/flex_balance.h +73 -0
- package/ui/image_node.cpp +33 -28
- package/ui/input.cpp +88 -38
- package/ui/input_render.cpp +17 -13
- package/ui/internal.h +51 -5
- package/ui/layout.cpp +2601 -441
- package/ui/layout_snapshot.cpp +49 -6
- package/ui/node_features.h +18 -0
- package/ui/node_lifecycle.cpp +204 -71
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +930 -70
- package/ui/node_text.h +82 -0
- package/ui/render.cpp +793 -352
- package/ui/renderer_features.h +19 -0
- package/ui/root_scroll_refresh.cpp +46 -24
- package/ui/style.cpp +4155 -1073
- package/ui/style.h +143 -6
- package/ui/style_values.h +16 -0
- package/ui/text.cpp +401 -106
- package/ui/tree_events.cpp +138 -95
- package/ui/tree_events.h +28 -19
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_internal.h +19 -0
- package/ui/tree_nodes.cpp +38 -4
- package/ui/tree_render.cpp +119 -40
- package/ui/tree_scroll_mirror.cpp +26 -0
- package/ui/tree_state.cpp +261 -114
- package/ui/tree_state.h +121 -16
- package/ui/tree_style.cpp +609 -82
- package/ui/view.cpp +720 -299
- package/ui/virtual_keyboard.cpp +10 -3
|
@@ -35,58 +35,45 @@ bool hasTransformState(const Node &node)
|
|
|
35
35
|
// fps before. A transform ADD routes through setStyle → clears the durable cache.
|
|
36
36
|
if (!ViewRenderer::anyTransformActive()) return false;
|
|
37
37
|
const RareStyle &rs = rstyle(node.style); // one pool lookup, not 11
|
|
38
|
-
return rs
|
|
38
|
+
return hasIndividualLinearTransform(rs) || hadIndividualLinearTransform(node.render) ||
|
|
39
|
+
rs.transform_rotate != 0 ||
|
|
39
40
|
node.render.previous_transform_rotate != 0 ||
|
|
40
41
|
rs.transform_rotate_x != 0 ||
|
|
41
42
|
node.render.previous_transform_rotate_x != 0 ||
|
|
42
43
|
rs.transform_rotate_y != 0 ||
|
|
43
44
|
node.render.previous_transform_rotate_y != 0 ||
|
|
44
|
-
rs
|
|
45
|
+
composedTranslateX(rs) != 0 ||
|
|
45
46
|
node.render.previous_transform_translate_x != 0 ||
|
|
46
|
-
rs
|
|
47
|
+
composedTranslateY(rs) != 0 ||
|
|
47
48
|
node.render.previous_transform_translate_y != 0 ||
|
|
48
|
-
rs
|
|
49
|
+
composedTranslateZ(rs) != 0 ||
|
|
49
50
|
node.render.previous_transform_translate_z != 0 ||
|
|
50
|
-
rs
|
|
51
|
+
composedTranslateXPercent(rs) != 0 ||
|
|
51
52
|
node.render.previous_transform_translate_x_percent != 0 ||
|
|
52
|
-
rs
|
|
53
|
+
composedTranslateYPercent(rs) != 0 ||
|
|
53
54
|
node.render.previous_transform_translate_y_percent != 0 ||
|
|
54
55
|
rs.transform_scale_x != 1000 ||
|
|
55
56
|
node.render.previous_transform_scale_x != 1000 ||
|
|
56
57
|
rs.transform_scale_y != 1000 ||
|
|
58
|
+
rs.transform_scale_z != 1000 ||
|
|
57
59
|
node.render.previous_transform_scale_y != 1000 ||
|
|
60
|
+
node.render.previous_transform_scale_z != 1000 ||
|
|
58
61
|
rs.perspective > 0 ||
|
|
59
62
|
node.render.previous_perspective > 0;
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
int alignedAbsoluteOffset(const Node &parent, const Node &child, bool horizontal)
|
|
63
66
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
? (row ? parent.style.justify_content : crossAlign)
|
|
68
|
-
: (row ? crossAlign : parent.style.justify_content);
|
|
69
|
-
const int parentSize = horizontal ? parent.layout.width : parent.layout.height;
|
|
70
|
-
const int childSize = horizontal ? child.layout.width : child.layout.height;
|
|
71
|
-
const int beforeMargin = horizontal ? child.style.margin[3] : child.style.margin[0];
|
|
72
|
-
const int afterMargin = horizontal ? child.style.margin[1] : child.style.margin[2];
|
|
73
|
-
int available = parentSize;
|
|
74
|
-
if (available < 0) available = 0;
|
|
75
|
-
const int occupied = childSize + beforeMargin + afterMargin;
|
|
76
|
-
int free = available - occupied;
|
|
77
|
-
if (free < 0) free = 0;
|
|
78
|
-
|
|
79
|
-
int offset = beforeMargin;
|
|
80
|
-
if (align == 1) offset += free / 2;
|
|
81
|
-
else if (align == 2) offset += free;
|
|
82
|
-
return offset;
|
|
67
|
+
int x, y, width, height;
|
|
68
|
+
LayoutEngine::absoluteContainingArea(parent, child, x, y, width, height);
|
|
69
|
+
return LayoutEngine::alignedAbsoluteOffset(parent, child, horizontal, &parent, horizontal ? x : y, horizontal ? width : height);
|
|
83
70
|
}
|
|
84
71
|
|
|
85
|
-
|
|
72
|
+
template <int side>
|
|
73
|
+
int resolvedPositionOffset(const Node &child, int basis)
|
|
86
74
|
{
|
|
87
|
-
|
|
88
|
-
int
|
|
89
|
-
const int percent = child.style.pos_offset_percent[side];
|
|
75
|
+
int offset = GEA_CSS_POSITION_PX(child.style, side) != kUnset ? GEA_CSS_POSITION_PX(child.style, side) : 0;
|
|
76
|
+
const int percent = GEA_CSS_POSITION_PERCENT(child.style, side);
|
|
90
77
|
if (percent != kUnset) {
|
|
91
78
|
const int numerator = basis * percent;
|
|
92
79
|
offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
|
|
@@ -94,9 +81,10 @@ int resolvedPositionOffset(const Node &parent, const Node &child, int side)
|
|
|
94
81
|
return offset;
|
|
95
82
|
}
|
|
96
83
|
|
|
97
|
-
|
|
84
|
+
template <int side>
|
|
85
|
+
bool hasPositionOffset(const Node &node)
|
|
98
86
|
{
|
|
99
|
-
return node.style
|
|
87
|
+
return GEA_CSS_POSITION_PX(node.style, side) != kUnset || GEA_CSS_POSITION_PERCENT(node.style, side) != kUnset;
|
|
100
88
|
}
|
|
101
89
|
|
|
102
90
|
bool hasExplicitWidth(const Node &node)
|
|
@@ -113,6 +101,12 @@ bool retainableAbsoluteLayoutNode(const Node &node)
|
|
|
113
101
|
{
|
|
114
102
|
if ((!isViewLikeNodeType(node.type) && node.type != NodeType::Image) || node.style.position != 1) return false;
|
|
115
103
|
if (node.parent < 0) return false;
|
|
104
|
+
const Node &parent = Tree::instance().nodes()[node.parent];
|
|
105
|
+
// A static wrapper cannot supply the offsets for a more distant containing
|
|
106
|
+
// block. Let the full positioning pass resolve that ancestor instead.
|
|
107
|
+
if (parent.parent >= 0 && parent.style.position == 0) return false;
|
|
108
|
+
// Grid area geometry and its percentage bases belong to the grid pass.
|
|
109
|
+
if (isDisplayGrid(Tree::instance().nodes()[node.parent].style)) return false;
|
|
116
110
|
if (!hasExplicitWidth(node) || !hasExplicitHeight(node)) return false;
|
|
117
111
|
if (node.first_child >= 0) {
|
|
118
112
|
if (node.style.width != kUnset && node.style.width != node.layout.width) return false;
|
|
@@ -195,7 +189,14 @@ int AbsoluteLeafRefresh::mode()
|
|
|
195
189
|
Node *n = &state.nodes[i];
|
|
196
190
|
if (!n->render.dirty) continue;
|
|
197
191
|
if (n->render.transform_dirty) {
|
|
192
|
+
// A transform can create/remove a fixed descendant's containing block.
|
|
193
|
+
// Reprojecting retained commands alone leaves its percentage sizes and
|
|
194
|
+
// offsets tied to the previous block, so resolve layout first.
|
|
195
|
+
if (state.fixedPositionUsed) return reject(i, 8);
|
|
198
196
|
if (retainableAbsoluteLayoutNode(*n)) continue;
|
|
197
|
+
// A transform update cannot stand in for an accompanying geometry
|
|
198
|
+
// update. This node cannot use refreshPositions(), so lay it out.
|
|
199
|
+
if (n->render.layout_dirty) return reject(i, 9);
|
|
199
200
|
if (n->layout.x != n->layout.previous_x ||
|
|
200
201
|
n->layout.y != n->layout.previous_y ||
|
|
201
202
|
n->layout.width != n->layout.previous_width ||
|
|
@@ -253,23 +254,25 @@ void AbsoluteLeafRefresh::refreshPositions()
|
|
|
253
254
|
if (n->style.width != kUnset) n->layout.width = n->style.width;
|
|
254
255
|
if (n->style.height != kUnset) n->layout.height = n->style.height;
|
|
255
256
|
Node *p = &state.nodes[n->parent];
|
|
257
|
+
int areaX, areaY, areaWidth, areaHeight;
|
|
258
|
+
LayoutEngine::absoluteContainingArea(*p, *n, areaX, areaY, areaWidth, areaHeight);
|
|
256
259
|
const int before_x = n->layout.x;
|
|
257
260
|
const int before_y = n->layout.y;
|
|
258
261
|
int parent_x = p->layout.x;
|
|
259
262
|
if (p->style.overflow == 2 && scrollsOverflowX(p->style)) parent_x -= p->layout.scroll_x;
|
|
260
|
-
if (hasPositionOffset(*n
|
|
261
|
-
n->layout.x = parent_x + resolvedPositionOffset(*
|
|
262
|
-
else if (hasPositionOffset(*n
|
|
263
|
-
n->layout.x = parent_x +
|
|
263
|
+
if (hasPositionOffset<3>(*n))
|
|
264
|
+
n->layout.x = parent_x + areaX + resolvedPositionOffset<3>(*n, areaWidth);
|
|
265
|
+
else if (hasPositionOffset<1>(*n))
|
|
266
|
+
n->layout.x = parent_x + areaX + areaWidth - n->layout.width - resolvedPositionOffset<1>(*n, areaWidth);
|
|
264
267
|
else
|
|
265
268
|
n->layout.x = parent_x + alignedAbsoluteOffset(*p, *n, true);
|
|
266
269
|
|
|
267
270
|
int parent_y = p->layout.y;
|
|
268
271
|
if (p->style.overflow == 2 && scrollsOverflowY(p->style)) parent_y -= p->layout.scroll_y;
|
|
269
|
-
if (hasPositionOffset(*n
|
|
270
|
-
n->layout.y = parent_y + resolvedPositionOffset(*
|
|
271
|
-
else if (hasPositionOffset(*n
|
|
272
|
-
n->layout.y = parent_y +
|
|
272
|
+
if (hasPositionOffset<0>(*n))
|
|
273
|
+
n->layout.y = parent_y + areaY + resolvedPositionOffset<0>(*n, areaHeight);
|
|
274
|
+
else if (hasPositionOffset<2>(*n))
|
|
275
|
+
n->layout.y = parent_y + areaY + areaHeight - n->layout.height - resolvedPositionOffset<2>(*n, areaHeight);
|
|
273
276
|
else
|
|
274
277
|
n->layout.y = parent_y + alignedAbsoluteOffset(*p, *n, false);
|
|
275
278
|
translateDescendantLayouts(state, i, n->layout.x - before_x, n->layout.y - before_y);
|
package/ui/core.cpp
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "document.h"
|
|
5
5
|
#include "refresh_perf.h"
|
|
6
6
|
#include "tree_state.h"
|
|
7
|
+
#include "tree_inspection.h"
|
|
7
8
|
|
|
8
9
|
namespace gea::embedded::ui {
|
|
9
10
|
|
|
@@ -37,16 +38,28 @@ void Tree::markNodeDisplayCommandsDirty(int node)
|
|
|
37
38
|
{
|
|
38
39
|
if (node < 0 || node >= kMaxNodes) return;
|
|
39
40
|
refreshPerfStatsMutable().treeMarkNodeCommandDirtyCalls++;
|
|
40
|
-
treeState()
|
|
41
|
+
auto &state = treeState();
|
|
42
|
+
state.nodeCommandDirty[node] = 1;
|
|
43
|
+
const int root = state.mountedRoot;
|
|
44
|
+
if (root >= 0 && root < state.nodeCount && node < state.nodeCount && isDocumentCanvasRoot(state.nodes[root]) &&
|
|
45
|
+
(node == root || (state.nodes[node].parent == root && std::string_view(tagFromId(state.nodes[node].tag_id)) == "body"))) {
|
|
46
|
+
// The affected canvas pixels extend beyond the root/body layout boxes.
|
|
47
|
+
// A body mutation can also move background ownership to or from html.
|
|
48
|
+
markDisplayListDirty();
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
void Tree::markScrollDirty(int node)
|
|
44
53
|
{
|
|
54
|
+
#if GEA_CSS_SCROLLING
|
|
45
55
|
auto &state = treeState();
|
|
46
56
|
if (node < 0 || node >= kMaxNodes) return;
|
|
47
57
|
state.nodes[node].render.scroll_dirty = 1;
|
|
48
58
|
state.scrollDirtyNodes[node / 64] |= (1ull << (node % 64));
|
|
49
59
|
state.scrollDirtyAny = true;
|
|
60
|
+
#else
|
|
61
|
+
(void)node;
|
|
62
|
+
#endif
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
Node *Tree::nodes()
|
|
@@ -74,6 +87,24 @@ int Tree::mountedRoot() const { return treeState().mountedRoot; }
|
|
|
74
87
|
int Tree::mountedWidth() const { return treeState().mountedWidth; }
|
|
75
88
|
int Tree::mountedHeight() const { return treeState().mountedHeight; }
|
|
76
89
|
|
|
90
|
+
int TreeInspection::nodeCount() { return Tree::instance().nodeCount(); }
|
|
91
|
+
int TreeInspection::mountedWidth() { return Tree::instance().mountedWidth(); }
|
|
92
|
+
bool TreeInspection::hasMountedText(const char *text)
|
|
93
|
+
{
|
|
94
|
+
if (!text) return false;
|
|
95
|
+
const auto &tree = Tree::instance();
|
|
96
|
+
for (int i = 0; i < tree.nodeCount(); ++i) {
|
|
97
|
+
if (tree.node(i).text != text) continue;
|
|
98
|
+
int node = i;
|
|
99
|
+
for (int depth = 0; node >= 0 && node < tree.nodeCount() && depth < tree.nodeCount(); ++depth) {
|
|
100
|
+
if (isDisplayNone(tree.node(node).style)) break;
|
|
101
|
+
if (node == tree.mountedRoot()) return true;
|
|
102
|
+
node = tree.node(node).parent;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
77
108
|
bool Tree::displayListRebuildRequired() const { return treeState().displayListDirty; }
|
|
78
109
|
bool Tree::refreshRequired() const
|
|
79
110
|
{
|
package/ui/css_atom.cpp
CHANGED
|
@@ -145,6 +145,12 @@ CssAtomId internCssAtom(const std::string &text)
|
|
|
145
145
|
return internCssAtom(text.c_str(), text.size());
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
const std::string &cssAtomString(CssAtomId atom)
|
|
149
|
+
{
|
|
150
|
+
auto &table = atomTable();
|
|
151
|
+
return table[static_cast<std::size_t>(atom) < table.size() ? atom : kInvalidCssAtom];
|
|
152
|
+
}
|
|
153
|
+
|
|
148
154
|
const char *cssAtomText(CssAtomId atom)
|
|
149
155
|
{
|
|
150
156
|
auto &table = atomTable();
|
package/ui/css_atom.h
CHANGED
|
@@ -16,6 +16,8 @@ CssAtomId findCssAtom(const std::string &text);
|
|
|
16
16
|
CssAtomId internCssAtom(const char *text, std::size_t length);
|
|
17
17
|
CssAtomId internCssAtom(const char *text);
|
|
18
18
|
CssAtomId internCssAtom(const std::string &text);
|
|
19
|
+
// References remain valid for the process lifetime, including table growth.
|
|
20
|
+
const std::string &cssAtomString(CssAtomId atom);
|
|
19
21
|
const char *cssAtomText(CssAtomId atom);
|
|
20
22
|
|
|
21
23
|
} // namespace gea::embedded::ui
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#ifndef GEA_CSS_PSEUDO_ELEMENTS
|
|
5
|
+
#define GEA_CSS_PSEUDO_ELEMENTS 1
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
// Opaque/default colour proof, generated from the complete source graph.
|
|
9
|
+
#ifndef GEA_CSS_TEXT_ALPHA
|
|
10
|
+
#define GEA_CSS_TEXT_ALPHA 1
|
|
11
|
+
#endif
|
|
12
|
+
#ifndef GEA_CSS_BORDER_ALPHA
|
|
13
|
+
#define GEA_CSS_BORDER_ALPHA 1
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Whole-source animation reachability; older/opaque builds retain support.
|
|
17
|
+
#ifndef GEA_CSS_ANIMATIONS
|
|
18
|
+
#define GEA_CSS_ANIMATIONS 1
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Build-generated reachability facts. The application does not configure these.
|
|
22
|
+
// A driver without CSS analysis retains every feature. All translation units
|
|
23
|
+
// must receive the same facts, because they specialize per-node storage too.
|
|
24
|
+
#ifndef GEA_CSS_TRANSFORMS
|
|
25
|
+
#define GEA_CSS_TRANSFORMS 1
|
|
26
|
+
#endif
|
|
27
|
+
#ifndef GEA_CSS_GRID
|
|
28
|
+
#define GEA_CSS_GRID 1
|
|
29
|
+
#endif
|
|
30
|
+
#ifndef GEA_CSS_FLOATS
|
|
31
|
+
#define GEA_CSS_FLOATS 1
|
|
32
|
+
#endif
|
|
33
|
+
#ifndef GEA_CSS_WRITING_MODE
|
|
34
|
+
#define GEA_CSS_WRITING_MODE 1
|
|
35
|
+
#endif
|
|
36
|
+
#ifndef GEA_CSS_PERCENT_RADIUS
|
|
37
|
+
#define GEA_CSS_PERCENT_RADIUS 1
|
|
38
|
+
#endif
|
|
39
|
+
#ifndef GEA_CSS_PERCENT_GAP
|
|
40
|
+
#define GEA_CSS_PERCENT_GAP 1
|
|
41
|
+
#endif
|
|
42
|
+
#ifndef GEA_CSS_BLINK
|
|
43
|
+
#define GEA_CSS_BLINK 1
|
|
44
|
+
#endif
|
|
45
|
+
#ifndef GEA_CSS_ORDER
|
|
46
|
+
#define GEA_CSS_ORDER 1
|
|
47
|
+
#endif
|
|
48
|
+
#ifndef GEA_CSS_BORDER_RELIEF
|
|
49
|
+
#define GEA_CSS_BORDER_RELIEF 1
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
#ifndef GEA_CSS_OPACITY
|
|
53
|
+
#define GEA_CSS_OPACITY 1
|
|
54
|
+
#endif
|
|
55
|
+
|
|
56
|
+
#ifndef GEA_CSS_TEXT_DECORATION
|
|
57
|
+
#define GEA_CSS_TEXT_DECORATION 1
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#ifndef GEA_CSS_TEXT_TRANSFORM
|
|
61
|
+
#define GEA_CSS_TEXT_TRANSFORM 1
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#ifndef GEA_CSS_VISIBILITY
|
|
65
|
+
#define GEA_CSS_VISIBILITY 1
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#ifndef GEA_CSS_POINTER_EVENTS
|
|
69
|
+
#define GEA_CSS_POINTER_EVENTS 1
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
#ifndef GEA_CSS_MASK
|
|
73
|
+
#define GEA_CSS_MASK 1
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
#ifndef GEA_CSS_IMAGE_FIT
|
|
77
|
+
#define GEA_CSS_IMAGE_FIT 1
|
|
78
|
+
#endif
|
|
79
|
+
|
|
80
|
+
#ifndef GEA_CSS_FILTERS
|
|
81
|
+
#define GEA_CSS_FILTERS 1
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#ifndef GEA_CSS_BOX_SHADOW
|
|
85
|
+
#define GEA_CSS_BOX_SHADOW 1
|
|
86
|
+
#endif
|
|
87
|
+
|
|
88
|
+
#ifndef GEA_CSS_FLEX_WRAP
|
|
89
|
+
#define GEA_CSS_FLEX_WRAP 1
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
#ifndef GEA_CSS_JUSTIFY_ITEMS
|
|
93
|
+
#define GEA_CSS_JUSTIFY_ITEMS 1
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
#ifndef GEA_CSS_ALIGN_CONTENT
|
|
97
|
+
#define GEA_CSS_ALIGN_CONTENT 1
|
|
98
|
+
#endif
|
|
99
|
+
|
|
100
|
+
#ifndef GEA_CSS_ALIGN_SELF
|
|
101
|
+
#define GEA_CSS_ALIGN_SELF 1
|
|
102
|
+
#endif
|
|
103
|
+
|
|
104
|
+
#ifndef GEA_CSS_MIN_WIDTH
|
|
105
|
+
#define GEA_CSS_MIN_WIDTH 1
|
|
106
|
+
#endif
|
|
107
|
+
|
|
108
|
+
#ifndef GEA_CSS_HEIGHT_EXPRESSIONS
|
|
109
|
+
#define GEA_CSS_HEIGHT_EXPRESSIONS 1
|
|
110
|
+
#endif
|
|
111
|
+
|
|
112
|
+
#ifndef GEA_CSS_Z_INDEX
|
|
113
|
+
#define GEA_CSS_Z_INDEX 1
|
|
114
|
+
#endif
|
|
115
|
+
|
|
116
|
+
#ifndef GEA_CSS_ASPECT_RATIO
|
|
117
|
+
#define GEA_CSS_ASPECT_RATIO 1
|
|
118
|
+
#endif
|
|
119
|
+
|
|
120
|
+
#ifndef GEA_CSS_MARGIN_TRIM
|
|
121
|
+
#define GEA_CSS_MARGIN_TRIM 1
|
|
122
|
+
#endif
|
|
123
|
+
|
|
124
|
+
#ifndef GEA_CSS_CONTAINMENT
|
|
125
|
+
#define GEA_CSS_CONTAINMENT 1
|
|
126
|
+
#endif
|
|
127
|
+
|
|
128
|
+
#ifndef GEA_CSS_JUSTIFY_SELF
|
|
129
|
+
#define GEA_CSS_JUSTIFY_SELF 1
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
#ifndef GEA_CSS_FLEX_LINE_COUNT
|
|
133
|
+
#define GEA_CSS_FLEX_LINE_COUNT 1
|
|
134
|
+
#endif
|
|
135
|
+
|
|
136
|
+
#ifndef GEA_CSS_BOX_EXPRESSIONS
|
|
137
|
+
#define GEA_CSS_BOX_EXPRESSIONS 1
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
#ifndef GEA_CSS_AXIS_GAP
|
|
142
|
+
#define GEA_CSS_AXIS_GAP 1
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
#ifndef GEA_CSS_CORNER_RADIUS
|
|
146
|
+
#define GEA_CSS_CORNER_RADIUS 1
|
|
147
|
+
#endif
|
|
148
|
+
|
|
149
|
+
// Uniform-corner applications retain a real array with a single element.
|
|
150
|
+
// Every index becomes the constant zero before C++ compilation: no accessor,
|
|
151
|
+
// branch, decoding or additional load. Arguments must be side-effect free.
|
|
152
|
+
#if GEA_CSS_CORNER_RADIUS
|
|
153
|
+
#define GEA_CSS_RADIUS_COUNT 4
|
|
154
|
+
#define GEA_CSS_RADIUS_INDEX(index) (index)
|
|
155
|
+
#else
|
|
156
|
+
#define GEA_CSS_RADIUS_COUNT 1
|
|
157
|
+
#define GEA_CSS_RADIUS_INDEX(index) 0
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
#ifndef GEA_CSS_FIRST_LINE
|
|
161
|
+
#define GEA_CSS_FIRST_LINE 1
|
|
162
|
+
#endif
|
|
163
|
+
|
|
164
|
+
#ifndef GEA_CSS_SIDE_BORDERS
|
|
165
|
+
#define GEA_CSS_SIDE_BORDERS 1
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
#ifndef GEA_CSS_BACKGROUND_LAYERS
|
|
169
|
+
#define GEA_CSS_BACKGROUND_LAYERS 1
|
|
170
|
+
#endif
|
|
171
|
+
|
|
172
|
+
#ifndef GEA_CSS_LINE_HEIGHT_EXPRESSIONS
|
|
173
|
+
#define GEA_CSS_LINE_HEIGHT_EXPRESSIONS 1
|
|
174
|
+
#endif
|
|
175
|
+
|
|
176
|
+
#ifndef GEA_CSS_SCROLLING
|
|
177
|
+
#define GEA_CSS_SCROLLING 1
|
|
178
|
+
#endif
|
|
179
|
+
|
|
180
|
+
#ifndef GEA_CSS_FLEX_BASIS_EXPRESSIONS
|
|
181
|
+
#define GEA_CSS_FLEX_BASIS_EXPRESSIONS 1
|
|
182
|
+
#endif
|
|
183
|
+
#ifndef GEA_CSS_CUSTOM_PROPERTY_LENGTHS
|
|
184
|
+
#define GEA_CSS_CUSTOM_PROPERTY_LENGTHS 1
|
|
185
|
+
#endif
|
|
186
|
+
|
|
187
|
+
#ifndef GEA_CSS_MAX_HEIGHT
|
|
188
|
+
#define GEA_CSS_MAX_HEIGHT 1
|
|
189
|
+
#endif
|
|
190
|
+
#ifndef GEA_CSS_FLEX_BASIS
|
|
191
|
+
#define GEA_CSS_FLEX_BASIS 1
|
|
192
|
+
#endif
|
|
193
|
+
#ifndef GEA_CSS_OVERFLOW_AXES
|
|
194
|
+
#define GEA_CSS_OVERFLOW_AXES 1
|
|
195
|
+
#endif
|
|
196
|
+
|
|
197
|
+
// Positive range proofs supplied by the build; unknown inputs retain 16 bits.
|
|
198
|
+
#ifndef GEA_CSS_U8_PADDING
|
|
199
|
+
#define GEA_CSS_U8_PADDING 0
|
|
200
|
+
#endif
|
|
201
|
+
#ifndef GEA_CSS_U8_GAP
|
|
202
|
+
#define GEA_CSS_U8_GAP 0
|
|
203
|
+
#endif
|
|
204
|
+
#ifndef GEA_CSS_U8_BORDER
|
|
205
|
+
#define GEA_CSS_U8_BORDER 0
|
|
206
|
+
#endif
|
|
207
|
+
#ifndef GEA_CSS_U8_RADIUS
|
|
208
|
+
#define GEA_CSS_U8_RADIUS 0
|
|
209
|
+
#endif
|
|
210
|
+
#ifndef GEA_CSS_U8_FONT
|
|
211
|
+
#define GEA_CSS_U8_FONT 0
|
|
212
|
+
#endif
|
|
213
|
+
#ifndef GEA_CSS_U8_LINE_HEIGHT
|
|
214
|
+
#define GEA_CSS_U8_LINE_HEIGHT 0
|
|
215
|
+
#endif
|
|
216
|
+
#ifndef GEA_CSS_U8_FLEX
|
|
217
|
+
#define GEA_CSS_U8_FLEX 0
|
|
218
|
+
#endif
|
|
219
|
+
|
|
220
|
+
#define GEA_CSS_U8_BORDER_FLAGS (!GEA_CSS_SIDE_BORDERS && (GEA_CSS_U8_PADDING || GEA_CSS_U8_GAP || GEA_CSS_U8_BORDER || GEA_CSS_U8_RADIUS || GEA_CSS_U8_FONT || GEA_CSS_U8_LINE_HEIGHT || GEA_CSS_U8_FLEX))
|
|
221
|
+
|
|
222
|
+
// Per-edge reachability. Opaque/older builds keep the original four-edge arrays.
|
|
223
|
+
#ifndef GEA_CSS_POSITION_TOP
|
|
224
|
+
#define GEA_CSS_POSITION_TOP 1
|
|
225
|
+
#endif
|
|
226
|
+
#ifndef GEA_CSS_POSITION_TOP_PERCENT
|
|
227
|
+
#define GEA_CSS_POSITION_TOP_PERCENT 1
|
|
228
|
+
#endif
|
|
229
|
+
#ifndef GEA_CSS_POSITION_RIGHT
|
|
230
|
+
#define GEA_CSS_POSITION_RIGHT 1
|
|
231
|
+
#endif
|
|
232
|
+
#ifndef GEA_CSS_POSITION_RIGHT_PERCENT
|
|
233
|
+
#define GEA_CSS_POSITION_RIGHT_PERCENT 1
|
|
234
|
+
#endif
|
|
235
|
+
#ifndef GEA_CSS_POSITION_BOTTOM
|
|
236
|
+
#define GEA_CSS_POSITION_BOTTOM 1
|
|
237
|
+
#endif
|
|
238
|
+
#ifndef GEA_CSS_POSITION_BOTTOM_PERCENT
|
|
239
|
+
#define GEA_CSS_POSITION_BOTTOM_PERCENT 1
|
|
240
|
+
#endif
|
|
241
|
+
#ifndef GEA_CSS_POSITION_LEFT
|
|
242
|
+
#define GEA_CSS_POSITION_LEFT 1
|
|
243
|
+
#endif
|
|
244
|
+
#ifndef GEA_CSS_POSITION_LEFT_PERCENT
|
|
245
|
+
#define GEA_CSS_POSITION_LEFT_PERCENT 1
|
|
246
|
+
#endif
|
|
247
|
+
|
|
248
|
+
#define GEA_CSS_POSITION_PX_ALL (GEA_CSS_POSITION_TOP && GEA_CSS_POSITION_RIGHT && GEA_CSS_POSITION_BOTTOM && GEA_CSS_POSITION_LEFT)
|
|
249
|
+
#if GEA_CSS_POSITION_PX_ALL
|
|
250
|
+
#define GEA_CSS_POSITION_PX_0(style) ((style).pos_offsets[0])
|
|
251
|
+
#define GEA_CSS_POSITION_PX_1(style) ((style).pos_offsets[1])
|
|
252
|
+
#define GEA_CSS_POSITION_PX_2(style) ((style).pos_offsets[2])
|
|
253
|
+
#define GEA_CSS_POSITION_PX_3(style) ((style).pos_offsets[3])
|
|
254
|
+
#else
|
|
255
|
+
#define GEA_CSS_POSITION_PX_0(style) ((style).pos_top)
|
|
256
|
+
#define GEA_CSS_POSITION_PX_1(style) ((style).pos_right)
|
|
257
|
+
#define GEA_CSS_POSITION_PX_2(style) ((style).pos_bottom)
|
|
258
|
+
#define GEA_CSS_POSITION_PX_3(style) ((style).pos_left)
|
|
259
|
+
#endif
|
|
260
|
+
// The selector must be a compile-time constant: no runtime edge mapping.
|
|
261
|
+
#define GEA_CSS_POSITION_PX(style, side) \
|
|
262
|
+
(std::integral_constant<int, (side)>::value == 0 ? GEA_CSS_POSITION_PX_0(style) : \
|
|
263
|
+
std::integral_constant<int, (side)>::value == 1 ? GEA_CSS_POSITION_PX_1(style) : \
|
|
264
|
+
std::integral_constant<int, (side)>::value == 2 ? GEA_CSS_POSITION_PX_2(style) : GEA_CSS_POSITION_PX_3(style))
|
|
265
|
+
|
|
266
|
+
#define GEA_CSS_POSITION_PERCENT_ALL (GEA_CSS_POSITION_TOP_PERCENT && GEA_CSS_POSITION_RIGHT_PERCENT && GEA_CSS_POSITION_BOTTOM_PERCENT && GEA_CSS_POSITION_LEFT_PERCENT)
|
|
267
|
+
#if GEA_CSS_POSITION_PERCENT_ALL
|
|
268
|
+
#define GEA_CSS_POSITION_PERCENT_0(style) ((style).pos_offset_percent[0])
|
|
269
|
+
#define GEA_CSS_POSITION_PERCENT_1(style) ((style).pos_offset_percent[1])
|
|
270
|
+
#define GEA_CSS_POSITION_PERCENT_2(style) ((style).pos_offset_percent[2])
|
|
271
|
+
#define GEA_CSS_POSITION_PERCENT_3(style) ((style).pos_offset_percent[3])
|
|
272
|
+
#else
|
|
273
|
+
#define GEA_CSS_POSITION_PERCENT_0(style) ((style).pos_percent_top)
|
|
274
|
+
#define GEA_CSS_POSITION_PERCENT_1(style) ((style).pos_percent_right)
|
|
275
|
+
#define GEA_CSS_POSITION_PERCENT_2(style) ((style).pos_percent_bottom)
|
|
276
|
+
#define GEA_CSS_POSITION_PERCENT_3(style) ((style).pos_percent_left)
|
|
277
|
+
#endif
|
|
278
|
+
// The selector must be a compile-time constant: no runtime edge mapping.
|
|
279
|
+
#define GEA_CSS_POSITION_PERCENT(style, side) \
|
|
280
|
+
(std::integral_constant<int, (side)>::value == 0 ? GEA_CSS_POSITION_PERCENT_0(style) : \
|
|
281
|
+
std::integral_constant<int, (side)>::value == 1 ? GEA_CSS_POSITION_PERCENT_1(style) : \
|
|
282
|
+
std::integral_constant<int, (side)>::value == 2 ? GEA_CSS_POSITION_PERCENT_2(style) : GEA_CSS_POSITION_PERCENT_3(style))
|
|
@@ -41,8 +41,23 @@ bool DisplayInvalidation::rebuildsNodeDisplayCommands(Property prop)
|
|
|
41
41
|
case Property::Display:
|
|
42
42
|
case Property::Opacity:
|
|
43
43
|
case Property::BackgroundColor:
|
|
44
|
+
case Property::BackgroundAlpha:
|
|
45
|
+
case Property::BackgroundClip:
|
|
46
|
+
case Property::BackgroundImage:
|
|
47
|
+
case Property::Containment:
|
|
44
48
|
case Property::ActiveBackgroundColor:
|
|
45
49
|
case Property::Color:
|
|
50
|
+
case Property::ColorAlpha:
|
|
51
|
+
case Property::BorderAlpha:
|
|
52
|
+
case Property::BorderTopAlpha:
|
|
53
|
+
case Property::BorderRightAlpha:
|
|
54
|
+
case Property::BorderBottomAlpha:
|
|
55
|
+
case Property::BorderLeftAlpha:
|
|
56
|
+
case Property::BorderColorCurrent:
|
|
57
|
+
case Property::BorderTopColorCurrent:
|
|
58
|
+
case Property::BorderRightColorCurrent:
|
|
59
|
+
case Property::BorderBottomColorCurrent:
|
|
60
|
+
case Property::BorderLeftColorCurrent:
|
|
46
61
|
case Property::BorderColor:
|
|
47
62
|
case Property::BorderTopWidth:
|
|
48
63
|
case Property::BorderRightWidth:
|
|
@@ -63,6 +78,19 @@ bool DisplayInvalidation::rebuildsNodeDisplayCommands(Property prop)
|
|
|
63
78
|
case Property::TransformRotate:
|
|
64
79
|
case Property::TransformRotateX:
|
|
65
80
|
case Property::TransformRotateY:
|
|
81
|
+
case Property::TranslateX:
|
|
82
|
+
case Property::RotateAngle:
|
|
83
|
+
case Property::RotateAxisX:
|
|
84
|
+
case Property::RotateAxisY:
|
|
85
|
+
case Property::RotateAxisZ:
|
|
86
|
+
case Property::ScaleX:
|
|
87
|
+
case Property::ScaleY:
|
|
88
|
+
case Property::ScaleZ:
|
|
89
|
+
case Property::TransformTranslateOuterAxes:
|
|
90
|
+
case Property::TranslateY:
|
|
91
|
+
case Property::TranslateZ:
|
|
92
|
+
case Property::TranslateXPercent:
|
|
93
|
+
case Property::TranslateYPercent:
|
|
66
94
|
case Property::TransformTranslateX:
|
|
67
95
|
case Property::TransformTranslateY:
|
|
68
96
|
case Property::TransformTranslateZ:
|
|
@@ -70,6 +98,7 @@ bool DisplayInvalidation::rebuildsNodeDisplayCommands(Property prop)
|
|
|
70
98
|
case Property::TransformTranslateYPercent:
|
|
71
99
|
case Property::TransformScaleX:
|
|
72
100
|
case Property::TransformScaleY:
|
|
101
|
+
case Property::TransformScaleZ:
|
|
73
102
|
case Property::TransformOriginX:
|
|
74
103
|
case Property::TransformOriginY:
|
|
75
104
|
case Property::Perspective:
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
namespace gea::embedded::ui {
|
|
9
|
+
|
|
10
|
+
// CSS Flexbox 2, 9.7: contiguous, nonempty lines minimizing squared unused
|
|
11
|
+
// space. Sizes include margins and are floored at zero only for balancing.
|
|
12
|
+
// Returns exclusive line ends. An oversized item occupies a line by itself.
|
|
13
|
+
inline std::vector<int> balancedFlexLineEnds(const std::vector<int> &sizes, int available, int gap, int minimumLines)
|
|
14
|
+
{
|
|
15
|
+
const int n = static_cast<int>(sizes.size());
|
|
16
|
+
if (!n) return {};
|
|
17
|
+
std::vector<std::int64_t> prefix(n + 1);
|
|
18
|
+
for (int i = 0; i < n; ++i) prefix[i + 1] = prefix[i] + std::max(0, sizes[i]) + gap;
|
|
19
|
+
std::vector<int> furthest(n), required(n + 1);
|
|
20
|
+
for (int i = n - 1; i >= 0; --i) {
|
|
21
|
+
const auto bound = std::upper_bound(prefix.begin() + i + 1, prefix.end(), prefix[i] + available + gap);
|
|
22
|
+
furthest[i] = std::max(i + 1, static_cast<int>(bound - prefix.begin()) - 1);
|
|
23
|
+
required[i] = 1 + required[furthest[i]];
|
|
24
|
+
}
|
|
25
|
+
const int count = std::max(required[0], std::min(n, minimumLines));
|
|
26
|
+
if (count == 1) return {n};
|
|
27
|
+
std::vector<int> ends(count);
|
|
28
|
+
if (count == n) {
|
|
29
|
+
for (int i = 0; i < n; ++i) ends[i] = i + 1;
|
|
30
|
+
return ends;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constexpr std::int64_t infinity = INT64_MAX / 4;
|
|
34
|
+
std::vector<std::int64_t> previous(n + 1, infinity), current(n + 1, infinity);
|
|
35
|
+
std::vector<int> choices((count + 1) * (n + 1), -1);
|
|
36
|
+
previous[n] = 0;
|
|
37
|
+
int previousFirst = n;
|
|
38
|
+
for (int lines = 1; lines <= count; ++lines) {
|
|
39
|
+
int first = 0;
|
|
40
|
+
while (required[first] > lines) ++first;
|
|
41
|
+
std::fill(current.begin(), current.end(), infinity);
|
|
42
|
+
// Squared interval sums form a Monge cost matrix: optimal next breaks
|
|
43
|
+
// are monotone. Divide-and-conquer computes a row in O(n log n), avoiding
|
|
44
|
+
// a quadratic search per line. Suffix costs let ties favor the largest
|
|
45
|
+
// FIRST break, then recursively apply the same preference to later lines.
|
|
46
|
+
auto solve = [&](auto &&self, int lo, int hi, int optLo, int optHi) -> void {
|
|
47
|
+
if (lo > hi) return;
|
|
48
|
+
const int start = (lo + hi) / 2;
|
|
49
|
+
const int begin = std::max({start + 1, previousFirst, optLo});
|
|
50
|
+
const int end = std::min({furthest[start], n - lines + 1, optHi});
|
|
51
|
+
int best = begin;
|
|
52
|
+
for (int next = begin; next <= end; ++next) {
|
|
53
|
+
const std::int64_t error = available - (prefix[next] - prefix[start] - gap);
|
|
54
|
+
const std::int64_t cost = previous[next] + error * error;
|
|
55
|
+
if (cost <= current[start]) { current[start] = cost; best = next; }
|
|
56
|
+
}
|
|
57
|
+
choices[lines * (n + 1) + start] = best;
|
|
58
|
+
self(self, lo, start - 1, optLo, best);
|
|
59
|
+
self(self, start + 1, hi, best, optHi);
|
|
60
|
+
};
|
|
61
|
+
solve(solve, first, n - lines, first + 1, n - lines + 1);
|
|
62
|
+
previous.swap(current);
|
|
63
|
+
previousFirst = first;
|
|
64
|
+
}
|
|
65
|
+
int start = 0;
|
|
66
|
+
for (int line = 0; line < count; ++line) {
|
|
67
|
+
start = choices[(count - line) * (n + 1) + start];
|
|
68
|
+
ends[line] = start;
|
|
69
|
+
}
|
|
70
|
+
return ends;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} // namespace gea::embedded::ui
|