mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-09-24 05:25:20 -04:00
properly add lengthComputable flag to XHR sync path
This commit is contained in:
3 files changed
+9
-3
No files matched your search
@@ -62,6 +62,7 @@ fn initWithTrusted(arena: *lp.Arena, typ: String, _opts: ?Options, trusted: bool
|
||||
._proto = undefined,
|
||||
._total = opts.total,
|
||||
._loaded = opts.loaded,
|
||||
._length_computable = opts.lengthComputable,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -348,8 +348,8 @@ pub fn send(self: *XMLHttpRequest, body_: ?BodyInit, exec_: *const Execution) !v
|
||||
|
||||
try self.stateChanged(.done, exec);
|
||||
const loaded = self._response_data.items.len;
|
||||
try self._proto.dispatch(.load, .{ .total = loaded, .loaded = loaded }, exec);
|
||||
try self._proto.dispatch(.load_end, .{ .total = loaded, .loaded = loaded }, exec);
|
||||
try self._proto.dispatch(.load, .{ .total = loaded, .loaded = loaded, .length_computable = true }, exec);
|
||||
try self._proto.dispatch(.load_end, .{ .total = loaded, .loaded = loaded, .length_computable = true }, exec);
|
||||
|
||||
log.info(.http, "request complete", .{
|
||||
.source = "xhr",
|
||||
|
||||
@@ -74,7 +74,11 @@ pub fn dispatch(self: *XMLHttpRequestEventTarget, comptime event_type: DispatchT
|
||||
const progress = progress_ orelse Progress{};
|
||||
const event = (try ProgressEvent.initTrusted(
|
||||
comptime .wrap(typ),
|
||||
.{ .total = progress.total, .loaded = progress.loaded },
|
||||
.{
|
||||
.total = progress.total,
|
||||
.loaded = progress.loaded,
|
||||
.lengthComputable = progress.length_computable,
|
||||
},
|
||||
exec.page,
|
||||
)).asEvent();
|
||||
|
||||
@@ -173,6 +177,7 @@ const DispatchType = enum {
|
||||
const Progress = struct {
|
||||
loaded: usize = 0,
|
||||
total: usize = 0,
|
||||
length_computable: bool = false,
|
||||
};
|
||||
|
||||
pub const JsApi = struct {
|
||||
|
||||
Reference in new issue
Block a user