mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
xhr: implement prototype chain correctly
This commit is contained in:
@@ -32,6 +32,10 @@ pub const XMLHttpRequestEventTarget = struct {
|
|||||||
ontimeout_cbk: ?Callback = null,
|
ontimeout_cbk: ?Callback = null,
|
||||||
onloadend_cbk: ?Callback = null,
|
onloadend_cbk: ?Callback = null,
|
||||||
|
|
||||||
|
pub fn constructor() !XMLHttpRequestEventTarget {
|
||||||
|
return .{};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_onloadstart(self: *XMLHttpRequestEventTarget, handler: Callback) void {
|
pub fn set_onloadstart(self: *XMLHttpRequestEventTarget, handler: Callback) void {
|
||||||
self.onloadstart_cbk = handler;
|
self.onloadstart_cbk = handler;
|
||||||
}
|
}
|
||||||
@@ -55,6 +59,8 @@ pub const XMLHttpRequestEventTarget = struct {
|
|||||||
pub const XMLHttpRequestUpload = struct {
|
pub const XMLHttpRequestUpload = struct {
|
||||||
pub const prototype = *XMLHttpRequestEventTarget;
|
pub const prototype = *XMLHttpRequestEventTarget;
|
||||||
pub const mem_guarantied = true;
|
pub const mem_guarantied = true;
|
||||||
|
|
||||||
|
proto: XMLHttpRequestEventTarget,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const XMLHttpRequest = struct {
|
pub const XMLHttpRequest = struct {
|
||||||
@@ -67,6 +73,7 @@ pub const XMLHttpRequest = struct {
|
|||||||
pub const LOADING: u16 = 3;
|
pub const LOADING: u16 = 3;
|
||||||
pub const DONE: u16 = 4;
|
pub const DONE: u16 = 4;
|
||||||
|
|
||||||
|
proto: XMLHttpRequestEventTarget,
|
||||||
cli: Client,
|
cli: Client,
|
||||||
impl: YieldImpl,
|
impl: YieldImpl,
|
||||||
|
|
||||||
@@ -79,6 +86,7 @@ pub const XMLHttpRequest = struct {
|
|||||||
pub fn constructor(alloc: std.mem.Allocator, loop: *Loop) !*XMLHttpRequest {
|
pub fn constructor(alloc: std.mem.Allocator, loop: *Loop) !*XMLHttpRequest {
|
||||||
var req = try alloc.create(XMLHttpRequest);
|
var req = try alloc.create(XMLHttpRequest);
|
||||||
req.* = XMLHttpRequest{
|
req.* = XMLHttpRequest{
|
||||||
|
.proto = try XMLHttpRequestEventTarget.constructor(),
|
||||||
.headers = .{ .allocator = alloc, .owned = false },
|
.headers = .{ .allocator = alloc, .owned = false },
|
||||||
.impl = undefined,
|
.impl = undefined,
|
||||||
.uri = undefined,
|
.uri = undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user