fix(anatomy): V1-2.2 the visible wins on the editor canvas
Owner decision 2026-11-01. The canvas paints and hits every point hitbox, then every zone and trigger, then every visible twin, which captures on what it paints; a junction's disc is no longer taken by the zone drawn after it. The PDF view keeps the document order and its bytes. Click spec: the five fixme run unmarked, six projects incl. a 320 px phone.
This commit is contained in:
1 parent
e67715025c
commit
9c606aa567
13 files changed
+504
-64
No files matched your search
@@ -42,7 +42,8 @@ export const PROJECTS: Project[] = [
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The canvas click proof (V1-2.2, e2e/ui/canvas-clicks.spec.ts) also runs on Firefox and
|
* The canvas click proof (V1-2.2, e2e/ui/canvas-clicks.spec.ts) also runs on Firefox and
|
||||||
* WebKit, desktop, and on the WebKit phone, when the pinned engine is installed
|
* WebKit, desktop, and on the WebKit phone, when the pinned engine is installed, and on a
|
||||||
|
* 320 px Chromium phone
|
||||||
* (`playwright install firefox webkit`, no sudo, never `--with-deps`). A missing engine is
|
* (`playwright install firefox webkit`, no sudo, never `--with-deps`). A missing engine is
|
||||||
* named in the run's output, never passed silently.
|
* named in the run's output, never passed silently.
|
||||||
*/
|
*/
|
||||||
@@ -55,6 +56,18 @@ function installed(name: string, executable: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const CLICK_PROJECTS: Project[] = [
|
export const CLICK_PROJECTS: Project[] = [
|
||||||
|
// The smallest preview the markers' visible size is measured on (owner decision 2026-11-01).
|
||||||
|
{
|
||||||
|
name: 'chromium-320',
|
||||||
|
testMatch: CANVAS_CLICKS,
|
||||||
|
use: {
|
||||||
|
...devices['Desktop Chrome'],
|
||||||
|
viewport: { width: 320, height: 568 },
|
||||||
|
deviceScaleFactor: 2,
|
||||||
|
isMobile: true,
|
||||||
|
hasTouch: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
...(installed('firefox', firefox.executablePath())
|
...(installed('firefox', firefox.executablePath())
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,11 +6,7 @@ import type { Page } from '@playwright/test'
|
|||||||
// clicks (taps on the phone project) on the bundled equine sheet in AnatomyCanvas
|
// clicks (taps on the phone project) on the bundled equine sheet in AnatomyCanvas
|
||||||
// (e2e/harness/canvas.tsx); run on Chromium, Firefox and WebKit when installed.
|
// (e2e/harness/canvas.tsx); run on Chromium, Firefox and WebKit when installed.
|
||||||
|
|
||||||
/**
|
/** The points of the equine main view, in document order. */
|
||||||
* The points of the equine main view whose visible disc no other marker covers, in document
|
|
||||||
* order. The three vertebral junctions sit on the edge of a zone painted after them: part of
|
|
||||||
* their disc records the zone (pre-existing, owner decision, see the fixme below).
|
|
||||||
*/
|
|
||||||
const POINTS = [
|
const POINTS = [
|
||||||
'hind-fetlock',
|
'hind-fetlock',
|
||||||
'hock',
|
'hock',
|
||||||
@@ -23,6 +19,11 @@ const POINTS = [
|
|||||||
'fore-fetlock',
|
'fore-fetlock',
|
||||||
'fore-sesamoids',
|
'fore-sesamoids',
|
||||||
]
|
]
|
||||||
|
/**
|
||||||
|
* The vertebral junctions sit on the edge of a zone. Until the canvas painted its markers in
|
||||||
|
* three passes (« the visible wins », owner decision 2026-11-01) the zone, drawn after them,
|
||||||
|
* took up to half of their disc.
|
||||||
|
*/
|
||||||
const JUNCTIONS = ['l6-s1', 't18-l1', 'c7-t1']
|
const JUNCTIONS = ['l6-s1', 't18-l1', 'c7-t1']
|
||||||
const DRAWINGS = ['plain', 'giant-stroke', 'invisible-stroke', 'hidden-stroke']
|
const DRAWINGS = ['plain', 'giant-stroke', 'invisible-stroke', 'hidden-stroke']
|
||||||
|
|
||||||
@@ -31,7 +32,9 @@ type Point = { x: number; y: number }
|
|||||||
async function open(page: Page, drawing: string) {
|
async function open(page: Page, drawing: string) {
|
||||||
await page.goto(`/e2e/harness/canvas.html?drawing=${drawing}`)
|
await page.goto(`/e2e/harness/canvas.html?drawing=${drawing}`)
|
||||||
await expect(
|
await expect(
|
||||||
page.locator('[data-testid="anatomy-canvas"] [data-anno-id="hock"]').first(),
|
page
|
||||||
|
.locator('[data-testid="anatomy-canvas"] [data-anno-id="hock"]')
|
||||||
|
.first(),
|
||||||
).toBeAttached()
|
).toBeAttached()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,16 +69,24 @@ async function clickRecords(page: Page, at: Point, touch = false) {
|
|||||||
|
|
||||||
test.describe('canvas clicks', () => {
|
test.describe('canvas clicks', () => {
|
||||||
for (const drawing of DRAWINGS) {
|
for (const drawing of DRAWINGS) {
|
||||||
test(`a click on the hock records the hock (${drawing})`, async ({ page }, info) => {
|
test(`a click on the hock records the hock (${drawing})`, async ({
|
||||||
|
page,
|
||||||
|
}, info) => {
|
||||||
await open(page, drawing)
|
await open(page, drawing)
|
||||||
const touch = info.project.use.hasTouch === true
|
const touch = info.project.use.hasTouch === true
|
||||||
expect(await clickRecords(page, await centreOf(page, 'hock'), touch)).toEqual(['hock'])
|
expect(
|
||||||
|
await clickRecords(page, await centreOf(page, 'hock'), touch),
|
||||||
|
).toEqual(['hock'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test(`every point clear of the zones records itself (${drawing})`, async ({ page }) => {
|
test(`every point clear of the zones records itself (${drawing})`, async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
await open(page, drawing)
|
await open(page, drawing)
|
||||||
for (const id of POINTS) {
|
for (const id of POINTS) {
|
||||||
expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([id])
|
expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([
|
||||||
|
id,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -96,7 +107,7 @@ test.describe('canvas clicks', () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
test('two close points each record themselves, their shared edge goes to the later one', async ({
|
test('two close points each record themselves, the gap between their discs goes to the later hitbox', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
await open(page, 'giant-stroke')
|
await open(page, 'giant-stroke')
|
||||||
@@ -104,30 +115,225 @@ test.describe('canvas clicks', () => {
|
|||||||
const sesamoids = await centreOf(page, 'fore-sesamoids')
|
const sesamoids = await centreOf(page, 'fore-sesamoids')
|
||||||
expect(await clickRecords(page, fetlock)).toEqual(['fore-fetlock'])
|
expect(await clickRecords(page, fetlock)).toEqual(['fore-fetlock'])
|
||||||
expect(await clickRecords(page, sesamoids)).toEqual(['fore-sesamoids'])
|
expect(await clickRecords(page, sesamoids)).toEqual(['fore-sesamoids'])
|
||||||
// Halfway, outside both visible discs and inside both hitboxes: document order, the
|
// On the perpendicular bisector, halfway between the visible discs' edge and the
|
||||||
// later marker is on top. One id, never two.
|
// hitboxes' edge: outside both discs, inside both hitboxes, the later hitbox on top.
|
||||||
const half = { x: (fetlock.x + sesamoids.x) / 2, y: (fetlock.y + sesamoids.y) / 2 }
|
const twin = await page
|
||||||
expect(await clickRecords(page, half)).toEqual(['fore-sesamoids'])
|
.locator('[data-anno-id="fore-fetlock"]')
|
||||||
|
.last()
|
||||||
|
.boundingBox()
|
||||||
|
const hitbox = await page
|
||||||
|
.locator('[data-anno-id="fore-fetlock"]')
|
||||||
|
.first()
|
||||||
|
.boundingBox()
|
||||||
|
if (!twin || !hitbox) throw new Error('fore-fetlock has no box')
|
||||||
|
const [disc, ring] = [twin.width / 2, hitbox.width / 2]
|
||||||
|
const span = { x: sesamoids.x - fetlock.x, y: sesamoids.y - fetlock.y }
|
||||||
|
const half = Math.hypot(span.x, span.y) / 2
|
||||||
|
const reach = Math.sqrt(((disc + ring) / 2) ** 2 - half ** 2)
|
||||||
|
const at = {
|
||||||
|
x: (fetlock.x + sesamoids.x) / 2 - (span.y / (2 * half)) * reach,
|
||||||
|
y: (fetlock.y + sesamoids.y) / 2 + (span.x / (2 * half)) * reach,
|
||||||
|
}
|
||||||
|
// WebKit snaps a real press to whole pixels: below 1.5 px of margin on each side the
|
||||||
|
// browser's own hit test answers, at the exact point. One id, never two.
|
||||||
|
if ((ring - disc) / 2 >= 1.5) {
|
||||||
|
expect(await clickRecords(page, at)).toEqual(['fore-sesamoids'])
|
||||||
|
} else {
|
||||||
|
const hit = await page.evaluate(
|
||||||
|
({ x, y }) =>
|
||||||
|
document
|
||||||
|
.elementFromPoint(x, y)
|
||||||
|
?.closest('[data-anno-id]')
|
||||||
|
?.getAttribute('data-anno-id'),
|
||||||
|
at,
|
||||||
|
)
|
||||||
|
expect(hit).toBe('fore-sesamoids')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test('a click on a vertebral junction records the junction', async ({ page }) => {
|
test('a click on a vertebral junction records the junction', async ({
|
||||||
test.fixme(
|
page,
|
||||||
true,
|
}, info) => {
|
||||||
'V1-2.2 finding: the zones are painted and hit after the points; c7-t1 records « thoracic » at its centre in Firefox and WebKit, and up to half of each junction disc records a zone in every engine (owner decision on the capture order)',
|
|
||||||
)
|
|
||||||
await open(page, 'plain')
|
await open(page, 'plain')
|
||||||
for (const id of JUNCTIONS) {
|
const touch = info.project.use.hasTouch === true
|
||||||
expect(await clickRecords(page, await centreOf(page, id)), id).toEqual([id])
|
for (const id of [...JUNCTIONS, 'fore-fetlock']) {
|
||||||
|
const centre = await centreOf(page, id)
|
||||||
|
expect(await clickRecords(page, centre, touch), id).toEqual([id])
|
||||||
|
// Four points towards the edge of the visible disc, on the zone side and the other ones.
|
||||||
|
const box = await page
|
||||||
|
.locator(`[data-testid="anatomy-canvas"] [data-anno-id="${id}"]`)
|
||||||
|
.last()
|
||||||
|
.boundingBox()
|
||||||
|
if (!box) throw new Error(`${id} has no box`)
|
||||||
|
// A real press is snapped to whole pixels by WebKit (taps and clicks, measured
|
||||||
|
// 2026-11-01): 80 % of the radius, at most the radius less 1.5 px.
|
||||||
|
const radius = box.width / 2
|
||||||
|
const reach = Math.min(radius * 0.8, radius - 1.5)
|
||||||
|
for (const [dx, dy] of [
|
||||||
|
[0, -1],
|
||||||
|
[1, 0],
|
||||||
|
[0, 1],
|
||||||
|
[-1, 0],
|
||||||
|
] as const) {
|
||||||
|
const at = { x: centre.x + dx * reach, y: centre.y + dy * reach }
|
||||||
|
expect(
|
||||||
|
await clickRecords(page, at, touch),
|
||||||
|
`${id} ${dx},${dy}`,
|
||||||
|
).toEqual([id])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('every visible disc records its point on its whole surface', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await open(page, 'plain')
|
||||||
|
expect(await page.evaluate(sampleDiscs), 'main').toEqual({})
|
||||||
|
await page.goto('/e2e/harness/canvas.html?view=head')
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('[data-testid="anatomy-canvas"] [data-anno-id="atm"]')
|
||||||
|
.first(),
|
||||||
|
).toBeAttached()
|
||||||
|
expect(await page.evaluate(sampleDiscs), 'head').toEqual({})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('every zone records itself wherever no disc covers it', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await open(page, 'plain')
|
||||||
|
const missed = await page.evaluate(sampleZones)
|
||||||
|
expect(missed).toEqual({})
|
||||||
|
})
|
||||||
|
|
||||||
// @phone: the desktop projects leave it out (grepInvert), the touch projects run it.
|
// @phone: the desktop projects leave it out (grepInvert), the touch projects run it.
|
||||||
test('a tap on the hock records the hock @phone', async ({ page }) => {
|
test('a tap on the hock records the hock @phone', async ({ page }) => {
|
||||||
for (const drawing of DRAWINGS) {
|
for (const drawing of DRAWINGS) {
|
||||||
await open(page, drawing)
|
await open(page, drawing)
|
||||||
expect(await clickRecords(page, await centreOf(page, 'hock'), true), drawing).toEqual([
|
expect(
|
||||||
'hock',
|
await clickRecords(page, await centreOf(page, 'hock'), true),
|
||||||
])
|
drawing,
|
||||||
|
).toEqual(['hock'])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In the page: the topmost visible disc decides. Samples every visible twin of the layer
|
||||||
|
* inside 95 % of its radius (anti-aliasing aside), every 2 units; the expected id is the last
|
||||||
|
* twin in document order whose disc holds the sample. Answers the twins that missed, with
|
||||||
|
* their counts.
|
||||||
|
*/
|
||||||
|
function sampleDiscs(): Record<string, string> {
|
||||||
|
const svg = document.querySelector(
|
||||||
|
'[data-testid="anatomy-canvas"] svg',
|
||||||
|
) as SVGSVGElement
|
||||||
|
const ctm = svg.getScreenCTM()
|
||||||
|
if (!ctm) throw new Error('no CTM')
|
||||||
|
const layer = svg.lastElementChild as SVGGElement
|
||||||
|
const twins = Array.from(layer.children).filter(
|
||||||
|
(k) => k.tagName === 'circle' && k.getAttribute('fill') !== 'transparent',
|
||||||
|
) as SVGCircleElement[]
|
||||||
|
const disc = (t: SVGCircleElement) => ({
|
||||||
|
id: t.getAttribute('data-anno-id') ?? '',
|
||||||
|
cx: t.cx.baseVal.value,
|
||||||
|
cy: t.cy.baseVal.value,
|
||||||
|
r: t.r.baseVal.value,
|
||||||
|
})
|
||||||
|
const discs = twins.map(disc)
|
||||||
|
const who = (x: number, y: number) => {
|
||||||
|
const p = new DOMPoint(x, y).matrixTransform(ctm)
|
||||||
|
return document
|
||||||
|
.elementFromPoint(p.x, p.y)
|
||||||
|
?.closest('[data-anno-id]')
|
||||||
|
?.getAttribute('data-anno-id')
|
||||||
|
}
|
||||||
|
const missed: Record<string, string> = {}
|
||||||
|
for (const d of discs) {
|
||||||
|
let n = 0
|
||||||
|
let own = 0
|
||||||
|
const reach = d.r * 0.95
|
||||||
|
for (let dx = -reach; dx <= reach; dx += 2) {
|
||||||
|
for (let dy = -reach; dy <= reach; dy += 2) {
|
||||||
|
if (Math.hypot(dx, dy) > reach) continue
|
||||||
|
const x = d.cx + dx
|
||||||
|
const y = d.cy + dy
|
||||||
|
const top = discs
|
||||||
|
.filter((o) => Math.hypot(x - o.cx, y - o.cy) <= o.r)
|
||||||
|
.pop()
|
||||||
|
n++
|
||||||
|
if (who(x, y) === top?.id) own++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (own < n) missed[d.id] = `${own}/${n}`
|
||||||
|
}
|
||||||
|
return missed
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In the page: every filled shape of the layer (zones, trigger), sampled every 4 units inside
|
||||||
|
* its fill, 2 CSS pixels from its edges; a sample counts where no visible disc lies within 2 CSS
|
||||||
|
* pixels and no later shape holds it in its fill or its stroke. Answers the shapes that missed, with their counts.
|
||||||
|
*/
|
||||||
|
function sampleZones(): Record<string, string> {
|
||||||
|
const svg = document.querySelector(
|
||||||
|
'[data-testid="anatomy-canvas"] svg',
|
||||||
|
) as SVGSVGElement
|
||||||
|
const ctm = svg.getScreenCTM()
|
||||||
|
if (!ctm) throw new Error('no CTM')
|
||||||
|
const margin = 2 / ctm.a
|
||||||
|
const layer = svg.lastElementChild as SVGGElement
|
||||||
|
const kids = Array.from(layer.children) as SVGGeometryElement[]
|
||||||
|
const twins = kids.filter(
|
||||||
|
(k) =>
|
||||||
|
k.tagName === 'circle' &&
|
||||||
|
k.getAttribute('pointer-events') === 'visiblePainted',
|
||||||
|
) as SVGCircleElement[]
|
||||||
|
const shapes = kids.filter(
|
||||||
|
(k) => k.tagName !== 'circle' || k.getAttribute('pointer-events') === 'all',
|
||||||
|
)
|
||||||
|
const nearDisc = (x: number, y: number) =>
|
||||||
|
twins.some(
|
||||||
|
(t) =>
|
||||||
|
Math.hypot(x - t.cx.baseVal.value, y - t.cy.baseVal.value) <=
|
||||||
|
t.r.baseVal.value + 0.75 + margin,
|
||||||
|
)
|
||||||
|
const who = (x: number, y: number) => {
|
||||||
|
const p = new DOMPoint(x, y).matrixTransform(ctm)
|
||||||
|
return document
|
||||||
|
.elementFromPoint(p.x, p.y)
|
||||||
|
?.closest('[data-anno-id]')
|
||||||
|
?.getAttribute('data-anno-id')
|
||||||
|
}
|
||||||
|
const missed: Record<string, string> = {}
|
||||||
|
shapes.forEach((shape, at) => {
|
||||||
|
const id = shape.getAttribute('data-anno-id') ?? ''
|
||||||
|
const later = shapes.slice(at + 1)
|
||||||
|
const b = shape.getBBox()
|
||||||
|
let n = 0
|
||||||
|
let own = 0
|
||||||
|
for (let x = b.x; x <= b.x + b.width; x += 4) {
|
||||||
|
for (let y = b.y; y <= b.y + b.height; y += 4) {
|
||||||
|
const point = new DOMPoint(x, y)
|
||||||
|
// Edges and vertices aside: a sample 2 CSS pixels inside the fill in each direction.
|
||||||
|
const inside = [
|
||||||
|
[margin, 0],
|
||||||
|
[-margin, 0],
|
||||||
|
[0, margin],
|
||||||
|
[0, -margin],
|
||||||
|
].every(([dx, dy]) => shape.isPointInFill(new DOMPoint(x + dx, y + dy)))
|
||||||
|
if (!shape.isPointInFill(point) || !inside || nearDisc(x, y)) continue
|
||||||
|
if (
|
||||||
|
later.some((o) => o.isPointInFill(point) || o.isPointInStroke(point))
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
n++
|
||||||
|
const got = who(x, y)
|
||||||
|
if (got === id) own++
|
||||||
|
else missed[`${id} first miss`] ??= `${x},${y}: ${String(got)}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (own < n) missed[id] = `${own}/${n}`
|
||||||
|
})
|
||||||
|
return missed
|
||||||
|
}
|
||||||
@@ -152,7 +152,8 @@ export function withDeclaredHitboxes(layer: unknown): unknown {
|
|||||||
* Owner brief 2026-10-30 (V1-2.2, three MEDIUM): the composition root is the engine's. Applied
|
* Owner brief 2026-10-30 (V1-2.2, three MEDIUM): the composition root is the engine's. Applied
|
||||||
* to a frozen canvas tree (a deep copy): the root keeps its namespaces and `viewBox`; its other
|
* to a frozen canvas tree (a deep copy): the root keeps its namespaces and `viewBox`; its other
|
||||||
* attributes and every child before the layer go into a `<g>` of the drawing; the layer's
|
* attributes and every child before the layer go into a `<g>` of the drawing; the layer's
|
||||||
* hitboxes are declared (`withDeclaredHitboxes`). Mirrors `crates/core/tests/common/svg_tree.rs`.
|
* hitboxes are declared (`withDeclaredHitboxes`) and its markers put in the canvas passes
|
||||||
|
* (`withCanvasPasses`, owner decision 2026-11-01). Mirrors `crates/core/tests/common/svg_tree.rs`.
|
||||||
*/
|
*/
|
||||||
export function withIsolatedLayer(tree: unknown): unknown {
|
export function withIsolatedLayer(tree: unknown): unknown {
|
||||||
const root = structuredClone(tree) as {
|
const root = structuredClone(tree) as {
|
||||||
@@ -169,6 +170,31 @@ export function withIsolatedLayer(tree: unknown): unknown {
|
|||||||
}
|
}
|
||||||
const group = { ns: root.ns, name: 'g', attrs: moved, children: root.children }
|
const group = { ns: root.ns, name: 'g', attrs: moved, children: root.children }
|
||||||
root.attrs = kept
|
root.attrs = kept
|
||||||
root.children = [group, withDeclaredHitboxes(layer)]
|
root.children = [group, withCanvasPasses(withDeclaredHitboxes(layer))]
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A marker's pass on the canvas: 0 a point hitbox, 1 a zone or a trigger, 2 a visible twin. */
|
||||||
|
function canvasPass(node: unknown): number {
|
||||||
|
const n = node as { name?: string; attrs?: Record<string, string> }
|
||||||
|
if (n.name !== 'circle') return 1
|
||||||
|
if (n.attrs?.fill === 'transparent') return 0
|
||||||
|
return n.attrs?.['pointer-events'] === 'none' ? 2 : 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Owner decision 2026-11-01 (V1-2.2, « the visible wins »), the editor canvas only: applied to
|
||||||
|
* a frozen layer after `withDeclaredHitboxes` (a deep copy). Every point hitbox, then every
|
||||||
|
* other shape, then every visible twin, each pass in the frozen order; the twins capture on
|
||||||
|
* `visiblePainted`. Mirrors `with_canvas_passes` in `crates/core/tests/common/svg_tree.rs`.
|
||||||
|
*/
|
||||||
|
export function withCanvasPasses(layer: unknown): unknown {
|
||||||
|
const copy = structuredClone(layer) as { children?: unknown[] }
|
||||||
|
const ranked = (copy.children ?? []).map((child, at) => ({ child, at, pass: canvasPass(child) }))
|
||||||
|
ranked.sort((a, b) => a.pass - b.pass || a.at - b.at)
|
||||||
|
copy.children = ranked.map(({ child, pass }) => {
|
||||||
|
if (pass === 2) (child as { attrs: Record<string, string> }).attrs['pointer-events'] = 'visiblePainted'
|
||||||
|
return child
|
||||||
|
})
|
||||||
|
return copy
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
checkR3Golden,
|
checkR3Golden,
|
||||||
treeOf,
|
treeOf,
|
||||||
|
withCanvasPasses,
|
||||||
withDeclaredHitboxes,
|
withDeclaredHitboxes,
|
||||||
withIdsScopedPerView,
|
withIdsScopedPerView,
|
||||||
withIsolatedLayer,
|
withIsolatedLayer,
|
||||||
@@ -101,7 +102,7 @@ describe.each(VIEWS)('the %s canvas', (viewId) => {
|
|||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
Object.entries(declared(frozen) as Record<string, unknown>).map(([name, layer]) => [
|
Object.entries(declared(frozen) as Record<string, unknown>).map(([name, layer]) => [
|
||||||
name,
|
name,
|
||||||
withDeclaredHitboxes(layer),
|
withCanvasPasses(withDeclaredHitboxes(layer)),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use super::frame::view_frame;
|
use super::frame::view_frame;
|
||||||
use super::layer::{LayerError, find_view, render_composed_layer};
|
use super::layer::{LayerError, find_view, render_canvas_layer, render_composed_layer};
|
||||||
pub use super::svg::refs::HALO_FILTER_ID;
|
pub use super::svg::refs::HALO_FILTER_ID;
|
||||||
use super::svg::refs::holds_reserved_id;
|
use super::svg::refs::holds_reserved_id;
|
||||||
use super::svg::sanitize::check_root_visibility;
|
use super::svg::sanitize::check_root_visibility;
|
||||||
@@ -113,7 +113,7 @@ pub fn compose_canvas(
|
|||||||
if !references_scoped(&root, &scope) {
|
if !references_scoped(&root, &scope) {
|
||||||
return Err(ComposeError::UnscopedReference);
|
return Err(ComposeError::UnscopedReference);
|
||||||
}
|
}
|
||||||
let layer = render_composed_layer(document, view_id, &HashSet::new())?;
|
let layer = render_canvas_layer(document, view_id, &HashSet::new())?;
|
||||||
root.children.push(Node::Element(checked(layer)?));
|
root.children.push(Node::Element(checked(layer)?));
|
||||||
Ok(root)
|
Ok(root)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ pub fn render_layer(
|
|||||||
view_id: &str,
|
view_id: &str,
|
||||||
states: &HashSet<&str>,
|
states: &HashSet<&str>,
|
||||||
) -> Result<Element, LayerError> {
|
) -> Result<Element, LayerError> {
|
||||||
layer(document, view_id, states, false)
|
layer(document, view_id, states, Form::Review)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The layer the composers draw (V1-2.2 owner brief 2026-10-30): the R3 tree with each point
|
/// The layer of the PDF view (V1-2.2 owner brief 2026-10-30): the R3 tree with each point
|
||||||
/// hitbox declaring its paint and its capture rule, `stroke="none"` and
|
/// hitbox declaring its paint and its capture rule, `stroke="none"` and
|
||||||
/// `pointer-events="visibleFill"`, so its clickable area is its circle whatever stroke the page
|
/// `pointer-events="visibleFill"`, so its clickable area is its circle whatever stroke the page
|
||||||
/// or a drawing would give it (under `pointer-events="all"` a stroke widens the hit area even
|
/// or a drawing would give it (under `pointer-events="all"` a stroke widens the hit area even
|
||||||
@@ -47,18 +47,50 @@ pub fn render_composed_layer(
|
|||||||
view_id: &str,
|
view_id: &str,
|
||||||
states: &HashSet<&str>,
|
states: &HashSet<&str>,
|
||||||
) -> Result<Element, LayerError> {
|
) -> Result<Element, LayerError> {
|
||||||
layer(document, view_id, states, true)
|
layer(document, view_id, states, Form::Highlight)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The layer of the editor canvas: the PDF view's elements in three passes, each in document
|
||||||
|
/// order, every point hitbox, then every filled shape (zones and triggers), then every visible
|
||||||
|
/// twin, which captures on what it paints (`visiblePainted`). « The visible wins » (owner
|
||||||
|
/// decision 2026-11-01): a vertebral junction's disc is no longer taken by the zone drawn
|
||||||
|
/// after it, a zone keeps what no disc covers, a hitbox ring what neither covers.
|
||||||
|
pub fn render_canvas_layer(
|
||||||
|
document: &AnatomicalSheetDocument,
|
||||||
|
view_id: &str,
|
||||||
|
states: &HashSet<&str>,
|
||||||
|
) -> Result<Element, LayerError> {
|
||||||
|
layer(document, view_id, states, Form::Canvas)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Which product draws the layer.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum Form {
|
||||||
|
/// The R3 tree, for the seed review drawings.
|
||||||
|
Review,
|
||||||
|
/// Declared hitboxes, document order.
|
||||||
|
Highlight,
|
||||||
|
/// Declared hitboxes, three passes, capturing twins.
|
||||||
|
Canvas,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The pass an element is painted (and hit) in, on the canvas.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum Pass {
|
||||||
|
Hitbox,
|
||||||
|
Shape,
|
||||||
|
Twin,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layer(
|
fn layer(
|
||||||
document: &AnatomicalSheetDocument,
|
document: &AnatomicalSheetDocument,
|
||||||
view_id: &str,
|
view_id: &str,
|
||||||
states: &HashSet<&str>,
|
states: &HashSet<&str>,
|
||||||
declared_hitbox: bool,
|
form: Form,
|
||||||
) -> Result<Element, LayerError> {
|
) -> Result<Element, LayerError> {
|
||||||
let view = find_view(document, view_id).ok_or(LayerError::UnknownView)?;
|
let view = find_view(document, view_id).ok_or(LayerError::UnknownView)?;
|
||||||
let context = Context {
|
let context = Context {
|
||||||
declared_hitbox,
|
form,
|
||||||
twin_opacity: if view.is_main() { "0.65" } else { "0.5" },
|
twin_opacity: if view.is_main() { "0.65" } else { "0.5" },
|
||||||
categories: document
|
categories: document
|
||||||
.categories
|
.categories
|
||||||
@@ -68,13 +100,23 @@ fn layer(
|
|||||||
view_names: document.views.iter().map(|v| (v.id(), v.name())).collect(),
|
view_names: document.views.iter().map(|v| (v.id(), v.name())).collect(),
|
||||||
states,
|
states,
|
||||||
};
|
};
|
||||||
let children = document
|
let elements = document
|
||||||
.annotations
|
.annotations
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|a| a.view_id() == view_id)
|
.filter(|a| a.view_id() == view_id)
|
||||||
.flat_map(|a| context.elements(a))
|
.flat_map(|a| context.elements(a));
|
||||||
.map(Node::Element)
|
let children = if form == Form::Canvas {
|
||||||
.collect();
|
// Each pass keeps the document order.
|
||||||
|
let mut passes: [Vec<Node>; 3] = Default::default();
|
||||||
|
for (pass, element) in elements {
|
||||||
|
passes[pass as usize].push(Node::Element(element));
|
||||||
|
}
|
||||||
|
passes.concat()
|
||||||
|
} else {
|
||||||
|
elements
|
||||||
|
.map(|(_, element)| Node::Element(element))
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
let attrs = vec![
|
let attrs = vec![
|
||||||
("data-layer", "annotations".to_owned()),
|
("data-layer", "annotations".to_owned()),
|
||||||
("data-view-id", view_id.to_owned()),
|
("data-view-id", view_id.to_owned()),
|
||||||
@@ -83,8 +125,7 @@ fn layer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Context<'a> {
|
struct Context<'a> {
|
||||||
/// The hitbox declares `stroke="none"` and captures on its circle only (composed form).
|
form: Form,
|
||||||
declared_hitbox: bool,
|
|
||||||
twin_opacity: &'static str,
|
twin_opacity: &'static str,
|
||||||
/// Last duplicate wins, as a JavaScript `Map` built from the list.
|
/// Last duplicate wins, as a JavaScript `Map` built from the list.
|
||||||
categories: HashMap<&'a str, Option<&'a str>>,
|
categories: HashMap<&'a str, Option<&'a str>>,
|
||||||
@@ -95,7 +136,7 @@ struct Context<'a> {
|
|||||||
type Attrs = Vec<(&'static str, String)>;
|
type Attrs = Vec<(&'static str, String)>;
|
||||||
|
|
||||||
impl Context<'_> {
|
impl Context<'_> {
|
||||||
fn elements(&self, annotation: &Annotation) -> Vec<Element> {
|
fn elements(&self, annotation: &Annotation) -> Vec<(Pass, Element)> {
|
||||||
let (geometry, color) = match annotation {
|
let (geometry, color) = match annotation {
|
||||||
Annotation::Observable(a) => (a.geometry.as_ref(), a.color.as_deref()),
|
Annotation::Observable(a) => (a.geometry.as_ref(), a.color.as_deref()),
|
||||||
Annotation::DetailTrigger(a) => (a.geometry.as_ref(), a.color.as_deref()),
|
Annotation::DetailTrigger(a) => (a.geometry.as_ref(), a.color.as_deref()),
|
||||||
@@ -119,11 +160,15 @@ impl Context<'_> {
|
|||||||
value_of(&data, "data-anno-name-en")
|
value_of(&data, "data-anno-name-en")
|
||||||
);
|
);
|
||||||
if annotation.trigger().is_some() {
|
if annotation.trigger().is_some() {
|
||||||
return vec![shape(geometry, &color, trigger_visual(), &data, &label)];
|
let trigger = shape(geometry, &color, trigger_visual(), &data, &label);
|
||||||
|
return vec![(Pass::Shape, trigger)];
|
||||||
}
|
}
|
||||||
match geometry {
|
match geometry {
|
||||||
Geometry::Circle(c) => self.point(c.cx, c.cy, c.r, &color, &data, &label),
|
Geometry::Circle(c) => self.point(c.cx, c.cy, c.r, &color, &data, &label),
|
||||||
_ => vec![shape(geometry, &color, zone_visual(), &data, &label)],
|
_ => vec![(
|
||||||
|
Pass::Shape,
|
||||||
|
shape(geometry, &color, zone_visual(), &data, &label),
|
||||||
|
)],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,14 +219,14 @@ impl Context<'_> {
|
|||||||
color: &str,
|
color: &str,
|
||||||
data: &Attrs,
|
data: &Attrs,
|
||||||
label: &str,
|
label: &str,
|
||||||
) -> Vec<Element> {
|
) -> Vec<(Pass, Element)> {
|
||||||
let mut hitbox: Attrs = vec![
|
let mut hitbox: Attrs = vec![
|
||||||
("cx", js_number(cx)),
|
("cx", js_number(cx)),
|
||||||
("cy", js_number(cy)),
|
("cy", js_number(cy)),
|
||||||
("r", js_number(r)),
|
("r", js_number(r)),
|
||||||
("fill", "transparent".to_owned()),
|
("fill", "transparent".to_owned()),
|
||||||
];
|
];
|
||||||
if self.declared_hitbox {
|
if self.form != Form::Review {
|
||||||
hitbox.push(("stroke", "none".to_owned()));
|
hitbox.push(("stroke", "none".to_owned()));
|
||||||
hitbox.push(("pointer-events", "visibleFill".to_owned()));
|
hitbox.push(("pointer-events", "visibleFill".to_owned()));
|
||||||
} else {
|
} else {
|
||||||
@@ -197,12 +242,16 @@ impl Context<'_> {
|
|||||||
("fill-opacity", self.twin_opacity.to_owned()),
|
("fill-opacity", self.twin_opacity.to_owned()),
|
||||||
("stroke", "#000".to_owned()),
|
("stroke", "#000".to_owned()),
|
||||||
("stroke-width", "1.5".to_owned()),
|
("stroke-width", "1.5".to_owned()),
|
||||||
("pointer-events", "none".to_owned()),
|
|
||||||
];
|
];
|
||||||
|
let twin_capture = match self.form {
|
||||||
|
Form::Canvas => "visiblePainted",
|
||||||
|
Form::Review | Form::Highlight => "none",
|
||||||
|
};
|
||||||
|
visible.push(("pointer-events", twin_capture.to_owned()));
|
||||||
visible.extend(data.iter().cloned());
|
visible.extend(data.iter().cloned());
|
||||||
vec![
|
vec![
|
||||||
titled("circle", hitbox, label),
|
(Pass::Hitbox, titled("circle", hitbox, label)),
|
||||||
titled("circle", visible, label),
|
(Pass::Twin, titled("circle", visible, label)),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
use common::svg_tree::{
|
use common::svg_tree::{
|
||||||
tree_value, view_names, with_ids_scoped_per_view, with_isolated_layer,
|
tree_value, view_names, with_canvas_passes, with_ids_scoped_per_view, with_isolated_layer,
|
||||||
with_trigger_names_per_language,
|
with_trigger_names_per_language,
|
||||||
};
|
};
|
||||||
use faunosteo_core::anatomy::svg::tree::parse_svg;
|
use faunosteo_core::anatomy::svg::tree::parse_svg;
|
||||||
@@ -46,6 +46,7 @@ fn golden(view: &str, sheet: &LoadedSheet) -> Value {
|
|||||||
with_trigger_names_per_language(&mut frozen, &view_names(&sheet.document));
|
with_trigger_names_per_language(&mut frozen, &view_names(&sheet.document));
|
||||||
with_ids_scoped_per_view(&mut frozen, view);
|
with_ids_scoped_per_view(&mut frozen, view);
|
||||||
with_isolated_layer(&mut frozen);
|
with_isolated_layer(&mut frozen);
|
||||||
|
with_canvas_passes(&mut frozen);
|
||||||
frozen
|
frozen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ mod common;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use common::svg_tree::{
|
use common::svg_tree::{
|
||||||
reread, tree_value, view_names, with_ids_scoped_per_view, with_isolated_layer,
|
reread, tree_value, view_names, with_canvas_passes, with_ids_scoped_per_view,
|
||||||
with_trigger_names_per_language,
|
with_isolated_layer, with_trigger_names_per_language,
|
||||||
};
|
};
|
||||||
use faunosteo_core::anatomy::compose::{
|
use faunosteo_core::anatomy::compose::{
|
||||||
ComposeError, asset_id_of_view, compose_canvas, compose_highlight,
|
ComposeError, asset_id_of_view, compose_canvas, compose_highlight,
|
||||||
@@ -112,6 +112,7 @@ fn canvas_golden(view: &str) -> Value {
|
|||||||
with_trigger_names_per_language(&mut frozen, &view_names(&draft()));
|
with_trigger_names_per_language(&mut frozen, &view_names(&draft()));
|
||||||
with_ids_scoped_per_view(&mut frozen, view);
|
with_ids_scoped_per_view(&mut frozen, view);
|
||||||
with_isolated_layer(&mut frozen);
|
with_isolated_layer(&mut frozen);
|
||||||
|
with_canvas_passes(&mut frozen);
|
||||||
frozen
|
frozen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,3 +175,30 @@ fn take_from(node: &mut Value) -> Option<Value> {
|
|||||||
}
|
}
|
||||||
kids.iter_mut().find_map(take_from)
|
kids.iter_mut().find_map(take_from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Owner decision 2026-11-01 (V1-2.2, « the visible wins »), the editor canvas only: applied
|
||||||
|
/// after `with_isolated_layer` to a frozen canvas tree, written apart from the core. The layer's
|
||||||
|
/// markers are put in three passes, each keeping the frozen order: every point hitbox (a circle
|
||||||
|
/// with `fill="transparent"`), then every other shape, then every visible twin (a circle with
|
||||||
|
/// `pointer-events="none"`), which captures on `visiblePainted`.
|
||||||
|
pub fn with_canvas_passes(tree: &mut Value) {
|
||||||
|
let layer = tree["children"].as_array_mut().unwrap().last_mut().unwrap();
|
||||||
|
let markers = std::mem::take(layer["children"].as_array_mut().unwrap());
|
||||||
|
let pass = |m: &Value| match (&m["attrs"]["fill"], &m["attrs"]["pointer-events"]) {
|
||||||
|
(f, _) if m["name"] == "circle" && f == "transparent" => 0,
|
||||||
|
(_, p) if m["name"] == "circle" && p == "none" => 2,
|
||||||
|
_ => 1,
|
||||||
|
};
|
||||||
|
let mut ranked: Vec<(u8, Value)> = markers.into_iter().map(|m| (pass(&m), m)).collect();
|
||||||
|
ranked.sort_by_key(|(rank, _)| *rank);
|
||||||
|
let out: Vec<Value> = ranked
|
||||||
|
.into_iter()
|
||||||
|
.map(|(rank, mut marker)| {
|
||||||
|
if rank == 2 {
|
||||||
|
marker["attrs"]["pointer-events"] = json!("visiblePainted");
|
||||||
|
}
|
||||||
|
marker
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
layer["children"] = Value::Array(out);
|
||||||
|
}
|
||||||
@@ -170,7 +170,8 @@ fn the_halo_filter_lives_outside_the_drawing() {
|
|||||||
|
|
||||||
/// Every interactive surface of the canvas: the point hitboxes declare `stroke="none"` and
|
/// Every interactive surface of the canvas: the point hitboxes declare `stroke="none"` and
|
||||||
/// capture on their circle only (`visibleFill`), the zones and the trigger declare their
|
/// capture on their circle only (`visibleFill`), the zones and the trigger declare their
|
||||||
/// stroke width; the visible twins never capture.
|
/// stroke width; the visible twins capture on what they paint (« the visible wins », owner
|
||||||
|
/// decision 2026-11-01), with their declared stroke.
|
||||||
#[test]
|
#[test]
|
||||||
fn every_interactive_surface_declares_its_geometry_and_capture() {
|
fn every_interactive_surface_declares_its_geometry_and_capture() {
|
||||||
let draft = draft();
|
let draft = draft();
|
||||||
@@ -184,7 +185,9 @@ fn every_interactive_surface_declares_its_geometry_and_capture() {
|
|||||||
assert_eq!(marker.attr("stroke"), Some("none"), "{marker:?}");
|
assert_eq!(marker.attr("stroke"), Some("none"), "{marker:?}");
|
||||||
assert_eq!(capture, Some("visibleFill"), "{marker:?}");
|
assert_eq!(capture, Some("visibleFill"), "{marker:?}");
|
||||||
}
|
}
|
||||||
(_, Some("none")) => {}
|
(_, Some("visiblePainted")) => {
|
||||||
|
assert_eq!(marker.attr("stroke-width"), Some("1.5"), "{marker:?}");
|
||||||
|
}
|
||||||
(_, Some("all")) => assert!(marker.attr("stroke-width").is_some(), "{marker:?}"),
|
(_, Some("all")) => assert!(marker.attr("stroke-width").is_some(), "{marker:?}"),
|
||||||
other => panic!("unexpected capture {other:?}"),
|
other => panic!("unexpected capture {other:?}"),
|
||||||
}
|
}
|
||||||
@@ -300,3 +303,70 @@ fn nothing_the_reader_keeps_changes_the_layer_or_the_halo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The role of a marker element of a composed layer, by its capture rule (the PDF view
|
||||||
|
/// recolours the hitbox): 0 a point hitbox, 1 a zone or a trigger, 2 a visible twin.
|
||||||
|
fn pass(marker: &Element) -> u8 {
|
||||||
|
match marker.attr("pointer-events") {
|
||||||
|
Some("visibleFill") => 0,
|
||||||
|
Some("none" | "visiblePainted") => 2,
|
||||||
|
_ => 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// « The visible wins » (owner decision 2026-11-01): the canvas paints every point hitbox, then
|
||||||
|
/// every zone and trigger, then every visible twin, each pass in document order; the PDF view
|
||||||
|
/// keeps the document order (its bytes, the R4 digests and the step6 goldens unchanged).
|
||||||
|
#[test]
|
||||||
|
fn the_canvas_paints_hitboxes_then_shapes_then_twins_and_the_pdf_keeps_document_order() {
|
||||||
|
let draft = draft();
|
||||||
|
for view in ["main", "head"] {
|
||||||
|
let canvas = compose_canvas(&draft, view, &horse()).unwrap();
|
||||||
|
let layer = canvas.element_children().last().unwrap();
|
||||||
|
let passes: Vec<u8> = layer.element_children().map(pass).collect();
|
||||||
|
let mut sorted = passes.clone();
|
||||||
|
sorted.sort_unstable();
|
||||||
|
assert_eq!(passes, sorted, "{view}: {passes:?}");
|
||||||
|
let ids = |p: u8| -> Vec<&str> {
|
||||||
|
layer
|
||||||
|
.element_children()
|
||||||
|
.filter(|m| pass(m) == p)
|
||||||
|
.map(|m| m.attr("data-anno-id").unwrap())
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
|
let document_order: Vec<&str> = draft
|
||||||
|
.annotations
|
||||||
|
.iter()
|
||||||
|
.filter(|a| a.view_id() == view)
|
||||||
|
.map(|a| a.id())
|
||||||
|
.collect();
|
||||||
|
for p in 0..3 {
|
||||||
|
let mut expected = document_order.clone();
|
||||||
|
expected.retain(|id| ids(p).contains(id));
|
||||||
|
assert_eq!(ids(p), expected, "{view} pass {p} keeps document order");
|
||||||
|
}
|
||||||
|
assert_eq!(ids(0), ids(2), "{view}: one twin per hitbox");
|
||||||
|
}
|
||||||
|
let all: HashSet<&str> = draft.annotations.iter().map(|a| a.id()).collect();
|
||||||
|
let pdf = compose_highlight(&draft, "main", horse(), &all, false).unwrap();
|
||||||
|
let layer = pdf.element_children().last().unwrap();
|
||||||
|
let passes: Vec<u8> = layer.element_children().map(pass).collect();
|
||||||
|
assert_ne!(
|
||||||
|
passes,
|
||||||
|
{
|
||||||
|
let mut s = passes.clone();
|
||||||
|
s.sort_unstable();
|
||||||
|
s
|
||||||
|
},
|
||||||
|
"the PDF view keeps the interleaved document order"
|
||||||
|
);
|
||||||
|
let twin_captures: Vec<_> = layer
|
||||||
|
.element_children()
|
||||||
|
.filter(|m| pass(m) == 2)
|
||||||
|
.map(|m| m.attr("pointer-events"))
|
||||||
|
.collect();
|
||||||
|
assert!(
|
||||||
|
twin_captures.iter().all(|c| *c == Some("none")),
|
||||||
|
"{twin_captures:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -23,11 +23,22 @@ trigger.
|
|||||||
| Annotation | Elements |
|
| Annotation | Elements |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `detail_trigger`, any geometry | one dashed shape: fill and stroke = the colour, `fill-opacity` 0.06, `stroke-width` 2, `stroke-dasharray` `8,4`, `pointer-events` all, `style` `cursor:pointer`, class `detail-zone` |
|
| `detail_trigger`, any geometry | one dashed shape: fill and stroke = the colour, `fill-opacity` 0.06, `stroke-width` 2, `stroke-dasharray` `8,4`, `pointer-events` all, `style` `cursor:pointer`, class `detail-zone` |
|
||||||
| `point` or `zone` with a circle | a transparent hitbox (the geometry's `r`, `fill` transparent, `stroke` none, `pointer-events` visibleFill, `style` `cursor:pointer`; the R3 form kept for the seed review drawings has no `stroke` and `pointer-events` all) then a visible twin on top (radius `max(2, r − 12)`, the colour, `fill-opacity` 0.65 on the main view / 0.5 on a detail view, stroke `#000` 1.5, `pointer-events` none) |
|
| `point` or `zone` with a circle | a transparent hitbox (the geometry's `r`, `fill` transparent, `stroke` none, `pointer-events` visibleFill, `style` `cursor:pointer`; the R3 form kept for the seed review drawings has no `stroke` and `pointer-events` all) then a visible twin on top (radius `max(2, r − 12)`, the colour, `fill-opacity` 0.65 on the main view / 0.5 on a detail view, stroke `#000` 1.5, `pointer-events` none; visiblePainted in the editor canvas, see below) |
|
||||||
| `point` or `zone` with a polygon or a path | one filled shape: fill and stroke = the colour, `fill-opacity` 0.3, `stroke-width` 2, `pointer-events` all, `style` `cursor:pointer` |
|
| `point` or `zone` with a polygon or a path | one filled shape: fill and stroke = the colour, `fill-opacity` 0.3, `stroke-width` 2, `pointer-events` all, `style` `cursor:pointer` |
|
||||||
|
|
||||||
Annotations without geometry draw nothing. Annotations follow the document
|
Annotations without geometry draw nothing. Annotations follow the document
|
||||||
order of the view. Coordinates are printed as JavaScript prints numbers, never
|
order of the view, in the PDF view and the review drawings. The editor canvas
|
||||||
|
paints and hits them in three passes, each in document order (« the visible
|
||||||
|
wins », owner decision 2026-11-01, V1-2.2): every point hitbox, then every
|
||||||
|
filled shape (zones and triggers), then every visible twin, which captures on
|
||||||
|
what it paints (`pointer-events` visiblePainted). A tap on a point's visible
|
||||||
|
disc selects that point even where a zone or another point's hitbox lies
|
||||||
|
under it; a zone keeps every pixel no visible disc covers, the hitbox ring of
|
||||||
|
a point included; a hitbox ring keeps what neither covers. Until then each
|
||||||
|
annotation's elements followed one another, so a zone painted after a
|
||||||
|
vertebral junction took part of its disc. Visible consequence: a selected
|
||||||
|
point's hitbox, filled by the canvas stylesheet, sits under a neighbouring
|
||||||
|
zone, which tints the part it covers. Coordinates are printed as JavaScript prints numbers, never
|
||||||
rounded; a path's `d` is copied as written. Each element has one `<title>`
|
rounded; a path's `d` is copied as written. Each element has one `<title>`
|
||||||
child, "name FR / name EN" (native tooltip), and the attributes below.
|
child, "name FR / name EN" (native tooltip), and the attributes below.
|
||||||
Owner decision 2026-10-15: until then an unnamed trigger carried the French
|
Owner decision 2026-10-15: until then an unnamed trigger carried the French
|
||||||
|
|||||||
@@ -113,10 +113,17 @@ suite needs Docker in the runner for the sandbox.
|
|||||||
## 6. Limits
|
## 6. Limits
|
||||||
|
|
||||||
- Chromium only, but `e2e/ui/canvas-clicks.spec.ts` (V1-2.2: projects
|
- Chromium only, but `e2e/ui/canvas-clicks.spec.ts` (V1-2.2: projects
|
||||||
`firefox-desktop`, `webkit-desktop`, `webkit-375`, added when
|
`chromium-320` (320 × 568, touch, the smallest preview the markers' visible
|
||||||
`playwright install firefox webkit` has put the pinned engines in the cache;
|
size is measured on), `firefox-desktop`, `webkit-desktop`, `webkit-375`, the
|
||||||
a missing one is named in the run's output and its projects do not run;
|
last three added when `playwright install firefox webkit` has put the pinned
|
||||||
harness `e2e/harness/canvas.{html,tsx}`, dev server only). Firefox, WebKit
|
engines in the cache; a missing one is named in the run's output and its
|
||||||
|
projects do not run; harness `e2e/harness/canvas.{html,tsx}`, dev server
|
||||||
|
only). WebKit snaps a real tap or click to whole CSS pixels (measured
|
||||||
|
2026-11-01: a tap at x 100.1 lands right of an edge at 100.4, a click at
|
||||||
|
100.9 left of it; Chromium keeps the fraction on a click, rounds a tap), so a
|
||||||
|
real press keeps 1.5 px of margin from any edge it tests; below that margin
|
||||||
|
the spec asks the browser's own hit test (`elementFromPoint`) at the exact
|
||||||
|
point. Firefox, WebKit
|
||||||
and the 412 × 915 viewport join every suite at V1-5
|
and the 412 × 915 viewport join every suite at V1-5
|
||||||
(contract §12.5). WebKit's system libraries may need `sudo` (owner action).
|
(contract §12.5). WebKit's system libraries may need `sudo` (owner action).
|
||||||
Desktop WebKit is not iOS Safari: the owner's manual check on a real iPhone
|
Desktop WebKit is not iOS Safari: the owner's manual check on a real iPhone
|
||||||
|
|||||||
@@ -4263,6 +4263,34 @@ The equine renders identically before and after (0 px, three engines, canvas and
|
|||||||
byte-identical to `958228a`. Correction to §12.10: the class fix does not change the R4 digests; only the R4.1 call-1
|
byte-identical to `958228a`. Correction to §12.10: the class fix does not change the R4 digests; only the R4.1 call-1
|
||||||
`svgSha256` changes.
|
`svgSha256` changes.
|
||||||
|
|
||||||
Open, pre-existing, owner decision: the vertebral junction points sit on the edge of zones painted and hit after them;
|
Junction points (open here until 2026-11-01): the vertebral junction points sat on the edge of zones painted and hit
|
||||||
measured in all three engines on the plain equine sheet, 28 to 49 % of `c7-t1`, `l6-s1` and `t18-l1`'s visible disc
|
after them; 28 to 49 % of `c7-t1`, `l6-s1` and `t18-l1`'s visible disc recorded the zone, 8 % of the fore fetlock's the
|
||||||
records the zone, 8 % of the fore fetlock's records the fore sesamoids (`fixme` in the click spec).
|
fore sesamoids. Closed by the canvas passes of §12.13.
|
||||||
|
|
||||||
|
### 12.13 Owner decisions of 2026-11-01
|
||||||
|
|
||||||
|
Brief « V1-2.2 : décisions et poursuite des corrections » on `f1bb19b`: lot B approved and committed (`4f52f5e`), the R3
|
||||||
|
transforms and the R4.1 call-1 `svgSha256` authorised (`e677150`, §12.12).
|
||||||
|
|
||||||
|
**Junctions, « the visible wins », the editor canvas only** (owner answer 2026-11-01: the PDF view is not interactive and
|
||||||
|
keeps the document order, its bytes, the R4 digests and the step6 goldens). `layer::render_canvas_layer`, drawn by
|
||||||
|
`compose_canvas`: every point hitbox, then every zone and trigger, then every visible twin, each pass in document order;
|
||||||
|
the twin captures on `visiblePainted` (its declared fill and its 1.5 stroke). `render_composed_layer` (PDF) and
|
||||||
|
`render_layer` (R3, review drawings) unchanged. Declared transform on the frozen canvas side: `with_canvas_passes`
|
||||||
|
(`tests/common/svg_tree.rs`, after `with_isolated_layer`) and `withCanvasPasses` (`tests/helpers/svgTree.ts`, inside
|
||||||
|
`withIsolatedLayer` and on each `canvas.*.layers.json` layer); the R3 highlight oracle keeps `with_isolated_layer` alone.
|
||||||
|
Visible consequence, declared: a selected point's hitbox, filled by the canvas stylesheet, sits under a neighbouring zone,
|
||||||
|
which tints the part it covers at 30 %.
|
||||||
|
|
||||||
|
| Proof | Result |
|
||||||
|
|---|---|
|
||||||
|
| `svg_marker_isolation::the_canvas_paints_hitboxes_then_shapes_then_twins_and_the_pdf_keeps_document_order` | passes sorted in both views, document order inside each pass, one twin per hitbox; the PDF view interleaved, twins `pointer-events="none"` |
|
||||||
|
| `canvas-clicks.spec.ts`, 6 projects (Chromium 1280, 375 and 320 touch, Firefox 1280, WebKit 1280 and 375 touch) | 99 passed, 0 fixme. On `e677150` (lot B alone) the junction test and the disc test fail in all 6 projects (12), the rest pass |
|
||||||
|
| junction test | `c7-t1`, `l6-s1`, `t18-l1`, fore fetlock: the centre and four points towards the disc edge (80 % of the radius, at most the radius less 1.5 px) record the point, real clicks or taps |
|
||||||
|
| disc test | every twin of the main and head views, sampled every 2 units inside 95 % of its radius: 100 % record the topmost disc, through the browser's hit test |
|
||||||
|
| zone test | every zone and the trigger, sampled every 4 units, 2 px inside their fill, away from any disc and any later shape: 100 % record the shape |
|
||||||
|
| close fetlocks | each centre records itself; the gap between their discs, inside both hitboxes, records the later hitbox (a real click where the margin is 1.5 px or more, the hit test below) |
|
||||||
|
|
||||||
|
The five `fixme` of the previous checkpoint were one test, « a click on a vertebral junction records the junction », in
|
||||||
|
each of the five projects of the time: it now runs unmarked in the six. Module: 574 234 B gzip -9 (lot B 573 134).
|
||||||
|
|
||||||
Reference in new issue
Block a user