Commit graph

351 commits

Author SHA1 Message Date
Gae24
f986160ed4
fix many clippy warnings (#33510)
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2024-09-21 13:58:31 +00:00
Simon Wülker
7df30f3788
Replace .map_or(false with Option::is_some_and (#33468)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2024-09-16 10:03:52 +00:00
Taym Haddadi
747e562ff0
Make CanGc derive Copy and Clone (#33407)
Signed-off-by: Taym <haddadi.taym@gmail.com>
2024-09-12 10:24:44 +00:00
Andriy Sultanov
e5150dbda1
Propagate CanGc from Document::new() (#33386)
* Add canGc as a parameter to autogenerated trait methods

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>

* Propagate CanGc from Document::new()

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>

---------

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
2024-09-09 22:38:01 +00:00
Kopanov Anton
ad45fa0a19
script: Fix panic in htmlimageelement.rs using str::find() to find character boundaries. (#32980)
* fix loop with chars().enumerate() by using find()

Signed-off-by: Kopanov Anton <anton.kopanov@ya.ru>

* Add documentation to parser and fix some small issues

- Rename the properties of `Descriptor` so that they are full words
- Use the Rust-parser to parse doubles
- Add documentation and restructure parser to be more readable

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Kopanov Anton <anton.kopanov@ya.ru>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-08-24 08:22:39 +00:00
Josh Matthews
60ef6bc461
Start marking functions that can transitively trigger a GC (#33144)
* Mark JS reflector wrappers as CanGc.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from reflect_dom_object_with_proto.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Mark DOM constructors as GC operations.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-08-22 11:42:36 +00:00
Taym Haddadi
1d048f4f6a
Implement HTMLImageElement decode (#31269)
* Implement HTMLImageElement decode

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Fix Decode doc link

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Temp

* Decode HTML Image

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Fix doc link

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Move image decode to process_image_response_for_environment_change

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Update some wpt test result

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Handle multiple image decode promises

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Remove unnecessary promise calls

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Update more wpt test result

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Undo body-size-cross-origin.https.html.ini changes

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Reject decode when src and srcset are missing

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Revert "Reject decode when src and srcset are missing"

This reverts commit 1b57ab978f9fc24facafc8af97ee8851d5142533.

* Drain promises vec and run update_the_image_data when element is created

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* resolve decode promise in abort_request when request is CompletelyAvailable

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Update wpt test

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Move storing promise in decode task

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Remove the resolve logic from decode task

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Revert "Remove the resolve logic from decode task"

This reverts commit eee6096d50.

* reject or reject current promise before storing it

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Add comment to explain why resolve promise when state is CompletelyAvailable

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

---------

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
2024-06-13 10:15:49 +00:00
Peter Mikola
0a641816bf
clippy fixes regarding clone_from (#32482) 2024-06-12 17:09:56 +00:00
Martin Robinson
53c0726ef4
script: Have Document own Layout (#32316)
Have `Document` own `Layout`. This makes it impossible to have a
`Document` without `Layout`, which was true, but now the compiler checks
it. In addition, `Layout` is now released when the `Document` is,
avoiding leaking the entire `Layout`.
2024-05-20 13:04:32 +00:00
Mukilan Thiyagarajan
2af6fe0b30
compositor: Move WebRender-ish messages and types to webrender_traits (#32315)
* Move WebRender related types to `webrender_traits`

This refactor moves several WebRender related types
from `compositing_traits`, `script_traits` and `net_traits`
crates to the `webrender_traits` crate.

This change also moves the `Image` type and associated
function out of `net_traits` and into the `pixels` crate.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Move `script_traits::WebrenderIpcSender` to `webrender_traits::WebRenderScriptApi`

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-05-20 10:35:18 +00:00
Martin Robinson
3398fc017b
Move non-gfx things out of gfx_traits and create a base crate (#32296)
For a long time, `gfx_traits` has held a lot of things unrelated to graphics
and also unrelated to the `gfx` crate (which is mostly about fonts).
This is a cleanup which does a few things:

1. Move non `gfx` crate things out of `gfx_traits`. This is important in
   order to prevent dependency cycles with a different integration between
   layout, script, and fonts.
2. Rename the `msg` crate to `base`. It didn't really contain anything
   to do with messages and instead mostly holds ids, which are used
   across many different crates in Servo. This new crate will hold the
   *rare* data types that are widely used.

Details:

 - All BackgroundHangMonitor-related things from base to a new
   `background_hang_monitor_api` crate.
 - Moved `TraversalDirection` to `script_traits`
 - Moved `Epoch`-related things from `gfx_traits` to `base`.
 - Moved `PrintTree` to base. This should be widely useful in Servo.
 - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it
   to `WebRenderFontApi`.
2024-05-17 12:28:58 +00:00
Martin Robinson
a0640c8524
Address issues uncovered by rust-1.78 beta (#32130)
This change makes changes to allow Servo to compile with the 1.78
version of Rust:

 - Dead code is removd (Rust seems to have gotten better at detecting
   it).
 - The `FlowRef` `DerefMut` is updated according to @SimonSapin's advice
   [^1].
 - The `imports.rs` now explicitly silences warnings about unused
   imports.

[^1]: https://github.com/servo/servo/issues/6503#issuecomment-2066088179

<!-- Please describe your changes on the following line: -->


---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they should not change
behavior.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->
2024-04-22 18:20:47 +00:00
Martin Robinson
fe8b23d14a
layout: Add a FontMetricsProvider for resolving font-relative units (#31966)
The only font relative unit that Servo knows how to resolve currently is
`rem` (relative to the root font size). This is because Stylo cannot do
any font queries. This adds a mechanism to allow this, exposing the
ability to properly render `ex` units in Servo.

This change only allows resolving some font size relative units thoug,
as Servo doesn't collect all the FontMetrics it needs to resolve them
all. This capability will be added in followup changes.

Some new tests fail:
 - ex-unit-001.html: This test fails because Servo does not yet have
   support for setting the weight using @font-face rules on web fonts.
 - ex-unit-004.html: This test fails because Servo does not yet have
   support for setting the Unicode range of a web font using @font-face
   rules.
 - first-available-font-001.html: This test fails because the above
   two feature are missing.
2024-04-04 12:35:15 +00:00
Aarya Khandelwal
bd39e03eeb
changed match to 'matches!' (#31850) 2024-03-25 11:28:12 +00:00
Aarya Khandelwal
9b26dca141
Fixed the .clone() warnings. (#31819) 2024-03-22 05:41:17 +00:00
Aarya Khandelwal
7cdff9dd06
Clippy: Fixed warnings in htmlimageelement.rs (#31800)
* Fixed warnings in htmlimageelement.rs

* making changes for test-tidy to run without errors.
2024-03-21 08:00:24 +00:00
Aarya Khandelwal
da3288dd00
Clippy: Fixed clippy warnings in components/script/dom (#31801)
* fixed clippy warnings in htmlformelement.rs

* Fixed clippy warnings

* Fixed warnings related to matches!

* made changes to compile "test-tidy" successfully
2024-03-21 07:14:12 +00:00
Oluwatobi Sofela
2789e98876
clippy: Fix redundant field names warnings (#31793) 2024-03-20 23:05:29 +00:00
Martin Robinson
9a6973d629
style: Remove dependency on servo_url (#31358)
In order for stylo to be a separate crate, it needs to depend on less
things from Servo. This change makes it so that stylo no longer depends
on servo_url.
2024-02-16 11:56:35 +00:00
Martin Robinson
5c1723c983
rustdoc: Fix many rustdoc errors (#31147)
This fixes many rustdoc errors that occur due to raw URLs in rustdoc
comments as well as unescaped Rust code that should be in backticks.
2024-01-22 13:13:48 +00:00
Samson
604979e367
Replace script_plugins with a clippy like rustc driver (named crown) (#30508)
* Remove script_plugins

* Use crown instead of script_plugins

* crown_is_not_used

* Use crown in command base

* bootstrap crown

* tidy happy

* disable sccache

* Bring crown in tree

* Install crown from tree

* fix windows ci

* fix warning

* fix mac

libscript_plugins.dylib is not available anymore

* Update components/script/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* Update for nightly-2023-03-18

Mostly just based off https://github.com/servo/servo/pull/30630

* Always install crown

it's slow only when there is new version

* Run crown test with `mach test-unit`

* Small fixups; better trace_in_no_trace tests

* Better doc

* crown in config.toml

* Fix tidy for real

* no sccache on rustc_wrapper

* document rustc overrides

* fixup of compiletest

* Make a few minor comment adjustments

* Fix a typo in python/servo/platform/base.py

Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>

* Proper test types

* Ignore tidy on crown/tests

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-12-01 15:50:52 +00:00
Oriol Brufau
f1ae42678a Further changes required by Servo 2023-11-24 08:57:14 +01:00
Samson
ebd41d4101
Use Foo_Binding instead of FooBinding for namespace modules (#30447)
* Update Codegen.py to emit Foo_Binding instead of FooBinding

* s/FooBinding/Foo_Binding/g
2023-09-30 00:52:04 +00:00
Samson
aad2dccc9c
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Samson
711dbbd4af
remove extern crate (#30311)
* remove extern crate

* Update components/script_plugins/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-09-08 12:11:31 +00:00
Samson
9514f670d1
No tracing of nop traceable fields (#29926)
* Add `no_trace` option to JSTraceable derive

* NoTrace wrapper

* Port some types to no_trace schematics

* Fixing my unsafe mistakes (not tracing traceables)

* Add docs & safety guards for no_trace

Safety guards (trait shenanigans) guarantees safety usage of `no_trace`

* Port canvas_traits to no_trace

* Port servo_media to no_trace

* Port net_traits to no_trace

* Port style to no_trace

* Port webgpu to no_trace

* Port script_traits to no_trace

* Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace

* unrooted_must_root lint in seperate file

* Add trace_in_no_trace_lint as script_plugin

* Composable types in must_not_have_traceable

* Introduced HashMapTracedValues wrapper

* `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>`

* Port rest of servo's types to no_trace

* Port html5ever, euclid, mime and http to no_trace

* Port remaining externals to no_trace

* Port webxr and Arc<Mutex<_>>

* Fix spelling in notrace doc
2023-08-04 10:17:43 +00:00
Josh Matthews
dbff26bce0 Support arbitrary protos when wrapping DOM objects with constructors. 2023-05-28 23:23:12 -04:00
Josh Matthews
864e072d5c Enter realms more consistently during the script event loop. 2023-05-20 14:30:22 -04:00
Matthias Deiml
fa18cf620f Make url for "client" referrer mandatory 2020-06-17 19:07:14 +02:00
Bastien Orivel
bdbfde9ec0 Don't send a load event when a loaded image is actually the placeholder
The image cache returns an `ImageCacheResult::ImageAvailable `the second
time you try getting the placeholder. This means that in some cases, the
loading of an image would fail, then the same image would get fetched
from the cache, the placeholder would be loaded from that but would be
seen as a normal image, firing a load event.

This made the tests in
`fetch/cross-origin-resource-policy/image-loads.html` fail depending on
their order.
2020-05-08 19:15:24 +02:00
bors-servo
6aec2c8594
Auto merge of #26450 - PeterZhizhin:add_referrerpolicy_to_list_of_relevant_mutations, r=jdm
Add referrerpolicy to list of relevant mutations

<!-- Please describe your changes on the following line: -->

`img.referrerPolicy` change now mutates the image.
Not all `referrerPolicy` attribute changes result in an image update event.
Only valid changes are reflected.

All referrerpolicy tests inside `relevant-mutations.html` WPT test now pass.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #26388

<!-- Either: -->
- [x] These have tests:
```
./mach test-wpt tests/wpt/web-platform-tests/html/semantics/embedded-content/the-img-element/relevant-mutations.html
```
2020-05-07 08:45:12 -04:00
PeterZhizhin
f44c2c9bc5 Added referrerpolicy as relevant mutation for img
This fixes #26388. referrerPolicy is now calls onload for image
mutations. Not all referrerPolicy attribute changes result in an image
update event. Only valid changes are reflected.

Referrerpolicy tests now pass.
2020-05-07 10:12:53 +03:00
Martin Robinson
b585ce5b1f Use a restyle for animation ticks
This change corrects synchronization issues with animations, by
reworking the animation processing model to do a quick restyle and
incremental layout when ticking animations.

While this change adds overhead to animation ticks, the idea is that
this will be the fallback when synchronous behavior is required to
fulfill specification requirements. In the optimistic case, many
animations could be updated and applied off-the-main-thread and then
resynchronized when style information is queried by script.

Fixes #13865.
2020-05-05 15:13:35 +02:00
Julien Tregoat
2742fd2bea Refactor ImageCache::find_image_or_metadata API. 2020-04-17 11:58:18 -04:00
Anthony Ramine
1cd3d6bd4c Introduce <LayoutDom<HTMLImageElement>>::current_request
This safe helper contains the only source of unsafety from the actual image
layout helpers methods, making them completely safe.
2020-04-01 11:40:55 +02:00
Anthony Ramine
5ff931d171 Introduce <LayoutDom<Element>>::attrs()
This safe method is the basic block to access element attributes from layout.
We reuse it in the other attr-related layout methods to remove a pretty big
source of rampant unsafe code between script and layout.
2020-03-31 18:46:49 +02:00
Anthony Ramine
0bda174823 Merge RawLayoutElementHelpers into LayoutElementHelpers 2020-03-31 18:30:42 +02:00
Anthony Ramine
e590251e5f Make LayoutHTMLImageElementHelpers methods take self 2020-03-29 17:20:40 +02:00
Anthony Ramine
dba6a635e5 Give a lifetime parameter to LayoutDom 2020-03-28 15:37:57 +01:00
YUAN LYU
3ea6d87bcc
Add trait DomObjectWrap to provide WRAP function 2020-03-20 22:16:56 -04:00
pylbrecht
3ec848f4a8 Handle nonexistent images in CanvasRenderingContext2D.createPattern() 2020-03-13 20:48:27 +01:00
Patrick Shaughnessy
f29e22f131 Names should now be consistently atoms 2020-02-13 11:21:46 -05:00
pylbrecht
ed0973fb1c Add image usability checks to drawImage() 2020-02-03 20:46:03 +01:00
Patrick Shaughnessy
0228904f27 Remove unnecessary LocalName::from(constant) calls 2020-01-28 11:47:05 -05:00
bors-servo
53879945a9
Auto merge of #25515 - pshaughn:checkpoints, r=jdm
Add microtask checkpoints to script elements and custom elements

Servo had a microtask checkpoint at the end of running a script, but there was also supposed to be one at the end of HTML-parsing a script element before Javascript-parsing the script itself, and there were supposed to be checkpoints immediately after the call to a custom element constructor. This adds those, passing all cases of one WPT test file.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25016 except for the remaining not-really-about-microtasks case #25514

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-01-25 07:30:48 -05:00
bors-servo
0c4205ebfe
Auto merge of #25431 - warren-fisher:create-html-element, r=jdm
use create_html_element for HTMLAudioElement and HTMLImageElement

<!-- Please describe your changes on the following line: -->

Updated the Image and Audio constructors to use `create_html_element` via the Element::create method. This was done to meet these specifications of "Let (audio/image) be the result of **creating an element** given document, audio, and the HTML namespace." for [dom-image](https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image) and [dom-audio](https://html.spec.whatwg.org/multipage/media.html#dom-audio)
Not sure what _is_ is according to the [create-element guidelines](https://dom.spec.whatwg.org/#concept-create-element) so I left it as None copying from #25393. Also copied the ElementCreator and CustomElementCreationMode from #25393 as I do not know what they do.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25421 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because it is a small swap out of the way used to generate these HTML elements. The pre-existing tests should be sufficient.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-01-21 12:38:07 -05:00
Kunal Mohan
f7db4b7f80
Modify script to prevent further violations of snake_case 2020-01-18 14:22:15 +05:30
Patrick Shaughnessy
c725f9e84d Add microtask checkpoints on </script> and CE construct 2020-01-15 11:49:52 -05:00
Kunal Mohan
02c1612cb0
Add accountable-refcell as optional build time feature 2020-01-08 09:44:41 +05:30
Warren Fisher
6e296150f8 use create_html_element for HTMLAudioElement and HTMLImageElement 2020-01-04 16:14:03 -04:00