Title: [279860] trunk/Source
Revision
279860
Author
[email protected]
Date
2021-07-12 18:22:14 -0700 (Mon, 12 Jul 2021)

Log Message

[Cocoa] Turn on `USE(OS_STATE)` when building with a non-Apple-internal SDK
https://bugs.webkit.org/show_bug.cgi?id=227884

Reviewed by Tim Horton.

Source/WebKit:

Instead of directly importing <os/state_private.h>, introduce a new SPI header (OSStateSPI.h) that simply
includes <os/state_private.h> on internal builds, and falls back to function declarations when using the non-
internal SDK.

* Platform/spi/Cocoa/OSStateSPI.h: Added.
* WebKit.xcodeproj/project.pbxproj:

Drive-by fix: additionally restore the minimum `objectVersion` to 52 rather than 54. This was unintentionally
bumped in r279133.

* WebProcess/cocoa/WebProcessCocoa.mm:

Source/WTF:

Enable the compile-time flag for all Cocoa builds.

* wtf/PlatformUse.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (279859 => 279860)


--- trunk/Source/WTF/ChangeLog	2021-07-13 00:33:10 UTC (rev 279859)
+++ trunk/Source/WTF/ChangeLog	2021-07-13 01:22:14 UTC (rev 279860)
@@ -1,3 +1,14 @@
+2021-07-12  Wenson Hsieh  <[email protected]>
+
+        [Cocoa] Turn on `USE(OS_STATE)` when building with a non-Apple-internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=227884
+
+        Reviewed by Tim Horton.
+
+        Enable the compile-time flag for all Cocoa builds.
+
+        * wtf/PlatformUse.h:
+
 2021-07-12  Chris Fleizach  <[email protected]>
 
         AX: Make WebKit observe spatial audio accessibility settings

Modified: trunk/Source/WTF/wtf/PlatformUse.h (279859 => 279860)


--- trunk/Source/WTF/wtf/PlatformUse.h	2021-07-13 00:33:10 UTC (rev 279859)
+++ trunk/Source/WTF/wtf/PlatformUse.h	2021-07-13 01:22:14 UTC (rev 279860)
@@ -231,7 +231,7 @@
 #define USE_OS_LOG 1
 #endif
 
-#if PLATFORM(COCOA) && USE(APPLE_INTERNAL_SDK)
+#if PLATFORM(COCOA)
 #define USE_OS_STATE 1
 #endif
 

Modified: trunk/Source/WebKit/ChangeLog (279859 => 279860)


--- trunk/Source/WebKit/ChangeLog	2021-07-13 00:33:10 UTC (rev 279859)
+++ trunk/Source/WebKit/ChangeLog	2021-07-13 01:22:14 UTC (rev 279860)
@@ -1,3 +1,22 @@
+2021-07-12  Wenson Hsieh  <[email protected]>
+
+        [Cocoa] Turn on `USE(OS_STATE)` when building with a non-Apple-internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=227884
+
+        Reviewed by Tim Horton.
+
+        Instead of directly importing <os/state_private.h>, introduce a new SPI header (OSStateSPI.h) that simply
+        includes <os/state_private.h> on internal builds, and falls back to function declarations when using the non-
+        internal SDK.
+
+        * Platform/spi/Cocoa/OSStateSPI.h: Added.
+        * WebKit.xcodeproj/project.pbxproj:
+
+        Drive-by fix: additionally restore the minimum `objectVersion` to 52 rather than 54. This was unintentionally
+        bumped in r279133.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+
 2021-07-12  Garrett Davidson  <[email protected]>
 
         _WKWebAuthenticationPanel escapes slashes in origin

Added: trunk/Source/WebKit/Platform/spi/Cocoa/OSStateSPI.h (0 => 279860)


--- trunk/Source/WebKit/Platform/spi/Cocoa/OSStateSPI.h	                        (rev 0)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/OSStateSPI.h	2021-07-13 01:22:14 UTC (rev 279860)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(OS_STATE)
+
+#if USE(APPLE_INTERNAL_SDK)
+#include <os/state_private.h>
+#else
+
+#include <os/base.h>
+
+OS_ENUM(os_state_reason, uint32_t,
+    OS_STATE_REASON_GENERAL          = 0x0001,
+    OS_STATE_REASON_NETWORKING       = 0x0002,
+    OS_STATE_REASON_CELLULAR         = 0x0004,
+    OS_STATE_REASON_AUTHENTICATION   = 0x0008,
+);
+
+OS_ENUM(os_state_api, uint32_t,
+    OS_STATE_API_ERROR = 1,
+    OS_STATE_API_FAULT = 2,
+    OS_STATE_API_REQUEST = 3,
+);
+
+OS_ENUM(os_state_data_type, uint32_t,
+    OS_STATE_DATA_SERIALIZED_NSCF_OBJECT = 1,
+    OS_STATE_DATA_PROTOCOL_BUFFER = 2,
+    OS_STATE_DATA_CUSTOM = 3,
+);
+
+typedef struct os_state_hints_s {
+    uint32_t osh_version;
+    const char *osh_requestor;
+    os_state_api_t osh_api;
+    os_state_reason_t osh_reason;
+} *os_state_hints_t;
+
+typedef struct os_state_data_decoder_s {
+    char osdd_library[64];
+    char osdd_type[64];
+} *os_state_data_decoder_t;
+
+typedef struct os_state_data_s {
+    os_state_data_type_t osd_type;
+    IGNORE_CLANG_WARNINGS_BEGIN("packed")
+    union {
+        uint64_t osd_size:32;
+        uint32_t osd_data_size;
+    } __attribute__((packed, aligned(4)));
+    IGNORE_CLANG_WARNINGS_END
+    struct os_state_data_decoder_s osd_decoder;
+    char osd_title[64];
+    uint8_t osd_data[];
+} *os_state_data_t;
+
+typedef uint64_t os_state_handle_t;
+typedef os_state_data_t (^os_state_block_t)(os_state_hints_t hints);
+
+WTF_EXTERN_C_BEGIN
+
+OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
+os_state_handle_t
+os_state_add_handler(dispatch_queue_t, os_state_block_t);
+
+WTF_EXTERN_C_END
+
+#define OS_STATE_DATA_SIZE_NEEDED(data_size) (sizeof(struct os_state_data_s) + data_size)
+
+#endif
+
+#endif // USE(OS_STATE)

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (279859 => 279860)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-07-13 00:33:10 UTC (rev 279859)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-07-13 01:22:14 UTC (rev 279860)
@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 54;
+	objectVersion = 52;
 	objects = {
 
 /* Begin PBXAggregateTarget section */
@@ -2042,6 +2042,7 @@
 		F4D985C82690FC1200BBCCBE /* _WKTapHandlingResult.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D985C72690FBEF00BBCCBE /* _WKTapHandlingResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F4D985CB2691096600BBCCBE /* TapHandlingResult.h in Headers */ = {isa = PBXBuildFile; fileRef = F4E2B44A268FDE1A00327ABC /* TapHandlingResult.h */; };
 		F4DB54E62319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4DB54E42319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h */; };
