about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-05-26 00:32:09 +0200
committerGitHub <noreply@github.com>2022-05-26 00:32:09 +0200
commit02b630f566fae3d049d1d4e70e1974c7741bf2f4 (patch)
treeb5f46af257b5bc0dc8a56f8c1d519a18cd8579e0
parent1b5e1215efa47cf4d78a945c7be1c04cda4f57d4 (diff)
parentf4f14f66711756e67bbc252b9e14546c771fe508 (diff)
downloadrust-02b630f566fae3d049d1d4e70e1974c7741bf2f4.tar.gz
rust-02b630f566fae3d049d1d4e70e1974c7741bf2f4.zip
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
Allow to click on setting text

You can test it [here](https://rustdoc.crud.net/imperio/gui-settings-text-click/doc/foo/index.html).

This PR allows to click on the text alongside the toggle to change it.

r? `@jsha`
-rw-r--r--src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version2
-rw-r--r--src/librustdoc/html/static/css/rustdoc.css24
-rw-r--r--src/librustdoc/html/static/css/settings.css40
-rw-r--r--src/librustdoc/html/static/js/settings.js11
-rw-r--r--src/test/rustdoc-gui/settings.goml10
-rw-r--r--src/tools/rustdoc-gui/tester.js18
6 files changed, 65 insertions, 40 deletions
diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version
index b3ec1638fda..03834411d15 100644
--- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version
+++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version
@@ -1 +1 @@
-0.9.3
\ No newline at end of file
+0.9.5
\ No newline at end of file
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 4eb8029ee2d..d0229bdb5f2 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1415,30 +1415,6 @@ pre.rust {
 #settings-menu.rotate > a img {
 	animation: rotating 2s linear infinite;
 }
-#settings-menu #settings {
-	position: absolute;
-	right: 0;
-	z-index: 1;
-	display: block;
-	margin-top: 7px;
-	border-radius: 3px;
-	border: 1px solid;
-}
-#settings-menu #settings .setting-line {
-	margin: 0.6em;
-}
-/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
-#settings-menu #settings::before {
-	content: '';
-	position: absolute;
-	right: 11px;
-	border: solid;
-	border-width: 1px 1px 0 0;
-	display: inline-block;
-	padding: 4px;
-	transform: rotate(-45deg);
-	top: -5px;
-}
 
 #help-button {
 	font-family: "Fira Sans", Arial, sans-serif;
diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css
index 07588748ad6..c69ff04236d 100644
--- a/src/librustdoc/html/static/css/settings.css
+++ b/src/librustdoc/html/static/css/settings.css
@@ -46,9 +46,12 @@
 .toggle {
 	position: relative;
 	display: inline-block;
-	width: 45px;
+	width: 100%;
 	height: 27px;
 	margin-right: 20px;
+	display: flex;
+	align-items: center;
+	cursor: pointer;
 }
 
 .toggle input {
@@ -57,12 +60,12 @@
 }
 
 .slider {
-	position: absolute;
+	position: relative;
+	width: 45px;
+	display: block;
+	height: 28px;
+	margin-right: 20px;
 	cursor: pointer;
-	top: 0;
-	left: 0;
-	right: 0;
-	bottom: 0;
 	background-color: #ccc;
 	transition: .3s;
 }
@@ -95,3 +98,28 @@ input:checked + .slider:before {
 	width: 100%;
 	display: block;
 }
+
+div#settings {
+	position: absolute;
+	right: 0;
+	z-index: 1;
+	display: block;
+	margin-top: 7px;
+	border-radius: 3px;
+	border: 1px solid;
+}
+#settings .setting-line {
+	margin: 1.2em 0.6em;
+}
+/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
+div#settings::before {
+	content: '';
+	position: absolute;
+	right: 11px;
+	border: solid;
+	border-width: 1px 1px 0 0;
+	display: inline-block;
+	padding: 4px;
+	transform: rotate(-45deg);
+	top: -5px;
+}
diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js
index 8770cc3f3b1..6746783717f 100644
--- a/src/librustdoc/html/static/js/settings.js
+++ b/src/librustdoc/html/static/js/settings.js
@@ -130,12 +130,11 @@
             } else {
                 // This is a toggle.
                 const checked = setting["default"] === true ? " checked" : "";
-                output += `
-                    <label class="toggle">
-                        <input type="checkbox" id="${js_data_name}"${checked}>
-                        <span class="slider"></span>
-                    </label>
-                    <div>${setting_name}</div>`;
+                output += `<label class="toggle">\
+                        <input type="checkbox" id="${js_data_name}"${checked}>\
+                        <span class="slider"></span>\
+                        <span class="label">${setting_name}</span>\
+                    </label>`;
             }
             output += "</div>";
         }
diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml
index 9a9c45a9b7f..1b2d1e31f52 100644
--- a/src/test/rustdoc-gui/settings.goml
+++ b/src/test/rustdoc-gui/settings.goml
@@ -34,7 +34,7 @@ wait-for: "#settings"
 
 // We check that the "Use system theme" is disabled.
 assert-property: ("#use-system-theme", {"checked": "false"})
-assert: "//*[@class='setting-line']/*[text()='Use system theme']"
+assert: "//*[@class='setting-line']//span[text()='Use system theme']"
 // Meaning that only the "theme" menu is showing up.
 assert: ".setting-line:not(.hidden) #theme"
 assert: ".setting-line.hidden #preferred-dark-theme"
@@ -55,7 +55,13 @@ assert: ".setting-line.hidden #theme"
 assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
 assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")
 
+// We now check that clicking on the "sliders"' text is like clicking on the slider.
+// To test it, we use the "Disable keyboard shortcuts".
+local-storage: {"rustdoc-disable-shortcuts": "false"}
+click: ".setting-line:last-child .toggle .label"
+assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
+
 // Now we go to the settings page to check that the CSS is loaded as expected.
 goto: file://|DOC_PATH|/settings.html
 wait-for: "#settings"
-assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"})
+assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"})
diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js
index 8532410a1bf..4599e12de5f 100644
--- a/src/tools/rustdoc-gui/tester.js
+++ b/src/tools/rustdoc-gui/tester.js
@@ -19,6 +19,7 @@ function showHelp() {
     console.log("  --help                     : show this message then quit");
     console.log("  --tests-folder [PATH]      : location of the .GOML tests folder");
     console.log("  --jobs [NUMBER]            : number of threads to run tests on");
+    console.log("  --executable-path [PATH]   : path of the browser's executable to be used");
 }
 
 function isNumeric(s) {
@@ -34,6 +35,8 @@ function parseOptions(args) {
         "show_text": false,
         "no_headless": false,
         "jobs": -1,
+        "executable_path": null,
+        "no_sandbox": false,
     };
     var correspondances = {
         "--doc-folder": "doc_folder",
@@ -41,13 +44,16 @@ function parseOptions(args) {
         "--debug": "debug",
         "--show-text": "show_text",
         "--no-headless": "no_headless",
+        "--executable-path": "executable_path",
+        "--no-sandbox": "no_sandbox",
     };
 
     for (var i = 0; i < args.length; ++i) {
         if (args[i] === "--doc-folder"
             || args[i] === "--tests-folder"
             || args[i] === "--file"
-            || args[i] === "--jobs") {
+            || args[i] === "--jobs"
+            || args[i] === "--executable-path") {
             i += 1;
             if (i >= args.length) {
                 console.log("Missing argument after `" + args[i - 1] + "` option.");
@@ -68,6 +74,9 @@ function parseOptions(args) {
         } else if (args[i] === "--help") {
             showHelp();
             process.exit(0);
+        } else if (args[i] === "--no-sandbox") {
+            console.log("`--no-sandbox` is being used. Be very careful!");
+            opts[correspondances[args[i]]] = true;
         } else if (correspondances[args[i]]) {
             opts[correspondances[args[i]]] = true;
         } else {
@@ -147,10 +156,17 @@ async function main(argv) {
         if (opts["show_text"]) {
             args.push("--show-text");
         }
+        if (opts["no_sandbox"]) {
+            args.push("--no-sandbox");
+        }
         if (opts["no_headless"]) {
             args.push("--no-headless");
             headless = false;
         }
+        if (opts["executable_path"] !== null) {
+            args.push("--executable-path");
+            args.push(opts["executable_path"]);
+        }
         options.parseArguments(args);
     } catch (error) {
         console.error(`invalid argument: ${error}`);