Skip to content

Commit ff94bad

Browse files
Merge pull request #472 from SceneTech/feature/trusted-input-events-470
Expose trusted native input events
2 parents e4d8f5f + 5aa3a28 commit ff94bad

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_browser_apis.inc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@
849849
event->Set(local_context, js_string(isolate, "bubbles"), v8::False(isolate)).Check();
850850
event->Set(local_context, js_string(isolate, "cancelable"), v8::False(isolate)).Check();
851851
event->Set(local_context, js_string(isolate, "composed"), v8::False(isolate)).Check();
852+
event->Set(local_context, js_string(isolate, "isTrusted"), v8::False(isolate)).Check();
852853
event->Set(
853854
local_context,
854855
js_string(isolate, "__webSceneComposedPath"),

‎experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_core.inc‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4754,7 +4754,9 @@
47544754
synthetic,
47554755
"click",
47564756
*node,
4757-
&default_prevented)) {
4757+
&default_prevented,
4758+
nullptr,
4759+
false)) {
47584760
if (checkable_activation.active) {
47594761
if (default_prevented) {
47604762
self->restore_checkable_click_activation(checkable_activation);
@@ -4764,8 +4766,10 @@
47644766
}
47654767
if (!default_prevented) self->queue_external_navigation(*node);
47664768
if (form_control_changed && self->is_connected(*node)) {
4767-
self->dispatch_input_event_type(synthetic, "input", *node);
4768-
self->dispatch_input_event_type(synthetic, "change", *node);
4769+
self->dispatch_input_event_type(
4770+
synthetic, "input", *node, nullptr, nullptr, false);
4771+
self->dispatch_input_event_type(
4772+
synthetic, "change", *node, nullptr, nullptr, false);
47694773
}
47704774
}
47714775
}

‎experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,8 @@
17661766
const char* type,
17671767
dom_node& target,
17681768
bool* default_prevented = nullptr,
1769-
dom_node* submitter = nullptr)
1769+
dom_node* submitter = nullptr,
1770+
std::optional<bool> trusted = std::nullopt)
17701771
{
17711772
webscene_frame_trace::scope trace(frame_trace, "event-start", "event-end", input.sequence);
17721773
const auto previous_context = isolate->GetCurrentContext();
@@ -1826,6 +1827,10 @@
18261827
event->Set(local_context, js_string(isolate, "bubbles"), v8::Boolean::New(isolate, bubbles)).Check();
18271828
event->Set(local_context, js_string(isolate, "cancelable"), v8::Boolean::New(isolate, cancelable)).Check();
18281829
event->Set(local_context, js_string(isolate, "defaultPrevented"), v8::False(isolate)).Check();
1830+
event->Set(
1831+
local_context,
1832+
js_string(isolate, "isTrusted"),
1833+
v8::Boolean::New(isolate, trusted.value_or(dispatching_user_input))).Check();
18291834
if (type_view == "beforetoggle") {
18301835
event->Set(local_context, js_string(isolate, "oldState"), js_string(isolate, "closed")).Check();
18311836
event->Set(local_context, js_string(isolate, "newState"), js_string(isolate, "open")).Check();

0 commit comments

Comments
 (0)