-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc: use CSS containment to speed up render #102253
Conversation
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @Folyd, @jsha |
You're doing two different things in here: reducing margins and speeding up page load. The second one is a great improvement, the first one I'm not sure to understand why it was done. It makes the CSS a bit more complicated so I assume that there is a good reason behind it. Can you provide more information about it please? |
The appearance of the page shouldn’t change. The reduced margins are supposed to make up for the way that |
That seems quite easy to break then. :-/ |
Yeah, we need to fix it so that rustdoc doesn’t rely on margin collapsing so much. |
☔ The latest upstream changes (presumably #102292) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
tl;dr: if you update the
|
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Containment This affected layout a little and required adjustments to the CSS to keep spacing the same. In particular, the margins of adjacent items usually overlap with each other. However, when an item has contain: layout, any margins of child nodes push out the size of the item itself. This was making spacing between items a little too big. To solve that, I removed margins in some places: in particular for certain classes that often occur at the end of a `details.rustdoc-toggle` block, I removed their bottom margin. Generally, the margins provided by the next item down are sufficient. Also remove an unnecessary margin-top on .code-header.
This comment has been minimized.
This comment has been minimized.
margin-bottom: 2em; | ||
} | ||
|
||
.implementors-toggle[open] { | ||
.implementors-toggle[open]:not(:last-child) { | ||
margin-bottom: 2em; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 2em margin works out to be 32px.
This means that, by disabling it on the last child, you're reducing the margin on the bottom of a list of implementors in this scenario (on current nightly, it'll be 32px, while on your branch, it's now 25px, because that's the top margin of the header).
Co-authored-by: Michael Howell <michael@notriddle.com>
@bors r+ rollup |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#101555 (Stabilize `#![feature(mixed_integer_ops)]`) - rust-lang#102253 (rustdoc: use CSS containment to speed up render) - rust-lang#102281 (make invalid_value lint a bit smarter around enums) - rust-lang#102284 (Structured suggestion for missing `mut`/`const` in raw pointer) - rust-lang#102330 (rustdoc: remove no-op CSS `.srclink { font-weight; font-size }`) - rust-lang#102337 (Avoid LLVM-deprecated `Optional::hasValue`) - rust-lang#102356 (session: remove now-unnecessary lint `#[allow]`s) - rust-lang#102367 (rustdoc: remove redundant `#help-button` CSS) - rust-lang#102369 (Fix search result colors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Containment
This affected layout a little and required adjustments to the CSS to keep spacing the same. In particular, the margins of adjacent items usually overlap with each other. However, when an item has contain: layout, any margins of child nodes push out the size of the item itself. This was making spacing between items a little too big. To solve that, I removed margins in some places: in particular for certain classes that often occur at the end of a
details.rustdoc-toggle
block, I removed their bottom margin. Generally, the margins provided by the next item down are sufficient.Also remove an unnecessary margin-top on .code-header.
In particular this helps with the problem that rustdoc in some situations can generate giant HTML pages, which can crash a Chrome tab on typical modern hardware, for instance:
https://docs.rs/iced-x86/1.16.0/iced_x86/code_asm/struct.CodeAssembler.html
(26MB, 409k DOM nodes). This doesn't, of course, universally solve the problem, but it pushes out the boundary of the largest page rustdoc can produce without crashing a browser tab.Demos:
https://rustdoc.crud.net/jsha/css-contain/std/string/struct.String.html
(warning: giant page, may crash a browser tab) https://rustdoc.crud.net/jsha/css-contain-icedx86/iced_x86/code_asm/struct.CodeAssembler.html
r? @notriddle