aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread_2020
Commit message (Collapse)AuthorAgeFilesLines
* `compositing`: Combine `webrender_traits` and `compositing_traits` (#36372)Martin Robinson2025-04-062-2/+2
| | | | | | | | | | | | | | | These two traits both exposed different parts of the compositing API, but now that the compositor doesn't depend directly on `script` any longer and the `script_traits` crate has been split into the `constellation_traits` crate, this can be finally be cleaned up without causing circular dependencies. In addition, some unit tests for the `IOPCompositor`'s scroll node tree are also moved into `compositing_traits` as well. Testing: This just combines two crates, so no new tests are necessary. Fixes: #35984. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Move `ScriptToConstellationMsg` to `constellation_traits` (#36364)Martin Robinson2025-04-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last big change necessary to create the `constellation_traits` crate. This moves the data structure for messages that originate from the `ScriptThread` and are sent to the `Contellation` to `constellation_traits`, effectively splitting `script_traits` in half. Before, `script_traits` was responsible for exposing the API of both the `ScriptThread` and the `Constellation` to the rest of Servo. - Data structures that are used by `ScriptToConstellationMsg` are moved to `constellation_traits`. The dependency graph looks a bit like this: `script_layout_interface` depends on `script_traits` depends on `constellation_traits` depends on `embedder_traits`. - Data structures that are used in the embedding layer (`UntrustedNodeAddress`, `CompositorHitTestResult`, `TouchEventResult` and `AnimationState`) are moved to embedder_traits, to avoid a dependency cycle between `webrender_traits` and `constellation_traits`. - Types dealing with MessagePorts and serialization are moved to `constellation_traits::message_port`. Testing: This is covered by existing tests as it just moves types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* constellation: Stop assuming that the viewport is shared by all WebViews ↵Martin Robinson2025-04-041-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#36312) The `Constellation` previously held a `window_size` member, but this assumes that all `WebView`s have the same size. This change removes that assumption as well as making sure that all `WebView`s pass their size and HiDIP scaling to the `Constellation` when they are created. In addition - `WindowSizeData` is renamed to `ViewportDetails`, as it was holding more than just the size and it didn't necessarily correspond to a "window." It's used for tracking viewport data, whether for an `<iframe>` or the main `WebView` viewport. - `ViewportDetails` is stored more consistently so that conceptually an `<iframe>` can also have its own HiDPI scaling. This isn't something we necessarily want, but it makes everything conceptually simpler. The goal with this change is to work toward allowing per-`WebView` HiDPI scaling and sizing. There are still some corresponding changes in the compositor to make that happen, but they will in a subsequent change. Testing: This is covered by existing tests. There should be no behavior changes. Fixes: This is part of #36232. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Organize component Cargo.toml dependencies (#36224)Alex Touchet2025-03-301-2/+2
| | | Signed-off-by: Alex Touchet <26315797+atouchet@users.noreply.github.com>
* Animation: Aggregate Animated Image Info to Document (#36141)TIN TUN AUNG2025-03-281-7/+38
| | | Signed-off-by: rayguo17 <rayguo17@gmail.com>
* chore: Remove unused generation counter field from LayoutThread (#36172)Kelechi Ebiri2025-03-261-7/+0
| | | Signed-off-by: TG <ebiritg@gmail.com>
* Create a `constellation_traits` crate (#36088)Martin Robinson2025-03-222-6/+5
| | | | | | | | | | | | | | This change creates a `constellation_traits` crate. Previously messages to the `Constellation` were in the `compositing_traits` crate, which came about organically. This change moves these to a new crate which also contains data types that are used in both compositing/libservo and script (ie types that cross the process boundary). The idea is similar to `embedding_traits`, but this is meant for types not exposed to the API. This change allows deduplicating `UntrustedNodeAddress`, which previously had two versions to avoid circular dependencies. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* metrics: Simplify `ProgressiveWebMetrics` (#35985)Martin Robinson2025-03-211-23/+2
| | | | | | | | | | | | | | | | Simply how `ProgressiveWebMetrics` works: 1. Keep only a single struct instead of one in layout and one script that both implement the `ProgressiveWebMetrics` trait. Since layout and script are the same thread these can now just be a single `ProgressiveWebMetrics` struct stored in script. 2. Have the compositor be responsible for informing the Constellation (which informs the ScripThread) about paint metrics. This makes communication flow one way and removes one dependency between the compositor and script (of two). 3. All units tests are moved into the `metrics` crate itself since there is only one struct there now. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* constellation: Proxy `ScrollState` through the `Constellation` (#36062)Martin Robinson2025-03-211-4/+4
| | | | | | | | | This will allow removing the dependency of the compositor on `script_traits`, which should make our internal dependency chain a lot easier to deal with. Part of #35984. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Cleanup Stylo dependencies (#36046)Oriol Brufau2025-03-191-2/+2
| | | | | | | | | Now that Stylo considers `servo` as the default feature, Servo doesn't need to specify `features = ["servo"]`. Also use the same crate names as Stylo, rather than renaming them with `package`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Use new stylo crate renames (#35898)Nico Burns2025-03-122-2/+2
| | | Signed-off-by: Nico Burns <nico@nicoburns.com>
* compositor: Make `PipelineDetails` and pending paint metrics per-WebView ↵Martin Robinson2025-03-041-2/+6
| | | | | | | | | | | | | | | | (#35701) This is one of the first big steps toward making the compositor work per-WebView. It moves the collection of pipelines into the per-WebView data structure in the compositor as well as the pending paint metrics. This means that more messages need to carry information about the WebView they apply to. Note that there are still a few places that we need to map from `PipelineId` to `WebViewId`, so this also includes a shared mapping which tracks this. The mapping can be removed once event handling is fully per-WebView. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Delan Azabani <dazabani@igalia.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-3/+3
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* fonts: Remove the per-FontGroup cached fallback font (#35705)Martin Robinson2025-02-281-2/+2
| | | | | | | | | | | | | | | | | | | Instead of keeping a per-FontGroup cache of the previously used fallback font, cache this value in the caller of `FontGroup::find_by_codepoint`. The problem with caching this value in the `FontGroup` is that it can make one layout different from the next. Still, it is important to cache the value somewhere so that, for instance, Chinese character don't have to continuously walk through the entire fallback list when laying out. The heuristic here is to try to last used font first if the `Script`s match. At the very least this should make one layout consistent with the next. Fixes #35704. Fixes #35697. Fixes #35689. Fixes #35679. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: add skeleton implementation of `FontFace` API (#35262)Mukilan Thiyagarajan2025-02-191-2/+2
| | | | | | | | | | | | | | | | This patch implements the `FontFace` interface, but with some caveats 1. The interface is only exposed on `Window`. Support for Workers will be handled in the future. 2. The concept of `css-connected` `FontFace` is not implemented, so `@font-face` rules in stylesheets will not be represented in the DOM. 3. The constructor only supports using `url()` strings as source and `ArrayBuffer` and `ArrayBufferView` are not supported yet. A skeleton implementation of the `load` method of `FontFaceSet` is also implemented in this patch. The intention is to support some web pages that don't load without this method. Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Fix scroll_sensitivity related naming issue (#35462)Euclid Ye2025-02-141-1/+1
| | | Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* script_traits: Rename `ConstellationControlMsg` to `ScriptThreadMessage` ↵Martin Robinson2025-01-301-6/+3
| | | | | | | | | | | (#35226) At some point in the past this message was only sent from the `Constellation` to `script`, but nowadays this is sent from various parts of servo to the `ScriptThread`, so this is a better name. In particular, the current name makes it seeem like this message controls the `Constellation`, which it does not. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Include `WebViewId` into EmbedderMsg variants where possible (#35211)Delan Azabani2025-01-301-42/+25
| | | | | | | | | | | | | | | | | `EmbedderMsg` was previously paired with an implicit `Option<WebViewId>`, even though almost all variants were either always `Some` or always `None`, depending on whether there was a `WebView involved. This patch adds the `WebViewId` to as many `EmbedderMsg` variants as possible, so we can call their associated `WebView` delegate methods without needing to check and unwrap the `Option`. In many cases, this required more changes to plumb through the `WebViewId`. Notably, all `Request`s now explicitly need a `WebView` or not, in order to ensure that it is passed when appropriate. Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* layout: Remove the obsolete layout tracing functionality (#35001)Martin Robinson2025-01-151-11/+1
| | | | | | | | | | | | | | | | | | | | There were two kinds of layout tracing controlled by the same debugging option: - modern layout: Functionality that dumped a JSON serialization of the layout tree before and after layout. - legacy layout: A scope based tracing that reported the process of layout in a structured way. I don't think anyone working on layout is using either of these two features. For modern layout requiring data structure to implement `serde` serialization is incredibly inconvenient and also generates a lot of extra code. We also have a more modern tracing functionality based on perfetto that we have started to use for layout and IMO it's actually being used and more robust. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* fonts: Remove synchronous web font loading functionality (#35000)Martin Robinson2025-01-151-11/+1
| | | | | | | | Synchronous web font loading is not specification compliant and was added in #8341 to work around issues that do not exist any longer. This change removes the functionality and ensures that WPT tests are run with the spec compliant loader. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* api: Flatten and simplify Servo preferences (#34966)Martin Robinson2025-01-141-3/+3
| | | | | | | | | | | | | | | | | | | Flatten and simplify Servo's preferences code. In addition, have both preferences and options passed in as arguments to `Servo::new()` and make sure not to use the globally set preferences in `servoshell` (as much as possible now). Instead of a complex procedural macro to generate preferences, just expose a very simple derive macro that adds string based getters and setters. - All command-line parsing is moved to servoshell. - There is no longer the concept of a missing preference. - Preferences no longer have to be part of the resources bundle because they now have reasonable default values. - servoshell specific preferences are no longer part of the preferences exposed by the Servo API. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Move the `FontContext` to `Window` (#34845)Martin Robinson2025-01-071-15/+3
| | | | | | | This will allow using layout's `FontContext` in `Window` letting script manage font selection and download. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* script: Manage `<iframe>` sizes in `Window` (#34643)Martin Robinson2024-12-161-71/+12
| | | | | | | | 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>
* layout: Send back layout results directly and remove channels (#34609)Martin Robinson2024-12-131-75/+27
| | | | | | | | | | | | | | This eliminates the way that crossbeam channels are used to send layout results back to script, which should increase the efficiency of layout. If asynchronous layout is re-established it can be written as a layer on top of the layout interface, that way layout doesn't have to know so many details of how the asynchronocity works. Renames: - `ScriptReflow` to `ReflowRequest`: Script is the only thing that requests reflow. - `ReflowComplete` to `ReflowResult` Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Add embedder event for preferred color scheme and respond to it in the ↵arthmis2024-12-121-20/+31
| | | | | | | | | | | | | | | | | | | | | | | | LayoutThread (#34532) * respond to winit platform theme changed event and send it to the layout thread Signed-off-by: Lloyd Massiah <artmis9@protonmail.com> * refactoring viewport and theme change handling functions based on feedback Signed-off-by: Lloyd Massiah <artmis9@protonmail.com> * fixing issues reported by test-tidy Signed-off-by: Lloyd Massiah <artmis9@protonmail.com> * update stylo in order to use color_scheme function on Device Signed-off-by: Lloyd Massiah <artmis9@protonmail.com> --------- Signed-off-by: Lloyd Massiah <artmis9@protonmail.com> Co-authored-by: lazypassion <25536767+lazypassion@users.noreply.github.com>
* script: Remove 'pending reflow' concept and some explicit reflows (#34558)Martin Robinson2024-12-111-14/+1
| | | | | | | | | | | | | | | | | | The `pending reflow` concept isn't necessary now that *update the rendering* is taking care of triggering reflows at the correct time. `Window::reflow` already avoids reflows if the page is not dirty, so pending reflows is now just an extraneous check as long as *update the rendering* runs properly. This change also removes some explicit reflows, which now wait until the appropriate moment during *update the rendering*. This should remove some extra reflows that are not necessary. Servo needs some way to track that resizing the web view needs to re-layout due to the initial containing block changing. Move handling of `Document::needs_paint` to the script thread and use this, expanding the rustdoc to explain what it is for a bit more clearly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Move stylo thread pool mutex to servo layout thread crates (#34480)Nico Burns2024-12-051-2/+10
| | | | | | | | | | | | | | | | | * Eliminate stylo thread pool mutex Signed-off-by: Nico Burns <nico@nicoburns.com> * Reinstate Mutex in the Servo codebase Signed-off-by: Nico Burns <nico@nicoburns.com> * Revert back to main Stylo branch Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* Make Servo compatible with Stylo with `prefers-color-scheme` support (#34423)Nico Burns2024-11-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * Make Servo compatible with Stylo with prefer-color-scheme support Signed-off-by: Nico Burns <nico@nicoburns.com> Update imports to work with deduped version of stylo PR Signed-off-by: Nico Burns <nico@nicoburns.com> Switch back to stylo main branch Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix unit tests Signed-off-by: Nico Burns <nico@nicoburns.com> * Update text expectations Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* Use `webrender_api::units::DevicePixel` rather than ↵Nico Burns2024-11-251-5/+6
| | | | | | | | | | | | | | | `style_traits::DevicePixel` unless interfacing with Stylo (#34353) * Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix OpenHarmony build Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* Set all tracing spans to trace level for now (#34256)Delan Azabani2024-11-191-20/+15
| | | | | | | | | | | | | * Clean up tracing instrumentation Signed-off-by: Delan Azabani <dazabani@igalia.com> * Set all tracing spans to trace level for now Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Plumb time profiler output into tracing (#34238)Delan Azabani2024-11-151-3/+3
| | | | | | | | | | | | | | | | | * Plumb time profiler output into tracing Signed-off-by: Delan Azabani <dazabani@igalia.com> * Enter the span tightly around the callback Signed-off-by: Delan Azabani <dazabani@igalia.com> * Use `info_span!()` shorthand Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Gate all use of `tracing` behind Cargo feature (#33845)Delan Azabani2024-10-162-16/+63
| | | Signed-off-by: Delan Azabani <dazabani@igalia.com>
* compositor: Create a single cross-process compositor API (#33619) (#33660)Martin Robinson2024-10-091-13/+13
| | | | | | | | | | | | | | | | | | | | | | Instead of exposing many different kinds of messages to the compositor that are routed through the constellation, expose a single message type which can be sent across IPC channels. In addition, this IPC channel and the route to the crossbeam channel with the compositor is created along with the `CompositorProxy`, simplifying what needs to be passed around during pipeline initialization. Previously, some image updates (from video) were sent over IPC with a special serialization routine and some were sent via crossbeam channels (canvas). Now all updates go over the IPC channel `IpcSharedMemory` is used to avoid serialization penalties. This should improve performance and reduce copies for video, but add a memory copy overhead for canvas. This will improve in the future when canvas renders directly into a texture. All-in-all this is a simplification which opens the path toward having a standard compositor API and reduces the number of duplicate messages and proxying that had to happen in libservo. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* tools: Improve instrumentation and add it for some layout (#33647)Martin Robinson2024-10-051-14/+14
| | | | | | | Improves the instrumentation to skip all function arguments and also add spans for some layout modes. This is preparation for improving the performance of flexbox. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* clippy: Fix too_many_arguments warnings (#33648)tanishka2024-10-041-0/+2
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* clippy: Fix `too_many_arguments` in `components/layout_thread_2020` (#33646)Adavize Promise2024-10-041-0/+2
| | | | | | | | | | | | | * clippy: Fix too many arguments in components/layout_thread_2020/lib.rs Signed-off-by: PS Adavize <siyakapromise@gmail.com> * clippy: Fix- re-add space between methods Signed-off-by: PS Adavize <siyakapromise@gmail.com> --------- Signed-off-by: PS Adavize <siyakapromise@gmail.com>
* Revert "compositor: Create a single cross-process compositor API (#33619)" ↵Martin Robinson2024-10-041-13/+13
| | | | | | | | | (#33645) This reverts commit f2f5614ad64927aa82aa8937ae14a6086df49d2b. This is causing intermittent crashes: https://github.com/servo/servo/actions/runs/11167043809/job/31044255019 Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* compositor: Create a single cross-process compositor API (#33619)Martin Robinson2024-10-031-13/+13
| | | | | | | | | | | | | | | | | | | | | | Instead of exposing many different kinds of messages to the compositor that are routed through the constellation, expose a single message type which can be sent across IPC channels. In addition, this IPC channel and the route to the crossbeam channel with the compositor is created along with the `CompositorProxy`, simplifying what needs to be passed around during pipeline initialization. Previously, some image updates (from video) were sent over IPC with a special serialization routine and some were sent via crossbeam channels (canvas). Now all updates go over the IPC channel `IpcSharedMemory` is used to avoid serialization penalties. This should improve performance and reduce copies for video, but add a memory copy overhead for canvas. This will improve in the future when canvas renders directly into a texture. All-in-all this is a simplification which opens the path toward having a standard compositor API and reduces the number of duplicate messages and proxying that had to happen in libservo. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* fonts: Simplify `FontContext` in two ways that affect the unit test (#33541)Martin Robinson2024-09-251-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+6
| | | | | | | | | | | | | | | | | | | | | 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>
* Layout: Implement innerText/outerText (#33312)Ben2024-09-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement outerText on HtmlElement Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fixed some innerText/outerText bugs Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> * Unified innerText/outerText handling outside of Layout Before these 2 were treated separately and only within Layout would they end up calling the same method, now they are already unified within HTMLElement Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> * Address a few nits Signed-off-by: Martin Robinson <mrobinson@igalia.com> * Added innerText support for `inline-flex` Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> --------- Signed-off-by: Shane Handley <shanehandley@fastmail.com> Signed-off-by: Benjamin Vincent Schulenburg <bennyschulenburg@gmx.de> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Shane Handley <shanehandley@fastmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Add `rust-version` to all `Cargo.toml` files (#33483)Martin Robinson2024-09-171-0/+1
| | | | | | | This is another step preparing for building Servo without `mach`. Fixes #33430. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Trace more functions by adding perfetto tracing events (#33417)atbrakhi2024-09-132-0/+18
| | | Signed-off-by: atbrakhi <atbrakhi@igalia.com>
* script: Create a `CrossProcessInstant` to enable serializable monotonic time ↵Martin Robinson2024-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#33282) Up until now, Servo was using a very old version of time to get a cross-process monotonic timestamp (using `time::precise_time_ns()`). This change replaces the usage of old time with a new serializable monotonic time called `CrossProcessInstant` and uses it where `u64` timestamps were stored before. The standard library doesn't provide this functionality because it isn't something you can do reliably on all platforms. The idea is that we do our best and then fall back gracefully. This is a big change, because Servo was using `u64` timestamps all over the place some as raw values taken from `time::precise_time_ns()` and some as relative offsets from the "navigation start," which is a concept similar to DOM's `timeOrigin` (but not exactly the same). It's very difficult to fix this situation without fixing it everywhere as the `Instant` concept is supposed to be opaque. The good thing is that this change clears up all ambiguity when passing times as a `time::Duration` is unit agnostic and a `CrossProcessInstant` represents an absolute moment in time. The `time` version of `Duration` is used because it can both be negative and is also serializable. Good things: - No need too pass around `time` and `time_precise` any longer. `CrossProcessInstant` is also precise and monotonic. - The distinction between a time that is unset or at `0` (at some kind of timer epoch) is now gone. There still a lot of work to do to clean up timing, but this is the first step. In general, I've tried to preserve existing behavior, even when not spec compliant, as much as possible. I plan to submit followup PRs fixing some of the issues I've noticed. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Replace lazy_static crate with `std::sync::LazyLock` in layout and config ↵Hayashi Mikihiro2024-08-152-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#33065) * replace in layout_thread_2020 Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in layout_thread Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in layout Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in config Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in config_plugins The macro of config_plugins require Send trait bounds Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> --------- Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
* fonts: Add support for generic font families and font size configuration ↵Martin Robinson2024-07-081-2/+23
| | | | | | | | | | | | | | | | | | (#32673) This adds support for generic font families in Servo and allows for configuration of them as well as their default font sizes. One interesting fix here is that now monospace default to 13px, like it does in other browsers. In addition to that, this exposes a new interface in Stylo which allows setting a default style. This is quite useful for fonts, but also for other kinds of default style settings -- like text zoom. Fixes #8371. Fixes #14773. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* script: Implement the `FontFaceSet` DOM API (#32576)Mukilan Thiyagarajan2024-06-261-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a skeleton implementation of FontFaceSet interface with support for resolving the `document.fonts.ready` Promise when the loading of web fonts is completed. This change exposes new failures in the web platform tests. These were ERROR before the change because `document.fonts.ready` caused a `ReferenceError` causing the tests to be aborted and they now FAIL: - /css/CSS2/linebox/vertical-align-top-bottom-001.html - /css/css-flexbox/flex-one-sets-flex-basis-to-zero-px.html - /css/css-fonts/generic-family-keywords-001.html - /css/css-fonts/math-script-level-and-math-style/math-script-level-004.tentative.html - /css/css-fonts/math-script-level-and-math-style/math-script-level-002.tentative.html - /css/css-text/text-autospace/text-autospace-ligature-001.html - /css/css-values/calc-size/calc-size-width.tentative.html These were TIMEOUT before the change because `document.fonts.ready` was a ReferenceError and the tests were asynchronous (reftest-wait). These now FAIL because the assertions are now executed after fonts are loaded: - /css/css-fonts/matching/fixed-stretch-style-over-weight.html - /css/css-fonts/matching/range-descriptor-reversed.html - /css/css-fonts/matching/stretch-distance-over-weight-distance.html - /css/css-fonts/matching/style-ranges-over-weight-direction.html - /css/css-fonts/variations/variable-box-font.html - /css/css-fonts/variations/variable-gpos-m2b.html - /css/css-fonts/variations/variable-gsub.html - /css/css-fonts/variations/variable-opsz-size-adjust.html - /css/css-position/sticky/position-sticky-change-top.html - /css/css-position/sticky/position-sticky-fixed-ancestor.html - /css/css-position/sticky/position-sticky-flexbox.html - /css/css-position/sticky/position-sticky-grid.html - /css/css-position/sticky/position-sticky-inline.html - /css/css-position/sticky/position-sticky-rendering.html - /css/css-position/sticky/position-sticky-stacking-context.html - /css/css-position/sticky/position-sticky-table-td-left.html - /css/css-position/sticky/position-sticky-table-td-right.html - /css/css-position/sticky/position-sticky-table-tfoot-bottom.html - /css/css-position/sticky/position-sticky-table-th-right.html - /css/css-position/sticky/position-sticky-table-thead-top.html - /css/css-position/sticky/position-sticky-table-tr-bottom.html - /css/css-position/sticky/position-sticky-table-tr-top.html - /css/css-position/sticky/position-sticky-writing-modes.html - /css/css-pseudo/marker-intrinsic-contribution-001.html - /css/css-text/hyphens/hyphens-character.html These tests now PASS due to this patch: * FAIL -> PASS - /html/canvas/element/text/2d.text.draw.fill.maxWidth.fontface.html - /html/canvas/element/text/2d.text.measure.width.empty.html * TIMEOUT -> PASS - /css/css-fonts/variations/font-descriptor-range-reversed.html - /css/css-fonts/variations/variable-opsz.html - /css/css-position/sticky/position-sticky-table-th-left.html * ERROR -> PASS - /css/css-fonts/generic-family-keywords-002.html - /css/css-fonts/generic-family-keywords-003.html * These two tests only PASS in Layout 2020: - /css/CSS2/positioning/inline-static-position-001.html - /css/cssom-view/getBoundingClientRect-empty-inline.html These two tests have subtests that PASS intermittenttly: - /fetch/metadata/generated/css-font-face.sub.tentative.html - /css/css-fonts/generic-family-keywords-001.html These tests are new TIMEOUTS that used to FAIL because `documents.fonts.ready` was undefined: - /resource-timing/TAO-match.html - /resource-timing/content-type.html - /resource-timing/nextHopProtocol-is-tao-protected.https.html The failure in `/resize-observer/change-layout-in-error.html` could be due to an issue in the ResizeObserver implementation that is now exposed with this change, but this needs more investigation. Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Clean up some unused dependencies (#32600)Oriol Brufau2024-06-251-1/+0
|
* Rename `gfx` to `fonts` (#32556)Martin Robinson2024-06-192-5/+4
| | | | | | | | | 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 WebRender web fonts when they are no longer used (#32545)Martin Robinson2024-06-181-0/+16
| | | | | | | | | | | This is the first part of cleaning up unused WebRender resources. Currently this only cleans up web font resources, but a more full-featured implementation in the future could also clean up unused system fonts. Fixes #32345. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>