Skip to content
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: do not preload fonts when browsing locally #122410

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

rjeli
Copy link
Contributor

@rjeli rjeli commented Mar 12, 2024

First PR, please let me know if I'm doing anything wrong.

As noted in #98769, currently cargo doc --open on macOS/Safari (17.2.1) doesn't load fonts due to a CORS issue. (webkit issue here). This patch moves the font preloads inside a js if statement as suggested in the GitHub issue.

I tried something more elegant with iterating over a tera array of fonts, but ran into issues, so here's the dumb fix. Only thing to note is that the font path is interpolated into a template string, so HTML escaping works fine, but it will break if there's a backtick or ${ in the font path. Not sure if this is a big deal.

@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @notriddle (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 12, 2024
@notriddle
Copy link
Contributor

No complaints, other than keeping the issue open because this is, unfortunately, an incomplete solution. It doesn't help unless the Develop menu is turned on.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 13, 2024

📌 Commit f3b348b has been approved by notriddle

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 13, 2024
@rjeli
Copy link
Contributor Author

rjeli commented Mar 13, 2024

Oh, I didn't even notice - I thought that referred to the developer console being open. Do you have a more general workaround in mind? I can figure it out otherwise

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 13, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#121820 (pattern analysis: Store field indices in `DeconstructedPat` to avoid virtual wildcards)
 - rust-lang#121908 (match lowering: don't collect test alternatives ahead of time)
 - rust-lang#122203 (Add `intrinsic_name` to get plain intrinsic name)
 - rust-lang#122226 (coverage: Remove or migrate all unstable values of `-Cinstrument-coverage`)
 - rust-lang#122255 (Use `min_exhaustive_patterns` in core & std)
 - rust-lang#122360 ( Don't Create `ParamCandidate` When Obligation Contains Errors )
 - rust-lang#122383 (Enable PR tracking review assignment for rust-lang/rust)
 - rust-lang#122386 (Move `Once` implementations to `sys`)
 - rust-lang#122400 (Fix ICE in diagnostics for parenthesized type arguments)
 - rust-lang#122410 (rustdoc: do not preload fonts when browsing locally)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 62e9e46 into rust-lang:master Mar 13, 2024
11 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 13, 2024
Rollup merge of rust-lang#122410 - rjeli:rustdoc-no-local-font-preload, r=notriddle

rustdoc: do not preload fonts when browsing locally

First PR, please let me know if I'm doing anything wrong.

As noted in rust-lang#98769, currently `cargo doc --open` on macOS/Safari (17.2.1) doesn't load fonts due to a CORS issue. (webkit issue [here](https://bugs.webkit.org/show_bug.cgi?id=249887)). This patch moves the font preloads inside a js if statement as suggested in the GitHub issue.

I tried something more elegant with iterating over a tera array of fonts, but ran into issues, so here's the dumb fix. Only thing to note is that the font path is interpolated into a template string, so HTML escaping works fine, but it will break if there's a backtick or `${` in the font path. Not sure if this is a big deal.
@rustbot rustbot added this to the 1.78.0 milestone Mar 13, 2024
@notriddle
Copy link
Contributor

Do you have a more general workaround in mind?

I was thinking of integrating a small HTTP server into Rustdoc1. That would definitely solve this problem, along with a few other problems like localStorage partitioning.

This solution is controversial, which is why I didn't block this PR it.

Footnotes

  1. If it's in Rustdoc, then Rustup and Cargo can both use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants