Skip to content

Commit ae1d259

Browse files
committed
[Swift in WebKit] Use swift-format to lint WebKit code
https://bugs.webkit.org/show_bug.cgi?id=293842 rdar://152347799 Reviewed by Abrar Rahman Protyasha. Work towards having consistently formatted and linted Swift code; lint the WebKit codebase for improved correctness and readability. This is excluding WebKitSwift for now. * Source/WebKit/Shared/AuxiliaryProcessExtensions/GPUProcessExtension.swift: * Source/WebKit/Shared/AuxiliaryProcessExtensions/NetworkingProcessExtension.swift: * Source/WebKit/Shared/AuxiliaryProcessExtensions/WebContentProcessExtension.swift: * Source/WebKit/UIProcess/API/Cocoa/ObjectiveCBlockConversions.swift: - Replace block quotes. * Source/WebKit/UIProcess/API/Cocoa/WKContextMenuElementInfoAdapter.swift: - Ignore AllPublicDeclarationsHaveDocumentation due to SPI. * Source/WebKit/UIProcess/API/Cocoa/WebKitSwiftOverlay.swift: - Replace block quotes. - Ignore AllPublicDeclarationsHaveDocumentation due to pre-existing API documentation. - Use null coalescing instead of force-unwrapping - Add missing documentation for some WKWebExtension initializers, based on their Objective-C documentation. - Add missing documentation for `WKWebsiteDataStore.proxyConfigurations` based on its Objective-C documentation. * Source/WebKit/UIProcess/API/Swift/URLSchemeHandler.swift: - Add missing docs. * Source/WebKit/UIProcess/API/Swift/WebPage+BackForwardList.swift: - Add missing docs. * Source/WebKit/UIProcess/API/Swift/WebPage+Configuration.swift: - Add missing docs. - Fix variable naming. * Source/WebKit/UIProcess/API/Swift/WebPage+DialogPresenting.swift: - Fix doc format. * Source/WebKit/UIProcess/API/Swift/WebPage+Navigation.swift: - Fix doc format. - Ignore AllPublicDeclarationsHaveDocumentation due to SPI. * Source/WebKit/UIProcess/API/Swift/WebPage+NavigationDeciding.swift: - Ignore AllPublicDeclarationsHaveDocumentation due to SPI. - Add a FIXME to SPI that should be API. * Source/WebKit/UIProcess/API/Swift/WebPage+NavigationPreferences.swift: - Fix variable naming * Source/WebKit/UIProcess/API/Swift/WebPage.swift: - Fix doc format - Fix parameter and variable naming - Add missing docs - Ignore AllPublicDeclarationsHaveDocumentation in some places due to SPI. * Source/WebKit/UIProcess/Cocoa/GroupActivities/WKGroupSession.swift: - Fix variable naming - Justify force-unwrapping * Source/WebKit/UIProcess/Cocoa/RunLoopQueue.swift: - Add documentation (even though this is SPI). * Source/WebKit/UIProcess/Cocoa/TextExtraction/WKTextExtractionItem.swift: - Fix variable naming. * Source/WebKit/UIProcess/Cocoa/TextExtraction/WKWebView+TextExtraction.swift: - Ignore NoLeadingUnderscores because it is a false-positive. * Source/WebKit/UIProcess/Cocoa/WKNavigationDelegateAdapter.swift: - Ignore NoLeadingUnderscores because it is a false-positive. * Source/WebKit/UIProcess/Cocoa/WKScrollGeometryAdapter.swift: * Source/WebKit/UIProcess/Cocoa/WKUIDelegateAdapter.swift: * Source/WebKit/UIProcess/Cocoa/WebPageWebView.swift: - Ignore AllPublicDeclarationsHaveDocumentation due to SPI. Canonical link: https://commits.webkit.org/295655@main
1 parent 478041e commit ae1d259

24 files changed

+305
-159
lines changed

Source/WebKit/Shared/AuxiliaryProcessExtensions/GPUProcessExtension.swift

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
/*
2-
* Copyright (C) 2023 Apple Inc. All rights reserved.
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions
6-
* are met:
7-
* 1. Redistributions of source code must retain the above copyright
8-
* notice, this list of conditions and the following disclaimer.
9-
* 2. Redistributions in binary form must reproduce the above copyright
10-
* notice, this list of conditions and the following disclaimer in the
11-
* documentation and/or other materials provided with the distribution.
12-
*
13-
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15-
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23-
* THE POSSIBILITY OF SUCH DAMAGE.
24-
*/
1+
// Copyright (C) 2023 Apple Inc. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// 1. Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// 2. Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
//
12+
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14+
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16+
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22+
// THE POSSIBILITY OF SUCH DAMAGE.
2523

