diff --git a/apps/readest-lite/QA.md b/apps/readest-lite/QA.md index c149ad103..d6dfdf9af 100644 --- a/apps/readest-lite/QA.md +++ b/apps/readest-lite/QA.md @@ -219,10 +219,9 @@ while KOReader is open; close the owner's Lite only after 5 idle minutes and reo | Tables, collapsed borders | The outer border takes the cells' width when the table's own is wider (a 40x30 table where Chromium's is 44x34); a cell's box takes its whole border where Chromium's takes half (24x14 where Chromium's is 23x13, with 1 px borders); the table's padding applies, where Chromium ignores it | Blitz's border-collapse resolution | Open | | Steps after a tap | Readest's tapped element (or what replaced it there) keeps `:hover` | The harness clicks with a mouse that stays in CEF; Lite gets a finger | Harness: reader-links step 5's darker gray button passes the ink check | | Comic and fixed-layout pages | Boxes in hidden page frames: Readest gives a `display: none` frame's document no boxes and a frame with no `src` an empty `about:blank` document; Lite lays out the first and gives the second no document | Blitz | Open, nothing visible (format-cbz, every step) | -| Toasts | 271 px wide where Readest's is 432, and the close button lies outside the box, unseen | The toast is `width: max-content`; in Taffy's max-content size of a flex row, a scroll container item (the message, `overflow-y: auto`) counts its flex basis without its `min-width: 60vw` | Open (opds-catalog step 12) | | A textarea | No resize grip at its corner | Blitz draws none | Open, small | | Online Library's catalog list | Its scroll box (`overflow-y: auto; pb-4`) is 15 px taller: 31 px under its content where Readest has 16 | Not found yet (15 px is a classic scrollbar's width) | Open, below the fold (opds-catalog step 9) | -| Tables, an empty `` | No box; Chromium gives it a zero-height box at its place | Lite's row group rect comes from its rows' grid tracks | Open, nothing visible (opds-catalog step 11) | +| Tables, an empty `` | No box; Chromium gives it a zero-height box at its place | Lite's row group rect comes from its rows' grid tracks | Open, nothing visible (opds-catalog steps 11-12) | | Forms | Enter in a field submits only a form with one text field, with no `submit` event; an empty `required` field doesn't stop a submit | Blitz's implicit submission; Lite has no constraint validation | Open | ## 7. Plan diff --git a/apps/readest-lite/crates/tauri-runtime-blitz/tests/flex_scroll_contribution.rs b/apps/readest-lite/crates/tauri-runtime-blitz/tests/flex_scroll_contribution.rs new file mode 100644 index 000000000..2cacd78b5 --- /dev/null +++ b/apps/readest-lite/crates/tauri-runtime-blitz/tests/flex_scroll_contribution.rs @@ -0,0 +1,48 @@ +//! A scroll container in a flex row contributes its size to the row's max-content width clamped +//! by its `min-width` and `max-width`, as any item does. readest-app's toast is a `width: +//! max-content` column holding such a row, its message `flex: 1; overflow-y: auto; min-width: +//! 60vw`: Taffy counted the message's flex basis unclamped, so the toast was 271 px wide where +//! Readest's is 432, and its close button lay outside it. Expected values are Chromium's for the +//! same page. + +use blitz_dom::{Document as _, DocumentConfig}; +use blitz_qjs_script::QjsDocument; +use blitz_traits::shell::{ColorScheme, Viewport}; + +fn row(id: u32, text: &str, extra: &str) -> String { + format!( + "
+
+
+ {text} +
+
", + top = id * 50 + ) +} + +#[test] +fn a_scroll_container_s_contribution_is_clamped_by_its_min_and_max_width() { + let html = format!( + "{}{}{}", + row(0, "Short text", ""), + row(1, &"x ".repeat(150), ""), + row(2, "Short text", "overflow:visible") + ); + let config = DocumentConfig { + viewport: Some(Viewport::new(800, 400, 1.0, ColorScheme::Light)), + ..DocumentConfig::default() + }; + let mut doc = QjsDocument::from_html(&html, config); + doc.inner_mut().resolve(0.0); + doc.eval( + "console.log([0, 1, 2].map((i) => { const t = document.getElementById('t' + i).getBoundingClientRect(); const m = document.getElementById('m' + i).getBoundingClientRect(); return `t${i}=${t.width} m${i}=${m.width}`; }).join(' '));", + "test", + ); + assert_eq!(doc.take_js_errors(), Vec::::new()); + // The text clamped up to 300 and down to 400; the last is the first without `overflow`. + assert_eq!( + doc.take_messages(), + ["log: t0=412 m0=300 t1=512 m1=400 t2=412 m2=300"] + ); +} diff --git a/apps/readest-lite/patches/README.md b/apps/readest-lite/patches/README.md index 7f74f8eaf..38ec4e4fe 100644 --- a/apps/readest-lite/patches/README.md +++ b/apps/readest-lite/patches/README.md @@ -371,6 +371,11 @@ Blitz's pin, the crate alone (`src`, `Cargo.toml`); the root `Cargo.toml` patche is measured. A container centred in its line was given its measured height as a known but indefinite size, and Readest's library header grouped its buttons in a 36px box where Readest has 32px. +- `compute/flexbox`: a scroll container's contribution to the container's min- or max-content + main size is its flex basis clamped by its min and max main size, as any item's is. Taffy + counted the flex basis alone: Readest's toast (`width: max-content`, its message `flex: 1; + overflow-y: auto; min-width: 60vw`) was 271px wide where Readest's is 432, its close button + outside it. ## tauri.diff (readest/tauri d6ef6e4c7, feat/cef) diff --git a/apps/readest-lite/patches/taffy.diff b/apps/readest-lite/patches/taffy.diff index c2f2032e3..ae163fda0 100644 --- a/apps/readest-lite/patches/taffy.diff +++ b/apps/readest-lite/patches/taffy.diff @@ -50,7 +50,21 @@ diff -ruN taffy/src/compute/flexbox.rs taffy/src/compute/flexbox.rs /// Determine the container's main size (if not already known) fn determine_container_main_size( tree: &mut impl LayoutFlexboxContainer, -@@ -2079,7 +2090,7 @@ +@@ -1614,7 +1625,12 @@ + + // Else compute the min- or -max content size and apply the full formula for computing the + // min- or max- content contribution +- _ if item.is_scroll_container() => item.flex_basis + margin_sum, ++ // A scroll container contributes its flex basis, clamped by its min and max ++ // main size as any item's contribution is (a `min-width` on an ++ // `overflow: auto` message widens a `width: max-content` toast in Chrome). ++ _ if item.is_scroll_container() => { ++ item.flex_basis.min(max_main_size).max(min_main_size) + margin_sum ++ } + + // If the item has a definite preferred main size then that is its content + // contribution (an inherent-size measure of the item would return it), floored +@@ -2079,7 +2095,7 @@ height: if constants.is_row { child_cross } else { child.target_size.height.into() }, }, known_dimensions_are_definite: item_known_dimension_definiteness(constants, child),