aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/script_layout/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* script: Include layout when collecting memory reports (#32204)Mukilan Thiyagarajan2024-05-011-2/+2
| | | Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* script_layout: Remove script to layout messages (#32081)Martin Robinson2024-04-221-8/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of communicating with layout via messages, script can simply call methods on the layout trait. This simplifies the way that script communicates with layout and opens the path to sharing more data structures between the two systems. This is part of a continuing series of cleanups after removing the layout thread. <!-- 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. -->
* clippy: Fix needless_lifetimes warning (#32049)Oluwatobi Sofela2024-04-111-1/+1
|
* chore: Clean up use of `gfx` and `constellation` types (#31981)Martin Robinson2024-04-091-2/+1
| | | | | | | | | | | | This change contains three semi-related clean ups: 1. the `to_webrender()` and `from_webrender()` functions on Pipeline are turned into more-idiomatic `From` and `Into` implementations. 2. `combine_id_with_fragment_type` now returns a `u64` as that is what is expected for all callers and not a `usize`. 3. The `query_scroll_id` query is removed entirely. The `ExternalScrollId` that this queries is easily generated directly from the node's opaque id. Querying into layout isn't necessary at all.
* layout: Add a `FontMetricsProvider` for resolving font-relative units (#31966)Martin Robinson2024-04-041-0/+5
| | | | | | | | | | | | | | | | | | | 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.
* script: Split style and layout data in DOM nodes (#31985)Martin Robinson2024-04-041-27/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change splits the style and layout data in DOM nodes that is populated by style and layout passes. This makes Servo's data design more like Gecko's. This allows: 1. Removing the various `StyleAndLayout` data structures used by layout. 2. Removing the `GetStyleAndLayoutData` and `GetStyleAndOpaqueLayoutData` traits. Accessing style and layout data are now just functions on the `LayoutNode` and `ThreadSafeLayoutNode` traits. 3. Styling now doesn't populate layout data. This is is postponed until layout itself. 4. Allows the DOM wrappers to no longer have to be generic over the layout data. This data was already stored using `std::any::Any` and the new code just makes layout responsible for downcasting. Cleaning up the generic type parameter in the DOM wrappers can happen in a followup change. The main benefit to all of this is that we should be able to remove unsafe creation of `ServoLayoutNode` in layout and `TrustedLayoutNodeAddress` entirely, because `ServoLayoutNode` will be able to be passed directly from script to layout. In addition, this removes one more abstraction layer from the layout DOM wrappers, making the code a lot more understandable. Note: This increases the measured size of DOM types, but the same data is stored. It's simply that before that data was stored behind a heap pointer.
* layout: Remove LayoutRPC and query layout via the `Layout` trait (#31937)Martin Robinson2024-03-291-8/+50
| | | | | | | | | | | | | | | | | Instead of the tricky `LayoutRPC` interface, query layout using the `Layout` trait. This means that now queries will requires calling layout and then running the query. During layout an enum is used to indicate what kind of layout is necessary. This change also removes the mutex-locked `rw_data` from both layout threads. It's no longer necessary since layout runs synchronously. The one downside here is that for resolved style queries, we now have to create two StyleContexts. One for layout and one for the query itself. The creation of this context should not be very expensive though. `LayoutRPC` used to be necessary because layout used to run asynchronously from script, but that no longer happens. With this change, it becomes possible to safely pass nodes to layout from script -- a cleanup that can happen in a followup change.
* fonts: Add support for WOFF2 and properly load web fonts from @imports (#31879)Martin Robinson2024-03-261-0/+18
| | | | | | | | | | | | This change also makes two fixes that are necessary to get WOFF2 fonts working: 1. It adds support for loading web fonts from stylesheets included via @import rules. 2. It ensure that when web fonts are loaded synchronusly they invalidate the font cache. This led to incorrect font rendering when running tests before. Fixes #31598.
* Updated comment with 'layout_traits' to 'script_layout_interface' (#31707)Tumuhairwe2024-03-151-3/+3
| | | | | | | | | | | * Updated comment with 'layout_traits' to 'script_layout_interface' * Rewrap text * Remove trailing whitespace --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* clippy: Fix warnings in `components/shared` (#31627)eri2024-03-121-12/+4
| | | | | | | * clippy: fix warnings in `components/shared` * fix: formatting derive * fix: rename new to default
* script: Do not run layout in a thread (#31346)Martin Robinson2024-02-231-2/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Do not run layout in a thread Instead of spawning a thread for layout that almost always runs synchronously with script, simply run layout in the script thread. This is a resurrection of #28708, taking just the bits that remove the layout thread. It's a complex change and thus is just a first step toward cleaning up the interface between script and layout. Messages are still passed from script to layout via a `process()` method and script proxies some messages to layout from other threads as well. Big changes: 1. Layout is created in the script thread on Document load, thus every live document is guaranteed to have a layout. This isn't completely hidden in the interface, but we can safely `unwrap()` on a Document's layout. 2. Layout configuration is abstracted away into a LayoutConfig struct and the LayoutFactory is a struct passed around by the Constellation. This is to avoid having to monomorphize the entire script thread for each layout. 3. Instead of having the Constellation block on the layout thread to figure out the current epoch and whether there are pending web fonts loading, updates are sent synchronously to the Constellation when rendering to a screenshot. This practically only used by the WPT. A couple tests start to fail, which is probably inevitable since removing the layout thread has introduced timing changes in "exit after load" and screenshot behavior. Co-authored-by: Josh Matthews <josh@joshmatthews.net> * Update test expectations * Fix some issues found during review * Clarify some comments * Address review comments --------- Co-authored-by: Josh Matthews <josh@joshmatthews.net>
* Move `*_traits` and other shared types to `shared`Martin Robinson2023-11-031-0/+164
This is the start of the organization of types that are in their own crates in order to break dependency cycles between other crates. The idea here is that putting these packages into their own directory is the first step toward cleaning them up. They have grown organically and it is difficult to explain to new folks where to put new shared types. Many of these crates contain more than traits or don't contain traits at all. Notably, `script_traits` isn't touched because it is vendored from Gecko. Eventually this will move to `third_party`.