Title: [286831] trunk/Source
Revision
286831
Author
wenson_hs...@apple.com
Date
2021-12-09 21:05:27 -0800 (Thu, 09 Dec 2021)

Log Message

Add a new WKWebpagePreferences SPI for modal container observation policies
https://bugs.webkit.org/show_bug.cgi?id=234013
rdar://86219613

Reviewed by Brent Fulgham.

Source/WebCore:

Add a new website policy flag `ModalContainerObservationPolicy`. Refer to rdar://86219613 for more info.

* loader/DocumentLoader.h:
(WebCore::DocumentLoader::modalContainerObservationPolicy const):
(WebCore::DocumentLoader::setModalContainerObservationPolicy):

Source/WebKit:

Add a new website policy flag `ModalContainerObservationPolicy`, and expose it as SPI on WKWebpagePreferences.
Refer to rdar://86219613 for additional details.

* Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::encode const):
(WebKit::WebsitePoliciesData::decode):
(WebKit::WebsitePoliciesData::applyToDocumentLoader):
* Shared/WebsitePoliciesData.h:
* UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::copy const):
(API::WebsitePolicies::data):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(WebKit::modalContainerObservationPolicy):
(WebKit::coreModalContainerObservationPolicy):
(-[WKWebpagePreferences _setModalContainerObservationPolicy:]):
(-[WKWebpagePreferences _modalContainerObservationPolicy]):
* UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286830 => 286831)


--- trunk/Source/WebCore/ChangeLog	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebCore/ChangeLog	2021-12-10 05:05:27 UTC (rev 286831)
@@ -1,3 +1,17 @@
+2021-12-09  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add a new WKWebpagePreferences SPI for modal container observation policies
+        https://bugs.webkit.org/show_bug.cgi?id=234013
+        rdar://86219613
+
+        Reviewed by Brent Fulgham.
+
+        Add a new website policy flag `ModalContainerObservationPolicy`. Refer to rdar://86219613 for more info.
+
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::modalContainerObservationPolicy const):
+        (WebCore::DocumentLoader::setModalContainerObservationPolicy):
+
 2021-12-09  Cathie Chen  <cathiec...@igalia.com>
 
         Stack-overflow crash in WebCore::RenderBox::computeLogicalHeight()

Modified: trunk/Source/WebCore/loader/DocumentLoader.h (286830 => 286831)


--- trunk/Source/WebCore/loader/DocumentLoader.h	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebCore/loader/DocumentLoader.h	2021-12-10 05:05:27 UTC (rev 286831)
@@ -144,6 +144,13 @@
 #endif
 };
 
+enum class ModalContainerObservationPolicy : uint8_t {
+    Disabled,
+    Prompt,
+    Allow,
+    Disallow,
+};
+
 DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(DocumentLoader);
 class DocumentLoader
     : public RefCounted<DocumentLoader>
@@ -343,6 +350,9 @@
     WEBCORE_EXPORT MouseEventPolicy mouseEventPolicy() const;
     void setMouseEventPolicy(MouseEventPolicy policy) { m_mouseEventPolicy = policy; }
 
+    ModalContainerObservationPolicy modalContainerObservationPolicy() const { return m_modalContainerObservationPolicy; }
+    void setModalContainerObservationPolicy(ModalContainerObservationPolicy policy) { m_modalContainerObservationPolicy = policy; }
+
     void addSubresourceLoader(ResourceLoader&);
     void removeSubresourceLoader(LoadCompletionType, ResourceLoader*);
     void addPlugInStreamLoader(ResourceLoader&);
@@ -667,6 +677,7 @@
     SimulatedMouseEventsDispatchPolicy m_simulatedMouseEventsDispatchPolicy { SimulatedMouseEventsDispatchPolicy::Default };
     LegacyOverflowScrollingTouchPolicy m_legacyOverflowScrollingTouchPolicy { LegacyOverflowScrollingTouchPolicy::Default };
     MouseEventPolicy m_mouseEventPolicy { MouseEventPolicy::Default };
