Skip to content

Commit 55bc638

Browse files
Fix wrong padding for expanded scraped example
1 parent e3af6dc commit 55bc638

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Diff for: src/librustdoc/html/static/css/rustdoc.css

+7
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,18 @@ both the code example and the line numbers, so we need to remove the radius in t
789789
}
790790

791791
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers,
792+
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers > pre,
792793
.rustdoc:not(.src) .scraped-example:not(.expanded) pre.rust {
793794
padding-bottom: 0;
794795
/* See above comment, should be the same max-height. */
795796
overflow: auto hidden;
796797
}
798+
.rustdoc:not(.src) .scraped-example .src-line-numbers {
799+
padding-top: 0;
800+
}
801+
.rustdoc:not(.src) .scraped-example.expanded .src-line-numbers {
802+
padding-bottom: 0;
803+
}
797804

798805
.rustdoc:not(.src) .example-wrap pre {
799806
overflow: auto;

Diff for: tests/rustdoc-gui/scrape-examples-button-focus.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ assert-property: (".scraped-example-list > .scraped-example .rust", {
2929

3030
// The expand button increases the scrollHeight of the minimized code viewport
3131
store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": smallOffsetHeight})
32-
assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", {
32+
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
3333
"scrollHeight": |smallOffsetHeight|
3434
}, NEAR)
35-
assert-property-false: (".scraped-example-list > .scraped-example .rust", {
35+
assert-property: (".scraped-example-list > .scraped-example .rust", {
3636
"scrollHeight": |smallOffsetHeight|
3737
}, NEAR)
3838
focus: ".scraped-example-list > .scraped-example .expand"

Diff for: tests/rustdoc-gui/scrape-examples-layout.goml

+19
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ assert-position: (".scraped-example .scraped-example-title", {
4747
"y": |y| + |height| - |title_height| - 8,
4848
})
4949

50+
// Check that the expand button works and also that line number aligns with code.
51+
move-cursor-to: ".scraped-example .rust"
52+
click: ".scraped-example .button-holder .expand"
53+
wait-for: ".scraped-example.expanded"
54+
// They should have the same y position.
55+
compare-elements-position: (
56+
".scraped-example.expanded .src-line-numbers pre span",
57+
".scraped-example.expanded .rust code",
58+
["y"],
59+
)
60+
// And they should have the same height.
61+
compare-elements-size: (
62+
".scraped-example.expanded .src-line-numbers",
63+
".scraped-example.expanded .rust",
64+
["height"],
65+
)
66+
// Collapse code again.
67+
click: ".scraped-example .button-holder .expand"
68+
5069
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
5170
// correctly.
5271

0 commit comments

Comments
 (0)