-
Notifications
You must be signed in to change notification settings - Fork 321
Support PerformanceObserver API
#1282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: zigdom
Are you sure you want to change the base?
Conversation
Heavily based on MutationObserver and IntersectionObserver.
This still needs investigation. Spec doesn't refer usage of microtask queue for this, yet the current behavior doesn't match to Firefox and Chrome.
459cef0 to
e1ba5df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like this file is used anywhere in this PR?
| const ShadowRoot = @import("webapi/ShadowRoot.zig"); | ||
| const Performance = @import("webapi/Performance.zig"); | ||
| const Screen = @import("webapi/Screen.zig"); | ||
| const HtmlScript = @import("webapi/Element.zig").Html.Script; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used? (Can always use Element.Html.Script)
| struct { | ||
| fn run(_page: *anyopaque) anyerror!?u32 { | ||
| const page: *Page = @ptrCast(@alignCast(_page)); | ||
| page._performance_delivery_scheduled = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be set to false?
| /// This doesn't emit callbacks but rather fills the queues of observers. | ||
| pub fn notifyPerformanceObservers(self: *Page, entry: *Performance.Entry) !void { | ||
| for (self._performance_observers.items) |observer| { | ||
| if (observer.interested(entry)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might encapsulate this in the observer, so just:
observer.newEntry(entry)and let it decide how/if to handle it.
| page._performance_delivery_scheduled = true; | ||
| // Dispatch performance observer events. | ||
| for (page._performance_observers.items) |observer| { | ||
| if (observer.hasRecords()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, maybe just call observer.dispatch() and let it deal with what (if anything) to do.
| pub const prototype_chain = bridge.prototypeChain(); | ||
| pub var class_id: bridge.ClassId = undefined; | ||
|
|
||
| pub const getEntries = bridge.function(EntryList.getEntries, .{}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be defined in JsApi, not Meta. This tells me there might be some tests missing.
This PR implements
PerformanceObserverformarkandmeasureperformance types. I'll add tests also but would like to receive reviews before that.