Skip to content

Commit 194140b

Browse files
committed
Auto merge of #103165 - matthiaskrgr:rollup-guw8oh6, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #103152 (Use named arguments to make GUI test more clear) - #103160 (rustdoc: factor JS mobile scroll lock into its own function) - #103161 (rustdoc: remove redundant CSS on `#copy-path`) - #103162 (rustdoc: remove redundant CSS `#crate-search { border-radius }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 06f049a + 8a467c3 commit 194140b

File tree

5 files changed

+64
-85
lines changed

5 files changed

+64
-85
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.5
1+
0.12.6

Diff for: src/librustdoc/html/static/css/rustdoc.css

+8-16
Original file line numberDiff line numberDiff line change
@@ -1431,10 +1431,7 @@ h3.variant {
14311431
}
14321432

14331433
#settings-menu > a, #help-button > a, #copy-path {
1434-
padding: 5px;
14351434
width: 33px;
1436-
border: 1px solid var(--border-color);
1437-
border-radius: 2px;
14381435
cursor: pointer;
14391436
line-height: 1.5;
14401437
}
@@ -1444,10 +1441,18 @@ h3.variant {
14441441
height: 100%;
14451442
display: block;
14461443
background-color: var(--button-background-color);
1444+
border: 1px solid var(--border-color);
1445+
border-radius: 2px;
14471446
}
14481447

14491448
#copy-path {
14501449
color: var(--copy-path-button-color);
1450+
background: var(--main-background-color);
1451+
height: 34px;
1452+
margin-left: 10px;
1453+
padding: 0;
1454+
padding-left: 2px;
1455+
border: 0;
14511456
}
14521457
#copy-path > img {
14531458
filter: var(--copy-path-img-filter);
@@ -1495,15 +1500,6 @@ input:checked + .slider {
14951500
padding-top: 2px;
14961501
}
14971502

1498-
#copy-path {
1499-
height: 34px;
1500-
background-color: var(--main-background-color);
1501-
margin-left: 10px;
1502-
padding: 0;
1503-
padding-left: 2px;
1504-
border: 0;
1505-
}
1506-
15071503
kbd {
15081504
display: inline-block;
15091505
padding: 3px 5px;
@@ -1994,10 +1990,6 @@ in storage.js plus the media query with (min-width: 701px)
19941990
}
19951991

19961992
@media (max-width: 464px) {
1997-
#crate-search {
1998-
border-radius: 4px;
1999-
}
2000-
20011993
.docblock {
20021994
margin-left: 12px;
20031995
}

Diff for: src/librustdoc/html/static/js/main.js

+25-11
Original file line numberDiff line numberDiff line change
@@ -733,37 +733,51 @@ function loadCss(cssFileName) {
733733

734734
let oldSidebarScrollPosition = null;
735735

736-
function showSidebar() {
736+
// Scroll locking used both here and in source-script.js
737+
738+
window.rustdocMobileScrollLock = function() {
737739
const mobile_topbar = document.querySelector(".mobile-topbar");
738-
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT && mobile_topbar) {
740+
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
739741
// This is to keep the scroll position on mobile.
740742
oldSidebarScrollPosition = window.scrollY;
741743
document.body.style.width = `${document.body.offsetWidth}px`;
742744
document.body.style.position = "fixed";
743745
document.body.style.top = `-${oldSidebarScrollPosition}px`;
744-
mobile_topbar.style.top = `${oldSidebarScrollPosition}px`;
745-
mobile_topbar.style.position = "relative";
746+
if (mobile_topbar) {
747+
mobile_topbar.style.top = `${oldSidebarScrollPosition}px`;
748+
mobile_topbar.style.position = "relative";
749+
}
746750
} else {
747751
oldSidebarScrollPosition = null;
748752
}
749-
const sidebar = document.getElementsByClassName("sidebar")[0];
750-
addClass(sidebar, "shown");
751-
}
753+
};
752754

