Skip to content

feat(css): expose preferred text scale in the Servo environment - #1

Closed
lanyue-llk wants to merge 4 commits into
ldm0:wpt/property-rule-escaped-namesfrom
lanyue-llk:codex/preferred-text-scale
Closed

lanyue-llk wants to merge 4 commits into
ldm0:wpt/property-rule-escaped-namesfrom
lanyue-llk:codex/preferred-text-scale

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Sep 21, 2026 •

Copy link
Copy Markdown

Expose env(preferred-text-scale) as a numeric CSS environment value on Servo devices, defaulting to 1. Embedders can update the preference through Device::set_preferred_text_scale; CSS that does not reference the variable keeps its original size. Gecko is unchanged.

This extends the exact revision currently pinned by Moli (wpt/property-rule-escaped-names); it does not pull in unrelated Stylo changes. The embedder remains responsible for invalidating computed styles when the preference changes.

Validated with rustfmt, a standalone Stylo device/environment test for default and updated values, unknown names, and invalid input, plus a public-CDP Moli test that checks 1.5 → 2 → reset, computed font size and width, unaffected fixed font sizes, and preservation across media preference changes. Chromium 151 was used as the behavioral reference.

Dependency provenance: Moli PR #640 pins all seven Stylo-family Git dependencies to ldm0/stylo@671d13d31b3b00e7b1e0088ba2b36a4e35c0858c; that is the head of this PR’s target branch wpt/property-rule-escaped-names. The repository is an active fork of servo/stylo, not an unused substitute. Default branch main is not the revision Moli currently consumes.

Moli PR #731 calls Device::set_preferred_text_scale from its style environment update. While this PR is open, Moli pins the contributor fork lanyue-llk/stylo at immutable commit 402a73dba5624bbfb0a16639f03bd48db63af1b0. After this change is integrated into the consumed branch, the dependency can return to ldm0/stylo using the actual resulting commit and updated lockfile; this PR does not switch Moli to Stylo main.

Review illustrations and evidence

完整验证报告:逐项根因、Chromium 对照与原始证据

以下为 ImageGen 生成的机制示意图;执行结果与原始证据见报告。

文字缩放:环境值、样式失效与重新计算

Moli 将缩放偏好传入 Stylo Device 并触发样式重算;Stylo 提供 env(preferred-text-scale)。只有引用该环境值的 CSS 参与缩放,普通固定字号保持原值。

文字缩放:环境值、样式失效与重新计算

图中 Moli 的环境更新与样式失效由 Moli #731 实现;本 PR 仅负责 Stylo Device 的环境值及默认值。

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

已核对 PR 目标、Stylo 现有 env() 路径、Servo Device setter 约定及 CSSWG 的 preferred-text-scale 定义。改动范围小且分层合理;下面两处分别涉及公开 API 的输入契约和本仓库的回归保护。

Comment thread style/device/servo.rs
Comment thread style/custom_properties.rs
@lanyue-llk
lanyue-llk force-pushed the codex/preferred-text-scale branch from 402a73d to 3d44ed3 Compare September 24, 2026 10:49
@lanyue-llk

Copy link
Copy Markdown
Author

该 PR 的目标分支不是 Moli 实际消费的 Stylo 基线。文字缩放提交已真正 rebase 到 lexmount/stylo:moli@3c8bbb450a52f9a4dcb2de51061216a1d2727def,由 lexmount#1 取代;Moli #731 也已固定到新的不可变提交。

@lanyue-llk lanyue-llk closed this Sep 24, 2026
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