Skip to content

Commit 3942cb1

Browse files
Repair full-V8 GCC portability (#688) (#691)
1 parent 789f4d3 commit 3942cb1

8 files changed

Lines changed: 34 additions & 27 deletions

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@
361361
} else if (owner->tag == "style") {
362362
append_node_text(*owner, source);
363363
}
364-
info.GetReturnValue().Set(js_string(info.GetIsolate(), source));
364+
info.GetReturnValue().Set(js_string(info.GetIsolate(), source.c_str()));
365365
}
366366

367367
static void load_style_sheet_import(
@@ -390,9 +390,9 @@
390390
}
391391
auto result = v8::Object::New(info.GetIsolate());
392392
result->Set(local_context, js_string(info.GetIsolate(), "source"),
393-
js_string(info.GetIsolate(), source)).Check();
393+
js_string(info.GetIsolate(), source.c_str())).Check();
394394
result->Set(local_context, js_string(info.GetIsolate(), "url"),
395-
js_string(info.GetIsolate(), resolved)).Check();
395+
js_string(info.GetIsolate(), resolved.c_str())).Check();
396396
info.GetReturnValue().Set(result);
397397
}
398398

@@ -425,16 +425,16 @@
425425
}
426426
}
427427
result->Set(local_context, js_string(isolate, "href"),
428-
node.tag == "link" ? js_string(isolate, base_address).As<v8::Value>()
428+
node.tag == "link" ? js_string(isolate, base_address.c_str()).As<v8::Value>()
429429
: v8::Null(isolate).As<v8::Value>()).Check();
430430
result->Set(local_context, js_string(isolate, "title"),
431431
node.attributes.contains("title")
432-
? js_string(isolate, node.attributes.at("title")).As<v8::Value>()
432+
? js_string(isolate, node.attributes.at("title").c_str()).As<v8::Value>()
433433
: v8::Null(isolate).As<v8::Value>()).Check();
434434
result->DefineOwnProperty(
435435
local_context,
436436
js_string(isolate, "__webSceneBaseURL"),
437-
js_string(isolate, base_address),
437+
js_string(isolate, base_address.c_str()),
438438
static_cast<v8::PropertyAttribute>(
439439
v8::DontEnum | v8::DontDelete | v8::ReadOnly)).Check();
440440
result->DefineOwnProperty(
@@ -1114,7 +1114,7 @@
11141114
});
11151115
}
11161116

1117-
const std::string& effective_document_base(dom_node* root)
1117+
const std::string& effective_document_base(const dom_node* root)
11181118
{
11191119
if (root == nullptr) root = &document.body();
11201120
auto [found, inserted] = document_base_caches.try_emplace(root);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3683,7 +3683,9 @@
36833683
if(self==nullptr || form==nullptr || form->tag!="form") return;
36843684
dom_node* submitter=nullptr;
36853685
if(info.Length()>0 && !info[0]->IsNullOrUndefined()) {
3686-
submitter=unwrap_node(info[0]);
3686+
submitter=info[0]->IsObject()
3687+
? unwrap_node(info[0].As<v8::Object>())
3688+
: nullptr;
36873689
if(!is_form_submitter(submitter)) {
36883690
info.GetIsolate()->ThrowException(v8::Exception::TypeError(
36893691
js_string(info.GetIsolate(),

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
void report_document_script_error(const std::string& error)
2+
{
3+
if (diagnostics == nullptr
4+
|| !diagnostics->enabled(WEBSCENE_DIAGNOSTIC_LEGACY_CONSOLE)) {
5+
return;
6+
}
7+
std::lock_guard lock(console_message_mutex);
8+
constexpr size_t maximum_console_messages = 1024U;
9+
if (console_messages.size() >= maximum_console_messages) {
10+
console_messages.pop_front();
11+
}
12+
console_messages.push_back("error\n" + error);
13+
}
14+
115
#if defined(WEBSCENE_NATIVE_ENGINE_ENABLE_GRAPHICS)
216
void retire_document_graphics()
317
{
@@ -712,15 +726,6 @@
712726
// own image subtrees separately.
713727
enqueue_connected_image_resources_subtree(html_element, local_context);
714728

715-
const auto report_document_script_error = [&](const std::string& error) {
716-
if (diagnostics == nullptr || !diagnostics->enabled(WEBSCENE_DIAGNOSTIC_LEGACY_CONSOLE)) return;
717-
std::lock_guard lock(console_message_mutex);
718-
constexpr size_t maximum_console_messages = 1024U;
719-
if (console_messages.size() >= maximum_console_messages) {
720-
console_messages.pop_front();
721-
}
722-
console_messages.push_back("error\n" + error);
723-
};
724729
const auto execute_group = [&](bool defer) {
725730
for (const auto& script : scripts) {
726731
if (script.defer != defer) continue;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
return candidate;
6363
}
6464
if (hit == nullptr) return nullptr;
65-
auto* root = css_cascade_root_for_node(hit);
65+
auto* root = css_cascade_root_for_node(*hit);
6666
const auto root_id = root == nullptr ? document.body().id : root->id;
6767
if (const auto known = window_selections.find(root_id);
6868
known != window_selections.end() && validate_selection(known->second)
@@ -74,7 +74,7 @@
7474

7575
std::string outbound_selection_text(dom_node& source)
7676
{
77-
auto* root = css_cascade_root_for_node(&source);
77+
auto* root = css_cascade_root_for_node(source);
7878
const auto root_id = root == nullptr ? document.body().id : root->id;
7979
const auto known = window_selections.find(root_id);
8080
if (known == window_selections.end() || !validate_selection(known->second)
@@ -202,7 +202,7 @@
202202
const auto href = source.attributes.find("href");
203203
if (href != source.attributes.end()) {
204204
auto uri = resolve_resource_url(
205-
href->second, effective_document_base(css_cascade_root_for_node(&source)));
205+
href->second, effective_document_base(css_cascade_root_for_node(source)));
206206
if (!uri.empty() && !add_outbound_item(*request,
207207
WEBSCENE_OUTBOUND_DRAG_ITEM_URI_V1,
208208
"text/uri-list", std::move(uri))) {
@@ -214,7 +214,7 @@
214214
auto uri = source.replaced_image().resolved_source;
215215
if (uri.empty()) uri = resolve_resource_url(
216216
source.attributes["src"],
217-
effective_document_base(css_cascade_root_for_node(&source)));
217+
effective_document_base(css_cascade_root_for_node(source)));
218218
std::string name;
219219
if (const auto alt = source.attributes.find("alt");
220220
alt != source.attributes.end()) name = alt->second;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@
12801280
connected_resource_task& resource,
12811281
const service_worker_fetch_result* controlled)
12821282
{
1283-
if (resource.node == nullptr || !document.is_connected(*resource.node)
1283+
if (resource.node == nullptr || !is_connected(*resource.node)
12841284
|| resource.document_generation
12851285
!= document_generation.load(std::memory_order_acquire)) {
12861286
return;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@
599599
std::vector<std::unordered_map<std::string, const dom_node*>> all_id_nodes;
600600

601601
const auto append_document = [&](uint32_t frame_owner, uint64_t frame_generation,
602-
std::string_view origin) {
602+
std::string_view origin) -> uint32_t {
603603
if (result->documents.size() == maximum_semantic_documents_v1) {
604604
result->flags |= WEBSCENE_SEMANTIC_SNAPSHOT_TRUNCATED_DOCUMENTS_V1;
605605
return WEBSCENE_SEMANTIC_NONE_INDEX_V1;
@@ -767,7 +767,7 @@
767767
const auto target = semantic_attribute(*capture.node, "for");
768768
if (!target.empty()) {
769769
label_texts[capture.document_index].try_emplace(
770-
target,
770+
std::string{target},
771771
subtree_text(*capture.node));
772772
}
773773
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@
912912
node->style.mutable_table().border_collapsed = value == "collapse";
913913
node->style.inline_property_mask |= inline_table_border_model;
914914
} else if (name == "aspect-ratio") {
915-
if (parse_preferred_aspect_ratio(
915+
if (css::parse_preferred_aspect_ratio(
916916
value,
917917
node->style.aspect_ratio_width,
918918
node->style.aspect_ratio_height)) {
@@ -2503,7 +2503,7 @@
25032503
node->style.mutable_table().border_collapsed = value == "collapse";
25042504
node->style.inline_property_mask |= inline_table_border_model;
25052505
} else if (name == "aspectRatio") {
2506-
if (parse_preferred_aspect_ratio(
2506+
if (css::parse_preferred_aspect_ratio(
25072507
value,
25082508
node->style.aspect_ratio_width,
25092509
node->style.aspect_ratio_height)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4244,7 +4244,7 @@
42444244
}
42454245
if (changed_button == 1 && !mouse_up_default_prevented
42464246
&& !auxiliary_click_default_prevented) {
4247-
auto activation_flags =
4247+
uint32_t activation_flags =
42484248
WEBSCENE_HOST_REQUEST_EXTERNAL_NEW_CONTEXT_V1;
42494249
if ((input.flags & WEBSCENE_INPUT_POINTER_MODIFIER_SHIFT) == 0U) {
42504250
activation_flags |=

0 commit comments

Comments
 (0)