From e588d70bae63ba4d468a66bb6f5ab7372534081a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sat, 19 Sep 2026 16:59:43 +0200 Subject: [PATCH] Repair full-V8 GCC portability (#688) --- .../native/webscene_v8_runtime_dom_core.inc | 14 +++++------ .../webscene_v8_runtime_dom_properties.inc | 4 +++- .../native/webscene_v8_runtime_navigation.inc | 23 +++++++++++-------- .../webscene_v8_runtime_outbound_drag.inc | 8 +++---- .../native/webscene_v8_runtime_resources.inc | 2 +- .../native/webscene_v8_runtime_semantics.inc | 4 ++-- .../native/webscene_v8_runtime_style.inc | 4 ++-- .../native/webscene_v8_runtime_tasks.inc | 2 +- 8 files changed, 34 insertions(+), 27 deletions(-) diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_core.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_core.inc index c6467299..6cc8af0e 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_core.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_dom_core.inc @@ -361,7 +361,7 @@ } else if (owner->tag == "style") { append_node_text(*owner, source); } - info.GetReturnValue().Set(js_string(info.GetIsolate(), source)); + info.GetReturnValue().Set(js_string(info.GetIsolate(), source.c_str())); } static void load_style_sheet_import( @@ -390,9 +390,9 @@ } auto result = v8::Object::New(info.GetIsolate()); result->Set(local_context, js_string(info.GetIsolate(), "source"), - js_string(info.GetIsolate(), source)).Check(); + js_string(info.GetIsolate(), source.c_str())).Check(); result->Set(local_context, js_string(info.GetIsolate(), "url"), - js_string(info.GetIsolate(), resolved)).Check(); + js_string(info.GetIsolate(), resolved.c_str())).Check(); info.GetReturnValue().Set(result); } @@ -425,16 +425,16 @@ } } result->Set(local_context, js_string(isolate, "href"), - node.tag == "link" ? js_string(isolate, base_address).As() + node.tag == "link" ? js_string(isolate, base_address.c_str()).As() : v8::Null(isolate).As()).Check(); result->Set(local_context, js_string(isolate, "title"), node.attributes.contains("title") - ? js_string(isolate, node.attributes.at("title")).As() + ? js_string(isolate, node.attributes.at("title").c_str()).As() : v8::Null(isolate).As()).Check(); result->DefineOwnProperty( local_context, js_string(isolate, "__webSceneBaseURL"), - js_string(isolate, base_address), + js_string(isolate, base_address.c_str()), static_cast( v8::DontEnum | v8::DontDelete | v8::ReadOnly)).Check(); result->DefineOwnProperty( @@ -1114,7 +1114,7 @@ }); } - const std::string& effective_document_base(dom_node* root) + const std::string& effective_document_base(const dom_node* root) { if (root == nullptr) root = &document.body(); auto [found, inserted] = document_base_caches.try_emplace(root); 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 cdd6c0bd..66d6955b 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 @@ -3683,7 +3683,9 @@ if(self==nullptr || form==nullptr || form->tag!="form") return; dom_node* submitter=nullptr; if(info.Length()>0 && !info[0]->IsNullOrUndefined()) { - submitter=unwrap_node(info[0]); + submitter=info[0]->IsObject() + ? unwrap_node(info[0].As()) + : nullptr; if(!is_form_submitter(submitter)) { info.GetIsolate()->ThrowException(v8::Exception::TypeError( js_string(info.GetIsolate(), diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_navigation.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_navigation.inc index b668affd..0fab6438 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_navigation.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_navigation.inc @@ -1,3 +1,17 @@ + void report_document_script_error(const std::string& error) + { + if (diagnostics == nullptr + || !diagnostics->enabled(WEBSCENE_DIAGNOSTIC_LEGACY_CONSOLE)) { + return; + } + std::lock_guard lock(console_message_mutex); + constexpr size_t maximum_console_messages = 1024U; + if (console_messages.size() >= maximum_console_messages) { + console_messages.pop_front(); + } + console_messages.push_back("error\n" + error); + } + #if defined(WEBSCENE_NATIVE_ENGINE_ENABLE_GRAPHICS) void retire_document_graphics() { @@ -712,15 +726,6 @@ // own image subtrees separately. enqueue_connected_image_resources_subtree(html_element, local_context); - const auto report_document_script_error = [&](const std::string& error) { - if (diagnostics == nullptr || !diagnostics->enabled(WEBSCENE_DIAGNOSTIC_LEGACY_CONSOLE)) return; - std::lock_guard lock(console_message_mutex); - constexpr size_t maximum_console_messages = 1024U; - if (console_messages.size() >= maximum_console_messages) { - console_messages.pop_front(); - } - console_messages.push_back("error\n" + error); - }; const auto execute_group = [&](bool defer) { for (const auto& script : scripts) { if (script.defer != defer) continue; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_outbound_drag.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_outbound_drag.inc index 1bb691dd..066d832c 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_outbound_drag.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_outbound_drag.inc @@ -62,7 +62,7 @@ return candidate; } if (hit == nullptr) return nullptr; - auto* root = css_cascade_root_for_node(hit); + auto* root = css_cascade_root_for_node(*hit); const auto root_id = root == nullptr ? document.body().id : root->id; if (const auto known = window_selections.find(root_id); known != window_selections.end() && validate_selection(known->second) @@ -74,7 +74,7 @@ std::string outbound_selection_text(dom_node& source) { - auto* root = css_cascade_root_for_node(&source); + auto* root = css_cascade_root_for_node(source); const auto root_id = root == nullptr ? document.body().id : root->id; const auto known = window_selections.find(root_id); if (known == window_selections.end() || !validate_selection(known->second) @@ -202,7 +202,7 @@ const auto href = source.attributes.find("href"); if (href != source.attributes.end()) { auto uri = resolve_resource_url( - href->second, effective_document_base(css_cascade_root_for_node(&source))); + href->second, effective_document_base(css_cascade_root_for_node(source))); if (!uri.empty() && !add_outbound_item(*request, WEBSCENE_OUTBOUND_DRAG_ITEM_URI_V1, "text/uri-list", std::move(uri))) { @@ -214,7 +214,7 @@ auto uri = source.replaced_image().resolved_source; if (uri.empty()) uri = resolve_resource_url( source.attributes["src"], - effective_document_base(css_cascade_root_for_node(&source))); + effective_document_base(css_cascade_root_for_node(source))); std::string name; if (const auto alt = source.attributes.find("alt"); alt != source.attributes.end()) name = alt->second; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_resources.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_resources.inc index e2b995da..d85b52ec 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_resources.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_resources.inc @@ -1280,7 +1280,7 @@ connected_resource_task& resource, const service_worker_fetch_result* controlled) { - if (resource.node == nullptr || !document.is_connected(*resource.node) + if (resource.node == nullptr || !is_connected(*resource.node) || resource.document_generation != document_generation.load(std::memory_order_acquire)) { return; 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 64a7573b..41fc5ad4 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc @@ -599,7 +599,7 @@ std::vector> all_id_nodes; const auto append_document = [&](uint32_t frame_owner, uint64_t frame_generation, - std::string_view origin) { + std::string_view origin) -> uint32_t { if (result->documents.size() == maximum_semantic_documents_v1) { result->flags |= WEBSCENE_SEMANTIC_SNAPSHOT_TRUNCATED_DOCUMENTS_V1; return WEBSCENE_SEMANTIC_NONE_INDEX_V1; @@ -767,7 +767,7 @@ const auto target = semantic_attribute(*capture.node, "for"); if (!target.empty()) { label_texts[capture.document_index].try_emplace( - target, + std::string{target}, subtree_text(*capture.node)); } } diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc index f6325d82..87c2034e 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_style.inc @@ -912,7 +912,7 @@ node->style.mutable_table().border_collapsed = value == "collapse"; node->style.inline_property_mask |= inline_table_border_model; } else if (name == "aspect-ratio") { - if (parse_preferred_aspect_ratio( + if (css::parse_preferred_aspect_ratio( value, node->style.aspect_ratio_width, node->style.aspect_ratio_height)) { @@ -2503,7 +2503,7 @@ node->style.mutable_table().border_collapsed = value == "collapse"; node->style.inline_property_mask |= inline_table_border_model; } else if (name == "aspectRatio") { - if (parse_preferred_aspect_ratio( + if (css::parse_preferred_aspect_ratio( value, node->style.aspect_ratio_width, node->style.aspect_ratio_height)) { 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 6d0c6af7..805040fe 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_tasks.inc @@ -4244,7 +4244,7 @@ } if (changed_button == 1 && !mouse_up_default_prevented && !auxiliary_click_default_prevented) { - auto activation_flags = + uint32_t activation_flags = WEBSCENE_HOST_REQUEST_EXTERNAL_NEW_CONTEXT_V1; if ((input.flags & WEBSCENE_INPUT_POINTER_MODIFIER_SHIFT) == 0U) { activation_flags |=