LibJS+WebContent: Implement console.table

- Expose table from console object
- Add new Table log level
- Create a JS object that represents table rows and columns
- Print table as HTML using WebContentConsoleClient
This commit is contained in:
Gasim Gasimzada
2024-08-09 23:24:26 +02:00
committed by Sam Atkins
parent a2a9a11466
commit 785180dd45
7 changed files with 337 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ void ConsoleObject::initialize(Realm& realm)
define_native_function(realm, vm.names.error, error, 0, attr);
define_native_function(realm, vm.names.info, info, 0, attr);
define_native_function(realm, vm.names.log, log, 0, attr);
define_native_function(realm, vm.names.table, table, 0, attr);
define_native_function(realm, vm.names.trace, trace, 0, attr);
define_native_function(realm, vm.names.warn, warn, 0, attr);
define_native_function(realm, vm.names.dir, dir, 0, attr);
@@ -102,6 +103,13 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::log)
return console_object.console().log();
}
// 1.1.7. table(tabularData, properties), https://console.spec.whatwg.org/#table
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::table)
{
auto& console_object = *vm.current_realm()->intrinsics().console_object();
return console_object.console().table();
}
// 1.1.8. trace(...data), https://console.spec.whatwg.org/#trace
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::trace)
{