aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/context.rs
Commit message (Collapse)AuthorAgeFilesLines
* layout: Scale images in `image_set` by their specified resolution (#36374)ToBinio2025-04-071-6/+25
| | | | | | | | | | | | | | | | | | | | | | | This PR makes it so the `resolution` factor in `image-set` also affects the image size. For instance, in the example below: ```css background-image: image-set("./small.png" 1x, "./large.png" 2x); ``` if `large.png` is used, an image which is 32x32 will be rendered as 16x16. This is specified in <https://drafts.csswg.org/css-images-4/#image-set-notation>. Testing: - `css/css-images/image-set/image-set-resolution-002.html` --------- Signed-off-by: tobinio <Tobias.frischmann1@gmail.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
* layout: Implement support for `image-set()` notation (#36210)chocolate-pie2025-03-291-3/+40
| | | Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
* Animation: Aggregate Animated Image Info to Document (#36141)TIN TUN AUNG2025-03-281-1/+26
| | | Signed-off-by: rayguo17 <rayguo17@gmail.com>
* script: Do not set up an IPC route for every image load (#35041)Martin Robinson2025-01-251-1/+1
| | | | | | | | | | | | Instead of setting up a route for every image load in the DOM / Layout, route all incoming image cache responses through the `ScriptThread`. This avoids creating a set of file descriptor for every image that is loaded. This change requires having the `ImageCache` track the `PipelineId` of the original the listener so that the `ScriptThread` can route it properly to the correct `Window`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Elide lifetimes where possible after rustup (#34824)Martin Robinson2025-01-031-2/+2
| | | | | | | | | The new version of rust allows us to elide some lifetimes and clippy is now complaining about this. This change elides them where possible and removes the clippy exceptions. Fixes #34804. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Manage `<iframe>` sizes in `Window` (#34643)Martin Robinson2024-12-161-1/+4
| | | | | | | | Manage `<iframe>` size updates in `Window`. In addition to removing duplicated code, this will allow setting `<iframe>` sizes synchronously on child `Pipeline`s of the same origin in the script process in a followup change. The goal is remove flakiness from `<iframe>` sizing. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* fonts: Simplify `FontContext` in two ways that affect the unit test (#33541)Martin Robinson2024-09-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This is done by no longer forwarding compositor-bound messages through SystemFontService and making `FontContext` non-generic: - Messages from the `FontContext` to the `Compositor` no longer need to be forwarded through the `SystemFontService`. Instead send these messages directly through the script IPC channel to the `Compositor`. - Instead of adding a mock `SystemFontServiceProxy`, simply implement a mock `SystemFontService` on the other side of an IPC channel in the `font_context` unit test. This allows making `FontContext` non-generic, greatly simplifying the code. The extra complexity moves into the unit test. These changes necessitate adding a new kind of `FontIdentifier`, `FontIdentifier::Mock` due to the fact that local fonts have platform-specific identifiers. This avoids having to pretend like the system font service can have web fonts -- which was always a bit of a hack. These two changes are combined into one PR because they both require extensive and similar chages in the font_context unit test which dependended on the details of both of them. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* fonts: Use `IpcSharedMemory` to send font data (#33530)Martin Robinson2024-09-251-2/+2
| | | | | | | | | | | | | | | | | | | | | This changes modifes the way that font data is sent over IPC channels. Instead of serializing the data or sending it via IPC byte senders, font data is copied into shared memory and a copy of the handle is sent over the channel. There is also the idea of sending the file handle of the on disk data of system fonts. This could be implemented as a further followup once there is an abstraction in `ipc-channel` over file handles. To accomplish this, a `FontData` abstraction is added, which also allows caching an in-memory shared `Arc<Vec<u8>>` version of the data (neeeded by some APIs). This could also be a place for caching font tables in the future. Finally, the `FontCacheThread` is renamed to the `SystemFontService` while the proxy for this is now named `SystemFontServiceProxy`. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Rename `gfx` to `fonts` (#32556)Martin Robinson2024-06-191-2/+1
| | | | | | | | | This crate only takes care of fonts now as graphics related things are split into other crates. In addition, this exposes data structures at the top of the crate, hiding the implementation details and making it simpler to import them. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* fonts: Clean up messaging during web fonts loads (#32332)Martin Robinson2024-05-221-5/+5
| | | | | | | | | | | | Instead of sending a message to the script thread via IPC when a web font loads and then sending another, just give the `FontContext` a callback that send a single message to the script thread. This moves all the cache invalidation internally into `FontContext` as well. Additionally, the unused LayoutControlMessage::ExitNow enum variant is removed. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Move non-gfx things out of `gfx_traits` and create a `base` crate (#32296)Martin Robinson2024-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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`.
* fonts: Make `FontContext` thread-safe and share it per-Layout (#32205)Martin Robinson2024-05-021-28/+2
| | | | | | | | | | | | This allows sharing font templates, fonts, and platform fonts across layout threads. It's the first step toward storing web fonts in the layout versus the shared `FontCacheThread`. Now fonts and font groups have some locking (especially on FreeType), which will probably affect performance. On the other hand, we measured memory usage and this saves roughly 40 megabytes of memory when loading servo.org based on data from the memory profiler. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* layout: Add a `FontMetricsProvider` for resolving font-relative units (#31966)Martin Robinson2024-04-041-12/+22
| | | | | | | | | | | | | | | | | | | 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.
* Lint layout_2020 with clippy (#31169)Oriol Brufau2024-01-251-1/+1
| | | cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-3/+5
| | | | | * strict imports formatting * Reformat all imports
* Combine DOM-related concepts in Layout 2020 into dom.rsMartin Robinson2023-05-131-3/+2
|
* Implement cross origin resource policy checkBastien Orivel2020-05-081-1/+1
| | | | | I removed the window getter usage from those tests as servo does not support that yet.
* Use a restyle for animation ticksMartin Robinson2020-05-051-35/+13
| | | | | | | | | | | | | | 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.
* Refactor ImageCache::find_image_or_metadata API.Julien Tregoat2020-04-171-26/+28
|
* remove option for origin and mirror changes to layout_thread_2020Kunal Mohan2020-02-181-0/+2
|
* Copy image-fetching code from Layout 2013Simon Sapin2020-01-131-1/+128
|
* Disable use of rayon with `--layout-threads 1` instead of panickingSimon Sapin2019-12-101-0/+1
|
* Un-allow and fix warnings in `components/layout_2020`Simon Sapin2019-12-021-1/+1
|
* Pass a LayoutContext to TextRun::layout in 2020Anthony Ramine2019-11-251-0/+17
|
* Import victor's layout system 🍷Anthony Ramine2019-09-111-0/+3
|
* Remove most of the things in layout 2020Anthony Ramine2019-07-311-183/+0
| | | | | We keep mostly the query system. There is probably more to delete but that's a good start I think.
* Make layout_2020 be layout_2013Anthony Ramine2019-07-311-0/+201