Skip to content

Commit

Permalink
Merge branch 'release/0.30.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Oct 31, 2022
2 parents 9ea6efa + 64931b1 commit a63c133
Show file tree
Hide file tree
Showing 15 changed files with 300 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MARKETING_VERSION = 0.30.3
MARKETING_VERSION = 0.30.4

8 changes: 8 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
3184AC6F288F2A1100C35E4B /* CookieNotificationAnimationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3184AC6E288F2A1100C35E4B /* CookieNotificationAnimationModel.swift */; };
31A031A6288191230090F792 /* CookieConsentAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A031A5288191230090F792 /* CookieConsentAnimationView.swift */; };
31A031A928819D920090F792 /* CookieConsentAnimationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A031A828819D920090F792 /* CookieConsentAnimationModel.swift */; };
31B4AF532901A4F20013585E /* NSEventExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B4AF522901A4F20013585E /* NSEventExtension.swift */; };
31B7C84F288008E00049841F /* CookieConsent.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 31B7C84E288008E00049841F /* CookieConsent.storyboard */; };
31B7C85128800A5D0049841F /* CookieConsentPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B7C85028800A5D0049841F /* CookieConsentPopover.swift */; };
31B9226C288054D5001F55B7 /* CookieConsentPopoverManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B9226B288054D5001F55B7 /* CookieConsentPopoverManager.swift */; };
Expand Down Expand Up @@ -708,6 +709,7 @@
B693956126F1C1BC0015B914 /* DownloadListStoreMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = B693956026F1C1BC0015B914 /* DownloadListStoreMock.swift */; };
B693956326F1C2A40015B914 /* FileDownloadManagerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = B693956226F1C2A40015B914 /* FileDownloadManagerMock.swift */; };
B693956926F352DB0015B914 /* DownloadsWebViewMock.m in Sources */ = {isa = PBXBuildFile; fileRef = B693956826F352DB0015B914 /* DownloadsWebViewMock.m */; };
B698E5042908011E00A746A8 /* AppKitPrivateMethodsAvailabilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B698E5032908011E00A746A8 /* AppKitPrivateMethodsAvailabilityTests.swift */; };
B69B503A2726A12500758A2B /* StatisticsLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69B50342726A11F00758A2B /* StatisticsLoader.swift */; };
B69B503B2726A12500758A2B /* Atb.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69B50352726A11F00758A2B /* Atb.swift */; };
B69B503C2726A12500758A2B /* StatisticsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69B50362726A12000758A2B /* StatisticsStore.swift */; };
Expand Down Expand Up @@ -855,6 +857,7 @@
3184AC6E288F2A1100C35E4B /* CookieNotificationAnimationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieNotificationAnimationModel.swift; sourceTree = "<group>"; };
31A031A5288191230090F792 /* CookieConsentAnimationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieConsentAnimationView.swift; sourceTree = "<group>"; };
31A031A828819D920090F792 /* CookieConsentAnimationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieConsentAnimationModel.swift; sourceTree = "<group>"; };
31B4AF522901A4F20013585E /* NSEventExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSEventExtension.swift; sourceTree = "<group>"; };
31B7C84E288008E00049841F /* CookieConsent.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CookieConsent.storyboard; sourceTree = "<group>"; };
31B7C85028800A5D0049841F /* CookieConsentPopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieConsentPopover.swift; sourceTree = "<group>"; };
31B9226B288054D5001F55B7 /* CookieConsentPopoverManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieConsentPopoverManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1553,6 +1556,7 @@
B693956626F352940015B914 /* TestsBridging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestsBridging.h; sourceTree = "<group>"; };
B693956726F352DB0015B914 /* DownloadsWebViewMock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DownloadsWebViewMock.h; sourceTree = "<group>"; };
B693956826F352DB0015B914 /* DownloadsWebViewMock.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DownloadsWebViewMock.m; sourceTree = "<group>"; };
B698E5032908011E00A746A8 /* AppKitPrivateMethodsAvailabilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppKitPrivateMethodsAvailabilityTests.swift; sourceTree = "<group>"; };
B69B50342726A11F00758A2B /* StatisticsLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatisticsLoader.swift; sourceTree = "<group>"; };
B69B50352726A11F00758A2B /* Atb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Atb.swift; sourceTree = "<group>"; };
B69B50362726A12000758A2B /* StatisticsStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatisticsStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2736,6 +2740,7 @@
4BA1A6CE258BF58C00F6F690 /* File System */,
B6AE74322609AFBB005B9B1A /* Progress */,
4B0511E6262CAB3700F6079C /* UserDefaultsWrapperUtilities.swift */,
B698E5032908011E00A746A8 /* AppKitPrivateMethodsAvailabilityTests.swift */,
B6B3E0952654DACD0040E0A2 /* UTTypeTests.swift */,
B693956626F352940015B914 /* TestsBridging.h */,
);
Expand Down Expand Up @@ -3667,6 +3672,7 @@
4B139AFC26B60BD800894F82 /* NSImageExtensions.swift */,
AA6EF9B2250785D5004754E6 /* NSMenuExtension.swift */,
AA72D5FD25FFF94E00C77619 /* NSMenuItemExtension.swift */,
31B4AF522901A4F20013585E /* NSEventExtension.swift */,
4B0511DF262CAA8600F6079C /* NSOpenPanelExtensions.swift */,
4B0135CD2729F1AA00D54834 /* NSPasteboardExtension.swift */,
AA5C8F5D2590EEE800748EB7 /* NSPointExtension.swift */,
Expand Down Expand Up @@ -4620,6 +4626,7 @@
4B9292A026670D2A00AD2C21 /* SpacerNode.swift in Sources */,
B6E61EE8263ACE16004E11AB /* UTType.swift in Sources */,
4BE6547F271FCD4D008D1D63 /* PasswordManagementCreditCardModel.swift in Sources */,
31B4AF532901A4F20013585E /* NSEventExtension.swift in Sources */,
85707F26276A335700DC0649 /* Onboarding.swift in Sources */,
AAFCB37F25E545D400859DD4 /* PublisherExtension.swift in Sources */,
B68C92C1274E3EF4002AC6B0 /* PopUpWindow.swift in Sources */,
Expand Down Expand Up @@ -5177,6 +5184,7 @@
3767190028E58513003A2A15 /* PrivatePlayerURLExtensionTests.swift in Sources */,
B6B3E0962654DACD0040E0A2 /* UTTypeTests.swift in Sources */,
4B2975992828285900187C4E /* FirefoxKeyReaderTests.swift in Sources */,
B698E5042908011E00A746A8 /* AppKitPrivateMethodsAvailabilityTests.swift in Sources */,
4B02199D25E063DE00ED7DEA /* FireproofingURLExtensionsTests.swift in Sources */,
4BB99D0F26FE1A84001E4761 /* ChromiumBookmarksReaderTests.swift in Sources */,
4BB99D1026FE1A84001E4761 /* FirefoxBookmarksReaderTests.swift in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions DuckDuckGo/Common/Extensions/NSEventExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// NSEventExtension.swift
//
// Copyright © 2022 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

extension NSEvent {
static func isContextClick(_ event: NSEvent) -> Bool {
let isControlClick = event.type == .leftMouseDown && (event.modifierFlags.rawValue & NSEvent.ModifierFlags.control.rawValue != 0)
let isRightClick = event.type == .rightMouseDown
return isControlClick || isRightClick
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/Extensions/NSViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension NSView {

func mouseLocationInsideBounds(_ point: NSPoint?) -> NSPoint? {
withMouseLocationInViewCoordinates(point) { locationInView in
guard self.bounds.contains(locationInView) else { return nil }
guard self.visibleRect.contains(locationInView) else { return nil }
return locationInView
}
}
Expand Down
23 changes: 23 additions & 0 deletions DuckDuckGo/Common/Extensions/NSWindowExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,27 @@ extension NSWindow {
setFrameOrigin(frameOrigin)
}

private static let lastLeftHitKey = "_lastLeftHit"
var lastLeftHit: NSView? {
return try? NSException.catch {
self.value(forKey: Self.lastLeftHitKey) as? NSView
}
}

func evilHackToClearLastLeftHitInWindow() {
guard let oldValue = self.lastLeftHit else { return }
let oldValueRetainCount = CFGetRetainCount(oldValue)
defer {
// compensate unbalanced release call
if CFGetRetainCount(oldValue) < oldValueRetainCount {
_=Unmanaged.passUnretained(oldValue).retain()
}
}
NSException.try {
autoreleasepool {
self.setValue(nil, forKey: Self.lastLeftHitKey)
}
}
}

}
28 changes: 1 addition & 27 deletions DuckDuckGo/Common/View/AppKit/MouseClickView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,43 +40,19 @@ final class MouseClickView: NSView {

weak var delegate: MouseClickViewDelegate?

private func repostMultiClickEventIfNeeded(_ event: NSEvent) -> Bool {
// don't let more-than-doubleclicks get in
guard event.clickCount > 2,
let newEvent = NSEvent.mouseEvent(with: event.type,
location: event.locationInWindow,
modifierFlags: event.modifierFlags,
timestamp: event.timestamp,
windowNumber: event.windowNumber,
context: nil,
eventNumber: event.eventNumber,
clickCount: 1,
pressure: event.pressure),
let window = self.window
else { return false }

// break the growing clickCount event cycle by sending a new 1-click event to the window
window.postEvent(newEvent, atStart: true)
return true
}

override func mouseDown(with event: NSEvent) {
let coordinateInWindow = event.locationInWindow
let coordinateInView = self.convert(coordinateInWindow, from: nil)

if !self.bounds.contains(coordinateInView) {
return
}

guard !repostMultiClickEventIfNeeded(event) else { return }

super.mouseDown(with: event)
delegate?.mouseClickView(self, mouseDownEvent: event)
}

override func mouseUp(with event: NSEvent) {
guard !repostMultiClickEventIfNeeded(event) else { return }

super.mouseUp(with: event)
delegate?.mouseClickView(self, mouseUpEvent: event)
}
Expand All @@ -88,8 +64,6 @@ final class MouseClickView: NSView {
}

override func otherMouseDown(with event: NSEvent) {
guard !repostMultiClickEventIfNeeded(event) else { return }

super.otherMouseDown(with: event)

delegate?.mouseClickView(self, otherMouseDownEvent: event)
Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/Common/View/AppKit/WindowDraggingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ final class WindowDraggingView: NSView {
}

override func mouseDown(with event: NSEvent) {
if NSEvent.isContextClick(event) {
super.mouseDown(with: event)
return
}

mouseDownSubject.send(event)

if event.clickCount == 2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import BrowserServicesKit
final class AppPrivacyConfigurationDataProvider: EmbeddedDataProvider {

public struct Constants {
public static let embeddedDataETag = "\"935fa59752c73635441e270a83b7e232\""
public static let embeddedDataSHA = "2bded09f6e401c16fa071629b95d9a3cb4707e2c37de0ddf306c7866016a44ed"
public static let embeddedDataETag = "\"05b2307e4d4ee1e23458b8417031812e\""
public static let embeddedDataSHA = "3e2f55fa1a687b5f1255b243b028b3469b61f7084a685b4c2ef2d205ae31933b"
}

var embeddedDataEtag: String {
Expand Down
Loading

0 comments on commit a63c133

Please sign in to comment.