Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Submodules/duckduckgo-find-in-page"]
path = Submodules/duckduckgo-find-in-page
url = git@github.com:more-duckduckgo-org/duckduckgo-find-in-page.git
[submodule "Submodules/privacy-reference-tests"]
path = Submodules/privacy-reference-tests
url = git@github.com:duckduckgo/privacy-reference-tests.git
2 changes: 1 addition & 1 deletion Configuration/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = DEBUG=1 CI=1 $(inherite
GCC_PREPROCESSOR_DEFINITIONS[config=Debug][arch=*][sdk=*] = DEBUG=1 $(inherited)
GCC_PREPROCESSOR_DEFINITIONS[config=Review][arch=*][sdk=*] = REVIEW=1 $(inherited)

MACOSX_DEPLOYMENT_TARGET = 10.15
MACOSX_DEPLOYMENT_TARGET = 10.15.4

PRODUCT_MODULE_NAME = $(TARGET_NAME:c99extidentifier)

Expand Down
39 changes: 0 additions & 39 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
31F28C5328C8EECA00119F70 /* DuckPlayerSchemeHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31F28C5228C8EECA00119F70 /* DuckPlayerSchemeHandler.swift */; };
31F28C5828C8EEDB00119F70 /* youtube_player_template.html in Resources */ = {isa = PBXBuildFile; fileRef = 31F28C5528C8EEDB00119F70 /* youtube_player_template.html */; };
31F7F2A6288AD2CA001C0D64 /* NavigationBarBadgeAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31F7F2A5288AD2CA001C0D64 /* NavigationBarBadgeAnimationView.swift */; };
336D5B18262D8D3C0052E0C9 /* findinpage.js in Resources */ = {isa = PBXBuildFile; fileRef = 336D5AEF262D8D3C0052E0C9 /* findinpage.js */; };
3701C9CE29BD040C00305B15 /* FirefoxBerkeleyDatabaseReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3701C9CD29BD040900305B15 /* FirefoxBerkeleyDatabaseReader.swift */; };
3701C9CF29BD040C00305B15 /* FirefoxBerkeleyDatabaseReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3701C9CD29BD040900305B15 /* FirefoxBerkeleyDatabaseReader.swift */; };
37054FC92873301700033B6F /* PinnedTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37054FC82873301700033B6F /* PinnedTabView.swift */; };
Expand Down Expand Up @@ -463,7 +462,6 @@
3706FC12293F65D500E42796 /* MenuItemSelectors.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DA06E52913F39400225DE2 /* MenuItemSelectors.swift */; };
3706FC13293F65D500E42796 /* FaviconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85589E9927BFE3C30038AD11 /* FaviconView.swift */; };
3706FC14293F65D500E42796 /* OnboardingFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85707F2B276A364E00DC0649 /* OnboardingFlow.swift */; };
3706FC15293F65D500E42796 /* FindInPageUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A011E925B4D4CA00FA6A0C /* FindInPageUserScript.swift */; };
3706FC16293F65D500E42796 /* PasswordManagementLoginModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE6547C271FCD4D008D1D63 /* PasswordManagementLoginModel.swift */; };
3706FC17293F65D500E42796 /* TabViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA9FF95A24A1EFC20039E328 /* TabViewModel.swift */; };
3706FC18293F65D500E42796 /* TabDragAndDropManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA9E9A5D25A4867200D1959D /* TabDragAndDropManager.swift */; };
Expand Down Expand Up @@ -669,7 +667,6 @@
3706FCF6293F65D500E42796 /* trackers-2.json in Resources */ = {isa = PBXBuildFile; fileRef = AA3439742754D55100B241FA /* trackers-2.json */; };
3706FCF7293F65D500E42796 /* ProximaNova-Reg-webfont.woff2 in Resources */ = {isa = PBXBuildFile; fileRef = EAA29AE8278D2E43007070CF /* ProximaNova-Reg-webfont.woff2 */; };
3706FCF8293F65D500E42796 /* clickToLoad.js in Resources */ = {isa = PBXBuildFile; fileRef = EAFAD6C92728BD1200F9DF00 /* clickToLoad.js */; };
3706FCF9293F65D500E42796 /* findinpage.js in Resources */ = {isa = PBXBuildFile; fileRef = 336D5AEF262D8D3C0052E0C9 /* findinpage.js */; };
3706FDDA293F661700E42796 /* EmbeddedTrackerDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9833913227AAAEEE00DAF119 /* EmbeddedTrackerDataTests.swift */; };
3706FDDB293F661700E42796 /* AutofillPreferencesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3776583027F8325B009A6B35 /* AutofillPreferencesTests.swift */; };
3706FDDC293F661700E42796 /* FileManagerExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B67C6C462654C643006C872E /* FileManagerExtensionTests.swift */; };
Expand Down Expand Up @@ -1259,7 +1256,6 @@
85A0116925AF1D8900FA6A0C /* FindInPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A0116825AF1D8900FA6A0C /* FindInPageViewController.swift */; };
85A0117425AF2EDF00FA6A0C /* FindInPage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 85A0117325AF2EDF00FA6A0C /* FindInPage.storyboard */; };
85A0118225AF60E700FA6A0C /* FindInPageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A0118125AF60E700FA6A0C /* FindInPageModel.swift */; };
85A011EA25B4D4CA00FA6A0C /* FindInPageUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A011E925B4D4CA00FA6A0C /* FindInPageUserScript.swift */; };
85AC3AEF25D5CE9800C7D2AA /* UserScripts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85AC3AEE25D5CE9800C7D2AA /* UserScripts.swift */; };
85AC3AF725D5DBFD00C7D2AA /* DataExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85AC3AF625D5DBFD00C7D2AA /* DataExtension.swift */; };
85AC3B0525D6B1D800C7D2AA /* ScriptSourceProviding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85AC3B0425D6B1D800C7D2AA /* ScriptSourceProviding.swift */; };
Expand Down Expand Up @@ -1977,8 +1973,6 @@
31F28C5528C8EEDB00119F70 /* youtube_player_template.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = youtube_player_template.html; sourceTree = "<group>"; };
31F7F2A5288AD2CA001C0D64 /* NavigationBarBadgeAnimationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarBadgeAnimationView.swift; sourceTree = "<group>"; };
336B39E22726B4B700C417D3 /* LocalUnprotectedDomains.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalUnprotectedDomains.swift; sourceTree = "<group>"; };
336D5AEF262D8D3C0052E0C9 /* findinpage.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = findinpage.js; sourceTree = "<group>"; };
339A6B5726A044BA00E3DAE8 /* duckduckgo-privacy-dashboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "duckduckgo-privacy-dashboard"; path = "Submodules/duckduckgo-privacy-dashboard"; sourceTree = SOURCE_ROOT; };
3701C9CD29BD040900305B15 /* FirefoxBerkeleyDatabaseReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirefoxBerkeleyDatabaseReader.swift; sourceTree = "<group>"; };
37054FC82873301700033B6F /* PinnedTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinnedTabView.swift; sourceTree = "<group>"; };
37054FCD2876472D00033B6F /* WebViewSnapshotView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewSnapshotView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2338,7 +2332,6 @@
85A0116825AF1D8900FA6A0C /* FindInPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindInPageViewController.swift; sourceTree = "<group>"; };
85A0117325AF2EDF00FA6A0C /* FindInPage.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = FindInPage.storyboard; sourceTree = "<group>"; };
85A0118125AF60E700FA6A0C /* FindInPageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindInPageModel.swift; sourceTree = "<group>"; };
85A011E925B4D4CA00FA6A0C /* FindInPageUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindInPageUserScript.swift; sourceTree = "<group>"; };
85AC3AEE25D5CE9800C7D2AA /* UserScripts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserScripts.swift; sourceTree = "<group>"; };
85AC3AF625D5DBFD00C7D2AA /* DataExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtension.swift; sourceTree = "<group>"; };
85AC3B0425D6B1D800C7D2AA /* ScriptSourceProviding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptSourceProviding.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3168,23 +3161,6 @@
path = BadgeAnimations;
sourceTree = "<group>";
};
336D5AEA262D8D3C0052E0C9 /* duckduckgo-find-in-page */ = {
isa = PBXGroup;
children = (
336D5AEE262D8D3C0052E0C9 /* dist */,
);
name = "duckduckgo-find-in-page";
path = "Submodules/duckduckgo-find-in-page";
sourceTree = SOURCE_ROOT;
};
336D5AEE262D8D3C0052E0C9 /* dist */ = {
isa = PBXGroup;
children = (
336D5AEF262D8D3C0052E0C9 /* findinpage.js */,
);
path = dist;
sourceTree = "<group>";
};
373A1AA6283ECC8000586521 /* HTML */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3564,15 +3540,6 @@
path = Database;
sourceTree = "<group>";
};
4B677447255DBF1400025BD8 /* Submodules */ = {
isa = PBXGroup;
children = (
339A6B5726A044BA00E3DAE8 /* duckduckgo-privacy-dashboard */,
336D5AEA262D8D3C0052E0C9 /* duckduckgo-find-in-page */,
);
name = Submodules;
sourceTree = "<group>";
};
4B70BFFD27B0793D000386ED /* CrashReports */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4080,7 +4047,6 @@
children = (
85A0117325AF2EDF00FA6A0C /* FindInPage.storyboard */,
85A0118125AF60E700FA6A0C /* FindInPageModel.swift */,
85A011E925B4D4CA00FA6A0C /* FindInPageUserScript.swift */,
85A0116825AF1D8900FA6A0C /* FindInPageViewController.swift */,
);
path = FindInPage;
Expand Down Expand Up @@ -4425,7 +4391,6 @@
4B677422255DBEB800025BD8 /* SmarterEncryption */,
B68458AE25C7E75100DC17B6 /* StateRestoration */,
B6A9E44E26142AF90067D1B9 /* Statistics */,
4B677447255DBF1400025BD8 /* Submodules */,
AACB8E7224A4C8BC005F2218 /* Suggestions */,
3775913429AB99DA00E26367 /* Sync */,
AA86491B24D837DE001BABEE /* Tab */,
Expand Down Expand Up @@ -6191,7 +6156,6 @@
3706FCF6293F65D500E42796 /* trackers-2.json in Resources */,
3706FCF7293F65D500E42796 /* ProximaNova-Reg-webfont.woff2 in Resources */,
3706FCF8293F65D500E42796 /* clickToLoad.js in Resources */,
3706FCF9293F65D500E42796 /* findinpage.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -6307,7 +6271,6 @@
AA34397A2754D55100B241FA /* trackers-2.json in Resources */,
EAA29AEA278D2E43007070CF /* ProximaNova-Reg-webfont.woff2 in Resources */,
EAFAD6CA2728BD1200F9DF00 /* clickToLoad.js in Resources */,
336D5B18262D8D3C0052E0C9 /* findinpage.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -6903,7 +6866,6 @@
3706FC13293F65D500E42796 /* FaviconView.swift in Sources */,
3706FC14293F65D500E42796 /* OnboardingFlow.swift in Sources */,
EEC8EB3E2982CA3B0065AA39 /* JSAlertViewModel.swift in Sources */,
3706FC15293F65D500E42796 /* FindInPageUserScript.swift in Sources */,
3706FC16293F65D500E42796 /* PasswordManagementLoginModel.swift in Sources */,
3706FC17293F65D500E42796 /* TabViewModel.swift in Sources */,
3706FC18293F65D500E42796 /* TabDragAndDropManager.swift in Sources */,
Expand Down Expand Up @@ -7780,7 +7742,6 @@
B6DA06E62913F39400225DE2 /* MenuItemSelectors.swift in Sources */,
85589E9A27BFE3C30038AD11 /* FaviconView.swift in Sources */,
85707F2C276A364E00DC0649 /* OnboardingFlow.swift in Sources */,
85A011EA25B4D4CA00FA6A0C /* FindInPageUserScript.swift in Sources */,
4BE65480271FCD4D008D1D63 /* PasswordManagementLoginModel.swift in Sources */,
AA9FF95B24A1EFC20039E328 /* TabViewModel.swift in Sources */,
AA9E9A5E25A4867200D1959D /* TabDragAndDropManager.swift in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions DuckDuckGo/Common/Extensions/WKWebView+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ typedef NS_OPTIONS(NSUInteger, _WKCaptureDevices) {
_WKCaptureDeviceDisplay = 1 << 2,
} API_AVAILABLE(macosx(10.3));

typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
_WKFindOptionsCaseInsensitive = 1 << 0,
_WKFindOptionsAtWordStarts = 1 << 1,
_WKFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
_WKFindOptionsBackwards = 1 << 3,
_WKFindOptionsWrapAround = 1 << 4,
_WKFindOptionsShowOverlay = 1 << 5,
_WKFindOptionsShowFindIndicator = 1 << 6,
_WKFindOptionsShowHighlight = 1 << 7,
_WKFindOptionsNoIndexChange = 1 << 8,
_WKFindOptionsDetermineMatchIndex = 1 << 9,
} API_AVAILABLE(macos(10.10));

@interface WKWebView (Private)

- (void)_restoreFromSessionStateData:(NSData *)data;
Expand Down
36 changes: 6 additions & 30 deletions DuckDuckGo/FindInPage/FindInPageModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@ import WebKit
final class FindInPageModel {

@Published private(set) var text: String = ""
@Published private(set) var currentSelection: Int = 1
@Published private(set) var matchesFound: Int = 0
@Published private(set) var currentSelection: Int?
@Published private(set) var matchesFound: UInt?
@Published private(set) var isVisible: Bool = false

weak var webView: WKWebView?

func update(currentSelection: Int?, matchesFound: Int?) {
self.currentSelection = currentSelection ?? self.currentSelection
self.matchesFound = matchesFound ?? self.matchesFound
func update(currentSelection: Int?, matchesFound: UInt?) {
self.currentSelection = currentSelection
self.matchesFound = matchesFound
}

func show(with webView: WKWebView) {
self.webView = webView
func show() {
isVisible = true
}

Expand All @@ -44,27 +41,6 @@ final class FindInPageModel {

func find(_ text: String) {
self.text = text
evaluate("window.__firefox__.find('\(text.escapedJavaScriptString())')")
}

func findDone() {
evaluate("window.__firefox__.findDone()")
}

func findNext() {
evaluate("window.__firefox__.findNext()")
}

func findPrevious() {
evaluate("window.__firefox__.findPrevious()")
}

private func evaluate(_ js: String) {
if #available(macOS 11.0, *) {
webView?.evaluateJavaScript(js, in: nil, in: WKContentWorld.defaultClient)
} else {
webView?.evaluateJavaScript(js)
}
}

}
42 changes: 0 additions & 42 deletions DuckDuckGo/FindInPage/FindInPageUserScript.swift

This file was deleted.

14 changes: 10 additions & 4 deletions DuckDuckGo/FindInPage/FindInPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,23 @@ final class FindInPageViewController: NSViewController {

private func rebuildStatus() {
guard let model = model else { return }
statusField.stringValue = String(format: UserText.findInPage, model.currentSelection, model.matchesFound)
statusField.stringValue = {
guard let matchesFound = model.matchesFound,
let currentSelection = model.currentSelection else { return "" }
return String(format: UserText.findInPage, currentSelection, matchesFound)
}()
}

private func updateView(firstResponder: Bool) {
focusRingView.updateView(stroke: firstResponder)
}

private func updateFieldStates() {
statusField.isHidden = model?.text.isEmpty ?? true
nextButton.isEnabled = model?.matchesFound ?? 0 > 0
previousButton.isEnabled = model?.matchesFound ?? 0 > 0
guard let model else { return }
statusField.isHidden = model.text.isEmpty
// enable next/prev buttons by default if current status is unknown (fallback to public find API)
nextButton.isEnabled = model.matchesFound.map { $0 > 0 } ?? !model.text.isEmpty
previousButton.isEnabled = model.matchesFound.map { $0 > 0 } ?? !model.text.isEmpty
}

private func listenForTextFieldResponderNotifications() {
Expand Down
Loading