@geastack/engine 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/canvas.cpp +105 -48
- package/css/declarative.h +6 -0
- package/css/engine.h +20 -0
- package/image_store.cpp +136 -33
- package/package.json +4 -3
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +77 -62
- package/ui/core.cpp +26 -3
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +369 -0
- package/ui/document.cpp +11 -0
- package/ui/image_node.cpp +25 -24
- package/ui/input.cpp +46 -26
- package/ui/input_render.cpp +31 -27
- package/ui/internal.h +22 -0
- package/ui/layout.cpp +899 -613
- package/ui/layout_snapshot.cpp +29 -2
- package/ui/node_features.h +36 -0
- package/ui/node_lifecycle.cpp +358 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +816 -96
- package/ui/node_text.h +84 -0
- package/ui/refresh_perf.h +19 -17
- package/ui/render.cpp +341 -259
- package/ui/renderer_features.h +24 -0
- package/ui/root_scroll_refresh.cpp +86 -69
- package/ui/storage_usage.h +45 -0
- package/ui/style.cpp +1398 -349
- package/ui/style_values.h +2 -2
- package/ui/text.cpp +172 -154
- package/ui/tree_events.cpp +218 -92
- package/ui/tree_events.h +44 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +51 -19
- package/ui/tree_render.cpp +159 -126
- package/ui/tree_scroll_mirror.cpp +30 -4
- package/ui/tree_state.cpp +334 -115
- package/ui/tree_state.h +118 -22
- package/ui/tree_style.cpp +679 -303
- package/ui/view.cpp +268 -208
- package/ui/virtual_keyboard.cpp +18 -11
package/ui/input.cpp
CHANGED
|
@@ -128,14 +128,16 @@ 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
|
+
#if GEA_CSS_SCROLLING
|
|
138
139
|
node.render.non_scroll_dirty = 1;
|
|
140
|
+
#endif
|
|
139
141
|
// We mutated bg_color directly (bypassing setStyleValue), so the
|
|
140
142
|
// direct-replay refresh path would otherwise keep the cached
|
|
141
143
|
// pre-press color in the display list. Mark commands dirty so the
|
|
@@ -279,7 +281,7 @@ public:
|
|
|
279
281
|
const int count = tree.nodeCount();
|
|
280
282
|
for (int id = 0; id < count; ++id) {
|
|
281
283
|
Node &node = tree.nodes()[id];
|
|
282
|
-
if (node.
|
|
284
|
+
if (node.computedStyle().display == 1) continue; // display:none
|
|
283
285
|
if (!nodeCanScrollY(id, node)) continue;
|
|
284
286
|
const int cur = scrollTop(id);
|
|
285
287
|
int next = cur + dy;
|
|
@@ -441,20 +443,20 @@ private:
|
|
|
441
443
|
int hitTestNodeId(int id, int x, int y, bool clipped = false, bool groupRoot = true, bool includePositioned = true)
|
|
442
444
|
{
|
|
443
445
|
Node &node = Tree::instance().nodes()[id];
|
|
444
|
-
if (node.
|
|
446
|
+
if (node.computedStyle().display == 1 || isCollapsedFlexSubtree(node)) return -1;
|
|
445
447
|
// CSS `pointer-events: none` — this node and its subtree are never the
|
|
446
448
|
// target of a pointer event, so the hit-test falls through to whatever is
|
|
447
449
|
// painted behind it. Without this, a decorative overlay image positioned
|
|
448
450
|
// over interactive controls (e.g. the weather hero art over the city rail)
|
|
449
451
|
// swallows their clicks. Matches the browser/DOM build, which honors it.
|
|
450
|
-
if (node.
|
|
452
|
+
if (node.computedStyle().pointer_events == 1) return -1;
|
|
451
453
|
|
|
452
454
|
const bool inside = pointInsideNodeHitArea(node, x, y);
|
|
453
455
|
if (LayoutEngine::isViewportFixed(node)) clipped = false;
|
|
454
456
|
int clipX, clipY, clipW, clipH;
|
|
455
457
|
overflowClipBounds(node, clipX, clipY, clipW, clipH);
|
|
456
458
|
const bool outsideClip = x < clipX || y < clipY || x >= clipX + clipW || y >= clipY + clipH;
|
|
457
|
-
const bool childClipped = clipped || (outsideClip && node.
|
|
459
|
+
const bool childClipped = clipped || (outsideClip && node.computedStyle().overflow != 0);
|
|
458
460
|
if (childClipped && (!inside || clipped) && !LayoutEngine::containsViewportFixed(id)) return -1;
|
|
459
461
|
|
|
460
462
|
const auto children = PaintOrder::collectChildren(id, groupRoot, includePositioned);
|
|
@@ -463,31 +465,31 @@ private:
|
|
|
463
465
|
const Node *nodes = Tree::instance().nodes();
|
|
464
466
|
for (int p = nodes[*child].parent; p >= 0 && p != id; p = nodes[p].parent) {
|
|
465
467
|
const auto &ancestor = nodes[p];
|
|
466
|
-
if (ancestor.
|
|
468
|
+
if (ancestor.computedStyle().pointer_events == 1) ignored = true;
|
|
467
469
|
int ax, ay, aw, ah;
|
|
468
470
|
overflowClipBounds(ancestor, ax, ay, aw, ah);
|
|
469
|
-
if (ancestor.
|
|
471
|
+
if (ancestor.computedStyle().overflow && (x < ax || y < ay || x >= ax + aw || y >= ay + ah)) inheritedClip = true;
|
|
470
472
|
}
|
|
471
473
|
if (ignored) continue;
|
|
472
474
|
const int result = hitTestNodeId(*child, x, y, inheritedClip, PaintOrder::isGroup(*child), PaintOrder::isContext(*child));
|
|
473
475
|
if (result >= 0) return result;
|
|
474
476
|
}
|
|
475
477
|
|
|
476
|
-
if (!inside || clipped || node.
|
|
478
|
+
if (!inside || clipped || node.computedStyle().visibility != 0) return -1;
|
|
477
479
|
return id;
|
|
478
480
|
}
|
|
479
481
|
|
|
480
482
|
int findScrollNodeId(int id, int x, int y, bool clipped = false, bool groupRoot = true, bool includePositioned = true)
|
|
481
483
|
{
|
|
482
484
|
Node &node = Tree::instance().nodes()[id];
|
|
483
|
-
if (node.
|
|
485
|
+
if (node.computedStyle().display == 1 || isCollapsedFlexSubtree(node)) return -1;
|
|
484
486
|
|
|
485
487
|
const bool inside = pointInsideNodeHitArea(node, x, y);
|
|
486
488
|
if (LayoutEngine::isViewportFixed(node)) clipped = false;
|
|
487
489
|
int clipX, clipY, clipW, clipH;
|
|
488
490
|
overflowClipBounds(node, clipX, clipY, clipW, clipH);
|
|
489
491
|
const bool outsideClip = x < clipX || y < clipY || x >= clipX + clipW || y >= clipY + clipH;
|
|
490
|
-
const bool childClipped = clipped || (outsideClip && node.
|
|
492
|
+
const bool childClipped = clipped || (outsideClip && node.computedStyle().overflow != 0);
|
|
491
493
|
if (childClipped && (!inside || clipped) && !LayoutEngine::containsViewportFixed(id)) return -1;
|
|
492
494
|
|
|
493
495
|
const auto children = PaintOrder::collectChildren(id, groupRoot, includePositioned);
|
|
@@ -499,14 +501,14 @@ private:
|
|
|
499
501
|
|
|
500
502
|
int ax, ay, aw, ah;
|
|
501
503
|
overflowClipBounds(ancestor, ax, ay, aw, ah);
|
|
502
|
-
if (ancestor.
|
|
504
|
+
if (ancestor.computedStyle().overflow && (x < ax || y < ay || x >= ax + aw || y >= ay + ah)) inheritedClip = true;
|
|
503
505
|
}
|
|
504
506
|
if (ignored) continue;
|
|
505
507
|
const int result = findScrollNodeId(*child, x, y, inheritedClip, PaintOrder::isGroup(*child), PaintOrder::isContext(*child));
|
|
506
508
|
if (result >= 0) return result;
|
|
507
509
|
}
|
|
508
510
|
|
|
509
|
-
if (!inside || clipped || node.
|
|
511
|
+
if (!inside || clipped || node.computedStyle().visibility != 0) return -1;
|
|
510
512
|
const bool scrollableVirtualList = node.type == NodeType::VirtualList && VirtualListRenderer::scrollMaxY(id) > 0;
|
|
511
513
|
const bool scrollableView = node.type != NodeType::VirtualList && isViewLikeNodeType(node.type) &&
|
|
512
514
|
(nodeCanScrollX(id, node) || nodeCanScrollY(id, node));
|
|
@@ -541,13 +543,13 @@ private:
|
|
|
541
543
|
static bool nodeCanScrollX(int nodeId, const Node &node)
|
|
542
544
|
{
|
|
543
545
|
(void)nodeId;
|
|
544
|
-
return node.type != NodeType::VirtualList && scrollsOverflowX(node.
|
|
546
|
+
return node.type != NodeType::VirtualList && scrollsOverflowX(node.computedStyle()) && ViewRenderer::scrollMaxX(node) > 0;
|
|
545
547
|
}
|
|
546
548
|
|
|
547
549
|
static bool nodeCanScrollY(int nodeId, const Node &node)
|
|
548
550
|
{
|
|
549
551
|
if (node.type == NodeType::VirtualList) return VirtualListRenderer::scrollMaxY(nodeId) > 0;
|
|
550
|
-
return scrollsOverflowY(node.
|
|
552
|
+
return scrollsOverflowY(node.computedStyle()) && ViewRenderer::scrollMaxY(node) > 0;
|
|
551
553
|
}
|
|
552
554
|
|
|
553
555
|
static bool nodeCanScrollAxis(int nodeId, const Node &node, ScrollAxis axis)
|
|
@@ -559,6 +561,7 @@ private:
|
|
|
559
561
|
|
|
560
562
|
static void setScrollLeft(int nodeId, int next)
|
|
561
563
|
{
|
|
564
|
+
#if GEA_CSS_SCROLLING
|
|
562
565
|
Tree &tree = Tree::instance();
|
|
563
566
|
if (nodeId < 0 || nodeId >= tree.nodeCount()) return;
|
|
564
567
|
Node &node = tree.node(nodeId);
|
|
@@ -571,10 +574,14 @@ private:
|
|
|
571
574
|
// handles either axis), so it no longer forces the full clipped-replay
|
|
572
575
|
// path via non_scroll_dirty — mirror the vertical setScrollTop path.
|
|
573
576
|
tree.markScrollDirty(nodeId);
|
|
574
|
-
|
|
577
|
+
#else
|
|
578
|
+
(void)nodeId; (void)next;
|
|
579
|
+
#endif
|
|
580
|
+
}
|
|
575
581
|
|
|
576
582
|
static void setScrollTop(int nodeId, int next)
|
|
577
583
|
{
|
|
584
|
+
#if GEA_CSS_SCROLLING
|
|
578
585
|
Tree &tree = Tree::instance();
|
|
579
586
|
if (nodeId < 0 || nodeId >= tree.nodeCount()) return;
|
|
580
587
|
if (tree.node(nodeId).type == NodeType::VirtualList) {
|
|
@@ -587,7 +594,10 @@ private:
|
|
|
587
594
|
node.render.dirty = 1;
|
|
588
595
|
node.render.layout_dirty = 1;
|
|
589
596
|
tree.markScrollDirty(nodeId);
|
|
590
|
-
|
|
597
|
+
#else
|
|
598
|
+
(void)nodeId; (void)next;
|
|
599
|
+
#endif
|
|
600
|
+
}
|
|
591
601
|
|
|
592
602
|
static std::uint16_t lightenRgb565(std::uint16_t color)
|
|
593
603
|
{
|
|
@@ -608,7 +618,7 @@ private:
|
|
|
608
618
|
Tree &tree = Tree::instance();
|
|
609
619
|
for (int current = nodeId; current >= 0 && current < tree.nodeCount(); current = tree.node(current).parent) {
|
|
610
620
|
const Node &node = tree.node(current);
|
|
611
|
-
if (node.
|
|
621
|
+
if (node.computedStyle().has_active_bg || (node.computedStyle().has_bg && isNativeButtonNodeType(node.type))) return current;
|
|
612
622
|
}
|
|
613
623
|
return -1;
|
|
614
624
|
}
|
|
@@ -644,13 +654,15 @@ private:
|
|
|
644
654
|
|
|
645
655
|
Node &node = Tree::instance().node(activeTouchNode_);
|
|
646
656
|
const bool ownsActiveBackground =
|
|
647
|
-
node.
|
|
648
|
-
node.
|
|
657
|
+
node.computedStyle().bg_color == activeBackgroundColor_ &&
|
|
658
|
+
node.computedStyle().has_bg == activeHasBackground_;
|
|
649
659
|
if (ownsActiveBackground) {
|
|
650
|
-
node.
|
|
651
|
-
node.
|
|
660
|
+
node.mutableStyle().bg_color = savedBackgroundColor_;
|
|
661
|
+
node.mutableStyle().has_bg = savedHasBackground_;
|
|
652
662
|
node.render.dirty = 1; // paint-only: press highlight restore
|
|
663
|
+
#if GEA_CSS_SCROLLING
|
|
653
664
|
node.render.non_scroll_dirty = 1;
|
|
665
|
+
#endif
|
|
654
666
|
Tree::instance().markNodeDisplayCommandsDirty(activeTouchNode_);
|
|
655
667
|
}
|
|
656
668
|
activeTouchNode_ = -1;
|
|
@@ -893,6 +905,7 @@ int Tree::activeInputId() const
|
|
|
893
905
|
|
|
894
906
|
void Tree::setActiveInput(int nodeId)
|
|
895
907
|
{
|
|
908
|
+
#if GEA_UI_INPUT_NODES
|
|
896
909
|
auto &state = treeState();
|
|
897
910
|
if (nodeId < -1 || nodeId >= state.nodeCount) nodeId = -1;
|
|
898
911
|
if (state.activeInputId == nodeId) return;
|
|
@@ -910,7 +923,9 @@ void Tree::setActiveInput(int nodeId)
|
|
|
910
923
|
Node &n = state.nodes[id];
|
|
911
924
|
n.render.dirty = 1;
|
|
912
925
|
n.render.layout_dirty = 1;
|
|
926
|
+
#if GEA_CSS_SCROLLING
|
|
913
927
|
n.render.non_scroll_dirty = 1;
|
|
928
|
+
#endif
|
|
914
929
|
state.nodeCommandDirty[id] = 1;
|
|
915
930
|
};
|
|
916
931
|
markInputDirty(previousId);
|
|
@@ -923,6 +938,7 @@ void Tree::setActiveInput(int nodeId)
|
|
|
923
938
|
// `displayListDirty`; the keyboard subsystem decides activity in
|
|
924
939
|
// notifyActiveInputChanged.
|
|
925
940
|
state.displayListDirty = true;
|
|
941
|
+
#endif
|
|
926
942
|
}
|
|
927
943
|
|
|
928
944
|
bool Tree::activeInputCaretVisible() const
|
|
@@ -932,6 +948,7 @@ bool Tree::activeInputCaretVisible() const
|
|
|
932
948
|
|
|
933
949
|
void Tree::tickInputCaret(int timestampMs)
|
|
934
950
|
{
|
|
951
|
+
#if GEA_UI_INPUT_NODES
|
|
935
952
|
auto &state = treeState();
|
|
936
953
|
if (state.activeInputId < 0) {
|
|
937
954
|
state.caretVisible = false;
|
|
@@ -959,8 +976,11 @@ void Tree::tickInputCaret(int timestampMs)
|
|
|
959
976
|
Node &n = state.nodes[state.activeInputId];
|
|
960
977
|
n.render.dirty = 1;
|
|
961
978
|
n.render.layout_dirty = 1;
|
|
979
|
+
#if GEA_CSS_SCROLLING
|
|
962
980
|
n.render.non_scroll_dirty = 1;
|
|
981
|
+
#endif
|
|
963
982
|
}
|
|
983
|
+
#endif
|
|
964
984
|
}
|
|
965
985
|
|
|
966
986
|
} // namespace gea::embedded::ui
|
package/ui/input_render.cpp
CHANGED
|
@@ -78,46 +78,50 @@ const char *inputMeasureText(int id)
|
|
|
78
78
|
|
|
79
79
|
void InputRenderer::layout(int id, int)
|
|
80
80
|
{
|
|
81
|
+
if (!GEA_UI_INPUT_NODES) return;
|
|
81
82
|
auto &tree = Tree::instance();
|
|
82
83
|
if (id < 0 || id >= tree.nodeCount()) return;
|
|
83
84
|
Node &n = tree.node(id);
|
|
84
85
|
if (n.type != NodeType::View) return;
|
|
85
86
|
if (std::strcmp(tagFromId(n.tag_id), "input") != 0) return;
|
|
86
87
|
|
|
87
|
-
const char *content = inputContentText(id, nullptr, n.
|
|
88
|
+
const char *content = inputContentText(id, nullptr, n.computedStyle().text_color);
|
|
88
89
|
const char *measureText = inputMeasureText(id);
|
|
89
|
-
int width = TextRenderer::measureWidth(content, n.
|
|
90
|
-
int height = TextRenderer::measureHeight(measureText, n.
|
|
91
|
-
|
|
92
|
-
if (n.
|
|
93
|
-
else if ((n.
|
|
94
|
-
if (n.
|
|
95
|
-
else if ((n.
|
|
96
|
-
n.layout.width = clampBorderBoxSize(n.
|
|
97
|
-
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
|
+
#if GEA_CSS_SCROLLING
|
|
98
100
|
n.layout.scroll_content_height = n.layout.height;
|
|
99
101
|
n.layout.scroll_y = 0;
|
|
102
|
+
#endif
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
void InputRenderer::record(int id)
|
|
103
106
|
{
|
|
107
|
+
if (!GEA_UI_INPUT_NODES) return;
|
|
104
108
|
auto &tree = Tree::instance();
|
|
105
109
|
if (id < 0 || id >= tree.nodeCount()) return;
|
|
106
110
|
const Node &n = tree.node(id);
|
|
107
111
|
if (n.type != NodeType::View) return;
|
|
108
112
|
if (std::strcmp(tagFromId(n.tag_id), "input") != 0) return;
|
|
109
113
|
|
|
110
|
-
std::uint16_t color = n.
|
|
111
|
-
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);
|
|
112
116
|
|
|
113
117
|
const int x = n.layout.x;
|
|
114
118
|
const int y = n.layout.y;
|
|
115
119
|
const int w = n.layout.width;
|
|
116
120
|
const int h = n.layout.height;
|
|
117
|
-
const int padLeft = boxInset(n.
|
|
118
|
-
const int padRight = boxInset(n.
|
|
119
|
-
const int padTop = boxInset(n.
|
|
120
|
-
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);
|
|
121
125
|
const int contentX = x + padLeft;
|
|
122
126
|
const int contentY = y + padTop;
|
|
123
127
|
int contentW = w - padLeft - padRight;
|
|
@@ -132,8 +136,8 @@ void InputRenderer::record(int id)
|
|
|
132
136
|
// system rasterizes at font_size directly — but it still needs to
|
|
133
137
|
// be non-zero to keep the bitmap path's math consistent for callers
|
|
134
138
|
// without `font-family` set.
|
|
135
|
-
const float textScale = n.
|
|
136
|
-
? static_cast<float>(n.
|
|
139
|
+
const float textScale = n.computedStyle().font_size > 0
|
|
140
|
+
? static_cast<float>(n.computedStyle().font_size) / 16.0f
|
|
137
141
|
: 1.0f;
|
|
138
142
|
|
|
139
143
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
@@ -150,21 +154,21 @@ void InputRenderer::record(int id)
|
|
|
150
154
|
// inputs are conventionally one line and the framework's text
|
|
151
155
|
// renderer would otherwise top-align.
|
|
152
156
|
// 16 = BitmapFont8x16::kHeight (default when no font_size set).
|
|
153
|
-
const int fontSize = n.
|
|
157
|
+
const int fontSize = n.computedStyle().font_size > 0 ? n.computedStyle().font_size : 16;
|
|
154
158
|
const int yCenter = contentY + (contentH - fontSize) / 2;
|
|
155
159
|
cmd->text.y = yCenter > contentY ? yCenter : contentY;
|
|
156
160
|
cmd->text.maxWidth = contentW;
|
|
157
161
|
cmd->text.color = color;
|
|
158
162
|
cmd->text.scale = textScale;
|
|
159
|
-
cmd->text.align = n.
|
|
160
|
-
cmd->text.textTransform = n.
|
|
161
|
-
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;
|
|
162
166
|
cmd->text.containerWidth = contentW;
|
|
163
|
-
cmd->text.fontId = n.
|
|
167
|
+
cmd->text.fontId = n.computedStyle().font_id;
|
|
164
168
|
// append() hands back uninitialized scratch — set these explicitly so
|
|
165
169
|
// the deferred draw doesn't read stale white-space/text-overflow.
|
|
166
|
-
cmd->text.whiteSpace = n.
|
|
167
|
-
cmd->text.textOverflow = n.
|
|
170
|
+
cmd->text.whiteSpace = n.computedStyle().white_space;
|
|
171
|
+
cmd->text.textOverflow = n.computedStyle().text_overflow;
|
|
168
172
|
cmd->text.maxHeight = 0;
|
|
169
173
|
cmd->text.firstLineIndent = 0;
|
|
170
174
|
}
|
|
@@ -188,14 +192,14 @@ void InputRenderer::record(int id)
|
|
|
188
192
|
const bool hasValue = valueAttr && valueAttr[0];
|
|
189
193
|
int caretX = contentX;
|
|
190
194
|
if (hasValue) {
|
|
191
|
-
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);
|
|
192
196
|
caretX += textWidth < contentW ? textWidth : contentW - kInputCaretWidth;
|
|
193
197
|
if (caretX < contentX) caretX = contentX;
|
|
194
198
|
}
|
|
195
199
|
const int caretY = contentY + kInputCaretInsetY;
|
|
196
200
|
int caretH = contentH - kInputCaretInsetY * 2;
|
|
197
201
|
if (caretH < 4) caretH = contentH > 4 ? contentH - 2 : contentH;
|
|
198
|
-
const std::uint16_t caretColor = n.
|
|
202
|
+
const std::uint16_t caretColor = n.computedStyle().text_color ? n.computedStyle().text_color : 0xFFFF;
|
|
199
203
|
|
|
200
204
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
201
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
|