Merge pull request #1040 from lightpanda-io/event_timestamp_resolution
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled

Increase event timeStamp resolution
This commit is contained in:
Karl Seguin
2025-09-11 21:08:09 +08:00
committed by GitHub
4 changed files with 7 additions and 7 deletions

View File

@@ -113,7 +113,7 @@ pub const Event = struct {
// Even though this is supposed to to provide microsecond resolution, browser
// return coarser values to protect against fingerprinting. libdom returns
// seconds, which is good enough.
pub fn get_timeStamp(self: *parser.Event) !u32 {
pub fn get_timeStamp(self: *parser.Event) !u64 {
return parser.eventTimestamp(self);
}

View File

@@ -505,11 +505,11 @@ pub fn eventIsTrusted(evt: *Event) !bool {
return res;
}
pub fn eventTimestamp(evt: *Event) !u32 {
var ts: c_uint = undefined;
pub fn eventTimestamp(evt: *Event) !u64 {
var ts: u64 = 0;
const err = c._dom_event_get_timestamp(evt, &ts);
try DOMErr(err);
return @as(u32, @intCast(ts));
return ts;
}
pub fn eventStopPropagation(evt: *Event) !void {

View File

@@ -5,7 +5,7 @@
</div>
<script id=dispatch>
const startTime = new Date().getTime();
const startTime = new Event('x').timeStamp;
let content = $('#content');
// let para = document.getElementById('para');
@@ -27,7 +27,7 @@
testing.expectEqual(true, evt.cancelable);
testing.expectEqual(true, evt.defaultPrevented);
testing.expectEqual(true, evt.isTrusted);
testing.expectEqual(true, evt.timeStamp >= Math.floor(startTime/1000));
testing.expectEqual(true, evt.timeStamp >= Math.floor(startTime));
</script>
<script id=propogate>