From b4f404b581a3e93c146ca2ea711fa03dca77327b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 4 Aug 2025 17:23:56 +0200 Subject: [PATCH 1/2] Fix wrong font being used for tooltips `i` icons --- src/librustdoc/html/static/css/rustdoc.css | 4 ++++ tests/rustdoc-gui/notable-trait.goml | 4 ++-- tests/rustdoc-gui/src/test_docs/lib.rs | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 99b3da8b2cd47..c48863b4681ef 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1838,6 +1838,10 @@ instead, we check that it's not a "finger" cursor. border-right: 3px solid var(--target-border-color); } +a.tooltip { + font-family: var(--font-family); +} + .code-header a.tooltip { color: inherit; margin-right: 15px; diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index 7fc70e0675df4..423a273fde746 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -8,10 +8,10 @@ define-function: ( [x, i_x], block { // Checking they have the same y position. - compare-elements-position: ( + compare-elements-position-near: ( "//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']", "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", - ["y"], + {"y": 1}, ) // Checking they don't have the same x position. compare-elements-position-false: ( diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index e8afe8b568727..623f5b33e9bc9 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -767,3 +767,17 @@ pub mod impls_indent { pub fn bar() {} } } + +pub mod tooltips { + pub struct X; + + impl X { + pub fn bar() -> Vec { + Vec::new() + } + } + + pub fn bar() -> Vec { + Vec::new() + } +} From 22607491bb944a715a15c15749f563986e6984bf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 4 Aug 2025 17:41:48 +0200 Subject: [PATCH 2/2] Add GUI regression test for tooltips `i` icons --- tests/rustdoc-gui/tooltips.goml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/rustdoc-gui/tooltips.goml diff --git a/tests/rustdoc-gui/tooltips.goml b/tests/rustdoc-gui/tooltips.goml new file mode 100644 index 0000000000000..6e79196be2731 --- /dev/null +++ b/tests/rustdoc-gui/tooltips.goml @@ -0,0 +1,15 @@ +// This test checks that the right font is applied to the `i` tooltip element. + +define-function: ( + "check-font", + [path], + block { + go-to: "file://" + |DOC_PATH| + "/test_docs/" + |path| + assert-css: ( + "a.tooltip", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ALL, + ) + } +) + +call-function: ("check-font", {"path": "tooltips/fn.bar.html"}) +call-function: ("check-font", {"path": "tooltips/struct.X.html"})