about summary refs log tree commit diff
path: root/src/test/rustdoc-gui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-02 10:21:53 +0000
committerbors <bors@rust-lang.org>2023-01-02 10:21:53 +0000
commitf89003eda8917ff99f8ee3fb5c812310a58c014b (patch)
tree4db143a6d6c509c1de4f8ebb92a74ede8782b112 /src/test/rustdoc-gui
parentd5a7ddd99f5e43116ec452777f08fddbde7f42fd (diff)
parent399fe5d0cd93f7b78e6464111546788c43ba1f61 (diff)
downloadrust-f89003eda8917ff99f8ee3fb5c812310a58c014b.tar.gz
rust-f89003eda8917ff99f8ee3fb5c812310a58c014b.zip
Auto merge of #106301 - notriddle:notriddle/dir-entry, r=GuillaumeGomez
rustdoc: use the regular arrow indicator for dir-entry CSS

This mostly reverts 468acca108e65101b802821bded17149dc1d86c9, while still fixing the problem it fixed by using an internal list-style-position. It results in a slight change in the hover indicator, but nothing misleading.

Preview: http://notriddle.com/notriddle-rustdoc-demos/dir-entry/src/std/lib.rs.html

## Before

![image](https://user-images.githubusercontent.com/1593513/210104247-642e6df0-07d3-452a-a2ab-4c700bc22e0e.png)

## After

![image](https://user-images.githubusercontent.com/1593513/210104271-a3832784-1e4d-4516-983e-6ecb9051857b.png)
Diffstat (limited to 'src/test/rustdoc-gui')
-rw-r--r--src/test/rustdoc-gui/source-code-page.goml89
1 files changed, 85 insertions, 4 deletions
diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml
index 8a33e713191..aa792196960 100644
--- a/src/test/rustdoc-gui/source-code-page.goml
+++ b/src/test/rustdoc-gui/source-code-page.goml
@@ -111,8 +111,57 @@ assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
 click: "#source-sidebar details:first-of-type > summary"
 assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
 
-// Check the spacing.
-assert-css: ("#source-sidebar > details.dir-entry", {"padding-left": "4px"})
+// And open it again, since it'll be the reference we use to check positions.
+click: "#source-sidebar details:first-of-type > summary"
+assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
+
+// Check the sidebar directory entries have a marker and spacing (desktop).
+store-property: (
+    link_height,
+    "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a",
+    "offsetHeight"
+)
+define-function: (
+    "check-sidebar-dir-entry",
+    (x, y),
+    [
+        ("assert", "details:first-of-type.dir-entry[open] > summary::marker"),
+        ("assert-css", ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"})),
+        // This check ensures that the summary is only one line.
+       ("assert-property", (
+            "#source-sidebar > details:first-of-type.dir-entry[open] > summary",
+            {"offsetHeight": |link_height|}
+        )),
+        ("assert-position", (
+            "#source-sidebar > details:first-of-type.dir-entry[open] > summary",
+            {"x": |x|, "y": |y|}
+        )),
+        ("assert-property", (
+            "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a",
+            {"offsetHeight": |link_height|}
+        )),
+        ("assert-position", (
+            "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a",
+            // left margin
+            {"x": |x| + 27, "y": |y| + |link_height|}
+        )),
+    ]
+)
+store-property: (
+    source_sidebar_title_height,
+    "#source-sidebar > .title",
+    "offsetHeight"
+)
+store-property: (
+    source_sidebar_title_y,
+    "#source-sidebar > .title",
+    "offsetTop"
+)
+call-function: ("check-sidebar-dir-entry", {
+    "x": 0,
+    // border + margin = 6
+    "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
+})
 
 // Check the search form
 assert-css: ("nav.sub", {"flex-direction": "row"})
@@ -125,13 +174,45 @@ assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34})
 assert-property: ("#main-content", {"offsetTop": 90})
 // 28 = 90 - 34 - 28
 
-// Now do the same check on moderately-sized mobile.
+// Now do the same check on moderately-sized, tablet mobile.
 size: (700, 700)
 assert-css: ("nav.sub", {"flex-direction": "row"})
 assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34})
 assert-property: ("#main-content", {"offsetTop": 76})
 // 21 = 76 - 34 - 21
 
-// Tiny mobile gets a different display where the logo is stacked on top.
+// Check the sidebar directory entries have a marker and spacing (tablet).
+store-property: (
+    source_sidebar_title_height,
+    "#source-sidebar > .title",
+    "offsetHeight"
+)
+store-property: (
+    source_sidebar_title_y,
+    "#source-sidebar > .title",
+    "offsetTop"
+)
+call-function: ("check-sidebar-dir-entry", {
+    "x": 0,
+    "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
+})
+
+// Tiny, phone mobile gets a different display where the logo is stacked on top.
 size: (450, 700)
 assert-css: ("nav.sub", {"flex-direction": "column"})
+
+// Check the sidebar directory entries have a marker and spacing (phone).
+store-property: (
+    source_sidebar_title_height,
+    "#source-sidebar > .title",
+    "offsetHeight"
+)
+store-property: (
+    source_sidebar_title_y,
+    "#source-sidebar > .title",
+    "offsetTop"
+)
+call-function: ("check-sidebar-dir-entry", {
+    "x": 0,
+    "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
+})