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

Dev tools visibility fix #457

Merged
merged 6 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion DuckDuckGo/BrowserTab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ extension Tab: UserContentControllerDelegate {

}

extension Tab: ChildAutofillUserScriptDelegate {
extension Tab: BrowserTabViewControllerClickDelegate {
func browserTabViewController(_ browserTabViewController: BrowserTabViewController, didClickAtPoint: NSPoint) {
guard let autofillScript = autofillScript else { return }
autofillScript.clickPoint = didClickAtPoint
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/BrowserTab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import Combine
import SwiftUI
import BrowserServicesKit

protocol ChildAutofillUserScriptDelegate: AnyObject {
protocol BrowserTabViewControllerClickDelegate: AnyObject {
func browserTabViewController(_ browserTabViewController: BrowserTabViewController, didClickAtPoint: CGPoint)
}

// swiftlint:disable type_body_length
// swiftlint:disable file_length
// swiftlint:disable type_body_length

final class BrowserTabViewController: NSViewController {

Expand Down
19 changes: 15 additions & 4 deletions DuckDuckGo/BrowserTab/View/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ final class WebView: WKWebView {
"WKMenuItemIdentifierDownloadLinkedFile": UserText.downloadLinkedFileAs,
"WKMenuItemIdentifierSearchWeb": UserText.searchWithDuckDuckGo
]

deinit {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also reorganized WebView.swift and added few marks. Hope it is ok

self.configuration.userContentController.removeAllUserScripts()
}

// MARK: - Zoom

static private let maxZoomLevel: CGFloat = 3.0
static private let minZoomLevel: CGFloat = 0.5
Expand Down Expand Up @@ -85,10 +91,6 @@ final class WebView: WKWebView {
self.zoomLevel = max(self.zoomLevel - Self.zoomLevelStep, Self.minZoomLevel)
}

deinit {
self.configuration.userContentController.removeAllUserScripts()
}

// MARK: - Back/Forward Navigation

var frozenCanGoBack: Bool?
Expand Down Expand Up @@ -142,6 +144,13 @@ final class WebView: WKWebView {

// MARK: - Developer Tools

override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
if self.isInspectorShown {
self.openDeveloperTools()
}
}

@nonobjc var mainFrame: AnyObject? {
guard self.responds(to: NSSelectorFromString("_mainFrame")) else {
assertionFailure("WKWebView does not respond to _mainFrame")
Expand Down Expand Up @@ -186,6 +195,8 @@ final class WebView: WKWebView {
inspectorPerform("showResources")
}

// MARK: - Fullscreen

var fullscreenWindowController: NSWindowController? {
guard let fullscreenWindowController = self.window?.windowController,
fullscreenWindowController.className.contains("FullScreen")
Expand Down