753-
function hideSidebar() {
755+
window.rustdocMobileScrollUnlock = function() {
754756
const mobile_topbar = document.querySelector(".mobile-topbar");
755-
if (oldSidebarScrollPosition !== null && mobile_topbar) {
757+
if (oldSidebarScrollPosition !== null) {
756758
// This is to keep the scroll position on mobile.
757759
document.body.style.width = "";
758760
document.body.style.position = "";
759761
document.body.style.top = "";
760-
mobile_topbar.style.top = "";
761-
mobile_topbar.style.position = "";
762+
if (mobile_topbar) {
763+
mobile_topbar.style.top = "";
764+
mobile_topbar.style.position = "";
765+
}
762766
// The scroll position is lost when resetting the style, hence why we store it in
763767
// `oldSidebarScrollPosition`.
764768
window.scrollTo(0, oldSidebarScrollPosition);
765769
oldSidebarScrollPosition = null;
766770
}
771+
};
772+
773+
function showSidebar() {
774+
window.rustdocMobileScrollLock();
775+
const sidebar = document.getElementsByClassName("sidebar")[0];
776+
addClass(sidebar, "shown");
777+
}
778+
779+
function hideSidebar() {
780+
window.rustdocMobileScrollUnlock();
767781
const sidebar = document.getElementsByClassName("sidebar")[0];
768782
removeClass(sidebar, "shown");
769783
}

Diff for: src/librustdoc/html/static/js/source-script.js

+3-30
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
(function() {
1111

1212
const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value;
13-
let oldScrollPosition = null;
1413

1514
const NAME_OFFSET = 0;
1615
const DIRS_OFFSET = 1;
@@ -70,44 +69,18 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
7069
function toggleSidebar() {
7170
const child = this.parentNode.children[0];
7271
if (child.innerText === ">") {
73-
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
74-
// This is to keep the scroll position on mobile.
75-
oldScrollPosition = window.scrollY;
76-
document.body.style.position = "fixed";
77-
document.body.style.top = `-${oldScrollPosition}px`;
78-
} else {
79-
oldScrollPosition = null;
80-
}
72+
window.rustdocMobileScrollLock();
8173
addClass(document.documentElement, "source-sidebar-expanded");
8274
child.innerText = "<";
8375
updateLocalStorage("source-sidebar-show", "true");
8476
} else {
85-
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT && oldScrollPosition !== null) {
86-
// This is to keep the scroll position on mobile.
87-
document.body.style.position = "";
88-
document.body.style.top = "";
89-
// The scroll position is lost when resetting the style, hence why we store it in
90-
// `oldScrollPosition`.
91-
window.scrollTo(0, oldScrollPosition);
92-
oldScrollPosition = null;
93-
}
77+
window.rustdocMobileScrollUnlock();
9478
removeClass(document.documentElement, "source-sidebar-expanded");
9579
child.innerText = ">";
9680
updateLocalStorage("source-sidebar-show", "false");
9781
}
9882
}
9983

100-
window.addEventListener("resize", () => {
101-
if (window.innerWidth >= window.RUSTDOC_MOBILE_BREAKPOINT && oldScrollPosition !== null) {
102-
// If the user opens the sidebar in "mobile" mode, and then grows the browser window,
103-
// we need to switch away from mobile mode and make the main content area scrollable.
104-
document.body.style.position = "";
105-
document.body.style.top = "";
106-
window.scrollTo(0, oldScrollPosition);
107-
oldScrollPosition = null;
108-
}
109-
});
110-
11184
function createSidebarToggle() {
11285
const sidebarToggle = document.createElement("div");
11386
sidebarToggle.id = "sidebar-toggle";
@@ -125,7 +98,7 @@ function createSidebarToggle() {
12598
return sidebarToggle;
12699
}
127100

128-
// This function is called from "source-files.js", generated in `html/render/mod.rs`.
101+
// This function is called from "source-files.js", generated in `html/render/write_shared.rs`.
129102
// eslint-disable-next-line no-unused-vars
130103
function createSourceSidebar() {
131104
const container = document.querySelector("nav.sidebar");

Diff for: src/test/rustdoc-gui/anchors.goml

+27-27
Original file line numberDiff line numberDiff line change
@@ -71,37 +71,37 @@ define-function: (
7171

7272
call-function: (
7373
"check-colors",
74-
(
75-
"ayu", // theme
76-
"rgb(197, 197, 197)", // main color
77-
"rgb(255, 255, 255)", // title color
78-
"rgb(255, 255, 255)", // fqn color
79-
"rgb(255, 160, 165)", // fqn type color
80-
"rgb(57, 175, 215)", // src link
81-
"rgb(83, 177, 219)", // sidebar link
82-
),
74+
{
75+
"theme": "ayu",
76+
"main_color": "rgb(197, 197, 197)",
77+
"title_color": "rgb(255, 255, 255)",
78+
"fqn_color": "rgb(255, 255, 255)",
79+
"fqn_type_color": "rgb(255, 160, 165)",
80+
"src_link_color": "rgb(57, 175, 215)",
81+
"sidebar_link_color": "rgb(83, 177, 219)",
82+
},
8383
)
8484
call-function: (
8585
"check-colors",
86-
(
87-
"dark", // theme
88-
"rgb(221, 221, 221)", // main color
89-
"rgb(221, 221, 221)", // title color
90-
"rgb(221, 221, 221)", // fqn color
91-
"rgb(45, 191, 184)", // fqn type color
92-
"rgb(210, 153, 29)", // src link
93-
"rgb(253, 191, 53)", // sidebar link
94-
),
86+
{
87+
"theme": "dark",
88+
"main_color": "rgb(221, 221, 221)",
89+
"title_color": "rgb(221, 221, 221)",
90+
"fqn_color": "rgb(221, 221, 221)",
91+
"fqn_type_color": "rgb(45, 191, 184)",
92+
"src_link_color": "rgb(210, 153, 29)",
93+
"sidebar_link_color": "rgb(253, 191, 53)",
94+
},
9595
)
9696
call-function: (
9797
"check-colors",
98-
(
99-
"light", // theme
100-
"rgb(0, 0, 0)", // main color
101-
"rgb(0, 0, 0)", // title color
102-
"rgb(0, 0, 0)", // fqn color
103-
"rgb(173, 55, 138)", // fqn type color
104-
"rgb(56, 115, 173)", // src link
105-
"rgb(53, 109, 164)", // sidebar link
106-
),
98+
{
99+
"theme": "light",
100+
"main_color": "rgb(0, 0, 0)",
101+
"title_color": "rgb(0, 0, 0)",
102+
"fqn_color": "rgb(0, 0, 0)",
103+
"fqn_type_color": "rgb(173, 55, 138)",
104+
"src_link_color": "rgb(56, 115, 173)",
105+
"sidebar_link_color": "rgb(53, 109, 164)",
106+
},
107107
)

0 commit comments

Comments
 (0)