From 2575e4da3b09974efd84aa94ca98555bcd898965 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sun, 13 Nov 2022 14:56:22 -0700 Subject: rustdoc: remove unused CSS `code { opacity: 1 }` According to https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/CSS.20cleanup this style was added for declarations that no longer use opacity. --- src/librustdoc/html/static/css/rustdoc.css | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/librustdoc') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 3f295b96dc5..d195c9cf6f9 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1262,10 +1262,6 @@ h3.variant { margin-left: 24px; } -:target > code, :target > .code-header { - opacity: 1; -} - :target { padding-right: 3px; background-color: var(--target-background-color); -- cgit 1.4.1-3-g733a5 From e6baae576c9b474d1946a1d0f98692c7a3e62549 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 14 Nov 2022 15:14:54 +0100 Subject: Fix missing minification for static files --- src/librustdoc/html/static_files.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/librustdoc') diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index afe920b7fa1..b4d4150cddb 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -19,9 +19,13 @@ impl StaticFile { } pub(crate) fn minified(&self) -> Vec { - if self.filename.ends_with(".css") { + let extension = match self.filename.extension() { + Some(e) => e, + None => return self.bytes.to_owned(), + }; + if extension == "css" { minifier::css::minify(str::from_utf8(self.bytes).unwrap()).unwrap().to_string().into() - } else if self.filename.ends_with(".js") { + } else if extension == "js" { minifier::js::minify(str::from_utf8(self.bytes).unwrap()).to_string().into() } else { self.bytes.to_owned() -- cgit 1.4.1-3-g733a5 From 7b00534952c9d2685a960e2d501cc4eefab6c075 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 14 Nov 2022 10:41:07 -0700 Subject: rustdoc: fix corner case in search keyboard commands --- src/librustdoc/html/static/js/search.js | 1 + src/test/rustdoc-gui/search-keyboard.goml | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/test/rustdoc-gui/search-keyboard.goml (limited to 'src/librustdoc') diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index dd0531c5e70..4999bb35994 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1491,6 +1491,7 @@ function initSearch(rawSearchIndex) { const target = searchState.focusedByTab[searchState.currentTab] || document.querySelectorAll(".search-results.active a").item(0) || document.querySelectorAll("#titles > button").item(searchState.currentTab); + searchState.focusedByTab[searchState.currentTab] = null; if (target) { target.focus(); } diff --git a/src/test/rustdoc-gui/search-keyboard.goml b/src/test/rustdoc-gui/search-keyboard.goml new file mode 100644 index 00000000000..be642fc4997 --- /dev/null +++ b/src/test/rustdoc-gui/search-keyboard.goml @@ -0,0 +1,28 @@ +// Checks that the search tab results work correctly with function signature syntax +// First, try a search-by-name +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "Foo") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#titles" + +// Now use the keyboard commands to switch to the third result. +press-key: "ArrowDown" +press-key: "ArrowDown" +press-key: "ArrowDown" +assert: ".search-results.active > a:focus:nth-of-type(3)" + +// Now switch to the second tab, then back to the first one, then arrow back up. +press-key: "ArrowRight" +assert: ".search-results.active:nth-of-type(2) > a:focus:nth-of-type(1)" +press-key: "ArrowLeft" +assert: ".search-results.active:nth-of-type(1) > a:focus:nth-of-type(3)" +press-key: "ArrowUp" +assert: ".search-results.active > a:focus:nth-of-type(2)" +press-key: "ArrowUp" +assert: ".search-results.active > a:focus:nth-of-type(1)" +press-key: "ArrowUp" +assert: ".search-input:focus" +press-key: "ArrowDown" +assert: ".search-results.active > a:focus:nth-of-type(1)" -- cgit 1.4.1-3-g733a5