@geastack/engine 0.1.17 → 0.1.18
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 +40 -5
- package/package.json +1 -1
- package/rasterized_font.cpp +118 -7
- package/touch_runtime.cpp +118 -67
- package/ui/canvas_element.h +1 -1
- package/ui/child_node_list.h +94 -0
- package/ui/control_commit.h +23 -0
- package/ui/css_features.h +5 -0
- package/ui/document.cpp +43 -96
- package/ui/document.h +61 -6
- package/ui/input.cpp +72 -20
- package/ui/input_retirement.h +22 -0
- package/ui/internal.h +3 -1
- package/ui/layout.cpp +31 -25
- package/ui/node.cpp +123 -31
- package/ui/node.h +55 -16
- package/ui/node_lifecycle.cpp +3 -0
- package/ui/node_model.h +20 -1
- package/ui/render.cpp +16 -3
- package/ui/selector.cpp +527 -0
- package/ui/selector.h +32 -0
- package/ui/style.cpp +94 -23
- package/ui/style.h +8 -3
- package/ui/text.cpp +73 -49
- package/ui/tree_events.cpp +376 -85
- package/ui/tree_events.h +34 -2
- package/ui/tree_internal.h +17 -5
- package/ui/tree_nodes.cpp +218 -13
- package/ui/tree_state.h +4 -0
- package/ui/tree_style.cpp +4 -0
- package/ui/virtual_keyboard.cpp +8 -1
package/ui/node.cpp
CHANGED
|
@@ -1,65 +1,70 @@
|
|
|
1
|
+
#include "selector.h"
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
#include "node.h"
|
|
4
|
+
#include "child_node_list.h"
|
|
5
|
+
#include "tree_state.h"
|
|
3
6
|
|
|
4
7
|
#include "host/audio.h"
|
|
5
8
|
#include "tree_internal.h"
|
|
9
|
+
#include "input_retirement.h"
|
|
6
10
|
|
|
7
11
|
#include <cstring>
|
|
8
12
|
#include <utility>
|
|
13
|
+
#include <stdexcept>
|
|
9
14
|
|
|
10
15
|
namespace gea::embedded::ui {
|
|
11
16
|
|
|
12
17
|
bool ClassList::add(const std::string &token) const
|
|
13
18
|
{
|
|
14
|
-
if (
|
|
19
|
+
if (!valid()) return false;
|
|
15
20
|
return Tree::instance().addClass(nodeId_, token);
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
bool ClassList::remove(const std::string &token) const
|
|
19
24
|
{
|
|
20
|
-
if (
|
|
25
|
+
if (!valid()) return false;
|
|
21
26
|
return Tree::instance().removeClass(nodeId_, token);
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
bool ClassList::toggle(const std::string &token) const
|
|
25
30
|
{
|
|
26
|
-
if (
|
|
31
|
+
if (!valid()) return false;
|
|
27
32
|
return Tree::instance().toggleClass(nodeId_, token);
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
bool ClassList::toggle(const std::string &token, bool force) const
|
|
31
36
|
{
|
|
32
|
-
if (
|
|
37
|
+
if (!valid()) return false;
|
|
33
38
|
return Tree::instance().toggleClass(nodeId_, token, force);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
void ClassList::set(const std::string &className) const
|
|
37
42
|
{
|
|
38
|
-
if (
|
|
43
|
+
if (!valid()) return;
|
|
39
44
|
Tree::instance().setClassName(nodeId_, className);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
void ClassList::set(const char *className) const
|
|
43
48
|
{
|
|
44
|
-
if (
|
|
49
|
+
if (!valid()) return;
|
|
45
50
|
Tree::instance().setClassName(nodeId_, className);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
void ClassList::clear() const
|
|
49
54
|
{
|
|
50
|
-
if (
|
|
55
|
+
if (!valid()) return;
|
|
51
56
|
Tree::instance().clearClasses(nodeId_);
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
bool ClassList::contains(const std::string &token) const
|
|
55
60
|
{
|
|
56
|
-
if (
|
|
61
|
+
if (!valid()) return false;
|
|
57
62
|
return Tree::instance().hasClass(nodeId_, token);
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
std::string ClassList::value() const
|
|
61
66
|
{
|
|
62
|
-
if (
|
|
67
|
+
if (!valid()) return std::string();
|
|
63
68
|
return Tree::instance().className(nodeId_);
|
|
64
69
|
}
|
|
65
70
|
|
|
@@ -81,19 +86,54 @@ NodeHandle NodeHandle::nextSiblingHandle() const
|
|
|
81
86
|
return NodeHandle(Tree::instance().node(id()).next_sibling);
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
ChildNodeList NodeHandle::childNodesHandle() const
|
|
90
|
+
{
|
|
91
|
+
if (!valid()) return ChildNodeList();
|
|
92
|
+
auto &rare = ensureRareData(id());
|
|
93
|
+
if (!rare.childNodeListIdentity) rare.childNodeListIdentity = std::make_shared<ChildNodeListIdentity>();
|
|
94
|
+
return ChildNodeList(*this, rare.childNodeListIdentity);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
NodeHandle NodeHandle::parentHandle() const
|
|
98
|
+
{
|
|
99
|
+
if (!valid()) return NodeHandle();
|
|
100
|
+
return NodeHandle(Tree::instance().node(id()).parent);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
NodeHandle NodeHandle::lastElementChildHandle() const
|
|
104
|
+
{
|
|
105
|
+
if (!valid()) return NodeHandle();
|
|
106
|
+
auto &tree = Tree::instance();
|
|
107
|
+
for (int child = tree.node(id()).last_child; child >= 0; child = tree.node(child).prev_sibling) {
|
|
108
|
+
NodeHandle candidate(child);
|
|
109
|
+
if (candidate.valid() && candidate.nodeType == 1) return candidate;
|
|
110
|
+
}
|
|
111
|
+
return NodeHandle();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
std::vector<NodeHandle> NodeHandle::elementChildren() const
|
|
115
|
+
{
|
|
116
|
+
std::vector<NodeHandle> result;
|
|
117
|
+
if (!valid()) return result;
|
|
118
|
+
auto &tree = Tree::instance();
|
|
119
|
+
for (int child = tree.node(id()).first_child; child >= 0; child = tree.node(child).next_sibling) {
|
|
120
|
+
NodeHandle candidate(child);
|
|
121
|
+
if (candidate.valid() && candidate.nodeType == 1) result.push_back(candidate);
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
|
|
84
126
|
void NodeHandle::replaceChildren(const std::vector<NodeHandle> &children) const
|
|
85
127
|
{
|
|
86
128
|
if (!valid()) return;
|
|
87
129
|
auto &tree = Tree::instance();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
child = nextChild;
|
|
130
|
+
std::vector<int> ids;
|
|
131
|
+
ids.reserve(children.size());
|
|
132
|
+
for (const auto &child : children) {
|
|
133
|
+
if (!child.valid()) throw std::invalid_argument("replaceChildren requires live nodes");
|
|
134
|
+
ids.push_back(child.id());
|
|
94
135
|
}
|
|
95
|
-
|
|
96
|
-
if (c.valid()) appendChild(c);
|
|
136
|
+
tree.replaceChildren(id(), ids);
|
|
97
137
|
}
|
|
98
138
|
|
|
99
139
|
NodeHandle NodeHandle::childAt(int index) const
|
|
@@ -108,10 +148,20 @@ void NodeHandle::appendChild(NodeHandle child) const
|
|
|
108
148
|
Tree::instance().setParent(child.id(), id());
|
|
109
149
|
}
|
|
110
150
|
|
|
111
|
-
|
|
151
|
+
NodeHandle NodeHandle::insertBefore(NodeHandle child, NodeHandle reference) const
|
|
112
152
|
{
|
|
113
|
-
if (!valid() || !child.valid()) return;
|
|
153
|
+
if (!valid() || !child.valid()) return NodeHandle();
|
|
154
|
+
if (!reference.valid() && reference.identity()) throw std::invalid_argument("insertBefore reference is retired");
|
|
114
155
|
Tree::instance().insertBefore(child.id(), id(), reference.valid() ? reference.id() : -1);
|
|
156
|
+
return child;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
NodeHandle NodeHandle::removeChild(NodeHandle child) const
|
|
160
|
+
{
|
|
161
|
+
if (!valid() || !child.valid() || child.parentHandle().identity() != identity())
|
|
162
|
+
throw std::invalid_argument("removeChild requires a direct live child");
|
|
163
|
+
Tree::instance().detachNode(child.id());
|
|
164
|
+
return child;
|
|
115
165
|
}
|
|
116
166
|
|
|
117
167
|
void NodeHandle::setParent(NodeHandle parent) const
|
|
@@ -167,19 +217,42 @@ void NodeHandle::scrollIntoView() const
|
|
|
167
217
|
Tree::instance().scrollIntoView(id());
|
|
168
218
|
}
|
|
169
219
|
|
|
220
|
+
bool NodeHandle::isConnected() const
|
|
221
|
+
{
|
|
222
|
+
if (!valid()) return false;
|
|
223
|
+
const Tree &tree = Tree::instance();
|
|
224
|
+
const int root = tree.mountedRoot();
|
|
225
|
+
if (root < 0 || !NodeHandle(root).valid()) return false;
|
|
226
|
+
// Bound the walk even if trusted raw Tree clients violate ancestry invariants.
|
|
227
|
+
int current = id_;
|
|
228
|
+
for (int remaining = tree.nodeCount(); remaining > 0; --remaining) {
|
|
229
|
+
if (current < 0 || current >= tree.nodeCount()) return false;
|
|
230
|
+
if (current == root) return true;
|
|
231
|
+
current = tree.node(current).parent;
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
__attribute__((weak)) void retirePlatformInputForSubtrees(const InputRetirementRoots &,const InputRetirementRoots &) {}
|
|
237
|
+
__attribute__((weak)) NativeFocusResult requestNativeFocus(NodeHandle,bool){return NativeFocusResult::unhandled;}
|
|
238
|
+
__attribute__((weak)) NativeFocusQuery queryNativeFocus(){return {};}
|
|
170
239
|
void NodeHandle::focus() const
|
|
171
240
|
{
|
|
172
|
-
|
|
173
|
-
|
|
241
|
+
if(!valid()||!isConnected()||selector::disabled(Tree::instance(),id()))return;
|
|
242
|
+
if(requestNativeFocus(*this,true)==NativeFocusResult::refused)return;
|
|
243
|
+
// A native responder callback may retire this allocation synchronously.
|
|
244
|
+
if(valid()&&isConnected())Tree::instance().setActiveInput(id());
|
|
174
245
|
}
|
|
175
246
|
|
|
176
247
|
void NodeHandle::blur() const
|
|
177
248
|
{
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
249
|
+
if(!valid())return;
|
|
250
|
+
const auto native=queryNativeFocus();
|
|
251
|
+
if(native.handled){
|
|
252
|
+
if(native.node.valid()&&native.node.identity()!=identity())return;
|
|
253
|
+
if(native.node.valid()&&requestNativeFocus(*this,false)==NativeFocusResult::refused)return;
|
|
254
|
+
}
|
|
255
|
+
if(valid()&&Tree::instance().activeInputId()==id())Tree::instance().setActiveInput(-1);
|
|
183
256
|
}
|
|
184
257
|
|
|
185
258
|
bool NodeHandle::play() const
|
|
@@ -207,13 +280,18 @@ const char *NodeHandle::tagName() const
|
|
|
207
280
|
}
|
|
208
281
|
|
|
209
282
|
// DOM Node.nodeType for a handle: ELEMENT_NODE (1) for any element-like tree
|
|
210
|
-
// node, TEXT_NODE (3)
|
|
211
|
-
// invalid handle (the embedded tree has no fragment node kind, so a real handle
|
|
212
|
-
// is never a fragment).
|
|
283
|
+
// node, TEXT_NODE (3), COMMENT_NODE (8), or DOCUMENT_FRAGMENT_NODE (11).
|
|
213
284
|
NodeHandle::NodeTypeProperty::operator int() const
|
|
214
285
|
{
|
|
215
|
-
if (id
|
|
216
|
-
|
|
286
|
+
if (!gea::framework::identity::current(id, owner)) return 0;
|
|
287
|
+
const auto &tree=Tree::instance();
|
|
288
|
+
// The template renderer's list/conditional anchors are hidden nodes tagged
|
|
289
|
+
// "#comment"; DOM queries must see them as the comments they stand for.
|
|
290
|
+
if (tree.node(id).type == NodeType::Comment || std::strcmp(tree.tagName(id), "#comment") == 0) return 8;
|
|
291
|
+
if (tree.node(id).type == NodeType::DocumentFragment) return 11;
|
|
292
|
+
// Native JSX text leaves retain their element tag (p/h1/etc.). Only an
|
|
293
|
+
// anonymous Text allocation projects a DOM text node.
|
|
294
|
+
return tree.node(id).type==NodeType::Text && !*tree.tagName(id)?3:1;
|
|
217
295
|
}
|
|
218
296
|
|
|
219
297
|
void NodeHandle::setPressId(int pressId) const
|
|
@@ -241,3 +319,17 @@ bool NodeHandle::removeEventListener(const char *type, gea::framework::events::E
|
|
|
241
319
|
}
|
|
242
320
|
|
|
243
321
|
} // namespace gea::embedded::ui
|
|
322
|
+
|
|
323
|
+
namespace gea::embedded::ui {
|
|
324
|
+
const char *NodeHandle::selectorText(const std::string &s) { if(s.find('\0')!=std::string::npos)selector::parse("").requireValid();return s.c_str(); }
|
|
325
|
+
bool NodeHandle::disabled() const { return valid()&&hasAttribute("disabled"); }
|
|
326
|
+
void NodeHandle::setDisabled(bool value) const { if(value)setAttribute("disabled","");else removeAttribute("disabled"); }
|
|
327
|
+
bool NodeHandle::matches(const char *s) const { auto q=selector::parse(s); q.requireValid(); return valid()&&q.matches(Tree::instance(),id(),id()); }
|
|
328
|
+
NodeHandle NodeHandle::closest(const char *s) const { auto q=selector::parse(s);q.requireValid();if(!valid())return {};auto&t=Tree::instance();for(int n=id(),left=t.nodeCount();left>0&&NodeHandle(n).valid();--left,n=t.node(n).parent)if(q.matches(t,n,id()))return NodeHandle(n);return {}; }
|
|
329
|
+
std::vector<NodeHandle> NodeHandle::querySelectorAll(const char *s) const {
|
|
330
|
+
auto q=selector::parse(s);q.requireValid();std::vector<NodeHandle> out;if(!valid())return out;auto&t=Tree::instance();
|
|
331
|
+
std::vector<int> pending; for(int c=t.node(id()).last_child,left=t.nodeCount();left>0&&NodeHandle(c).valid();--left,c=t.node(c).prev_sibling)pending.push_back(c);
|
|
332
|
+
for(int left=t.nodeCount();left>0&&!pending.empty();--left){int n=pending.back();pending.pop_back();if(!NodeHandle(n).valid())continue;if(q.matches(t,n,id()))out.emplace_back(n);for(int c=t.node(n).last_child,b=t.nodeCount();b>0&&NodeHandle(c).valid();--b,c=t.node(c).prev_sibling)pending.push_back(c);}return out;
|
|
333
|
+
}
|
|
334
|
+
NodeHandle NodeHandle::querySelector(const char*s) const {auto all=querySelectorAll(s);return all.empty()?NodeHandle():all.front();}
|
|
335
|
+
}
|
package/ui/node.h
CHANGED
|
@@ -4,15 +4,19 @@
|
|
|
4
4
|
#include "events.h"
|
|
5
5
|
#include "style.h"
|
|
6
6
|
|
|
7
|
+
#include <cstddef>
|
|
7
8
|
#include <string>
|
|
8
9
|
#include <utility>
|
|
9
10
|
#include <vector>
|
|
10
11
|
|
|
11
12
|
namespace gea::embedded::ui {
|
|
12
13
|
|
|
14
|
+
class ChildNodeList;
|
|
15
|
+
|
|
13
16
|
class ClassList {
|
|
14
17
|
public:
|
|
15
|
-
explicit ClassList(int nodeId = -1)
|
|
18
|
+
explicit ClassList(int nodeId = -1)
|
|
19
|
+
: nodeId_(nodeId), identity_(gea::framework::identity::node(nodeId)) {}
|
|
16
20
|
|
|
17
21
|
bool add(const std::string &token) const;
|
|
18
22
|
bool remove(const std::string &token) const;
|
|
@@ -25,12 +29,15 @@ public:
|
|
|
25
29
|
std::string value() const;
|
|
26
30
|
|
|
27
31
|
private:
|
|
32
|
+
bool valid() const { return gea::framework::identity::current(nodeId_, identity_); }
|
|
28
33
|
int nodeId_;
|
|
34
|
+
gea::framework::identity::Owner identity_;
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
class NodeHandle {
|
|
32
38
|
protected:
|
|
33
39
|
int id_;
|
|
40
|
+
gea::framework::identity::Owner identity_;
|
|
34
41
|
|
|
35
42
|
public:
|
|
36
43
|
// DOM Node.nodeType, resolved from the backing tree node. geatsc types a
|
|
@@ -38,14 +45,13 @@ public:
|
|
|
38
45
|
// runtime's `CompiledStaticComponent::render` element/fragment check
|
|
39
46
|
// (`node.nodeType === 1` / `=== 11`) lowers to a typed member read on this
|
|
40
47
|
// handle rather than a dynamic record lookup — the handle has to answer it.
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
// (text); 11 (document fragment) only arises for an invalid handle, e.g. the
|
|
44
|
-
// base `createDocumentFragment()` template no mounted component ever uses.
|
|
48
|
+
// Structural comments/fragments report 8/11 and never become visual boxes.
|
|
49
|
+
// A retired handle reports 0, distinct from a live empty fragment.
|
|
45
50
|
// Resolved lazily on read (cheap, rare) rather than at every handle
|
|
46
|
-
// construction (hot path)
|
|
51
|
+
// construction (hot path); generation ownership is captured separately.
|
|
47
52
|
struct NodeTypeProperty {
|
|
48
53
|
int id;
|
|
54
|
+
gea::framework::identity::Owner owner = gea::framework::identity::node(id);
|
|
49
55
|
operator int() const;
|
|
50
56
|
bool operator==(int other) const { return static_cast<int>(*this) == other; }
|
|
51
57
|
bool operator!=(int other) const { return static_cast<int>(*this) != other; }
|
|
@@ -57,11 +63,14 @@ public:
|
|
|
57
63
|
// constructor, so `explicit NodeHandle(int = -1)` alone breaks every
|
|
58
64
|
// generated `__gea_type_X __gea_out{};`.
|
|
59
65
|
NodeHandle() : NodeHandle(-1) {}
|
|
60
|
-
explicit NodeHandle(int id) : id_(id), nodeType{id} {}
|
|
66
|
+
explicit NodeHandle(int id) : id_(id), identity_(gea::framework::identity::node(id)), nodeType{id, identity_} {}
|
|
67
|
+
const void *identity() const { return identity_.get(); }
|
|
68
|
+
std::shared_ptr<const void> weakIdentityOwner() const { return identity_; }
|
|
61
69
|
// Event targets and DOM elements are two views of the same tree identity.
|
|
62
70
|
// Pointer/touch event targets declared as Element therefore project to a
|
|
63
71
|
// full node handle without boxing or losing the source node id.
|
|
64
|
-
NodeHandle(const gea::framework::events::EventTarget &target)
|
|
72
|
+
NodeHandle(const gea::framework::events::EventTarget &target)
|
|
73
|
+
: id_(target.id()), identity_(target.identityOwner()), nodeType{target.id(), identity_} {}
|
|
65
74
|
// Implicit build from a boxed node value (record carrying "__gea_node_id"),
|
|
66
75
|
// so the compiled-component emitters' `NodeHandle x = <gea_cpp_value>` copy-
|
|
67
76
|
// inits and NodeHandle-typed args accept a boxed node. SFINAE'd on
|
|
@@ -93,11 +102,24 @@ public:
|
|
|
93
102
|
return *this = __gea_native_from_value(value);
|
|
94
103
|
}
|
|
95
104
|
|
|
96
|
-
int id() const { return id_; }
|
|
97
|
-
bool valid() const { return id_
|
|
105
|
+
int id() const { return valid() ? id_ : -1; }
|
|
106
|
+
bool valid() const { return gea::framework::identity::current(id_, identity_); }
|
|
107
|
+
// Current allocation is in the explicitly mounted retained-tree subtree.
|
|
108
|
+
bool isConnected() const;
|
|
109
|
+
bool disabled() const;
|
|
110
|
+
void setDisabled(bool value) const;
|
|
111
|
+
static const char *selectorText(const std::string &s);
|
|
112
|
+
bool matches(const char *selector) const;
|
|
113
|
+
NodeHandle closest(const char *selector) const;
|
|
114
|
+
NodeHandle querySelector(const char *selector) const;
|
|
115
|
+
std::vector<NodeHandle> querySelectorAll(const char *selector) const;
|
|
116
|
+
bool matches(const std::string &s) const { return matches(selectorText(s)); }
|
|
117
|
+
NodeHandle closest(const std::string &s) const { return closest(selectorText(s)); }
|
|
118
|
+
NodeHandle querySelector(const std::string &s) const { return querySelector(selectorText(s)); }
|
|
119
|
+
std::vector<NodeHandle> querySelectorAll(const std::string &s) const { return querySelectorAll(selectorText(s)); }
|
|
98
120
|
explicit operator bool() const { return valid(); }
|
|
99
|
-
Style style() const { return Style(
|
|
100
|
-
ClassList classList() const { return ClassList(
|
|
121
|
+
Style style() const { return Style(id()); }
|
|
122
|
+
ClassList classList() const { return ClassList(id()); }
|
|
101
123
|
|
|
102
124
|
NodeTypeProperty nodeType;
|
|
103
125
|
|
|
@@ -106,14 +128,20 @@ public:
|
|
|
106
128
|
// lowering (gea_ir::domFirstChild), which geatsc resolves on Node-typed
|
|
107
129
|
// receivers; a same-named member function would shadow it.
|
|
108
130
|
NodeHandle firstChildHandle() const;
|
|
131
|
+
ChildNodeList childNodesHandle() const;
|
|
109
132
|
NodeHandle nextSiblingHandle() const;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
133
|
+
NodeHandle parentHandle() const;
|
|
134
|
+
std::vector<NodeHandle> elementChildren() const;
|
|
135
|
+
NodeHandle lastElementChildHandle() const;
|
|
136
|
+
// Replace children without retiring allocations. Retained children move to
|
|
137
|
+
// their final order; removed children remain live and may be reinserted.
|
|
113
138
|
void replaceChildren(const std::vector<NodeHandle> &children) const;
|
|
114
139
|
NodeHandle childAt(int index) const;
|
|
115
140
|
void appendChild(NodeHandle child) const;
|
|
116
|
-
|
|
141
|
+
NodeHandle insertBefore(NodeHandle child, NodeHandle reference) const;
|
|
142
|
+
// A literal JS null appends through the same ownerless native sentinel.
|
|
143
|
+
NodeHandle insertBefore(NodeHandle child, std::nullptr_t) const { return insertBefore(child, NodeHandle()); }
|
|
144
|
+
NodeHandle removeChild(NodeHandle child) const;
|
|
117
145
|
void setParent(NodeHandle parent) const;
|
|
118
146
|
void remove() const;
|
|
119
147
|
void setText(const char *text) const;
|
|
@@ -144,6 +172,10 @@ public:
|
|
|
144
172
|
// existed and had no handle-level spelling, so an app that wanted it (maps'
|
|
145
173
|
// hidden search input) had nothing typed to call.
|
|
146
174
|
void focus() const;
|
|
175
|
+
// Native responder focus never scrolls the Tree viewport. The supported
|
|
176
|
+
// options record honors preventScroll without fabricating viewport movement.
|
|
177
|
+
template<class Options> requires requires(const Options& options){options->preventScroll;}
|
|
178
|
+
void focus(const Options& options) const {(void)options;focus();}
|
|
147
179
|
void blur() const;
|
|
148
180
|
bool play() const;
|
|
149
181
|
void pause() const;
|
|
@@ -155,4 +187,11 @@ public:
|
|
|
155
187
|
bool removeEventListener(const char *type, gea::framework::events::EventListenerId listenerId) const;
|
|
156
188
|
};
|
|
157
189
|
|
|
190
|
+
// Platform focus owns the actual responder transition. Pixel targets use the
|
|
191
|
+
// unhandled default; native targets must explicitly accept or refuse.
|
|
192
|
+
enum class NativeFocusResult { unhandled, accepted, refused };
|
|
193
|
+
struct NativeFocusQuery { bool handled=false; NodeHandle node; };
|
|
194
|
+
NativeFocusResult requestNativeFocus(NodeHandle node,bool focus);
|
|
195
|
+
NativeFocusQuery queryNativeFocus();
|
|
196
|
+
|
|
158
197
|
} // namespace gea::embedded::ui
|
package/ui/node_lifecycle.cpp
CHANGED
|
@@ -191,6 +191,9 @@ constexpr ComputedStyle makeDefaultStyle()
|
|
|
191
191
|
#endif
|
|
192
192
|
// transform / perspective / filter / box-shadow moved to RareStyle; a fresh
|
|
193
193
|
// node (rare_style = -1) reads their correct defaults from the zero entry.
|
|
194
|
+
#if GEA_CSS_FONT_STRETCH
|
|
195
|
+
style.font_stretch = 1000;
|
|
196
|
+
#endif
|
|
194
197
|
style.font_id = -1;
|
|
195
198
|
style.font_size = 0;
|
|
196
199
|
#if GEA_CSS_FONT_WEIGHT
|
package/ui/node_model.h
CHANGED
|
@@ -136,9 +136,16 @@ enum class NodeType : uint8_t {
|
|
|
136
136
|
Button = 4,
|
|
137
137
|
VirtualList = 5,
|
|
138
138
|
Camera = 6,
|
|
139
|
-
Audio = 7
|
|
139
|
+
Audio = 7,
|
|
140
|
+
Comment = 8,
|
|
141
|
+
DocumentFragment = 9
|
|
140
142
|
};
|
|
141
143
|
|
|
144
|
+
inline bool isStructuralNodeType(NodeType type)
|
|
145
|
+
{
|
|
146
|
+
return type == NodeType::Comment || type == NodeType::DocumentFragment;
|
|
147
|
+
}
|
|
148
|
+
|
|
142
149
|
inline bool isViewLikeNodeType(NodeType type)
|
|
143
150
|
{
|
|
144
151
|
return type == NodeType::View || type == NodeType::Button || type == NodeType::VirtualList;
|
|
@@ -814,6 +821,12 @@ struct ComputedStyle {
|
|
|
814
821
|
|
|
815
822
|
// transform / perspective / filter / box-shadow moved to RareStyle (rare).
|
|
816
823
|
|
|
824
|
+
#if GEA_CSS_FONT_STRETCH
|
|
825
|
+
// Percentage in tenths: 1000 = normal 100%, preserving 87.5%.
|
|
826
|
+
int16_t font_stretch;
|
|
827
|
+
#else
|
|
828
|
+
static constexpr int16_t font_stretch = 1000;
|
|
829
|
+
#endif
|
|
817
830
|
int16_t font_id;
|
|
818
831
|
#if !GEA_CSS_U8_FONT
|
|
819
832
|
int16_t font_size;
|
|
@@ -1623,6 +1636,12 @@ struct Node {
|
|
|
1623
1636
|
RenderState render;
|
|
1624
1637
|
};
|
|
1625
1638
|
|
|
1639
|
+
// Structural DOM nodes never participate in visual layout, regardless of authored styles.
|
|
1640
|
+
inline bool isLayoutExcluded(const Node &node)
|
|
1641
|
+
{
|
|
1642
|
+
return isStructuralNodeType(node.type) || isDisplayNone(node.computedStyle());
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1626
1645
|
// Overflow clips the padding edge on each non-visible axis. Open axes span
|
|
1627
1646
|
// the positive display coordinate range and remain stationary during replay.
|
|
1628
1647
|
inline void overflowClipBounds(const Node &node, int &x, int &y, int &w, int &h)
|
package/ui/render.cpp
CHANGED
|
@@ -2861,7 +2861,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
2861
2861
|
|
|
2862
2862
|
gea::framework::graphics::RasterizedFont font =
|
|
2863
2863
|
gea::framework::graphics::FontRegistry::rasterizedFamily(command.projectedText.fontId,
|
|
2864
|
-
command.projectedText.fontSize);
|
|
2864
|
+
command.projectedText.fontSize,command.projectedText.fontWeight,command.projectedText.fontStretch);
|
|
2865
2865
|
if (!font.valid())
|
|
2866
2866
|
return;
|
|
2867
2867
|
|
|
@@ -2932,6 +2932,9 @@ int gLastScrollUiFrame = -1000;
|
|
|
2932
2932
|
#endif
|
|
2933
2933
|
std::uint32_t hash = 0;
|
|
2934
2934
|
int fontId = -2, fontSize = -1, srcW = -1, srcH = -1, textTransform = -1;
|
|
2935
|
+
#if GEA_CSS_FONT_STRETCH
|
|
2936
|
+
int fontWeight=400,fontStretch=1000;
|
|
2937
|
+
#endif
|
|
2935
2938
|
int bytes = 0;
|
|
2936
2939
|
int ink[4] = {0, 0, -1, -1};
|
|
2937
2940
|
bool valid = false;
|
|
@@ -2966,6 +2969,9 @@ int gLastScrollUiFrame = -1000;
|
|
|
2966
2969
|
for (auto &e : cache)
|
|
2967
2970
|
{
|
|
2968
2971
|
if (e.valid && e.hash == textHash && e.fontId == fid && e.fontSize == fsz &&
|
|
2972
|
+
#if GEA_CSS_FONT_STRETCH
|
|
2973
|
+
e.fontWeight==command.projectedText.fontWeight && e.fontStretch==command.projectedText.fontStretch &&
|
|
2974
|
+
#endif
|
|
2969
2975
|
e.srcW == srcW && e.srcH == srcH && e.textTransform == ttf)
|
|
2970
2976
|
{
|
|
2971
2977
|
hit = &e;
|
|
@@ -2989,6 +2995,9 @@ int gLastScrollUiFrame = -1000;
|
|
|
2989
2995
|
e.hash = textHash;
|
|
2990
2996
|
e.fontId = fid;
|
|
2991
2997
|
e.fontSize = fsz;
|
|
2998
|
+
#if GEA_CSS_FONT_STRETCH
|
|
2999
|
+
e.fontWeight=command.projectedText.fontWeight;e.fontStretch=command.projectedText.fontStretch;
|
|
3000
|
+
#endif
|
|
2992
3001
|
e.srcW = srcW;
|
|
2993
3002
|
e.srcH = srcH;
|
|
2994
3003
|
e.textTransform = ttf;
|
|
@@ -6834,7 +6843,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6834
6843
|
TextRenderer::drawWrapped(c.text.text, c.text.x, c.text.y,
|
|
6835
6844
|
c.text.maxWidth, c.text.color, c.text.scale,
|
|
6836
6845
|
c.text.align, c.text.containerWidth, c.text.fontId, c.text.textTransform, c.text.lineHeight,
|
|
6837
|
-
c.text.whiteSpace, c.text.textOverflow, c.text.maxHeight, c.text.firstLineIndent);
|
|
6846
|
+
c.text.whiteSpace, c.text.textOverflow, c.text.maxHeight, c.text.firstLineIndent,c.text.fontWeight,c.text.fontStretch);
|
|
6838
6847
|
break;
|
|
6839
6848
|
case DisplayCommandType::BlitImage:
|
|
6840
6849
|
#if GEA_PIXEL_STORAGE_PACKED
|
|
@@ -7101,6 +7110,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
7101
7110
|
{
|
|
7102
7111
|
if (!state.hasNodeScratchFor(id))
|
|
7103
7112
|
return;
|
|
7113
|
+
if (isStructuralNodeType(Tree::instance().node(id).type)) {
|
|
7114
|
+
state.clearNodeRange(id);
|
|
7115
|
+
return;
|
|
7116
|
+
}
|
|
7104
7117
|
// Backdrop-cache record skip: skip recording a subtree only when it's fully
|
|
7105
7118
|
// static — neither containing a dirty node (subtreeDirty) NOR sitting under one
|
|
7106
7119
|
// (insideDirty, set once we descend into a dirty node so the cube's faces are
|
|
@@ -9649,7 +9662,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9649
9662
|
auto walk = [&](auto &&self, int parent, bool withinGroup) -> void {
|
|
9650
9663
|
std::vector<int> children;
|
|
9651
9664
|
for (int child = nodes[parent].first_child; child >= 0; child = nodes[child].next_sibling)
|
|
9652
|
-
if (!isDisplayNone(nodes[child].computedStyle())) children.push_back(child);
|
|
9665
|
+
if (!isStructuralNodeType(nodes[child].type) && !isDisplayNone(nodes[child].computedStyle())) children.push_back(child);
|
|
9653
9666
|
if (nodes[parent].computedStyle().display == kDisplayFlex || isDisplayGrid(nodes[parent].computedStyle())) {
|
|
9654
9667
|
std::stable_sort(children.begin(), children.end(), [&](int a, int b) {
|
|
9655
9668
|
const int oa = isOutOfFlowPosition(nodes[a].computedStyle().position) ? 0 : nodes[a].computedStyle().order;
|