Skip to content

Commit d6016aa

Browse files
authored
Unrolled build for rust-lang#120526
Rollup merge of rust-lang#120526 - GuillaumeGomez:mobile-long-crate-name, r=notriddle rustdoc: Correctly handle long crate names on mobile Fixes rust-lang#120471. It now renders like this: ![image](https://github.com/rust-lang/rust/assets/3050060/065b4b8b-ba55-4163-a928-8d7bf735c111) r? `@notriddle`
2 parents d3df8ff + 5d29f5a commit d6016aa

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -1941,13 +1941,8 @@ in src-script.js and main.js
19411941
pixels to avoid overflowing the topbar when the user sets a bigger
19421942
font size. */
19431943
font-size: 24px;
1944-
}
1945-
1946-
.mobile-topbar h2 a {
1947-
display: block;
1948-
text-overflow: ellipsis;
1949-
overflow: hidden;
19501944
white-space: nowrap;
1945+
text-overflow: ellipsis;
19511946
}
19521947

19531948
.mobile-topbar .logo-container > img {

src/librustdoc/html/static/js/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function setMobileTopbar() {
4545
const mobileTitle = document.createElement("h2");
4646
mobileTitle.className = "location";
4747
if (hasClass(document.querySelector(".rustdoc"), "crate")) {
48-
mobileTitle.innerText = `Crate ${window.currentCrate}`;
48+
mobileTitle.innerHTML = `Crate <a href="#">${window.currentCrate}</a>`;
4949
} else if (locationTitle) {
5050
mobileTitle.innerHTML = locationTitle.innerHTML;
5151
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Checks that if the crate name is too long on mobile, it will not grow and overflow its parent
2+
// (thanks to text overflow ellipsis).
3+
4+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
5+
// First we change the title to make it big.
6+
set-window-size: (350, 800)
7+
// We ensure that the "format" of the title is the same as the one we'll use.
8+
assert-text: (".mobile-topbar .location a", "test_docs")
9+
// We store the height we know is correct.
10+
store-property: (".mobile-topbar .location", {"offsetHeight": height})
11+
// We change the crate name to something longer.
12+
set-text: (".mobile-topbar .location a", "cargo_packager_resource_resolver")
13+
// And we check that the size remained the same.
14+
assert-property: (".mobile-topbar .location", {"offsetHeight": |height|})
15+
16+
// Now we check if it works for the non-crate pages as well.
17+
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
18+
// We store the height we know is correct.
19+
store-property: (".mobile-topbar .location", {"offsetHeight": height})
20+
set-text: (".mobile-topbar .location a", "Something_incredibly_long_because")
21+
// And we check that the size remained the same.
22+
assert-property: (".mobile-topbar .location", {"offsetHeight": |height|})

tests/rustdoc-gui/type-declation-overflow.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ assert-property: ("pre.item-decl", {"scrollWidth": "950"})
3939
set-window-size: (600, 600)
4040
go-to: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html"
4141
// It shouldn't have an overflow in the topbar either.
42-
store-property: (".mobile-topbar h2", {"scrollWidth": scrollWidth})
43-
assert-property: (".mobile-topbar h2", {"clientWidth": |scrollWidth|})
42+
store-property: (".mobile-topbar", {"scrollWidth": scrollWidth})
43+
assert-property: (".mobile-topbar", {"clientWidth": |scrollWidth|})
4444
assert-css: (".mobile-topbar h2", {"overflow-x": "hidden"})
4545

4646
// Check wrapping for top main-heading h1 and out-of-band.

0 commit comments

Comments
 (0)