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

api: Flatten and simplify Servo preferences #34966

Merged
merged 1 commit into from
Jan 14, 2025
Merged

Conversation

mrobinson
Copy link
Member

@mrobinson mrobinson commented Jan 13, 2025

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.

This is an implementation of the changes that were discussed on Zulip.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes are covered by existing tests.

@mrobinson mrobinson added the T-linux-wpt-2020 Do a try run of the WPT label Jan 13, 2025
@github-actions github-actions bot removed the T-linux-wpt-2020 Do a try run of the WPT label Jan 13, 2025
Copy link

🔨 Triggering try run (#12749142047) for Linux WPT

@mrobinson
Copy link
Member Author

First off, apologies for the size of this change. The preferences are marbled through all of servo from servoshell down to the most basic crates. This change is hopefully the first step toward improving that.

Copy link

Test results for linux-wpt-layout-2020 from try job (#12749142047):

Flaky unexpected result (17)
  • TIMEOUT [expected OK] /_mozilla/mozilla/cache_crossorigin_response.sub.html
    • TIMEOUT [expected PASS] subtest: Cached cross-origin response doesn't hang

      Test timed out
      

  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • PASS [expected FAIL] /css/compositing/mix-blend-mode/mix-blend-mode-video-sibling.html (#32849)
  • TIMEOUT [expected OK] /custom-elements/reactions/customized-builtins/HTMLMediaElement.html (#31014)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Cross-site
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-nosrc.html (#34819)
    • PASS [expected FAIL] subtest: link click
    • PASS [expected FAIL] subtest: form submission
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-aboutblank-navigate-immediately.html (#29048)
    • FAIL [expected PASS] subtest: Navigating to a different document with location.href

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?1" but got "about:blank"
      

    • TIMEOUT [expected FAIL] subtest: Navigating to a different document with link click

      Test timed out
      

    • NOTRUN [expected FAIL] subtest: Navigating to a different document with form submission
  • FAIL [expected PASS] /html/canvas/element/manual/text/canvas.2d.disconnected.html (#30063)
  • CRASH [expected OK] /html/canvas/offscreen/canvas-host/2d.canvas.host.size.large.html (#34117)
  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • TIMEOUT [expected FAIL] subtest: Host element with delegatesFocus should support autofocus

      Test timed out
      

    • NOTRUN [expected FAIL] subtest: Host element with delegatesFocus including no focusable descendants should be skipped
    • NOTRUN [expected FAIL] subtest: Area element should support autofocus
  • OK /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-window-open.html (#32596)
    • FAIL [expected PASS] subtest: Navigating iframe loading='lazy' before it is loaded: location.replace

      uncaught exception: Error: assert_equals: expected "http://web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/support/blank.htm?nav" but got "http://web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/support/blank.htm?src"
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if allow-popups-to-escape-sandbox is used

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if allow-popups-to-escape-sandbox is used

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • OK /html/semantics/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
    • PASS [expected FAIL] subtest: Verifies that location navigations take precedence when following form submissions.
  • TIMEOUT [expected CRASH] /html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.html (#21444)
  • TIMEOUT [expected OK] /resource-timing/nested-context-navigations-iframe.html (#24311)
    • TIMEOUT [expected PASS] subtest: Test that iframe navigations are not observable by the parent, even after history navigations by the parent

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe navigations are not observable by the parent, even after history navigations by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent, even after history navigations by the parent
    • NOTRUN [expected PASS] subtest: Test that iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe refreshes are not observable by the parent
  • OK /workers/WorkerGlobalScope-close.html (#23064)
    • PASS [expected FAIL] subtest: Test sending a message after closing.
Stable unexpected results that are known to be intermittent (10)
  • FAIL [expected PASS] /css/css-sizing/dynamic-available-size-iframe.html (#31559)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • FAIL [expected PASS] subtest: Same-origin navigation started from unload handler must be ignored

      assert_equals: expected "?pass" but got "?fail"
      

  • CRASH [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html (#24057)
  • TIMEOUT [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html (#24066)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • OK /html/semantics/forms/historical.html (#28568)
    • FAIL [expected PASS] subtest: <input name=isindex> should not be supported

      assert_regexp_match: expected object "/\?isindex=x$/" but got "about:blank"
      

  • OK /navigation-timing/test-navigation-type-reload.html (#33334)
    • PASS [expected FAIL] subtest: Reload domComplete > Original domComplete
    • PASS [expected FAIL] subtest: Reload domContentLoadedEventEnd > Original domContentLoadedEventEnd
    • PASS [expected FAIL] subtest: Reload domContentLoadedEventStart > Original domContentLoadedEventStart
    • PASS [expected FAIL] subtest: Reload domInteractive > Original domInteractive
    • PASS [expected FAIL] subtest: Reload fetchStart > Original fetchStart
    • PASS [expected FAIL] subtest: Reload loadEventEnd > Original loadEventEnd
    • PASS [expected FAIL] subtest: Reload loadEventStart > Original loadEventStart
  • OK /resize-observer/change-layout-in-error.html (#32629)
    • PASS [expected FAIL] subtest: Changing layout in window error handler should not result in lifecyle loop when resize observer loop limit is reached.
  • OK [expected TIMEOUT] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • PASS [expected TIMEOUT] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe
  • ERROR [expected OK] /workers/constructors/Worker/Worker-constructor.html (#22991)

Copy link

⚠️ Try run (#12749142047) failed.

Copy link
Member Author

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

Here's a quick guide to this PR as it is quite large:

@@ -232,15 +234,22 @@ where
)]
#[allow(clippy::new_ret_no_self)]
pub fn new(
Copy link
Member Author

Choose a reason for hiding this comment

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

This is one of the big things to look at in this change. Here we are passing Opts and Preferences into the Servo instance instead of setting them globally from the embedder.

Comment on lines +44 to +50
// TODO: Map more preferences onto their Servo values.
Ok(match key {
"dom.serviceWorkers.enabled" => {
self.write_bool(pref!(dom_serviceworker_enabled), stream)
},
_ => self.handle_missing_preference(msg_type, stream),
})
Copy link
Member Author

Choose a reason for hiding this comment

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

I have had to rework this code a little. In practice the only setting devtools is reading now is the service worker setting, so this is the setting that is preserved here. Otherwise I've tidied up the rest of this code to increase code reuse when more settings are supported.

@@ -0,0 +1,55 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Member Author

@mrobinson mrobinson Jan 13, 2025

Choose a reason for hiding this comment

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

This is the new derive macro that we use to generate setters and getters. It's considerably simpler than the one that was previously found in config_plugins.

@@ -1,333 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Member Author

Choose a reason for hiding this comment

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

This testing code has mainly moved to servoshell as that is what handles setting preferences via JSON now.

},
PrefValue::Bool(value) => Ok(Self::Bool(value)),
_ => Err(TryFromPrefValueError::UnmappedType),
impl Preferences {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the new way that preferences are set by default. I've taking these values from resources/prefs.json. In some cases (like for layout_threads) a default was defined in Servo but overridden by the resource file. I've used the one from the JSON in those cases.

Comment on lines +1783 to +1797
// If we only want to reset some of the preferences.
let mut new_preferences = prefs::get().clone();
let default_preferences = Preferences::default();
for key in parameters.prefs.iter() {
new_preferences.set_value(key, default_preferences.get_value(key))
}

let map = parameters
Copy link
Member Author

@mrobinson mrobinson Jan 13, 2025

Choose a reason for hiding this comment

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

This has been changed because now preferences are all set at once.

Comment on lines +45 to +47
opts: Opts,
preferences: Preferences,
servo_shell_preferences: ServoShellPreferences,
Copy link
Member Author

Choose a reason for hiding this comment

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

These are the three kinds of preferences that servoshell has now. My goal is to get this down to one in a followup by merging Opts into Preferences and then making Preferences a member of ServoShellPreferences.


pub fn main() {
crate::crash_handler::install();
crate::init_tracing();
crate::init_crypto();
crate::resources::init();

// Parse the command line options and store them globally
Copy link
Member Author

Choose a reason for hiding this comment

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

All command-line argument parsing is now consolidated in servoshell's prefs.rs.

Comment on lines -93 to -96
if pref!(media.glvideo.enabled) {
warn!("GL video rendering is not supported on headless windows.");
set_pref!(media.glvideo.enabled, false);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This has been moved to command-line argument processing as it's servoshell specific.


pub fn register_user_prefs(opts_matches: &Matches) {
// Read user's prefs.json and then parse --pref command line args.
pub(crate) struct ServoShellPreferences {
Copy link
Member Author

Choose a reason for hiding this comment

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

These are the libservo preferences that were specific to servoshell and shouldn't be part of libservo.

Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

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

This is a really useful step forward! Thank you for pushing through it!

@@ -198,10 +204,12 @@ impl App {
CompositeTarget::Window
};
let mut servo = Servo::new(
self.opts.clone(),
self.preferences.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

The embedder's copy of the preferences will be out of date if they're updated at runtime, right? For example, via webdriver. I don't know that we need to solve that, just making sure that my mental model is correct.

Copy link
Contributor

@nicoburns nicoburns left a comment

Choose a reason for hiding this comment

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

@mrobinson Would it make sense to have the pref accessor map . to _ so that the pref strings can stay the same even though the structure is now flat? That would dramatically reduce the diff (and resolve issues with the changed format in stylo too).

@jdm
Copy link
Member

jdm commented Jan 14, 2025

That would only help with the ini and webidl files; the pref! macro would still use underscores. I'm on the fence about whether that would be too confusing.

@nicoburns
Copy link
Contributor

That would only help with the ini and webidl files; the pref! macro would still use underscores. I'm on the fence about whether that would be too confusing.

An underscore-based pref! macro could probably be implemented as a proc-macro if we really wanted to? But I guess maybe not worth it.

Copy link
Member

@wusyong wusyong left a comment

Choose a reason for hiding this comment

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

Really happy to see the change! And I also want to see the merge of Opts and Preference in the future!

@mrobinson mrobinson force-pushed the prefs branch 2 times, most recently from 68bec2d to f719de2 Compare January 14, 2025 09:17
@mrobinson
Copy link
Member Author

mrobinson commented Jan 14, 2025

@Loirooriol suggested keeping the original Stylo preference names, so I've done that. It has required a bit more mapping of preferences in the DOM code generator, but it's probably true that Stylo should not be dependent on Servo's preference names anyway. It would be good to have an even cleaner solution for this that doesn't require mapping in two places, but I think that might require even more code generation -- which I guess we should avoid for now.

@mrobinson
Copy link
Member Author

Here are the new changes:
diff --git a/Cargo.lock b/Cargo.lock
index 6cb72b4c92..68f54d8036 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1600,7 +1600,7 @@ dependencies = [
 [[package]]
 name = "dom"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "bitflags 2.6.0",
  "malloc_size_of",
@@ -4332,7 +4332,7 @@ dependencies = [
 [[package]]
 name = "malloc_size_of"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "app_units",
  "cssparser",
@@ -6312,7 +6312,7 @@ dependencies = [
 [[package]]
 name = "selectors"
 version = "0.26.0"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "bitflags 2.6.0",
  "cssparser",
@@ -6600,7 +6600,7 @@ dependencies = [
 [[package]]
 name = "servo_arc"
 version = "0.4.0"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "serde",
  "stable_deref_trait",
@@ -6609,7 +6609,7 @@ dependencies = [
 [[package]]
 name = "servo_atoms"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "string_cache",
  "string_cache_codegen",
@@ -6977,7 +6977,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
 [[package]]
 name = "static_prefs"
 version = "0.1.0"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 
 [[package]]
 name = "strck"
@@ -7058,7 +7058,7 @@ dependencies = [
 [[package]]
 name = "style"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "app_units",
  "arrayvec",
@@ -7116,7 +7116,7 @@ dependencies = [
 [[package]]
 name = "style_config"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "lazy_static",
 ]
@@ -7124,7 +7124,7 @@ dependencies = [
 [[package]]
 name = "style_derive"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "darling",
  "proc-macro2",
@@ -7154,7 +7154,7 @@ dependencies = [
 [[package]]
 name = "style_traits"
 version = "0.0.1"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "app_units",
  "bitflags 2.6.0",
@@ -7549,7 +7549,7 @@ dependencies = [
 [[package]]
 name = "to_shmem"
 version = "0.1.0"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "cssparser",
  "servo_arc",
@@ -7562,7 +7562,7 @@ dependencies = [
 [[package]]
 name = "to_shmem_derive"
 version = "0.1.0"
-source = "git+https://github.com/servo/stylo?rev=refs%2Fpull%2F108%2Fhead#4bf0c2e744837b66009cd65287744f72ffbb794b"
+source = "git+https://github.com/servo/stylo?branch=2025-01-02#dfed17bd04a713f5dce775176c3a28c39c934970"
 dependencies = [
  "darling",
  "proc-macro2",
diff --git a/Cargo.toml b/Cargo.toml
index 015661d83f..474e25d920 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -110,25 +110,25 @@ rustls-pemfile = "2.0"
 rustls-pki-types = "1.10"
 script_layout_interface = { path = "components/shared/script_layout" }
 script_traits = { path = "components/shared/script" }
-selectors = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head" }
+selectors = { git = "https://github.com/servo/stylo", branch = "2025-01-02" }
 serde = "1.0.217"
 serde_bytes = "0.11"
 serde_json = "1.0"
 servo-media = { git = "https://github.com/servo/media" }
 servo-media-dummy = { git = "https://github.com/servo/media" }
 servo-media-gstreamer = { git = "https://github.com/servo/media" }
-servo_arc = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head", features = ["servo"] }
-servo_atoms = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head" }
+servo_arc = { git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
+servo_atoms = { git = "https://github.com/servo/stylo", branch = "2025-01-02" }
 smallbitvec = "2.5.3"
 smallvec = "1.13"
 static_assertions = "1.1"
 string_cache = "0.8"
 string_cache_codegen = "0.5"
-style = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head", features = ["servo"] }
-style_config = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head" }
-style_dom = { git = "https://github.com/servo/stylo", package = "dom", rev = "refs/pull/108/head" }
-style_traits = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head", features = ["servo"] }
-style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", rev = "refs/pull/108/head", features = ["servo"] }
+style = { git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
+style_config = { git = "https://github.com/servo/stylo", branch = "2025-01-02" }
+style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2025-01-02" }
+style_traits = { git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
+style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
 surfman = { git = "https://github.com/servo/surfman", rev = "300789ddbda45c89e9165c31118bf1c4c07f89f6", features = ["chains"] }
 syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
 synstructure = "0.13"
@@ -137,7 +137,7 @@ thin-vec = "0.2.13"
 tikv-jemalloc-sys = "0.6.0"
 tikv-jemallocator = "0.6.0"
 time_03 = { package = "time", version = "0.3", features = ["large-dates", "local-offset", "serde"] }
-to_shmem = { git = "https://github.com/servo/stylo", rev = "refs/pull/108/head" }
+to_shmem = { git = "https://github.com/servo/stylo", branch = "2025-01-02" }
 tokio = "1"
 tokio-rustls = { version = "0.26", default-features = false, features = ["logging"] }
 tower-service = "0.3"
diff --git a/components/config/prefs.rs b/components/config/prefs.rs
index d22562c483..9c4edf30e3 100644
--- a/components/config/prefs.rs
+++ b/components/config/prefs.rs
@@ -18,23 +18,25 @@ pub fn get() -> RwLockReadGuard<'static, Preferences> {
 }
 
 pub fn set(preferences: Preferences) {
-    // TODO: Remove some preferences here that should always be on, such as the one for
-    // flexbox and the one for transition-behavior.
-    style_config::set_bool("layout_unimplemented", preferences.layout_unimplemented);
-    style_config::set_i32("layout_threads", preferences.layout_threads as i32);
-    style_config::set_bool("layout_flexbox_enabled", preferences.layout_flexbox_enabled);
-    style_config::set_bool("layout_columns_enabled", preferences.layout_columns_enabled);
-    style_config::set_bool("layout_grid_enabled", preferences.layout_grid_enabled);
+    // Map between Stylo preference names and Servo preference names as the This should be
+    // kept in sync with components/script/dom/bindings/codegen/run.py which generates the
+    // DOM CSS style accessors.
+    style_config::set_bool("layout.unimplemented", preferences.layout_unimplemented);
+    style_config::set_i32("layout.threads", preferences.layout_threads as i32);
+    style_config::set_bool("layout.legacy_layout", preferences.layout_legacy_layout);
+    style_config::set_bool("layout.flexbox.enabled", preferences.layout_flexbox_enabled);
+    style_config::set_bool("layout.columns.enabled", preferences.layout_columns_enabled);
+    style_config::set_bool("layout.grid.enabled", preferences.layout_grid_enabled);
     style_config::set_bool(
-        "layout_css_transition_behavior_enabled",
+        "layout.css.transition-behavior.enabled",
         preferences.layout_css_transition_behavior_enabled,
     );
     style_config::set_bool(
-        "layout_writing_mode_enabled",
+        "layout.writing-mode.enabled",
         preferences.layout_writing_mode_enabled,
     );
     style_config::set_bool(
-        "layout_container_queries_enabled",
+        "layout.container-queries.enabled",
         preferences.layout_container_queries_enabled,
     );
 
diff --git a/components/script/dom/bindings/codegen/run.py b/components/script/dom/bindings/codegen/run.py
index 2dee39814b..d60cff896d 100644
--- a/components/script/dom/bindings/codegen/run.py
+++ b/components/script/dom/bindings/codegen/run.py
@@ -89,10 +89,31 @@ def generate(config, name, filename):
 
 
 def add_css_properties_attributes(css_properties_json, parser):
+    def map_preference_name(preference_name: str):
+        """Map between Stylo preference names and Servo preference names as the
+        `css-properties.json` file is generated by Stylo. This should be kept in sync with the
+        preference mapping done in `components/servo_config/prefs.rs`, which handles the runtime version of
+        these preferences."""
+        MAPPING = [
+            ["layout.unimplemented", "layout_unimplemented"],
+            ["layout.threads", "layout_threads"],
+            ["layout.legacy_layout", "layout_legacy_layout"],
+            ["layout.flexbox.enabled", "layout_flexbox_enabled"],
+            ["layout.columns.enabled", "layout_columns_enabled"],
+            ["layout.grid.enabled", "layout_grid_enabled"],
+            ["layout.css.transition-behavior.enabled", "layout_css_transition_behavior_enabled"],
+            ["layout.writing-mode.enabled", "layout_writing_mode_enabled"],
+            ["layout.container-queries.enabled", "layout_container_queries_enabled"],
+        ]
+        for mapping in MAPPING:
+            if mapping[0] == preference_name:
+                return mapping[1]
+        return preference_name
+
     css_properties = json.load(open(css_properties_json, "rb"))
     idl = "partial interface CSSStyleDeclaration {\n%s\n};\n" % "\n".join(
         "  [%sCEReactions, SetterThrows] attribute [LegacyNullToEmptyString] DOMString %s;" % (
-            ('Pref="%s", ' % data["pref"] if data["pref"] else ""),
+            (f'Pref="{map_preference_name(data["pref"])}", ' if data["pref"] else ""),
             attribute_name
         )
         for (kind, properties_list) in sorted(css_properties.items())

@mrobinson mrobinson enabled auto-merge January 14, 2025 09:30
@mrobinson mrobinson added this pull request to the merge queue Jan 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 14, 2025
@mrobinson mrobinson added T-android Do a try run on Android T-ohos Do a try run on OpenHarmony labels Jan 14, 2025
@github-actions github-actions bot removed T-android Do a try run on Android T-ohos Do a try run on OpenHarmony labels Jan 14, 2025
Copy link

🔨 Triggering try run (#12766835791) for Android, OpenHarmony

Copy link

⚠️ Try run (#12766835791) failed.

@mrobinson mrobinson added T-android Do a try run on Android T-ohos Do a try run on OpenHarmony labels Jan 14, 2025
@github-actions github-actions bot removed T-android Do a try run on Android T-ohos Do a try run on OpenHarmony labels Jan 14, 2025
Copy link

🔨 Triggering try run (#12767522303) for Android, OpenHarmony

Copy link

✨ Try run (#12767522303) succeeded.

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 <[email protected]>
@mrobinson mrobinson enabled auto-merge January 14, 2025 13:17
@mrobinson mrobinson added this pull request to the merge queue Jan 14, 2025
Merged via the queue into servo:main with commit 0e616e0 Jan 14, 2025
22 checks passed
@mrobinson mrobinson deleted the prefs branch January 14, 2025 14:31
simonwuelker added a commit to simonwuelker/servo that referenced this pull request Jan 15, 2025
The python code set a preference that was renamed
as part of servo#34966.

This fixes MQ runs which currently all fail
(https://github.com/servo/servo/actions/runs/12779051326/job/35623343302)

Signed-off-by: Simon Wülker <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jan 15, 2025
The python code set a preference that was renamed
as part of #34966.

This fixes MQ runs which currently all fail
(https://github.com/servo/servo/actions/runs/12779051326/job/35623343302)

Signed-off-by: Simon Wülker <[email protected]>
@wusyong wusyong mentioned this pull request Feb 2, 2025
22 tasks
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.

4 participants