Skip to content

Add font size up/down support and allow anchor links for What's New page #1561

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

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/MacVim/MMWhatsNewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ - (void)windowWillClose:(NSNotification *)notification
return;
}

// Font size delegates for menu items

#if defined(MAC_OS_VERSION_11_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
- (IBAction)fontSizeUp:(id)sender
{
if (@available(macos 11.0, *)) {
CGFloat pageZoom = _webView.pageZoom + 0.25;
_webView.pageZoom = pageZoom > 3.0 ? 3.0 : pageZoom;
}
}

- (IBAction)fontSizeDown:(id)sender
{
if (@available(macos 11.0, *)) {
CGFloat pageZoom = _webView.pageZoom - 0.25;
_webView.pageZoom = pageZoom < 0.25 ? 0.25 : pageZoom;
}
}
#endif

// WKNavigationDelegate methods

/// Tells web view how to handle links and navigation. Current behavior is
Expand All @@ -149,14 +169,21 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
NSURLRequest *request = navigationAction.request;
NSURL *requestURL = request.URL;

if ([requestURL isEqual:_whatsNewURL]) {
if ([requestURL.scheme isEqual:_whatsNewURL.scheme] &&
[requestURL.host isEqual:_whatsNewURL.host] &&
[requestURL.port isEqual:_whatsNewURL.port] &&
[requestURL.path isEqual:_whatsNewURL.path] &&
[requestURL.query isEqual:_whatsNewURL.query])
{
// Only allow if everything except for fragment is the same (which
// we allow so that table of contents anchor links would work).
decisionHandler(WKNavigationActionPolicyAllow);
}
else {
// We want to open any links in the release notes with a browser instead.
decisionHandler(WKNavigationActionPolicyCancel);

if ([request.URL.scheme isEqualToString:@"https"]) {
if ([requestURL.scheme isEqualToString:@"https"]) {
// Just try to be sane and only open https:// urls. There should be
// no reason why the release notes should contain other schemes and it
// would be an indication something is wrong or malicious (e.g. file:
Expand Down
Loading