Crate split phase 3c: untangle StyleBuilder's Stylist and Device upward references - #11
Draft
nicoburns wants to merge 1 commit into
Draft
Conversation
- StyleBuilder.stylist is now Option<&dyn CustomPropertyRegistry>, a narrow trait defined next to computed::Context; Stylist implements it. Cascade code that needs the concrete Stylist uses Cascade's own field. - The custom-property substitution machinery takes the registry trait, resolving env() through the computed context's device. - Device no longer names GeckoElement: calc_line_height and ResolvedElementInfo take the raw bindings Element reference. - The gecko system_font module is generated in the types half (properties::system_font), re-exported from properties::gecko.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes three of the upward references that block extracting the generated "types half" (style structs /
ComputedValues/StyleBuilder, see #10) into a futurestylo_valuescrate:1.
StyleBuilder.stylistno longer namesStylist. All the value-computation layer ever does with it is look up registered custom properties, so:Stylistimplements the trait; the custom-property substitution chain (custom_properties::substitute*,UnparsedValue::substitute_variables, container-query custom-property comparisons) now takes&dyn CustomPropertyRegistry, resolvingenv()through the computed context's device instead ofstylist.device(). The two cascade sites that need the concreteStylist(cascade_rulesfor visited styles, variable substitution) useCascade's ownstylistfield instead of going through the builder.Context::new_for_initial_at_property_valuetakes(device, registry, quirks_mode)instead of&Stylist.2.
Deviceno longer namesGeckoElement(the DOM-layer wrapper):Device::calc_line_heightandResolvedElementInfo.elementtake the rawgecko_bindings::structs::Elementreference (which lives at the bottom of the graph); the wrapper was only ever unwrapped to that pointer for FFI.style/device/now has zero references to upper layers (stylist, rule tree, stylesheets, DOM wrappers), so it can move down with the types half.3. The gecko
system_fontmodule is generated in the types half (properties::system_font, extracted fromgecko.mako.rsintosystem_font.mako.rs), with a compat re-export atproperties::gecko::system_font. This makesContext.cached_system_font's type live below the property machinery.Remaining knots for extraction (next phase):
ComputedValues.rules: Option<StrongRuleNode>(rule tree depends onPropertyDeclarationBlock) andPseudoElementplacement.Validated with
cargo check --workspace,cargo test --workspace --exclude stylo(the stylo test target has a pre-existing failure on main), and gecko template rendering.Link to Devin session: https://app.devin.ai/sessions/5d2d6be20e724623bdc1bcf7e1687af1
Requested by: @nicoburns