+		F4EB4AFD269CD7F300D297AE /* OSStateSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F4EB4AFC269CD23600D297AE /* OSStateSPI.h */; };
 		F4EC94E32356CC57000BB614 /* ApplicationServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D04E2821F7C73D0076741D /* ApplicationServicesSPI.h */; };
 		F4FE0A3B24632B60002631E1 /* CocoaColor.h in Headers */ = {isa = PBXBuildFile; fileRef = F4FE0A3A24632B10002631E1 /* CocoaColor.h */; };
 		F6113E25126CE1820057D0A7 /* APIUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E24126CE1820057D0A7 /* APIUserContentURLPattern.h */; };
@@ -6031,6 +6032,7 @@
 		F4DB54E42319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKHighlightLongPressGestureRecognizer.h; path = ios/WKHighlightLongPressGestureRecognizer.h; sourceTree = "<group>"; };
 		F4DB54E52319E733009E3155 /* WKHighlightLongPressGestureRecognizer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKHighlightLongPressGestureRecognizer.mm; path = ios/WKHighlightLongPressGestureRecognizer.mm; sourceTree = "<group>"; };
 		F4E2B44A268FDE1A00327ABC /* TapHandlingResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TapHandlingResult.h; path = ios/TapHandlingResult.h; sourceTree = "<group>"; };
+		F4EB4AFC269CD23600D297AE /* OSStateSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSStateSPI.h; sourceTree = "<group>"; };
 		F4F59AD32065A5C9006CAA46 /* WKSelectMenuListViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSelectMenuListViewController.mm; path = ios/forms/WKSelectMenuListViewController.mm; sourceTree = "<group>"; };
 		F4F59AD42065A5CA006CAA46 /* WKSelectMenuListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKSelectMenuListViewController.h; path = ios/forms/WKSelectMenuListViewController.h; sourceTree = "<group>"; };
 		F4FE0A3A24632B10002631E1 /* CocoaColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CocoaColor.h; sourceTree = "<group>"; };
@@ -7989,6 +7991,7 @@
 				57B826402304EB3E00B72EB0 /* NearFieldSPI.h */,
 				3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
 				41DD72AA2682167300A90C71 /* NWParametersSPI.h */,
+				F4EB4AFC269CD23600D297AE /* OSStateSPI.h */,
 				5CB6AE432609799C00B6ED5A /* ReasonSPI.h */,
 				0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */,
 				448AC24D267135A600B28921 /* SynapseSPI.h */,
@@ -12217,6 +12220,7 @@
 				3754D5451B3A29FD003A4C7F /* NSInvocationSPI.h in Headers */,
 				41DD72AB2682167300A90C71 /* NWParametersSPI.h in Headers */,
 				BC8ACA1316670D89004C1941 /* ObjCObjectGraph.h in Headers */,
+				F4EB4AFD269CD7F300D297AE /* OSStateSPI.h in Headers */,
 				7CF47FFB17275C57008ACB91 /* PageBanner.h in Headers */,
 				BC6EDAA6111271C600E7678B /* PageClient.h in Headers */,
 				0FCB4E4618BBE044000FCFC9 /* PageClientImplIOS.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (279859 => 279860)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-07-13 00:33:10 UTC (rev 279859)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-07-13 01:22:14 UTC (rev 279860)
@@ -33,6 +33,7 @@
 #import "Logging.h"
 #import "NetworkConnectionToWebProcessMessages.h"
 #import "NetworkProcessConnection.h"
+#import "OSStateSPI.h"
 #import "ObjCObjectGraph.h"
 #import "ProcessAssertion.h"
 #import "SandboxExtension.h"
@@ -148,9 +149,6 @@
 #import <pal/spi/mac/NSScrollerImpSPI.h>
 #endif
 
-#if USE(OS_STATE)
-#import <os/state_private.h>
-#endif
 
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
 #import "WebCaptionPreferencesDelegate.h"
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to