Skip to content

Commit d755e18

Browse files
committed
Keep page chrome on the document coordinate plane
Remove body's obsolete role as the containing block for page-attached chrome. Standing workspaces can now move the body layout shell with symmetric margins without moving the coordinate origin used by aims, composers, and the page map. Centralize viewport-to-document placement and pin the contract with the Asks tray regression.
1 parent 6bbfb4b commit d755e18

6 files changed

Lines changed: 32 additions & 35 deletions

File tree

‎skills/leaf/CLAUDE.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ guards, deferred measurement, layout-change signalling, and control sizing;
8787
`runtime/scrolling.js` owns the document scroller identity, relative scroller moves,
8888
fixed-surface wheel forwarding, and the gutter its bar takes;
8989
`runtime/chrome-style.js` owns the comment layer's private stylesheet, built from
90-
the declaration-derived names and layout queries the runtime supplies it;
90+
the declaration-derived names and layout queries the runtime supplies it, and keeps
91+
body's layout shell out of the containing-block chain for document-positioned chrome;
9192
`runtime/chrome-layout.js` owns comment-panel visibility, chrome geometry, and the
9293
document room left after the panel and trays;
9394
`runtime/presentation.js` owns runtime paint and the words it projects;
@@ -106,7 +107,7 @@ landing across authored-document replacement, and the page-block reading used to
106107
start directional walks;
107108
`runtime/pointer.js` owns the shared unrounded pointer position;
108109
`runtime/geometry.js` owns the shared readings of visible boxes and clipping, plus the
109-
conversion from viewport boxes to body-positioned document chrome;
110+
conversion from viewport boxes to document-positioned chrome;
110111
`runtime/navigation.js` owns reader travel and scroller selection;
111112
`runtime/anchors.js` owns anchor resolution, paint, and anchor-specific travel;
112113
`runtime/conversation/model.js` adapts server-projected threads to browser callers;

‎skills/leaf/assets/runtime/chrome-style.js‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ export function chromeStyle({
6767
body::before { content: ""; display: block; height: var(--lf-banner-h); }
6868
}
6969
}
70-
/* position: relative makes the document shell the containing block for the two floats
71-
that point into it (the 💬 button and composer), so root scrolling carries them with
72-
the passage they stand beside. */
70+
/* Page-attached chrome is absolute against the initial containing block, not against
71+
body. Body is the layout shell and may move or narrow for standing workspaces; the
72+
document coordinate system does neither, and root scrolling still carries absolute
73+
chrome with the passage it stands beside. */
7374
/* The banner's height, said once. Everything at the top edge derives from it — the
7475
bar itself, the panel starting under it, the focus-revealed mark note, the
7576
scroll padding that keeps an anchored jump out from beneath it (plus air) — and
@@ -100,7 +101,7 @@ export function chromeStyle({
100101
@media screen and (pointer: coarse) and ${NON_COVERING} {
101102
:root { --lf-banner-h: calc(53px + var(--lf-safe-top)); }
102103
}
103-
body { position: relative; box-sizing: border-box; }
104+
body { position: static; box-sizing: border-box; }
104105
/* The strip the panel takes is given up as motion rather than as a jump, so the eye
105106
can follow the sentence it was reading to where it went. Keyed on the stamp that
106107
says the document is done becoming itself, because until then every margin the
@@ -150,12 +151,10 @@ export function chromeStyle({
150151
moves still wants the slide, an arrow step on the edge included: a step is one
151152
discrete move the eye can follow, which is what the rule above is for. */
152153
body[data-lf-sizing] { transition: none; }
153-
/* A tray that takes its room out of the page takes it the same way, off the one
154-
attribute showTray writes to say which tray is up and the one list that says which
155-
of them the page yields to (STRIP_TRAYS, where the reasons are). Everything else
156-
about the strip — that it comes out of the page rather than being held aside, that it
157-
is carried as motion, what it costs on a window narrow enough to rewrap — is the
158-
panel's story above, told once for both sides. */
154+
/* A tray that takes its room out of the page takes it the same way as the right panel:
155+
a body margin narrows and moves the layout shell while page-attached chrome keeps the
156+
document origin above it. showTray states which tray is up; STRIP_TRAYS states which
157+
trays claim this room. */
159158
@media screen and (not ${TRAY_COVERING}) {
160159
${STRIP_TRAY_RULE} { margin-left: var(${TRAY_PROP}); }
161160
}

