Diff
Modified: trunk/Source/WebKit/ChangeLog (288344 => 288345)
--- trunk/Source/WebKit/ChangeLog 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/ChangeLog 2022-01-21 03:09:32 UTC (rev 288345)
@@ -1,3 +1,48 @@
+2022-01-20 Devin Rousso <drou...@apple.com>
+
+ Add SPI for passing around and getting details about `WebCore::CSSStyleDeclaration` in injected bundle code
+ https://bugs.webkit.org/show_bug.cgi?id=235386
+ <rdar://problem/87566737>
+
+ Reviewed by Tim Horton.
+
+ Test: WebKit.WKWebProcessPlugInCSSStyleDeclarationHandle
+
+ * WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h:
+ * WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp:
+ (WebKit::InjectedBundleCSSStyleDeclarationHandle::getOrCreate):
+ (WebKit::InjectedBundleCSSStyleDeclarationHandle::coreCSSStyleDeclaration): Added.
+ Expose a way to get the related `WebCore::CSSStyleDeclaration` (for `toJS`).
+ Add a method that returns the string value for a given property name.
+
+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.h: Added.
+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h: Added.
+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.mm: Added.
+ (-[WKWebProcessPlugInCSSStyleDeclarationHandle dealloc]):
+ (+[WKWebProcessPlugInCSSStyleDeclarationHandle cssStyleDeclarationHandleWithJSValue:inContext:]):
+ (-[WKWebProcessPlugInCSSStyleDeclarationHandle _cssStyleDeclarationHandle]):
+ (-[WKWebProcessPlugInCSSStyleDeclarationHandle _apiObject]):
+ Add ObjC SPI for manipulating `WebCore::CSSStyleDeclaration` (in the injected bundle).
+
+ * WebProcess/WebPage/WebFrame.h:
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::jsWrapperForWorld):
+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h:
+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
+ (-[WKWebProcessPlugInFrame jsCSSStyleDeclarationForCSSStyleDeclarationHandle:inWorld:]): Added.
+ Add methods for converting from ObjC SPI wrappers of `WebCore::CSSStyleDeclaration` to JS.
+
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject):
+ Add support for automatic conversion of `WKBundleCSSStyleDeclarationRef` to ObjC (above).
+
+ * PlatformMac.cmake:
+ * SourcesCocoa.txt:
+ * WebKit.xcodeproj/project.pbxproj:
+
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ Drive-by: Unified sources fixes.
+
2022-01-20 Tim Horton <timothy_hor...@apple.com>
ReplayCGDisplayListsIntoBackingStore often results in compositing layers with black backgrounds
Modified: trunk/Source/WebKit/PlatformMac.cmake (288344 => 288345)
--- trunk/Source/WebKit/PlatformMac.cmake 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/PlatformMac.cmake 2022-01-21 03:09:32 UTC (rev 288345)
@@ -490,6 +490,7 @@
UIProcess/Cocoa/WKShareSheet.h
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.h
+ WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.h
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h
Modified: trunk/Source/WebKit/Shared/Cocoa/APIObject.mm (288344 => 288345)
--- trunk/Source/WebKit/Shared/Cocoa/APIObject.mm 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/Shared/Cocoa/APIObject.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -59,6 +59,7 @@
#import "WKUserContentControllerInternal.h"
#import "WKUserScriptInternal.h"
#import "WKWebProcessPlugInBrowserContextControllerInternal.h"
+#import "WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h"
#import "WKWebProcessPlugInFrameInternal.h"
#import "WKWebProcessPlugInHitTestResultInternal.h"
#import "WKWebProcessPlugInInternal.h"
@@ -422,6 +423,10 @@
wrapper = [WKWebProcessPlugInHitTestResult alloc];
break;
+ case Type::BundleCSSStyleDeclarationHandle:
+ wrapper = [WKWebProcessPlugInCSSStyleDeclarationHandle alloc];
+ break;
+
case Type::BundleNodeHandle:
wrapper = [WKWebProcessPlugInNodeHandle alloc];
break;
Modified: trunk/Source/WebKit/SourcesCocoa.txt (288344 => 288345)
--- trunk/Source/WebKit/SourcesCocoa.txt 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2022-01-21 03:09:32 UTC (rev 288345)
@@ -635,6 +635,7 @@
WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.mm
+WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.mm
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInHitTestResult.mm
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (288344 => 288345)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-01-21 03:09:32 UTC (rev 288345)
@@ -1487,6 +1487,8 @@
93E799DC276121080074008A /* StorageAreaBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E799D6276121080074008A /* StorageAreaBase.h */; };
93F549B41E3174B7000E7239 /* WKSnapshotConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
950F2880252414EA00B74F1C /* WKMouseDeviceObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */; };
+ 952BC0A12797A368003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 952BC09E2797A366003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h */; };
+ 952BC0A32797A368003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 952BC0A02797A367003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
9565083926D87A2B00E15CB7 /* AppleMediaServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9565083726D87A2B00E15CB7 /* AppleMediaServicesSPI.h */; };
9565083A26D87A2B00E15CB7 /* AppleMediaServicesUISPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9565083826D87A2B00E15CB7 /* AppleMediaServicesUISPI.h */; };
9593675F252E5E3100D3F0A0 /* WKStylusDeviceObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 9593675D252E5E3000D3F0A0 /* WKStylusDeviceObserver.h */; };
@@ -5367,6 +5369,9 @@
93F549B51E3174DA000E7239 /* WKSnapshotConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSnapshotConfiguration.mm; sourceTree = "<group>"; };
950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKMouseDeviceObserver.h; path = ios/WKMouseDeviceObserver.h; sourceTree = "<group>"; };
950F287F252414EA00B74F1C /* WKMouseDeviceObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKMouseDeviceObserver.mm; path = ios/WKMouseDeviceObserver.mm; sourceTree = "<group>"; };
+ 952BC09E2797A366003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h; sourceTree = "<group>"; };
+ 952BC09F2797A367003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInCSSStyleDeclarationHandle.mm; sourceTree = "<group>"; };
+ 952BC0A02797A367003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInCSSStyleDeclarationHandle.h; sourceTree = "<group>"; };
9565083726D87A2B00E15CB7 /* AppleMediaServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleMediaServicesSPI.h; sourceTree = "<group>"; };
9565083826D87A2B00E15CB7 /* AppleMediaServicesUISPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleMediaServicesUISPI.h; sourceTree = "<group>"; };
9593675D252E5E3000D3F0A0 /* WKStylusDeviceObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKStylusDeviceObserver.h; path = ios/WKStylusDeviceObserver.h; sourceTree = "<group>"; };
@@ -7890,6 +7895,9 @@
children = (
1AA2E56518D77508003814BD /* WKWebProcessBundleParameters.h */,
1AA2E56418D77508003814BD /* WKWebProcessBundleParameters.mm */,
+ 952BC0A02797A367003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.h */,
+ 952BC09F2797A367003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.mm */,
+ 952BC09E2797A366003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h */,
3775122E1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h */,
3795789B18AD4F1100B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h */,
1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */,
@@ -13980,6 +13988,8 @@
BC8F2F2B16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.h in Headers */,
BC8F2F2E16273ACC005FACB5 /* WKWebProcessPlugInBrowserContextControllerInternal.h in Headers */,
29501724162A4504004A9D71 /* WKWebProcessPlugInBrowserContextControllerPrivate.h in Headers */,
+ 952BC0A32797A368003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandle.h in Headers */,
+ 952BC0A12797A368003F3D25 /* WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h in Headers */,
3775122F1DF0DC8B008A351C /* WKWebProcessPlugInEditingDelegate.h in Headers */,
3795789C18AD4F1900B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h in Headers */,
1F7506B11859163700EC0FF7 /* WKWebProcessPlugInFrame.h in Headers */,
Copied: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.h (from rev 288344, trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h) (0 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.h 2022-01-21 03:09:32 UTC (rev 288345)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+#import <Foundation/Foundation.h>
+#import <_javascript_Core/_javascript_Core.h>
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface WKWebProcessPlugInCSSStyleDeclarationHandle : NSObject
+
++ (WKWebProcessPlugInCSSStyleDeclarationHandle *)cssStyleDeclarationHandleWithJSValue:(JSValue *)value inContext:(JSContext *)context;
+
+@end
Copied: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.mm (from rev 288344, trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h) (0 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.mm (rev 0)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandle.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import "config.h"
+#import "WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h"
+
+#import <WebCore/CSSStyleDeclaration.h>
+#import <WebCore/WebCoreObjCExtras.h>
+
+@implementation WKWebProcessPlugInCSSStyleDeclarationHandle {
+ API::ObjectStorage<WebKit::InjectedBundleCSSStyleDeclarationHandle> _cssStyleDeclarationHandle;
+}
+
+- (void)dealloc
+{
+ if (WebCoreObjCScheduleDeallocateOnMainRunLoop(WKWebProcessPlugInCSSStyleDeclarationHandle.class, self))
+ return;
+ _cssStyleDeclarationHandle->~InjectedBundleCSSStyleDeclarationHandle();
+ [super dealloc];
+}
+
++ (WKWebProcessPlugInCSSStyleDeclarationHandle *)cssStyleDeclarationHandleWithJSValue:(JSValue *)value inContext:(JSContext *)context
+{
+ JSContextRef contextRef = [context JSGlobalContextRef];
+ JSObjectRef objectRef = JSValueToObject(contextRef, [value JSValueRef], nullptr);
+ return wrapper(WebKit::InjectedBundleCSSStyleDeclarationHandle::getOrCreate(contextRef, objectRef));
+}
+
+- (WebKit::InjectedBundleCSSStyleDeclarationHandle&)_cssStyleDeclarationHandle
+{
+ return *_cssStyleDeclarationHandle;
+}
+
+// MARK: WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+ return *_cssStyleDeclarationHandle;
+}
+
+@end
Copied: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h (from rev 288344, trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h) (0 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h 2022-01-21 03:09:32 UTC (rev 288345)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import <WebKit/WKWebProcessPlugInCSSStyleDeclarationHandle.h>
+
+#import "InjectedBundleCSSStyleDeclarationHandle.h"
+#import "WKObject.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<InjectedBundleCSSStyleDeclarationHandle> {
+ using WrapperClass = WKWebProcessPlugInCSSStyleDeclarationHandle;
+};
+
+}
+
+@interface WKWebProcessPlugInCSSStyleDeclarationHandle () <WKObject>
+
+@property (readonly) WebKit::InjectedBundleCSSStyleDeclarationHandle& _cssStyleDeclarationHandle;
+
+@end
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h 2022-01-21 03:09:32 UTC (rev 288345)
@@ -30,6 +30,7 @@
#import <_javascript_Core/_javascript_Core.h>
@class _WKFrameHandle;
+@class WKWebProcessPlugInCSSStyleDeclarationHandle;
@class WKWebProcessPlugInHitTestResult;
@class WKWebProcessPlugInNodeHandle;
@class WKWebProcessPlugInRangeHandle;
@@ -58,6 +59,7 @@
- (JSContext *)jsContextForServiceWorkerWorld:(WKWebProcessPlugInScriptWorld *)world;
- (WKWebProcessPlugInHitTestResult *)hitTest:(CGPoint)point;
- (WKWebProcessPlugInHitTestResult *)hitTest:(CGPoint)point options:(WKHitTestOptions)options WK_API_AVAILABLE(macos(12.0), ios(15.0));
+- (JSValue *)jsCSSStyleDeclarationForCSSStyleDeclarationHandle:(WKWebProcessPlugInCSSStyleDeclarationHandle *)cssStyleDeclarationHandle inWorld:(WKWebProcessPlugInScriptWorld *)world WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (JSValue *)jsNodeForNodeHandle:(WKWebProcessPlugInNodeHandle *)nodeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world;
- (JSValue *)jsRangeForRangeHandle:(WKWebProcessPlugInRangeHandle *)rangeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world WK_API_AVAILABLE(macos(10.12.3), ios(10.3));
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -29,6 +29,7 @@
#import "WKNSArray.h"
#import "WKNSURLExtras.h"
#import "WKWebProcessPlugInBrowserContextControllerInternal.h"
+#import "WKWebProcessPlugInCSSStyleDeclarationHandleInternal.h"
#import "WKWebProcessPlugInHitTestResultInternal.h"
#import "WKWebProcessPlugInNodeHandleInternal.h"
#import "WKWebProcessPlugInRangeHandleInternal.h"
@@ -91,6 +92,12 @@
return wrapper(_frame->hitTest(WebCore::IntPoint(point), types));
}
+- (JSValue *)jsCSSStyleDeclarationForCSSStyleDeclarationHandle:(WKWebProcessPlugInCSSStyleDeclarationHandle *)cssStyleDeclarationHandle inWorld:(WKWebProcessPlugInScriptWorld *)world
+{
+ JSValueRef valueRef = _frame->jsWrapperForWorld(&[cssStyleDeclarationHandle _cssStyleDeclarationHandle], &[world _scriptWorld]);
+ return [JSValue valueWithJSValueRef:valueRef inContext:[self jsContextForWorld:world]];
+}
+
- (JSValue *)jsNodeForNodeHandle:(WKWebProcessPlugInNodeHandle *)nodeHandle inWorld:(WKWebProcessPlugInScriptWorld *)world
{
JSValueRef valueRef = _frame->jsWrapperForWorld(&[nodeHandle _nodeHandle], &[world _scriptWorld]);
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp 2022-01-21 03:09:32 UTC (rev 288345)
@@ -26,7 +26,9 @@
#include "config.h"
#include "InjectedBundleCSSStyleDeclarationHandle.h"
+#include <_javascript_Core/APICast.h>
#include <WebCore/CSSStyleDeclaration.h>
+#include <WebCore/JSCSSStyleDeclaration.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
@@ -41,6 +43,12 @@
return cache;
}
+RefPtr<InjectedBundleCSSStyleDeclarationHandle> InjectedBundleCSSStyleDeclarationHandle::getOrCreate(JSContextRef, JSObjectRef object)
+{
+ CSSStyleDeclaration* cssStyleDeclaration = JSCSSStyleDeclaration::toWrapped(toJS(object)->vm(), toJS(object));
+ return getOrCreate(cssStyleDeclaration);
+}
+
RefPtr<InjectedBundleCSSStyleDeclarationHandle> InjectedBundleCSSStyleDeclarationHandle::getOrCreate(CSSStyleDeclaration* styleDeclaration)
{
if (!styleDeclaration)
@@ -65,4 +73,9 @@
domStyleDeclarationHandleCache().remove(m_styleDeclaration.ptr());
}
+CSSStyleDeclaration* InjectedBundleCSSStyleDeclarationHandle::coreCSSStyleDeclaration()
+{
+ return m_styleDeclaration.ptr();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h 2022-01-21 03:09:32 UTC (rev 288345)
@@ -27,6 +27,7 @@
#define InjectedBundleCSSStyleDeclarationHandle_h
#include "APIObject.h"
+#include <_javascript_Core/JSBase.h>
#include <wtf/Ref.h>
#include <wtf/RefPtr.h>
@@ -38,9 +39,12 @@
class InjectedBundleCSSStyleDeclarationHandle : public API::ObjectImpl<API::Object::Type::BundleCSSStyleDeclarationHandle> {
public:
+ static RefPtr<InjectedBundleCSSStyleDeclarationHandle> getOrCreate(JSContextRef, JSObjectRef);
static RefPtr<InjectedBundleCSSStyleDeclarationHandle> getOrCreate(WebCore::CSSStyleDeclaration*);
virtual ~InjectedBundleCSSStyleDeclarationHandle();
+ WebCore::CSSStyleDeclaration* coreCSSStyleDeclaration();
+
private:
InjectedBundleCSSStyleDeclarationHandle(WebCore::CSSStyleDeclaration&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2022-01-21 03:09:32 UTC (rev 288345)
@@ -29,6 +29,7 @@
#include "APIArray.h"
#include "DownloadManager.h"
#include "FrameInfoData.h"
+#include "InjectedBundleCSSStyleDeclarationHandle.h"
#include "InjectedBundleHitTestResult.h"
#include "InjectedBundleNodeHandle.h"
#include "InjectedBundleRangeHandle.h"
@@ -718,6 +719,17 @@
return coreFrame ? WebFrame::fromCoreFrame(*coreFrame) : nullptr;
}
+JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleCSSStyleDeclarationHandle* cssStyleDeclarationHandle, InjectedBundleScriptWorld* world)
+{
+ if (!m_coreFrame)
+ return nullptr;
+
+ JSDOMWindow* globalObject = m_coreFrame->script().globalObject(world->coreWorld());
+
+ JSLockHolder lock(globalObject);
+ return toRef(globalObject, toJS(globalObject, globalObject, cssStyleDeclarationHandle->coreCSSStyleDeclaration()));
+}
+
JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, InjectedBundleScriptWorld* world)
{
if (!m_coreFrame)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h 2022-01-21 03:09:32 UTC (rev 288345)
@@ -58,6 +58,7 @@
namespace WebKit {
+class InjectedBundleCSSStyleDeclarationHandle;
class InjectedBundleHitTestResult;
class InjectedBundleNodeHandle;
class InjectedBundleRangeHandle;
@@ -146,6 +147,7 @@
static WebFrame* frameForContext(JSContextRef);
+ JSValueRef jsWrapperForWorld(InjectedBundleCSSStyleDeclarationHandle*, InjectedBundleScriptWorld*);
JSValueRef jsWrapperForWorld(InjectedBundleNodeHandle*, InjectedBundleScriptWorld*);
JSValueRef jsWrapperForWorld(InjectedBundleRangeHandle*, InjectedBundleScriptWorld*);
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (288344 => 288345)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -62,6 +62,7 @@
#import <WebCore/DisplayRefreshMonitorManager.h>
#import <WebCore/FontCache.h>
#import <WebCore/FontCascade.h>
+#import <WebCore/FrameView.h>
#import <WebCore/HistoryController.h>
#import <WebCore/HistoryItem.h>
#import <WebCore/IOSurface.h>
@@ -75,6 +76,7 @@
#import <WebCore/PerformanceLogging.h>
#import <WebCore/PictureInPictureSupport.h>
#import <WebCore/PlatformMediaSessionManager.h>
+#import <WebCore/PlatformScreen.h>
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/RuntimeEnabledFeatures.h>
#import <WebCore/SWContextManager.h>
Modified: trunk/Tools/ChangeLog (288344 => 288345)
--- trunk/Tools/ChangeLog 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Tools/ChangeLog 2022-01-21 03:09:32 UTC (rev 288345)
@@ -1,3 +1,31 @@
+2022-01-20 Devin Rousso <drou...@apple.com>
+
+ Add SPI for passing around and getting details about `WebCore::CSSStyleDeclaration` in injected bundle code
+ https://bugs.webkit.org/show_bug.cgi?id=235386
+ <rdar://problem/87566737>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandleProtocol.h: Added.
+ * TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandle.mm: Added.
+ (-[BundleCSSStyleDeclarationHandleRemoteObject verifyStyle:]):
+ (TEST.WebKit.WKWebProcessPlugInCSSStyleDeclarationHandle):
+ * TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandlePlugIn.mm: Added.
+ (-[BundleCSSStyleDeclarationHandlePlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+ (-[BundleCSSStyleDeclarationHandlePlugIn webProcessPlugInBrowserContextController:didFinishDocumentLoadForFrame:]):
+
+ * TestWebKitAPI/SourcesCocoa.txt:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/CookiePrivateBrowsing.mm:
+ (-[CookiePrivateBrowsingDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+ (TEST.WebKit.CookiePrivateBrowsing):
+ * TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm:
+ * TestWebKitAPI/Tests/WebKitCocoa/RestoreSessionStateWithoutNavigation.mm:
+ (-[SessionStateDelegate webView:didFinishNavigation:]):
+ (TestWebKitAPI::createSessionStateData):
+ Drive-by: Unified sources fixes.
+
2022-01-20 Jonathan Bedard <jbed...@apple.com>
[ews] Load credentials from passwords.json in master.cfg (Follow-up)
Modified: trunk/Tools/TestWebKitAPI/SourcesCocoa.txt (288344 => 288345)
--- trunk/Tools/TestWebKitAPI/SourcesCocoa.txt 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Tools/TestWebKitAPI/SourcesCocoa.txt 2022-01-21 03:09:32 UTC (rev 288345)
@@ -54,6 +54,7 @@
Tests/WebKitCocoa/AudioRoutingArbitration.mm
Tests/WebKitCocoa/AutoFillAvailable.mm
Tests/WebKitCocoa/AutoLayoutIntegration.mm
+Tests/WebKitCocoa/BundleCSSStyleDeclarationHandle.mm
Tests/WebKitCocoa/BundleEditingDelegate.mm
Tests/WebKitCocoa/BundleFormDelegate.mm
Tests/WebKitCocoa/BundlePageConsoleMessage.mm
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (288344 => 288345)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-01-21 03:09:32 UTC (rev 288345)
@@ -768,6 +768,7 @@
93F56DA71E5F9174003EDE84 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */; };
93F7E86F14DC8E5C00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */; };
93FCDB34263631560046DD7D /* SortedArrayMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FCDB33263631560046DD7D /* SortedArrayMap.cpp */; };
+ 9528E5FD279A0341008ADFEF /* BundleCSSStyleDeclarationHandlePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9528E5FC279A0338008ADFEF /* BundleCSSStyleDeclarationHandlePlugIn.mm */; };
952F7167270BD9CB00D00DCC /* CSSViewportUnits.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 952F7166270BD99700D00DCC /* CSSViewportUnits.html */; };
952F7167270BD9CB00D00DCD /* CSSViewportUnits.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = 952F7166270BD99700D00DCD /* CSSViewportUnits.svg */; };
95C52729275F35E100DA7E40 /* FontShadowTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C52728275F35E100DA7E40 /* FontShadowTests.cpp */; };
@@ -2540,6 +2541,9 @@
93FCDB33263631560046DD7D /* SortedArrayMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SortedArrayMap.cpp; sourceTree = "<group>"; };
95095F1F262FFFA50000D920 /* SampledPageTopColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SampledPageTopColor.mm; sourceTree = "<group>"; };
950E4CC0252E75230071659F /* iOSStylusSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = iOSStylusSupport.mm; sourceTree = "<group>"; };
+ 9528E5FA279A0337008ADFEF /* BundleCSSStyleDeclarationHandleProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BundleCSSStyleDeclarationHandleProtocol.h; sourceTree = "<group>"; };
+ 9528E5FB279A0337008ADFEF /* BundleCSSStyleDeclarationHandle.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleCSSStyleDeclarationHandle.mm; sourceTree = "<group>"; };
+ 9528E5FC279A0338008ADFEF /* BundleCSSStyleDeclarationHandlePlugIn.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleCSSStyleDeclarationHandlePlugIn.mm; sourceTree = "<group>"; };
952F7164270BD97E00D00DCC /* CSSViewportUnits.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CSSViewportUnits.mm; sourceTree = "<group>"; };
952F7166270BD99700D00DCC /* CSSViewportUnits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = CSSViewportUnits.html; sourceTree = "<group>"; };
952F7166270BD99700D00DCD /* CSSViewportUnits.svg */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = CSSViewportUnits.svg; sourceTree = "<group>"; };
@@ -3388,6 +3392,9 @@
2DD355351BD08378005DF4A7 /* AutoLayoutIntegration.mm */,
07CD32F52065B5420064A4BE /* AVFoundationPreference.mm */,
5C42594422669E9B0039AA7A /* BasicProposedCredentialPlugIn.mm */,
+ 9528E5FB279A0337008ADFEF /* BundleCSSStyleDeclarationHandle.mm */,
+ 9528E5FC279A0338008ADFEF /* BundleCSSStyleDeclarationHandlePlugIn.mm */,
+ 9528E5FA279A0337008ADFEF /* BundleCSSStyleDeclarationHandleProtocol.h */,
374B7A5E1DF36EEE00ACCB6C /* BundleEditingDelegate.mm */,
374B7A5F1DF36EEE00ACCB6C /* BundleEditingDelegatePlugIn.mm */,
374B7A621DF3734C00ACCB6C /* BundleEditingDelegateProtocol.h */,
@@ -5888,6 +5895,7 @@
491AEEF82652E33500D530A8 /* AppPrivacyReportPlugIn.mm in Sources */,
754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */,
5C4259462266A68A0039AA7A /* BasicProposedCredentialPlugIn.mm in Sources */,
+ 9528E5FD279A0341008ADFEF /* BundleCSSStyleDeclarationHandlePlugIn.mm in Sources */,
374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */,
7A89BB682331643A0042CB1E /* BundleFormDelegatePlugIn.mm in Sources */,
5175C7A226F876230003AF5C /* BundlePageConsoleMessage.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandle.mm (0 => 288345)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandle.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandle.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import "config.h"
+#import <WebKit/WKFoundation.h>
+
+#import "BundleCSSStyleDeclarationHandleProtocol.h"
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKRemoteObjectInterface.h>
+#import <WebKit/_WKRemoteObjectRegistry.h>
+#import <wtf/RetainPtr.h>
+
+static bool didVerifyStyle;
+
+@interface BundleCSSStyleDeclarationHandleRemoteObject : NSObject <BundleCSSStyleDeclarationHandleProtocol>
+@end
+
+@implementation BundleCSSStyleDeclarationHandleRemoteObject
+
+- (void)verifyStyle:(BOOL)valid
+{
+ EXPECT_TRUE(valid);
+
+ didVerifyStyle = true;
+}
+
+@end
+
+TEST(WebKit, WKWebProcessPlugInCSSStyleDeclarationHandle)
+{
+ auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundleCSSStyleDeclarationHandlePlugIn"]);
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ auto object = adoptNS([[BundleCSSStyleDeclarationHandleRemoteObject alloc] init]);
+ auto interface = retainPtr([_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(BundleCSSStyleDeclarationHandleProtocol)]);
+ [[webView _remoteObjectRegistry] registerExportedObject:object.get() interface:interface.get()];
+
+ NSString *html = @(
+ "<script>"
+ "function verifyStyle(style) {"
+ " return style === document.body.style;"
+ "}"
+ "</script>"
+ );
+ [webView loadHTMLString:html baseURL:nil];
+
+ TestWebKitAPI::Util::run(&didVerifyStyle);
+}
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandlePlugIn.mm (0 => 288345)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandlePlugIn.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandlePlugIn.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import "config.h"
+
+#import "BundleCSSStyleDeclarationHandleProtocol.h"
+#import "PlatformUtilities.h"
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
+#import <WebKit/WKWebProcessPlugInCSSStyleDeclarationHandle.h>
+#import <WebKit/WKWebProcessPlugInFrame.h>
+#import <WebKit/WKWebProcessPlugInLoadDelegate.h>
+#import <WebKit/WKWebProcessPlugInScriptWorld.h>
+#import <WebKit/_WKRemoteObjectInterface.h>
+#import <WebKit/_WKRemoteObjectRegistry.h>
+#import <wtf/RetainPtr.h>
+
+@interface BundleCSSStyleDeclarationHandlePlugIn : NSObject <WKWebProcessPlugIn, WKWebProcessPlugInLoadDelegate>
+@end
+
+@implementation BundleCSSStyleDeclarationHandlePlugIn {
+ RetainPtr<WKWebProcessPlugInBrowserContextController> _browserContextController;
+ RetainPtr<WKWebProcessPlugInController> _plugInController;
+ RetainPtr<id <BundleCSSStyleDeclarationHandleProtocol>> _remoteObject;
+}
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+ ASSERT(!_browserContextController);
+ ASSERT(!_plugInController);
+ _browserContextController = browserContextController;
+ _plugInController = plugInController;
+
+ auto interface = retainPtr([_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(BundleCSSStyleDeclarationHandleProtocol)]);
+ _remoteObject = [browserContextController._remoteObjectRegistry remoteObjectProxyWithInterface:interface.get()];
+
+ [_browserContextController setLoadDelegate:self];
+}
+
+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didFinishDocumentLoadForFrame:(WKWebProcessPlugInFrame *)frame
+{
+ auto context = [frame jsContextForWorld:WKWebProcessPlugInScriptWorld.normalWorld];
+ auto jsCSSStyleDeclaration = [context evaluateScript:@"document.body.style"];
+ auto cssStyleDeclarationHandle = [WKWebProcessPlugInCSSStyleDeclarationHandle cssStyleDeclarationHandleWithJSValue:jsCSSStyleDeclaration inContext:context];
+ auto jsCSSStyleDeclarationForCSSStyleDeclarationHandle = [frame jsCSSStyleDeclarationForCSSStyleDeclarationHandle:cssStyleDeclarationHandle inWorld:WKWebProcessPlugInScriptWorld.normalWorld];
+ if (jsCSSStyleDeclaration != jsCSSStyleDeclarationForCSSStyleDeclarationHandle)
+ [_remoteObject verifyStyle:NO];
+ else {
+ auto jsVerifyStyle = [context evaluateScript:@"verifyStyle"];
+ [_remoteObject verifyStyle:[jsVerifyStyle callWithArguments:@[jsCSSStyleDeclarationForCSSStyleDeclarationHandle]].toBool];
+ }
+}
+
+@end
Copied: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandleProtocol.h (from rev 288344, trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h) (0 => 288345)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandleProtocol.h (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleCSSStyleDeclarationHandleProtocol.h 2022-01-21 03:09:32 UTC (rev 288345)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+@protocol BundleCSSStyleDeclarationHandleProtocol <NSObject>
+- (void)verifyStyle:(BOOL)valid;
+@end
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/CookiePrivateBrowsing.mm (288344 => 288345)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/CookiePrivateBrowsing.mm 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/CookiePrivateBrowsing.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -38,7 +38,7 @@
#import <wtf/text/StringConcatenateNumbers.h>
#import <wtf/text/WTFString.h>
-static bool receivedAlert;
+static bool didRunJavaScriptAlertForCookiePrivateBrowsing;
@interface CookiePrivateBrowsingDelegate : NSObject <WKUIDelegate>
@end
@@ -48,7 +48,7 @@
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
EXPECT_STREQ(message.UTF8String, "old cookie: <>");
- receivedAlert = true;
+ didRunJavaScriptAlertForCookiePrivateBrowsing = true;
completionHandler();
}
@@ -69,10 +69,10 @@
[view2 setUIDelegate:delegate.get()];
NSString *alertOldCookie = @"<script>var oldCookie = document.cookie; document.cookie = 'key=value'; alert('old cookie: <' + oldCookie + '>');</script>";
[view1 loadHTMLString:alertOldCookie baseURL:[NSURL URLWithString:@"http://example.com/"]];
- TestWebKitAPI::Util::run(&receivedAlert);
- receivedAlert = false;
+ TestWebKitAPI::Util::run(&didRunJavaScriptAlertForCookiePrivateBrowsing);
+ didRunJavaScriptAlertForCookiePrivateBrowsing = false;
[view2 loadHTMLString:alertOldCookie baseURL:[NSURL URLWithString:@"http://example.com/"]];
- TestWebKitAPI::Util::run(&receivedAlert);
+ TestWebKitAPI::Util::run(&didRunJavaScriptAlertForCookiePrivateBrowsing);
}
TEST(WebKit, CookieCacheSyncAcrossProcess)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm (288344 => 288345)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalContainerObservation.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -27,10 +27,12 @@
#import "Test.h"
#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
#import "TestProtocol.h"
#import "TestWKWebView.h"
#import "WKWebViewConfigurationExtras.h"
#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKUIDelegatePrivate.h>
#import <WebKit/WKWebViewConfigurationPrivate.h>
#import <WebKit/WKWebpagePreferencesPrivate.h>
#import <WebKit/_WKModalContainerInfo.h>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RestoreSessionStateWithoutNavigation.mm (288344 => 288345)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RestoreSessionStateWithoutNavigation.mm 2022-01-21 03:00:14 UTC (rev 288344)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RestoreSessionStateWithoutNavigation.mm 2022-01-21 03:09:32 UTC (rev 288345)
@@ -45,7 +45,7 @@
- (WKPageRef)_pageForTesting;
@end
-static bool didFinishLoad;
+static bool didFinishNavigationForSessionState;
static bool didChangeBackForwardList;
@interface SessionStateDelegate : NSObject <WKNavigationDelegate>
@@ -55,7 +55,7 @@
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
- didFinishLoad = true;
+ didFinishNavigationForSessionState = true;
}
- (void)_webView:(WKWebView *)webView backForwardListItemAdded:(WKBackForwardListItem *)itemAdded removed:(NSArray<WKBackForwardListItem *> *)itemsRemoved
@@ -73,8 +73,8 @@
auto view = adoptNS([WKWebView new]);
[view setNavigationDelegate:delegate.get()];
[view loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
- Util::run(&didFinishLoad);
- didFinishLoad = false;
+ Util::run(&didFinishNavigationForSessionState);
+ didFinishNavigationForSessionState = false;
NSData *data = "" _sessionStateData];
return adoptWK(WKDataCreate(static_cast<const unsigned char*>(data.bytes), data.length));