@geastack/engine 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas.cpp +59 -24
- package/css/engine.h +1 -0
- package/package.json +4 -3
- package/ui/absolute_leaf_refresh.cpp +65 -52
- package/ui/core.cpp +4 -4
- package/ui/css_features.h +87 -0
- package/ui/document.cpp +11 -0
- package/ui/image_node.cpp +24 -24
- package/ui/input.cpp +24 -24
- package/ui/input_render.cpp +27 -27
- package/ui/internal.h +22 -0
- package/ui/layout.cpp +771 -573
- package/ui/layout_snapshot.cpp +1 -1
- package/ui/node_features.h +18 -0
- package/ui/node_lifecycle.cpp +167 -1
- package/ui/node_model.h +216 -56
- package/ui/node_text.h +2 -0
- package/ui/refresh_perf.h +19 -17
- package/ui/render.cpp +203 -189
- package/ui/renderer_features.h +5 -0
- package/ui/root_scroll_refresh.cpp +65 -65
- package/ui/storage_usage.h +45 -0
- package/ui/style.cpp +432 -146
- package/ui/style_values.h +2 -2
- package/ui/text.cpp +151 -153
- package/ui/tree_events.cpp +86 -0
- package/ui/tree_events.h +16 -0
- package/ui/tree_nodes.cpp +21 -17
- package/ui/tree_render.cpp +127 -123
- package/ui/tree_scroll_mirror.cpp +4 -4
- package/ui/tree_state.cpp +78 -6
- package/ui/tree_state.h +49 -4
- package/ui/tree_style.cpp +409 -300
- package/ui/view.cpp +207 -207
- package/ui/virtual_keyboard.cpp +11 -11
package/ui/image_node.cpp
CHANGED
|
@@ -19,16 +19,16 @@ class ImageFitResolver {
|
|
|
19
19
|
public:
|
|
20
20
|
static ImageFitRect resolve(const Node &node, int imageWidth, int imageHeight)
|
|
21
21
|
{
|
|
22
|
-
const int contentWidth = node.layout.width - boxInsets(node.
|
|
23
|
-
const int contentHeight = node.layout.height - boxInsets(node.
|
|
22
|
+
const int contentWidth = node.layout.width - boxInsets(node.computedStyle(), true);
|
|
23
|
+
const int contentHeight = node.layout.height - boxInsets(node.computedStyle(), false);
|
|
24
24
|
ImageFitRect rect{
|
|
25
|
-
node.layout.x + boxInset(node.
|
|
26
|
-
node.layout.y + boxInset(node.
|
|
25
|
+
node.layout.x + boxInset(node.computedStyle(), 3),
|
|
26
|
+
node.layout.y + boxInset(node.computedStyle(), 0),
|
|
27
27
|
contentWidth,
|
|
28
28
|
contentHeight,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
if (node.
|
|
31
|
+
if (node.computedStyle().image_fit == 1 || node.computedStyle().image_fit == 4) {
|
|
32
32
|
const int scaledWidth = (imageWidth * contentHeight) / imageHeight;
|
|
33
33
|
const int scaledHeight = (imageHeight * contentWidth) / imageWidth;
|
|
34
34
|
if (scaledWidth <= contentWidth) {
|
|
@@ -38,12 +38,12 @@ public:
|
|
|
38
38
|
rect.width = contentWidth;
|
|
39
39
|
rect.height = scaledHeight;
|
|
40
40
|
}
|
|
41
|
-
if (node.
|
|
41
|
+
if (node.computedStyle().image_fit == 4 && rect.width >= imageWidth && rect.height >= imageHeight) {
|
|
42
42
|
rect.width = imageWidth;
|
|
43
43
|
rect.height = imageHeight;
|
|
44
44
|
}
|
|
45
45
|
center(node, rect);
|
|
46
|
-
} else if (node.
|
|
46
|
+
} else if (node.computedStyle().image_fit == 2) {
|
|
47
47
|
const int scaledWidth = (imageWidth * contentHeight) / imageHeight;
|
|
48
48
|
const int scaledHeight = (imageHeight * contentWidth) / imageWidth;
|
|
49
49
|
if (scaledWidth >= contentWidth) {
|
|
@@ -54,7 +54,7 @@ public:
|
|
|
54
54
|
rect.height = scaledHeight;
|
|
55
55
|
}
|
|
56
56
|
center(node, rect);
|
|
57
|
-
} else if (node.
|
|
57
|
+
} else if (node.computedStyle().image_fit == 3) {
|
|
58
58
|
rect.width = imageWidth;
|
|
59
59
|
rect.height = imageHeight;
|
|
60
60
|
center(node, rect);
|
|
@@ -66,25 +66,25 @@ public:
|
|
|
66
66
|
private:
|
|
67
67
|
static void center(const Node &node, ImageFitRect &rect)
|
|
68
68
|
{
|
|
69
|
-
rect.x = node.layout.x + boxInset(node.
|
|
70
|
-
rect.y = node.layout.y + boxInset(node.
|
|
69
|
+
rect.x = node.layout.x + boxInset(node.computedStyle(), 3) + (node.layout.width - boxInsets(node.computedStyle(), true) - rect.width) / 2;
|
|
70
|
+
rect.y = node.layout.y + boxInset(node.computedStyle(), 0) + (node.layout.height - boxInsets(node.computedStyle(), false) - rect.height) / 2;
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
bool hasImageRadius(const Node &node)
|
|
75
75
|
{
|
|
76
|
-
return node.
|
|
77
|
-
node.
|
|
78
|
-
node.
|
|
79
|
-
node.
|
|
76
|
+
return node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)] > 0 ||
|
|
77
|
+
node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)] > 0 ||
|
|
78
|
+
node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)] > 0 ||
|
|
79
|
+
node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)] > 0;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
void setScaledBlitRadius(DisplayCommand *cmd, const Node &node)
|
|
83
83
|
{
|
|
84
|
-
cmd->scaledBlit.tl = node.
|
|
85
|
-
cmd->scaledBlit.tr = node.
|
|
86
|
-
cmd->scaledBlit.br = node.
|
|
87
|
-
cmd->scaledBlit.bl = node.
|
|
84
|
+
cmd->scaledBlit.tl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)];
|
|
85
|
+
cmd->scaledBlit.tr = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)];
|
|
86
|
+
cmd->scaledBlit.br = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)];
|
|
87
|
+
cmd->scaledBlit.bl = node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
bool applyAxisAlignedTransform(const Node &node, ImageFitRect &rect)
|
|
@@ -112,12 +112,12 @@ void ImageRenderer::layout(int id)
|
|
|
112
112
|
int iw = images.width(n->image_id);
|
|
113
113
|
int ih = images.height(n->image_id);
|
|
114
114
|
|
|
115
|
-
if (n->
|
|
116
|
-
n->layout.width = iw + boxInsets(n->
|
|
117
|
-
if (n->
|
|
118
|
-
n->layout.height = ih + boxInsets(n->
|
|
119
|
-
n->layout.width = clampBorderBoxSize(n->
|
|
120
|
-
n->layout.height = clampBorderBoxSize(n->
|
|
115
|
+
if (n->computedStyle().width == kUnset && n->computedStyle().width_percent == kUnset && n->computedStyle().width_expression < 0 && iw > 0)
|
|
116
|
+
n->layout.width = iw + boxInsets(n->computedStyle(), true);
|
|
117
|
+
if (n->computedStyle().height == kUnset && n->computedStyle().height_percent == kUnset && n->computedStyle().height_expression < 0 && ih > 0)
|
|
118
|
+
n->layout.height = ih + boxInsets(n->computedStyle(), false);
|
|
119
|
+
n->layout.width = clampBorderBoxSize(n->computedStyle(), n->layout.width, true);
|
|
120
|
+
n->layout.height = clampBorderBoxSize(n->computedStyle(), n->layout.height, false);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
void ImageRenderer::record(const Node &node)
|
package/ui/input.cpp
CHANGED
|
@@ -128,12 +128,12 @@ public:
|
|
|
128
128
|
|
|
129
129
|
Node &node = tree.nodes()[activeNodeId];
|
|
130
130
|
activeTouchNode_ = activeNodeId;
|
|
131
|
-
savedBackgroundColor_ = node.
|
|
132
|
-
savedHasBackground_ = node.
|
|
133
|
-
node.
|
|
134
|
-
node.
|
|
135
|
-
activeBackgroundColor_ = node.
|
|
136
|
-
activeHasBackground_ = node.
|
|
131
|
+
savedBackgroundColor_ = node.computedStyle().bg_color;
|
|
132
|
+
savedHasBackground_ = node.computedStyle().has_bg;
|
|
133
|
+
node.mutableStyle().bg_color = node.mutableStyle().has_active_bg ? node.mutableStyle().active_bg_color : lightenRgb565(node.mutableStyle().bg_color);
|
|
134
|
+
node.mutableStyle().has_bg = 1;
|
|
135
|
+
activeBackgroundColor_ = node.computedStyle().bg_color;
|
|
136
|
+
activeHasBackground_ = node.computedStyle().has_bg;
|
|
137
137
|
node.render.dirty = 1; // paint-only: press highlight recolors in place
|
|
138
138
|
#if GEA_CSS_SCROLLING
|
|
139
139
|
node.render.non_scroll_dirty = 1;
|
|
@@ -281,7 +281,7 @@ public:
|
|
|
281
281
|
const int count = tree.nodeCount();
|
|
282
282
|
for (int id = 0; id < count; ++id) {
|
|
283
283
|
Node &node = tree.nodes()[id];
|
|
284
|
-
if (node.
|
|
284
|
+
if (node.computedStyle().display == 1) continue; // display:none
|
|
285
285
|
if (!nodeCanScrollY(id, node)) continue;
|
|
286
286
|
const int cur = scrollTop(id);
|
|
287
287
|
int next = cur + dy;
|
|
@@ -443,20 +443,20 @@ private:
|
|
|
443
443
|
int hitTestNodeId(int id, int x, int y, bool clipped = false, bool groupRoot = true, bool includePositioned = true)
|
|
444
444
|
{
|
|
445
445
|
Node &node = Tree::instance().nodes()[id];
|
|
446
|
-
if (node.
|
|
446
|
+
if (node.computedStyle().display == 1 || isCollapsedFlexSubtree(node)) return -1;
|
|
447
447
|
// CSS `pointer-events: none` — this node and its subtree are never the
|
|
448
448
|
// target of a pointer event, so the hit-test falls through to whatever is
|
|
449
449
|
// painted behind it. Without this, a decorative overlay image positioned
|
|
450
450
|
// over interactive controls (e.g. the weather hero art over the city rail)
|
|
451
451
|
// swallows their clicks. Matches the browser/DOM build, which honors it.
|
|
452
|
-
if (node.
|
|
452
|
+
if (node.computedStyle().pointer_events == 1) return -1;
|
|
453
453
|
|
|
454
454
|
const bool inside = pointInsideNodeHitArea(node, x, y);
|
|
455
455
|
if (LayoutEngine::isViewportFixed(node)) clipped = false;
|
|
456
456
|
int clipX, clipY, clipW, clipH;
|
|
457
457
|
overflowClipBounds(node, clipX, clipY, clipW, clipH);
|
|
458
458
|
const bool outsideClip = x < clipX || y < clipY || x >= clipX + clipW || y >= clipY + clipH;
|
|
459
|
-
const bool childClipped = clipped || (outsideClip && node.
|
|
459
|
+
const bool childClipped = clipped || (outsideClip && node.computedStyle().overflow != 0);
|
|
460
460
|
if (childClipped && (!inside || clipped) && !LayoutEngine::containsViewportFixed(id)) return -1;
|
|
461
461
|
|
|
462
462
|
const auto children = PaintOrder::collectChildren(id, groupRoot, includePositioned);
|
|
@@ -465,31 +465,31 @@ private:
|
|
|
465
465
|
const Node *nodes = Tree::instance().nodes();
|
|
466
466
|
for (int p = nodes[*child].parent; p >= 0 && p != id; p = nodes[p].parent) {
|
|
467
467
|
const auto &ancestor = nodes[p];
|
|
468
|
-
if (ancestor.
|
|
468
|
+
if (ancestor.computedStyle().pointer_events == 1) ignored = true;
|
|
469
469
|
int ax, ay, aw, ah;
|
|
470
470
|
overflowClipBounds(ancestor, ax, ay, aw, ah);
|
|
471
|
-
if (ancestor.
|
|
471
|
+
if (ancestor.computedStyle().overflow && (x < ax || y < ay || x >= ax + aw || y >= ay + ah)) inheritedClip = true;
|
|
472
472
|
}
|
|
473
473
|
if (ignored) continue;
|
|
474
474
|
const int result = hitTestNodeId(*child, x, y, inheritedClip, PaintOrder::isGroup(*child), PaintOrder::isContext(*child));
|
|
475
475
|
if (result >= 0) return result;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
if (!inside || clipped || node.
|
|
478
|
+
if (!inside || clipped || node.computedStyle().visibility != 0) return -1;
|
|
479
479
|
return id;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
int findScrollNodeId(int id, int x, int y, bool clipped = false, bool groupRoot = true, bool includePositioned = true)
|
|
483
483
|
{
|
|
484
484
|
Node &node = Tree::instance().nodes()[id];
|
|
485
|
-
if (node.
|
|
485
|
+
if (node.computedStyle().display == 1 || isCollapsedFlexSubtree(node)) return -1;
|
|
486
486
|
|
|
487
487
|
const bool inside = pointInsideNodeHitArea(node, x, y);
|
|
488
488
|
if (LayoutEngine::isViewportFixed(node)) clipped = false;
|
|
489
489
|
int clipX, clipY, clipW, clipH;
|
|
490
490
|
overflowClipBounds(node, clipX, clipY, clipW, clipH);
|
|
491
491
|
const bool outsideClip = x < clipX || y < clipY || x >= clipX + clipW || y >= clipY + clipH;
|
|
492
|
-
const bool childClipped = clipped || (outsideClip && node.
|
|
492
|
+
const bool childClipped = clipped || (outsideClip && node.computedStyle().overflow != 0);
|
|
493
493
|
if (childClipped && (!inside || clipped) && !LayoutEngine::containsViewportFixed(id)) return -1;
|
|
494
494
|
|
|
495
495
|
const auto children = PaintOrder::collectChildren(id, groupRoot, includePositioned);
|
|
@@ -501,14 +501,14 @@ private:
|
|
|
501
501
|
|
|
502
502
|
int ax, ay, aw, ah;
|
|
503
503
|
overflowClipBounds(ancestor, ax, ay, aw, ah);
|
|
504
|
-
if (ancestor.
|
|
504
|
+
if (ancestor.computedStyle().overflow && (x < ax || y < ay || x >= ax + aw || y >= ay + ah)) inheritedClip = true;
|
|
505
505
|
}
|
|
506
506
|
if (ignored) continue;
|
|
507
507
|
const int result = findScrollNodeId(*child, x, y, inheritedClip, PaintOrder::isGroup(*child), PaintOrder::isContext(*child));
|
|
508
508
|
if (result >= 0) return result;
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
if (!inside || clipped || node.
|
|
511
|
+
if (!inside || clipped || node.computedStyle().visibility != 0) return -1;
|
|
512
512
|
const bool scrollableVirtualList = node.type == NodeType::VirtualList && VirtualListRenderer::scrollMaxY(id) > 0;
|
|
513
513
|
const bool scrollableView = node.type != NodeType::VirtualList && isViewLikeNodeType(node.type) &&
|
|
514
514
|
(nodeCanScrollX(id, node) || nodeCanScrollY(id, node));
|
|
@@ -543,13 +543,13 @@ private:
|
|
|
543
543
|
static bool nodeCanScrollX(int nodeId, const Node &node)
|
|
544
544
|
{
|
|
545
545
|
(void)nodeId;
|
|
546
|
-
return node.type != NodeType::VirtualList && scrollsOverflowX(node.
|
|
546
|
+
return node.type != NodeType::VirtualList && scrollsOverflowX(node.computedStyle()) && ViewRenderer::scrollMaxX(node) > 0;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
static bool nodeCanScrollY(int nodeId, const Node &node)
|
|
550
550
|
{
|
|
551
551
|
if (node.type == NodeType::VirtualList) return VirtualListRenderer::scrollMaxY(nodeId) > 0;
|
|
552
|
-
return scrollsOverflowY(node.
|
|
552
|
+
return scrollsOverflowY(node.computedStyle()) && ViewRenderer::scrollMaxY(node) > 0;
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
static bool nodeCanScrollAxis(int nodeId, const Node &node, ScrollAxis axis)
|
|
@@ -618,7 +618,7 @@ private:
|
|
|
618
618
|
Tree &tree = Tree::instance();
|
|
619
619
|
for (int current = nodeId; current >= 0 && current < tree.nodeCount(); current = tree.node(current).parent) {
|
|
620
620
|
const Node &node = tree.node(current);
|
|
621
|
-
if (node.
|
|
621
|
+
if (node.computedStyle().has_active_bg || (node.computedStyle().has_bg && isNativeButtonNodeType(node.type))) return current;
|
|
622
622
|
}
|
|
623
623
|
return -1;
|
|
624
624
|
}
|
|
@@ -654,11 +654,11 @@ private:
|
|
|
654
654
|
|
|
655
655
|
Node &node = Tree::instance().node(activeTouchNode_);
|
|
656
656
|
const bool ownsActiveBackground =
|
|
657
|
-
node.
|
|
658
|
-
node.
|
|
657
|
+
node.computedStyle().bg_color == activeBackgroundColor_ &&
|
|
658
|
+
node.computedStyle().has_bg == activeHasBackground_;
|
|
659
659
|
if (ownsActiveBackground) {
|
|
660
|
-
node.
|
|
661
|
-
node.
|
|
660
|
+
node.mutableStyle().bg_color = savedBackgroundColor_;
|
|
661
|
+
node.mutableStyle().has_bg = savedHasBackground_;
|
|
662
662
|
node.render.dirty = 1; // paint-only: press highlight restore
|
|
663
663
|
#if GEA_CSS_SCROLLING
|
|
664
664
|
node.render.non_scroll_dirty = 1;
|
package/ui/input_render.cpp
CHANGED
|
@@ -85,17 +85,17 @@ void InputRenderer::layout(int id, int)
|
|
|
85
85
|
if (n.type != NodeType::View) return;
|
|
86
86
|
if (std::strcmp(tagFromId(n.tag_id), "input") != 0) return;
|
|
87
87
|
|
|
88
|
-
const char *content = inputContentText(id, nullptr, n.
|
|
88
|
+
const char *content = inputContentText(id, nullptr, n.computedStyle().text_color);
|
|
89
89
|
const char *measureText = inputMeasureText(id);
|
|
90
|
-
int width = TextRenderer::measureWidth(content, n.
|
|
91
|
-
int height = TextRenderer::measureHeight(measureText, n.
|
|
92
|
-
|
|
93
|
-
if (n.
|
|
94
|
-
else if ((n.
|
|
95
|
-
if (n.
|
|
96
|
-
else if ((n.
|
|
97
|
-
n.layout.width = clampBorderBoxSize(n.
|
|
98
|
-
n.layout.height = clampBorderBoxSize(n.
|
|
90
|
+
int width = TextRenderer::measureWidth(content, n.computedStyle().font_id, n.computedStyle().font_size, n.computedStyle().text_transform) + boxInset(n.computedStyle(), 1) + boxInset(n.computedStyle(), 3);
|
|
91
|
+
int height = TextRenderer::measureHeight(measureText, n.computedStyle().font_id, n.computedStyle().font_size, n.computedStyle().text_transform, n.computedStyle().line_height) + boxInset(n.computedStyle(), 0) + boxInset(n.computedStyle(), 2);
|
|
92
|
+
|
|
93
|
+
if (n.computedStyle().width != kUnset) width = contentSizeToBorderSize(n.computedStyle(), n.computedStyle().width, true);
|
|
94
|
+
else if ((n.computedStyle().width_percent != kUnset || n.computedStyle().width_expression >= 0) && n.layout.width > 0) width = n.layout.width;
|
|
95
|
+
if (n.computedStyle().height != kUnset) height = contentSizeToBorderSize(n.computedStyle(), n.computedStyle().height, false);
|
|
96
|
+
else if ((n.computedStyle().height_percent != kUnset || n.computedStyle().height_expression >= 0) && n.layout.height > 0) height = n.layout.height;
|
|
97
|
+
n.layout.width = clampBorderBoxSize(n.computedStyle(), width, true);
|
|
98
|
+
n.layout.height = clampBorderBoxSize(n.computedStyle(), height, false);
|
|
99
99
|
#if GEA_CSS_SCROLLING
|
|
100
100
|
n.layout.scroll_content_height = n.layout.height;
|
|
101
101
|
n.layout.scroll_y = 0;
|
|
@@ -111,17 +111,17 @@ void InputRenderer::record(int id)
|
|
|
111
111
|
if (n.type != NodeType::View) return;
|
|
112
112
|
if (std::strcmp(tagFromId(n.tag_id), "input") != 0) return;
|
|
113
113
|
|
|
114
|
-
std::uint16_t color = n.
|
|
115
|
-
const char *content = inputContentText(id, &color, n.
|
|
114
|
+
std::uint16_t color = n.computedStyle().text_color;
|
|
115
|
+
const char *content = inputContentText(id, &color, n.computedStyle().text_color);
|
|
116
116
|
|
|
117
117
|
const int x = n.layout.x;
|
|
118
118
|
const int y = n.layout.y;
|
|
119
119
|
const int w = n.layout.width;
|
|
120
120
|
const int h = n.layout.height;
|
|
121
|
-
const int padLeft = boxInset(n.
|
|
122
|
-
const int padRight = boxInset(n.
|
|
123
|
-
const int padTop = boxInset(n.
|
|
124
|
-
const int padBottom = boxInset(n.
|
|
121
|
+
const int padLeft = boxInset(n.computedStyle(), 3);
|
|
122
|
+
const int padRight = boxInset(n.computedStyle(), 1);
|
|
123
|
+
const int padTop = boxInset(n.computedStyle(), 0);
|
|
124
|
+
const int padBottom = boxInset(n.computedStyle(), 2);
|
|
125
125
|
const int contentX = x + padLeft;
|
|
126
126
|
const int contentY = y + padTop;
|
|
127
127
|
int contentW = w - padLeft - padRight;
|
|
@@ -136,8 +136,8 @@ void InputRenderer::record(int id)
|
|
|
136
136
|
// system rasterizes at font_size directly — but it still needs to
|
|
137
137
|
// be non-zero to keep the bitmap path's math consistent for callers
|
|
138
138
|
// without `font-family` set.
|
|
139
|
-
const float textScale = n.
|
|
140
|
-
? static_cast<float>(n.
|
|
139
|
+
const float textScale = n.computedStyle().font_size > 0
|
|
140
|
+
? static_cast<float>(n.computedStyle().font_size) / 16.0f
|
|
141
141
|
: 1.0f;
|
|
142
142
|
|
|
143
143
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
@@ -154,21 +154,21 @@ void InputRenderer::record(int id)
|
|
|
154
154
|
// inputs are conventionally one line and the framework's text
|
|
155
155
|
// renderer would otherwise top-align.
|
|
156
156
|
// 16 = BitmapFont8x16::kHeight (default when no font_size set).
|
|
157
|
-
const int fontSize = n.
|
|
157
|
+
const int fontSize = n.computedStyle().font_size > 0 ? n.computedStyle().font_size : 16;
|
|
158
158
|
const int yCenter = contentY + (contentH - fontSize) / 2;
|
|
159
159
|
cmd->text.y = yCenter > contentY ? yCenter : contentY;
|
|
160
160
|
cmd->text.maxWidth = contentW;
|
|
161
161
|
cmd->text.color = color;
|
|
162
162
|
cmd->text.scale = textScale;
|
|
163
|
-
cmd->text.align = n.
|
|
164
|
-
cmd->text.textTransform = n.
|
|
165
|
-
cmd->text.lineHeight = n.
|
|
163
|
+
cmd->text.align = n.computedStyle().text_align;
|
|
164
|
+
cmd->text.textTransform = n.computedStyle().text_transform;
|
|
165
|
+
cmd->text.lineHeight = n.computedStyle().line_height;
|
|
166
166
|
cmd->text.containerWidth = contentW;
|
|
167
|
-
cmd->text.fontId = n.
|
|
167
|
+
cmd->text.fontId = n.computedStyle().font_id;
|
|
168
168
|
// append() hands back uninitialized scratch — set these explicitly so
|
|
169
169
|
// the deferred draw doesn't read stale white-space/text-overflow.
|
|
170
|
-
cmd->text.whiteSpace = n.
|
|
171
|
-
cmd->text.textOverflow = n.
|
|
170
|
+
cmd->text.whiteSpace = n.computedStyle().white_space;
|
|
171
|
+
cmd->text.textOverflow = n.computedStyle().text_overflow;
|
|
172
172
|
cmd->text.maxHeight = 0;
|
|
173
173
|
cmd->text.firstLineIndent = 0;
|
|
174
174
|
}
|
|
@@ -192,14 +192,14 @@ void InputRenderer::record(int id)
|
|
|
192
192
|
const bool hasValue = valueAttr && valueAttr[0];
|
|
193
193
|
int caretX = contentX;
|
|
194
194
|
if (hasValue) {
|
|
195
|
-
const int textWidth = TextRenderer::measureWidth(valueAttr, n.
|
|
195
|
+
const int textWidth = TextRenderer::measureWidth(valueAttr, n.computedStyle().font_id, n.computedStyle().font_size, n.computedStyle().text_transform);
|
|
196
196
|
caretX += textWidth < contentW ? textWidth : contentW - kInputCaretWidth;
|
|
197
197
|
if (caretX < contentX) caretX = contentX;
|
|
198
198
|
}
|
|
199
199
|
const int caretY = contentY + kInputCaretInsetY;
|
|
200
200
|
int caretH = contentH - kInputCaretInsetY * 2;
|
|
201
201
|
if (caretH < 4) caretH = contentH > 4 ? contentH - 2 : contentH;
|
|
202
|
-
const std::uint16_t caretColor = n.
|
|
202
|
+
const std::uint16_t caretColor = n.computedStyle().text_color ? n.computedStyle().text_color : 0xFFFF;
|
|
203
203
|
|
|
204
204
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
205
205
|
if (cmd) {
|
package/ui/internal.h
CHANGED
|
@@ -431,6 +431,28 @@ void rootScrollImageHoldTick();
|
|
|
431
431
|
// (LayoutBox::memo_pass). Must be called before each root layoutNode()
|
|
432
432
|
// so memo hits never leak across passes/frames.
|
|
433
433
|
void beginLayoutPass();
|
|
434
|
+
void endLayoutPass();
|
|
435
|
+
void invalidateMemo(int id);
|
|
436
|
+
void resetNodeLayoutState(int id);
|
|
437
|
+
void releasePersistentLayoutStorage();
|
|
438
|
+
static std::size_t persistentLayoutStorageBytes();
|
|
439
|
+
static std::size_t persistentLayoutHeapBytes();
|
|
440
|
+
static std::size_t persistentLayoutAllocationCount();
|
|
441
|
+
static std::size_t persistentLayoutPeakBytes();
|
|
442
|
+
static std::size_t persistentLayoutPeakAllocations();
|
|
443
|
+
static std::size_t persistentLayoutStaticBytes();
|
|
444
|
+
static std::size_t memoStorageBytes();
|
|
445
|
+
// ESP: allocator usable bytes, including slack; host: requested payload.
|
|
446
|
+
static std::size_t memoPeakHeapBytes();
|
|
447
|
+
class Pass {
|
|
448
|
+
public:
|
|
449
|
+
explicit Pass(bool active = true) : active_(active) { if (active_) instance().beginLayoutPass(); }
|
|
450
|
+
~Pass() { if (active_) instance().endLayoutPass(); }
|
|
451
|
+
Pass(const Pass &) = delete;
|
|
452
|
+
Pass &operator=(const Pass &) = delete;
|
|
453
|
+
private:
|
|
454
|
+
bool active_;
|
|
455
|
+
};
|
|
434
456
|
void layoutNode(int id, int availableWidth, int availableHeight, bool intrinsicBoxEdges = false);
|
|
435
457
|
// Scoped relayout: re-lays ONLY `scope`'s subtree using the available box
|
|
436
458
|
// remembered from its last layout, then resolves the subtree's absolute
|