1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 19:05:07 +00:00

Spreadsheet: Override visit_edges() and visit stored JS objects

...and don't let them leak out of their evaluation contexts.
Also keep the exceptions separate from the actual values.
This greatly reduces the number of assertions hit while entering random
data into a sheet.
This commit is contained in:
AnotherTest 2020-12-22 14:18:33 +03:30 committed by Andreas Kling
parent b3a9a25416
commit 7c8d35600c
11 changed files with 110 additions and 43 deletions

View file

@ -87,6 +87,16 @@ void SheetGlobalObject::initialize()
define_native_function("column_index", column_index, 1);
}
void SheetGlobalObject::visit_edges(Visitor& visitor)
{
GlobalObject::visit_edges(visitor);
for (auto& it : m_sheet.cells()) {
if (it.value->exception())
visitor.visit(it.value->exception());
visitor.visit(it.value->evaluated_data());
}
}
JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name)
{
if (vm.argument_count() != 1) {
@ -231,6 +241,13 @@ void WorkbookObject::initialize(JS::GlobalObject& global_object)
define_native_function("sheet", sheet, 1);
}
void WorkbookObject::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
for (auto& sheet : m_workbook.sheets())
visitor.visit(&sheet.global_object());
}
JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
{
if (vm.argument_count() != 1) {