Skip to content

test: resolve an anchor the document names through ::part() in the shift watch - #7365

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-6744-part-anchor
Nov 27, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-6744-part-anchor

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

The shift watch couldn't resolve an anchor that Leaf names from the document through ::part(), so it gave no credit to a margin marker whose carrier lags its heading's scroll by a frame. That missing credit is the (0, -95)px teardown error that test_primary_reading_holds_remote_changes_before_package_layout[Feed] keeps hitting on macOS.

dom/css-anchors.js names a box inside a widget's shadow tree with a document rule, ::part(lf-a3) { anchor-name: --lf-a3 }. That name belongs to the document's tree, but the watch's anchor map keyed every name by the named element's own root, the shadow root. So the margin carrier in the document, with position-anchor: --lf-a3, recorded anchor: null at every reading. With no anchor recorded, scrollMotion never reaches its native_anchor credit. That is why the failing evidence has scroll_terms: []. I found this by instrumenting a failing copy: the carrier's paint read anchor: null, and no light-DOM element carried --lf-a3. The copies that passed did so only when the carrier's catch-up landed inside the click's own input window.

With this change, an anchor name a shadow-tree element takes from a ::part() rule in its host's tree registers in that tree, the one a document ::part() rule reaches. The watch finds those names by matching the host tree's ::part() rules that declare anchor-name against the element's parts and its host; every other name, such as a private anchor the shadow tree's own style gives a box that exposes a part only for styling, stays in the shadow tree. A name that two elements hold in one tree still resolves to none, as before.

Verification

  • test_a_carried_row_keeps_its_anchor_s_lagging_scroll gains part cases, where the row's words sit in a shadow tree named through ::part(). On main, [step--part] and [twice--part] fail every run with the same empty-credit finding. It also gains private cases, where the document's words sit beside a shadow tree whose own style gives a parted box a private --words anchor; [step--private] fails on a watch that registered every parted name in both trees. With the change, all 12 cases pass, and the row fault cases still report the row.
  • Feed under leaf-dev suite flake --workers 4 --load 2 --cpu-throttle 3 on Linux: on main at 43fed2e7e it errored in 11 of 24 copies, then 17 of 24 in a second run. With the first version of the change it passed 54 of 54, and with the current one 24 of 24.
  • On the macOS runner, 54 copies of Feed under flake: on main, 5 errored at teardown with the same finding (run 45957207466). On this branch, all 54 passed (run 45957210757).
  • The other -k anchor cases in test_render_shift_watch.py pass, 45 in all.

#6744 also tracks the shift-watch overshoot case, the Firefox comment marks and the reading_place glide. This PR doesn't touch them.

Refs #6744 — automated triage

…ift watch

The runtime names a box inside a widget's shadow tree from the document, with a
`::part(lf-aN) { anchor-name: --lf-aN }` rule (dom/css-anchors.js). The shift
watch keyed every anchor name by the named element's own root, so a carrier in
the document that anchors to such a box (the margin carrier for a heading in the
workspace widget's reader) recorded no anchor. Its native lag behind the
reader's scroll then had no credit at all, and the watch reported the margin
marker as moved without input.

A shadow-tree element that exposes a part now registers its anchor names in its
host's tree as well. The lagging-anchor test gains cases whose words stand in a
shadow tree named through `::part()`: they failed every time before the change.

Under `leaf-dev suite flake --workers 4 --load 2 --cpu-throttle 3` on Linux,
test_primary_reading_holds_remote_changes_before_package_layout[Feed] errored at
teardown in 11 of 24 and 17 of 24 copies on main at 43fed2e, and passes 54 of
54 with the change.

Refs #6744
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The shift watch registers every computed anchor name on an element exposing a CSS part in both the shadow tree and the document tree. A part can exist for styling while the shadow stylesheet declares an unrelated private anchor. If its name matches a real document anchor, this marks the document mapping ambiguous and drops valid scroll credit. Please track which names the outer tree actually declares, and cover a private shadow anchor sharing a document anchor’s name.

This was written by Codex on behalf of max-sixty

…ule there declares it

The shift watch registered every computed anchor name on an element that
exposes a part in both its shadow tree and its host's tree. A part can exist
for styling while the shadow tree's own style gives a private anchor; when that
name matched a real document anchor, the document's mapping became ambiguous and
dropped valid scroll credit.

Now a name counts in the host's tree only when a ::part() rule in that tree's
sheets matches the element and declares the name; every other name stays in the
element's own tree. The carried-row test gains a case beside a shadow tree's
private anchor of the same name, which fails on the previous watch
([step--private]) and passes now.

Co-Authored-By: max-sixty <[email protected]>
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Done in d4ec2b3. The watch now gives an anchor name to the host's tree only when a ::part() rule in that tree's sheets declares anchor-name, and that rule must also match the element's parts and its host. Every other computed name stays in the element's own shadow tree. To find those rules it reuses the watch's existing per-sheet rulesStating cache and its @media/@supports condition check.

test_a_carried_row_keeps_its_anchor_s_lagging_scroll gains private cases: the document's --words anchor sits beside a shadow tree whose own style gives a part="label" box anchor-name: --words. On the previous head, [step--private] fails with empty scroll credit. On this head, all 12 carried-row cases and the other -k anchor cases pass, 47 in all. Feed under leaf-dev suite flake --copies 24 --workers 4 --load 2 --cpu-throttle 3 passed 24 of 24.

@max-sixty
max-sixty merged commit 19a7705 into main Nov 27, 2026
7 checks passed
@max-sixty
max-sixty deleted the fix/issue-6744-part-anchor branch November 27, 2026 07:59
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