Repository navigation
fix(layout): the last two CSS corpus gaps + the WPT corpus is one question - #2918
Conversation
… trim The two fixtures that still failed on purpose in the CSS corpus were one question asked twice: what counts as CONTENT on a line. A `<span>`'s border/padding edge enters the line as a piece with width (`AtomicKind::EdgeStart`/`EdgeEnd`), and that made the collapsible space right after the start edge stop being at the line's START, and the one before the end edge stop being at its END — so neither collapsed and `<span style="border-right:25px"> X </span>` measured 51.39 where Blink gives 33.8, one space too many on each side (CSS Text 3 §4.1.2). An edge now neither consumes the pending space nor opens the line: a cluster holding only edges answers "did the line start" the way an empty one does, and the space is attributed to the first real content that arrives. If none arrives, the line ends and the space is never realised, which IS the trim. The same question with the other answer: an inline whose runs all collapse away (`<span> </span>`, a single space) makes no line box (§9.4.2) and owned no piece of any line, so it got no rect at all and `getBoundingClientRect` answered y = 0 where Blink answers 0x0 at the line's place. The marker that gave a position to an inline that produced NO run now goes to any inline that produced nothing that SURVIVES — `preserved_spaces::tudo_colapsa`, which disqualifies an atom (a surface on the line) and a `white-space` regime that preserves (the space is then content and the line box real). Rejected: trimming the trailing space at each line push. It would have been six call sites deciding the same thing, and a width already summed into `cur_w`; not realising a space is cheaper than unrealising it. Rulers (`target/release/examples/run_fixture`, this tree): - corpus CSS 170/170, 4528/4528 measurements (was 168/170, 4525/4528); `tests/css/esperado-a-falhar.txt` is empty for the first time. - the Blink rects of both fixtures are asserted in Rust, written BEFORE the fix and seen to fail with exactly the documented deviations: `layout/tests/static_position_empty_line_corpus.rs` (the span widths) and `layout/tests/empty_inline_rect_corpus.rs` (new). - `cargo test --profile fast -p rts-dom -p rts-dom-bridge`: 1460 passed against 1459, and the 50 failures are the same set per NAME before and after (grid/subgrid, pre-existing on this branch) — nothing lost. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KjcGCJ2vTJf62LEjTE8d4M
`cargo test -p rts-dom --lib` failed 50 of its 1 510 tests on every machine but one, and had for months. Not a layout bug: each of those tests named the WPT corpus by an absolute path on the machine of whoever wrote it (`C:\Users\…\wpt-corpus\…`, 99 of them hand-written across 8 files), so everywhere else they panicked with `NotFound`. The `dom-tests` job of CI is `continue-on-error`, so the red was reported to nobody — a gate permanently red for everyone is a gate that teaches people to ignore red, which is the honesty floor's "a suite that does not run produces nothing to compare". `src/wpt_corpus.rs` is now the ONE answer to where the corpus is: `$RTS_WPT_CORPUS`, else `tests/wpt-corpus/` (git-ignored — nothing of the WPT is vendored), else the legacy path, so the machine that has always run these needs nothing set. `sem_corpus_wpt!()` is the first statement of each of the 51 tests that read it: no corpus, the test prints why and returns. Skipping is not the silent green this repository warns about: the skip prints the path it looked for, `corpus_is_present` is a test whose whole job is to report the state, and no number is published from a run that skipped — `tests/css/README.md`'s figure comes from the fixture corpus, which is in the tree and always runs. `path()` also normalises the separator. Two of the 51 named the file `css-grid\alignment\…`, which on Linux is a filename containing backslashes: they failed with the corpus in place, and were the only two a corpus alone did not fix. CI now clones the corpus sparsely for that job, which is what turns these 51 from a habit into a ruler. The checkout procedure is NOT written a second time — `scripts/wpt_reftests.md` has it, including the warning that narrowing an existing checkout deletes folders silently. Measured both ways, `cargo test --profile fast -p rts-dom -p rts-dom-bridge`: - with the corpus (a sparse wpt checkout, 57 MB): **1511 passed, 0 failed**. So 49 of the 51 were already correct and nobody could know; the 2 that were not were the backslashes. - without it: **1511 passed, 0 failed**, 51 skipped — against 1460 passed and 50 FAILED before this change. Not touched, and the same pattern: `rts-text` reads `C:/Users/…/wpt-corpus/fonts/Ahem.ttf` in a `#[cfg(test)]` block of `src/adapter.rs` and in `tests/shaping_and_breaks.rs`. Both are already graceful — the crate's tests pass here — and sharing this resolver would mean a crate for test support, which is a decision of its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KjcGCJ2vTJf62LEjTE8d4M
Cross-runtime parity (RTS vs Bun vs Node)
Divergences detected
|
Dois commits. O primeiro fecha as duas últimas fixtures do corpus CSS; o segundo trata dos 50 testes que só uma máquina do mundo conseguia correr, e que o primeiro deixou à vista.
1.
631fe42— a aresta de um inline não é conteúdo para o trim da linhaAs duas fixtures que ainda falhavam de propósito eram uma pergunta feita duas vezes: o que conta como CONTEÚDO numa linha.
<span>entra na linha como peça com largura (AtomicKind::EdgeStart/EdgeEnd), e isso fazia o espaço colapsável depois da aresta inicial deixar de estar no INÍCIO da linha, e o de antes da aresta final deixar de estar no FIM — nenhum colapsava.<span style="border-right:25px"> X </span>media 51,39 onde o Blink dá 33,8 (CSS Text 3 §4.1.2). Agora uma aresta não consome o espaço pendente nem abre a linha: um aglomerado só de arestas responde como um vazio, e o espaço é atribuído ao primeiro conteúdo real. Se nenhum chegar, a linha acaba e o espaço nunca se realiza — que é o trim.<span> </span>) não faz line box (§9.4.2) e não ficava dono de peça nenhuma, logo não tinha rect —getBoundingClientRectrespondia y=0 onde o Blink dá 0×0 na posição da linha. O marker que só ia ao inline que não gerou run nenhum vai agora a qualquer um que não gerou nada que SOBREVIVA (preserved_spaces::tudo_colapsa).Rejeitado: aparar o espaço final em cada
lines.push. Seriam seis sítios a decidir a mesma coisa, e uma largura já somada emcur_w; não realizar um espaço é mais barato que desrealizá-lo.Réguas (
target/release/examples/run_fixture, esta árvore):tests/css/esperado-a-falhar.txtOs rects do Blink das duas fixtures estão afirmados em Rust, escritos ANTES da correcção e vistos a falhar com exactamente os desvios documentados:
layout/tests/static_position_empty_line_corpus.rs(as larguras dos spans) elayout/tests/empty_inline_rect_corpus.rs(novo).2.
404e4a4— o corpus do WPT é uma pergunta, e sem ele o teste SALTAcargo test -p rts-dom --libfalhava 50 dos 1 510 testes em todas as máquinas menos uma, e há meses. Não era layout: 99 caminhos escritos à mão em 8 ficheiros nomeavam o corpus do WPT por um caminho absoluto da máquina de quem os escreveu (C:\Users\…\wpt-corpus\…). O jobdom-testsdo CI écontinue-on-error, portanto o vermelho não era reportado a ninguém — um gate permanentemente vermelho para todos é um gate que ensina a ignorar vermelho.crates/rts-dom/src/wpt_corpus.rs(novo) é a ÚNICA resposta a onde o corpus está:$RTS_WPT_CORPUS, senãotests/wpt-corpus/(ignorada pelo git — nada do WPT vendorizado), senão o caminho antigo, para a máquina que sempre os correu não precisar de configurar nada.sem_corpus_wpt!()é a primeira instrução dos 51 testes que o leem: sem corpus, imprime a razão e retorna. Não é o verde silencioso que este repositório teme: o salto imprime o caminho que procurou,corpus_is_presenté um teste cuja função é só relatar o estado, e nenhum número publicado vem de uma corrida que saltou (o detests/css/README.mdvem do corpus de fixtures, que está na árvore e corre sempre).path()normaliza a barra invertida: dois dos 51 escreviamcss-grid\alignment\…, que em Linux é um ficheiro com barras no nome — eram os únicos que um corpus não resolvia.dom-testsdo CI passa a clonar o corpus esparso, o que transforma estes 51 numa régua em vez de um hábito. O procedimento de checkout não é escrito uma segunda vez:scripts/wpt_reftests.mdjá o tem, incluindo o aviso de que encolher um checkout existente apaga pastas em silêncio.Medido nos dois estados,
cargo test --profile fast -p rts-dom -p rts-dom-bridge:O achado: 49 dos 51 já estavam certos e ninguém o podia saber. Os 2 que não estavam eram a barra invertida, não layout.
Perdidos
Nenhum, e comparado por NOME e não em líquido: as 50 falhas do
rts-domeram o mesmo conjunto antes e depois do commit 1 (grid/subgrid, por falta de corpus), e o commit 2 fecha-as todas.rts-eguierts-uicompilam.Fora do âmbito, mesmo padrão
rts-textlêC:/Users/…/wpt-corpus/fonts/Ahem.ttfnum bloco#[cfg(test)]desrc/adapter.rse emtests/shaping_and_breaks.rs. Ambos já degradam com elegância (o crate passa verde), e partilhar este resolvedor obrigaria a um crate de suporte a testes — decisão própria.Generated by Claude Code