Skip to content

Commit e599e2d

Browse files
dns2utf8Mark-Simulacrum
authored andcommitted
Move from grid layout to table based layout because of browser limits that overlay row entries after a UA specific amount of rows
1 parent 677fb6b commit e599e2d

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

src/librustdoc/html/render/print_item.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ use crate::html::markdown::MarkdownSummaryLine;
3434

3535
const ITEM_TABLE_OPEN: &'static str = "<div class=\"item-table\">";
3636
const ITEM_TABLE_CLOSE: &'static str = "</div>";
37+
const ITEM_TABLE_ROW_OPEN: &'static str = "<div class=\"item-row\">";
38+
const ITEM_TABLE_ROW_CLOSE: &'static str = "</div>";
3739

3840
pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, page: &Page<'_>) {
3941
debug_assert!(!item.is_stripped());
@@ -256,9 +258,6 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
256258

257259
debug!("{:?}", indices);
258260
let mut curty = None;
259-
// See: https://github.com/rust-lang/rust/issues/88545
260-
let item_table_block_size = 900usize;
261-
let mut item_table_nth_element = 0usize;
262261

263262
for &idx in &indices {
264263
let myitem = &items[idx];
@@ -285,13 +284,13 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
285284
id = cx.derive_id(short.to_owned()),
286285
name = name
287286
);
288-
item_table_nth_element = 0;
289287
}
290288

291289
match *myitem.kind {
292290
clean::ExternCrateItem { ref src } => {
293291
use crate::html::format::anchor;
294292

293+
w.write_str(ITEM_TABLE_ROW_OPEN);
295294
match *src {
296295
Some(ref src) => write!(
297296
w,
@@ -312,6 +311,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
312311
),
313312
}
314313
w.write_str("</code></div>");
314+
w.write_str(ITEM_TABLE_ROW_CLOSE);
315315
}
316316

317317
clean::ImportItem(ref import) => {
@@ -336,6 +336,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
336336

337337
let add = if stab.is_some() { " " } else { "" };
338338

339+
w.write_str(ITEM_TABLE_ROW_OPEN);
339340
write!(
340341
w,
341342
"<div class=\"item-left {stab}{add}import-item\">\
@@ -348,6 +349,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
348349
imp = import.print(cx),
349350
stab_tags = stab_tags.unwrap_or_default(),
350351
);
352+
w.write_str(ITEM_TABLE_ROW_CLOSE);
351353
}
352354

353355
_ => {
@@ -368,6 +370,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
368370
let add = if stab.is_some() { " " } else { "" };
369371

370372
let doc_value = myitem.doc_value().unwrap_or_default();
373+
w.write_str(ITEM_TABLE_ROW_OPEN);
371374
write!(
372375
w,
373376
"<div class=\"item-left {stab}{add}module-item\">\
@@ -390,15 +393,9 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
390393
.collect::<Vec<_>>()
391394
.join(" "),
392395
);
396+
w.write_str(ITEM_TABLE_ROW_CLOSE);
393397
}
394398
}
395-
396-
item_table_nth_element += 1;
397-
if item_table_nth_element > item_table_block_size {
398-
w.write_str(ITEM_TABLE_CLOSE);
399-
w.write_str(ITEM_TABLE_OPEN);
400-
item_table_nth_element = 0;
401-
}
402399
}
403400

404401
if curty.is_some() {

src/librustdoc/html/static/css/rustdoc.css

+9-10
Original file line numberDiff line numberDiff line change
@@ -773,22 +773,18 @@ h2.small-section-header > .anchor {
773773
.block a.current.crate { font-weight: 500; }
774774

775775
.item-table {
776-
display: grid;
777-
column-gap: 1.2rem;
778-
row-gap: 0.0rem;
779-
grid-template-columns: auto 1fr;
776+
display: table-row;
780777
/* align content left */
781778
justify-items: start;
782779
}
783-
780+
.item-row {
781+
display: table-row;
782+
}
784783
.item-left, .item-right {
785-
display: block;
784+
display: table-cell;
786785
}
787786
.item-left {
788-
grid-column: 1;
789-
}
790-
.item-right {
791-
grid-column: 2;
787+
padding-right: 1.2rem;
792788
}
793789

794790
.search-container {
@@ -1891,6 +1887,9 @@ details.undocumented[open] > summary::before {
18911887

18921888
/* Display an alternating layout on tablets and phones */
18931889
.item-table {
1890+
display: block;
1891+
}
1892+
.item-row {
18941893
display: flex;
18951894
flex-flow: column wrap;
18961895
}

0 commit comments

Comments
 (0)