Skip to content

Commit 9e9fd1b

Browse files
authored
Rollup merge of #157381 - robbycbennett:librustdoc-fix-borders, r=notriddle
librustdoc: fix CSS border issue to support Firefox high contrast mode This fixes #157378. The spacing and the clickable areas of the links are identical. The only difference is that there are no longer any unsightly thick borders. Screenshot before the fix: <img width="1180" height="676" alt="image" src="https://github.com/user-attachments/assets/f213561f-de90-4262-baba-2aa18c59d287" /> Screenshot after the fix: <img width="1180" height="676" alt="image" src="https://github.com/user-attachments/assets/72504d0a-cca3-4b39-8d35-ecc5ac84e361" />
2 parents fc36bf2 + 8e9173f commit 9e9fd1b

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ ul.block, .block li, .block ul {
731731
}
732732

733733
.block ul a {
734-
padding-left: 1rem;
734+
/* extend click target to far edge of screen (mile wide bar) */
735+
padding-left: calc(1rem + var(--sidebar-elems-left-padding));
735736
}
736737

737738
.sidebar-elems a,
@@ -740,7 +741,7 @@ ul.block, .block li, .block ul {
740741
padding: 0.25rem; /* 4px */
741742
margin-right: 0.25rem;
742743
/* extend click target to far edge of screen (mile wide bar) */
743-
border-left: solid var(--sidebar-elems-left-padding) transparent;
744+
padding-left: calc(0.25rem + var(--sidebar-elems-left-padding));
744745
margin-left: calc(-0.25rem - var(--sidebar-elems-left-padding));
745746
background-clip: border-box;
746747
}
@@ -861,7 +862,7 @@ ul.block, .block li, .block ul {
861862
| └─────┘
862863
*/
863864
margin-top: -16px;
864-
border-top: solid 16px transparent;
865+
padding-top: 16px;
865866
box-sizing: content-box;
866867
position: relative;
867868
background-clip: border-box;
@@ -870,8 +871,6 @@ ul.block, .block li, .block ul {
870871

871872
.sidebar-crate h2 a {
872873
display: block;
873-
/* extend click target to far edge of screen (mile wide bar) */
874-
border-left: solid var(--sidebar-elems-left-padding) transparent;
875874
background-clip: border-box;
876875
margin: 0 calc(-24px + 0.25rem) 0 calc(-0.2rem - var(--sidebar-elems-left-padding));
877876
/* Align the sidebar crate link with the search bar, which have different
@@ -888,7 +887,8 @@ ul.block, .block li, .block ul {
888887
x = ( 16px - 0.57rem ) / 2
889888
*/
890889
padding: calc( ( 16px - 0.57rem ) / 2 ) 0.25rem;
891-
padding-left: 0.2rem;
890+
/* extend click target to far edge of screen (mile wide bar) */
891+
padding-left: calc(0.2rem + var(--sidebar-elems-left-padding));
892892
}
893893

894894
.sidebar-crate h2 .version {

tests/rustdoc-gui/huge-logo.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ set-window-size: (1280, 1024)
77
assert-property: (".sidebar-crate .logo-container", {"offsetWidth": "96", "offsetHeight": 48})
88
// offsetWidth = width of sidebar, offsetHeight = height + top padding
99
assert-property: (".sidebar-crate .logo-container img", {"offsetWidth": "48", "offsetHeight": 64})
10-
assert-css: (".sidebar-crate .logo-container img", {"border-top-width": "16px", "margin-top": "-16px"})
10+
assert-css: (".sidebar-crate .logo-container img", {"padding-top": "16px", "margin-top": "-16px"})

0 commit comments

Comments
 (0)