+    ModalContainerObservationPolicy m_modalContainerObservationPolicy { ModalContainerObservationPolicy::Disabled };
 
 #if ENABLE(SERVICE_WORKER)
     std::optional<ServiceWorkerRegistrationData> m_serviceWorkerRegistrationData;
@@ -782,4 +793,14 @@
     >;
 };
 
+template<> struct EnumTraits<WebCore::ModalContainerObservationPolicy> {
+    using values = EnumValues<
+        WebCore::ModalContainerObservationPolicy,
+        WebCore::ModalContainerObservationPolicy::Disabled,
+        WebCore::ModalContainerObservationPolicy::Prompt,
+        WebCore::ModalContainerObservationPolicy::Allow,
+        WebCore::ModalContainerObservationPolicy::Disallow
+    >;
+};
+
 } // namespace WTF

Modified: trunk/Source/WebKit/ChangeLog (286830 => 286831)


--- trunk/Source/WebKit/ChangeLog	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/ChangeLog	2021-12-10 05:05:27 UTC (rev 286831)
@@ -1,3 +1,30 @@
+2021-12-09  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Add a new WKWebpagePreferences SPI for modal container observation policies
+        https://bugs.webkit.org/show_bug.cgi?id=234013
+        rdar://86219613
+
+        Reviewed by Brent Fulgham.
+
+        Add a new website policy flag `ModalContainerObservationPolicy`, and expose it as SPI on WKWebpagePreferences.
+        Refer to rdar://86219613 for additional details.
+
+        * Shared/WebsitePoliciesData.cpp:
+        (WebKit::WebsitePoliciesData::encode const):
+        (WebKit::WebsitePoliciesData::decode):
+        (WebKit::WebsitePoliciesData::applyToDocumentLoader):
+        * Shared/WebsitePoliciesData.h:
+        * UIProcess/API/APIWebsitePolicies.cpp:
+        (API::WebsitePolicies::copy const):
+        (API::WebsitePolicies::data):
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+        (WebKit::modalContainerObservationPolicy):
+        (WebKit::coreModalContainerObservationPolicy):
+        (-[WKWebpagePreferences _setModalContainerObservationPolicy:]):
+        (-[WKWebpagePreferences _modalContainerObservationPolicy]):
+        * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
+
 2021-12-09  Jigen Zhou  <jigen.z...@sony.com>
 
         [Playstation] Fix build break after r286751 with INTELLIGENT_TRACKING_PREVENTION enabled

Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp (286830 => 286831)


--- trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp	2021-12-10 05:05:27 UTC (rev 286831)
@@ -54,6 +54,7 @@
     encoder << allowContentChangeObserverQuirk;
     encoder << allowsContentJavaScript;
     encoder << mouseEventPolicy;
+    encoder << modalContainerObservationPolicy;
     encoder << idempotentModeAutosizingOnlyHonorsPercentages;
 }
 
@@ -146,6 +147,11 @@
     if (!mouseEventPolicy)
         return std::nullopt;
 
+    std::optional<WebCore::ModalContainerObservationPolicy> modalContainerObservationPolicy;
+    decoder >> modalContainerObservationPolicy;
+    if (!modalContainerObservationPolicy)
+        return std::nullopt;
+
     std::optional<bool> idempotentModeAutosizingOnlyHonorsPercentages;
     decoder >> idempotentModeAutosizingOnlyHonorsPercentages;
     if (!idempotentModeAutosizingOnlyHonorsPercentages)
@@ -171,6 +177,7 @@
         WTFMove(*allowContentChangeObserverQuirk),
         WTFMove(*allowsContentJavaScript),
         WTFMove(*mouseEventPolicy),
+        WTFMove(*modalContainerObservationPolicy),
         WTFMove(*idempotentModeAutosizingOnlyHonorsPercentages),
     } };
 }
@@ -295,6 +302,7 @@
 #endif
     }
 
