Skip to content

Commit 1d4397b

Browse files
authored
Rollup merge of #107964 - notriddle:notriddle/title-line-height, r=GuillaumeGomez
rustdoc: use tighter line height in h1 and h2 This keeps the line height for body text the same, as required by WCAG, but for headers, it makes sense to have wrapped lines be a bit tighter packed. ## Before ![image](https://user-images.githubusercontent.com/1593513/218332683-88a02467-7811-4e6b-81f8-67dded691465.png) ## After ![image](https://user-images.githubusercontent.com/1593513/218332698-a1b2a265-0658-4306-8473-b835f663172d.png)
2 parents f81cb97 + b0df355 commit 1d4397b

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ h1, h2, h3, h4 {
174174
.top-doc .docblock > h4 {
175175
border-bottom: 1px solid var(--headings-border-bottom-color);
176176
}
177+
/* while line-height 1.5 is required for any "block of text",
178+
which WCAG defines as more than one sentence, it looks weird for
179+
very large main headers */
180+
h1, h2 {
181+
line-height: 1.25;
182+
padding-top: 3px;
183+
padding-bottom: 9px;
184+
}
177185
h3.code-header {
178186
font-size: 1.125rem; /* 18px */
179187
}

tests/rustdoc-gui/mobile.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ assert-css: (".main-heading", {
1212
"flex-direction": "column"
1313
})
1414

15-
assert-property: (".mobile-topbar h2", {"offsetHeight": 36})
15+
assert-property: (".mobile-topbar h2", {"offsetHeight": 33})
1616

1717
// Note: We can't use assert-text here because the 'Since' is set by CSS and
1818
// is therefore not part of the DOM.

tests/rustdoc-gui/scrape-examples-layout.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ assert-property: (
4040
store-value: (offset_y, 4)
4141

4242
// First with desktop
43-
assert-position: (".scraped-example .code-wrapper", {"y": 255})
44-
assert-position: (".scraped-example .code-wrapper .prev", {"y": 255 + |offset_y|})
43+
assert-position: (".scraped-example .code-wrapper", {"y": 253})
44+
assert-position: (".scraped-example .code-wrapper .prev", {"y": 253 + |offset_y|})
4545

4646
// Then with mobile
4747
size: (600, 600)
48-
assert-position: (".scraped-example .code-wrapper", {"y": 314})
49-
assert-position: (".scraped-example .code-wrapper .prev", {"y": 314 + |offset_y|})
48+
assert-position: (".scraped-example .code-wrapper", {"y": 308})
49+
assert-position: (".scraped-example .code-wrapper .prev", {"y": 308 + |offset_y|})

tests/rustdoc-gui/search-result-display.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ size: (900, 900)
2222

2323
// First we check the current width, height and position.
2424
assert-css: ("#crate-search", {"width": "223px"})
25-
assert-css: (".search-results-title", {"height": "44px", "width": "640px"})
25+
assert-css: (".search-results-title", {"height": "50px", "width": "640px"})
2626
assert-css: ("#search", {"width": "640px"})
2727

2828
// Then we update the text of one of the `<option>`.
@@ -33,7 +33,7 @@ text: (
3333

3434
// Then we compare again to confirm the height didn't change.
3535
assert-css: ("#crate-search", {"width": "527px"})
36-
assert-css: (".search-results-title", {"height": "44px", "width": "640px"})
36+
assert-css: (".search-results-title", {"height": "50px", "width": "640px"})
3737
// And we check that the `<select>` isn't bigger than its container (".search-results-title").
3838
assert-css: ("#search", {"width": "640px"})
3939

tests/rustdoc-gui/sidebar-mobile-scroll.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
66

77
// Scroll down.
88
scroll-to: "//h2[@id='blanket-implementations']"
9-
assert-window-property: {"pageYOffset": "627"}
9+
assert-window-property: {"pageYOffset": "622"}
1010

1111
// Open the sidebar menu.
1212
click: ".sidebar-menu-toggle"
@@ -21,11 +21,11 @@ assert-window-property: {"pageYOffset": "0"}
2121
// Close the sidebar menu. Make sure the scroll position gets restored.
2222
click: ".sidebar-menu-toggle"
2323
wait-for-css: (".sidebar", {"left": "-1000px"})
24-
assert-window-property: {"pageYOffset": "627"}
24+
assert-window-property: {"pageYOffset": "622"}
2525

2626
// Now test that scrollability returns when the browser window is just resized.
2727
click: ".sidebar-menu-toggle"
2828
wait-for-css: (".sidebar", {"left": "0px"})
2929
assert-window-property: {"pageYOffset": "0"}
3030
size: (900, 600)
31-
assert-window-property: {"pageYOffset": "627"}
31+
assert-window-property: {"pageYOffset": "622"}

tests/rustdoc-gui/sidebar-mobile.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"})
4545
// so the target is not obscured by the topbar.
4646
click: ".sidebar-menu-toggle"
4747
click: ".sidebar-elems section .block li > a"
48-
assert-position: ("#method\.must_use", {"y": 45})
48+
assert-position: ("#method\.must_use", {"y": 46})
4949

5050
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
5151
click: ".sidebar-menu-toggle"

0 commit comments

Comments
 (0)