Commit Graph

1655 Commits

Author SHA1 Message Date
Karl Seguin
072110481f Unify the Zig and JS events using an intrusive node.
The approach borrows heavily from Zig's new LinkedList API.

The main benefit is that it unifies how event callbacks are done. When the
Page.windowClick event was added, the Event structure was changed to a union,
supporting a distinct Zig and JS event.

This new approach more or less treats everything like a Zig event. A JS event
is just a Zig struct that has a Env.Callback which it can invoke in its handle
method.

The intrusive nature of the EventNode means that what used to be 1 or 2
allocations is now 0 or 1.

It also has the benefit of making netsurf completely unaware of Env.Callbacks.
2025-04-26 22:22:34 +08:00
Pierre Tachoire
0fb0532875 Merge pull request #562 from lightpanda-io/mutation_observer
Some checks failed
e2e-test / zig build release (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / browser fetch (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
Improve MutationObserver
2025-04-25 10:53:48 +02:00
Pierre Tachoire
d8dd94c679 Merge pull request #569 from lightpanda-io/make_cdp_less_generic
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / 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
Make CDP less generic.
2025-04-25 09:50:17 +02:00
Karl Seguin
f3d7736acf Update src/browser/dom/mutation_observer.zig
Co-authored-by: Pierre Tachoire <pierre@lightpanda.io>
2025-04-25 15:48:46 +08:00
Pierre Tachoire
8fbf5590f8 Merge pull request #573 from lightpanda-io/typed_arrays
add support for mapping integer typed arrays into zig slices
2025-04-25 09:30:44 +02:00
Pierre Tachoire
b8ac93045e Merge pull request #574 from lightpanda-io/enable_icu
initialize ICU
2025-04-25 09:29:34 +02:00
Karl Seguin
89fea9b4df initialize ICU
This makes functions like new Intl.DateTimeFormat() not crash.
2025-04-25 13:15:38 +08:00
Karl Seguin
a3323dc8a7 add support for mapping integer typed arrays into zig slices 2025-04-25 13:01:43 +08:00
Karl Seguin
ba0505c13c Merge pull request #571 from lightpanda-io/remove-log.zig
Remove log.zig
2025-04-25 08:47:30 +08:00
Karl Seguin
dd8432e8fd Merge pull request #572 from lightpanda-io/framenavigated-order
cdp: dispatch Page.frameNavigated before DOM.documentUpdated
2025-04-25 08:47:07 +08:00
Pierre Tachoire
11c7f57745 cdp: dispatch Page.frameNavigated before DOM.documentUpdated
chromedp client expects to receive Page.frameNavigated before
DOM.documentUpdated.
2025-04-24 18:28:43 +02:00
sjorsdonkers
89a3fac316 log.zig does not appear to be used 2025-04-24 15:17:16 +02:00
Karl Seguin
b0b3e92600 remove Browser.EnvType 2025-04-24 19:48:27 +08:00
Karl Seguin
1fca035cfe Make CDP less generic.
It's still generic over the client - we need to assert messages written to and
be able to send specific commands, but it's no longer generic over Browser/
Session/Page/etc..
2025-04-24 18:06:55 +08:00
Karl Seguin
4c89bb0e0a Improve MutationObserver
- Fix get_removedNodes (it was returning addedNodes)
- get_removedNodes and get addedNodes now return references
- used enum for dispatching and clean up dispatching in general
- Remove MutationRecords and simply return an array
  - this allows the returned records to be iterable (as they should be)
  - jsruntime ZigToJs will now map a Zig array to a JS array
-Rely on default initialize of NodeList
-Batch observed records
 - Callback only executed when call_depth == 0
 - Fixes crashes when a MutationObserver callback mutated the nodes being
   observes.
 - Fixes some WPT issues, but Netsurf's mutationEventRelatedNode does not
   appear to be to spec, so most tests fail.
 - Allow zig methods to execute arbitrary code when call_depth == 0
   - This is a preview of how I hope to make XHR not crash if the CDP session
     ends while there's still network activity
2025-04-24 17:40:37 +08:00
Pierre Tachoire
332508f563 Merge pull request #567 from lightpanda-io/kind_before_deinit
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / 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
access the executor kind before it becomes invalid
2025-04-24 10:43:37 +02:00
Karl Seguin
158d11e93c access the executor kind before it becomes invalid 2025-04-24 16:36:04 +08:00
Pierre Tachoire
18a49601a0 Merge pull request #566 from lightpanda-io/null_prefix_namespace
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / 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
pass null namespace/prefix to libdom
2025-04-24 09:27:03 +02:00
Karl Seguin
b971b4754f update libdom to latest version, fixing null ptr usage and stack overflow 2025-04-24 15:18:22 +08:00
Pierre Tachoire
cfef22257e Merge pull request #560 from lightpanda-io/remove_arena_frees
Remove unnecessary cleanup when we know we have an arena
2025-04-24 09:04:46 +02:00
Karl Seguin
3153d8ee8c pass null namespace/prefix to libdom 2025-04-24 11:52:01 +08:00
sjorsdonkers
b2a975fe4a remove executionContextCreated
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / 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
2025-04-23 17:00:22 +02:00
sjorsdonkers
b2ba505954 Check if it works with v8 97bcfb6 2025-04-23 17:00:22 +02:00
sjorsdonkers
a1b673175a errdefer in the right scope 2025-04-23 17:00:22 +02:00
sjorsdonkers
d666de07a7 test scaffolding 2025-04-23 17:00:22 +02:00
sjorsdonkers
64508cec61 Executor World kind 2025-04-23 17:00:22 +02:00
sjorsdonkers
e0bcb625c2 browsercontext arena 2025-04-23 17:00:22 +02:00
sjorsdonkers
9534e765e5 refix page.contextCreated 2025-04-23 17:00:22 +02:00
sjorsdonkers
39124d2878 text fix 2025-04-23 17:00:22 +02:00
sjorsdonkers
9ae4d66194 page cleanup 2025-04-23 17:00:22 +02:00
sjorsdonkers
09850d7500 Fix executor used in resolveNode 2025-04-23 17:00:22 +02:00
sjorsdonkers
8897d9179c isolated world 2025-04-23 17:00:22 +02:00
Karl Seguin
2d1b9d64bd Remove unnecessary cleanup when we know we have an arena
Change a few old alloc+memcpy to dupe

Some other smaller cleanups.
2025-04-23 17:52:13 +08:00
Pierre Tachoire
e603a1707c Merge pull request #559 from lightpanda-io/processing_instruction_clone
Manually "clone" processing_instruction
2025-04-23 09:51:33 +02:00
Pierre Tachoire
6b1e7a1c5d Merge pull request #558 from lightpanda-io/node_is_equal
Implement custom isEqualNode
2025-04-23 09:50:43 +02:00
Pierre Tachoire
5acd4b5fd4 Revert "browser: temporary ignore mime sniff"
This reverts commit 0b2c4679fd.
2025-04-23 09:26:10 +02:00
Pierre Tachoire
9e88adb0da Merge pull request #557 from lightpanda-io/fix_peek
peek must check existing data first
2025-04-23 09:25:59 +02:00
Karl Seguin
69eaf0d338 Manually "clone" processing_instruction
When you clone a processing_node via the node_clone_node, or directly via the
processing_node copy, you end up in _dom_pi_copy:
da8b967905/src/core/pi.c (L104)

For whatever, reason, the node created here gets a vtable that doesn't seem
compatible with how we cast vtables in netsurf.zig. For now, a simple fix is
to create a new new and copy the attributes over.

Fixes https://github.com/lightpanda-io/browser/issues/123 and a WPT crash.
2025-04-23 13:31:05 +08:00
Karl Seguin
680de2dca1 Implement custom isEqualNode
Netsurf's dom_node_is_equal appears to be both unsafe and incorrect. It's unsafe
because various node types don't have the dom_node_get_attributes implementation
so they default to setting the node attributes to null:
https://github.com/lightpanda-io/libdom/blob/master/src/core/node.c#L658

However, it doesn't do a NULL check when comparing them, so it crashes:
da8b967905/src/core/namednodemap.c (L312)

Furthermore, specific nodes need to be compared using specific attributes/values.

This PR fixes a WPT crash.
2025-04-23 09:59:57 +08:00
Karl Seguin
837188f8d1 peek must check existing data first 2025-04-23 08:28:20 +08:00
Pierre Tachoire
4a696b4053 Merge pull request #556 from lightpanda-io/mime-sniff-skip
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / 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
browser: temporary ignore mime sniff
2025-04-22 18:55:57 +02:00
Pierre Tachoire
0b2c4679fd browser: temporary ignore mime sniff 2025-04-22 18:47:52 +02:00
Pierre Tachoire
5a08c92d02 Merge pull request #553 from lightpanda-io/mime_sniffing
Try to sniff the mime type based on the body content
2025-04-22 17:25:29 +02:00
Pierre Tachoire
faf93441f6 Merge pull request #555 from lightpanda-io/wpt_filter_non_tests
Don't [try] to run non-tests
2025-04-22 17:00:19 +02:00
Karl Seguin
8aa3608a3c Don't [try] to run non-tests
Currently, we treat every .html file in tests/wpt as-if it's a test. That
isn't always the case. wpt has a manifest tool to generate a manifest (in
JSON) of the tests, we should probably use that (but it's quite large).

This PR filters out two groups. First, everything in resources/ appears to
be things to _run_ the tests, not actual tests.

Second, any file without a "testharness.js" doesn't appear to be a test
either. Note that WPT's own manifest generator looks at this:
43a0615361/tools/manifest/sourcefile.py (L676)
(which is used later in the file to determine the type of file).
2025-04-22 21:05:12 +08:00
Pierre Tachoire
9727a9d000 Merge pull request #547 from lightpanda-io/jsruntime_arenas
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / web platform tests json output (push) Has been cancelled
wpt / 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
Re-introduce call_arena
2025-04-22 13:58:16 +02:00
Pierre Tachoire
1b74289c43 Merge pull request #543 from lightpanda-io/describeNode2
descibeNode for new js runtime
2025-04-22 13:57:18 +02:00
sjorsdonkers
a698ff8309 describeNode feedback 2025-04-22 13:49:01 +02:00
sjorsdonkers
5026c48805 Update zig-v8 to v0.1.18 2025-04-22 13:49:00 +02:00
sjorsdonkers
2ac63b6985 describeNode 2025-04-22 13:49:00 +02:00