Skip to content

fix(css): report extraFields in getComputedStyleForNode - #2805

Merged
ldm0 merged 1 commit into
mainfrom
fix/computed-style-extra-fields
Nov 12, 2026
Merged

ldm0 merged 1 commit into
mainfrom
fix/computed-style-extra-fields

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR #2805 at a glance

Closes #2783. Replaces part of #731.

Problem

CSS.getComputedStyleForNode returned only computedStyle. Chromium also returns extraFields: {"isAppearanceBase": false}, and typed CDP clients that treat it as required (e.g. Rust chromiumoxide_cdp GetComputedStyleForNodeReturns) reject moli's response. Repro: DOM.getDocument, DOM.querySelector body, CSS.getComputedStyleForNode {nodeId}.

Change

moli-protocol/src/domains/css.rs (computed_style_result): add extraFields: {isAppearanceBase: false}. moli does not implement appearance: base, so false is the correct value for every element. The existing css_loaded_page_methods_target_background_owner_without_activation test now asserts the field.

Verification

Before: debug build of origin/main f935014; after: debug build of this branch.

# before
keys: ['computedStyle'] extraFields: None
# after
keys: ['computedStyle', 'extraFields'] extraFields: {'isAppearanceBase': False}
  • cargo fmt --all: clean.
  • cargo clippy -p moli-protocol --all-targets --all-features -- -D warnings: passed.
  • cargo nextest run -p moli-protocol -E 'test(css)': 36 passed.
  • Not run locally: workspace-wide clippy and the full workspace nextest; left to CI.

Cost

Debug builds, /usr/bin/time -l, median of 5 runs (repro: two interleaved rounds):

main this PR
issue repro over CDP (moli serve) 1.195 / 1.193 s, 108.1 MB max RSS 1.196 / 1.200 s, 108.6 MB
ordinary page, moli fetch of a local 46 KB article 0.100 s, 88.8 MB 0.080 s, 89.2 MB

One constant JSON field per getComputedStyleForNode response; no other path is touched.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review of af43174

No blocking findings

  • Correctness: computed_style_result (moli-protocol/src/domains/css.rs:526-534) is the single builder for both the legacy path (css.rs:489) and the native path (css/native.rs:169), so every successful getComputedStyleForNode response now carries extraFields. Shape matches the CDP protocol JSON: extraFields: $ref ComputedStyleExtraFields (not optional), with the single required boolean isAppearanceBase. The not-found error path is unchanged. No other CSS command is touched.
  • Value: hard-coded false is correct for moli today. moli does not implement appearance: base/base-select. With v1.1.23 and select,::picker(select){appearance:base-select}, getComputedStyle(select).appearance is auto, CSS.supports("appearance","base-select") and CSS.supports("appearance","base") are both false, and the ::picker(select) computed appearance is none. moli recognizes the ::picker(select) pseudo-element only for getComputedStyle; it does not render base appearance. So no element can be rendered with base appearance, and false agrees with moli's own computed style. If moli later adds appearance: base-select, this constant has to be derived from the computed style at that point.
  • Test: the assertion added at css.rs:979-982 fails on main, where the field is absent, and passes here. It locks in only Chromium's shape and value for a non-base element.
  • Cost: one constant field per response. The numbers in the body are within noise and plausible.
  • CI: Clippy, Format, Python, Node and Windows checks pass. Nextest, CDP smoke and Build release were still pending when I reviewed.
  • Picture: pending.

@ldm0
ldm0 merged commit f98df6c into main Nov 12, 2026
12 of 21 checks passed
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.

CSS.getComputedStyleForNode omits extraFields, so typed CDP clients reject the response

2 participants