Skip to content

Commit f0eaa48

Browse files
authored
Rollup merge of #103663 - notriddle:notriddle/search-container, r=GuillaumeGomez
rustdoc: remove redundant CSS/DOM `div.search-container` Preview: https://notriddle.com/notriddle-rustdoc-demos/search-container/test_dingus/fn.test.html This wrapper DIV was originally added in 89e1fb3, when it allowed the search bar's size to be calculated without using `calc()`. This `width` hack can be removed using flexbox.
2 parents f41b1bf + 509d8ad commit f0eaa48

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

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

+7-12
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,16 @@ nav.sub {
683683
display: flex;
684684
align-items: center;
685685
}
686-
nav.sub form {
686+
.search-form {
687+
position: relative;
688+
display: flex;
689+
height: 34px;
687690
flex-grow: 1;
688691
}
689692
.source nav.sub {
690693
margin: 0 0 15px 0;
691694
}
692-
.source nav.sub form {
695+
.source .search-form {
693696
margin-left: 32px;
694697
}
695698

@@ -780,11 +783,6 @@ table,
780783
padding-right: 1.25rem;
781784
}
782785

783-
.search-container {
784-
position: relative;
785-
display: flex;
786-
height: 34px;
787-
}
788786
.search-results-title {
789787
margin-top: 0;
790788
white-space: nowrap;
@@ -860,15 +858,12 @@ so that we can apply CSS-filters to change the arrow color in themes */
860858
-webkit-appearance: textfield for search inputs. That
861859
causes rounded corners and no border on iOS Safari. */
862860
-webkit-appearance: none;
863-
/* Override Normalize.css: we have margins and do
864-
not want to overflow */
865-
box-sizing: border-box !important;
866861
outline: none;
867862
border: 1px solid var(--border-color);
868863
border-radius: 2px;
869864
padding: 8px;
870865
font-size: 1rem;
871-
width: 100%;
866+
flex-grow: 1;
872867
background-color: var(--button-background-color);
873868
color: var(--search-color);
874869
}
@@ -1957,7 +1952,7 @@ in storage.js
19571952
flex-direction: column;
19581953
}
19591954

1960-
nav.sub form {
1955+
.search-form {
19611956
align-self: stretch;
19621957
}
19631958

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ function loadCss(cssFileName) {
932932
* Hide all the popover menus.
933933
*/
934934
window.hidePopoverMenus = function() {
935-
onEachLazy(document.querySelectorAll(".search-container .popover"), elem => {
935+
onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
936936
elem.style.display = "none";
937937
});
938938
};

src/librustdoc/html/templates/page.html

+16-18
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,22 @@ <h2></h2> {#- -#}
115115
</a> {#- -#}
116116
{%- endif -%}
117117
<form class="search-form"> {#- -#}
118-
<div class="search-container"> {#- -#}
119-
<span></span> {#- This empty span is a hacky fix for Safari - See #93184 -#}
120-
<input {# -#}
121-
class="search-input" {# -#}
122-
name="search" {# -#}
123-
autocomplete="off" {# -#}
124-
spellcheck="false" {# -#}
125-
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
126-
type="search"> {#- -#}
127-
<div id="help-button" title="help" tabindex="-1"> {#- -#}
128-
<a href="{{page.root_path|safe}}help.html">?</a> {#- -#}
129-
</div> {#- -#}
130-
<div id="settings-menu" tabindex="-1"> {#- -#}
131-
<a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
132-
<img width="22" height="22" alt="Change settings" {# -#}
133-
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
134-
</a> {#- -#}
135-
</div> {#- -#}
118+
<span></span> {#- This empty span is a hacky fix for Safari - See #93184 -#}
119+
<input {# -#}
120+
class="search-input" {# -#}
121+
name="search" {# -#}
122+
autocomplete="off" {# -#}
123+
spellcheck="false" {# -#}
124+
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
125+
type="search"> {#- -#}
126+
<div id="help-button" title="help" tabindex="-1"> {#- -#}
127+
<a href="{{page.root_path|safe}}help.html">?</a> {#- -#}
128+
</div> {#- -#}
129+
<div id="settings-menu" tabindex="-1"> {#- -#}
130+
<a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
131+
<img width="22" height="22" alt="Change settings" {# -#}
132+
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
133+
</a> {#- -#}
136134
</div> {#- -#}
137135
</form> {#- -#}
138136
</nav> {#- -#}

0 commit comments

Comments
 (0)