From 1bb21ae4e3e4b21950cbdd055620df8da809ffb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sat, 19 Sep 2026 18:45:34 +0200 Subject: [PATCH] Implement interactive constraint validation feedback (#708) --- ...nternals-constraint-validation-20260919.md | 5 +- ...trol-constraint-validation-idl-20260919.md | 11 +- ...bmission-constraint-validation-20260919.md | 5 +- ...eractive-constraint-validation-20260919.md | 46 +++++++ .../native/webscene_native_dom.h | 18 ++- .../native/webscene_native_dom_scene.inc | 53 ++++++++ .../native/webscene_native_dom_tree.inc | 48 ++++++++ .../native/webscene_v8_runtime.cpp | 9 +- .../webscene_v8_runtime_dom_properties.inc | 114 +++++++++++++++++- .../native/webscene_v8_runtime_semantics.inc | 20 ++- .../native/webscene_v8_runtime_state.inc | 1 + .../native/webscene_v8_runtime_tasks.inc | 18 ++- 12 files changed, 328 insertions(+), 20 deletions(-) create mode 100644 docs/validation/interactive-constraint-validation-20260919.md diff --git a/docs/validation/element-internals-constraint-validation-20260919.md b/docs/validation/element-internals-constraint-validation-20260919.md index e9f1ec95..9f2db9a8 100644 --- a/docs/validation/element-internals-constraint-validation-20260919.md +++ b/docs/validation/element-internals-constraint-validation-20260919.md @@ -38,8 +38,9 @@ DOM layer. ## Deferred surface -`reportValidity()` deliberately adds no native validation bubble or focus -movement. Selector reads and subject recascade are live, but this slice adds no +WebScene #708 adds interactive `reportValidity()` focus and feedback and uses +the retained validation anchor for both direct and form-level reports. +Selector reads and subject recascade are live, but this slice adds no descendant-driven structural recascade for a form or fieldset whose aggregate validity changed. Label association, ARIA reflection, `CustomStateSet`, `HTMLFormElement.elements` integration, and a persisted session-history or diff --git a/docs/validation/form-control-constraint-validation-idl-20260919.md b/docs/validation/form-control-constraint-validation-idl-20260919.md index d8d59b2d..03b0b61a 100644 --- a/docs/validation/form-control-constraint-validation-idl-20260919.md +++ b/docs/validation/form-control-constraint-validation-idl-20260919.md @@ -17,9 +17,10 @@ custom error while `willValidate` is false; its validation message is empty and its validation methods return true. Both validation methods dispatch `invalid` at an invalid validation candidate. -The event is cancelable and does not bubble. `reportValidity()` currently has -the same observable dispatch and result as `checkValidity()` because native -validation UI is outside this slice. +The event is cancelable and does not bubble. WebScene #708 extends +`reportValidity()` with the bounded interactive behavior described in +`interactive-constraint-validation-20260919.md`; `checkValidity()` remains a +noninteractive validity query. ## State and invalidation bound @@ -42,8 +43,8 @@ owns the native companion for prototype placement, wrapper identity and liveness, flag projection, custom-error selector changes, event dispatch, and barred-control behavior. -Form and fieldset aggregation, submission-time validation, interactive native -validation UI, `datetime-local`, file-input value-missing state, and the UI-only +Form and fieldset aggregation, submission-time validation, `datetime-local`, +file-input value-missing state, and the UI-only bad-input and user-edited length transitions remain separate work. Per task direction, no build, generated-binding check, native test, browser/WPT diff --git a/docs/validation/form-submission-constraint-validation-20260919.md b/docs/validation/form-submission-constraint-validation-20260919.md index fc9de8e9..10271504 100644 --- a/docs/validation/form-submission-constraint-validation-20260919.md +++ b/docs/validation/form-submission-constraint-validation-20260919.md @@ -13,8 +13,9 @@ and form/fieldset elements never match `:user-valid` or `:user-invalid`. `HTMLFormElement.checkValidity()` and `reportValidity()` statically validate all owned candidates in tree order. Every invalid candidate receives the existing cancelable, non-bubbling `invalid` event, and either method returns false when -any candidate was invalid. `reportValidity()` deliberately adds no native -validation UI in this slice. +any candidate was invalid. WebScene #708 subsequently adds bounded interactive +feedback to `reportValidity()` while leaving submit-attempt validation on this +noninteractive path. Submit-button and implicit submission now set user validity on each owned input, select, and textarea before validation. A failing validation dispatches diff --git a/docs/validation/interactive-constraint-validation-20260919.md b/docs/validation/interactive-constraint-validation-20260919.md new file mode 100644 index 00000000..a9581358 --- /dev/null +++ b/docs/validation/interactive-constraint-validation-20260919.md @@ -0,0 +1,46 @@ +# Interactive constraint-validation source contract + +## Implemented boundary + +WebScene #708 makes `reportValidity()` interactive without changing +`checkValidity()` or submit-attempt validation. Form reports snapshot invalid +candidates in existing tree/form-owner order, dispatch one cancelable, +non-bubbling `invalid` event to every candidate, and choose the first +uncanceled candidate that remains connected and focusable after dispatch. +Control reports apply the same cancelation rule. A form-associated custom +element retains its validated descendant anchor so direct and form reports +focus and position feedback against the same element. + +The selected target receives focus once. The document then owns at most one +validation message: a 1 KiB UTF-8-bounded string plus target and anchor IDs in +the document's existing lazy auxiliary allocation. The scene appends a clipped +overlay through existing retained rectangle, border, clip, and text commands; +it creates no author DOM and needs no presenter ABI. Normal scene publication +recomputes geometry from the current anchor, so layout, scrolling, and viewport +changes reposition feedback without timers, sustained frames, selector +matching, cascade, or visual-tree mutation. + +The same bounded message produces one newest-wins assertive semantic live +event through the existing semantic ABI. It is consumed once and respects the +existing live-event count bound. Text content is not written to diagnostics. + +## Lifetime and dismissal + +Input or change on the target, custom-validity mutation, successful or repeated +interactive validation, focus transfer away from the target/anchor, target or +anchor subtree detachment, navigation, and teardown dismiss the retained +message. Navigation also retires any unconsumed semantic announcement. Stale +native IDs fail closed during scene construction, and a candidate removed by +an earlier `invalid` handler is skipped when focus is selected. + +## Validation status and deferred boundary + +The behavior follows the HTML interactive constraint-validation ordering and +cancelation model and reuses WebScene's existing focus, scene, and semantic +contracts. Per task direction, no build, native test, browser/WPT run, pixel +check, package gate, or CI job was run. Only `git diff --check` is used for this +commit, so the authored contract remains unexecuted source evidence. + +Rich multi-line bubble layout, user-agent localization beyond the existing +validation messages, timed auto-dismissal, and structural selector +invalidation remain outside #708. diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h index 4e43087c..89f580c6 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1458,6 +1459,7 @@ struct dom_node final { struct form_control_data final { std::string value; std::string custom_validation_message; + uint32_t validation_anchor_id{0}; uint16_t element_internals_validity_flags{0}; size_t selection_start{0}; size_t selection_end{0}; @@ -2145,6 +2147,11 @@ class native_document final { bool is_modal_dialog(const dom_node& node) const noexcept; bool is_in_modal_layer(const dom_node& node) const noexcept; bool is_inert(const dom_node& node) const noexcept; + void show_validation_message( + const dom_node& target, const dom_node& anchor, std::string message); + bool clear_validation_message() noexcept; + uint32_t validation_message_target_id() const noexcept; + uint32_t validation_message_anchor_id() const noexcept; dom_node* hit_test(dom_node& root, float x, float y); void clear(); void layout(float viewport_width, float viewport_height); @@ -2582,9 +2589,18 @@ class native_document final { // ever-growing pointer table. std::vector native_id_index_; struct modal_dialog_entry final { uint32_t scope_id; uint32_t dialog_id; }; + struct validation_message_state final { + uint32_t target_id{}; + uint32_t anchor_id{}; + std::string message; + }; // Most documents never open a modal. Keep the container allocation lazy // and its implementation-specific vector footprint out of every document. - struct auxiliary_nodes { std::vector dialogs; std::vector media; }; + struct auxiliary_nodes { + std::vector dialogs; + std::vector media; + std::optional validation_message; + }; std::unique_ptr auxiliary_nodes_; std::span modal_dialogs() const noexcept { return auxiliary_nodes_ ? std::span(auxiliary_nodes_->dialogs) diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_scene.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_scene.inc index 79645371..d30b58d4 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_scene.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_scene.inc @@ -59,6 +59,59 @@ void native_document::build_scene( append_scene(*modal, commands, strings, string_bytes, hidden, false, false, nullptr, nullptr, ordered_canvas, true, capture_gpu_outputs); } + // Interactive constraint feedback is engine-owned and therefore never + // enters the author DOM. Emit one retained overlay after all author and + // modal content. Its geometry is recomputed only when a scene is already + // being published, so scrolling/layout naturally repositions it without + // animation-frame demand or another cascade pass. + if (auxiliary_nodes_ && auxiliary_nodes_->validation_message) { + const auto& state = *auxiliary_nodes_->validation_message; + const auto* anchor = state.anchor_id == 0U + || state.anchor_id > native_id_index_.size() + ? nullptr : native_id_index_[state.anchor_id - 1U]; + const auto* target = state.target_id == 0U + || state.target_id > native_id_index_.size() + ? nullptr : native_id_index_[state.target_id - 1U]; + if (anchor != nullptr && target != nullptr + && is_connected(*anchor) && is_connected(*target) + && viewport_width_ > 0.0F && viewport_height_ > 0.0F) { + constexpr float padding = 9.0F; + constexpr float font_size = 13.0F; + constexpr float line_height = 18.0F; + constexpr float bubble_height = line_height + padding * 2.0F; + const auto text_width = measure_text_width(state.message, font_size); + const auto bubble_width = std::clamp( + text_width + padding * 2.0F, + std::min(160.0F, viewport_width_), + std::min(360.0F, viewport_width_)); + const auto x = std::clamp( + anchor->layout.x, 0.0F, std::max(0.0F, viewport_width_ - bubble_width)); + const auto below = anchor->layout.y + anchor->layout.height + 6.0F; + const auto above = anchor->layout.y - bubble_height - 6.0F; + const auto y = below + bubble_height <= viewport_height_ + ? below : std::max(0.0F, above); + commands.push_back(webscene_scene_command{ + 10U, 0U, x, y, bubble_width, bubble_height, + 0x202124F2U, anchor->id, 5, 5, 5, 5, 0}); + commands.push_back(webscene_scene_command{ + 11U, 0U, x, y, bubble_width, bubble_height, + 0xFFFFFFFFU, anchor->id, 5, 5, 5, 5, 1}); + commands.push_back(webscene_scene_command{ + 12U, 0U, x + padding, y + padding, + std::max(0.0F, bubble_width - padding * 2.0F), line_height, + 0U, anchor->id}); + const auto resource = std::to_string(font_size) + '\t' + + std::to_string(line_height) + "\t600\tstart\tsans-serif\tauto\t" + + state.message; + commands.push_back(webscene_scene_command{ + 3U, append_scene_string(resource, strings, string_bytes), + x + padding, y + padding, + std::max(0.0F, bubble_width - padding * 2.0F), line_height, + 0xFFFFFFFFU, anchor->id, 0, 0, 0, 0, 0}); + commands.push_back(webscene_scene_command{ + 13U, 0U, 0, 0, 0, 0, 0U, anchor->id}); + } + } } void native_document::publish_gpu_canvas_image(dom_node& node, diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_tree.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_tree.inc index 13eebc2d..50896d37 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_tree.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_native_dom_tree.inc @@ -999,3 +999,51 @@ void native_document::clear() body_->style.background_rgba = 0x131722FFU; mark_dirty(); } + +void native_document::show_validation_message( + const dom_node& target, const dom_node& anchor, std::string message) +{ + constexpr size_t maximum_message_bytes = 1024U; + for (auto& character : message) { + if (character == '\t' || character == '\r' || character == '\n') character = ' '; + } + if (message.size() > maximum_message_bytes) { + message.resize(maximum_message_bytes); + auto lead = message.size() - 1U; + while (lead > 0U + && (static_cast(message[lead]) & 0xc0U) == 0x80U) { + --lead; + } + const auto first = static_cast(message[lead]); + const auto expected = (first & 0x80U) == 0U ? 1U + : (first & 0xe0U) == 0xc0U ? 2U + : (first & 0xf0U) == 0xe0U ? 3U + : (first & 0xf8U) == 0xf0U ? 4U : 1U; + if (message.size() - lead < expected) message.resize(lead); + } + if (message.empty()) return; + if (!auxiliary_nodes_) auxiliary_nodes_ = std::make_unique(); + auxiliary_nodes_->validation_message = validation_message_state{ + target.id, anchor.id, std::move(message)}; + mark_scene_changed(); +} + +bool native_document::clear_validation_message() noexcept +{ + if (!auxiliary_nodes_ || !auxiliary_nodes_->validation_message) return false; + auxiliary_nodes_->validation_message.reset(); + mark_scene_changed(); + return true; +} + +uint32_t native_document::validation_message_target_id() const noexcept +{ + return auxiliary_nodes_ && auxiliary_nodes_->validation_message + ? auxiliary_nodes_->validation_message->target_id : 0U; +} + +uint32_t native_document::validation_message_anchor_id() const noexcept +{ + return auxiliary_nodes_ && auxiliary_nodes_->validation_message + ? auxiliary_nodes_->validation_message->anchor_id : 0U; +} diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp index c5c817eb..60caacfb 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime.cpp @@ -776,7 +776,7 @@ struct v8_dom_runtime::implementation final { v8::FunctionTemplate::New(isolate, validate_control)); element->PrototypeTemplate()->Set( js_string(isolate, "reportValidity"), - v8::FunctionTemplate::New(isolate, validate_control)); + v8::FunctionTemplate::New(isolate, report_control)); element->PrototypeTemplate()->Set( js_string(isolate, "submit"), v8::FunctionTemplate::New(isolate, form_submit)); @@ -3479,7 +3479,7 @@ struct v8_dom_runtime::implementation final { record.validationMessage = validationMessage; record.validationAnchor = anchor; setElementInternalsValidity( - element, validityFlags, validationMessage); + element, validityFlags, validationMessage, anchor); }, writable: true, configurable: true @@ -3494,8 +3494,9 @@ struct v8_dom_runtime::implementation final { }, reportValidity: { value() { - const {element} = associatedInternalsRecord(this); - return Boolean(validateElementInternals(element)); + const {element, validationAnchor} = associatedInternalsRecord(this); + return Boolean(validateElementInternals( + element, true, validationAnchor)); }, writable: true, configurable: true diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_properties.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_properties.inc index 66d6955b..071e8285 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_properties.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_properties.inc @@ -3465,6 +3465,8 @@ node->mutable_form_control().custom_validation_message=std::move(message); const auto selector_state_after=forms::validity_state( self->document,*node); + if(self->document.validation_message_target_id()==node->id) + self->dismiss_validation_message(); if(selector_state_before==selector_state_after) return; if(self->is_connected(*node)) self->recascade_dynamic_state_subject(*node,"setCustomValidity"); @@ -3487,6 +3489,7 @@ if(!enabled) { control.element_internals_validity_flags=0U; control.custom_validation_message.clear(); + control.validation_anchor_id=0U; control.user_validity_interacted=false; } const auto selector_state_after=forms::validity_state( @@ -3515,8 +3518,16 @@ :0U; control.custom_validation_message=info.Length()>2 ? to_utf8(info.GetIsolate(),info[2]):std::string{}; + control.validation_anchor_id=0U; + if(info.Length()>3 && info[3]->IsObject()) { + if(auto* anchor=unwrap_node(info[3].As()); + anchor!=nullptr && self->subtree_contains(*node,anchor)) + control.validation_anchor_id=anchor->id; + } const auto selector_state_after=forms::validity_state( self->document,*node); + if(self->document.validation_message_target_id()==node->id) + self->dismiss_validation_message(); if(selector_state_before==selector_state_after) return; if(self->is_connected(*node)) self->recascade_connected_subtree( @@ -3596,10 +3607,65 @@ } const auto valid=!forms::will_validate(self->document,*node) || forms::constraint_validity_state(self->document,*node).valid(); - if(!valid) static_cast(self->dispatch_invalid_event(*node)); + const auto interactive=info.Length()>1 + && info[1]->BooleanValue(info.GetIsolate()); + dom_node* anchor=node; + if(interactive && info.Length()>2 && info[2]->IsObject()) { + if(auto* candidate=unwrap_node(info[2].As()); + candidate!=nullptr && self->is_connected(*candidate) + && self->subtree_contains(*node,candidate)) anchor=candidate; + } + if(interactive) self->dismiss_validation_message(); + if(!valid) { + const auto uncanceled=self->dispatch_invalid_event(*node); + if(interactive && uncanceled) + self->present_validation_message(*node,*anchor); + } info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(),valid)); } + void dismiss_validation_message() + { + if(document.clear_validation_message()) pending_validation_announcement.reset(); + } + + bool present_validation_message(dom_node& target, dom_node& anchor) + { + if(!is_connected(target) || !is_connected(anchor) + || !is_programmatically_focusable(&anchor)) return false; + auto message=forms::validation_message(document,target); + if(message.empty()) return false; + webscene_input_event synthetic{}; + if(!set_active_element(&anchor,synthetic)) return false; + document.show_validation_message(target,anchor,message); + semantic_live_event_data_v1 event; + event.top_document_generation=document_generation.load( + std::memory_order_acquire); + event.frame_owner_dom_node_id=focus_document_owner(&anchor); + if(event.frame_owner_dom_node_id!=0U) { + const auto generation=frame_navigation_generations.find( + event.frame_owner_dom_node_id); + if(generation!=frame_navigation_generations.end()) + event.frame_generation=generation->second; + } + event.dom_node_id=target.id; + event.semantic_id=semantic_identity( + event.top_document_generation,event.frame_generation, + event.frame_owner_dom_node_id,target.id); + event.role=WEBSCENE_SEMANTIC_LIVE_REGION_ALERT_V1; + event.politeness=WEBSCENE_SEMANTIC_LIVE_ASSERTIVE_V1; + event.flags=WEBSCENE_SEMANTIC_LIVE_ATOMIC_V1 + | WEBSCENE_SEMANTIC_LIVE_RELEVANT_ADDITIONS_V1; + event.text=std::move(message); + if(event.text.size()>1024U) { + event.text.resize(1024U); + semantic_live_trim_incomplete_utf8(event.text); + event.flags|=WEBSCENE_SEMANTIC_LIVE_TEXT_TRUNCATED_V1; + } + pending_validation_announcement=std::move(event); + return true; + } + bool dispatch_invalid_event(dom_node& node) { auto local_context=isolate->GetCurrentContext(); @@ -3623,7 +3689,7 @@ && !result->IsFalse(); } - bool validate_form_constraints(dom_node& form) + bool validate_form_constraints(dom_node& form, bool interactive=false) { std::vector invalid_controls; for(const auto* candidate:forms::form_validation_controls(document,form)) { @@ -3631,8 +3697,25 @@ && !forms::constraint_validity_state(document,*candidate).valid()) invalid_controls.push_back(const_cast(candidate)); } - for(auto* control:invalid_controls) - static_cast(dispatch_invalid_event(*control)); + if(interactive) dismiss_validation_message(); + for(auto*& control:invalid_controls) { + const auto uncanceled=dispatch_invalid_event(*control); + if(!uncanceled) control=nullptr; + } + if(interactive) { + for(auto* control:invalid_controls) { + if(control==nullptr || !is_connected(*control)) continue; + auto* anchor=control; + if(control->form_control().validation_anchor_id!=0U) { + if(auto* stored=document.find_by_native_id( + control->form_control().validation_anchor_id); + stored!=nullptr && is_connected(*stored) + && subtree_contains(*control,stored)) anchor=stored; + } + if(is_programmatically_focusable(anchor) + && present_validation_message(*control,*anchor)) break; + } + } return invalid_controls.empty(); } @@ -3657,6 +3740,29 @@ info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(),valid)); } + static void report_control( + const v8::FunctionCallbackInfo& info) + { + auto* self=current(info.GetIsolate()); + auto* node=unwrap_node(info.This()); + if(self!=nullptr && node!=nullptr && node->tag=="form") { + info.GetReturnValue().Set(v8::Boolean::New( + info.GetIsolate(),self->validate_form_constraints(*node,true))); + return; + } + if(self==nullptr || !is_constraint_validation_element(node)) { + info.GetReturnValue().Set(v8::True(info.GetIsolate())); + return; + } + self->dismiss_validation_message(); + const auto candidate=forms::will_validate(self->document,*node); + const auto valid=!candidate + || forms::constraint_validity_state(self->document,*node).valid(); + if(!valid && self->dispatch_invalid_event(*node)) + static_cast(self->present_validation_message(*node,*node)); + info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(),valid)); + } + static bool is_form_submitter(const dom_node* node) { if(node==nullptr) return false; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc index 04625017..28651dfc 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc @@ -411,7 +411,18 @@ } }; visit(document.body(), 0U, 0U, false, false); - if (scan_truncated) return {}; + if (scan_truncated) { + semantic_live_capture_data_v1 capture; + capture.top_document_generation = top_generation; + if (pending_validation_announcement) { + if (capture.events.size() + < WEBSCENE_SEMANTIC_LIVE_MAXIMUM_PENDING_EVENTS_V1) + capture.events.push_back( + std::move(*pending_validation_announcement)); + pending_validation_announcement.reset(); + } + return capture; + } std::vector events; events.reserve(std::min(current.size(), static_cast(32U))); @@ -563,6 +574,12 @@ capture.live_region_semantic_ids.begin(), capture.live_region_semantic_ids.end()); capture.events = std::move(events); + if (pending_validation_announcement) { + if (capture.events.size() + < WEBSCENE_SEMANTIC_LIVE_MAXIMUM_PENDING_EVENTS_V1) + capture.events.push_back(std::move(*pending_validation_announcement)); + pending_validation_announcement.reset(); + } return capture; } @@ -570,6 +587,7 @@ { semantic_live_regions.clear(); semantic_live_suppress_initial_alerts = suppress_initial_alerts; + pending_validation_announcement.reset(); } std::shared_ptr build_semantic_snapshot_v1( diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_state.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_state.inc index a56e91ed..6ced4c7d 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_state.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_state.inc @@ -47,6 +47,7 @@ std::unordered_map semantic_live_regions; bool semantic_live_suppress_initial_alerts{false}; + std::optional pending_validation_announcement; std::shared_ptr shared_isolate; std::shared_ptr allocator; v8::Isolate* isolate{nullptr}; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc index 805040fe..035e0237 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc @@ -1772,6 +1772,11 @@ dom_node* submitter = nullptr, std::optional trusted = std::nullopt) { + const auto type_view = std::string_view(type); + if ((type_view == "input" || type_view == "change") + && document.validation_message_target_id() == target.id) { + dismiss_validation_message(); + } webscene_frame_trace::scope trace(frame_trace, "event-start", "event-end", input.sequence); const auto previous_context = isolate->GetCurrentContext(); auto local_context = context_for_node(target); @@ -1796,7 +1801,6 @@ ++event_dispatch_target_counts[type][target.id]; #endif const auto callback_count_before = input_callback_invocation_count; - const auto type_view = std::string_view(type); const auto drag_event = type_view == "dragstart" || type_view == "dragend" || type_view == "dragenter" || type_view == "dragover" || type_view == "dragleave" @@ -2600,6 +2604,11 @@ bool set_active_element(dom_node* next, const webscene_input_event& input) { + const auto validation_target=document.validation_message_target_id(); + const auto validation_anchor=document.validation_message_anchor_id(); + if(validation_target!=0U && (next==nullptr + || (next->id!=validation_target && next->id!=validation_anchor))) + dismiss_validation_message(); const auto next_owner = next == nullptr ? focused_document_owner_id : focus_document_owner(next); if (active_element == next && focused_document_owner_id == next_owner) @@ -2707,6 +2716,13 @@ bool blur_active_element_before_detach(dom_node& detached_root) { + const auto validation_target=document.find_by_native_id( + document.validation_message_target_id()); + const auto validation_anchor=document.find_by_native_id( + document.validation_message_anchor_id()); + if(subtree_contains(detached_root,validation_target) + || subtree_contains(detached_root,validation_anchor)) + dismiss_validation_message(); document.unregister_modal_subtree(detached_root); auto *focused_owner = focused_document_owner_id == 0U