The variable names and comments around the code refer to the main thread
as the "tokenizer" and the parser thread as the "html tokenizer". This
confuses me every time I look at the code, because both tokenize html
and neither can do it without the other.
I've renamed things to be a bit more clear, mostly referring to things
as the "main thread" and the "parser thread".
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
In preparation of introducing traits for some of these methods,
let's separate them from the basecommand trait. They are not
related to each other and it was making reasoning about where
lives what more difficult.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Following the convention of other major UAs of gating the virtual
keyboard by certain user activation, adding a flags to let the embedder
knows about the user activation. This would be used to determine whether
the virtual keyboard needs to be shown or not in android and ohos.
Testing: Manual testing.
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Unless the feature `preserve_order` is enabled, serde_json will sort the
map's entries in an alphanumerical order.
The specification instead expect the entries to be visited by the order
they are listed, a latter entry should replace a previous one when they
are resolved to the same url.
I've also removed a couple of `CanGc` introduced in #37405, unless I've
missed something there is not code that can trigger a GC.
Testing: A subtest now pass
Part of #37553
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
That respects the user locale better than hardcoding en-US. This can
also be manually set with the `LANG` environment variable.
Testing: Manual testing with the devtools to check the header sent and
the value of `navigator.language`
Signed-off-by: webbeef <me@webbeef.org>
We previously clonsed the CSP list unnecessarily which consisted of
roughly 2.7%. 1.2% spend in Document::get_csp_list.
We can easily avoid it with Ref and cloning it deliberately when needed.
Testing: This is functionally identical to the previous code as it is a
change from clone to a Ref<>.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
The pause debugger screen should be shown for both pausing manually
(interrupt) and hitting a breakpoint.
Reuse the logic for pausing breakpoints to pause the debugger when the
user manually clicks the pause button.
Rename the pause event to interrupt to match the language of the
DevTools client and to avoid confusion with paused frames, which can
happen on interrupt or on a breakpoint.
https://github.com/user-attachments/assets/ceb0007d-0e57-44d6-a159-55980ff8b517
Testing: New DevTools test and manual testing.
Part of: #36027
cc @atbrakhi
---------
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
In `NormalizedAlgorithm::from_object_value`, we use
`dictionary_from_jsval` to convert `HandleValue` into IDL dictionary
types generated by `script_bingings`, and immediately use `From`,
`TryFrom`, `TryFromWithCx` trait implementation to convert them into
webcrypto's subtle dictionary types.
Since our webcrypto implementation doesn't directly use the dictionary
types generated by `script_bingings`, this patch combines the 2 steps of
this conversion into one step, by using `TryFromWithCx` trait
implementation for those dictionaries and moving the
`dictionary_from_jsval` calls into `try_from_with_cx`.
Testing: Refactoring. Existing tests suffice.
Fixes: Preparation for #42579
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This implements a baseline for these tests. By implementing these dummy
methods, we avoid a lot of test expectation clutter when debugging these
tests to figure out why they aren't passing yet.
For the delete command, since it doesn't have any state or is
indeterminate, we always return the same.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Queue the "complete" event before unblocking later transactions in the
backend. This preserves event ordering for overlapping transactions
created on the same connection.
Fixes#42730Fixes#42718
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
- Use `FxHashMap` for `active_pointer_ids`
- Refactor and fix logging message for touch, especially
`update_active_touch_points_when_early_return`
- Randomly fix some typos
Testing: This changes logging message but no other observable
behaviours. The logging should be more accurate, but I didn't test.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
There is no specification for this, but there are relevant
WPT tests in `selection/contenteditable`. This PR implements
the required changes to make sure that when such an element
is focused (programmatically), it selects the correct node.
The implementation is therefore entirely reverse-engineered
based on existing browser behavior and commented to hopefully
make it make sense.
Part of #7492
Part of #12776
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Prerequisite for #40365.
Moving `run_a_module_script()` to `GlobalScope` will allow us to execute
module scripts on `WorkerGlobalScope`.
---
Relates to #23308
Signed-off-by: pylbrecht <pylbrecht@mailbox.org>
This method was already present on the document, but
wasn't implemented yet. Note that now more tests are
failing, since before they weren't running. The tests
check if a command is enabled before they started
running.
The selection API doesn't yet take into account
contenteditable containers, which is why these
tests don't consider a command enabled, since the
range of the selection is empty.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Use the new `reflect_dom_object_with_cx` introduced in #42725 in
`CryptoKey::new`.
Testing: Refactoring. Existing tests suffice.
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Follow-up PR to #42720 (addressing nits by @sagudev)
Testing: It compiles without any errors
Fixes: Part of issue #42638 and PR #42720
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
What I thought would be a small algorithm turns out required tons of
other implementations of various definitions, most of it around nodes.
Therefore, to keep things manageable, it only implements this algorithm
and relevant parts, but leaves the other parts of the delete command
untouched. For now, it is good if tests keep on working without
crashing. Later, once the full delete command is implemented, more tests
should be passing.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
These three methods date back from the very early history of Servo and
are no longer necessary:
1. `Window.debug`: `console.log` is a better replacement for this method
now. A manual test that tests the very basics of JavaScript used
this. This test is removed as well.
2. `Window.gc`: This can be replaced with `TestUtils.gc`, which is part
of a W3C specification.
3. `Window.js_backtrace`: This method is moved to `ServoTestUtils`.
Testing: Tests are updated to reflect these changes.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Just to complement existing with_proto method introduced in #42699.
Justification for arg ordering: reflect_dom_* have arguments reversed,
so first one is Box (the most important) then global, proto and lastly
cx.
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
`process_response_eof` is the only method that needs cx at least right
now. This PR removes one temp_cx and introduces one, removing that one
will is hard (needs VirtualMethods and a lot of work)
Testing: Just refactor
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This introduces a new `ServoTestUtils` namespace with a `forceLayout()`
function. This `forceLayout()` function returns an object which
currently has an array of the phases ran by layout. Also moves
`panic()`, `crashHard()` and `advanceClock()` from `TestBinding` to this
new namespace. `TestBinding` is meant to test the bindings generation,
but these are more generic helpers for Servo-only tests.
Testing: This change adds a series of Servo-only tests that verify the
behavior of the new `forceLayout()` function. Tests that rely on the
moved interfaces are updated and should continue to pass.
Signed-off-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This patch changes the methods of `SubtleCrypto` to use the new `&mut
JSContext` and `&mut CurrentRealm`, Those methods are `Encrypt`,
`Decrypt`, `Sign`, `Verify`, `GenerateKey`, `DeriveKey`, `DeriveBits`,
`Digest`, `ImportKey`, `ExportKey`, `WrapKey`, `UnwrapKey`,
`EncapsulateKey`, `EncapsulateBits`, `DecapsulateKey`,
`DecapsulateBits`.
The change also propagate to the all internal methods within the
`subtlecrypto` module.
Testing: Refactoring. Existing tests suffice.
Fixes: Part of #42638
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Move from `InRealm` to `&mut CurrentRealm` and from `CanGc` to `&mut
js::context::JSContext`
Testing: `/mach build`, `/mach test-unit` and `/mach test-tidy`
Fixes: Part of #42638
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
this patch adds a Servo::set_accessibility_active() method that
embedders can use to tell Servo to start building and sending
accessibility trees to the platform, as long as the pref is enabled
(#42333). doing so sets a global flag in the constellation, which is
then propagated to the layout of all existing and future pipelines.
Testing: none yet, no functional change
Fixes: part of #4344
---------
Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Alice Boxhall <alice@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
Replace the old dirty root box tree layout approach with one that works
based on independent formatting contexts. Instead of just allowing a
single dirty root to be the source of box tree reconstruction, allow box
tree reconstruction to happen anywhere in the tree that can isolate box
tree damage from ancestors. This essentially combines damage propagation
and box tree construction into a single step.
There is currently one downside to this approach compared to the dirty
root approach which is that we currently cannot detect and start box
tree layout when the dirty has a compatible `display` and `position`
value. This can mean the scope of box tree layout extends further up the
tree. We will address this in a followup -- but have not noticed any
major performance implications (currently fragment tree layout is much
more expensive than box tree layout).
Benefits:
1. Damage propagation now only happens under the dirty root.
2. Future changes can limit the scope of damage up the tree and perhaps
preserve the inline content size cache between box tree rebuilds.
Testing: This should not change behavior in a testable way (we currently
do
not have robust performance tests), so WPT test results should not
change.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Indexeddb: transaction lifecycle
Testing: more Indexeddb test should pass
part of #40983
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
#42681 did not actually allowed using cx in Constructor, but it did most
heavy lifting. Now we need to pass cx to Constructor call (and skip
CanGc) if cx is requested in Bindings.conf. This PR also test this on
testbindings.
Also we now always use `let cx = &mut cx`, so we can always use just cx
(compiler will automatically deref it into &cx if needed). This is
important because codegen stuff is called from many places to it make
sense/easier to just unify this.
Testing: It compiles
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
If the number of layout threads is set to 1, then there sometimes is no
style thread pool. Instead of panicking in this case, we should just run
the code in question on the main thread with no thread pool. This fixes
a crash when `-y 1` is passed to servoshell.
Testing: This fixes a crash, but we currently do not run any automated
tests
with a single layout thread.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Moves the drop implementation for `GPUComputePipeline` to a separate
`DroppableGPUComputePipeline` struct.
Removes `allowDropImpl` from the bindings configuration.
Testing: No tests added because of webgpu tests existent coverage
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
- `resolved_module_set_mut()` was replaced by
`add_module_to_resolved_module_set`
- `send_to_constellation()`, all code use
`script_to_constellation_chan()` and optionally handle errors
- `from_object_maybe_wrapped` one usage was removed in #36966, not clear
if that was the only one or more were removed later on
Testing: A successful build is enough
Part of #40882
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
After debugging some of the failing tests, it appears spec text is
wrong.
Inside [merge existing and new import
maps](https://html.spec.whatwg.org/multipage/#merge-existing-and-new-import-maps)
algorithm, when checking which imports needs to be ignored,
specification will check if each _specifier_ of _newImportMap's imports_
will override any specifier of [resolved module
set](https://html.spec.whatwg.org/multipage/#resolved-module-set), by
checking if specifier starts with `record.specifier`.
Since each specifier gets normalized before they are inserted in the
resolved module set, the are cases where the check fails and we end up
overriding a module resolution.
This was an oversight, since for _newImportMap's scopes_ specification
performs the right check:
`specifierKey is a code unit prefix of record's specifier;`
Testing: More tests are now passing
Part of #37553
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Pass down `&mut JSContext` in `post_connection_steps`
Testing: No functionality change, a successful build is enough
Part of #40600
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
The first step of `execCommand` commands is to figure out
if they are supported and enabled. Therefore, implement
these two pieces with only 1 command: delete.
The implementation of `delete` is currently mostly dummy,
to have at least something going. But the main part of
this change is to setup the infrastructure to figure out
when commands are supported and enabled.
For the first part, its simply the list of commands we
currently have implemented, which is only delete.
For the second part, we need to consider the active range
of the current selection and do various checks, as well as
check the presence of `contenteditable`.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
The inspector view allows modifying the attributes of DOM elements.
However, we lie to the devtools client: While it looks like the
attributes change, the changes are never actually applied to the DOM.
This change fixes that, and also makes it so attribute modifications
from non-inspector sources are shown in the inspector.
Testing: This change adds two tests
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>