Limit user-agent interactions based on the touch-action property on iOS
[WebKit-https.git] / Source / WebKit / Shared / WebCoreArgumentCoders.cpp
index 3b0529a..54d199e 100644 (file)
@@ -329,10 +329,40 @@ Optional<DOMCacheEngine::Record> ArgumentCoder<DOMCacheEngine::Record>::decode(D
     return {{ WTFMove(identifier), WTFMove(updateResponseCounter), WTFMove(requestHeadersGuard), WTFMove(request), WTFMove(options.value()), WTFMove(referrer), WTFMove(responseHeadersGuard), WTFMove(response), WTFMove(responseBody), responseBodySize }};
 }
 
+#if ENABLE(POINTER_EVENTS)
+void ArgumentCoder<TouchActionData>::encode(Encoder& encoder, const TouchActionData& touchActionData)
+{
+    encoder << touchActionData.touchActions << touchActionData.scrollingNodeID << touchActionData.region;
+}
+
+Optional<TouchActionData> ArgumentCoder<TouchActionData>::decode(Decoder& decoder)
+{
+    Optional<OptionSet<TouchAction>> touchActions;
+    decoder >> touchActions;
+    if (!touchActions)
+        return WTF::nullopt;
+
+    Optional<ScrollingNodeID> scrollingNodeID;
+    decoder >> scrollingNodeID;
+    if (!scrollingNodeID)
+        return WTF::nullopt;
+
+    Optional<Region> region;
+    decoder >> region;
+    if (!region)
+        return WTF::nullopt;
+
+    return {{ WTFMove(*touchActions), WTFMove(*scrollingNodeID), WTFMove(*region) }};
+}
+#endif
+
 void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions)
 {
     encoder << eventTrackingRegions.asynchronousDispatchRegion;
     encoder << eventTrackingRegions.eventSpecificSynchronousDispatchRegions;
+#if ENABLE(POINTER_EVENTS)
+    encoder << eventTrackingRegions.touchActionData;
+#endif
 }
 
 bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions)
@@ -343,8 +373,16 @@ bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTracking
     HashMap<String, Region> eventSpecificSynchronousDispatchRegions;
     if (!decoder.decode(eventSpecificSynchronousDispatchRegions))
         return false;
+#if ENABLE(POINTER_EVENTS)
+    Vector<TouchActionData> touchActionData;
+    if (!decoder.decode(touchActionData))
+        return false;
+#endif
     eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion);
     eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions);
+#if ENABLE(POINTER_EVENTS)
+    eventTrackingRegions.touchActionData = WTFMove(touchActionData);
+#endif
     return true;
 }
 
@@ -915,6 +953,15 @@ bool ArgumentCoder<Region>::decode(Decoder& decoder, Region& region)
     return true;
 }
 
+Optional<Region> ArgumentCoder<Region>::decode(Decoder& decoder)
+{
+    Region region;
+    if (!decode(decoder, region))
+        return WTF::nullopt;
+
+    return region;
+}
+
 void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length)
 {
     SimpleArgumentCoder<Length>::encode(encoder, length);