2624
import BrowserEngineKit
2725

Source/WebKit/Shared/AuxiliaryProcessExtensions/NetworkingProcessExtension.swift

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
/*
2-
* Copyright (C) 2023 Apple Inc. All rights reserved.
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions
6-
* are met:
7-
* 1. Redistributions of source code must retain the above copyright
8-
* notice, this list of conditions and the following disclaimer.
9-
* 2. Redistributions in binary form must reproduce the above copyright
10-
* notice, this list of conditions and the following disclaimer in the
11-
* documentation and/or other materials provided with the distribution.
12-
*
13-
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15-
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23-
* THE POSSIBILITY OF SUCH DAMAGE.
24-
*/
1+
// Copyright (C) 2023 Apple Inc. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// 1. Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// 2. Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
//
12+
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14+
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16+
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22+
// THE POSSIBILITY OF SUCH DAMAGE.
2523

2624
import BrowserEngineKit
2725

Source/WebKit/Shared/AuxiliaryProcessExtensions/WebContentProcessExtension.swift

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
/*
2-
* Copyright (C) 2023 Apple Inc. All rights reserved.
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions
6-
* are met:
7-
* 1. Redistributions of source code must retain the above copyright
8-
* notice, this list of conditions and the following disclaimer.
9-
* 2. Redistributions in binary form must reproduce the above copyright
10-
* notice, this list of conditions and the following disclaimer in the
11-
* documentation and/or other materials provided with the distribution.
12-
*
13-
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15-
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23-
* THE POSSIBILITY OF SUCH DAMAGE.
24-
*/
1+
// Copyright (C) 2023 Apple Inc. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// 1. Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// 2. Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
//
12+
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14+
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16+
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22+
// THE POSSIBILITY OF SUCH DAMAGE.
2523

2624
import BrowserEngineKit
2725

Source/WebKit/UIProcess/API/Cocoa/ObjectiveCBlockConversions.swift

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
/*
2-
* Copyright (C) 2020 Apple Inc. All rights reserved.
3-
*
4-
* Redistribution and use in source and binary forms, with or without
5-
* modification, are permitted provided that the following conditions
6-
* are met:
7-
* 1. Redistributions of source code must retain the above copyright
8-
* notice, this list of conditions and the following disclaimer.
9-
* 2. Redistributions in binary form must reproduce the above copyright
10-
* notice, this list of conditions and the following disclaimer in the
11-
* documentation and/or other materials provided with the distribution.
12-
*
13-
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15-
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23-
* THE POSSIBILITY OF SUCH DAMAGE.
24-
*/
1+
// Copyright (C) 2020 Apple Inc. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// 1. Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// 2. Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
//
12+
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14+
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16+
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22+
// THE POSSIBILITY OF SUCH DAMAGE.
2523

2624
/// A family of conversions for translating between Swift blocks expecting a `Result<V, Error>` and
2725
/// Objective-C callbacks of the form `(T?, Error?)`.

Source/WebKit/UIProcess/API/Cocoa/WKContextMenuElementInfoAdapter.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@
2626
public import Foundation
2727
internal import WebKit_Internal
2828

29+
// SPI for the cross-import overlay.
30+
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
2931
@_spi(CrossImportOverlay)
3032
public struct WKContextMenuElementInfoAdapter {
33+
// SPI for the cross-import overlay.
34+
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
3135
public let linkURL: URL?
3236
}
3337

Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences+Extras.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension WKWebpagePreferences {
5757
self.preferredHTTPSNavigationPolicy = .init(wrapped.preferredHTTPSNavigationPolicy)
5858
self.allowsContentJavaScript = wrapped.allowsContentJavaScript
5959

60-
if let isLockdownModeEnabled = wrapped._isLockdownModeEnabled, self.isLockdownModeEnabled != isLockdownModeEnabled {
60+
if let isLockdownModeEnabled = wrapped.backingIsLockdownModeEnabled, self.isLockdownModeEnabled != isLockdownModeEnabled {
6161
self.isLockdownModeEnabled = isLockdownModeEnabled
6262
}
6363
}

Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore+SwiftOverlay.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ extension WKWebsiteDataStore {
3636
set { __proxyConfigurations = newValue.map(\._nw) }
3737
}
3838
}
39-

0 commit comments

Comments
 (0)