‎skills/leaf/assets/runtime/composing/surface.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export function createSelectionSurface({
5151
}) {
5252
// ---------- selection → comment ----------
5353
// Floating UI stays inside the document layout shell. Body already ends at a standing
54-
// panel's edge through its margin, while the root scrollport owns the browser's gutter.
55-
// A covering sheet is the one strip body does not yield, so its width comes off here.
54+
// right panel's edge through its margin, while the root scrollport owns the browser's
55+
// gutter. A covering sheet is the one strip body does not yield, so its width comes off
56+
// here.
5657
const rightEdge = () =>
5758
(panelCovers()
5859
? innerWidth - panel.offsetWidth

‎skills/leaf/assets/runtime/geometry.js‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { uiInside } from "./passages.js";
22

33
/* Shared readings of the boxes the page actually shows. */
4-
// Document-anchored chrome is absolutely positioned against body's padding box, while
5-
// the boxes it follows are read in viewport coordinates. Body normally starts at the
6-
// viewport's left edge, but the Asks strip moves that containing block to the right.
7-
// Convert at the boundary instead of making every overlay know which workspace is open.
4+
// Document-anchored chrome is positioned from the document origin, while the boxes it
5+
// follows are read in viewport coordinates. Convert once at that boundary.
86
export function documentPoint(left, top) {
9-
const body = document.body;
10-
const origin = body.getBoundingClientRect();
117
return {
12-
left: left - origin.left - body.clientLeft,
13-
top: top - origin.top - body.clientTop,
8+
left: left + scrollX,
9+
top: top + scrollY,
1410
};
1511
}
1612

‎skills/leaf/assets/runtime/living-margin.js‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
unregisterMarginRow,
66
updateMarginRow,
77
} from "./margin-layout.js";
8-
import { shownBox, shownParts } from "./geometry.js";
8+
import { documentPoint, shownBox, shownParts } from "./geometry.js";
99
import { clampedRow } from "./keyboard/bindings.js";
1010

1111
const KINDS = {
@@ -220,13 +220,9 @@ export function createLivingMargin(dependencies) {
220220
) {
221221
const main = document.querySelector("main");
222222
if (!main || !columnRect) return;
223-
// The chrome root is a body child. A standing left tray moves that body's box,
224-
// so viewport coordinates would spend its offset twice when applied to this
225-
// absolute child. Convert the document column's horizontal coordinate into the
226-
// root's moved space; neither side panel changes its document-space vertical origin.
227-
const chromeRect = chromeRoot.getBoundingClientRect();
228-
nav.style.left = `${columnRect.left - chromeRect.left + pageScroller.scrollLeft}px`;
229-
nav.style.top = `${columnRect.top + pageScroller.scrollTop}px`;
223+
const at = documentPoint(columnRect.left, columnRect.top);
224+
nav.style.left = `${at.left}px`;
225+
nav.style.top = `${at.top}px`;
230226
nav.style.width = `${columnRect.width}px`;
231227
nav.style.height = `${main.scrollHeight}px`;
232228
}

‎tests/test_render_aim.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ def test_the_catalog_sidenote_can_be_aimed_whole(browser, serve):
113113

114114

115115
def test_an_aimed_comment_keeps_its_place_with_the_asks_tray_open(browser, serve):
116-
"""The Asks strip moves body's containing block, not the page's coordinates.
116+
"""The Asks strip can move the page without moving its coordinate origin.
117117
118-
The aim, action bar, and composer are absolute children of body. When the tray
119-
shifted body right, each used a viewport x-position as its local x-position and
120-
gained the tray's width a second time. Keep the whole route on the item the reader
121-
pointed at: the promise outlines it, and Comment opens a visible box clear of it.
118+
Page-attached chrome is positioned from the initial containing block while its
119+
targets are read in viewport coordinates. The tray therefore moves body's layout
120+
shell without moving the coordinate space above it. Keep the whole comment route on
121+
the item the reader pointed at.
122122
"""
123123
page, errors = open_page(browser, serve(DECISIONS_PAGE))
124124
resized(page, 1200, 900)
@@ -134,10 +134,14 @@ def test_an_aimed_comment_keeps_its_place_with_the_asks_tray_open(browser, serve
134134
const target = document.getElementById('lq-keep').getBoundingClientRect();
135135
const aim = document.querySelector('.lf-aim').getBoundingClientRect();
136136
return { bodyLeft: document.body.getBoundingClientRect().left,
137+
bodyPosition: getComputedStyle(document.body).position,
137138
dx: aim.left - target.left, dy: aim.top - target.top };
138139
}"""
139140
)
140141
assert aligned["bodyLeft"] > 0, "the Asks tray took no strip from the page"
142+
assert aligned["bodyPosition"] == "static", (
143+
"body became a moving containing block for document-attached chrome"
144+
)
141145
assert abs(aligned["dx"]) < 2 and abs(aligned["dy"]) < 2, (
142146
f"the aim moved {aligned['dx']:.1f}px across and {aligned['dy']:.1f}px down "
143147
f"from its target with body starting at {aligned['bodyLeft']:.1f}px"

0 commit comments

Comments
 (0)