mirror of
https://github.com/readest/readest.git
synced 2026-11-30 03:13:39 +00:00
fix(lite): a scroll container's min and max width size a max-content flex row, as in Chromium (owner: "go ahead and yes use tauri's plugin:http")
Readest's toast is a width: max-content column holding one flex row: an icon, the message (flex: 1; overflow-y: auto; min-width: 60vw) and a close button. Taffy sized that row from the message's flex basis alone: a scroll container's contribution to a container's min- or max-content main size skipped the min/max clamp every other item gets. The toast was 271 px wide where Readest's is 432, its close button outside it. The contribution is now the flex basis clamped by the item's min and max main size. A message holding a fixed-size box instead of text already measured right (Blitz's block layout applies the min-width itself). Test: tauri-runtime-blitz tests/flex_scroll_contribution.rs, Chromium's widths for rows like the toast's. Without the change it fails with t0=188.27 and t1=2075.91 where Chromium has 412 (short text, clamped up to 300) and 512 (long text, clamped down to 400); with it, it passes. cargo test -p blitz-qjs-script -p tauri-runtime-blitz -p anyrender_cairo: 252 passed; -p blitz-dom -p blitz-html: 176 passed. Taffy's own suite at its pin (a scratch copy with vendor/taffy/src): all 6689 generated tests, 186 + 5 others and 156 of 157 hand-written tests pass, as before this change; the one failure is the end-margin test the earlier scroll-overflow patch contradicts. Real use, parity against Readest on Linux (CEF): in opds-catalog, step 12's toast now matches Readest's; the step had 8 moved boxes and five ink regions, and now differs only by the empty tbody QA.md lists (10/13 steps pass, as before). Every other scenario, run in Lite against the Readest runs of 11-28 (the same Readest build), passes the steps it passed on 11-28, except reader-search steps 6 and 7 (QA.md H4, the same on hosts without this change) and dictionary-de, whose step 2 once found no Dictionary button after the double tap. Rerun in both apps it fails only the steps it failed before (1/4, a known difference), and reader-turns-eink then reader-reopen pass 7/7 and 2/2. Not run on the Kindle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6807c4192e
commit
f65b0fe648
4 changed files with 69 additions and 3 deletions
|
|
@ -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 `<tbody>` | 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 `<tbody>` | 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
|
||||
|
|
|
|||
|
|
@ -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!(
|
||||
"<div style=\"position:absolute;top:{top}px;width:max-content;display:flex;flex-direction:column\" id=t{id}>
|
||||
<div style=\"display:flex;gap:12px;padding:0 20px\">
|
||||
<div style=\"width:24px;height:24px;flex-shrink:0\"></div>
|
||||
<span id=m{id} style=\"flex:1;overflow-y:auto;min-width:300px;max-width:400px;{extra}\">{text}</span>
|
||||
<div style=\"width:24px;height:24px;flex-shrink:0\"></div>
|
||||
</div></div>",
|
||||
top = id * 50
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_scroll_container_s_contribution_is_clamped_by_its_min_and_max_width() {
|
||||
let html = format!(
|
||||
"<!DOCTYPE html><html><body style=\"margin:0\">{}{}{}</body></html>",
|
||||
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::<String>::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"]
|
||||
);
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue