Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable will-change property for servo #128

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

yezhizhen
Copy link
Contributor

@yezhizhen yezhizhen commented Mar 1, 2025

Copy link
Contributor

@Loirooriol Loirooriol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but this will need a Servo PR with the implementation before landing.

@yezhizhen yezhizhen force-pushed the enable-will-change branch from ebb7844 to ee822d4 Compare March 2, 2025 10:32
@yezhizhen
Copy link
Contributor Author

I added a function, fn contains_critical_properties. I believe it is needed, to check if certain values are contained in will-change

I am also referring to https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_positioned_layout/Understanding_z-index/Stacking_context to check the list of properties whose non-initial value would create a stacking context.

@yezhizhen
Copy link
Contributor Author

yezhizhen commented Mar 2, 2025

I am almost done. I have one question before Servo PR tho: change_bits_for_longhand for servo simply returns empty WillChangeBits. In that case, STACKING_CONTEXT_UNCONDITIONAL is never enabled in servo, even with filter/backdrop-filter.

#[cfg(feature="servo")]
fn change_bits_for_longhand(_longhand: LonghandId) -> WillChangeBits { WillChangeBits::empty() }
#[cfg(feature = "gecko")]
fn change_bits_for_longhand(longhand: LonghandId) -> WillChangeBits {
match longhand {
LonghandId::Opacity => WillChangeBits::OPACITY,
LonghandId::Contain => WillChangeBits::CONTAIN,
LonghandId::Perspective => WillChangeBits::PERSPECTIVE,
LonghandId::Position => {
WillChangeBits::STACKING_CONTEXT_UNCONDITIONAL | WillChangeBits::POSITION
},

I tried to enable it for servo. But would instead get errors like:

error[E0599]: no variant or associated item named `Contain` found for enum `generated::LonghandId` in the current scope
     --> D:\stylo\style\values\specified\box.rs:1026:21
      |
1026  |         LonghandId::Contain => WillChangeBits::CONTAIN,
      |                     ^^^^^^^ variant or associated item not found in `LonghandId`

Do you think I should enable these? If so, how?

@yezhizhen yezhizhen force-pushed the enable-will-change branch from ee822d4 to 9422fe9 Compare March 2, 2025 14:39
@Loirooriol
Copy link
Contributor

You can enable these properties with engines="gecko servo" and then disable them at runtime with servo_pref="layout.unimplemented".

Or merge both change_bits_for_longhand definitions with a bunch of #[cfg(feature = "gecko")].

Or copy the gecko definition for servo, just removing the properties that are disabled.

Maybe the 1st option is better because otherwise we may forget to update change_bits_for_longhand when we enable them in the future. But no strong opinion.

@yezhizhen
Copy link
Contributor Author

yezhizhen commented Mar 4, 2025

I merged with latest main Stylo branch.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
@yezhizhen yezhizhen force-pushed the enable-will-change branch from ef66cdc to e1b5391 Compare March 5, 2025 02:47
@Loirooriol Loirooriol added this pull request to the merge queue Mar 9, 2025
Merged via the queue into servo:main with commit a93e7ef Mar 9, 2025
3 checks passed
@yezhizhen yezhizhen deleted the enable-will-change branch March 9, 2025 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants