This removes some complains that clippy will have in 1.95.
As this is mostly just match guards, it doesn't update MSRV.
Testing: This is equivalent exchanges, so current WPT would find
anything.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Servo has lots of `LayoutXYZHelper` traits that are used to define
additional methods on `LayoutDom<XYZ>`. We can replace them with `impl
LayoutDom<XYZ>` blocks, reducing the number of LoC and making it easier
to add or modify methods.
Testing: These should be covered by existing tests
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Refer to https://github.com/servo/servo/pull/43746 for a description of
the problem. This change ensures that video posters can be loaded from
blob URLs, even if the URL is revoked right after.
Testing: This change adds a test
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
`blob` URLs have a implicit blob URL entry attached, which stores the
data contained in the blob. The specification requires this entry to be
resolved as the URL is parsed. We only resolve it inside `net` when
loading the URL. That causes problems if the blob entry has been revoked
in the meantime - see https://github.com/servo/servo/issues/25226.
Ideally we would want to resolve blobs at parse-time as required. But
because `ServoUrl` is such a fundamental type, I've not managed to do
this change without having to touch hundreds of files at once.
Thus, we now require passing a `UrlWithBlobClaim` instead of a
`ServoUrl` when `fetch`-ing. This type proves that the caller has
acquired the blob beforehand.
As a temporary escape hatch, I've added
`UrlWithBlobClaim::from_url_without_having_claimed_blob`. That method
logs a warning if its used unsafely. This method is currently used in
most places to keep this change small. Only workers now acquire the blob
beforehand.
Testing: A new test starts to pass
Part of https://github.com/servo/servo/issues/43326
Part of https://github.com/servo/servo/issues/25226
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
A lot (and I mean, really a lot) depends on these constructors.
Therefore, this is the one spaghetti ball that I could extract and
convert all `can_gc` to `cx`. There are some new introductions of
`temp_cx` in the callbacks of the servo parser, but we already had some
in other callbacks.
Part of #40600
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
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>
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>
It pushes the `temp_cx` 1 level up to `element.rs` where the calling
chain begins. Other than that this was purely a mechanical change where
I used regexes to replace all patterns with the new ones.
Part of #42812
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Correct data type of poster in `HTMLVideoElement` interface
Successful compilation is enough to verify the change.
Testing: `tests/wpt/meta/html/dom/reflection-embedded.html`
---------
Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
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>
`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>
Rather than having each callside specifying the relevant
information from the GlobalScope, do this via a trait instead.
This would have saved us quite a bit of test debugging
since we would often forget to set relevant information
from the global context for a request.
Now, in the future when we need additional information from
the globalscope for a request, we only need to update this
method to make that happen.
Previously it would also sometimes use `document`, but
calling the relevant information on either `document` or
`globalscope` doesn't matter, since the `globalscope`
defers to the value from the `document` anyways.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
These keep-alive records live on the `CoreResourceManager` since the vec
of records must be modified by the fetch thread. The script thread
sometimes
requires this information as well, which is why it can send a message to
obtain the total size.
The keep-alive records must be tracked per global. That's why all code
needs
to specify the `pipeline_id`. Requests optionally have this field, which
is why
the code expects it to be present. The relevant information is added to
the
navigator request to ensure it can compute it.
Fixes#41230
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This implements waiting for pending preloads, where the preload request
is still fetching the result when the second "real" request is started.
It is
implemented by storing responses in the `SharedPreloadedResources`
which is communicated via `PreloadId` send to the `CoreResourceManager`.
Part of #35035
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This implements the required plumbing for the keep-alive flag on
requests. The flag already exists on the request object, but now also
exists on the builder itself.
The flag is then passed into a canceller. While we could make canceller
optional, in many cases it isn't and would require a whole lot more
changes. To follow the spec more closely, opted to put the keep_alive
flag on the canceller as well.
Note that this doesn't pass any extra fetch-later tests since we are not
correctly unloading iframe documents. That will be fixed in a follow-up
PR.
Part of #41230
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
The goal of this change is to prevent having to copy so much data out of
listeners when a fetch completes, which will be particularly important
for off-the-main thread parsing of CSS (see #22478). This change has
pros and cons:
Pros:
- This makes the design of the `FetchResponseListener` a great deal
simpler.
They no longer individually store a dummy `ResourceFetchTiming` that is
only replaced right before `process_response_eof`.
- The creation of the `Arc<Mutex<FetchResponseListener>>` in the
`NetworkListener` is abstracted away from clients and now they just
pass the `FetchResponseListener` to the fetch methods in the global.
Cons:
- Now each `FetchResponseListener` must explicitly call `submit_timing`
instead of having the `NetworkListener` do it. This is arguably a bit
easier to follow in the code.
- Since the internal data of the `NetworkListener` is now an
`Arc<Mutex<Option<FetchResponseListener>>>`, when the fetching code
needs to share state with the `NetworkListener` it either needs to
share an `Option` or some sort of internal state. In one case I've
stored the `Option` and in another case, I've stored a new inner
shared value.
Testing: This should not change observable behavior and is thus covered
by existing tests.
Fixes: #22550
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Adds a wrapper type for vectors that can contain large response bodies
to prevent flooding debug logs with the contents of those bodies.
Testing: Can't test debug log output.
Fixes: #37769
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
`FetchReponseListener` has traditionally lived in `net` even though it
is only used in `script` currently. Because of the two way dependency,
it has also use a lot of templating to implement something pretty basic
(call methods on a trait object).
This change moves the trait to `script` and removes several levels of
templating, making the code quite a bit shorter and easier to
understand.
This change is preparation for fixing #22550 and implementing
off-the-main-thread CSS parsing.
Testing: This should not change any behavior so is covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Previously, the `ImageCache` would inform consumers of changes to image
availability by messaging an IPC channel. This isn't great, because it
requires serialization and deserialization. Nowadays, `ImageCache`s are
always owned by the same `Global` that uses them. This change replaces
the IPC channel with callback that implements `Send`.
For the case of normal HTML document images, the results are still sent
over the pre-existing Crossbeam channel that was connected via an IPC
route. A followup change might eliminate that channel entirely.
Testing: This should not change observable behavior so is covered by
existing tests.
Fixes: #24338.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Instead of having the `ImageCache` return the broken image icon for
failed loads, have `HTMLImageElement` explicitly request it. This means
that the image is loaded on demand (reducing the usage of resources) and
also simplifying the interface of the `ImageCache` greatly.
In addition, the display of the broken image icon is improved, more
closely matching other browsers. A test for this display (which was
falsely passing before) is updated to reflect the new display of the
broken image icon.
Testing: There is a Servo-specific test for this change. Some WPT tests
start to fail as well. Before these were not properly loading the broken
image icon so they were failing before, just in a hidden way.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Servo has a lot of comments like this:
```rust
// https://example-spec.com/#do-the-thing
fn do_the_thing() {}
```
and I keep turning these into doc comments whenever I'm working close to
one of them. Doing so allows me to hover over a function call in an IDE
and open its specification without having to jump to the function
definition first. This change fixes all of these comments at once.
This was done using `find components -name '*.rs' -exec perl -i -0777
-pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`.
Note that these comments should be doc comments even within trait `impl`
blocks, because rustdoc will use them as fallback documentation when the
method definition on the trait does not have documentation.
Testing: Comments only, no testing required
Preparation for https://github.com/servo/servo/pull/39552
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Moves interfaces defined by the performance spec to the
`script/dom/performance/` module from `script/dom/`.
Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901
Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
The HTML specification defines the 'width' and 'height' attributes as
dimension attributes for the embedded content and images (img, iframe,
embed, object, video, source, input with image type)
https://html.spec.whatwg.org/multipage/#dimension-attributes and for the
tables (table, col, colgroup, thead, tbody, tfoot, tr, td, th) even
these attributes are marked as obsolete.
And UA are expected to use these 'width' and 'height' attributes as
style presentational hints for the rendering.
The embedded content and images:
https://html.spec.whatwg.org/multipage/#dimRendering
The tables:
https://html.spec.whatwg.org/multipage/#tables-2:the-table-element-4
Added missing 'width' and/or 'height' reflected IDL attributes:
- conformant 'unsigned long' IDL attributes for the 'img, source, video'
(with new macro 'make_dimension_uint*)
- obsolete 'DOMString' IDL attributes for the 'td, th, col, colgroup'
Moved the `fn attribute_affects_presentational_hints()` from Element to
specific HTML and SVG elements with attributes which affects
presentational hints for rendering.
Testing: Improvements in the following tests
- html/dom/idlharness.https.html
- html/dom/reflection-embedded.html
- html/dom/reflection-tabular.html
-
html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>