Skip to content

Crate split phase 2: extract stylo_common (parser context, shared lock, error reporting, atoms, gecko bindings) - #7

Draft
nicoburns wants to merge 3 commits into
devin/1785852309-crate-splitfrom
devin/1785852309-crate-split-2
Draft

Crate split phase 2: extract stylo_common (parser context, shared lock, error reporting, atoms, gecko bindings)#7
nicoburns wants to merge 3 commits into
devin/1785852309-crate-splitfrom
devin/1785852309-crate-split-2

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Summary

Second layer of the crate split (stacked on #6). Adds a new stylo_common crate (lib name style_common) sitting between stylo_traits and style, holding the implementation-support code that can't live in stylo_traits because it depends on gecko bindings or engine support types:

stylo_common
├── parser.rs          (ParserContext, Parse trait — was style/parser.rs)
├── error_reporting.rs
├── shared_lock.rs
├── thread_state.rs
├── use_counters.rs
├── url_extra_data.rs  (UrlExtraData, extracted from style/stylesheets/mod.rs)
├── namespaces.rs      (Namespaces, extracted from stylesheet.rs)
├── attr_taint.rs      (AttrTaint/AttrTaintedRange, extracted from custom_properties.rs)
├── atom_types.rs      (Atom/Namespace/Prefix/LocalName aliases, AtomIdent/AtomString/GenericAtomIdent, extracted from values/mod.rs and lib.rs)
├── gecko_bindings/    (moved wholesale, incl. build_gecko.rs; gecko-only)
└── gecko_string_cache/

The style crate re-exports everything at the old paths (style::parser, style::error_reporting, style::shared_lock, style::Atom, ...), so the public API is unchanged.

Decoupling changes needed to make the layer acyclic:

  • error_reporting no longer references the engine's concrete SelectorImpl: the selector-warning visitors are now generic over selectors::parser::SelectorImpl, and ContextualParseError::UnsupportedPropertyDeclaration stores precomputed Vec<SelectorWarningKind> (via new SelectorWarningKind::from_selector_lists) instead of &[SelectorList<SelectorImpl>].
  • parser.rs uses selectors::matching::QuirksMode directly instead of the crate::context re-export.
  • Since Parse is now a foreign trait to style, impl Parse for InitialValue (= Arc<SpecifiedValue>) hit the orphan rule; replaced with a generic impl<T: Parse> Parse for servo_arc::Arc<T> in stylo_common plus impl Parse for SpecifiedValue in style.
  • Stripped ToComputedValue/ToResolvedValue/SpecifiedValueInfo derives from the moved atom types (their traits live above); replaced with trivial_to_computed_value!/trivial_to_resolved_value! in style and manual SpecifiedValueInfo impls.

Verified with cargo check --workspace and cargo test --workspace --exclude stylo (the stylo test target fails on main for a preexisting pseudo-element issue). Gecko-feature code was moved cfg-intact but can't be compile-verified outside mozilla-central.

Link to Devin session: https://app.devin.ai/sessions/5d2d6be20e724623bdc1bcf7e1687af1
Requested by: @nicoburns

@nicoburns nicoburns self-assigned this Aug 4, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant