Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -425,16 +425,16 @@
}
}
result->Set(local_context, js_string(isolate, "href"),
node.tag == "link" ? js_string(isolate, base_address).As<v8::Value>()
node.tag == "link" ? js_string(isolate, base_address.c_str()).As<v8::Value>()
: v8::Null(isolate).As<v8::Value>()).Check();
result->Set(local_context, js_string(isolate, "title"),
node.attributes.contains("title")
? js_string(isolate, node.attributes.at("title")).As<v8::Value>()
? js_string(isolate, node.attributes.at("title").c_str()).As<v8::Value>()
: v8::Null(isolate).As<v8::Value>()).Check();
result->DefineOwnProperty(
local_context,
js_string(isolate, "__webSceneBaseURL"),
js_string(isolate, base_address),
js_string(isolate, base_address.c_str()),
static_cast<v8::PropertyAttribute>(
v8::DontEnum | v8::DontDelete | v8::ReadOnly)).Check();
result->DefineOwnProperty(
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Object>())
: nullptr;
if(!is_form_submitter(submitter)) {
info.GetIsolate()->ThrowException(v8::Exception::TypeError(
js_string(info.GetIsolate(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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))) {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@
std::vector<std::unordered_map<std::string, const dom_node*>> 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;
Expand Down Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |=
Expand Down
Loading