mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-18 00:15:44 +00:00
Merge remote-tracking branch 'origin/main' into pr6863
This commit is contained in:
commit
6854bd1fb3
5 files changed
+35
-5
No files matched your search
@@ -18,4 +18,7 @@ jobs:
|
||||
sonarcloud:
|
||||
# Tracked at @main so org-wide CI improvements propagate without PR churn.
|
||||
uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@main
|
||||
with:
|
||||
# Same craft-fonts commit as ci.yml: the UI glyph tests need its CJK and Arabic fonts.
|
||||
fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
secrets: inherit
|
||||
@@ -123,6 +123,8 @@ arboard = { version = "3.7", default-features = false, features = ["wayland-data
|
||||
|
||||
[workspace.lints.rust]
|
||||
unsafe_code = "forbid"
|
||||
# cargo llvm-cov sets `--cfg coverage`; timing tests skip themselves under its instrumentation.
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(coverage)"] }
|
||||
|
||||
[workspace.lints.clippy]
|
||||
cognitive_complexity = "deny"
|
||||
|
||||
@@ -718,12 +718,18 @@ pub(crate) fn place_objects(ctx: &mut Ctx, req: &ObjectPlacement) -> (Vec<Placed
|
||||
// (#4250). Inline objects go with their own line.
|
||||
let first = l0 == 0;
|
||||
let late = at.late.filter(|l| !l.placed.is_empty());
|
||||
let late_lines = late.map(LateFloats::lines_here).unwrap_or_default();
|
||||
for li in 0..pl.lines.len() {
|
||||
// A later piece looks only at its own lines and those holding the anchors of the late floats
|
||||
// it draws, in order: walking every line of the paragraph for each piece made a paragraph of
|
||||
// many pages quadratic (#6757).
|
||||
let (piece, mut late_lines) =
|
||||
if first { (0..pl.lines.len(), Vec::new()) } else { (l0..l1.min(pl.lines.len()), late.map(LateFloats::lines_here).unwrap_or_default()) };
|
||||
late_lines.retain(|li| !piece.contains(li));
|
||||
late_lines.sort_unstable();
|
||||
late_lines.dedup();
|
||||
let (before, after) = late_lines.split_at(late_lines.partition_point(|li| *li < piece.start));
|
||||
for li in before.iter().copied().chain(piece).chain(after.iter().copied()) {
|
||||
crate::work::steps(1);
|
||||
let in_piece = (l0..l1).contains(&li);
|
||||
if !in_piece && !first && !late_lines.contains(&li) {
|
||||
continue;
|
||||
}
|
||||
let Some(line) = pl.lines.get(li) else { continue };
|
||||
for k in line.c0..line.c1 {
|
||||
let Some(c) = pl.clusters.get(k) else { continue };
|
||||
|
||||
@@ -914,6 +914,7 @@ fn long_word_beside_a_float(n: usize) -> Document {
|
||||
/// A word with no break opportunity in it: measuring the word for every line it takes scanned
|
||||
/// the whole paragraph each time, so the layout was quadratic in the word's length.
|
||||
#[test]
|
||||
#[cfg_attr(coverage, ignore = "coverage instrumentation skews the time ratio")]
|
||||
fn a_long_unbreakable_word_lays_out_in_linear_time() {
|
||||
let (t1, tk, ratio) = layout_time_ratio(long_word_beside_a_float, 50_000, &LayoutOptions::default());
|
||||
eprintln!("t(n) {t1:.4} s, t(8n) {tk:.4} s, ratio {ratio:.1}");
|
||||
@@ -1134,6 +1135,7 @@ fn long_word_with_alternating_advances_beside_a_float(n: usize) -> Document {
|
||||
/// A word whose advances alternate in sign lays out in linear time: the measurement that asks
|
||||
/// whether it would fit the full line must not walk the word again for every line it takes.
|
||||
#[test]
|
||||
#[cfg_attr(coverage, ignore = "coverage instrumentation skews the time ratio")]
|
||||
fn a_word_with_alternating_advances_lays_out_in_linear_time() {
|
||||
let (t1, tk, ratio) = layout_time_ratio(long_word_with_alternating_advances_beside_a_float, 50_000, &LayoutOptions::default());
|
||||
eprintln!("t(n) {t1:.4} s, t(8n) {tk:.4} s, ratio {ratio:.1}");
|
||||
@@ -7839,6 +7841,7 @@ fn a_no_break_space_before_a_slash_still_holds() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(coverage, ignore = "coverage instrumentation skews the time ratio")]
|
||||
fn unequal_formats_lay_out_in_linear_time() {
|
||||
crate::test_fonts();
|
||||
// Runs whose formats never compare equal (NaN spacing from a hostile file) each get a style;
|
||||
|
||||
@@ -223,6 +223,22 @@ fn selecting_a_long_endnote_takes_linear_time() {
|
||||
assert_linear_steps("endnote selection", 20, laid, |(d, l, (a, b))| drop(std::hint::black_box(l.selection_rects(d, a, b, 0))));
|
||||
}
|
||||
|
||||
/// One paragraph of `n` lines (a line break after each word), so it runs over many pages.
|
||||
fn many_lines(n: usize) -> Document {
|
||||
let mut d = Document::from_text("");
|
||||
d.body = vec![wordcraft_doc::para_block(Paragraph::with_text(&"x\n".repeat(n), CharProps::default()))];
|
||||
d
|
||||
}
|
||||
|
||||
/// The piece of a long paragraph on each page looked through every line of the paragraph for the
|
||||
/// pictures and shapes to draw with it (#6757).
|
||||
#[test]
|
||||
fn a_paragraph_over_many_pages_lays_out_in_linear_time() {
|
||||
let pages = lay(&many_lines(SCALE * 400), &LayoutOptions::default()).pages.len();
|
||||
assert!(pages > 40, "the paragraph runs over many pages: {pages}");
|
||||
assert_layout_linear("a paragraph over many pages", 400, many_lines, &LayoutOptions::default());
|
||||
}
|
||||
|
||||
/// A table of `n` rows of 60 cells, each row exactly half a point high, so every cell clips its
|
||||
/// (empty) paragraph and the whole table fits on the first page.
|
||||
fn clipped_table(n: usize) -> Document {
|
||||
|
||||
Reference in new issue
Block a user