mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
add Blob ancestor initializer to Factory
This commit is contained in:
@@ -31,6 +31,7 @@ const Element = @import("webapi/Element.zig");
|
||||
const Document = @import("webapi/Document.zig");
|
||||
const EventTarget = @import("webapi/EventTarget.zig");
|
||||
const XMLHttpRequestEventTarget = @import("webapi/net/XMLHttpRequestEventTarget.zig");
|
||||
const Blob = @import("webapi/Blob.zig");
|
||||
|
||||
const MemoryPoolAligned = std.heap.MemoryPoolAligned;
|
||||
|
||||
@@ -224,6 +225,20 @@ pub fn xhrEventTarget(self: *Factory, child: anytype) !*@TypeOf(child) {
|
||||
return child_ptr;
|
||||
}
|
||||
|
||||
pub fn blob(self: *Factory, child: anytype) !*@TypeOf(child) {
|
||||
const child_ptr = try self.createT(@TypeOf(child));
|
||||
child_ptr.* = child;
|
||||
|
||||
const b = try self.createT(Blob);
|
||||
child_ptr._proto = b;
|
||||
b.* = .{
|
||||
._type = unionInit(Blob.Type, child_ptr),
|
||||
.slice = "",
|
||||
.mime = "",
|
||||
};
|
||||
return child_ptr;
|
||||
}
|
||||
|
||||
pub fn create(self: *Factory, value: anytype) !*@TypeOf(value) {
|
||||
const ptr = try self.createT(@TypeOf(value));
|
||||
ptr.* = value;
|
||||
|
||||
Reference in New Issue
Block a user