This is no longer present in the spec. Instead, the
`process_request_body` is the new way. These two
methods were called right after each other and there was only 1
implementation in `htmlvideoelement`. That implementation is now moved
to `process_request_body` and hence we can remove the unnecessary
method.
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This moves some easy elements in Script from IpcChannel and related
methods to GenericChannel and related methods and some callbacks.
Testing: This will be covered by WPT if the channels behave differently.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
in #42336, we added a
[Servo](https://doc.servo.org/servo/struct.Servo.html)-global API for
controlling whether accessibility is active. the idea was that when the
embedder activates accessibility, all webviews and documents activate
accessibility and start sending AccessKit tree updates, and vice versa
when they deactivate.
we found a problem with this approach in #42338. global activation of
accessibility makes it too easy to accidentally cause a panic in
AccessKit, and harder than it needs to be for embedders to learn that
they are responsible for grafting each webview’s subtree into their main
AccessKit tree as soon as accessibility is activated. this is due to an
invariant of the AccessKit subtree API: if a subtree starts sending
updates before the graft node is created, the program panics.
this patch reworks accessibility activation to make it per-webview. by
requiring embedders to explicitly activate accessibility for a webview,
we can communicate the AccessKit invariant via our API docs.
Testing: this patch includes an initial accessibility test in libservo
Fixes: part of #4344, extracted from our work in #42338
---------
Signed-off-by: Alice Boxhall <alice@igalia.com>
Signed-off-by: delan azabani <dazabani@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
Add the cx parameter to `fn process_response` in the
`FetchResponseListener` trait and the traits that that interface change
requires. Chose to add it as the first parameter, following the same
order that `FetchResponseListener::process_response_eof` uses.
Testing: Checked that servo builds locally as well as `./mach fmt` and
`./mach test-tidy`. I don't think more tests are needed as we are not
introducing new functionality
Fixes: #42840
---------
Signed-off-by: Javier Olaechea <pirata@gmail.com>
The console actor sends `Eval` via debugger.js, not `EvaluateJS`.
Workers only handled `EvaluateJS` which was never sent. We would want to
use `Eval` for workers as well. The worker evaluation was already
non-functional.
One more motivation behind not keeping this legacy path is because it
requires passing `None` for all new fields added to
`EvaluateJSReplyValue`, that is extra burden.
Testing: All existing tests are passing.
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
This is a hot path:
- there is a lot of processing in `handle_pending_input_events`: JS
realm entry, temporary variable creation, value assignment etc.
- we acquire a RAII guard before calling the function.
If the event queue is empty, this would result in unnecessary overhead
on the hot path.
We skip all above work in this case.
Testing: This is an optimization that should not change visible
behaviour,
thus covered by all the testdriver tests.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
ScriptWindowProxies's find_window_proxy and get methods are exactly the
same; remove the latter.
Testing: Existing WPT tests should cover the script_thread.rs change
Fixes: https://github.com/servo/servo/issues/43251
Signed-off-by: Simon Martin <simon@nasilyan.com>
The spec expects us to check for render blocking (among some other
state) before we start procesing a document. Therefore, add those checks
and also check in the
stylesheet loader that we should only do so when we are allowed to do
so.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This option controls whether progressive web metrics are printed to the
system console, which is essentially the purpose of
`DiagnosticsLogging`. This makes the API a bit more uniform.
Testing: We do not really have automated testing for this kind of
feature of the API.
Fixes: This is part of #34967.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Initial work to support scopes in the debugger. They don't show at the
moment since we are not processing variables yet. Depends on #43166.
Testing: Ran `mach test-devtools` and manual testing.
Part of: #36027
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
We send back input events handling results in batch. This reduces IPC,
and make the following **TODO** possible in a follow-up.
Testing: I hope existing tests results won't change.
Part of
https://github.com/servo/servo/issues/43136#issuecomment-4031915873
**TODO**: We have not done
> collect ids and send back a reply for each of them once the coalesced
event has been handled.
yet.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Add support for navigation requests ("navigateTo", "goBack", and
"goForward") over the Remote Debugging Protocol. These may be sent by a
UI client in response to user input (for example the address bar in the
Firefox inspector), or they can be used to automate navigation during
unit tests.
This currently only supports navigation within the URL domain at which
servoshell is initially launched, due to a bug in servo's
`BrowsingContextActor` implementation. (Unit tests covering a fix for
that issue will depend on this change.)
Testing: The behavior of all 3 new message types is covered by a new
test case—`test_navigation`—in the devtools unit test suite.
Fixes: #38668
---------
Signed-off-by: Brent Schroeter <contact@brentsch.com>
Co-authored-by: eri <eri@igalia.com>
Pass `ListFrames` back to devtools
Testing: existing test passes
Fixes: part of #36027
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
This change implements listing all frames from youngest to oldest. This
is in order to send correct frame message from thread actor
This is needed for our upcoming work!
Testing: Current tests are passing + manual test
Fixes: #36027
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
This changes makes it so that keyboard and click focusability are two
separate concepts in `script`. Some elements may be focusable only by
the keyboard and some only by the click events.
In addition, the `SEQUENTIALLY_FOCUSABLE` `Node` flag is removed in
favor of a
more specification-aligned approach of checking lazily if an element is
a focusable area. This allows moving the focus fixup steps to their
correct place, asynchronously during "update the rendering" and
synchronously during `unbind_from_tree`.
Testing: This causes some WPT tests to start passing and some to start
failing:
- Two subtests tests in
`tests/wpt/meta/css/css-conditional/container-queries/` because
we do not implement support for container queries. These are legitimate
failures
and they are compensated by a good subtest pass in the same file.
- A few subtests in `/html/interaction/focus/tabindex-focus-flag.html`
because now
we do not allow focusing non-rendering elements. The failures are HTML
elements with
`<svg>` which we do not rendering and `<summary>` elements of
`<details>` which
need special handling we do not implement yet.
- `html/semantics/forms/the-fieldset-element/disabled-003.html`: Some of
these tests
start to fail, but they are not spec compliant and browser properly
implementing
the asynchronous focus fixup rule also fail them.
Fixes: #31870.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
DomRefCell::borrow inside of layout code is risky because it leads to
memory races if the code is ever called from layout worker threads. This
can be caught via TSAN, but we can also catch it deterministically in CI
by using our existing thread state debug assertions correctly.
Testing: Existing WPT test coverage is sufficient.
Fixes: #42962
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Since `evaluate_js_on_global` called `enter_realm` and there were
already some callee that did it, I've actually passed `&mut
CurrentRealm`.
Also converted `Window::WebdriverException` to pass `&mut JSContext`
inside `javascript_error_info_from_error_info`.
Testing: A successful build is enough
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Remove embedder defined `ScrollEvent` and merge the payload of it to the
`SetScrollStates` message which tell the `ScriptThread` to update the
scroll state.
In the past, `ScrollEvent` is defined as a embedder's `InputEvent` and
being used only to forward the external scroll node id for a node that
is considered scrolled. This make us sends an additional message to
constellation and additionally, `ScrollEvent` went through lengthy
pipelines as it was deemed as an embedder input event, albeit being a
synthetic input fired by `WebviewRenderer`.
Subsequently, we could introduce a flag to detect whether the scrolling
is still ongoing or not (like whether it is still flinging) for
`scrollend` event.
Testing: No WPT changes
---------
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>
Now `ServoTestUtils.forceLayout()` will provide the number of fragments
that have been restyled and rebuilt. This will be useful to test that
incremental layout works well.
Testing: Adds a test using this new API
---------
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Currently, `script` and `devtools` use a node's unique id to identify it
across requests. The unique ID is part of a node's rare data field and
is really only meant for debugging. Instantiating it on a node causes
it's memory usage to go up significantly. Now, when the devtools ask for
information about a specific `Node` then they send the unique ID to
`script`, and the script thread then walks the whole DOM tree searching
for that specific ID. This happens here:
6d0b651218/components/script/devtools.rs (L142-L153)
So, in the worst case, all of the nodes in the tree now have a unique
ID. That's not great!
Also, when `script` notifies `devtools` about changes to a DOM node then
`devtools` expects a `NodeActor` to exist for that Node. The actor might
not exist if the inspector doesn't know about that node yet - that
happens when the user hasn't expanded their parent yet.
That is an oversight from https://github.com/servo/servo/pull/42601 and
causes problems now(https://github.com/servo/servo/issues/42784) because
for the longest time, `devtools` was mostly the one sending requests. Of
course, we could make `devtools` simply ignore updates for nodes that it
doesn't know about, but ideally we shouldn't send these updates in the
first place.
This change implements a lookup map on the `ScriptThread` that contains
all nodes that have been sent to the devtools inspector. The map allows
us to efficiently resolve a unique ID to a `Node` in O(1), without
creating unique IDs for the whole tree. It also allows us to only send
DOM updates for nodes that the inspector cares about.
For now, entries from the cache are not evicted unless the relevant
pipeline is closed. That reflects reality, because the inspector also
keeps using them forever.
In the future we will tell the inspector when nodes are removed from the
tree - then it can't interact with them anymore, and we can remove them
from the script-side map.
This is change is not all that complicated but it involves moving a lot
of code around, so feel free to ask for clarification when something is
unclear!
Testing: This change adds a test
Fixes part of https://github.com/servo/servo/issues/42784
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
As mentioned in #40600 we will need this to properly handle &mut
JSContext (we cannot pass it to drop) and I think this wrappers are
preferred ways of doing this in rust as it is safe to forget (not call
drop) which is unsound in this case (due to realm stack at least).
Revieable per commits.
Testing: Just a refactor, but should be covered by WPT
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.
I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`
Testing: Just refactor, but should be covered by WPT tests.
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@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>
`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 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>
This changes makes it so that tracing accesses the `ScriptThread` via a
weak reference set on the `Runtime` rather than thread local storage.
The idea is to use TLS less and less as time goes on. This is done by
creating a new data structure that holds all the data that is necessary
for SpiderMonkey callbacks in the `ScriptThread`.
Testing: This should not change behavior in a way that is observable
via testing.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This is a first step to compile scripts using `&mut JSContext`.
Testing: Refactor, covered by existing WPT tests.
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Since the steps for
https://html.spec.whatwg.org/multipage/parsing.html#the-end are
scattered throughout various pieces, it has been difficult to figure out
when to run what.
To remedy that, introduce the concept of phases. These phases are
checked in every method that needs to
"Spin the event loop" to know whether
1. It is the appropriate time to continue with #the-end
2. It has fully achieved its goal
For example, when processing deferred scripts, we need to do this after
a deferred script has finished loading. But we also need to do it at the
start of parsing, since we might not have any deferred scripts at all.
Therefore, each previous step sets the appropriate phase and calls the
corresponding next step. Each step then verifies its conditions and
continues if required.
Part of #41972
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
This change makes the devtools inspector show any event listeners that
are attached to a node. The primary motivation is making the devtools
more useful for debugging real-world websites.
<img width="536" height="268" alt="image"
src="https://github.com/user-attachments/assets/5ba13e41-14b4-4202-b994-eadff5d1c6b5"
/>
You can also click on the event listener to show some more info, though
most of that (everything except the event type and the event phase) is
currently just placeholder text:
<img width="1360" height="456" alt="image"
src="https://github.com/user-attachments/assets/ec025847-43fc-489c-8b26-46afb6dada64"
/>
Testing: This change adds a new test
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
The patch adds the following functionality to the per-WebView
`UserContentManager` API.
- Removing a `UserScript` at that was previously added.
- Adding a new `UserStyleSheet` representing a user-origin style sheet.
allow removing user script
- Removing a previously added `UserStyleSheet`.
There might be scope for some improvements in the API:
- `UserScript` and `UserStyleSheet` have different ways of representing
the source location - a `PathBuf` and `Url` respectively. This is due to
how those values are used by the underlying evaluation APIs in script
and stylo. More investigation is needed here and could be addressed in
future patches.
Testing: New unit tests are added for the user stylesheet APIs. Existing
tests have been updated to test the removal of user scripts.
This changes 3 occurences of HashSet to FxHashSet for speed
improvements:
- dom/notifications::pending_request_ids: Pending Request ids are
Uuid::new_v4, hence, not user assignable.
- script_thread: painters_generating_frames: These are pipeline ids and,
hence, ideal for FxHash.
- script_thread:: docs_with_no_blocking_loads: These are Dom<Document>
and their hash is the ptr address, so ideal for FxHash.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: These do not change functionality.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Continuing the implementation of `VisualViewport`, the resizing of
`PinchZoom` should be notified to `ScriptThread` to update the
`VisualViewport` interface and to fire the appropriate JS event. Top
level `Window`/`Pipeline` would have a `VisualViewport` interface that
mirrors the `PinchZoom` viewport, while nested `Window` would have a
default value that represent layout viewport of the relevant iframe. The
`VisualViewport` of an iframe is updated after each reflow that
calculate the rectangle of the iframe.
The updates of DOM's `VisualViewport` occurs immediately (instead of
waiting for the event loop like the viewport) but integrates with the
event loop for the JS events. This behavior would helps with the fact
that `VisualViewport` needs to be updated both when it is scrolled or
resized.
Testing: Existing WPTs and new unit test.
Part of: https://github.com/servo/servo/issues/41341
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
We populate the required field for all relevant entrypoints
and set it to `document.base_url` when the url is `about:blank`
or `about:srcdoc`. In all other cases, it uses
`document.about_base_url`.
Testing: WPT
Fixes#41836
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Add an event listener for `clearBreakpoint` to `debugger.js` and the
necessary glue to access it from the `devtools` crate.
Testing: `./mach test-devtools` and manual testing.
Fixes: Part of: https://github.com/servo/servo/issues/36027
---------
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: eri <eri@igalia.com>
This change finishes the big rename associated with the old
`compositing` crates. Long ago, these crates managed a compositor, like
you might find in a traditional web engine. These days, compositing is
done in WebRender so the name has stopped making much sense. Various
structs inside the crates have already been renamed and this is the
final big change necessary for the rename
Testing: This is just a rename so existing tests should cover it.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Add an event listener for `pause` to `debugger.js` and the necessary
glue to access it from the `devtools` crate. This returns important
information to know where we are paused, such as the source location and
frame state.
Fix frame and object actor encoding into messages. Use information from
`debugger.js` to correctly fill the fields.
Add a new `frames` list to the thread actor and handle the `frames`
message.
Fix `getEnvironment` reply in the frame actor. It is out of form (has a
`type` field but it doesn't require a followup empty message, it already
counts as a reply), so we need to handle it specially.
Note: For now we are focusing on the protocol side of the debugger, and
this patch only shows where the pause would happen. Pausing Servo itself
will happen in a followup.

Testing: `mach test-devtools` and manual testing. No errors (apart from
#42006).
Part of: #36027
---------
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>