+    documentLoader.setModalContainerObservationPolicy(websitePolicies.modalContainerObservationPolicy);
     documentLoader.setAllowContentChangeObserverQuirk(websitePolicies.allowContentChangeObserverQuirk);
     documentLoader.setIdempotentModeAutosizingOnlyHonorsPercentages(websitePolicies.idempotentModeAutosizingOnlyHonorsPercentages);
 

Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.h (286830 => 286831)


--- trunk/Source/WebKit/Shared/WebsitePoliciesData.h	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.h	2021-12-10 05:05:27 UTC (rev 286831)
@@ -71,6 +71,7 @@
     bool allowContentChangeObserverQuirk { false };
     WebCore::AllowsContentJavaScript allowsContentJavaScript { WebCore::AllowsContentJavaScript::Yes };
     WebCore::MouseEventPolicy mouseEventPolicy { WebCore::MouseEventPolicy::Default };
+    WebCore::ModalContainerObservationPolicy modalContainerObservationPolicy { WebCore::ModalContainerObservationPolicy::Disabled };
     bool idempotentModeAutosizingOnlyHonorsPercentages { false };
 
     void encode(IPC::Encoder&) const;

Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (286830 => 286831)


--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp	2021-12-10 05:05:27 UTC (rev 286831)
@@ -76,6 +76,7 @@
     policies->setAllowsContentJavaScript(m_allowsContentJavaScript);
     policies->setCaptivePortalModeEnabled(m_captivePortalModeEnabled);
     policies->setMouseEventPolicy(m_mouseEventPolicy);
+    policies->setModalContainerObservationPolicy(m_modalContainerObservationPolicy);
     return policies;
 }
 
@@ -121,6 +122,7 @@
         m_allowContentChangeObserverQuirk,
         m_allowsContentJavaScript,
         m_mouseEventPolicy,
+        m_modalContainerObservationPolicy,
         m_idempotentModeAutosizingOnlyHonorsPercentages
     };
 }

Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h (286830 => 286831)


--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h	2021-12-10 05:05:27 UTC (rev 286831)
@@ -135,6 +135,9 @@
     WebCore::MouseEventPolicy mouseEventPolicy() const { return m_mouseEventPolicy; }
     void setMouseEventPolicy(WebCore::MouseEventPolicy policy) { m_mouseEventPolicy = policy; }
 
+    WebCore::ModalContainerObservationPolicy modalContainerObservationPolicy() const { return m_modalContainerObservationPolicy; }
+    void setModalContainerObservationPolicy(WebCore::ModalContainerObservationPolicy policy) { m_modalContainerObservationPolicy = policy; }
+
     bool idempotentModeAutosizingOnlyHonorsPercentages() const { return m_idempotentModeAutosizingOnlyHonorsPercentages; }
     void setIdempotentModeAutosizingOnlyHonorsPercentages(bool idempotentModeAutosizingOnlyHonorsPercentages) { m_idempotentModeAutosizingOnlyHonorsPercentages = idempotentModeAutosizingOnlyHonorsPercentages; }
 
@@ -165,6 +168,7 @@
     bool m_allowContentChangeObserverQuirk { false };
     WebCore::AllowsContentJavaScript m_allowsContentJavaScript { WebCore::AllowsContentJavaScript::Yes };
     WebCore::MouseEventPolicy m_mouseEventPolicy { WebCore::MouseEventPolicy::Default };
+    WebCore::ModalContainerObservationPolicy m_modalContainerObservationPolicy { WebCore::ModalContainerObservationPolicy::Disabled };
     bool m_idempotentModeAutosizingOnlyHonorsPercentages { false };
     std::optional<bool> m_captivePortalModeEnabled;
 };

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (286830 => 286831)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm	2021-12-10 05:05:27 UTC (rev 286831)
@@ -104,6 +104,38 @@
     return WebCore::MouseEventPolicy::Default;
 }
 
+static _WKWebsiteModalContainerObservationPolicy modalContainerObservationPolicy(WebCore::ModalContainerObservationPolicy policy)
+{
+    switch (policy) {
+    case WebCore::ModalContainerObservationPolicy::Disabled:
+        return _WKWebsiteModalContainerObservationPolicyDisabled;
+    case WebCore::ModalContainerObservationPolicy::Prompt:
+        return _WKWebsiteModalContainerObservationPolicyPrompt;
+    case WebCore::ModalContainerObservationPolicy::Allow:
+        return _WKWebsiteModalContainerObservationPolicyAllow;
+    case WebCore::ModalContainerObservationPolicy::Disallow:
+        return _WKWebsiteModalContainerObservationPolicyDisallow;
+    }
+    ASSERT_NOT_REACHED();
+    return _WKWebsiteModalContainerObservationPolicyDisabled;
+}
+
+static WebCore::ModalContainerObservationPolicy coreModalContainerObservationPolicy(_WKWebsiteModalContainerObservationPolicy policy)
+{
+    switch (policy) {
+    case _WKWebsiteModalContainerObservationPolicyDisabled:
+        return WebCore::ModalContainerObservationPolicy::Disabled;
+    case _WKWebsiteModalContainerObservationPolicyPrompt:
+        return WebCore::ModalContainerObservationPolicy::Prompt;
+    case _WKWebsiteModalContainerObservationPolicyAllow:
+        return WebCore::ModalContainerObservationPolicy::Allow;
+    case _WKWebsiteModalContainerObservationPolicyDisallow:
+        return WebCore::ModalContainerObservationPolicy::Disallow;
+    }
+    ASSERT_NOT_REACHED();
+    return WebCore::ModalContainerObservationPolicy::Disabled;
+}
+
 class WebPagePreferencesCaptivePortalModeObserver final : public CaptivePortalModeObserver {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -493,6 +525,16 @@
     return WebKit::mouseEventPolicy(_websitePolicies->mouseEventPolicy());
 }
 
+- (void)_setModalContainerObservationPolicy:(_WKWebsiteModalContainerObservationPolicy)policy
+{
+    _websitePolicies->setModalContainerObservationPolicy(WebKit::coreModalContainerObservationPolicy(policy));
+}
+
+- (_WKWebsiteModalContainerObservationPolicy)_modalContainerObservationPolicy
+{
+    return WebKit::modalContainerObservationPolicy(_websitePolicies->modalContainerObservationPolicy());
+}
+
 #if USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/WKWebpagePreferencesAdditions.mm>
 #else

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (286830 => 286831)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h	2021-12-10 04:48:45 UTC (rev 286830)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h	2021-12-10 05:05:27 UTC (rev 286831)
@@ -62,6 +62,13 @@
 #endif
 } WK_API_AVAILABLE(macos(11.0), ios(14.0));
 
+typedef NS_OPTIONS(NSUInteger, _WKWebsiteModalContainerObservationPolicy) {
+    _WKWebsiteModalContainerObservationPolicyDisabled,
+    _WKWebsiteModalContainerObservationPolicyPrompt,
+    _WKWebsiteModalContainerObservationPolicyAllow,
+    _WKWebsiteModalContainerObservationPolicyDisallow,
+} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @class _WKCustomHeaderFields;
 @class WKUserContentController;
 @class WKWebsiteDataStore;
@@ -85,6 +92,7 @@
 @property (nonatomic, copy, setter=_setApplicationNameForUserAgentWithModernCompatibility:) NSString *_applicationNameForUserAgentWithModernCompatibility;
 
 @property (nonatomic, setter=_setMouseEventPolicy:) _WKWebsiteMouseEventPolicy _mouseEventPolicy WK_API_AVAILABLE(macos(11.0), ios(14.0));
+@property (nonatomic, setter=_setModalContainerObservationPolicy:) _WKWebsiteModalContainerObservationPolicy _modalContainerObservationPolicy WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, setter=_setCaptivePortalModeEnabled:) BOOL _captivePortalModeEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to