mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
move createTypedArray to Local
This commit is contained in:
@@ -1045,13 +1045,6 @@ pub const FinalizerCallback = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// Creates a new typed array. Memory is owned by JS context.
|
||||
/// If storing the type in a Zig type is desired, prefer `.global` state to persist.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Typed_arrays
|
||||
pub fn createTypedArray(self: *const Context, comptime array_type: js.ArrayType, size: usize) js.ArrayBufferRef(array_type) {
|
||||
return .init(self.local.?, size);
|
||||
}
|
||||
|
||||
// == Profiler ==
|
||||
pub fn startCpuProfiler(self: *Context) void {
|
||||
if (comptime !IS_DEBUG) {
|
||||
|
||||
@@ -75,6 +75,12 @@ pub fn newArray(self: *const Local, len: u32) js.Array {
|
||||
};
|
||||
}
|
||||
|
||||
/// Creates a new typed array. Memory is owned by JS context.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Typed_arrays
|
||||
pub fn createTypedArray(self: *const Local, comptime array_type: js.ArrayType, size: usize) js.ArrayBufferRef(array_type) {
|
||||
return .init(self, size);
|
||||
}
|
||||
|
||||
pub fn runMicrotasks(self: *const Local) void {
|
||||
self.isolate.performMicrotasksCheckpoint();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ pub fn constructor(
|
||||
return page._factory.create(ImageData{
|
||||
._width = width,
|
||||
._height = height,
|
||||
._data = try page.js.createTypedArray(.uint8_clamped, size).persist(),
|
||||
._data = try page.js.local.?.createTypedArray(.uint8_clamped, size).persist(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user